From 82eca8372fdd8c56a136b09b534e4369ce4a2486 Mon Sep 17 00:00:00 2001 From: prot Date: Sun, 12 Dec 2004 00:34:30 +0000 Subject: Added protocol for mode 3 and 4 Renaming variables -> Quite good for test ! --- n/line-follower/src/main.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'n/line-follower/src/main.c') diff --git a/n/line-follower/src/main.c b/n/line-follower/src/main.c index a8aceb2..1c89604 100644 --- a/n/line-follower/src/main.c +++ b/n/line-follower/src/main.c @@ -34,12 +34,14 @@ #include "counter.c" #include "speed.c" #include "postrack.c" +#include "linesensor.c" /** Motor mode : * 0 - pwm setup; * 1 - speed control; * 2 - position control; - * 3 - linefol mode. */ + * 3 - linefol mode; + * 4 - linefol calibration mode. */ int8_t motor_mode; /** Main loop counter. */ @@ -108,15 +110,22 @@ main_loop (void) postrack_update (); motor_timer_2 = timer_read (); /* Speed control. */ - if (motor_mode == 3) - { - speed_compute_linefol_pwm (); - } - else if (motor_mode >= 1) + switch (motor_mode) { + case 1: + case 2: speed_update (); speed_compute_left_pwm (); speed_compute_right_pwm (); + case 3: + linesensor_poll (); + speed_compute_linefol_pwm (); + case 4: + delay_ms (5L); + linesensor_print (); + default: + motor_mode = motor_mode; // j'ai pas trouvé comment faire + // autrement... } motor_timer_1 = timer_read (); /* Pwm setup. */ @@ -202,6 +211,24 @@ proto_callback (uint8_t cmd, uint8_t argc, proto_arg_t argv[]) speed_left_aim = argv[0]; speed_right_aim = argv[1]; break; + case c ('l', 0): + motor_mode = 3; + linesensor_init (); + break; + case c ('l', 1): + motor_mode = 3; + linesensor_init (); + linefol_max_pwm = argv[0]; + break; + case c ('l', 5): + motor_mode = 3; + linesensor_init (); + linefol_max_pwm = argv[0]; + speed_kp = argv[1]; + speed_ki = argv[2]; + speed_kd = argv[3]; + K_ATT_LINEPOS_DER = argv[4]; + break; case c ('a', 1): speed_acc_cpt = speed_acc = argv[0]; break; @@ -211,6 +238,9 @@ proto_callback (uint8_t cmd, uint8_t argc, proto_arg_t argv[]) case c ('i', 2): speed_ki = argv[0] << 8 | argv[1]; break; + case c ('d', 2): + speed_kd = argv[0] << 8 | argv[1]; + break; case c ('f', 2): postrack_set_footing (argv[0] << 8 | argv[1]); break; -- cgit v1.2.3