RPM limit fix

This commit is contained in:
Benjamin Vedder 2014-07-28 10:51:44 +02:00
parent 5d142c52c4
commit 004b360cc7
3 changed files with 6 additions and 5 deletions

View File

@ -37,7 +37,7 @@
#define MCPWM_MIN_VOLTAGE 20.0 // Minimum input voltage #define MCPWM_MIN_VOLTAGE 20.0 // Minimum input voltage
#define MCPWM_MAX_VOLTAGE 50.0 // Maximum input voltage #define MCPWM_MAX_VOLTAGE 50.0 // Maximum input voltage
#define MCPWM_CURRENT_STARTUP_BOOST 0.03 // The lowest duty cycle to use in current control mode (has to be > MCPWM_MIN_DUTY_CYCLE) #define MCPWM_CURRENT_STARTUP_BOOST 0.03 // The lowest duty cycle to use in current control mode (has to be > MCPWM_MIN_DUTY_CYCLE)
#define MCPWM_RPM_LIMIT_NEG_TORQUE 0 // Do not brake when going to fast, just stop applying torque #define MCPWM_RPM_LIMIT_NEG_TORQUE 0 // Use negative torque to limit the RPM
#define MCPWM_CURR_MIN_RPM_FBRAKE 900 // Minimum electrical RPM to use full brake at #define MCPWM_CURR_MIN_RPM_FBRAKE 900 // Minimum electrical RPM to use full brake at
// Sensorless settings // Sensorless settings

View File

@ -1520,14 +1520,14 @@ void mcpwm_adc_int_handler(void *p, uint32_t flags) {
direction ? MCPWM_MAX_DUTY_CYCLE : -MCPWM_MAX_DUTY_CYCLE, ramp_step_no_lim); direction ? MCPWM_MAX_DUTY_CYCLE : -MCPWM_MAX_DUTY_CYCLE, ramp_step_no_lim);
limit_delay = 1; limit_delay = 1;
} else if (rpm > MCPWM_RPM_MAX) { } else if (rpm > MCPWM_RPM_MAX) {
if ((MCPWM_RPM_LIMIT_NEG_TORQUE || current > -4.0) && dutycycle_now <= dutycycle_now_tmp) { if ((MCPWM_RPM_LIMIT_NEG_TORQUE || current > -1.0) && dutycycle_now <= dutycycle_now_tmp) {
utils_step_towards((float*) &dutycycle_now, 0.0, ramp_step); utils_step_towards((float*) &dutycycle_now, 0.0, MCPWM_RAMP_STEP_RPM_LIMIT);
limit_delay = 1; limit_delay = 1;
slow_ramping_cycles = 500; slow_ramping_cycles = 500;
} }
} else if (rpm < MCPWM_RPM_MIN) { } else if (rpm < MCPWM_RPM_MIN) {
if ((MCPWM_RPM_LIMIT_NEG_TORQUE || current > -4.0) && dutycycle_now >= dutycycle_now_tmp) { if ((MCPWM_RPM_LIMIT_NEG_TORQUE || current > -1.0) && dutycycle_now >= dutycycle_now_tmp) {
utils_step_towards((float*) &dutycycle_now, 0.0, ramp_step); utils_step_towards((float*) &dutycycle_now, 0.0, MCPWM_RAMP_STEP_RPM_LIMIT);
limit_delay = 1; limit_delay = 1;
slow_ramping_cycles = 500; slow_ramping_cycles = 500;
} }

View File

@ -120,6 +120,7 @@ extern volatile int mcpwm_vzero;
#define MCPWM_AVG_COM_RPM 3 // Number of commutations to average RPM over #define MCPWM_AVG_COM_RPM 3 // Number of commutations to average RPM over
#define MCPWM_RAMP_STEP 0.01 // Ramping step (1000 times/sec) at maximum duty cycle #define MCPWM_RAMP_STEP 0.01 // Ramping step (1000 times/sec) at maximum duty cycle
#define MCPWM_RAMP_STEP_CURRENT_MAX 0.04 // Maximum ramping step (1000 times/sec) for the current control #define MCPWM_RAMP_STEP_CURRENT_MAX 0.04 // Maximum ramping step (1000 times/sec) for the current control
#define MCPWM_RAMP_STEP_RPM_LIMIT 0.0005 // Ramping step when limiting the RPM
#define MCPWM_CURRENT_LIMIT_GAIN 0.1 // The error gain of the current limiting algorithm #define MCPWM_CURRENT_LIMIT_GAIN 0.1 // The error gain of the current limiting algorithm
#define MCPWM_FAULT_STOP_TIME 3000 // Ignore commands for this duration in msec when faults occur #define MCPWM_FAULT_STOP_TIME 3000 // Ignore commands for this duration in msec when faults occur
#define MCPWM_CMD_STOP_TIME 50 // Ignore commands for this duration in msec after a stop has been sent #define MCPWM_CMD_STOP_TIME 50 // Ignore commands for this duration in msec after a stop has been sent