Showing results for 
Search instead for 
Did you mean: 

MC after Stop command ABI encoder is dealigning

Associate III

I'm using custom firmware on EVSPING4 board.

After MC_StartMotor1() motor and ABI encoder is aligning, and everything works as expected.
After that I'm using MC_StopMotor1() command to stop motor and moving motor by hand.
After that I'm using MC_StartMotor1(), and It looks like motor working little worst. I don't want realign encoder again.

It's strange because ENCODER_M1->TIMx->CNT looks working.

I was reading ENC_CalcAngle(), and hElAngle (responsible by commutation) is calculated from hMecAngle, and hMecAngle is calculated from ENCODER_M1->TIMx->CNT.

What I'm doing wrong?


cedric H
ST Employee

Hello @ketchup ,

I did not understand if you use custom firmware or MCSDK 5.4.8. You mentioned both in your post.

Does this issue occur also with genuine MCSDK code ? Would it be possible to try with MCSDK 6.2.0 ?

I do not see anything wrong with your sequence. The key point is to be sure that you never miss any encoder timer tick, otherwise electrical angle and encoder angle information will be out of sync, I think it is what you observed.



Ok, My fault 🙂

I wrote an application using FW 1.5.1 and MC SDK 5.4.8 on an STSPING4 microcontroller. I'm using the ST MC SDK API, and I'm experiencing an issue.

The issue occurs when I use the motor start and stop functions. During motor shutdown, the motor moves. After re-enabling it, the encoder appears to be slightly realigned.

With MC SDK 5.Y.3 I've got the same result.

I'm wondering (because I can't find it in the code) is it possible that process which stops motor stops timer4 too (encoder) for few ms?

Fred V.
ST Employee

No, TIM4 is not stopped at this time. You can easily see that by using a debugger and setting a live view on the ENCODER_M1 structure or on the register bank of the timer. When the motor is stopped (after having run), you can turn the shaft with your hand and check that both change. Especially, the counter of the timer keeps on changing acording to the rotation of the rotor.

Best Regards

Fred V.

Yes, I see that encoder looks working - but motor working worse.

After stopping the engine when there is some torque on the arm (Motorcontrol switches to IDLE state), and the engine is moving because gravity (quite slowly, because the lower MOSFETs are on), when Motorcontrol will be switched to RUN mode (without realigning again), the engine performs differently/worse on the arm.

When I perform another aligning, the engine works perfectly again.

Let me know if you need further clarification. 

It looks like encoder lost few steps when stopping or restarting motor. It's for me very hard to debug.