FW 3.53: Limit foc_current_filter_const range, 1Mbit/de NRF speed, lower detect f_sw for resistance, no temp_comp by default

This commit is contained in:
Benjamin Vedder 2019-03-20 22:46:36 +01:00
parent 3bf1c13b76
commit 39bb8a6b09
38 changed files with 56 additions and 54 deletions

View File

@ -1,3 +1,9 @@
=== FW 3.53 ===
* Limit foc_current_filter_const range to prevent damage due to bad configuration.
* Set default NRF speed to 1 Mbit/s.
* Use lower switching frequency when detecting resistance to reduce deat-time distortion.
* Don't enable temperature compensation in auto detection by default.
=== FW 3.52 ===
* Added support for second revision of HW75/300 with separate UART for NRF51.
* Added COMM_TERMINAL_CMD_SYNC, which does not drop commands when busy.

View File

@ -109,6 +109,7 @@ include applications/applications.mk
include nrf/nrf.mk
include libcanard/canard.mk
include imu/imu.mk
#include blackmagic/blackmagic.mk
# Define linker script file here
LDSCRIPT= ld_eeprom_emu.ld
@ -157,7 +158,8 @@ CSRC = $(STARTUPSRC) \
$(APPSRC) \
$(NRFSRC) \
$(CANARDSRC) \
$(IMUSRC)
$(IMUSRC) \
# $(BLACKMAGICSRC)
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
@ -196,7 +198,8 @@ INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(APPINC) \
$(NRFINC) \
$(CANARDINC) \
$(IMUINC)
$(IMUINC) \
# $(BLACKMAGICINC)
#
# Project, sources and paths

View File

@ -218,7 +218,7 @@
// NRF app
#ifndef APPCONF_NRF_SPEED
#define APPCONF_NRF_SPEED NRF_SPEED_2M
#define APPCONF_NRF_SPEED NRF_SPEED_1M
#endif
#ifndef APPCONF_NRF_POWER
#define APPCONF_NRF_POWER NRF_POWER_0DBM

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1078,6 +1078,9 @@ void commands_apply_mcconf_hw_limits(mc_configuration *mcconf) {
utils_truncate_number(&mcconf->l_temp_fet_start, HW_LIM_TEMP_FET);
utils_truncate_number(&mcconf->l_temp_fet_end, HW_LIM_TEMP_FET);
#endif
#ifdef HW_FOC_CURRENT_FILTER_LIM
utils_truncate_number(&mcconf->foc_current_filter_const, HW_FOC_CURRENT_FILTER_LIM);
#endif
#endif
}

View File

@ -912,6 +912,7 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
mcconf.motor_type = MOTOR_TYPE_FOC;
mcconf.foc_sensor_mode = FOC_SENSOR_MODE_SENSORLESS;
mcconf.foc_f_sw = 10000.0; // Lower f_sw => less dead-time distortion
mcconf.foc_current_kp = 0.0005;
mcconf.foc_current_ki = 1.0;
mcconf.l_current_max = MCCONF_L_CURRENT_MAX;
@ -975,6 +976,12 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
float i_max = sqrtf(max_power_loss / r);
utils_truncate_number(&i_max, HW_LIM_CURRENT);
// Increase switching frequency for flux linkage measurement
// as dead-time distortion has less effect at higher modulation.
// Having a smooth rotation is more important.
mcconf.foc_f_sw = 20000.0;
mc_interface_set_configuration(&mcconf);
float lambda = 0.0;
int res = conf_general_measure_flux_linkage_openloop(i_max / 2.5, 0.3, 1800, r, &lambda);
@ -1005,12 +1012,14 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
mcconf_old.foc_observer_gain = gain * 1e6;
// Temperature compensation
if (mc_interface_temp_motor_filtered() > 0.0) {
mcconf_old.foc_temp_comp = true;
mcconf_old.foc_temp_comp_base_temp = mc_interface_temp_motor_filtered();
} else {
mcconf_old.foc_temp_comp = false;
}
// Skip temperature compensation for now, as it seems to make
// things worse on some setups.
// if (mc_interface_temp_motor_filtered() > 0.0) {
// mcconf_old.foc_temp_comp = true;
// mcconf_old.foc_temp_comp_base_temp = mc_interface_temp_motor_filtered();
// } else {
// mcconf_old.foc_temp_comp = false;
// }
} else {
result = -10;
}

View File

