mirror of https://github.com/rusefi/bldc.git
Added l_duty_start and set correct motor in mcinterface_timer
This commit is contained in:
parent
d9fc2fc34c
commit
57c5d04214
|
@ -24,7 +24,7 @@
|
|||
#define FW_VERSION_MAJOR 5
|
||||
#define FW_VERSION_MINOR 00
|
||||
// Set to 0 for building a release and iterate during beta test builds
|
||||
#define FW_TEST_VERSION_NUMBER 6
|
||||
#define FW_TEST_VERSION_NUMBER 7
|
||||
|
||||
#include "datatypes.h"
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *
|
|||
buffer_append_float32_auto(buffer, conf->l_watt_min, &ind);
|
||||
buffer_append_float32_auto(buffer, conf->l_current_max_scale, &ind);
|
||||
buffer_append_float32_auto(buffer, conf->l_current_min_scale, &ind);
|
||||
buffer_append_float32_auto(buffer, conf->l_duty_start, &ind);
|
||||
buffer_append_float32_auto(buffer, conf->sl_min_erpm, &ind);
|
||||
buffer_append_float32_auto(buffer, conf->sl_min_erpm_cycle_int_limit, &ind);
|
||||
buffer_append_float32_auto(buffer, conf->sl_max_fullbreak_current_dir_change, &ind);
|
||||
|
@ -330,6 +331,7 @@ bool confgenerator_deserialize_mcconf(const uint8_t *buffer, mc_configuration *c
|
|||
conf->l_watt_min = buffer_get_float32_auto(buffer, &ind);
|
||||
conf->l_current_max_scale = buffer_get_float32_auto(buffer, &ind);
|
||||
conf->l_current_min_scale = buffer_get_float32_auto(buffer, &ind);
|
||||
conf->l_duty_start = buffer_get_float32_auto(buffer, &ind);
|
||||
conf->sl_min_erpm = buffer_get_float32_auto(buffer, &ind);
|
||||
conf->sl_min_erpm_cycle_int_limit = buffer_get_float32_auto(buffer, &ind);
|
||||
conf->sl_max_fullbreak_current_dir_change = buffer_get_float32_auto(buffer, &ind);
|
||||
|
@ -617,6 +619,7 @@ void confgenerator_set_defaults_mcconf(mc_configuration *conf) {
|
|||
conf->l_watt_min = MCCONF_L_WATT_MIN;
|
||||
conf->l_current_max_scale = MCCONF_L_CURRENT_MAX_SCALE;
|
||||
conf->l_current_min_scale = MCCONF_L_CURRENT_MIN_SCALE;
|
||||
conf->l_duty_start = MCCONF_L_DUTY_START;
|
||||
conf->sl_min_erpm = MCCONF_SL_MIN_RPM;
|
||||
conf->sl_min_erpm_cycle_int_limit = MCCONF_SL_MIN_ERPM_CYCLE_INT_LIMIT;
|
||||
conf->sl_max_fullbreak_current_dir_change = MCCONF_SL_MAX_FB_CURR_DIR_CHANGE;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
// Constants
|
||||
#define MCCONF_SIGNATURE 3632471335
|
||||
#define MCCONF_SIGNATURE 3698540221
|
||||
#define APPCONF_SIGNATURE 2460147246
|
||||
|
||||
// Functions
|
||||
|
|
|
@ -244,6 +244,7 @@ typedef struct {
|
|||
float l_watt_min;
|
||||
float l_current_max_scale;
|
||||
float l_current_min_scale;
|
||||
float l_duty_start;
|
||||
// Overridden limits (Computed during runtime)
|
||||
float lo_current_max;
|
||||
float lo_current_min;
|
||||
|
|
|
@ -1846,6 +1846,7 @@ static void update_override_limits(volatile motor_if_state_t *motor, volatile mc
|
|||
|
||||
const float v_in = GET_INPUT_VOLTAGE();
|
||||
const float rpm_now = mc_interface_get_rpm();
|
||||
const float duty_now_abs = fabsf(mc_interface_get_duty_cycle_now());
|
||||
|
||||
UTILS_LP_FAST(motor->m_temp_fet, NTC_TEMP(is_motor_1 ? ADC_IND_TEMP_MOS : ADC_IND_TEMP_MOS_M2), 0.1);
|
||||
float temp_motor = 0.0;
|
||||
|
@ -1992,6 +1993,14 @@ static void update_override_limits(volatile motor_if_state_t *motor, volatile mc
|
|||
lo_min_rpm = utils_map(rpm_now, rpm_neg_cut_start, rpm_neg_cut_end, l_current_max_tmp, 0.0);
|
||||
}
|
||||
|
||||
// Duty max
|
||||
float lo_max_duty = 0.0;
|
||||
if (duty_now_abs < conf->l_duty_start) {
|
||||
lo_max_duty = l_current_max_tmp;
|
||||
} else {
|
||||
lo_max_duty = utils_map(duty_now_abs, conf->l_duty_start, conf->l_max_duty, l_current_max_tmp, 0.0);
|
||||
}
|
||||
|
||||
float lo_max = utils_min_abs(lo_max_mos, lo_max_mot);
|
||||
float lo_min = utils_min_abs(lo_min_mos, lo_min_mot);
|
||||
|
||||
|
@ -1999,6 +2008,7 @@ static void update_override_limits(volatile motor_if_state_t *motor, volatile mc
|
|||
lo_max = utils_min_abs(lo_max, lo_min_rpm);
|
||||
lo_max = utils_min_abs(lo_max, lo_fet_temp_accel);
|
||||
lo_max = utils_min_abs(lo_max, lo_motor_temp_accel);
|
||||
lo_max = utils_min_abs(lo_max, lo_max_duty);
|
||||
|
||||
if (lo_max < conf->cc_min_current) {
|
||||
lo_max = conf->cc_min_current;
|
||||
|
@ -2064,6 +2074,7 @@ static volatile motor_if_state_t *motor_now(void) {
|
|||
|
||||
static void run_timer_tasks(volatile motor_if_state_t *motor) {
|
||||
bool is_motor_1 = motor == &m_motor_1;
|
||||
mc_interface_select_motor_thread(is_motor_1 ? 1 : 2);
|
||||
|
||||
motor->m_f_samp_now = mc_interface_get_sampling_frequency_now();
|
||||
|
||||
|
|
|
@ -113,6 +113,9 @@
|
|||
#ifndef MCCONF_L_CURRENT_MIN_SCALE
|
||||
#define MCCONF_L_CURRENT_MIN_SCALE 1.0 // Minimum current scale
|
||||
#endif
|
||||
#ifndef MCCONF_L_DUTY_START
|
||||
#define MCCONF_L_DUTY_START 1.0 // Start limiting current at this duty cycle
|
||||
#endif
|
||||
|
||||
// Speed PID parameters
|
||||
#ifndef MCCONF_S_PID_KP
|
||||
|
|
Loading…
Reference in New Issue