PDA

View Full Version : Relay Assignments


MulletFish
01-27-2005, 11:58 AM
I am trying to assign more than one joystick button to a single relay_rev. I have tried using an "=" sign, I have tried adding a new line but the program recognizes one but not the other. How can I do it? Thanks!

Max Lobovsky
01-27-2005, 12:02 PM
The default code includes some code that controls some of the relays, make sure you check if that is overriding some of your stuff.

Alan Anderson
01-27-2005, 12:17 PM
I am trying to assign more than one joystick button to a single relay_rev. I have tried using an "=" sign, I have tried adding a new line but the program recognizes one but not the other. How can I do it? Thanks!
Use C's | "or" operator.

relay3_rev = p1_sw_trig | p2_sw_trig;

MulletFish
01-27-2005, 12:18 PM
Here is the code I have:

relay5_rev = p3_sw_aux1;
relay5_rev = p4_sw_aux1;

There are no other references to the relay in the "Buttons to Relays" section. It seems to me that it should work???

Max Lobovsky
01-27-2005, 12:24 PM
Ah, I misunderstood what you are trying to do (thought you meant multiple relays to one button, not vice versa). Alan Anderson has it right. Use the "or" operator just as he suggested.

Alan Anderson
01-27-2005, 12:25 PM
relay5_rev = p3_sw_aux1;
relay5_rev = p4_sw_aux1;
The first assignment sets the value based on the switch on port 3. The second assignment then sets the value based on the switch on port 4, regardless of what the first assignment did. p3_sw_aux1 is completely irrelevant to the final result.

You need to set the value based on a combination of the two switches. The | "or" operator will return a value of zero if both its operands are zero, and a value of one if either or both are one.
relay5_rev = p3_sw_aux1 | p4_sw_aux1;

MulletFish
01-27-2005, 12:52 PM
Use C's | "or" operator.

relay3_rev = p1_sw_trig | p2_sw_trig;

Thanks Alabn. I tried that and it still does not work.

Max Lobovsky
01-27-2005, 01:14 PM
Use some printf's or other diagnostic and determine if the trigger that isn't working is actually changing the variable.

Alan Anderson
01-27-2005, 01:32 PM
...it still does not work.
You'll have to give more details than that if you want useful help. What are you expecting to happen? How are you testing to see if it happens? What happens instead of what you expect?

Specifically, what do you have connected to the Spike, and what else is it connected to?

MulletFish
01-27-2005, 02:15 PM
It works! You guys are awesome! Thanks so much!