Skip to main content
Associate II
September 10, 2026
Question

Issue with Encoder Alignment Function

  • September 10, 2026
  • 5 replies
  • 20 views

Dear ST Support Team,

I am following the procedure described in AN5464 – Position control of a three-phase permanent magnet motor using X-CUBE-MCSDK. As mentioned in Section 5.8, MC_StartMotor1() performs the encoder alignment and zero-reset procedure, and MC_GetAlignmentStatusMotor1() is used to check whether the alignment has been completed.

I have verified that the encoder Z (index) signal is working correctly and have checked the Z-index pulse separately. However, the alignment function call is still failing, and the alignment is not completing as expected.

Could you please help me identify what could be causing the alignment function to fail even though the Z-index signal is working correctly? Please also suggest which parameters, configuration settings, or firmware sections I should check for debugging this issue.

Reference: AN5464, Section 5.8 – API Usage.

Regards,
Prathmesh

5 replies

mƎALLEm
ST Technical Moderator
September 10, 2026

Hello,

All motor related questions including those related to the software issues need to be posted in the STM32 MCUs Motor control forum board.

I’ve already moved your post to the correct forum board.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
GMA
ST Technical Moderator
September 11, 2026

Hello ​@prathmeshpatil06,

Did you first try to use the hardware setup in field-oriented control (FOC) with the encoder as the main speed sensor before using position control mode?

Verify all motor connections: U, V, and W phases, and encoder A, B, and Z.

If you agree with the answer, please accept it by clicking on 'Best answer'.Best regards.GMA
Associate II
September 11, 2026

Dear GMA,

Thank you for your response.

Yes, I have verified the hardware setup. The U, V, and W motor phase connections and encoder A, B, and Z connections are correct. The motor is also running properly in FOC mode with the encoder configured as the main sensor.

I have also verified that the encoder Z (index) pulse is being received correctly during the motor rotation.

However, the issue occurs during the encoder alignment procedure. The alignment function is not completing successfully, and the AlignmentStatus is always going into the error state, even though the motor is running and the Z-index pulse is detected correctly.

Could you please suggest what could cause the alignment status to enter the error state in this situation? Is there any specific alignment parameter, encoder configuration, or firmware setting that I should check?

Regards,
Prathmesh

GMA
ST Technical Moderator
September 11, 2026

Hello ​@prathmeshpatil06,

If TC_ALIGNMENT_ERROR is reported, the Z signal is not detected after a 2*pi rotation.
Check whether the motor Pulses per mechanical revolution parameter is correct.
Check whether the Z signal is correct at the MCU input point and whether the associated EXT IRQ handler is triggered.

Position Control feature is also available without the absolute position control pin (ENC_Z).

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