Chuk stop PID on dropout, ppm multi vesc duty fix

This commit is contained in:
Benjamin Vedder 2019-04-18 20:00:26 +02:00
parent e09bc7ce22
commit 5202ef41d9
3 changed files with 20 additions and 9 deletions

View File

@ -1,7 +1,9 @@
=== FW 3.55 === (Ongoing)
* Initial sin/cos encoder support
* New ADC control mode
* Virtual motor support
* Initial sin/cos encoder support.
* New ADC control mode.
* Virtual motor support.
* Disable chuk cruise control on dropouts.
* Fix multiple VESCs over CAN duty cycle mode.
=== FW 3.54 ===
* Added mcpwm_foc_set_openloop_duty and mcpwm_foc_set_openloop_duty_phase.

View File

@ -205,20 +205,25 @@ static THD_FUNCTION(output_thread, arg) {
chRegSetThreadName("Nunchuk output");
bool was_pid = false;
for(;;) {
chThdSleepMilliseconds(OUTPUT_ITERATION_TIME_MS);
if (timeout_has_timeout() || chuck_error != 0 || config.ctrl_type == CHUK_CTRL_TYPE_NONE) {
was_pid = false;
continue;
}
// Local timeout to prevent this thread from causing problems after not
// being used for a while.
if (chVTTimeElapsedSinceX(last_update_time) > MS2ST(LOCAL_TIMEOUT)) {
was_pid = false;
continue;
}
if (app_is_output_disabled()) {
was_pid = false;
continue;
}
@ -231,6 +236,7 @@ static THD_FUNCTION(output_thread, arg) {
if (chuck_d.bt_c && chuck_d.bt_z) {
led_external_set_state(LED_EXT_BATT);
was_pid = false;
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
static float filter_buffer[RPM_FILTER_SAMPLES];
static int filter_ptr = 0;

View File

@ -205,6 +205,7 @@ static THD_FUNCTION(ppm_thread, arg) {
bool current_mode = false;
bool current_mode_brake = false;
bool send_current = false;
bool send_duty = false;
switch (config.ctrl_type) {
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)) {
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;
@ -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 duty = mc_interface_get_duty_cycle_now();
for (int i = 0;i < CAN_STATUS_MSGS_TO_STORE;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) {
comm_can_set_current(msg->id, current_filtered);
if (send_current) {
comm_can_set_current(msg->id, current_filtered);
} else if (send_duty) {
comm_can_set_duty(msg->id, duty);
}
}
}
}