LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queue state machine event structure and latched switches

I use the example queue state machine + event structure + boolean switch, the examples which I have seen used  boolean switches which latch when press and when the program read the switch status;  the switch goes back to the initial state (False).

in my application, I would like to have the switches behave like a light switch, turn on and stay on until the user turn off and stay off.  I don't want the program to read and reset the switch.

When I change the mechanical action of the switches, the example Queuestatemachine.vi behaves differently (or does not work properyly)

My question: what do I need to modify to get the switches behave as light switches?


0 Kudos
Message 1 of 16
(3,670 Views)
I haven't seen the vi you are refering to, maybe you should attach it.  It all depends on the code.  If you change the mechanical action to on/off (like a light switch), you have to manually or programatically turn the switch off at some point after turning it on.  If the event case is set to trigger on value change, then it will trigger when the switch is turned on, and trigger again when the switch is turned off.  If the switch is set for a latch condition, the event is triggered only when the switch turns on (if off is the default state).  After reading, LV turns the switch off and the event does not fire a second time.  At least I think it doesn't.  This could be why it behaves differently.  Attach your vi and try to explain what you want to happen when the switch is turned on and then off.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 16
(3,643 Views)
I attached the VI here.
I would like to change the boolean control behavior to behave as a light switch = switch when pressed.
  except the "stop" switch
In the block diagram, do I  move the Boolean controls outside of the event structure loop?
 ( the program does not need to read the switches)

or should I leave the boolean controls inside the event structure (in the block diagram)?


0 Kudos
Message 3 of 16
(3,632 Views)
Your event cases are mostly set to "Value Change." The logic inside does not distinguish between the True state and the False state of the buttons, so either value change (True to False or False to True) will cause the event case to execute. If you put the Enqueue Element function inside a case structure with the boolean wired to the selector, I think it would be closer to what you want.

You did not include the custom controls and some subVIs so the program will not run.

Lynn
Message 4 of 16
(3,623 Views)
You could use the New Value block (on the left side of the event border) to determine if the switch is either True or False, then use a case statement to run code only if True.
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 16
(3,617 Views)
Lynn and tbob, thank you for helping I try again to attached the VI, I found the VI from here http://zone.ni.com/devzone/cda/epd/p/id/3909 the name of the article is: "Using queue to create a more flexible state machine." I would like to run both the cases of the switches   True and False ( not reset the switches) as the user changes the switches   (sixteen of them) I send their status to the NI DAQ card as output bits. the VI uses switches with "latched until read"     I would like to use as "switch when pressed" regards
0 Kudos
Message 6 of 16
(3,595 Views)
try this:
 
 
- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 16
(3,577 Views)
tbob,

I try your VI, it works very well,
when I add gauges and tank, it did not update the gauges and tank indicators.
Does it need a second loop to update gauges and tank indicators?

also, I would like to have the program turn off the compressor at a specified limit.



0 Kudos
Message 8 of 16
(3,543 Views)
Oh, the tank lower limit should be zero and the tank upper limit is 1290.  to have a shut off at 1200

just some numbers to be clear.
0 Kudos
Message 9 of 16
(3,539 Views)
The guages don't update because you don't have anything wired to them.  The tank does update every 2.005 seconds because of your timer in the main loop.
- tbob

Inventor of the WORM Global
0 Kudos
Message 10 of 16
(3,528 Views)