cancel
Showing results for 
Search instead for 
Did you mean: 

Force PWM signals to lock the rotor in fixed position

roar
Associate II

Hi,

I am using the P-NUCLEO-IHM03 STM32 motor-control pack along with a AMS AS5147U rotary sensor for speed control with Hall-effect.

The rotary sensor needs to be calibrated by setting a zero angle aligment. This is done by disconnecting the motor from the motor driver board, and connecting UVW to an external power supply. We then apply a current to the motor, resulting in locking the rotor in a fixed position and reading the angle from the rotary sensor. This angle is now treated as zero.

Does anybody know how to use the MC SDK to force a UVW pattern so that we do not rely on an external power supply to lock the rotor?

Thanks

Roar

1 ACCEPTED SOLUTION

Accepted Solutions
roar
Associate II

For anyone else struggeling with something similar, we solved it by "Virtualizing" the angle read from the rotary sensor.

First of all, we have hijacked the function, which is used in the FOC loop

weak int16_t HALL_CalcElAngle(HALL_Handle_t *pHandle)

 In normal circumstances, this function reads the RotarySensor, and populates the Handle. 

When entering calibration phase, we skip the sensor readout, and instead force known electrical angles based on Hall states: 

switch (Hall_State) {
case STATE_5 : {
Rotary_Sensor.VirtualElAngle = (int16_t) ((S16_60_PHASE_SHIFT / 2));
break;
} ...

Next, we program a TorqueRamp based on input from user with respect to how much current we allow to flow in the stator, and run MC_StartMotor1(). 

As the RotarySensor feeds the FOC loop with a constant, known electrical angle, the motor is locked in a fixed position. Further calibration routine is then iterated and electrical angle is incremented to get a full rotation. 

View solution in original post

1 REPLY 1
roar
Associate II

For anyone else struggeling with something similar, we solved it by "Virtualizing" the angle read from the rotary sensor.

First of all, we have hijacked the function, which is used in the FOC loop

weak int16_t HALL_CalcElAngle(HALL_Handle_t *pHandle)

 In normal circumstances, this function reads the RotarySensor, and populates the Handle. 

When entering calibration phase, we skip the sensor readout, and instead force known electrical angles based on Hall states: 

switch (Hall_State) {
case STATE_5 : {
Rotary_Sensor.VirtualElAngle = (int16_t) ((S16_60_PHASE_SHIFT / 2));
break;
} ...

Next, we program a TorqueRamp based on input from user with respect to how much current we allow to flow in the stator, and run MC_StartMotor1(). 

As the RotarySensor feeds the FOC loop with a constant, known electrical angle, the motor is locked in a fixed position. Further calibration routine is then iterated and electrical angle is incremented to get a full rotation.