summaryrefslogtreecommitdiff
path: root/n/accel/calcul.c
diff options
context:
space:
mode:
Diffstat (limited to 'n/accel/calcul.c')
-rw-r--r--n/accel/calcul.c63
1 files changed, 36 insertions, 27 deletions
diff --git a/n/accel/calcul.c b/n/accel/calcul.c
index aeff534..fe18b40 100644
--- a/n/accel/calcul.c
+++ b/n/accel/calcul.c
@@ -23,7 +23,6 @@
*
* }}} */
#include "calcul.h"
-#include <inttypes.h>
/* +AutoDec */
/* -AutoDec */
@@ -33,47 +32,57 @@ uint16_t T1x_cal;
uint16_t T1y_cal;
uint32_t K;
-volatile enum T_etat etat;
-
-int16_t G0x;
-int16_t G0y;
-
void
calibration(void)
{
- uint16_t i = 0;
- uint32_t T1x = 0;
- uint32_t T1y = 0;
+ mode =1;
+ uint32_t i = 0;
uint32_t T2c = 0;
- while (i < 1024 )
+ while (i < 32768)
+ {
+ if( etat == record_T2_x)
+ {
+ T2c += T2x;
+ i++;
+ }
+ }
+ T2x = T2c / 32768;
+ i=0;
+ T2c = 0;
+ ACSR |= 0x04; //change d'entrée : analogue comparator
+ mode=2;
+ while (i < 32768)
{
- if( etat == calcul)
+ if( etat == record_T2_y)
{
- T1x += Tb;
- T1y += Td - Tc;
- //T2 += (Td - (Td - Tc)/2) - Tb/2;
- T2c += (Td + Tc - Tb) /2;
+ T2c += T2y;
i++;
- etat = strt_at_Ta;
}
}
- T2_cal = T2c / 1024;
- T1x_cal = T1x / 1024;
- T1y_cal = T1y / 1024;
- K = (uint16_t)((uint32_t)( 4 * ( T2_cal * BIT_SCALE_FACTOR) / T2_cal));
+ ACSR &= ~0x04; //change d'entrée : IPC
+ T2y = T2c / 32768;
+ T2 = (T2x+T2y)/2;
+ mode = 0;
+ uint8_t j = 0;
+ while (j==0)
+ {
+ if(calcul_rdy == 1)
+ {
+ T1x_cal = Tx;
+ T1y_cal = Ty;
+ j++;
+ }
+ }
+ K = BIT_SCALE_FACTOR * 8 / T2;
Vx = 0;
Vy = 0;
-
}
int16_t
-calculG ( uint16_t T1, uint16_t T2, int16_t Go)
+calculG ( uint16_t T1, uint16_t T1_cal)
{
- /*uint32_t Zactual;
- Zactual = Zcal * T2 / T2_cal;
- return ( (int16_t) K * (int16_t)( T1 - Zactual) / (int16_t)T2);
-*/
- return (K * T1) / T2 - Go ;
+
+ return (T1 - T1_cal) * K ;
}
int16_t
calculGb(uint16_t T1, uint16_t T2, uint16_t T1cal)