summaryrefslogtreecommitdiff
path: root/digital/mimot/src/dirty/simu.host.c
diff options
context:
space:
mode:
authorNicolas Schodet2012-03-05 23:49:17 +0100
committerNicolas Schodet2012-03-06 23:16:56 +0100
commit830048da9a94cd9fb91678694dfd07d577e3070c (patch)
tree79012f8b303dbca5379b20661085022b47d04e1e /digital/mimot/src/dirty/simu.host.c
parent4895e54c666db9720abda0aa8ae901058679aee3 (diff)
digital/mimot: convert to new control system
Diffstat (limited to 'digital/mimot/src/dirty/simu.host.c')
-rw-r--r--digital/mimot/src/dirty/simu.host.c72
1 files changed, 14 insertions, 58 deletions
diff --git a/digital/mimot/src/dirty/simu.host.c b/digital/mimot/src/dirty/simu.host.c
index d27ffe5f..c4ac5026 100644
--- a/digital/mimot/src/dirty/simu.host.c
+++ b/digital/mimot/src/dirty/simu.host.c
@@ -38,38 +38,24 @@
#include <stdio.h>
#include <string.h>
-#include "pwm.h"
+#include "cs.h"
#include "aux.h"
#include "contacts.h"
-#include "motor_model.host.h"
#include "models.host.h"
/** Simulate some AVR regs. */
uint8_t PORTB, PORTC, PORTD, PINC;
-/** Overall counter values. */
-uint16_t counter_aux[AC_ASSERV_AUX_NB];
-/** Counter differences since last update.
- * Maximum of 9 significant bits, sign included. */
-int16_t counter_aux_diff[AC_ASSERV_AUX_NB];
-
-/** PWM control states. */
-struct pwm_t pwm_aux[AC_ASSERV_AUX_NB] = {
- PWM_INIT_FOR (pwm_aux0), PWM_INIT_FOR (pwm_aux1)
-};
-/** PWM reverse directions. */
-uint8_t pwm_reverse;
-
/* Robot model. */
const struct robot_t *simu_robot;
/** Motor models. */
-struct motor_t simu_aux_model[AC_ASSERV_AUX_NB];
+motor_model_t simu_aux_model[AC_ASSERV_AUX_NB];
-/** Full counter values. */
-uint32_t simu_counter_aux[AC_ASSERV_AUX_NB];
+/** Full encoder values. */
+uint32_t simu_encoder_aux[AC_ASSERV_AUX_NB];
/** Use mex. */
int simu_mex;
@@ -169,8 +155,8 @@ simu_step (void)
double old_aux_th[AC_ASSERV_AUX_NB];
/* Convert pwm value into voltage. */
for (i = 0; i < AC_ASSERV_AUX_NB; i++)
- simu_aux_model[i].u = simu_aux_model[i].m.u_max
- * ((double) pwm_aux[i].cur / (PWM_MAX + 1));
+ simu_aux_model[i].u = simu_robot->u_max
+ * ((double) output_aux[i].cur / (OUTPUT_MAX + 1));
/* Make one step. */
for (i = 0; i < AC_ASSERV_AUX_NB; i++)
{
@@ -178,22 +164,22 @@ simu_step (void)
if (simu_robot->aux_motor[i])
motor_model_step (&simu_aux_model[i]);
}
- /* Update auxiliary counter. */
+ /* Update auxiliary encoder. */
for (i = 0; i < AC_ASSERV_AUX_NB; i++)
{
if (simu_robot->aux_motor[i])
{
- uint32_t counter_aux_new = simu_aux_model[i].th / (2*M_PI)
+ uint32_t encoder_aux_new = simu_aux_model[i].th / (2*M_PI)
* simu_robot->aux_encoder_steps[i];
- counter_aux_diff[i] = counter_aux_new - simu_counter_aux[i];
- counter_aux[i] += counter_aux_diff[i];
- simu_counter_aux[i] = counter_aux_new;
+ encoder_aux[i].diff = encoder_aux_new - simu_encoder_aux[i];
+ encoder_aux[i].cur += encoder_aux[i].diff;
+ simu_encoder_aux[i] = encoder_aux_new;
}
else
{
- counter_aux_diff[i] = 0;
- counter_aux[i] = 0;
- simu_counter_aux[i] = 0;
+ encoder_aux[i].diff = 0;
+ encoder_aux[i].cur = 0;
+ simu_encoder_aux[i] = 0;
}
}
/* Update sensors. */
@@ -264,30 +250,6 @@ timer_read (void)
return 0;
}
-/** Initialize the counters. */
-void
-counter_init (void)
-{
-}
-
-/** Update overall counter values and compute diffs. */
-void
-counter_update (void)
-{
-}
-
-/** Initialise PWM generator. */
-void
-pwm_init (void)
-{
-}
-
-/** Update the hardware PWM values. */
-void
-pwm_update (void)
-{
-}
-
void
eeprom_read_params (void)
{
@@ -303,9 +265,3 @@ eeprom_clear_params (void)
{
}
-void
-pwm_set_reverse (uint8_t reverse)
-{
- pwm_reverse = reverse;
-}
-