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?

11 REPLIES 11
Jacob993
Associate

I have almost same question. You asked this question and many members replied your question by reading their answers my problem is solved almost 80 percent.

I hope Your problem will be also solved.

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