Skip to main content
DKASA
Associate II
May 16, 2019
Question

Instructions for encoder alignment

  • May 16, 2019
  • 5 replies
  • 6264 views

I have the ST FOC motor control kit (Nucleo F302R8 , X-Nucleo- IMH07M1. I have been successful using FOC with sensorless feedback. I have installed and wired an absolute encoder and configured the number of pulses in the workbench. What I cannot find are instructions for aligning the encoder. I see the GUI in the motor control workbench has a button for "align encoder" but it is not clear to me how the offset is properly set. I have clicked align (small movement) and then start motor but I get no rotation, just high current draw and a locked rotor.

Any help would be appreciated. Thanks!

This topic has been closed for replies.

5 replies

cedric H
Technical Moderator
May 22, 2019

Hello,

the ST Motor control kit supports for now only the incremental encoder.

Could you describe the encoder you use. How many pluses and how many wires does your encoder have ?

Regards

Cedric

DKASA
DKASAAuthor
Associate II
May 22, 2019

Hi Cedric!

Thanks for the response. I'm using a quadrature single-ended encoder (ABZ pulses) with 2048 ppr. I actually have made process with the running bull motor included in the kit and I am actually able to use sensorless and encoder based feedback (in separate builds) with this motor. However, when i moved the encoder over to a different larger motor I am having issues such that when I click "align encoder" the rotor moves, but when I click "start motor" the shaft is locked and a the unit draws quite a bit of current (2A) but no fault occurs. To be clear with the new motor I have run the motor profiler and I am able to drive this larger motor in sensorless PLL+observer mode without any issue, it's just that when I configure the system for encoder based feedback I cannot get it to spin. I know the encoder works (validated with o-scope) and i'm confident in my settings for PPR and selecting the correct motor model in the workbench.

So I suppose my questions are:

1.Am I correct to assume the only thing that is needed to align the encoder to 90degrees is to set this alignment value in motor control work bench, build the project and then from the monitor click "align encoder" (shaft moves) then "start motor" and the motor should spin? Right now it just locks up.

2.Since the motor is not spinning but locked and drawing current I have tried reversing the counts (from workbench) and re-building, also tried different sequence wiring on the motor. The rotor is still locked, do you have any suggested next steps? This would be greatly appreciated. Thank you! Dan

ypu
Visitor II
May 17, 2020

Hello Daniel,

Do you have any update on that, I have the same issue as you now

DKASA
DKASAAuthor
Associate II
May 17, 2020

Unfortunately I don't. When I learned the library wasn't using the Z pulse this actually changed what I wanted to accomplish. It also explained why the motor moves each time it is re-started, it seems to re-align itself with a given pole and then start counting A&B pulses as a reference point for the rotor position. I did get it work in sensor mode eventually but it is really inconsistent. I was getting speed errors and I have to think that it is due to noise or false edges on the AB signals but I didn't take it any further as I just went sensorless. I would love to know if anyone learns any tips/tricks for this with the library working in sensored mode.

cedric H
Technical Moderator
May 23, 2019

Hello Daniel,

From my experience, your issue could be the connection order of your different motor phases. When using encoder or Hall sensors, you need to respect the U,V,W phases from the motor.

From now, the library does not make use of Z, it means that the angle will not be absolute but relative to the position of the shaft at T0.

Let me know if it works.

Cedric

LJim
Visitor II
May 28, 2019

Hi,Cedric.

I have the same problem with Daniel. I checked the PWM pins defined in "main.h" and the actual connection on my custom board, they are all correct.

Anyway, I switched the "U" and "W" on the motor side, and the motor do working. I ramp the speed to max forward and backward, it looked all fine.

But when I set the speed to 0 without the "Stop motor" instruction, the switch chip was breakdown about 10 Seconds later.

Laurent Ca...
Senior III
June 22, 2021

The question has been moved from the section "Motor Control Hardware" to the "STM32 Motor Control" section (the question is about the STM32 MC SDK). 

Best regards

cedric H
Technical Moderator
November 17, 2022

Hello @jartim​ 

Could you describe your issue, we will be happy to help you.

For your information, the Z-pulse can be used if you do position control.

Kind Regards

Cedric

jartim
Associate III
November 21, 2022

Hi, yes as you know I started out using V6. of the firmware only to be told by yourselves, after numerous attempts to get the motor driver working, that V6 isn't yet complete and shouldn't be used. So I reverted to V5.Y.4 which, while working a little better, is still littered with bugs and "strange" coding. I have spent many weeks fixing your driver bugs and removing over 360 incorrect or unnecessary type-casts from one data type to another and adding new ones where they should have been originally. Now I have got to the stage where I need to be able to set a particular angle (mechanical and electrical) from a defined encoder angle, at startup. Not setting zero, but a specific angle which is the angle the encoder starts up at. I have spent many hours on this, but nothing I do gets around the fact that the motor just spins continuously in one direction or another, without stopping at startup. It seems that either the firmware is incorrectly interpreting the encoder position or there is an error in the internal maths that causes it to not see the correct encoder angle. I have found this incredibly difficult to debug your software as it is so badly written as to be almost unintelligible. There are so many variables that are passed around, and no comments on a lot of them to describe what they are doing or how they are doing it. My original comment still stands, this code you wrote over 3 years ago, but it is in the same state now as it was then, and still no sign of a full V6 release with the bugs fixed and the documentation present. Hence my comment that I suspect there is no-one left there that actually understands how the original code was meant to work. And yes, I am really, really pi*sed off with having to use it, and ST's total lack of commitment to their products. Rant over, but please fix it.