From: Keith Packard Date: Mon, 5 Sep 2022 04:05:25 +0000 (-0700) Subject: ao-eeprom: Add easy motor support X-Git-Tag: 1.9.12~1^2~27 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=681638032041efcb05b9623e2a0332ca4e2d0958 ao-eeprom: Add easy motor support Signed-off-by: Keith Packard --- diff --git a/ao-tools/ao-eeprom/ao-eeprom.c b/ao-tools/ao-eeprom/ao-eeprom.c index e249af9e..f6367630 100644 --- a/ao-tools/ao-eeprom/ao-eeprom.c +++ b/ao-tools/ao-eeprom/ao-eeprom.c @@ -148,7 +148,7 @@ ao_thrust(int16_t value, int16_t max_adc, double ref, double r1, double r2) } static void -ao_pressure(int16_t value, int16_t max_adc, double ref, double r1, double r2) +ao_pressure(int16_t value, int16_t max_adc, double ref, double r1, double r2, double sensor_range) { printf(" pressure %5d", value); if (r1 && r2 && ref) { @@ -156,7 +156,7 @@ ao_pressure(int16_t value, int16_t max_adc, double ref, double r1, double r2) if (volts < 0.5) volts = 0.5; if (volts > 4.5) volts = 4.5; - double psi = (volts - 0.5) / 4.0 * 2500.0; + double psi = (volts - 0.5) / 4.0 * sensor_range; double pa = psi_to_pa(psi); printf(" %9.3f kPa", pa / 1000.0); } @@ -261,6 +261,7 @@ main (int argc, char **argv) double sense_r1 = 0.0, sense_r2 = 0.0; double batt_r1 = 0.0, batt_r2 = 0.0; double adc_ref = 0.0; + double pressure_sensor = 0.0; int16_t max_adc = 0; switch (eeprom->log_format) { @@ -315,6 +316,7 @@ main (int argc, char **argv) break; case AO_LOG_FORMAT_TELEFIRETWO: len = 32; + pressure_sensor = 2500.0; max_adc = 4095; adc_ref = 3.3; sense_r1 = batt_r1 = 5600; @@ -361,6 +363,16 @@ main (int argc, char **argv) sense_r1 = 100e3; sense_r2 = 27e3; break; + case AO_LOG_FORMAT_EASYMOTOR: + len = 16; + max_adc = 32767; + adc_ref = 3.3; + pressure_sensor = 1600.0; + batt_r1 = 5600; + batt_r2 = 10000; + sense_r1 = 5600; + sense_r2 = 10000; + break; } if (arg_len) len = arg_len; @@ -385,6 +397,7 @@ main (int argc, char **argv) struct ao_log_metrum *log_metrum; struct ao_log_gps *log_gps; struct ao_log_firetwo *log_firetwo; + struct ao_log_motor *log_motor; if (!csum && !ao_csum_valid(&eeprom->data[pos], len)) { if (verbose) @@ -626,7 +639,8 @@ main (int argc, char **argv) case AO_LOG_SENSOR: ao_pressure(log_firetwo->u.sensor.pressure, max_adc, adc_ref, - sense_r1, sense_r2); + sense_r1, sense_r2, + pressure_sensor); ao_thrust(log_firetwo->u.sensor.thrust, max_adc, adc_ref, sense_r1, sense_r2); @@ -683,6 +697,31 @@ main (int argc, char **argv) break; case AO_LOG_FORMAT_DETHERM: break; + case AO_LOG_FORMAT_EASYMOTOR: + log_motor = (struct ao_log_motor *) &eeprom->data[pos]; + switch (log_motor->type) { + case AO_LOG_FLIGHT: + printf(" serial %5u flight %5u", + eeprom->serial_number, + log_motor->u.flight.flight); + break; + case AO_LOG_STATE: + ao_state(log_motor->u.state.state, + log_motor->u.state.reason); + break; + case AO_LOG_SENSOR: + ao_pressure(log_motor->u.sensor.pressure, + max_adc, adc_ref, + sense_r1, sense_r2, + pressure_sensor); + ao_volts("v_batt", + log_motor->u.sensor.v_batt, + max_adc, + adc_ref, + batt_r1, batt_r2); + break; + } + break; } } printf("\n"); diff --git a/ao-tools/lib/ao-eeprom-read.h b/ao-tools/lib/ao-eeprom-read.h index e4a9b0cc..11e4f91d 100644 --- a/ao-tools/lib/ao-eeprom-read.h +++ b/ao-tools/lib/ao-eeprom-read.h @@ -45,6 +45,7 @@ #define AO_LOG_FORMAT_TELESTATIC 17 /* 32 byte typed telestatic records */ #define AO_LOG_FORMAT_MICROPEAK2 18 /* 2-byte baro values with header */ #define AO_LOG_FORMAT_TELEMEGA_4 19 /* 32 byte typed telemega records with 32 bit gyro cal and Bmx160 */ +#define AO_LOG_FORMAT_EASYMOTOR 20 /* 16 byte typed easymotor records with pressure sensor and adxl375 */ #define AO_LOG_FORMAT_NONE 127 /* No log at all */ enum ao_pyro_flag { @@ -515,6 +516,37 @@ struct ao_log_gps { } u; }; +struct ao_log_motor { + char type; /* 0 */ + uint8_t csum; /* 1 */ + uint16_t tick; /* 2 */ + union { /* 4 */ + /* AO_LOG_FLIGHT */ + struct { + uint16_t flight; /* 4 */ + int16_t ground_accel; /* 6 */ + int16_t ground_accel_along; /* 8 */ + int16_t ground_accel_across; /* 10 */ + int16_t ground_accel_through; /* 12 */ + int16_t ground_motor_pressure; /* 14 */ + } flight; /* 16 */ + /* AO_LOG_STATE */ + struct { + uint16_t state; /* 4 */ + uint16_t reason; /* 6 */ + } state; + /* AO_LOG_SENSOR */ + struct { + uint16_t pressure; /* 4 */ + uint16_t v_batt; /* 6 */ + int16_t accel; /* 8 */ + int16_t accel_across; /* 10 */ + int16_t accel_along; /* 12 */ + int16_t accel_through; /* 14 */ + } sensor; /* 16 */ + } u; +}; + struct ao_eeprom { struct ao_config config; struct ao_ms5607_prom ms5607_prom;