summaryrefslogtreecommitdiff
path: root/2004/n/asserv/src
diff options
context:
space:
mode:
authorschodet2004-06-27 11:49:56 +0000
committerschodet2004-06-27 11:49:56 +0000
commit9c5225470159aad23dac1c3903a518c1b8be6236 (patch)
treebc054428def6a07120673d450d6747f74514e3c3 /2004/n/asserv/src
parente6a66ec7e5c9b95509c4a6f558f7a8ddc1045766 (diff)
Add: réglage de la fréquence des rapports codeurs.
Diffstat (limited to '2004/n/asserv/src')
-rw-r--r--2004/n/asserv/src/motor.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/2004/n/asserv/src/motor.c b/2004/n/asserv/src/motor.c
index aab34cf..8411a8c 100644
--- a/2004/n/asserv/src/motor.c
+++ b/2004/n/asserv/src/motor.c
@@ -46,9 +46,10 @@ unsigned int motor_pid_int; /* Compteur d'interruptions timer2 entre deux
calculs de PID. */
/* Statistiques, etc... */
-unsigned int motor_stat_delay; /* Delay between stats. */
-unsigned int motor_stat_delay_cpt; /* Delay counter. */
-short motor_cpt; /* Report motors counters. */
+unsigned int motor_stat_delay; /* Delais entre les stats. */
+unsigned int motor_stat_delay_cpt; /* Compteur de stats. */
+unsigned int motor_cpt_delay; /* Delais entre rapport codeurs. */
+unsigned int motor_cpt_delay_cpt; /* Compteur entre les rapports. */
/* Entres. */
unsigned int motor_gpi_delay; /* Delais entre deux envois. */
@@ -84,11 +85,9 @@ motor_init (void)
motor_a_cpt = 8;
motor_int_max = 1000;
motor_pid_int = 0;
- motor_stat_delay = 0;
- motor_stat_delay_cpt = 0;
- motor_cpt = 0;
- motor_gpi_delay = 0;
- motor_gpi_delay_cpt = 0;
+ motor_stat_delay = 0; motor_stat_delay_cpt = 0;
+ motor_cpt_delay = 0; motor_cpt_delay_cpt = 0;
+ motor_gpi_delay = 0; motor_gpi_delay_cpt = 0;
motor_g_vdes = 0; motor_g_vacc = 0;
motor_d_vdes = 0; motor_d_vacc = 0;
motor_g_cpt_av = 0; motor_g_cpt_ar = 0;
@@ -394,6 +393,16 @@ motor_main (void)
motor_stat_delay_cpt = motor_stat_delay;
}
}
+ /* Rapport des codeurs. */
+ if (motor_cpt_delay)
+ {
+ if (!--motor_cpt_delay_cpt)
+ {
+ serial_send_motor_cpt (motor_g_cpt, motor_d_cpt);
+ serial_unreliable_send_eob ();
+ motor_cpt_delay_cpt = motor_cpt_delay;
+ }
+ }
/* Acclre. */
if (motor_a)
{
@@ -422,11 +431,6 @@ motor_main (void)
serial_send_motor_ttl ();
}
serial_parse ();
- if (motor_cpt)
- {
- serial_send_motor_cpt (motor_g_cpt, motor_d_cpt);
- serial_unreliable_send_eob ();
- }
/* GPI. */
if (motor_gpi_delay)
{
@@ -488,7 +492,8 @@ motor_parse (void)
serial_send_ok ();
return 1;
case 'c':
- serial_recv_bool (motor_cpt);
+ serial_recv_int (motor_cpt_delay);
+ motor_cpt_delay_cpt = motor_cpt_delay;
serial_send_ok ();
return 1;
case 'g':