You are here

position hold below specific duty cycle

3 posts / 0 new
Last post
lacondro
Offline
Last seen: 1 month 1 day 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: 1 month 1 day 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.

cjmssmd
Offline
Last seen: 2 weeks 22 hours ago
VESC Free
Joined: 2022-05-14 22:36
Posts: 4

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.