# Stepmotor closed loop - matching encoder and microstep resolution

I am trying to get a high accuracy and not so extremely high resolution motor to work.

It's a step motor with 200 steps/rev and the motor driver can compute up to 400x microstepping. We have an high accuracy optical encoder with 4700000 lines per revolution (in reality there are 23600 physical lines, but 200x interpolation by the interface). And there is a 1:360 gearbox.

edit: The encoder is mounted at the actuator side, BEHIND the gearbox etc.

Our primary goal is to have an high overall accuracy better than 1 m°. The resolution is not as important as the accuracy. So there can be positions which are only discretely reachable (depending on the motor and microsteps).

In this setting let $N$ be the factor of microstepping and $M$ a prescaler (divider) for the encoder which can be set in the motor driver. There is NO multiplier.

The encoder resolution then is $\frac{360°\cdot M}{23600\cdot 200}\approx {76}\cdot{M} µ°$. while the resolution of the motor with gear is $\frac{360°}{360 \cdot 200 \cdot N}=\frac{5}{N}\mathrm{m}°.$ There is no way so far that the resolutions match i.e. $$\frac{360°\cdot M}{23600\cdot 200}=\frac{360°}{360 \cdot 200 \cdot N}\Leftrightarrow M\cdot N=\frac{23600}{360}\approx65.55556.$$ I can't choose any combination from M and N (both integer) to reach the 65.56, do you guys agree? The only way is to buy another encoder with a different line count, eg 18000 lines/rev?

I have a few questions about the whole thing:

1. If I could choose: Which resolution should be higher? Encoder or motor?
2. Is the fact I can't match the resolutions a problem regarding the accuracy or not? So shall we buy another encoder or not?
3. I can only reach positions which are multiples of $\frac{5}{N}$ millidegree, correct?
4. What if I want to control the motor with an PID control which is embedded in the motor driver, can there occur problems? Because I won't reach any arbitrary position 100% accurate if 2. is right.
5. Even if my set position is a multiple of $\frac{5}{N}m°$ there is no guarantee, that the STABLE (ie a position where the holding torque is high) electrical position matches my encoder position because of a) non linearity effects in the microstepping, b) misalignment of the encoder and c) effects made by the gearbox (c is an edit, sorry forget to mention it). A PID control could possibly not come to rest since the integral part sums and at any time the motor makes one "step" in the "right" direction. But then there is a error with opposite sign. So it oscillates the whole time, even if the position is a multiple of $\frac{5}{N}m°$. How to deal with that problem?
6. (this question is optional for my task but is interesting) Is there a way to set any arbitrary position with a step motor? I've read that stepping motors are nothing else than synchronous motors with a high number of poles, right? So a vector control could be appropriate, is that right?

Thank you very much!

edit:

From your two answers I see, that I possibly didn't say clear enough what the problems are ;-)

Question 6) really is optional. We need accurate positions, but not arbitrary positions. But I've read (unfortunately I can't remember where), that stepping motors in closed loop can behave like synchronous motors. Because they simply are synchronous motors with high pole number and more holding torque.

The main question here is how to choose the resolution of the encoder and the motor. Maybe we want to buy a new encoder and so I could get one with something else than 23600 lines to match the resolutions. But this is an effort that we can save if there is no advantage.

Does the encoder increase the accuracy in a microstep setup? I don't think so, because there is no "continous" control, only stepping. But the steps are not 100% precise due to nonlinearity etc?

I'm just wondering if this setup is so special? I know steppers are used open loop frequently, but a global motor and mechanical tools manufactor offered the closed loop system as it would be standard. It must be used there outside, almost every motor driver has an encoder input. So I thought I'd be a simple question :)

edit number 2:

Just to clarify: I don't want to throw money away, I'm just trying to make the existing systems (5 or 6 workstations with 2 motors and encoders for calibration tasks of sensors) a bit better.

I didn't buy the first version of the system since I'm new here. Nowerdays I'd maybe go with servos to be more flexible, but they are more expensive. The encoder is only used to ensure the endposition (in microsteps) is reached more or less. As a improvement I wanted to enable the embedded PID control to deal with velocity and load changes during a movement. But it seems as if driving the system with a PID controller is not the best idea, because there always will be some oscillation because the resolutions don't match?

The systems are accurate enough at the moment. It's more a question about how to improve the system in matters of speed and reliability. And for me personal to understand the things better.

Now the point regarding throwing away money: We will buy another system soon. To ensure compatibility we stay with the same components (this time, next time this could change because of my "research"). But there is the possiblity to choose another encoder resolution. This does not mean it's better - moreover it's worse, but still accurate enough. The main benefit I can think of is that the resolutions match. Either 1:1 or 1:2 (encoder is more accurate). I'm trying to find out, if this really is a benefit or not.

• If you want the precision on the actual actuator you need to get the position from there, not from the motors position – PlasmaHH Apr 24 '15 at 11:44
• I'm sorry, I forgot to mention that the encoder is mounted behind the gearbox, at the actuator. I've edited the text above. – Jan Apr 24 '15 at 11:54

forget it, because of 5. Edit: open loop.

The main question here is how to choose the resolution of the encoder [...]

