![]() |
Using Relays in Code
We ran out of speed controllers (our "genius" mechanics decided that we needed that many motors) and we are using relays and spikes right now. I am trying to use relays in the code and hitting some problems. Here is what I have now.
if(p3_sw_aux1 == 1){ relay1_fwd = 127; relay1_rev = 0; } else if(p3_sw_aux2 == 1){ relay1_fwd = 0; relay1_rev = 127; } else relay1_fwd = 254; relay1_rev = 0; the p3_sw_aux1 part appears to work and the motor doesn't move when nothing is done to it. But we are having some problems with that p3_sw_aux2 part. Any suggestions or comments would be greatly appreciated. |
Re: Using Relays in Code
Quote:
Relay outputs are 1 or 0 values, forward is 1 (on) or 0 (off), same for reverse. They have no speed control. This also means you can assign values directly from buttons. I'm not exactly sure what you were going for, but this will make aux1 make relay1 go forward, aux2 make relay1 go backward, neither button and relay outputs no power: Code:
relay_1_fwd = p3_sw_aux1; |
Re: Using Relays in Code
the relayX_fwd and relayX_rev variables don't function like pwm outputs - just assign them a value of 1 or 0.
|
Re: Using Relays in Code
And......................it works.
Thank you to Vladimir and deltacoder. |
| All times are GMT -5. The time now is 20:00. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi