mirror of https://github.com/rusefi/bldc.git
Locking around stop code, added mc_interface_set_current_off_delay
This commit is contained in:
parent
b3ed7a67d7
commit
934d7b9751
|
@ -24,7 +24,7 @@
|
|||
#define FW_VERSION_MAJOR 5
|
||||
#define FW_VERSION_MINOR 03
|
||||
// Set to 0 for building a release and iterate during beta test builds
|
||||
#define FW_TEST_VERSION_NUMBER 34
|
||||
#define FW_TEST_VERSION_NUMBER 35
|
||||
|
||||
#include "datatypes.h"
|
||||
|
||||
|
|
|
@ -1559,6 +1559,26 @@ void mc_interface_ignore_input_both(int time_ms) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void mc_interface_set_current_off_delay(float delay_sec) {
|
||||
if (mc_interface_try_input()) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (motor_now()->m_conf.motor_type) {
|
||||
case MOTOR_TYPE_BLDC:
|
||||
case MOTOR_TYPE_DC:
|
||||
|
||||
break;
|
||||
|
||||
case MOTOR_TYPE_FOC:
|
||||
mcpwm_foc_set_current_off_delay(delay_sec);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// MC implementation functions
|
||||
|
||||
/**
|
||||
|
|
|
@ -96,6 +96,8 @@ void mc_interface_set_odometer(uint64_t new_odometer_meters);
|
|||
void mc_interface_ignore_input(int time_ms);
|
||||
void mc_interface_ignore_input_both(int time_ms);
|
||||
|
||||
void mc_interface_set_current_off_delay(float delay_sec);
|
||||
|
||||
// MC implementation functions
|
||||
void mc_interface_fault_stop(mc_fault_code fault, bool is_second_motor, bool is_isr);
|
||||
int mc_interface_try_input(void);
|
||||
|
|
|
@ -3090,10 +3090,10 @@ static void run_fw(volatile motor_all_state_t *motor, float dt) {
|
|||
static void timer_update(volatile motor_all_state_t *motor, float dt) {
|
||||
run_fw(motor, dt);
|
||||
|
||||
utils_step_towards((float*)&motor->m_current_off_delay, 0.0, dt);
|
||||
|
||||
// Check if it is time to stop the modulation. Notice that modulation is kept on as long as there is
|
||||
// field weakening current.
|
||||
utils_sys_lock_cnt();
|
||||
utils_step_towards((float*)&motor->m_current_off_delay, 0.0, dt);
|
||||
if (!motor->m_phase_override && motor->m_state == MC_STATE_RUNNING &&
|
||||
(motor->m_control_mode == CONTROL_MODE_CURRENT ||
|
||||
motor->m_control_mode == CONTROL_MODE_CURRENT_BRAKE ||
|
||||
|
@ -3108,6 +3108,7 @@ static void timer_update(volatile motor_all_state_t *motor, float dt) {
|
|||
stop_pwm_hw(motor);
|
||||
}
|
||||
}
|
||||
utils_sys_unlock_cnt();
|
||||
|
||||
// Use this to study the openloop timers under experiment plot
|
||||
#if 0
|
||||
|
|
Loading…
Reference in New Issue