summaryrefslogtreecommitdiff
path: root/n/line-follower
diff options
context:
space:
mode:
Diffstat (limited to 'n/line-follower')
-rw-r--r--n/line-follower/src/main.c2
-rw-r--r--n/line-follower/src/speed.c7
2 files changed, 8 insertions, 1 deletions
diff --git a/n/line-follower/src/main.c b/n/line-follower/src/main.c
index f0059f9..a8aceb2 100644
--- a/n/line-follower/src/main.c
+++ b/n/line-follower/src/main.c
@@ -108,7 +108,7 @@ main_loop (void)
postrack_update ();
motor_timer_2 = timer_read ();
/* Speed control. */
- if (motor_mode = 3)
+ if (motor_mode == 3)
{
speed_compute_linefol_pwm ();
}
diff --git a/n/line-follower/src/speed.c b/n/line-follower/src/speed.c
index a2f2c54..1a66486 100644
--- a/n/line-follower/src/speed.c
+++ b/n/line-follower/src/speed.c
@@ -23,6 +23,8 @@
*
* }}} */
+#include "linesensor.c"
+
/** Maximum value the pwm can reach (defined by the avr configuration) */
#define PWM_MAX 255
/** Maximum value for the pwm in linefol mode (controls avg speed) */
@@ -31,6 +33,9 @@ int16_t linefol_max_pwm = 80;
#define N_LINEPOS_DER_TAB 8 // max : 256
int16_t linepos_der_tab[N_LINEPOS_DER_TAB];
uint8_t linepos_der_index;
+/** Attenuation for filtering the derivate term */
+#define K_ATT_LINEPOS_DER 0.95
+
/** Actual speed. */
int8_t speed_left, speed_right;
/** Wanted speed. */
@@ -49,6 +54,8 @@ int16_t speed_left_e_old, speed_right_e_old;
uint16_t speed_kp = 2 * 255;
/** I coeficients. 4.8 fixed point format. */
uint16_t speed_ki = 1 * 255;
+/** D coeficient. 4.8 fixed point format. */
+uint16_t speed_kd = 1 * 255;
/* +AutoDec */