|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
KST servo programming protocol: limits on an edited image. More...
Go to the source code of this file.
Macros | |
| #define | KST_DUTY_RAW_MAX 250u |
| Raw limits. | |
| #define | KST_DUTY_RAW_MIN 26u |
| #define | KST_DUTY_RAW_HALF 128u |
| #define | KST_DUTY_RAW_90 230u |
| #define | KST_BOOST_RAW_MAX 236u |
| #define | KST_STRETCH_INDEX_MAX 5u |
| #define | KST_SPD_RAW_MAX 1000u |
| #define | KST_SPD_RAW_MIN_ON 50u |
| #define | KST_SPD_RAW_SLOW 300u |
| #define | KST_DEAD_BAND_RAW_1US 60u |
| #define | KST_PULSE_RAW_MIN 625u |
| #define | KST_PULSE_RAW_MAX 3125u |
| #define | KST_NEUTRAL_RAW_MIN 2754u |
| #define | KST_NEUTRAL_RAW_MAX 4156u |
| #define | KST_UNCONT_TIME_RAW_MIN 4u |
| #define | KST_UNCONT_TIME_RAW_MAX 130u |
| #define | KST_UNCONT_TIME_RAW_SHORT 10u |
| #define | KST_ANGLE_RAW_SMALL 50u |
| #define | KST_MARGIN_HARD_TENTH_US 1000 |
| Distances between pulse widths, in 0.1us. | |
| #define | KST_MARGIN_SOFT_TENTH_US 3000 |
| #define | KST_SPAN_MIN_TENTH_US 4000 |
| #define | KST_END_MOVE_TENTH_US 1000 |
| #define | KST_NEUTRAL_MOVE_TENTH_US 200 |
| #define | KST_UNCONT_FAR_TENTH_US 3000 |
| #define | KST_RULE_BIT(rule) |
| #define | KST_RULES_HARD (KST_RULE_BIT(KST_S_DUTY_RAISED) - 1u) |
| The hard rules as a set. | |
Typedefs | |
| typedef uint64_t | kst_rules_t |
| A set of rules, bit n for rule n. | |
Functions | |
| kst_rules_t | kst_limits_image (const kst_image_t *img) |
| The hard rules an image breaks on its own. | |
| kst_rules_t | kst_limits_edit (const kst_image_t *backup, const kst_image_t *target, kst_field_set_t unlocked, kst_field_set_t *refused) |
The hard and soft rules the image target breaks as an edit of the servo's image backup. | |
KST servo programming protocol: limits on an edited image.
Implements the programming protocol of KST and Chaservo servos. KST and Chaservo are names or trademarks of their respective owners; they are used here only to say which servos this module works with (README.md, "Legal notice and disclaimer").
A hard rule refuses an image. A soft rule asks for a confirmation and never refuses. Each rule has an identifier that stays the same across versions, so a user interface maps it to a text.
The hard limits are the ranges the vendor tool prints on its controls, the encodings that are not established and the states with no control authority. The soft limits mark values inside the vendor's range that move away from the servo's own backed-up value in the hazardous direction. The numbers marked "proposed" have no measurement behind them. What a register does to the servo's motion is not measured for any register, so the limits rest on the vendor's labels.
The limits cannot see the mechanical travel of a gear train, a linkage, the supply or the load.
SPDX-License-Identifier: MIT
| #define KST_ANGLE_RAW_SMALL 50u |
proposed
| #define KST_BOOST_RAW_MAX 236u |
3000us
| #define KST_DEAD_BAND_RAW_1US 60u |
1.0us; a higher raw value is narrower
| #define KST_DUTY_RAW_90 230u |
the highest raw value shown as 90%
| #define KST_DUTY_RAW_HALF 128u |
50%, proposed
| #define KST_DUTY_RAW_MAX 250u |
Raw limits.
Pulse widths: 1 count is 0.8us. 98%
| #define KST_DUTY_RAW_MIN 26u |
10%, proposed
| #define KST_END_MOVE_TENTH_US 1000 |
an end point against the backup: 100us
| #define KST_MARGIN_HARD_TENTH_US 1000 |
Distances between pulse widths, in 0.1us.
All proposed. Neutral to an end point: 100us
| #define KST_MARGIN_SOFT_TENTH_US 3000 |
Neutral to an end point: 300us
| #define KST_NEUTRAL_MOVE_TENTH_US 200 |
Neutral against the backup: 20us
| #define KST_NEUTRAL_RAW_MAX 4156u |
1640us
| #define KST_NEUTRAL_RAW_MIN 2754u |
1360us
| #define KST_PULSE_RAW_MAX 3125u |
2500us
| #define KST_PULSE_RAW_MIN 625u |
500us
| #define KST_RULE_BIT | ( | rule | ) |
| #define KST_SPAN_MIN_TENTH_US 4000 |
Upper less Lower: 400us
| #define KST_SPD_RAW_MAX 1000u |
100%
| #define KST_SPD_RAW_MIN_ON 50u |
5% with spd_sel on, proposed
| #define KST_SPD_RAW_SLOW 300u |
30% with spd_sel on, proposed
| #define KST_STRETCH_INDEX_MAX 5u |
factor 32
| #define KST_UNCONT_FAR_TENTH_US 3000 |
Uncontrolled Pos from Neutral: 300us
| #define KST_UNCONT_TIME_RAW_MAX 130u |
13.0s
| #define KST_UNCONT_TIME_RAW_MIN 4u |
0.4s
| #define KST_UNCONT_TIME_RAW_SHORT 10u |
1.0s, proposed
| enum kst_rule_t |
The rules.
Values are stable: a rule keeps its number, a new rule takes the next free one. KST_H_ rules are hard, KST_S_ rules are soft.
| kst_rules_t kst_limits_edit | ( | const kst_image_t * | backup, |
| const kst_image_t * | target, | ||
| kst_field_set_t | unlocked, | ||
| kst_field_set_t * | refused ) |
The hard and soft rules the image target breaks as an edit of the servo's image backup.
unlocked lifts KST_ACCESS_LOCKED for the fields in it. Nothing lifts KST_ACCESS_NEVER; register 01 may follow 02. refused, when not NULL, receives the changed fields that the access class refuses.
A soft rule about a value on its own (KST_S_DUTY_BELOW_HALF and the like) is reported when the edit changes a field the rule reads, not for a state the servo already has.
| backup | Image the edit starts from. |
| target | Image after the edit. |
| unlocked | Fields whose KST_ACCESS_LOCKED is lifted. |
| refused | Receives the refused fields; may be NULL. |
| kst_rules_t kst_limits_image | ( | const kst_image_t * | img | ) |
The hard rules an image breaks on its own.
Pulse Lower, Upper and Uncontrolled Pos are compared with Neutral in microseconds, because Neutral's unit differs from theirs.
An image in Gyro Servo mode breaks KST_H_GYRO_MODE: the vendor tool halves every microsecond value there, and what a servo does with them is not measured.
| img | Image to check. |