From a26bbeacef99cc9c8cacfa6b12b42e783bcf4398 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sun, 2 May 2010 10:08:29 +0200 Subject: digital/io/src: change auxilliary motor interfaces --- digital/io/src/asserv.c | 39 +++++++-------------------------------- digital/io/src/asserv.h | 23 +++++++++-------------- digital/io/src/bot.h | 9 +++++++++ digital/io/src/main.c | 7 ++++--- digital/io/src/mimot.c | 8 ++++---- digital/io/src/mimot.h | 4 ++-- 6 files changed, 35 insertions(+), 55 deletions(-) diff --git a/digital/io/src/asserv.c b/digital/io/src/asserv.c index c9e95f51..f826ba15 100644 --- a/digital/io/src/asserv.c +++ b/digital/io/src/asserv.c @@ -53,11 +53,11 @@ enum asserv_status_flag_e asserv_status_flag_move_backward = 3, /** Motor0 movement finished with success. */ asserv_status_flag_motor0_succeed = 4, - /** Motor0 movement finished with failure (can not happen). */ + /** Motor0 movement finished with failure. */ asserv_status_flag_motor0_failed = 5, /** Motor1 movement finished with success. */ asserv_status_flag_motor1_succeed = 6, - /** Motor1 movement finished with failure (can not happen). */ + /** Motor1 movement finished with failure. */ asserv_status_flag_motor1_failed = 7, }; typedef enum asserv_status_flag_e asserv_status_flag_e; @@ -106,21 +106,6 @@ typedef struct asserv_struct_s */ asserv_struct_s asserv_status; -/** - * Move the motor0. - * @param position desired goal position (in step). - * @param speed speed of the movement. - */ -static void -asserv_move_motor0_absolute (uint16_t position, uint8_t speed); - -/** - * Current position of the motor0. - * We need to maintain it by ourself as it is more accurate than the one sent - * by the asserv board. - */ -static uint16_t asserv_motor0_current_position; - void asserv_init (void) { @@ -311,8 +296,7 @@ asserv_go_to_the_wall (uint8_t backward) twi_master_send (2); } -/* Move the motor0. */ -static void +void asserv_move_motor0_absolute (uint16_t position, uint8_t speed) { uint8_t *buffer = twi_master_get_buffer (ASSERV_SLAVE); @@ -323,15 +307,6 @@ asserv_move_motor0_absolute (uint16_t position, uint8_t speed) twi_master_send (4); } -void -asserv_move_motor0 (int16_t offset, uint8_t speed) -{ - /* Compute the new desired position with the desired offset */ - asserv_motor0_current_position += offset; - /* Move the motor0 to the desired position */ - asserv_move_motor0_absolute (asserv_motor0_current_position, speed); -} - void asserv_move_motor1_absolute (uint16_t position, uint8_t speed) { @@ -440,20 +415,20 @@ asserv_set_scale (uint32_t scale) } void -asserv_motor0_zero_position (void) +asserv_motor0_zero_position (int8_t speed) { uint8_t *buffer = twi_master_get_buffer (ASSERV_SLAVE); buffer[0] = 'B'; - buffer[1] = 0x05; + buffer[1] = speed; twi_master_send (2); } void -asserv_motor1_zero_position (void) +asserv_motor1_zero_position (int8_t speed) { uint8_t *buffer = twi_master_get_buffer (ASSERV_SLAVE); buffer[0] = 'C'; - buffer[1] = -0x10; + buffer[1] = speed; twi_master_send (2); } diff --git a/digital/io/src/asserv.h b/digital/io/src/asserv.h index 9ea12e2b..14bd959d 100644 --- a/digital/io/src/asserv.h +++ b/digital/io/src/asserv.h @@ -200,16 +200,15 @@ void asserv_go_to_the_wall (uint8_t backward); /** - * Move the motor0 to a certain number of steps. + * Move the motor0. * Motor0 class command. - * This function take the number of steps you want to move to. This is not an - * absolute position, this is only the number of steps you want to add to the - * current position. - * @param offset number of steps to add to the current position. + * This function take the number of steps you want to move to. This is an + * absolute position. + * @param position desired goal position (in step). * @param speed speed of the movement. */ void -asserv_move_motor0 (int16_t offset, uint8_t speed); +asserv_move_motor0_absolute (uint16_t position, uint8_t speed); /** * Move the motor1. @@ -286,16 +285,12 @@ asserv_goto (uint32_t x, uint32_t y, uint8_t backward); void asserv_set_scale (uint32_t scale); -/** - * Reset the motor0 to the zero position. - */ +/** Reset the motor0 to the zero position. */ void -asserv_motor0_zero_position (void); +asserv_motor0_zero_position (int8_t speed); -/** - * Reset the motor1 to the zero position. - */ +/** Reset the motor1 to the zero position. */ void -asserv_motor1_zero_position (void); +asserv_motor1_zero_position (int8_t speed); #endif /* asserv_h */ diff --git a/digital/io/src/bot.h b/digital/io/src/bot.h index 6a9eef89..fa8ad845 100644 --- a/digital/io/src/bot.h +++ b/digital/io/src/bot.h @@ -59,6 +59,15 @@ */ #define BOT_MIN_DISTANCE_TURN_FREE 300 +/** Elevator stroke in steps. */ +#define BOT_ELEVATOR_STROKE_STEP 11800 + +/** Elevator work speed. */ +#define BOT_ELEVATOR_SPEED 0x40 + +/** Elevator find zero speed. */ +#define BOT_ELEVATOR_ZERO_SPEED 0x10 + /** * Definition of the colors. */ diff --git a/digital/io/src/main.c b/digital/io/src/main.c index b4d558f1..bf7d06ae 100644 --- a/digital/io/src/main.c +++ b/digital/io/src/main.c @@ -466,10 +466,10 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) switch (args[1]) { case 'e': - asserv_motor1_zero_position (); + asserv_motor0_zero_position (-BOT_ELEVATOR_ZERO_SPEED); break; case 'a': - asserv_motor0_zero_position (); + asserv_motor1_zero_position (0x10); break; } break; @@ -498,7 +498,8 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) * - 2b: offset angle ; * - 1b: speed. */ - asserv_move_motor0 (v8_to_v16 (args[1], args[2]), args[3]); + asserv_move_motor0_absolute (v8_to_v16 (args[1], args[2]), + args[3]); break; case 'c': /* Move the motor1 diff --git a/digital/io/src/mimot.c b/digital/io/src/mimot.c index ac94c517..96746f51 100644 --- a/digital/io/src/mimot.c +++ b/digital/io/src/mimot.c @@ -140,20 +140,20 @@ mimot_move_motor1_absolute (uint16_t position, uint8_t speed) } void -mimot_motor0_zero_position (void) +mimot_motor0_zero_position (int8_t speed) { uint8_t *buffer = twi_master_get_buffer (MIMOT_SLAVE); buffer[0] = 'B'; - buffer[1] = 0x10; + buffer[1] = speed; twi_master_send (2); } void -mimot_motor1_zero_position (void) +mimot_motor1_zero_position (int8_t speed) { uint8_t *buffer = twi_master_get_buffer (MIMOT_SLAVE); buffer[0] = 'C'; - buffer[1] = 0x10; + buffer[1] = speed; twi_master_send (2); } diff --git a/digital/io/src/mimot.h b/digital/io/src/mimot.h index 58c7a7f9..1eb490c6 100644 --- a/digital/io/src/mimot.h +++ b/digital/io/src/mimot.h @@ -78,10 +78,10 @@ mimot_move_motor1_absolute (uint16_t position, uint8_t speed); /** Reset motor0 to zero position. */ void -mimot_motor0_zero_position (void); +mimot_motor0_zero_position (int8_t speed); /** Reset motor1 to zero position. */ void -mimot_motor1_zero_position (void); +mimot_motor1_zero_position (int8_t speed); #endif /* mimot_h */ -- cgit v1.2.3