Hi, I'm trying to modify firmware to hold position of motor when duty cycle is below 10%.(FOC with AS5047)
I am a mechanical engineer, so I'm not sure where to begin.
First, I cloned original bldc folder.
From mcpwm_foc.c
Original code
void mcpwm_foc_set_duty(float dutyCycle) { | |
get_motor_now()->m_control_mode = CONTROL_MODE_DUTY; | |
get_motor_now()->m_duty_cycle_set = dutyCycle; | |
if (get_motor_now()->m_state != MC_STATE_RUNNING) { | |
get_motor_now()->m_motor_released = false; | |
get_motor_now()->m_state = MC_STATE_RUNNING; | |
} | |
} |
changed to
void mcpwm_foc_set_duty(float dutyCycle) {
if(dutyCycle >0.1){
get_motor_now()->m_control_mode = CONTROL_MODE_DUTY;
get_motor_now()->m_duty_cycle_set = dutyCycle;
}
else{
get_motor_now()->m_control_mode = CONTROL_MODE_POS;
get_motor_now()->m_pos_pid_set = 0;
}
if (get_motor_now()->m_state != MC_STATE_RUNNING) {
get_motor_now()->m_motor_released = false;
get_motor_now()->m_state = MC_STATE_RUNNING;
}
}
Build and Upload new .HEX file via VESC Tool but it motor runs below 10% duty cycle.
Any suggestions where to fix?
Thanks.
I did some modifications and it works!
But too large bin file occurs on v6, so moved to v5.3.
Can you post your modifications? We are looking for exactly this. We're running in duty cycle mode. But when commanded duty cycle=0% (or less than 1%..) we want the motor to hold its position.