Not to be contradictory -- but I guess I may be. I had to dig out our last year's pneumatic code to check how we did it. In autonomous, the routine was called with variable Position either 1 or 0:
Code:
if (Position==1) //Open pinchers/release tube?
{
relay1_fwd= 1; //Pressurize to open
relay1_rev= 0; //This always zero
}
else if (Position==0) //Close pinchers/pinch tube?
{
relay1_fwd= 0; //Depressurize to open (release tube)
relay1_rev= 0; //This always zero
}
The
relay1_rev was always zero, and only
relay1_fwd switched between one and zero. I always thought it was odd, but hey, it did work.
But another place was in user_routines.c/User_Initialization routine -- make sure your
digital_io was set to INPUT:
Code:
digital_io_18 = INPUT; /* Used for pneumatic pressure switch. */
We also had a slightly different way with the joystick trigger, to click it each time to reverse state:
Code:
if (p2_sw_trig != SqueezeTrigLast) //Trigger changed state? (squeeze/no squeeze)
{ //Yes:
if (p2_sw_trig == 1) //...Trigger pressed
{
SqueezeState= 1 - SqueezeState; //Toggle state 0 to 1 to 0
}
//printf("SS=%d fwd=%d rev=%d",SqueezeState, relay1_fwd, relay1_rev);
// Part 2 Open... or... shut???
if (SqueezeState==0) //Is state to be OPEN?
{ //Yes:
relay1_fwd= 1; //Pressurize
relay1_rev= 0; //This stays zero
//printf ("OPEN\r\n");
}
else //State is NOT OPEN
{
relay1_fwd= 0; //Depressurize
relay1_rev= 0; //This stays zero
//printf ("SHUT\r\n");
}
SqueezeTrigLast= p2_sw_trig; //Save trigger state for next time check
}
This way you don't have to hold the trig button.
And yes, because programmers are always

perfect, have the hardware guys make sure they did everything right.
________________________________
Every revolutionary idea seems to evoke three stages of reaction. They may be summed up by the phrases: (1) It's completely impossible. (2) It's possible, but it's not worth doing. (3) I said it was a good idea all along. RIP Arthur C. Clarke