28#define BENCH_CHW_CHANNELS 12u
123 uint8_t servo_no_current;
124 uint8_t servo_no_voltage;
125 uint16_t servo_window;
126 int16_t servo_mean_ma[3];
127 int16_t servo_max_ma[3];
128 uint16_t servo_min_mv[3];
160 uint8_t offset, uint8_t count);
221 bool i_ok,
float amps,
bool clipped);
270#define BENCH_FINE_MAH_TOL 2.0f
271#define BENCH_FINE_WH_TOL 0.2f
278#define BENCH_CHARGE_MAH_MAX 65535.0f
279#define BENCH_ENERGY_WH_MAX 6553.5f
295 uint32_t energy_cwh);
301#define BENCH_COUNTED_CHARGE 0x01u
306#define BENCH_COUNTED_ENERGY 0x02u
309#define BENCH_TOTALS_MAX_STEP_S 1.0f
347#define BENCH_TOTALS_SETTLE_S 0.1f
374 float dt_s,
bool driving);
404#define BENCH_RPM_STALE_MS 200u
415#define BENCH_EDT_STALE_MS 2000u
void bench_state_fine_totals(bench_state_t *b, int32_t charge_cmah, uint32_t energy_cwh)
With LINK_BN_TOTALS_OK, the INA228's totals in the SENSE page's finer steps – charge_cmah in 0....
Definition bench_state.c:355
void bench_state_run_starts(bench_state_t *b, uint16_t *regs)
A run starts: the totals of the last one go, in b and in the BENCH page regs built from it – charge a...
Definition bench_state.c:131
void bench_state_from_telem(bench_state_t *b, const bench_telem_t *t)
The live readings of b and their valid bits from t, for the IOmcu's sample.
Definition bench_state.c:407
void bench_totals_count(bench_totals_t *t, const bench_state_t *b, float dt_s, bool driving)
Add dt_s of b's readings, while driving, and only what its flags mark measured: charge from a current...
Definition bench_state.c:193
void bench_state_to_regs(const bench_state_t *b, uint16_t *regs)
Encode into a BENCH page, for the IOmcu and for round-trip tests.
Definition bench_state.c:110
bool bench_state_esc_current(const bench_state_t *b, float *out)
The ESC's own current, from the same source as bench_state_esc_voltage().
Definition bench_state.c:318
void bench_totals_show(const bench_totals_t *t, bench_state_t *b)
Write the totals into b, over whatever its source put there.
Definition bench_state.c:241
void bench_state_from_regs(bench_state_t *b, const uint16_t *regs, uint8_t offset, uint8_t count)
Decode a BENCH page into b.
Definition bench_state.c:81
bool bench_state_esc_voltage(const bench_state_t *b, float *out)
The ESC's own voltage and current, whichever page carries them: the SENSE page's while the INA228 is ...
Definition bench_state.c:311
bool bench_state_ina_voltage(const bench_state_t *b, float *out)
The INA228's own voltage and current: BENCH's while it is the source.
Definition bench_state.c:345
void bench_state_set_esc(bench_state_t *b, bool v_ok, float volts, bool i_ok, float amps, bool clipped)
The ESC's own figures while the INA228 is the source: from the SENSE page's ESC registers,...
Definition bench_state.c:251
void bench_totals_reset(bench_totals_t *t)
A run begins: nothing counted.
Definition bench_state.c:183
bool bench_state_ina_current(const bench_state_t *b, float *out)
The INA228's own current: BENCH's while it is the source.
Definition bench_state.c:350
void bench_state_log_row(const bench_state_t *b, bool whole, bench_state_t *out)
One row of the bench log from b, into out.
Definition bench_state.c:145
void bench_state_track_peaks(bench_state_t *b)
Take the live readings into the peaks.
Definition bench_state.c:382
void bench_state_reset_peaks(bench_state_t *b)
Clear the peaks without disturbing the live readings.
Definition bench_state.c:167
#define BENCH_CHW_CHANNELS
The INA3221 channels SENSE_WIN_A and SENSE_WIN_B carry (4.25).
Definition bench_state.h:28
static bool bench_state_simulated(const bench_state_t *b)
True when the numbers are modelled rather than measured.
Definition bench_state.h:142
The page map: what the panel can ask the IOmcu for, and set.
@ LINK_BN_SIMULATED
The numbers are modelled, not measured.
Definition link_pages.h:1520
One 50ms window of every INA3221 channel, from SENSE_WIN_A and SENSE_WIN_B (protocol 4....
Definition bench_state.h:40
One extended-telemetry reading as the DShot driver holds it.
Definition bench_state.h:418
uint32_t age_ms
Definition bench_state.h:421
bool ok
Definition bench_state.h:419
uint16_t count
Definition bench_state.h:420
The bench readings in the units a person reads: V, A, W and rpm, with their peaks.
Definition bench_state.h:54
float rpm
Definition bench_state.h:58
uint8_t counted
Which of charge_mah and energy_wh the panel has counted this run (BENCH_COUNTED_*).
Definition bench_state.h:79
float charge_mah
Definition bench_state.h:61
float voltage
Definition bench_state.h:55
bool sag_seeded
Whether voltage_min is a measurement yet.
Definition bench_state.h:89
uint16_t flags
Definition bench_state.h:70
float energy_wh
Definition bench_state.h:62
bool valid
Definition bench_state.h:80
float esc_voltage
Definition bench_state.h:98
float temp_esc
Definition bench_state.h:59
float temp_motor
Definition bench_state.h:60
bool clipped
The INA228 read its current at the end of its range in the last window or since the arm (SENSE FLAGS ...
Definition bench_state.h:106
bench_chw_t chw
The same window of every channel the map reads, ok 0 for none: on the row of servo_window,...
Definition bench_state.h:133
float current
Definition bench_state.h:56
float esc_current
Definition bench_state.h:99
float power
Definition bench_state.h:57
The ESC's telemetry as the IOmcu reads it at a sample: raw, with each reading's age and whether there...
Definition bench_state.h:428
uint32_t erpm_age_ms
Definition bench_state.h:432
bench_edt_reading_t current
Definition bench_state.h:434
uint16_t poles
Definition bench_state.h:429
uint32_t erpm
Definition bench_state.h:431
bool erpm_ok
Definition bench_state.h:430
bench_edt_reading_t voltage
Definition bench_state.h:433
bench_edt_reading_t temperature
Definition bench_state.h:435
A run's charge and energy, counted by the panel.
Definition bench_state.h:332
uint8_t counted
Definition bench_state.h:335
float run_s
Definition bench_state.h:336