summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--n/asserv/src/Makefile2
-rw-r--r--n/asserv/src/goto.c32
-rw-r--r--n/asserv/src/main.c15
-rw-r--r--n/asserv/src/taz.c11
4 files changed, 36 insertions, 24 deletions
diff --git a/n/asserv/src/Makefile b/n/asserv/src/Makefile
index 88e343b..e1e9bde 100644
--- a/n/asserv/src/Makefile
+++ b/n/asserv/src/Makefile
@@ -10,7 +10,7 @@ CONFIGFILE = avrconfig.h
MCU_TARGET = atmega128
# -O2 : speed
# -Os : size
-OPTIMIZE = -O2
+OPTIMIZE = -O3
DEFS =
LDLIBS =
diff --git a/n/asserv/src/goto.c b/n/asserv/src/goto.c
index 552f853..07ab840 100644
--- a/n/asserv/src/goto.c
+++ b/n/asserv/src/goto.c
@@ -54,7 +54,7 @@ uint8_t goto_finish;
/* -AutoDec */
/** Linear control mode. */
-static void
+void
goto_linear_mode (void)
{
uint16_t d;
@@ -72,7 +72,8 @@ goto_linear_mode (void)
speed_right = 0;
speed_left_aim = 0;
speed_right_aim = 0;
- goto_finish = 1;
+ if (!goto_finish)
+ goto_finish = 1;
}
else
{
@@ -98,7 +99,7 @@ goto_linear (int16_t d)
}
/** Angular control mode. */
-static void
+void
goto_angular_mode (void)
{
int32_t angle_diff;
@@ -113,7 +114,8 @@ goto_angular_mode (void)
speed_right = 0;
speed_left_aim = 0;
speed_right_aim = 0;
- goto_finish = 1;
+ if (!goto_finish)
+ goto_finish = 1;
}
else
{
@@ -135,7 +137,7 @@ goto_angular (int8_t a)
}
/** Position control mode. */
-static void
+static inline void
goto_position_mode (void)
{
int32_t c, s, arc;
@@ -149,7 +151,8 @@ goto_position_mode (void)
speed_right = 0;
speed_left_aim = 0;
speed_right_aim = 0;
- goto_finish = 1;
+ if (!goto_finish)
+ goto_finish = 1;
}
else
{
@@ -228,7 +231,8 @@ goto_position_exact_mode (void)
{
speed_left_aim = 0;
speed_right_aim = 0;
- goto_finish = 1;
+ if (!goto_finish)
+ goto_finish = 1;
}
else
{
@@ -243,7 +247,7 @@ goto_position_exact_mode (void)
}
/** Counter control mode. */
-static void
+void
goto_counter_mode (void)
{
int16_t dl, dr;
@@ -253,7 +257,8 @@ goto_counter_mode (void)
if (dl < 3 && dl > -3
&& dr < 3 && dr > -3)
{
- goto_finish = 1;
+ if (!goto_finish)
+ goto_finish = 1;
}
dl248 = dl;
dr248 = dr;
@@ -272,7 +277,7 @@ goto_counter (int16_t l, int16_t r)
}
/** We fuck the wall mode. */
-static void
+void
goto_ftw_mode (void)
{
/* Change speed. */
@@ -295,7 +300,8 @@ goto_ftw_mode (void)
speed_right_aim = 0;
}
if (!(PINA & (_BV (0) | _BV (7))))
- goto_finish = 1;
+ if (!goto_finish)
+ goto_finish = 1;
}
/** Setup ftw mode. */
@@ -309,7 +315,7 @@ goto_ftw (int8_t s)
}
/** Update the speed according to the desired destination. */
-static void
+void
goto_update (void)
{
switch (goto_mode)
@@ -321,7 +327,7 @@ goto_update (void)
goto_angular_mode ();
break;
case 2:
- goto_position_mode ();
+ //goto_position_mode ();
break;
case 4:
goto_counter_mode ();
diff --git a/n/asserv/src/main.c b/n/asserv/src/main.c
index d437f24..c0da1ec 100644
--- a/n/asserv/src/main.c
+++ b/n/asserv/src/main.c
@@ -52,6 +52,9 @@ uint8_t motor_taz;
/** Main loop counter. */
uint8_t motor_loop_cpt;
+/** Report finish. */
+uint8_t motor_finish_counter = 8, motor_finish_counter_cpt = 8;
+
/** Report of counters. */
uint8_t motor_stat_counter, motor_stat_counter_cpt;
@@ -135,8 +138,6 @@ main_loop (void)
if (motor_mode >= 2)
{
goto_update ();
- if (goto_finish)
- proto_send0 ('F');
}
motor_timer_2 = timer_read ();
/* Speed control. */
@@ -146,6 +147,12 @@ main_loop (void)
/* Pwm setup. */
pwm_update ();
/* Stats. */
+ if (motor_finish_counter && !--motor_finish_counter_cpt)
+ {
+ if (goto_finish == 1)
+ proto_send0 ('F');
+ motor_finish_counter_cpt = motor_finish_counter;
+ }
if (motor_stat_counter && !--motor_stat_counter_cpt)
{
proto_send2w ('C', counter_left, counter_right);
@@ -189,9 +196,7 @@ main_loop (void)
{
if (twi_master_is_finished ())
{
- proto_send5w ('H', motor_sharps[0], motor_sharps[1],
- motor_sharps[2], motor_sharps[3],
- motor_sharps[4]);
+ proto_send ('H', 10, (uint8_t *) motor_sharps);
twi_master_read (0x02, (uint8_t *) motor_sharps, 10);
}
motor_print_sharps_cpt = motor_print_sharps;
diff --git a/n/asserv/src/taz.c b/n/asserv/src/taz.c
index e8f44cc..1fcae4d 100644
--- a/n/asserv/src/taz.c
+++ b/n/asserv/src/taz.c
@@ -57,7 +57,7 @@ static const uint16_t taz_start_y_16 = taz_scale * 450 / 2;
static const uint16_t taz_before_bridge_16 = taz_scale * 1200;
static const uint16_t taz_brige_interval_16 = taz_scale * 150;
//#define OR2 (1500 + 22 + 600 + 22)
-#define OR2 (1500 + 600)
+#define OR2 (1500 + 600 + 22)
static const uint16_t taz_after_bridge_16[4] =
{
taz_scale * (OR2),
@@ -122,7 +122,7 @@ taz_state_0 (void)
/* Recalage. */
speed_restart ();
postrack_y = -taz_rear_32;
- postrack_a = 0x00c00000;
+ postrack_a = 0x00bf0000;
/* On avance juste qu'à l'y de départ. */
goto_linear (taz_start_y_16 - taz_rear_16);
}
@@ -150,7 +150,7 @@ taz_state_0 (void)
/* Recalage. */
speed_restart ();
postrack_x = taz_rear_32;
- postrack_a = 0;
+ postrack_a = 0x00ff0000;
}
break;
case 6:
@@ -236,7 +236,7 @@ taz_state_1 (void)
/* Recalage. */
speed_restart ();
postrack_y = -taz_rear_32;
- postrack_a = 0x00c00000;
+ postrack_a = 0x00be0000;
}
// no break;
case 6:
@@ -246,7 +246,8 @@ taz_state_1 (void)
/* On avance juste qu'à l'y de traversée de pont. */
goto_linear (taz_start_y_16
+ taz_pont * taz_brige_interval_16
- + (postrack_y >> 8));
+ + (postrack_y >> 8)
+ + (taz_pont == 0 ? 15 * taz_scale : 0));
}
break;
case 7: