mirror of https://github.com/rusefi/bldc.git
Chuk stop PID on dropout, ppm multi vesc duty fix
This commit is contained in:
parent
e09bc7ce22
commit
5202ef41d9
|
@ -1,7 +1,9 @@
|
||||||
=== FW 3.55 === (Ongoing)
|
=== FW 3.55 === (Ongoing)
|
||||||
* Initial sin/cos encoder support
|
* Initial sin/cos encoder support.
|
||||||
* New ADC control mode
|
* New ADC control mode.
|
||||||
* Virtual motor support
|
* Virtual motor support.
|
||||||
|
* Disable chuk cruise control on dropouts.
|
||||||
|
* Fix multiple VESCs over CAN duty cycle mode.
|
||||||
|
|
||||||
=== FW 3.54 ===
|
=== FW 3.54 ===
|
||||||
* Added mcpwm_foc_set_openloop_duty and mcpwm_foc_set_openloop_duty_phase.
|
* Added mcpwm_foc_set_openloop_duty and mcpwm_foc_set_openloop_duty_phase.
|
||||||
|
|
|
@ -205,20 +205,25 @@ static THD_FUNCTION(output_thread, arg) {
|
||||||
|
|
||||||
chRegSetThreadName("Nunchuk output");
|
chRegSetThreadName("Nunchuk output");
|
||||||
|
|
||||||
|
bool was_pid = false;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
chThdSleepMilliseconds(OUTPUT_ITERATION_TIME_MS);
|
chThdSleepMilliseconds(OUTPUT_ITERATION_TIME_MS);
|
||||||
|
|
||||||
if (timeout_has_timeout() || chuck_error != 0 || config.ctrl_type == CHUK_CTRL_TYPE_NONE) {
|
if (timeout_has_timeout() || chuck_error != 0 || config.ctrl_type == CHUK_CTRL_TYPE_NONE) {
|
||||||
|
was_pid = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Local timeout to prevent this thread from causing problems after not
|
// Local timeout to prevent this thread from causing problems after not
|
||||||
// being used for a while.
|
// being used for a while.
|
||||||
if (chVTTimeElapsedSinceX(last_update_time) > MS2ST(LOCAL_TIMEOUT)) {
|
if (chVTTimeElapsedSinceX(last_update_time) > MS2ST(LOCAL_TIMEOUT)) {
|
||||||
|
was_pid = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app_is_output_disabled()) {
|
if (app_is_output_disabled()) {
|
||||||
|
was_pid = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +236,7 @@ static THD_FUNCTION(output_thread, arg) {
|
||||||
|
|
||||||
if (chuck_d.bt_c && chuck_d.bt_z) {
|
if (chuck_d.bt_c && chuck_d.bt_z) {
|
||||||
led_external_set_state(LED_EXT_BATT);
|
led_external_set_state(LED_EXT_BATT);
|
||||||
|
was_pid = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,9 +284,6 @@ static THD_FUNCTION(output_thread, arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If c is pressed and no throttle is used, maintain the current speed with PID control
|
|
||||||
static bool was_pid = false;
|
|
||||||
|
|
||||||
// Filter RPM to avoid glitches
|
// Filter RPM to avoid glitches
|
||||||
static float filter_buffer[RPM_FILTER_SAMPLES];
|
static float filter_buffer[RPM_FILTER_SAMPLES];
|
||||||
static int filter_ptr = 0;
|
static int filter_ptr = 0;
|
||||||
|
|
|
@ -205,6 +205,7 @@ static THD_FUNCTION(ppm_thread, arg) {
|
||||||
bool current_mode = false;
|
bool current_mode = false;
|
||||||
bool current_mode_brake = false;
|
bool current_mode_brake = false;
|
||||||
bool send_current = false;
|
bool send_current = false;
|
||||||
|
bool send_duty = false;
|
||||||
|
|
||||||
switch (config.ctrl_type) {
|
switch (config.ctrl_type) {
|
||||||
case PPM_CTRL_TYPE_CURRENT:
|
case PPM_CTRL_TYPE_CURRENT:
|
||||||
|
@ -243,7 +244,7 @@ static THD_FUNCTION(ppm_thread, arg) {
|
||||||
|
|
||||||
if (!(pulses_without_power < MIN_PULSES_WITHOUT_POWER && config.safe_start)) {
|
if (!(pulses_without_power < MIN_PULSES_WITHOUT_POWER && config.safe_start)) {
|
||||||
mc_interface_set_duty(utils_map(servo_val, -1.0, 1.0, -mcconf->l_max_duty, mcconf->l_max_duty));
|
mc_interface_set_duty(utils_map(servo_val, -1.0, 1.0, -mcconf->l_max_duty, mcconf->l_max_duty));
|
||||||
send_current = true;
|
send_duty = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -290,14 +291,19 @@ static THD_FUNCTION(ppm_thread, arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send_current && config.multi_esc) {
|
if ((send_current || send_duty) && config.multi_esc) {
|
||||||
float current_filtered = mc_interface_get_tot_current_directional_filtered();
|
float current_filtered = mc_interface_get_tot_current_directional_filtered();
|
||||||
|
float duty = mc_interface_get_duty_cycle_now();
|
||||||
|
|
||||||
for (int i = 0;i < CAN_STATUS_MSGS_TO_STORE;i++) {
|
for (int i = 0;i < CAN_STATUS_MSGS_TO_STORE;i++) {
|
||||||
can_status_msg *msg = comm_can_get_status_msg_index(i);
|
can_status_msg *msg = comm_can_get_status_msg_index(i);
|
||||||
|
|
||||||
if (msg->id >= 0 && UTILS_AGE_S(msg->rx_time) < MAX_CAN_AGE) {
|
if (msg->id >= 0 && UTILS_AGE_S(msg->rx_time) < MAX_CAN_AGE) {
|
||||||
|
if (send_current) {
|
||||||
comm_can_set_current(msg->id, current_filtered);
|
comm_can_set_current(msg->id, current_filtered);
|
||||||
|
} else if (send_duty) {
|
||||||
|
comm_can_set_duty(msg->id, duty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue