mirror of https://github.com/rusefi/bldc.git
Merge remote-tracking branch 'upstream/dev_fw_5_00' into dev_fw_5_00
This commit is contained in:
commit
558a92b6f9
|
@ -4,7 +4,12 @@
|
||||||
* Disable CC decoupling during flux linkage measurement.
|
* Disable CC decoupling during flux linkage measurement.
|
||||||
* Balance app updates. See: https://github.com/vedderb/bldc/pull/141
|
* Balance app updates. See: https://github.com/vedderb/bldc/pull/141
|
||||||
* Observer gain calculation update.
|
* Observer gain calculation update.
|
||||||
|
* Better observer gain scaling. This has a large impact on some motors.
|
||||||
* Added test build flag, that is transmitted with the FW Version command.
|
* Added test build flag, that is transmitted with the FW Version command.
|
||||||
|
* Detect all bug fix.
|
||||||
|
* Added COMM_SET_BATTERY_CUT command.
|
||||||
|
* Added CAN_PACKET_SHUTDOWN CAN-command.
|
||||||
|
* GPDRIVE output sample fix.
|
||||||
|
|
||||||
=== FW 4.02 ===
|
=== FW 4.02 ===
|
||||||
* Position PID fix (most notable on multiturn encoders).
|
* Position PID fix (most notable on multiturn encoders).
|
||||||
|
|
62
comm_can.c
62
comm_can.c
|
@ -36,6 +36,7 @@
|
||||||
#include "encoder.h"
|
#include "encoder.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "mempools.h"
|
#include "mempools.h"
|
||||||
|
#include "shutdown.h"
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
#define RX_FRAMES_SIZE 100
|
#define RX_FRAMES_SIZE 100
|
||||||
|
@ -606,6 +607,17 @@ void comm_can_detect_all_foc_res_clear(void) {
|
||||||
detect_all_foc_res_index = 0;
|
detect_all_foc_res_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void comm_can_conf_battery_cut(uint8_t controller_id,
|
||||||
|
bool store, float start, float end) {
|
||||||
|
int32_t send_index = 0;
|
||||||
|
uint8_t buffer[8];
|
||||||
|
buffer_append_float32(buffer, start, 1e3, &send_index);
|
||||||
|
buffer_append_float32(buffer, end, 1e3, &send_index);
|
||||||
|
comm_can_transmit_eid(controller_id |
|
||||||
|
((uint32_t)(store ? CAN_PACKET_CONF_STORE_BATTERY_CUT :
|
||||||
|
CAN_PACKET_CONF_BATTERY_CUT) << 8), buffer, send_index);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get status message by index.
|
* Get status message by index.
|
||||||
*
|
*
|
||||||
|
@ -1189,10 +1201,6 @@ static void decode_msg(uint32_t eid, uint8_t *data8, int len, bool is_replaced)
|
||||||
|
|
||||||
case CAN_PACKET_CONF_CURRENT_LIMITS:
|
case CAN_PACKET_CONF_CURRENT_LIMITS:
|
||||||
case CAN_PACKET_CONF_STORE_CURRENT_LIMITS: {
|
case CAN_PACKET_CONF_STORE_CURRENT_LIMITS: {
|
||||||
if (is_replaced) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ind = 0;
|
ind = 0;
|
||||||
float min = buffer_get_float32(data8, 1e3, &ind);
|
float min = buffer_get_float32(data8, 1e3, &ind);
|
||||||
float max = buffer_get_float32(data8, 1e3, &ind);
|
float max = buffer_get_float32(data8, 1e3, &ind);
|
||||||
|
@ -1217,10 +1225,6 @@ static void decode_msg(uint32_t eid, uint8_t *data8, int len, bool is_replaced)
|
||||||
|
|
||||||
case CAN_PACKET_CONF_CURRENT_LIMITS_IN:
|
case CAN_PACKET_CONF_CURRENT_LIMITS_IN:
|
||||||
case CAN_PACKET_CONF_STORE_CURRENT_LIMITS_IN: {
|
case CAN_PACKET_CONF_STORE_CURRENT_LIMITS_IN: {
|
||||||
if (is_replaced) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ind = 0;
|
ind = 0;
|
||||||
float min = buffer_get_float32(data8, 1e3, &ind);
|
float min = buffer_get_float32(data8, 1e3, &ind);
|
||||||
float max = buffer_get_float32(data8, 1e3, &ind);
|
float max = buffer_get_float32(data8, 1e3, &ind);
|
||||||
|
@ -1245,10 +1249,6 @@ static void decode_msg(uint32_t eid, uint8_t *data8, int len, bool is_replaced)
|
||||||
|
|
||||||
case CAN_PACKET_CONF_FOC_ERPMS:
|
case CAN_PACKET_CONF_FOC_ERPMS:
|
||||||
case CAN_PACKET_CONF_STORE_FOC_ERPMS: {
|
case CAN_PACKET_CONF_STORE_FOC_ERPMS: {
|
||||||
if (is_replaced) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ind = 0;
|
ind = 0;
|
||||||
float foc_openloop_rpm = buffer_get_float32(data8, 1e3, &ind);
|
float foc_openloop_rpm = buffer_get_float32(data8, 1e3, &ind);
|
||||||
float foc_sl_erpm = buffer_get_float32(data8, 1e3, &ind);
|
float foc_sl_erpm = buffer_get_float32(data8, 1e3, &ind);
|
||||||
|
@ -1278,6 +1278,44 @@ static void decode_msg(uint32_t eid, uint8_t *data8, int len, bool is_replaced)
|
||||||
encoder_ts5700n8501_get_raw_status(), 8);
|
encoder_ts5700n8501_get_raw_status(), 8);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case CAN_PACKET_CONF_BATTERY_CUT:
|
||||||
|
case CAN_PACKET_CONF_STORE_BATTERY_CUT: {
|
||||||
|
ind = 0;
|
||||||
|
float start = buffer_get_float32(data8, 1e3, &ind);
|
||||||
|
float end = buffer_get_float32(data8, 1e3, &ind);
|
||||||
|
|
||||||
|
mc_configuration *mcconf = mempools_alloc_mcconf();
|
||||||
|
*mcconf = *mc_interface_get_configuration();
|
||||||
|
|
||||||
|
if (mcconf->l_battery_cut_start != start || mcconf->l_battery_cut_end != end) {
|
||||||
|
mcconf->l_battery_cut_start = start;
|
||||||
|
mcconf->l_battery_cut_end = end;
|
||||||
|
|
||||||
|
if (cmd == CAN_PACKET_CONF_STORE_BATTERY_CUT) {
|
||||||
|
conf_general_store_mc_configuration(mcconf,
|
||||||
|
mc_interface_get_motor_thread() == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
mc_interface_set_configuration(mcconf);
|
||||||
|
}
|
||||||
|
|
||||||
|
mempools_free_mcconf(mcconf);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case CAN_PACKET_SHUTDOWN: {
|
||||||
|
#ifdef HW_SHUTDOWN_HOLD_ON
|
||||||
|
SHUTDOWN_SET_SAMPLING_DISABLED(true);
|
||||||
|
mc_interface_lock();
|
||||||
|
DISABLE_GATE();
|
||||||
|
HW_SHUTDOWN_HOLD_OFF();
|
||||||
|
chThdSleepMilliseconds(5000);
|
||||||
|
HW_SHUTDOWN_HOLD_ON();
|
||||||
|
ENABLE_GATE();
|
||||||
|
mc_interface_unlock();
|
||||||
|
SHUTDOWN_SET_SAMPLING_DISABLED(false);
|
||||||
|
#endif
|
||||||
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
#define CAN_STATUS_MSG_INT_MS 1
|
|
||||||
#define CAN_STATUS_MSGS_TO_STORE 10
|
#define CAN_STATUS_MSGS_TO_STORE 10
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
@ -54,6 +53,8 @@ void comm_can_conf_foc_erpms(uint8_t controller_id,
|
||||||
int comm_can_detect_all_foc_res(unsigned int index);
|
int comm_can_detect_all_foc_res(unsigned int index);
|
||||||
int comm_can_detect_all_foc_res_size(void);
|
int comm_can_detect_all_foc_res_size(void);
|
||||||
void comm_can_detect_all_foc_res_clear(void);
|
void comm_can_detect_all_foc_res_clear(void);
|
||||||
|
void comm_can_conf_battery_cut(uint8_t controller_id,
|
||||||
|
bool store, float start, float end);
|
||||||
can_status_msg *comm_can_get_status_msg_index(int index);
|
can_status_msg *comm_can_get_status_msg_index(int index);
|
||||||
can_status_msg *comm_can_get_status_msg_id(int id);
|
can_status_msg *comm_can_get_status_msg_id(int id);
|
||||||
can_status_msg_2 *comm_can_get_status_msg_2_index(int index);
|
can_status_msg_2 *comm_can_get_status_msg_2_index(int index);
|
||||||
|
|
41
commands.c
41
commands.c
|
@ -658,7 +658,7 @@ void commands_process_packet(unsigned char *data, unsigned int len,
|
||||||
case COMM_GPD_OUTPUT_SAMPLE: {
|
case COMM_GPD_OUTPUT_SAMPLE: {
|
||||||
timeout_reset();
|
timeout_reset();
|
||||||
int32_t ind = 0;
|
int32_t ind = 0;
|
||||||
gpdrive_add_buffer_sample(buffer_get_float32_auto(data, &ind));
|
gpdrive_output_sample(buffer_get_float32_auto(data, &ind));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case COMM_GPD_SET_MODE: {
|
case COMM_GPD_SET_MODE: {
|
||||||
|
@ -1020,6 +1020,41 @@ void commands_process_packet(unsigned char *data, unsigned int len,
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case COMM_SET_BATTERY_CUT: {
|
||||||
|
int32_t ind = 0;
|
||||||
|
float start = buffer_get_float32(data, 1e3, &ind);
|
||||||
|
float end = buffer_get_float32(data, 1e3, &ind);
|
||||||
|
bool store = data[ind++];
|
||||||
|
bool fwd_can = data[ind++];
|
||||||
|
|
||||||
|
if (fwd_can) {
|
||||||
|
comm_can_conf_battery_cut(255, store, start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
mc_configuration *mcconf = mempools_alloc_mcconf();
|
||||||
|
*mcconf = *mc_interface_get_configuration();
|
||||||
|
|
||||||
|
if (mcconf->l_battery_cut_start != start || mcconf->l_battery_cut_end != end) {
|
||||||
|
mcconf->l_battery_cut_start = start;
|
||||||
|
mcconf->l_battery_cut_end = end;
|
||||||
|
|
||||||
|
if (store) {
|
||||||
|
conf_general_store_mc_configuration(mcconf,
|
||||||
|
mc_interface_get_motor_thread() == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
mc_interface_set_configuration(mcconf);
|
||||||
|
}
|
||||||
|
|
||||||
|
mempools_free_mcconf(mcconf);
|
||||||
|
|
||||||
|
// Send ack
|
||||||
|
ind = 0;
|
||||||
|
uint8_t send_buffer[50];
|
||||||
|
send_buffer[ind++] = packet_id;
|
||||||
|
reply_func(send_buffer, ind);
|
||||||
|
} break;
|
||||||
|
|
||||||
// Blocking commands. Only one of them runs at any given time, in their
|
// Blocking commands. Only one of them runs at any given time, in their
|
||||||
// own thread. If other blocking commands come before the previous one has
|
// own thread. If other blocking commands come before the previous one has
|
||||||
// finished, they are discarded.
|
// finished, they are discarded.
|
||||||
|
@ -1168,7 +1203,11 @@ void commands_apply_mcconf_hw_limits(mc_configuration *mcconf) {
|
||||||
//control loop executes twice per pwm cycle when sampling in v0 and v7
|
//control loop executes twice per pwm cycle when sampling in v0 and v7
|
||||||
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ);
|
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ);
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef HW_HAS_DUAL_MOTORS
|
||||||
|
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ);
|
||||||
|
#else
|
||||||
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ * 2.0);
|
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ * 2.0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1107,6 +1107,11 @@ static bool measure_r_l_imax(float current_min, float current_max,
|
||||||
current_start = current_min * 1.1;
|
current_start = current_min * 1.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mc_configuration *mcconf = mempools_alloc_mcconf();
|
||||||
|
*mcconf = *mc_interface_get_configuration();
|
||||||
|
|
||||||
|
const float res_old = mcconf->foc_motor_r;
|
||||||
|
|
||||||
float i_last = 0.0;
|
float i_last = 0.0;
|
||||||
for (float i = current_start;i < current_max;i *= 1.5) {
|
for (float i = current_start;i < current_max;i *= 1.5) {
|
||||||
float res_tmp = mcpwm_foc_measure_resistance(i, 5);
|
float res_tmp = mcpwm_foc_measure_resistance(i, 5);
|
||||||
|
@ -1122,10 +1127,17 @@ static bool measure_r_l_imax(float current_min, float current_max,
|
||||||
}
|
}
|
||||||
|
|
||||||
*r = mcpwm_foc_measure_resistance(i_last, 100);
|
*r = mcpwm_foc_measure_resistance(i_last, 100);
|
||||||
|
|
||||||
|
mcconf->foc_motor_r = *r;
|
||||||
|
mc_interface_set_configuration(mcconf);
|
||||||
|
|
||||||
*l = mcpwm_foc_measure_inductance_current(i_last, 100, 0, 0) * 1e-6;
|
*l = mcpwm_foc_measure_inductance_current(i_last, 100, 0, 0) * 1e-6;
|
||||||
*i_max = sqrtf(max_power_loss / *r);
|
*i_max = sqrtf(max_power_loss / *r);
|
||||||
utils_truncate_number(i_max, HW_LIM_CURRENT);
|
utils_truncate_number(i_max, HW_LIM_CURRENT);
|
||||||
|
|
||||||
|
mcconf->foc_motor_r = res_old;
|
||||||
|
mc_interface_set_configuration(mcconf);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,8 @@
|
||||||
// Mark3 version of HW60 with power switch and separate NRF UART.
|
// Mark3 version of HW60 with power switch and separate NRF UART.
|
||||||
//#define HW60_IS_MK3
|
//#define HW60_IS_MK3
|
||||||
|
|
||||||
//#define HW_SOURCE "hw_60.c"
|
#define HW_SOURCE "hw_60.c"
|
||||||
//#define HW_HEADER "hw_60.h"
|
#define HW_HEADER "hw_60.h"
|
||||||
|
|
||||||
//#define HW_SOURCE "hw_r2.c"
|
//#define HW_SOURCE "hw_r2.c"
|
||||||
//#define HW_HEADER "hw_r2.h"
|
//#define HW_HEADER "hw_r2.h"
|
||||||
|
@ -140,10 +140,8 @@
|
||||||
//#define HW_SOURCE "hw_stormcore_60d.c"
|
//#define HW_SOURCE "hw_stormcore_60d.c"
|
||||||
//#define HW_HEADER "hw_stormcore_60d.h"
|
//#define HW_HEADER "hw_stormcore_60d.h"
|
||||||
|
|
||||||
#define HW_SOURCE "hw_stormcore_100s.c"
|
//#define HW_SOURCE "hw_stormcore_100s.c"
|
||||||
#define HW_HEADER "hw_stormcore_100s.h"
|
//#define HW_HEADER "hw_stormcore_100s.h"
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HW_SOURCE
|
#ifndef HW_SOURCE
|
||||||
|
|
26
datatypes.h
26
datatypes.h
|
@ -762,7 +762,8 @@ typedef enum {
|
||||||
COMM_WRITE_NEW_APP_DATA_ALL_CAN_LZO,
|
COMM_WRITE_NEW_APP_DATA_ALL_CAN_LZO,
|
||||||
COMM_BM_WRITE_FLASH_LZO,
|
COMM_BM_WRITE_FLASH_LZO,
|
||||||
COMM_SET_CURRENT_REL,
|
COMM_SET_CURRENT_REL,
|
||||||
COMM_CAN_FWD_FRAME
|
COMM_CAN_FWD_FRAME,
|
||||||
|
COMM_SET_BATTERY_CUT
|
||||||
} COMM_PACKET_ID;
|
} COMM_PACKET_ID;
|
||||||
|
|
||||||
// CAN commands
|
// CAN commands
|
||||||
|
@ -795,7 +796,10 @@ typedef enum {
|
||||||
CAN_PACKET_CONF_FOC_ERPMS,
|
CAN_PACKET_CONF_FOC_ERPMS,
|
||||||
CAN_PACKET_CONF_STORE_FOC_ERPMS,
|
CAN_PACKET_CONF_STORE_FOC_ERPMS,
|
||||||
CAN_PACKET_STATUS_5,
|
CAN_PACKET_STATUS_5,
|
||||||
CAN_PACKET_POLL_TS5700N8501_STATUS
|
CAN_PACKET_POLL_TS5700N8501_STATUS,
|
||||||
|
CAN_PACKET_CONF_BATTERY_CUT,
|
||||||
|
CAN_PACKET_CONF_STORE_BATTERY_CUT,
|
||||||
|
CAN_PACKET_SHUTDOWN
|
||||||
} CAN_PACKET_ID;
|
} CAN_PACKET_ID;
|
||||||
|
|
||||||
// Logged fault data
|
// Logged fault data
|
||||||
|
@ -904,15 +908,15 @@ typedef enum {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float v_in;
|
float v_in;
|
||||||
float temp_mos1;
|
float temp_mos;
|
||||||
float temp_mos2;
|
float temp_mos_1;
|
||||||
float temp_mos3;
|
float temp_mos_2;
|
||||||
float temp_mos4;
|
float temp_mos_3;
|
||||||
float temp_mos5;
|
float temp_motor;
|
||||||
float temp_mos6;
|
|
||||||
float temp_pcb;
|
|
||||||
float current_motor;
|
float current_motor;
|
||||||
float current_in;
|
float current_in;
|
||||||
|
float id;
|
||||||
|
float iq;
|
||||||
float rpm;
|
float rpm;
|
||||||
float duty_now;
|
float duty_now;
|
||||||
float amp_hours;
|
float amp_hours;
|
||||||
|
@ -921,7 +925,11 @@ typedef struct {
|
||||||
float watt_hours_charged;
|
float watt_hours_charged;
|
||||||
int tachometer;
|
int tachometer;
|
||||||
int tachometer_abs;
|
int tachometer_abs;
|
||||||
|
float position;
|
||||||
mc_fault_code fault_code;
|
mc_fault_code fault_code;
|
||||||
|
int vesc_id;
|
||||||
|
float vd;
|
||||||
|
float vq;
|
||||||
} mc_values;
|
} mc_values;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -322,6 +322,7 @@ void gpdrive_output_sample(float sample) {
|
||||||
|
|
||||||
case GPD_OUTPUT_MODE_CURRENT:
|
case GPD_OUTPUT_MODE_CURRENT:
|
||||||
m_current_state.current_set = sample;
|
m_current_state.current_set = sample;
|
||||||
|
m_is_running = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -261,7 +261,7 @@
|
||||||
#define MCCONF_FOC_OBSERVER_GAIN 9e7 // Can be something like 600 / L
|
#define MCCONF_FOC_OBSERVER_GAIN 9e7 // Can be something like 600 / L
|
||||||
#endif
|
#endif
|
||||||
#ifndef MCCONF_FOC_OBSERVER_GAIN_SLOW
|
#ifndef MCCONF_FOC_OBSERVER_GAIN_SLOW
|
||||||
#define MCCONF_FOC_OBSERVER_GAIN_SLOW 0.4 // Observer gain scale at minimum duty cycle
|
#define MCCONF_FOC_OBSERVER_GAIN_SLOW 0.05 // Observer gain scale at minimum duty cycle
|
||||||
#endif
|
#endif
|
||||||
#ifndef MCCONF_FOC_DUTY_DOWNRAMP_KP
|
#ifndef MCCONF_FOC_DUTY_DOWNRAMP_KP
|
||||||
#define MCCONF_FOC_DUTY_DOWNRAMP_KP 10.0 // PI controller for duty control when decreasing the duty
|
#define MCCONF_FOC_DUTY_DOWNRAMP_KP 10.0 // PI controller for duty control when decreasing the duty
|
||||||
|
|
24
mcpwm_foc.c
24
mcpwm_foc.c
|
@ -703,7 +703,7 @@ void mcpwm_foc_set_configuration(volatile mc_configuration *configuration) {
|
||||||
motor_now()->m_control_mode = CONTROL_MODE_NONE;
|
motor_now()->m_control_mode = CONTROL_MODE_NONE;
|
||||||
motor_now()->m_state = MC_STATE_OFF;
|
motor_now()->m_state = MC_STATE_OFF;
|
||||||
stop_pwm_hw(motor_now());
|
stop_pwm_hw(motor_now());
|
||||||
update_hfi_samples(m_motor_1.m_conf->foc_hfi_samples, &m_motor_1);
|
update_hfi_samples(motor_now()->m_conf->foc_hfi_samples, motor_now());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1307,7 +1307,7 @@ void mcpwm_foc_get_current_offsets(
|
||||||
volatile int *curr2_offset,
|
volatile int *curr2_offset,
|
||||||
bool is_second_motor) {
|
bool is_second_motor) {
|
||||||
#ifdef HW_HAS_DUAL_MOTORS
|
#ifdef HW_HAS_DUAL_MOTORS
|
||||||
volatile motor_all_state_t *motor = is_second_motor ? &m_motor_1 : &m_motor_2;
|
volatile motor_all_state_t *motor = is_second_motor ? &m_motor_2 : &m_motor_1;
|
||||||
#else
|
#else
|
||||||
(void)is_second_motor;
|
(void)is_second_motor;
|
||||||
volatile motor_all_state_t *motor = &m_motor_1;
|
volatile motor_all_state_t *motor = &m_motor_1;
|
||||||
|
@ -2727,19 +2727,15 @@ static void timer_update(volatile motor_all_state_t *motor, float dt) {
|
||||||
// motor->m_conf->foc_observer_gain);
|
// motor->m_conf->foc_observer_gain);
|
||||||
|
|
||||||
// Observer gain scaling, based on bus voltage and duty cycle
|
// Observer gain scaling, based on bus voltage and duty cycle
|
||||||
//motor->m_gamma_now = utils_map(fabsf(motor->m_motor_state.duty_now),
|
|
||||||
// 0.0, 40.0 / motor->m_motor_state.v_bus,
|
|
||||||
// motor->m_conf->foc_observer_gain_slow * motor->m_conf->foc_observer_gain,
|
|
||||||
// motor->m_conf->foc_observer_gain);
|
|
||||||
|
|
||||||
float gamma_tmp = utils_map(fabsf(motor->m_motor_state.duty_now),
|
float gamma_tmp = utils_map(fabsf(motor->m_motor_state.duty_now),
|
||||||
0.0, 15.0 / motor->m_motor_state.v_bus,
|
0.0, 40.0 / motor->m_motor_state.v_bus,
|
||||||
0,
|
0,
|
||||||
motor->m_conf->foc_observer_gain);
|
motor->m_conf->foc_observer_gain);
|
||||||
if (gamma_tmp < (motor->m_conf->foc_observer_gain_slow * motor->m_conf->foc_observer_gain)) {
|
if (gamma_tmp < (motor->m_conf->foc_observer_gain_slow * motor->m_conf->foc_observer_gain)) {
|
||||||
gamma_tmp = motor->m_conf->foc_observer_gain_slow * motor->m_conf->foc_observer_gain;
|
gamma_tmp = motor->m_conf->foc_observer_gain_slow * motor->m_conf->foc_observer_gain;
|
||||||
}
|
}
|
||||||
motor->m_gamma_now = gamma_tmp;
|
// 3.5 scaling is kind of arbitrary, but it should make configs from old VESC Tools more likely to work.
|
||||||
|
motor->m_gamma_now = gamma_tmp * 3.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
static THD_FUNCTION(timer_thread, arg) {
|
static THD_FUNCTION(timer_thread, arg) {
|
||||||
|
|
Loading…
Reference in New Issue