All-
I witnessed something very scary last night- I was demonstrating to a student how to trigger the actuator and the cylinder fired. I then checked the disable switch, and it was set correctly. I enabled, disabled, and it STILL fired.
I'm very confused- here's the relevant code section:
(global variable)
unsigned char ucGripperPosition = 1; //currently actuated meaning CLOSED
Code:
//ucGripperPosition = 0 is NON actuated, meaning OPEN
//Confirm double switch state to toggle the gripper position
if ( (1 == p2_sw_trig) && (1 == p2_sw_top ) && (1 == ucGripperLatch ) ) {
if ( 1 == ucGripperPosition) { //Gripper is actuated, so open it
ucGripperPosition = 0;
ucGripperLatch = 0;
} else {
ucGripperPosition = 1;
ucGripperLatch = 0;
} //endifelse gripper position
} else if ( (0 == p2_sw_trig) && (0 == p2_sw_top ) ) {
ucGripperLatch = 1;
//printf(" De-Latching Switch\r\n");
} //endif - ignore the current state of the sw_trigs because they both
//werent enabled at the same time
GRIPPERTOGGLE = ucGripperPosition; //Set the position of the gripper
As you can see we require both buttons to be depressed to fire the cylinder, and both buttons to be released before you can fire the cylinder again. It's an 'oopsy' prevention that hasn't dropped a tube yet...
Suggestions? This code runs inline with the rest of our code.