Skip to content

Commit

Permalink
FW 3.31: Acc temp dec option, PID for APP_ADC
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Oct 27, 2017
1 parent cf2502c commit 6277cf7
Show file tree
Hide file tree
Showing 34 changed files with 606 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
=== FW 3.31 ===
* Option to decrease temperature limits during acceleration to still have braking torque left.
* Added PID speed control mode to ADC app.

=== FW 3.30 ===
* Activated iterative observer for better operation at high ERPM.
* Check for NAN and truncate some FOC variables.
Expand Down
4 changes: 2 additions & 2 deletions appconf/appconf_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@
#define APPCONF_ADC_THROTTLE_EXP_MODE THR_EXP_POLY
#endif
#ifndef APPCONF_ADC_RAMP_TIME_POS
#define APPCONF_ADC_RAMP_TIME_POS 0.9
#define APPCONF_ADC_RAMP_TIME_POS 0.3
#endif
#ifndef APPCONF_ADC_RAMP_TIME_NEG
#define APPCONF_ADC_RAMP_TIME_NEG 0.3
#define APPCONF_ADC_RAMP_TIME_NEG 0.1
#endif
#ifndef APPCONF_ADC_MULTI_ESC
#define APPCONF_ADC_MULTI_ESC false
Expand Down
29 changes: 29 additions & 0 deletions applications/app_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ static THD_FUNCTION(adc_thread, arg) {
case ADC_CTRL_TYPE_CURRENT_REV_CENTER:
case ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_CENTER:
case ADC_CTRL_TYPE_DUTY_REV_CENTER:
case ADC_CTRL_TYPE_PID_REV_CENTER:
// Mapping with respect to center voltage
if (pwr < config.voltage_center) {
pwr = utils_map(pwr, config.voltage_start,
Expand Down Expand Up @@ -247,6 +248,7 @@ static THD_FUNCTION(adc_thread, arg) {
case ADC_CTRL_TYPE_CURRENT_REV_CENTER:
case ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_CENTER:
case ADC_CTRL_TYPE_DUTY_REV_CENTER:
case ADC_CTRL_TYPE_PID_REV_CENTER:
// Scale the voltage and set 0 at the center
pwr *= 2.0;
pwr -= 1.0;
Expand All @@ -260,6 +262,7 @@ static THD_FUNCTION(adc_thread, arg) {
case ADC_CTRL_TYPE_CURRENT_REV_BUTTON:
case ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_BUTTON:
case ADC_CTRL_TYPE_DUTY_REV_BUTTON:
case ADC_CTRL_TYPE_PID_REV_BUTTON:
// Invert the voltage if the button is pressed
if (rev_button) {
pwr = -pwr;
Expand Down Expand Up @@ -346,6 +349,32 @@ static THD_FUNCTION(adc_thread, arg) {
}
break;

case ADC_CTRL_TYPE_PID:
case ADC_CTRL_TYPE_PID_REV_CENTER:
case ADC_CTRL_TYPE_PID_REV_BUTTON:
if ((pwr >= 0.0 && rpm_now > 0.0) || (pwr < 0.0 && rpm_now < 0.0)) {
current = pwr * mcconf->lo_current_motor_max_now;
} else {
current = pwr * fabsf(mcconf->lo_current_motor_min_now);
}

if (!(ms_without_power < MIN_MS_WITHOUT_POWER && config.safe_start)) {
float speed = 0.0;
if (pwr >= 0.0) {
speed = pwr * mcconf->l_max_erpm;
} else {
speed = pwr * fabsf(mcconf->l_min_erpm);
}

mc_interface_set_pid_speed(speed);
send_duty = true;
}

if (fabsf(pwr) < 0.001) {
ms_without_power += (1000.0 * (float)sleep_time) / (float)CH_CFG_ST_FREQUENCY;
}
break;

default:
continue;
}
Expand Down
Binary file modified build_all/410_o_411_o_412/VESC_0005ohm.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_default.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_0005ohm.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_33k.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_default.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_ws2811_33k.bin
Binary file not shown.
Binary file modified build_all/48/VESC_0005ohm.bin
Binary file not shown.
Binary file modified build_all/48/VESC_default.bin
Binary file not shown.
Binary file modified build_all/48/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/48/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/60/VESC_default.bin
Binary file not shown.
Binary file modified build_all/60/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/60/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/60/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/DAS_RS/VESC_default.bin
Binary file not shown.
40 changes: 20 additions & 20 deletions build_all/rebuild_all
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,42 @@ rm $COPYDIR/*
# default
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DHW_VERSION_46"
make -j8 build_args="-DHW_VERSION_46"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default.bin

# 33k
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DVIN_R1=33000.0 -DHW_VERSION_46"
make -j8 build_args="-DVIN_R1=33000.0 -DHW_VERSION_46"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_33k.bin

# 0005ohm
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DCURRENT_SHUNT_RES=0.0005 -DHW_VERSION_46"
make -j8 build_args="-DCURRENT_SHUNT_RES=0.0005 -DHW_VERSION_46"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_0005ohm.bin

# ws2811
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DWS2811_ENABLE=1 -DHW_VERSION_46"
make -j8 build_args="-DWS2811_ENABLE=1 -DHW_VERSION_46"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_ws2811.bin

# ws2811_33k
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DWS2811_ENABLE=1 -DVIN_R1=33000.0 -DHW_VERSION_46"
make -j8 build_args="-DWS2811_ENABLE=1 -DVIN_R1=33000.0 -DHW_VERSION_46"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_ws2811_33k.bin

# servoout
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DSERVO_OUT_ENABLE=1 -DHW_VERSION_46"
make -j8 build_args="-DSERVO_OUT_ENABLE=1 -DHW_VERSION_46"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_servoout.bin

Expand All @@ -59,28 +59,28 @@ rm $COPYDIR/*
# default
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DHW_VERSION_48"
make -j8 build_args="-DHW_VERSION_48"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default.bin

# 0005ohm
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DCURRENT_SHUNT_RES=0.0005 -DHW_VERSION_48"
make -j8 build_args="-DCURRENT_SHUNT_RES=0.0005 -DHW_VERSION_48"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_0005ohm.bin

# ws2811
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DWS2811_ENABLE=1 -DHW_VERSION_48"
make -j8 build_args="-DWS2811_ENABLE=1 -DHW_VERSION_48"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_ws2811.bin

# servoout
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DSERVO_OUT_ENABLE=1 -DHW_VERSION_48"
make -j8 build_args="-DSERVO_OUT_ENABLE=1 -DHW_VERSION_48"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_servoout.bin

Expand All @@ -92,35 +92,35 @@ rm $COPYDIR/*
# default
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DHW_VERSION_410"
make -j8 build_args="-DHW_VERSION_410"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default.bin

# default with HW limits disables
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DHW_VERSION_410 -DDISABLE_HW_LIMITS"
make -j8 build_args="-DHW_VERSION_410 -DDISABLE_HW_LIMITS"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default_no_hw_limits.bin

# 0005ohm
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DCURRENT_SHUNT_RES=0.0005 -DHW_VERSION_410"
make -j8 build_args="-DCURRENT_SHUNT_RES=0.0005 -DHW_VERSION_410"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_0005ohm.bin

# ws2811
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DWS2811_ENABLE=1 -DHW_VERSION_410"
make -j8 build_args="-DWS2811_ENABLE=1 -DHW_VERSION_410"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_ws2811.bin

# servoout
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DSERVO_OUT_ENABLE=1 -DHW_VERSION_410"
make -j8 build_args="-DSERVO_OUT_ENABLE=1 -DHW_VERSION_410"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_servoout.bin

Expand All @@ -132,28 +132,28 @@ rm $COPYDIR/*
# default
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DHW_VERSION_60"
make -j8 build_args="-DHW_VERSION_60"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default.bin

# default with HW limits disables
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DHW_VERSION_60 -DDISABLE_HW_LIMITS"
make -j8 build_args="-DHW_VERSION_60 -DDISABLE_HW_LIMITS"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default_no_hw_limits.bin

# ws2811
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DWS2811_ENABLE=1 -DHW_VERSION_60"
make -j8 build_args="-DWS2811_ENABLE=1 -DHW_VERSION_60"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_ws2811.bin

# servoout
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DSERVO_OUT_ENABLE=1 -DHW_VERSION_60"
make -j8 build_args="-DSERVO_OUT_ENABLE=1 -DHW_VERSION_60"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_servoout.bin

Expand All @@ -170,7 +170,7 @@ rm $COPYDIR/*
# default
cd $FWPATH
touch conf_general.h
make -j4 build_args="-DHW_VERSION_DAS_RS"
make -j8 build_args="-DHW_VERSION_DAS_RS"
cd $DIR
cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default.bin

Expand Down
2 changes: 2 additions & 0 deletions commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ void commands_process_packet(unsigned char *data, unsigned int len) {
mcconf.l_temp_fet_end = buffer_get_float32_auto(data, &ind);
mcconf.l_temp_motor_start = buffer_get_float32_auto(data, &ind);
mcconf.l_temp_motor_end = buffer_get_float32_auto(data, &ind);
mcconf.l_temp_accel_dec = buffer_get_float32_auto(data, &ind);
mcconf.l_min_duty = buffer_get_float32_auto(data, &ind);
mcconf.l_max_duty = buffer_get_float32_auto(data, &ind);
mcconf.l_watt_max = buffer_get_float32_auto(data, &ind);
Expand Down Expand Up @@ -437,6 +438,7 @@ void commands_process_packet(unsigned char *data, unsigned int len) {
buffer_append_float32_auto(send_buffer, mcconf.l_temp_fet_end, &ind);
buffer_append_float32_auto(send_buffer, mcconf.l_temp_motor_start, &ind);
buffer_append_float32_auto(send_buffer, mcconf.l_temp_motor_end, &ind);
buffer_append_float32_auto(send_buffer, mcconf.l_temp_accel_dec, &ind);
buffer_append_float32_auto(send_buffer, mcconf.l_min_duty, &ind);
buffer_append_float32_auto(send_buffer, mcconf.l_max_duty, &ind);
buffer_append_float32_auto(send_buffer, mcconf.l_watt_max, &ind);
Expand Down
1 change: 1 addition & 0 deletions conf_general.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ void conf_general_get_default_mc_configuration(mc_configuration *conf) {
conf->l_temp_fet_end = MCCONF_L_LIM_TEMP_FET_END;
conf->l_temp_motor_start = MCCONF_L_LIM_TEMP_MOTOR_START;
conf->l_temp_motor_end = MCCONF_L_LIM_TEMP_MOTOR_END;
conf->l_temp_accel_dec = MCCONF_L_LIM_TEMP_ACCEL_DEC;
conf->l_min_duty = MCCONF_L_MIN_DUTY;
conf->l_max_duty = MCCONF_L_MAX_DUTY;
conf->l_watt_max = MCCONF_L_WATT_MAX;
Expand Down
6 changes: 4 additions & 2 deletions conf_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

// Firmware version
#define FW_VERSION_MAJOR 3
#define FW_VERSION_MINOR 30
#define FW_VERSION_MINOR 31

#include "datatypes.h"

Expand Down Expand Up @@ -50,7 +50,8 @@
#if !defined(HW_VERSION_40) && !defined(HW_VERSION_45) && !defined(HW_VERSION_46) && \
!defined(HW_VERSION_48) && !defined(HW_VERSION_49) && !defined(HW_VERSION_410) && \
!defined(HW_VERSION_60) && !defined(HW_VERSION_R2) && !defined(HW_VERSION_VICTOR_R1A) && \
!defined(HW_VERSION_DAS_RS) && !defined(HW_VERSION_PALTA) && !defined(HW_VERSION_RH)
!defined(HW_VERSION_DAS_RS) && !defined(HW_VERSION_PALTA) && !defined(HW_VERSION_RH) && \
!defined(HW_VERSION_TP)
//#define HW_VERSION_40
//#define HW_VERSION_45
//#define HW_VERSION_46 // Also for 4.7
Expand All @@ -63,6 +64,7 @@
//#define HW_VERSION_DAS_RS
//#define HW_VERSION_PALTA
//#define HW_VERSION_RH
//#define HW_VERSION_TP
#endif

/*
Expand Down
6 changes: 5 additions & 1 deletion datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ typedef struct {
float l_temp_fet_end;
float l_temp_motor_start;
float l_temp_motor_end;
float l_temp_accel_dec;
float l_min_duty;
float l_max_duty;
float l_watt_max;
Expand Down Expand Up @@ -298,7 +299,10 @@ typedef enum {
ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_ADC,
ADC_CTRL_TYPE_DUTY,
ADC_CTRL_TYPE_DUTY_REV_CENTER,
ADC_CTRL_TYPE_DUTY_REV_BUTTON
ADC_CTRL_TYPE_DUTY_REV_BUTTON,
ADC_CTRL_TYPE_PID,
ADC_CTRL_TYPE_PID_REV_CENTER,
ADC_CTRL_TYPE_PID_REV_BUTTON
} adc_control_type;

typedef struct {
Expand Down
2 changes: 2 additions & 0 deletions hwconf/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include "hw_palta.h"
#elif defined HW_VERSION_RH
#include "hw_rh.h"
#elif defined HW_VERSION_TP
#include "hw_tp.h"
#else
#error "No hardware version defined"
#endif
Expand Down
Loading

0 comments on commit 6277cf7

Please sign in to comment.