From 4db3737c3757527a270e058c0318013a545dd792 Mon Sep 17 00:00:00 2001 From: prot Date: Tue, 14 Dec 2004 10:51:26 +0000 Subject: Reorgqnizing --- n/line-follower/src/linesensor.c | 12 ------------ n/line-follower/src/main.c | 6 +++--- n/line-follower/src/speed.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 16 deletions(-) (limited to 'n/line-follower') diff --git a/n/line-follower/src/linesensor.c b/n/line-follower/src/linesensor.c index c43165a..545d48f 100644 --- a/n/line-follower/src/linesensor.c +++ b/n/line-follower/src/linesensor.c @@ -32,10 +32,6 @@ static int8_t lineActiveBits; /* +AutoDec */ -/** Initialize the line sensor. */ -static inline void -linesensor_init (void); - /** Poll linesensor, should be called as often as possible. */ static inline void linesensor_poll (void); @@ -47,14 +43,6 @@ linesensor_print (void); /* -AutoDec */ -/** Initialize the line sensor. */ -static inline void -linesensor_init (void) -{ - linepos=0; - sei (); -} - /** Poll linesensor, should be called as often as possible. */ static inline void linesensor_poll (void) diff --git a/n/line-follower/src/main.c b/n/line-follower/src/main.c index 1c89604..96c4629 100644 --- a/n/line-follower/src/main.c +++ b/n/line-follower/src/main.c @@ -213,16 +213,16 @@ proto_callback (uint8_t cmd, uint8_t argc, proto_arg_t argv[]) break; case c ('l', 0): motor_mode = 3; - linesensor_init (); + linesensor_reset (); break; case c ('l', 1): motor_mode = 3; - linesensor_init (); + linesensor_reset (); linefol_max_pwm = argv[0]; break; case c ('l', 5): motor_mode = 3; - linesensor_init (); + linesensor_reset (); linefol_max_pwm = argv[0]; speed_kp = argv[1]; speed_ki = argv[2]; diff --git a/n/line-follower/src/speed.c b/n/line-follower/src/speed.c index 99c7023..25ec08c 100644 --- a/n/line-follower/src/speed.c +++ b/n/line-follower/src/speed.c @@ -32,7 +32,7 @@ int16_t linefol_max_pwm = 80; /** Attenuation for filtering the derivate term (f88). */ uint16_t K_ATT_LINEPOS_DER = 0x00FE; // ~= 95% /** Table and index for calculating the derivate term. */ -#define N_LINEPOS_DER_TAB 8 // max : 256 +#define N_LINEPOS_DER_TAB 8 // max : 255 (8bit-addressing) int16_t linepos_der_tab[N_LINEPOS_DER_TAB]; uint8_t linepos_der_index; @@ -61,14 +61,26 @@ uint16_t speed_kd = 1 * 255; /* +AutoDec */ +/** Update speeds according to the wanted speeds and the acceleration. */ +static inline void +speed_update (void); + /** Initialise speed parameters. */ static inline void speed_init (void); +/** Initialize the line sensor parameters. */ +static inline void +linesensor_reset (void); + /** Update speeds according to the wanted speeds and the acceleration. */ static inline void speed_update (void); +/** Compute new pwm value for motors in linefol mode. */ +static inline void +speed_compute_linefol_pwm (void); + /** Compute new pwm value for left motor. */ static inline void speed_compute_left_pwm (void); @@ -84,6 +96,7 @@ speed_restart (void); /* -AutoDec */ + /** Initialise speed parameters. */ static inline void speed_init (void) @@ -94,6 +107,21 @@ speed_init (void) speed_ki = 1 * 255; } +/** Initialize the line sensor parameters. */ +static inline void +linesensor_reset (void) +{ + uint8_t i; + + for(i=0;i