@ -22,7 +22,7 @@
// Firmware version
#define FW_VERSION_MAJOR 3
#define FW_VERSION_MINOR 52
#define FW_VERSION_MINOR 53
#include "datatypes.h"
@ -138,6 +138,7 @@
*/
//#define APP_CUSTOM_TO_USE "app_rotary_led.c"
//#define APPCONF_APP_TO_USE APP_CUSTOM
//#define MCCONF_FOC_F_SW 5000
/*
* Enable CAN-bus

View File

@ -175,6 +175,10 @@
#define HW_LIM_FOC_CTRL_LOOP_FREQ 3000.0, 30000.0
#endif
#ifndef HW_FOC_CURRENT_FILTER_LIM
#define HW_FOC_CURRENT_FILTER_LIM 0.05, 1.0
#endif
// Functions
void hw_init_gpio(void);
void hw_setup_adc_channels(void);

60
main.c
View File

@ -1,5 +1,5 @@
/*
Copyright 2016 Benjamin Vedder benjamin@vedder.se
Copyright 2016 - 2019 Benjamin Vedder benjamin@vedder.se
This file is part of the VESC firmware.
@ -51,7 +51,8 @@
#include "imu.h"
/*
* Timers used:
* HW resources used:
*
* TIM1: mcpwm
* TIM5: timer
* TIM8: mcpwm
@ -68,8 +69,6 @@
*/
// Private variables
static THD_WORKING_AREA(periodic_thread_wa, 1024);
static THD_WORKING_AREA(timer_thread_wa, 128);
@ -106,20 +105,20 @@ static THD_FUNCTION(periodic_thread, arg) {
disp_pos_mode display_mode = commands_get_disp_pos_mode();
switch (display_mode) {
case DISP_POS_MODE_ENCODER:
commands_send_rotor_pos(encoder_read_deg());
break;
case DISP_POS_MODE_ENCODER:
commands_send_rotor_pos(encoder_read_deg());
break;
case DISP_POS_MODE_PID_POS:
commands_send_rotor_pos(mc_interface_get_pid_pos_now());
break;
case DISP_POS_MODE_PID_POS:
commands_send_rotor_pos(mc_interface_get_pid_pos_now());
break;
case DISP_POS_MODE_PID_POS_ERROR:
commands_send_rotor_pos(utils_angle_difference(mc_interface_get_pid_pos_set(), mc_interface_get_pid_pos_now()));
break;
case DISP_POS_MODE_PID_POS_ERROR:
commands_send_rotor_pos(utils_angle_difference(mc_interface_get_pid_pos_set(), mc_interface_get_pid_pos_now()));
break;
default:
break;
default:
break;
}
if (mc_interface_get_configuration()->motor_type == MOTOR_TYPE_FOC) {
@ -134,30 +133,10 @@ static THD_FUNCTION(periodic_thread, arg) {
default:
break;
}
}
}
chThdSleepMilliseconds(10);
// chThdSleepMilliseconds(40);
// volatile const mc_configuration *conf = mc_interface_get_configuration();
// float vq = mcpwm_foc_get_vq();
// float iq = mc_interface_get_tot_current_directional();
// float linkage = conf->foc_motor_flux_linkage;
// float speed = ((2.0 * M_PI) / 60.0) * mc_interface_get_rpm();
//
// if (iq < -6.0) {
// float res = vq / (linkage * speed * iq);
// res *= 2.0 / 3.0;
// static float res_filtered = 0.0;
// UTILS_LP_FAST(res_filtered, res, 0.02);
// commands_printf("Res: %.4f", (double)res_filtered);
// }
// chThdSleepMilliseconds(40);
// commands_printf("Max: %.2f Min: %.2f",
// (double)mc_interface_get_configuration()->lo_current_motor_max_now,
// (double)mc_interface_get_configuration()->lo_current_motor_min_now);
}
}
@ -173,12 +152,13 @@ static THD_FUNCTION(timer_thread, arg) {
}
}
/* When assertions enabled halve PWM frequency. The control loop ISR runs 40% slower */
// When assertions enabled halve PWM frequency. The control loop ISR runs 40% slower
void assert_failed(uint8_t* file, uint32_t line) {
commands_printf("Wrong parameters value: file %s on line %d\r\n", file, line);
mc_interface_release_motor();
while(1)
while(1) {
chThdSleepMilliseconds(1);
}
}
int main(void) {
@ -317,9 +297,5 @@ int main(void) {
for(;;) {
chThdSleepMilliseconds(10);
if (encoder_is_configured()) {
// comm_can_set_pos(0, encoder_read_deg());
}
}
}

View File

@ -155,7 +155,7 @@ void nrf_driver_start_pairing(int ms) {
conf.retries = 3;
conf.retry_delay = NRF_RETR_DELAY_1000US;
conf.send_crc_ack = true;
conf.speed = NRF_SPEED_250K;
conf.speed = NRF_SPEED_1M;
rfhelp_update_conf(&conf);
}
@ -472,7 +472,7 @@ void nrf_driver_process_packet(unsigned char *buf, unsigned char len) {
appconf.app_nrf_conf.retries = 3;
appconf.app_nrf_conf.retry_delay = NRF_RETR_DELAY_1000US;
appconf.app_nrf_conf.send_crc_ack = true;
appconf.app_nrf_conf.speed = NRF_SPEED_250K;
appconf.app_nrf_conf.speed = NRF_SPEED_1M;
if (ext_nrf) {
unsigned char data[5];