You are here

position hold below specific duty cycle

2 posts / 0 new
Last post
lacondro
Offline
Last seen: 5 hours 55 min ago
VESC Free
Joined: 2020-07-14 05:09
Posts: 9
position hold below specific duty cycle

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.

lacondro
Offline
Last seen: 5 hours 55 min ago
VESC Free
Joined: 2020-07-14 05:09
Posts: 9

I did some modifications and it works!

But too large bin file occurs on v6, so moved to v5.3.