06-24-2013 11:08 AM
Hi.
I'm nowhere near completing this VI, but here's eventually what will happen: There are 6 valves connected by pneumatic logic controllers. In my VI, there are buttons that will control sets of valves (for example, a button might set valves 1, 3, 4 ON and 2, 5, 6 OFF), but I also want to be able to switch the valves individually. Currenty, I have it set up so the valve controls are slide switches (Switch when pressed, & colored differently for ON and OFF) and the buttons to control sets of valves are text buttons (Latch when pressed). There is also an OFF button that stops the whole VI (it is all within a while loop controlled by this button).
Anyways, the main issue that I am trying to address is: I would like the slide switches to switch when the text buttons are pressed. However, as I understand it, this would force these slide switches to be both a control AND and indicator. Is there a way to do this?
[Also, I'm having issues with the text buttons not returning to the unpressed state after they are pressed. Possibly because they are within the while loop, so they don't reset…]
Thanks,
Quevvy
Solved! Go to Solution.
06-24-2013 11:23 AM - edited 06-24-2013 11:24 AM
This is one of those rare times when it is OK to use a local variable to write a value to a control.
Be careful with booleans though. The mechanical action cannot be any "Latch" type (For good reason--- if you think about it) In your case you only need to write to the switchers anyway.
Now about those Latchers that are not resetting. They won't reset until they are actually read! That means they have to be in a block diagram area that will execute. If you are using an event structure, put the latching booleans in the case that handles the value change event.
06-24-2013 11:25 AM
06-24-2013 03:48 PM - edited 06-24-2013 03:49 PM
I was able to automate some of the pneumatic switches using local variables, but the buttons still don't latch properly. For example, I have a "Close All" button, which closes all of the valves. The button is able to close all of the valves, but does not return to its initial state. With my understanding, the buttons should latch back to the original state after the case with the local variables runs.
[Found a solution:]
I did this by having the case set the button to FALSE after it changed the 6 switches, using a local variable. Is this an okay solution? I mean, it does what I want it to do, but I'm wary of setting a boolean to false within its own case structure…
06-24-2013 06:08 PM
I would think the "close all" button could be latch action. Why would that need a local variable?
06-24-2013 06:28 PM - edited 06-24-2013 06:31 PM
Here's a quick example how it could be done (LabVIEW 8.2). Modify as needed. Remember to use arrays whenever practical to reduce clutter.
06-24-2013 06:30 PM
@Quevvy wrote:
[Also, I'm having issues with the text buttons not returning to the unpressed state after they are pressed. Possibly because they are within the while loop, so they don't reset…]
In order for the buttons to reset, they need to be read by the code. As long as they are in the while loop, they should reset. If they don't, show us some code. (They will not reset if you place them outside the loop, because they would only get read once at the start of the program, and never again.)
06-25-2013 05:27 AM
06-25-2013 09:55 AM - edited 06-25-2013 09:59 AM
"First Attempt" is what I wrote out. I have a few parts in the works, so I disabled those. I am using local variables, not the event structure that "ComboSwitches.vi" used (I also am not using arrays, sorry.), so it may be a bit confusing. I may work on making it an array so it's more manageable…
On another note, my VI can no longer access the pneumatic switches as it used to. Whenever I run my VI, all the valves close, but then cannot be changed. "kpcipiodirectio" is the example VI to write/read from an instrument I'm using. Yesterday, the instrument was able to be written to, but cannot today. I have not touched the computer at all over night; nobody has. All I did was copy the block diagram to my VI and change the inputs to constants.
Also, I'm fairly new to LabVIEW, so I don't know how to use event structures well yet…
06-25-2013 10:55 AM
I tried using an array. It does look neater, but I'm still having issues with the instrument actually reading the number that it has sent. This might be why the buttons aren't popping back up. There's now an indicator showing the number that the array sends to the instrument (in binary, each digit represents a valve); this number is the correct number, but is not getting to the machine correctly.
I'm going to add a wait time to check if that's the problem.