From: Keith Packard Date: Thu, 9 Feb 2023 23:22:17 +0000 (-0800) Subject: altos: Fix TMega v6.0 and v5.0 IMU axes X-Git-Tag: 1.9.15~1^2~9^2 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=7e69610859e88cacbc5801bcafecaf84b9f7f455 altos: Fix TMega v6.0 and v5.0 IMU axes Add documentation to each board in ao_pins.h to clarify the required sensor axis orientations. TeleMega v5.0 had flipped the 'across' axis sensor value signs incorrectly, so remove that. TeleMega v6.0 had selected the wrong axes for across and along, along is X and across is Y for this board. Signed-off-by: Keith Packard --- diff --git a/src/easymega-v3.0/ao_pins.h b/src/easymega-v3.0/ao_pins.h index 863909d5..2fa4fd01 100644 --- a/src/easymega-v3.0/ao_pins.h +++ b/src/easymega-v3.0/ao_pins.h @@ -177,7 +177,7 @@ struct ao_adc { }; #define AO_ADC_DUMP(p) \ - printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \ + printf("tick: %5lu A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \ (p)->tick, \ (p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \ (p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \ diff --git a/src/telemega-v5.0/ao_pins.h b/src/telemega-v5.0/ao_pins.h index 3f2c9ea4..01774519 100644 --- a/src/telemega-v5.0/ao_pins.h +++ b/src/telemega-v5.0/ao_pins.h @@ -329,22 +329,27 @@ struct ao_adc { /* + * Here are the required sensor signs: * - * If the board is laying component side up with - * the antenna (nose) pointing north + * +along nose up + * +across USB down + * +through TH down * - * +along north +roll left up - * +across west +pitch nose down - * +through up +yaw left turn + * With the board aligned to have positive accel for the relevant + * axis, looking down from above we have: + * + * +roll counter clockwise (nose up) + * +pitch counter clockwise (USB down) + * +yaw counter clockwise (TH down) */ /* - * mpu6000 - * - * pin 1 NW corner of chip + * On TMega v5, MPU6000 pin 1 (NW corner of chip) is placed towards + * the USB and antenna edges of the board. Relative to MPU6000 specs, + * we don't need to change any signs and so the correct values are: * * +along +Y +roll +Y - * +across -X +pitch -X + * +across +X +pitch +X * +through +Z +yaw +Z * */ @@ -358,11 +363,11 @@ struct ao_adc { #define HAS_IMU 1 #define ao_mpu6000_along(m) ((m)->accel_y) -#define ao_mpu6000_across(m) (-(m)->accel_x) +#define ao_mpu6000_across(m) ((m)->accel_x) #define ao_mpu6000_through(m) ((m)->accel_z) #define ao_mpu6000_roll(m) ((m)->gyro_y) -#define ao_mpu6000_pitch(m) (-(m)->gyro_x) +#define ao_mpu6000_pitch(m) ((m)->gyro_x) #define ao_mpu6000_yaw(m) ((m)->gyro_z) #define ao_data_along(packet) ao_mpu6000_along(&(packet)->mpu6000) diff --git a/src/telemega-v6.0/ao_pins.h b/src/telemega-v6.0/ao_pins.h index 5bc224fe..2518e6ba 100644 --- a/src/telemega-v6.0/ao_pins.h +++ b/src/telemega-v6.0/ao_pins.h @@ -327,21 +327,28 @@ struct ao_adc { /* * - * If the board is laying component side up with - * the antenna (nose) pointing north + * Here are the required sensor signs: * - * +along north +roll left up - * +across west +pitch nose down - * +through up +yaw left turn + * +along nose up + * +across USB down + * +through TH down + * + * With the board aligned to have positive accel for the relevant + * axis, looking down from above we have: + * + * +roll counter clockwise (nose up) + * +pitch counter clockwise (USB down) + * +yaw counter clockwise (TH down) */ /* - * bmi088 - * - * pin 1 NE corner of chip + * On TMega v6, bmi088 pin 1 (NE corner of chip) is placed towards the + * USB and antenna edges of the board. Relative to bmi088 specs, to + * get the above values, we need to flip the Y axis, assigning values + * as follows: * - * +along +Y +roll +Y - * +across -X +pitch -X + * +along +X +roll +X + * +across -Y +pitch -Y * +through +Z +yaw +Z */ @@ -353,12 +360,12 @@ struct ao_adc { #define AO_BMI088_GYR_CS_PIN 13 #define HAS_IMU 1 -#define ao_bmi088_along(m) ((m)->acc.y) -#define ao_bmi088_across(m) (-(m)->acc.x) +#define ao_bmi088_along(m) ((m)->acc.x) +#define ao_bmi088_across(m) (-(m)->acc.y) #define ao_bmi088_through(m) ((m)->acc.z) -#define ao_bmi088_roll(m) ((m)->gyr.y) -#define ao_bmi088_pitch(m) (-(m)->gyr.x) +#define ao_bmi088_roll(m) ((m)->gyr.x) +#define ao_bmi088_pitch(m) (-(m)->gyr.y) #define ao_bmi088_yaw(m) ((m)->gyr.z) #define ao_data_along(packet) ao_bmi088_along(&(packet)->bmi088)