cancel
Showing results for 
Search instead for 
Did you mean: 

Position control (based on AN5464) using quadrature incremental encoder(ABZ)

Rajeswari
Associate III

Hello,

I'm trying to do position control using EVSPIN32G4 board and pmsm motor with incremental encoder. I followed the steps given in AN5464. The motor did not move and the rotor is locked. I'm attaching the code here. 

**********************************************************************************************************

/* USER CODE BEGIN 2 */
MC_StartMotor1();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while(MC_GetAlignmentStatusMotor1()!=TC_ALIGNMENT_COMPLETED){}
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
MC_ProgramPositionCommandMotor1(3.14/2,0.1);
HAL_Delay(2000);
MC_ProgramPositionCommandMotor1(-3.14/2,0.1);
HAL_Delay(2000);
}
/* USER CODE END 3 */

***********************************************************************************************************

While debugging the code stops at "while(MC_GetAlignmentStatusMotor1()!=TC_ALIGNMENT_COMPLETED){}". It never comes out of this while loop. 

The A,B & Z pulses are working fine. Motor runs perfectly in sensorless FOC(speed control). I think the alignment does not happen at all. kindly help with this. I'm very short on time to complete the project 

@msingh @smaiti and many others faced same issue. But there wasn't any explanation on how they overcome this issue.

MC Workbench 6.2.1

CubeMX 6.6.1

CubeIDE 1.15.0

any help guys?

13 REPLIES 13
GMA
ST Employee

Hello @Rajeswari,

Yes, test has been done with EVSPIN32G4, 1000ppr Encoder, 4500 RPM max motor, and signal Z pulse generated at each rotation.

RC low pass is used on encoder MCU input, smaller is your resistor higher is your cutoff frequency.

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA

I have changed the filter resistors from 10kohm to 510 ohm. Will it affect the stspin32g4 IC (any overcurrent drawn)? Why was position control working one day but not the next? 

I need some solution

 

Other than cutoff frequency, will it increase the current to MCU pin? 

So, I tried the same with a new EVSPIN32G4 board and it works fine now. I am able to do position control using pilot as well as using command from code