|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
A programmable supply and its model. More...
Functions | |
| float | supply_snap (float value, float min, float max, float step) |
value clamped to min .. max and rounded to a multiple of step above min. | |
| void | supply_reset_peaks (supply_state_t *s) |
| The run's extremes start again from what is shown, and only from readings that arrived; a maximum with nothing under it starts at 0. | |
| void | supply_track_peaks (supply_state_t *s) |
| Take this sample into the run's extremes, only what arrived. | |
| void | supply_reset_totals (supply_state_t *s) |
| The run begins: nothing delivered, nothing counted. | |
| void | supply_count_totals (supply_state_t *s, float dt_s) |
Add dt_s of the readings to the run's charge and energy while the output is on, only what arrived; dt_s is clamped to 0 .. | |
| supply_caps_t | supply_caps_limited (const supply_caps_t *caps, const supply_limits_t *lim) |
The supply's caps narrowed by lim: the set points a screen offers. | |
| void | supply_trip_reset (supply_trip_t *t) |
| Clears the trip state. | |
| static bool | over_for (float *over_s, bool *over, float *at, bool arrived, float value, float threshold, float hold_s, float dt) |
One reading against its threshold: true once it has been over for hold_s, counted from the first reading seen over – not from the one before it, which was not over, so the first interval is not credited. | |
| supply_trip_kind_t | supply_trip_step (supply_trip_t *t, const supply_limits_t *lim, const supply_state_t *s, float dt_s) |
Take dt_s of the readings in s into the trips. | |
| void | supply_sim_init (supply_sim_t *m) |
| Sets up the supply model. | |
| void | supply_sim_set (supply_sim_t *m, float v, float i) |
| Set points are snapped to the caps; the output's state is kept. | |
| void | supply_sim_output (supply_sim_t *m, bool on) |
| Switches the model's output on or off. | |
| void | supply_sim_step (supply_sim_t *m, float dt_s, supply_state_t *out) |
Advance dt_s and write the readings, mode and set points into out, counting one more sample; peaks, totals and taken_ms are the caller's. | |
|
static |
One reading against its threshold: true once it has been over for hold_s, counted from the first reading seen over – not from the one before it, which was not over, so the first interval is not credited.
A threshold of 0 or less is off.
| over_s | The time over the threshold, in s. |
| over | true while the reading is over. |
| at | The threshold the count was made against. |
| arrived | true when the reading arrived. |
| value | The reading. |
| threshold | The threshold. |
| hold_s | The time over the threshold that trips, in s. |
| dt | The time since the last call, in s. |
| supply_caps_t supply_caps_limited | ( | const supply_caps_t * | caps, |
| const supply_limits_t * | lim ) |
The supply's caps narrowed by lim: the set points a screen offers.
A cap below the supply's own minimum leaves the range at that minimum.
| caps | The supply's caps. |
| lim | The limits to narrow by. |
| void supply_count_totals | ( | supply_state_t * | s, |
| float | dt_s ) |
Add dt_s of the readings to the run's charge and energy while the output is on, only what arrived; dt_s is clamped to 0 ..
1s, as the bench's totals are.
| s | The supply state. |
| dt_s | The time since the last call, in s. |
| void supply_reset_peaks | ( | supply_state_t * | s | ) |
The run's extremes start again from what is shown, and only from readings that arrived; a maximum with nothing under it starts at 0.
The minimum voltage is a reading only while the output is on: an output switched off reads 0V, and a floor of 0V reads as a collapsed rail.
| s | The supply state. |
| void supply_reset_totals | ( | supply_state_t * | s | ) |
The run begins: nothing delivered, nothing counted.
| s | The supply state. |
| void supply_sim_init | ( | supply_sim_t * | m | ) |
Sets up the supply model.
| m | The model to set up. |
| void supply_sim_output | ( | supply_sim_t * | m, |
| bool | on ) |
Switches the model's output on or off.
| m | The model. |
| on | true to switch the output on. |
| void supply_sim_set | ( | supply_sim_t * | m, |
| float | v, | ||
| float | i ) |
Set points are snapped to the caps; the output's state is kept.
| m | The model. |
| v | The set point voltage, in V. |
| i | The set point current, in A. |
| void supply_sim_step | ( | supply_sim_t * | m, |
| float | dt_s, | ||
| supply_state_t * | out ) |
Advance dt_s and write the readings, mode and set points into out, counting one more sample; peaks, totals and taken_ms are the caller's.
| m | The model. |
| dt_s | The time step, in s. |
| out | Receives the readings, mode and set points. |
| float supply_snap | ( | float | value, |
| float | min, | ||
| float | max, | ||
| float | step ) |
value clamped to min .. max and rounded to a multiple of step above min.
A step of 0 or less only clamps.
| value | The value to snap. |
| min | The lowest value. |
| max | The highest value. |
| step | The step above min, in the value's unit; 0 or less only clamps. |
| void supply_track_peaks | ( | supply_state_t * | s | ) |
Take this sample into the run's extremes, only what arrived.
| s | The supply state. |
| void supply_trip_reset | ( | supply_trip_t * | t | ) |
Clears the trip state.
| t | The trip state. |
| supply_trip_kind_t supply_trip_step | ( | supply_trip_t * | t, |
| const supply_limits_t * | lim, | ||
| const supply_state_t * | s, | ||
| float | dt_s ) |
Take dt_s of the readings in s into the trips.
The count starts at the first reading seen over a threshold, and each reading over it after that adds the time since the one before; one at or under it starts the count again, and one that did not arrive leaves it where it is. A trip that is off forgets its count, and so does one whose threshold changed. A trip time of 0 fires on the first reading over. Returns which trip fired, once the time over reaches lim->trip_s; nothing while the output is off. dt_s is clamped to 0 .. 1s, as the totals' steps are.
| t | The trip state. |
| lim | The trip limits. |
| s | The readings. |
| dt_s | The time since the last call, in s. |