Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Relay Assignments (http://www.chiefdelphi.com/forums/showthread.php?t=33491)

MulletFish 27-01-2005 11:58

Relay Assignments
 
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 27-01-2005 12:02

Re: Relay Assignments
 
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 27-01-2005 12:17

Re: Relay Assignments
 
Quote:

Originally Posted by MulletFish
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.

Code:

relay3_rev = p1_sw_trig | p2_sw_trig;

MulletFish 27-01-2005 12:18

Re: Relay Assignments
 
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 27-01-2005 12:24

Re: Relay Assignments
 
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 27-01-2005 12:25

Re: Relay Assignments
 
Code:

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.
Code:

relay5_rev = p3_sw_aux1 | p4_sw_aux1;

MulletFish 27-01-2005 12:52

Re: Relay Assignments
 
Quote:

Originally Posted by Alan Anderson
Use C's | "or" operator.

Code:

relay3_rev = p1_sw_trig | p2_sw_trig;

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

Max Lobovsky 27-01-2005 13:14

Re: Relay Assignments
 
Use some printf's or other diagnostic and determine if the trigger that isn't working is actually changing the variable.

Alan Anderson 27-01-2005 13:32

Re: Relay Assignments
 
Quote:

Originally Posted by MulletFish
...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 27-01-2005 14:15

Re: Relay Assignments
 
It works! You guys are awesome! Thanks so much!


All times are GMT -5. The time now is 13:14.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi