LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to partial stroke a valve using limit switches

Hi there. I am trying to write a small piece of code which will allow me to perform a partial stroke on a valve from the open position. To perform this test, the valve has to be in the open position, and a partial stroke button needs to be pushed once. Once the partial limit switch indicates high, the valve should return to open. This is done by energising/de-energising a solenoid. The solenoid is energised when the valve is open.
This is the first time I have used labview and I am struggling to write any code. By using the manuals, I have managed to acquire and write signals, but I am struggling with the logic for this test. I realise this will probably be pretty simple for experience users, so any examples and or advice would be good.
Thanks.
0 Kudos
Message 1 of 25
(3,954 Views)
Use an Event Structure to capture the button press, and in the event structure for the button press write to the valve telling it to close.  The Timeout case of the event structure (which happens when the specified time goes by without any of the other events firing) read your limit switch, and when it goes high, write to open the valve.
0 Kudos
Message 2 of 25
(3,946 Views)
thanks Jeff. Can you save the file as labview 7.1 as the version I am using is on an old lap top which was used by someone a few years back.
0 Kudos
Message 3 of 25
(3,944 Views)
0 Kudos
Message 4 of 25
(3,939 Views)
Thanks Jeff,
 
I have had a look and tried to implement. It works ok for the partial closure part, but I also have a seperate switch for basic open close functionality, and the partial limit switch will also go high as it moves from close to open. How would I go about adding this switch so that my logic still works?
 
ie. Switch 1 = Valve open (high) Valve Closed (low). Solenoid is energised to go high, de-energised to go low.
     Switch 2 = partial closure switch. the valve must be open for this operation to be allowed. When this switch is pressed, the solenoid is de-energised until it hits the partial closure limit switch. the solenoid then re-energises and the valve returns to open position.
 
Attached is something an old collegue used to perform partial closures. I think he used timing here. I would like to use the partial limit switch to re-energise during my test rather than timing. Can you advise how to modify this code to do this?
0 Kudos
Message 5 of 25
(3,933 Views)

You can add a shift register to your while loop to store which valve action you're currently using.  An enum would be a good choice, because they're easy to debug.  Basically, an enum shows you text, but acts as an integer.  So if you had three states, you could pick from Open All, Open Limit, and Close, and they would act in your code as integers 0,1, and 2.  Then, in your timeout, just add another case structure that uses the enum as a case selector and code from there.

http://zone.ni.com/reference/en-XX/help/lv/71/glang/Enum_Constant/

http://zone.ni.com/reference/en-XX/help/lv/71/lvhelp/Creating_Shift_Registers/

0 Kudos
Message 6 of 25
(3,917 Views)
Jeff, could you post an example. I have had a play around with this but no success so far.
0 Kudos
Message 7 of 25
(3,903 Views)
this is a really simple way to do it, but at the level of complexity you're approaching I would begin to recommend a state machine
0 Kudos
Message 8 of 25
(3,899 Views)
Jeff,
why do you have the control logic both when the actuate button is pressed and in the timeout frame?
Jim

LV 2020
0 Kudos
Message 9 of 25
(3,897 Views)
From what I understand of his setup, the solenoid can be energized (which will start opening the valve) or it can be deenergized (which will allow the valve to close on its own).  So rather than have SubVIs which have to be called and have their own memory space, simply energize the solenoid on both Open commands and then have the timeout case poll the sensor to determine whether the valve has reached the "Limit Open" or "Fully Open" range, in which case it deenergizes.
0 Kudos
Message 10 of 25
(3,886 Views)