I am trying to get the micro switches to work as limit switches also and I am not sure if I am doing this right as it isn't working at all and could use some help...
I have connected these switches to digital input 01 & 02 normally open with the signal and ground from each respective input and I am relying on the internal pullups on the RC inputs to give me a "1" condition if the switches are not activated.
We noticed that the joystick wheel is at a value of 43 if untouched (neutral) and in the down position is ~ 148 and in the up position is ~ 255, hence the loose values in my code below.
When connected to the dashboard viewer, the switch 1 and switch 2 leds light when I close my switches so I know that electrically these are working but I must have my logic wrong.
Here is my code:
Quote:
if ((p3_wheel > 240) && (rc_dig_in01 = 1)) /* jaw close */
{
relay1_fwd = 0; /* FWD only if switch1 is not closed. */
relay1_rev = 1;
}
else
{
if ((p3_wheel < 200) && (rc_dig_in02 = 1)) /* jaw open */
{
relay1_fwd = 1; /* REV only if switch2 is not closed. */
relay1_rev = 0;
}
}
if ((p3_wheel < 50) || (rc_dig_in02 = 0) || (rc_dig_in01 = 0))
{
relay1_fwd = 0; /* don't move jaw if p3 wheel is not pressed */
relay1_rev = 0;
}
|
This code works just fine if I do not include the rc_dig_in01 and rc_dig_in02 conditions in my if statements.
What am I doing wrong here?
Thanks!