From: Bernard Blackham Date: Mon, 21 Jun 2004 16:39:22 +0000 (+0000) Subject: Make a delay before testing home sensors X-Git-Tag: ROMW~32 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=8e227175f6eeb47fc66679478840dce339941f44;p=uccvend-snackrom.git Make a delay before testing home sensors --- diff --git a/ROM2/motors.c b/ROM2/motors.c index 725c93e..e7cb6b5 100644 --- a/ROM2/motors.c +++ b/ROM2/motors.c @@ -93,16 +93,19 @@ bool is_motor(u8 slot) { return motor_here(slot); } -bool left_home(u8 slot) { +bool start_motor(u8 slot) { u16 i; u8 r = slot%10; if (r >= 5) r--; r = 1 << (r-1); + motor_on(slot); + delay(100); for (i = 0; i < 1000; i++) { if ((home_sensors & r) != 0) return 1; delay(1); } /* it never left */ + motors_off(); return 0; } @@ -113,6 +116,7 @@ bool back_home(u8 slot) { for (i = 0; i < 5; i++) { if ((home_sensors & r) == 0) return 1; + delay(1); } /* it never arrived */ @@ -134,13 +138,7 @@ bool motor_overcurrent() { u8 dispense_motor(u8 slot) { if (!is_motor(slot)) return MOTOR_NOSLOT; - - motor_on(slot); - - if (!left_home(slot)) { - motors_off(); - return MOTOR_HOME_FAIL; - } + if (!start_motor(slot)) return MOTOR_HOME_FAIL; while (1) { if (motor_overcurrent()) {