|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
Simulated ESC in its throttle-stick menu, with its supply current. More...
Go to the source code of this file.
Data Structures | |
| struct | esc_sim_cfg_t |
| Timing and fault settings of the simulated ESC. More... | |
| struct | esc_sim_t |
| Full state of one simulated ESC. More... | |
Macros | |
| #define | ESC_SIM_LOOP_MAX 64u |
| Most group numbers in the loop being sounded. | |
| #define | ESC_SIM_PULSE_MAX 16u |
| Most pulses in one group's beep sequence. | |
Enumerations | |
| enum | esc_sim_mode_t { ESC_SIM_OFF = 0 , ESC_SIM_IDLE , ESC_SIM_ENTRY , ESC_SIM_WAIT_LISTEN , ESC_SIM_ITEMS , ESC_SIM_VALUES , ESC_SIM_PENDING , ESC_SIM_DONE } |
| Mode of the simulated ESC's menu. More... | |
Functions | |
| void | esc_sim_defaults (esc_sim_cfg_t *c) |
| Fill a simulator config with its default settings. | |
| void | esc_sim_init (esc_sim_t *s, const esc_profile_t *p, const esc_sim_cfg_t *c) |
| Start a simulated ESC on a profile. | |
| int32_t | esc_sim_step (esc_sim_t *s, uint32_t now_ms, bool powered, float throttle_pct) |
| Advance the simulated ESC to a time and return its supply current. | |
| void | esc_sim_hand (esc_sim_t *s, uint32_t now_ms) |
| Record the person's action at the ESC. | |
| unsigned | esc_sim_store_moves (const esc_profile_t *p, uint8_t item, uint8_t value, esc_throttle_t *out, size_t cap) |
| List the moves that store a selected value. | |
| uint8_t | esc_sim_stored (const esc_sim_t *s, uint8_t item) |
| Value stored for an item. | |
Simulated ESC in its throttle-stick menu, with its supply current.
A simulated ESC (electronic speed controller) in its throttle-stick menu, as the supply current shows it: an idle current, and a pulse on top for every beep.
It follows a profile the way the stick programmer reads one: power on at the entry position, or at a position a value is programmed from (its entry_throttle), enters the menu; the groups loop, a move to the select position after a group selects it, and in a two-stage menu a move to the value_select position after a value group stores the value. Where the profile names a store move, or the value moves after its selection (after_select), the selection waits for each in order and is lost if the power goes first. An item keyed exit leaves the menu when it is selected, and one keyed reset clears what was stored. A value stored from a power-up at another position than its own is counted as misplaced: the ESC would teach that position. What it stores is kept across power cycles, as an ESC keeps it.
The timing is made up, as the stick programmer's defaults are: no ESC has been recorded. The host suite runs the engine against it end to end, and the panel runs it as the ESC on its modelled supply.
SPDX-License-Identifier: MIT
| enum esc_sim_mode_t |
| void esc_sim_defaults | ( | esc_sim_cfg_t * | c | ) |
Fill a simulator config with its default settings.
| c | Receives the defaults. |
| void esc_sim_hand | ( | esc_sim_t * | s, |
| uint32_t | now_ms ) |
Record the person's action at the ESC.
The person's action at the ESC – the jumper pulled, the button pressed – at now_ms. With wait_hand, a menu waiting for it starts; one done before the entry ends lets the menu start when it does.
| s | The simulator. |
| now_ms | Time of the action, ms. |
| void esc_sim_init | ( | esc_sim_t * | s, |
| const esc_profile_t * | p, | ||
| const esc_sim_cfg_t * | c ) |
Start a simulated ESC on a profile.
| s | The simulator to set up. |
| p | The profile the simulated ESC follows. |
| c | The timing and fault settings. |
| int32_t esc_sim_step | ( | esc_sim_t * | s, |
| uint32_t | now_ms, | ||
| bool | powered, | ||
| float | throttle_pct ) |
Advance the simulated ESC to a time and return its supply current.
Advance to now_ms with the supply powered and the signal at throttle_pct, negative for no signal. Returns the current it draws, mA. Call it often enough for its pulses: in the host suite every few milliseconds, on the panel at the supply's 50ms.
| s | The simulator. |
| now_ms | Time of this step, ms. |
| powered | Whether the supply is on. |
| throttle_pct | Throttle signal, percent; negative for no signal. |
| unsigned esc_sim_store_moves | ( | const esc_profile_t * | p, |
| uint8_t | item, | ||
| uint8_t | value, | ||
| esc_throttle_t * | out, | ||
| size_t | cap ) |
List the moves that store a selected value.
The moves that store value value of the item numbered item once it is selected, into out: the profile's store move, then the value's own after_select, of the first item and value of those numbers – items that apply to different models may share both. At most cap are written; returns how many.
| p | The profile. |
| item | Item number. |
| value | Value number. |
| out | Receives the moves. |
| cap | Capacity of out, in moves. |
| uint8_t esc_sim_stored | ( | const esc_sim_t * | s, |
| uint8_t | item ) |
Value stored for an item.
The value stored for the item numbered item, 0 when none was.
| s | The simulator. |
| item | Item number. |