View Full Version : Switch Latching
codalafin
04-02-2012, 11:08
I want to use a physical switch to act how a boolean control does. Specifically I need the ability to use "latch when released", activating a case structure when the switch goes from True to False. I have no idea where to begin with doing this, but I've opened the digital input, set the channel it runs on, set it under a variable name, and gotten its true-false value. Where do I work from there?
Also, if the answer would be in LabView help, I'm sorry but for some stupid reason the help doesn't load on this computer. I waited 15 minutes for the "Boolean Controls" page to load hoping that might have an answer and it never did.
The way I do it is to use a global variable.
I Use a case structure that is asking for the boolean and every time it turns true the value of the boolean is inverted.
Now in the picture I have it in teleoperated which causes some problems because you can't instantly press and release the button. So it cycles through true and false very quickly and I recommend some way of knowing the value.
Follow the Button Toggle Action example HERE (http://team358.org/files/programming/ControlSystem2009-/LabVIEW/)
codalafin
04-02-2012, 13:26
I don't think a toggle button will solve my issue. That would save the state until I pressed it again, which is most certainly not what I want.
Pretty much, in waveform description, I want the case structure to activate when the digital wave goes from 1 to 0.
I also can't use what that picture shows, since the variable will keep changing every moment the switch is pressed.
Okay I see what you want now. You want the action to only change when it goes from 1 to 0 and not when it goes from 0 to 1.
codalafin
04-02-2012, 14:40
I've tried multiple possible options, including storing a variable, but I can't figure out a way that works.
codalafin
04-02-2012, 15:41
Okay so I may have found what I need, can't test it at the moment but http://team358.org/files/programming/ControlSystem2009-/LabVIEW/ActionOnButtonRelease.jpg that node + less than system should work fine. genius design
DonRotolo
04-02-2012, 18:45
Maybe this is solved, but what if you stop checking the condition of the switch after it has activated the first time?
Pseudocode:
If SwitchedOn is ON, jump to move_along
.Check switch
.If switch is 1, set SwitchedOn to ON
move_along
...the rest of the code...
Alan Anderson
04-02-2012, 20:48
Okay so I may have found what I need, can't test it at the moment but http://team358.org/files/programming/ControlSystem2009-/LabVIEW/ActionOnButtonRelease.jpg that node + less than system should work fine. genius design
That's exactly what you want. I've made teeny little SubVIs that just take a boolean input and do the feedback node/comparison step, calling them "RisingEdge" and "FallingEdge". Their icons are very small.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.