From ed61c4d332009aa2f284321380a49d6b170548d9 Mon Sep 17 00:00:00 2001 From: Benjamin Vedder Date: Thu, 19 May 2016 19:24:01 +0200 Subject: [PATCH] FW 2.18: Better FOC sensorless startup, app adc safety fix --- applications/app_adc.c | 11 +++++++++++ conf_general.h | 3 ++- mcconf/mcconf_default.h | 2 +- mcpwm_foc.c | 8 ++++++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/applications/app_adc.c b/applications/app_adc.c index 84f906b8..ebe662bb 100644 --- a/applications/app_adc.c +++ b/applications/app_adc.c @@ -308,6 +308,17 @@ static THD_FUNCTION(adc_thread, arg) { } pulses_without_power_before = ms_without_power; mc_interface_set_brake_current(timeout_get_brake_current()); + + if (config.multi_esc) { + 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_brake(msg->id, timeout_get_brake_current()); + } + } + } + continue; } diff --git a/conf_general.h b/conf_general.h index 449c9fe8..61c63144 100644 --- a/conf_general.h +++ b/conf_general.h @@ -27,7 +27,7 @@ // Firmware version #define FW_VERSION_MAJOR 2 -#define FW_VERSION_MINOR 17 +#define FW_VERSION_MINOR 18 #include "datatypes.h" @@ -67,6 +67,7 @@ */ //#define MCCONF_DEFAULT_USER "mcconf_sten.h" //#define MCCONF_DEFAULT_USER "mcconf_sp_540kv.h" +//#define MCCONF_DEFAULT_USER "mcconf_castle_2028.h" /* * Select default user app configuration diff --git a/mcconf/mcconf_default.h b/mcconf/mcconf_default.h index 0eb69869..bea65b89 100644 --- a/mcconf/mcconf_default.h +++ b/mcconf/mcconf_default.h @@ -241,7 +241,7 @@ #define MCCONF_FOC_DUTY_DOWNRAMP_KI 200.0 // PI controller for duty control when decreasing the duty #endif #ifndef MCCONF_FOC_OPENLOOP_RPM -#define MCCONF_FOC_OPENLOOP_RPM 350.0 // Openloop RPM (sensorless low speed or when finding index pulse) +#define MCCONF_FOC_OPENLOOP_RPM 1200.0 // Openloop RPM (sensorless low speed or when finding index pulse) #endif #ifndef MCCONF_FOC_SL_OPENLOOP_HYST #define MCCONF_FOC_SL_OPENLOOP_HYST 0.5 // Time below min RPM to activate openloop (s) diff --git a/mcpwm_foc.c b/mcpwm_foc.c index 9448b6ed..00dfc4bb 100644 --- a/mcpwm_foc.c +++ b/mcpwm_foc.c @@ -1688,8 +1688,12 @@ static THD_FUNCTION(timer_thread, arg) { return; } + float openloop_rpm = utils_map(fabsf(m_motor_state.iq_target), + 0.0, m_conf->lo_current_max, + 0.0, m_conf->foc_openloop_rpm); + const float dt = 0.001; - const float min_rads = (m_conf->foc_openloop_rpm * 2.0 * M_PI) / 60.0; + const float min_rads = (openloop_rpm * 2.0 * M_PI) / 60.0; static float min_rpm_hyst_timer = 0.0; static float min_rpm_timer = 0.0; @@ -1712,7 +1716,7 @@ static THD_FUNCTION(timer_thread, arg) { } // Don't use this in brake mode. - if (m_control_mode == CONTROL_MODE_CURRENT_BRAKE) { + if (m_control_mode == CONTROL_MODE_CURRENT_BRAKE || fabsf(m_motor_state.duty_now) < 0.001) { min_rpm_hyst_timer = 0.0; m_phase_observer_override = false; }