Asking for a better encoder is simply not the right question to ask. A higher resolution encoder will bring the two states of the flip-flop-control (that you are essentially creating here) closer together, but it will remain a flip-flop.

[...] and the motor

As stated above, if you need accurate positions that are not arbitrary, just use open loop. It will be able to reach the positions as calculated in 3. and do so accurately. Choosing a higher resolution for the motor means smaller steps between positions. If this is necessary depends on what positions you want to reach.

Does the encoder increase the accuracy in a microstep setup?

No. A microstep is a microstep and reaching a position in between is still not accurately possible. The microsteps represent the smallest interpolation possible. If you need smaller steps, try to find electronics that do more microsteps per step.

but a global motor and mechanical tools manufactor offered the closed loop system as it would be standard

I worked for a company producing positioning systems like the one you describe. It doesn't matter if it is a standard or not. What matters is if it is the right tool for the job or not.

Maybe it is a standard product. But it's not the right product for your application.

almost every motor driver has an encoder input

Modern motor drivers are often able to control different kinds of actuators. For other actuators it is very common to be controlled in close loop, but that doesn't mean you have to use that input. Depending on the driver, the encoder input can be combined with the limit switches. Using limit switches is common for a lot of actuators (including stepper motors) to find the limits, because encoders usually do not give absolute position values.

And now for something completely different: Why do male humans have nipples?

So I thought I'd be a simple question

It is, just like the answer I provided above.

I have the feeling that you bought this positioning system, realised that it doesn't work in your application as intended and you think buying a newer/better/whatever encoder will solve your problems somehow.

It's very strange to me that you list all the problems that are intrinsic to a closed loop controlled stepper motor yourself, yet refuse to let go of your idea of a better encoder solving all your problems.

I don't know what kind of answer you expect. Maybe something like "Yes go ahead, throwing more money at it will make it work". But that's not the one I can give you, sorry.

In the end it will always be an on-off control between two microsteps. There's no way around it. They are called stepmotors for a reason.

If you are fine with being able to only reach those positions dictated by the microsteps of the stepper motor, just run it in open loop.

If you want smooth, accurate movement to arbitrary positions, use a regular motor.

From my experience with such systems, you need special requirements to justify a closed loop stepper motor and live with the drawback mentioned above.

1. The loop is closed. If the encoder has less resolution, it cannot distinguish between two positions of the motor. If the motor has less resolution, it cannot make that move to correct what the encoder measured as position error.
2. The stepper motor can only reach (and hold) the positions according to its (micro)steps. Those are the positions it can reach accurately. throwing a higher resolution encoder at it will not change that.
3. What positions a stepper motor can reach, depends on two numbers $\frac{steps}{revolution}$, which is a property of the motor itself and $\frac{microsteps}{step}$ which depends on the electronics that drive the motor. $$\frac{360°}{\frac{steps}{revolution} \times \frac{microsteps}{step}}=angle~of~one~microstep$$
4. Depends on your definition what a problem is for you (your system) if never reaching a position is a problem, then yes, there's your problem.
5. As pointed out above, use a different actuator or open loop
6. If you want to treat this like a synchronous motor, why don't you simply use a synchronous motor? I have seen it a lot that people come up with stepper motors for applications where they are simply not applicable. You stumbled upon some of the problems one can encounter. This is not an optional question. this is the mandatory first question of using the right tools for the right job. If you feel that a stepper motor is not the right tool for this job, don't try to force it into that role but pick a different actuator or control scheme.
• Well, I edited the question a bit. Thank you for your input so far, but sorry - I still dont't know how to choose the resolutions ;-) – Jan Apr 27 '15 at 8:42
• @user8648 I added some text to my answer addressing some of what you mention in your edit. – Magic Smoke Apr 27 '15 at 13:26
• I've edited another time. Thank you very much for your clear words. – Jan Apr 27 '15 at 14:07

Firstly, if you want precise, repeatable movements, microstepping at all may not be a good approach. Besides effects of non-linearity in the interpolation you mention, microsteps might not be repeatable for other reasons like stiction. That is, for small microsteps the motor might not move at all, whereas coming at the same position from a higher velocity, or from a different direction, results in a different position.

Secondly, if your motion target is a number of discrete steps, it's likely you will always have the problem where the motor's steps don't exactly get you to those steps unless you are lucky or can custom-order exactly the motor or mechanical transmission you need. This is essentially quantization noise in the spatial domain. While you may not be able to solve it at reasonable cost, if you research in that direction you can find how to at least quantify it, and determine if it can be engineered to be within your specifications. There are also some techniques like dithering to address the problem (or at least turn it into a different problem) which may or may not be useful, depending on your application.

And so to answer what I think was your basic question, no, there's not a way to get arbitrary position with a step motor. Stiction, slop in the transmission, and other such things mean that at some scale small enough, attempts to step more precisely aren't predictable.

The solution to this problem, if improving tolerances isn't an option, is a closed-loop system. Then the problem shifts to accurately measuring the current position, but slop and stiction become somewhat less of a problem since they are measured, and thus, the control loop can compensate for them.

• Thank you for your input, too. You mentioned a few points where I can do further research. To be clear, I do have an closed loop system here. I've got a high resolution encoder that brings me to the problems described above. Without the encoder I wouldn't even recognized them. – Jan Apr 27 '15 at 8:46