]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
lift: added pusher endswitch histeresis
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 25 Apr 2009 04:24:34 +0000 (06:24 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 25 Apr 2009 04:24:34 +0000 (06:24 +0200)
src/eb_lift_09/main.c

index 823590cac58afc1e6b5b6a7e0723d80e791de0c3..397fe818e63e3b9ce6a2c8fbeac9e5369bdfef9f 100644 (file)
@@ -299,7 +299,20 @@ int main(void){
 
                    fsm_lift.switch_front = (0 != (IO1PIN & (1<<LIFT_FRONT_SWITCH)));
                    fsm_lift.switch_back  = (0 != (IO1PIN & (1<<LIFT_BACK_SWITCH)));
-                   fsm_pusher.switch_front = (0 != (IO1PIN & (1<<PUSHER_FRONT_SWITCH)));
+                   {
+                           static int counter = 0;
+                           /* Histereze koncaku */
+                           if (0 != (IO1PIN & (1<<PUSHER_FRONT_SWITCH))) counter++;
+                           else counter--;
+                           if (counter > 10) {
+                                   counter=10;
+                                   fsm_pusher.switch_front = true;
+                           }
+                           if (counter < 0) {
+                                   fsm_pusher.switch_front = false;
+                                   counter = 0;
+                           }
+                   }
                    fsm_pusher.switch_back  = (0 != (IO1PIN & (1<<PUSHER_BACK_SWITCH)));
 
                    if (fsm_lift.switch_front) can_flags |= LIFT_LIFT_ENDSW_UP;