|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to toggle a relay with one button?
I need to turn a relay on and off your one button on the joystick. Much like a toggle button. Could some one give me some sample code?
|
|
#2
|
|||||
|
|||||
|
Re: How to toggle a relay with one button?
Here's a generic button toggle example:
![]() Put one Relay set in the inside True case, the opposite set in the inside False case. |
|
#3
|
|||
|
|||
|
Re: How to toggle a relay with one button?
What are the green arrows?
|
|
#4
|
|||||
|
|||||
|
Re: How to toggle a relay with one button?
The green arrow is found on the Programming -> Structures palette.
It's called a Feedback node, and what it does for you is remember the previous value, so the current value can be compared to the previous value. So for the button press the value can be thought of as 0 (false) or 1 (true). That first peculiar little combination is checking to see of the button is going from off (the previous value) to on (the current value), so it's only true the very first time you press the button and won't be true again until the button is release and pressed again. To change the arrow direction once you put it on your block diagram, right-click and choose Change direction. Last edited by Mark McLeod : 02-02-2013 at 12:14. |
|
#5
|
|||
|
|||
|
Re: How to toggle a relay with one button?
How does the arrow become green? I found the arrow, but it is black.
|
|
#6
|
|||||
|
|||||
|
Re: How to toggle a relay with one button?
It changes color based on the data type that then gets wired to it.
It's green in the example because a boolean wire got connected to it. So it'll turn green when you wire the button output to it. If you wired an integer to it, then it would turn blue. A floating point number would make it orange instead. |
|
#7
|
|||
|
|||
|
Re: How to toggle a relay with one button?
Thank you very much! It worked
|
|
#8
|
|||
|
|||
|
Re: How to toggle a relay with one button?
What about false in the outer case structure of?
|
|
#9
|
|||||
|
|||||
|
Re: How to toggle a relay with one button?
The outer false case avoids doing anything at all.
That's when the button hasn't been pushed again. The wire just gets passed from the input tunnel right to the output tunnel. Last edited by Mark McLeod : 02-02-2013 at 19:09. |
|
#10
|
||||
|
||||
|
Re: How to toggle a relay with one button?
One of our veteran team members wrote a very simple and effective Toggle vi, which I've attached. Just feed the button signal into the input, then use the output with a select block or case structure to select your relay state.
|
|
#11
|
||||
|
||||
|
Re: How to toggle a relay with one button?
I was asked to provide a screenshot of what our team's Toggle VI looks like, so here's how it works!
|
|
#12
|
||||
|
||||
|
Re: How to toggle a relay with one button?
Note: Remember that this VI would have to be set to Reentrant Execution (under VI Properties>Execution) in order to have a separate saved state at the feedback nodes for each instance of the VI. Otherwise it will not work properly at all (rising edge detection fails and all outputs will be locked together...).
|
|
#13
|
|||
|
|||
|
Re: How to toggle a relay with one button?
Ugh. The LabVIEW Developer in me can't stand feedback nodes. They make everything so much harder to understand.
|
|
#14
|
||||
|
||||
|
Re: How to toggle a relay with one button?
Quote:
|
|
#15
|
|||
|
|||
|
Re: How to toggle a relay with one button?
I understand them, but they break left to right data flow, which is considered a no-no in most of the LabVIEW world.
I prefer to use shift registers and while loops. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|