Quote:
|
Originally Posted by evilhunter
Ok i have one more question on the programing the double solinoid
this is what i have
relay1_fwd = p3_sw_trig; //lower arm extend double solenoid
relay1_rev = p3_sw_top; //lower arm retract double solenoid
relay2_fwd = p3_sw_aux1; //upper arm extent double solenoid
relay2_rev = p3_sw_aux2; //upper arm retract double solenoid
//relay3_fwd
//relay3_rev
//relay4_fwd
//relay4_rev
relay5_fwd = p4_sw_aux1 //lift plate up festo solenoid
relay5_rev = p4_sw_aux2 // lift plate down festo solenoid
ok will this work or will it cuase it to keep going one way and back the other way. If so how would i code this. Thanks
|
If you set them equal to each other, it will fire only if the button is pressed continuously. If you instead put them into if statements, all will resolve!
Please note, the festo is not a double, red code reflects change.
Code:
if(p3_sw_trig)
{
relay1_fwd = 1;
relay1_rev = 0;
}
if(p3_sw_top)
{
relay1_fwd = 0;
relay1_rev = 1;
}
if(p3_sw_aux1)
{
relay2_fwd = 1;
relay2_rev = 0;
}
if(p3_sw_aux2)
{
relay2_fwd = 0;
relay2_rev = 1;
}
if(p4_sw_aux1) relay5_fwd = 1;
if(p4_sw_aux2) relay5_fwd = 0;
Another way to decrease the amount of triggers used and make it easier for the operator, have the same button do both actions by
a) setting flags and then using if statements
b) declaring a bool, using logical operators
c) writing an abs function and using a
Code:
relay = abs(relay - 1);