PDA

View Full Version : How do I program a relay to turn on and off by pressing a button on the joystick?


eweathers
01-28-2009, 04:11 PM
Basically I want to program a relay connected to relay port 1 to go forward by pressing button 1 (trigger) and go reverse by pressing button 2 on the joystick.


Can anyone help me program this?

Thank you in advance.

Geekzilla201
01-28-2009, 06:32 PM
LabVIEW or WindRiver?

Boydean
01-28-2009, 09:14 PM
First things first. What do you really want to do. Do you want button 1 to make it forward without it being pressed down, and then backward when button 2 is pressed...so all its doing is changing the state. Or do you want it to go one way while you press button 1 and the other way while you press button 2. And its natural would be stopped.

AndrewN
01-28-2009, 09:29 PM
Try something like this example in the Basic Framework:

http://www.chiefdelphi.com/forums/attachment.php?attachmentid=7256&stc=1&d=1233199098

The "Off", "Forward", "Reverse" are constants created from the input to the relay "Set" VI.

The Up/Down arrows on the while loop are "Shift Registers" created using the menu on the while loop border. These are used to contain the current setting of the relay.

The T/F selectors are on the Programming Comparison Palette. These allow you to select the old value or the new one based off the buttons.

The buttons are obtained using the cluster "unbundle by name" function.
There is no button to turn the relay off ... you'll have to extend the example.

Don't forget the other cases in the main loop. The example is not complete.

TotalChaos
01-28-2009, 09:34 PM
Basically I want to program a relay connected to relay port 1 to go forward by pressing button 1 (trigger) and go reverse by pressing button 2 on the joystick.

First off, welcome to ChiefDelphi!

Second, I've seen this exact question asked a couple of times now. I have and example VI that is documented and shows how to do this. You can download it from my post in THIS THREAD (http://www.chiefdelphi.com/forums/showthread.php?t=73008).

Good luck!

- Austin