mirror of https://github.com/rusefi/bldc.git
Added ppm detach
This commit is contained in:
parent
02e4b1a7c0
commit
7d0a378245
|
@ -33,6 +33,8 @@ unsigned app_calc_crc(app_configuration* conf);
|
|||
void app_ppm_start(void);
|
||||
void app_ppm_stop(void);
|
||||
float app_ppm_get_decoded_level(void);
|
||||
void app_ppm_detach(bool detach);
|
||||
void app_ppm_override(float val);
|
||||
void app_ppm_configure(ppm_config *conf);
|
||||
|
||||
void app_adc_start(bool use_rx_tx);
|
||||
|
|
|
@ -50,6 +50,8 @@ static volatile ppm_config config;
|
|||
static volatile int pulses_without_power = 0;
|
||||
static float input_val = 0.0;
|
||||
static volatile float direction_hyst = 0;
|
||||
static volatile bool ppm_detached = false;
|
||||
static volatile float ppm_override = 0.0;
|
||||
|
||||
// Private functions
|
||||
|
||||
|
@ -86,6 +88,14 @@ float app_ppm_get_decoded_level(void) {
|
|||
return input_val;
|
||||
}
|
||||
|
||||
void app_ppm_detach(bool detach) {
|
||||
ppm_detached = detach;
|
||||
}
|
||||
|
||||
void app_ppm_override(float val) {
|
||||
ppm_override = val;
|
||||
}
|
||||
|
||||
static void servodec_func(void) {
|
||||
ppm_rx = true;
|
||||
chSysLockFromISR();
|
||||
|
@ -120,6 +130,11 @@ static THD_FUNCTION(ppm_thread, arg) {
|
|||
const float rpm_now = mc_interface_get_rpm();
|
||||
float servo_val = servodec_get_servo(0);
|
||||
float servo_ms = utils_map(servo_val, -1.0, 1.0, config.pulse_start, config.pulse_end);
|
||||
|
||||
if (ppm_detached) {
|
||||
servo_val = ppm_override;
|
||||
}
|
||||
|
||||
static bool servoError = false;
|
||||
|
||||
switch (config.ctrl_type) {
|
||||
|
|
|
@ -332,6 +332,22 @@ Detaches a peripherial from the APP ADC
|
|||
|
||||
Sets the override value
|
||||
|
||||
#### app-ppm-detach
|
||||
|
||||
```clj
|
||||
(app-ppm-detach state)
|
||||
```
|
||||
|
||||
Detaches the decoded ppm signal from APP PPM. 1 means detach, 0 means attach.
|
||||
|
||||
#### app-ppm-override
|
||||
|
||||
```clj
|
||||
(app-ppm-override value)
|
||||
```
|
||||
|
||||
Sets the override value. Range -1.0 to 1.0.
|
||||
|
||||
### Motor Set Commands
|
||||
|
||||
#### set-current
|
||||
|
|
|
@ -1073,6 +1073,18 @@ static lbm_value ext_app_adc_override(lbm_value *args, lbm_uint argn) {
|
|||
return ENC_SYM_TRUE;
|
||||
}
|
||||
|
||||
static lbm_value ext_app_ppm_detach(lbm_value *args, lbm_uint argn) {
|
||||
CHECK_ARGN_NUMBER(1);
|
||||
app_ppm_detach(lbm_dec_as_u32(args[0]) > 0);
|
||||
return ENC_SYM_TRUE;
|
||||
}
|
||||
|
||||
static lbm_value ext_app_ppm_override(lbm_value *args, lbm_uint argn) {
|
||||
CHECK_ARGN_NUMBER(1);
|
||||
app_ppm_override(lbm_dec_as_float(args[0]));
|
||||
return ENC_SYM_TRUE;
|
||||
}
|
||||
|
||||
|
||||
// Motor set commands
|
||||
|
||||
|
@ -3579,6 +3591,8 @@ void lispif_load_vesc_extensions(void) {
|
|||
// APP commands
|
||||
lbm_add_extension("app-adc-detach", ext_app_adc_detach);
|
||||
lbm_add_extension("app-adc-override", ext_app_adc_override);
|
||||
lbm_add_extension("app-ppm-detach", ext_app_ppm_detach);
|
||||
lbm_add_extension("app-ppm-override", ext_app_ppm_override);
|
||||
|
||||
// Motor set commands
|
||||
lbm_add_extension("set-current", ext_set_current);
|
||||
|
|
Loading…
Reference in New Issue