|
Re: Programming 2 buttons for a relay
Hi, Here is some code that avoids using case statements since it seemed overkill. We ran into the problem in which the red light would appear to be blinking at a fast rate and flickering. We resolved this issue by ensuring that a relay command is given only once during each execution. We did this by using select blocks. The true and false signals are enum constants in which I just copied from the relay set vi (right click on the input for the relay set vi and create as constant then make multiple copies of that to put as inputs to the select blocks). For our code, we set one button for forward and another for reverse. When either both or none of the buttons are pressed, the relay defaults to the off state. We are actually controlling two relays with the same control signals so you will see two relay set vis, just ignore the second one. I attached a picture.
This was a little too much but for forward and reverse we created boolean equations that are represented by the logical ands and ors that you see in the code.
I really hope this helps! If you have further questions feel free to ask!
|