Problem with KMS Current Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with KMS Current Control

438 Views
PedroCastro
Contributor III

Hi,

I generated the code from the KMS GUI and I was testing the current control. The motor speeds up pretty smooth using the interface. However, when I tried from the code generated, the motor tries to start apparently with much higher torque then a  fault comes up and the motor stops abruptly.

Here follows the code snippet I inserted in order to use current control:

if(GPIO_DRV_ReadPinInput(kGpioSW3) == 0){
   switch(user.state){
      case USER_BRAKE:
      user.state = USER_IDLE;
      break;
      case USER_IDLE:
      case USER_RUN_CURRENT:
      user.command.statorRefCurrent.q = _SQ(0.3/FULL_SCALE_CURRENT);
      user.state = USER_RUN_CURRENT;
      break;
      default:
      break;
   }
}
else{
   brake.config.brakingType = BRAKE_COAST;
   user.state = USER_BRAKE;
}

//Update drive module
DRV_updateSlowTick();

Could you please help me solve this problem?

Thanks

Labels (1)
0 Kudos
3 Replies

183 Views
PedroCastro
Contributor III

Thanks Pedro, you are great!

0 Kudos

183 Views
PedroCastro
Contributor III

if(GPIO_DRV_ReadPinInput(kGpioSW2) == 0){
   switch(user.state){
   case USER_BRAKE:
      user.state = USER_IDLE;
      break;
   case USER_IDLE:
      user.state = USER_RUN_CURRENT;
      break;
   case USER_RUN_CURRENT:
      user.command.statorRefCurrent.q = _SQ(0.5/FULL_SCALE_CURRENT);
      user.state = USER_RUN_CURRENT;
      break;
   default:
      break;
   }
}
else{
    brake.config.brakingType = BRAKE_COAST;

    user.state = USER_BRAKE;
}

It seems to me that at the first time you move from IDLE to CURRENT, the control sets an initial speed value to follow, so you need to set a current when you are already in the CURRENT mode

0 Kudos

183 Views
PedroCastro
Contributor III

I tried to use _SQ15(), but it did not work either.

What am I missing??

0 Kudos