📜 ⬆️ ⬇️

Driving a stepper motor with a driver

What is a stepper motor?

I will call him below simply “motor”, for short.


I'll tell you briefly, you can read more about it in Wikipedia or here .
The easiest option:
There are four electromagnetic coils A, B, A ', B'. If a current is passed through them, they become magnets (coils A and B are active with the “forward” direction of the current, A 'and B' with “reverse”).
There is a wheel with teeth (for example, one tooth is an arrow).
The tooth is attracted to the coil through which current is passed. Thus, if we sequentially turn on the current in the coils, then the arrow will perform a rotational motion.
To make this movement smoother, you can add teeth, you can coil, and you can both that and the other - the principle remains the same, only the thrust and rotation angle changes in one on / off.
The following configuration is commonly used: the coils are arranged in four lines along the rotation perimeter, for every four there is a tooth, so there is a gear and many coils around it.
Consider the simplest model with four coils and one clove.
Let's think about how you can rotate the arrow.
Suppose its initial position is at B '.
1. The most obvious:
Turn on A: the arrow stops opposite A.
Turn off A, turn on B: the arrow goes to B and stops opposite.
Turn off B, turn on A ': the arrow stops already at A'.
Turn off A ', turn on B': the arrow goes to B 'and stops opposite.
Turn off B ', turn on A: the arrow stops in front of A., etc.
')
For each time, a rotation of 90 degrees takes place, a full circle, respectively, four times.
Quickly, but very sharply.
What is bad:
Sharp, because noisy.
Immediately a large angle of rotation, therefore, depending on the load, the inertia can be large, and the accelerated arrow will not stop immediately, therefore a longer delay is needed before turning off the current coil and turning on the next one.
Because of the problem above, if the speed is too high, you can lose control of the rotation, and something will fly away from you, or the movement will become quite strange.
What is good: relatively easy to implement.

2. A slightly less obvious solution:
Turn on A and B ': the arrow stops between A and B', exactly in the middle.
Turn off B ', turn on B: the arrow is fixed between A and B.
Turn off A, turn on A ': arrow between B and A'.
Turn off B, turn on B ': the arrow stops between A' and B '.
Turn off A ', turn on A: arrow between B' and A. Etc.
At the time - the same 90 degrees, a full circle, too, for four times.
Too sharply.
What is wrong:
All the same as in the previous method.
Plus a bit more difficult to implement, but not too much.
What well:
At the same time, two coils are “in force” at once, that is, the thrust is much better than the previous method.
Accordingly, the threshold speed + inertia, after which we lose control, becomes higher compared with the first method.

3. Grind steps:
Suppose that for each motor we have not only an on / off state, but a certain state table:
a)
0%
50%
100%
Here 50% means that the current in the coil is 50% of the maximum.
You can even smaller:
b)
0%
25%
50%
75%
100%
Or even smaller.
Then the sequence will be:
B '100%, A 0%
B '75%, A 25%
B '50%, A 50%
B '25%, A 75%
B '0%, A 100%
And the same for pairs AB, B-A ', A'-B', B'-B
What is wrong:
More difficult to implement.
What well:
The step is smaller, therefore less noise and rattling, the movement is smoother.
Fewer problems with inertia and loss of control.
You can make it even smaller, and the movement will be even smoother.

4. We will supply the current in an analog way.
So to say a limiting case when the frequency of splitting increases to infinity.
B 'is smoothly changing from 100% to 0%, A from 0% to 100%, and so on for all pairs AB, B-A', A'-B ', B'-B.
Why is it good:
Very smooth, good control, good traction. And tishinaaa.
What is bad:
Analog.
Patented

5. Use the following option:
Turn on B 'and A: the arrow between B' and A.
Turn off B ': arrow at A.
Turn on B: arrow between A and B.
Turn off A: arrow at V.
Turn A ': arrow between A' and B.
Turn off the: arrow at A '.
Turn on B ': arrow between B' and A '.
Turn off A ': arrow at B'
Turn on A: an arrow between B 'and A.
Etc.
It differs from “0%, 50%, 100%” of step 3 only by the burden. 5 - stronger.

Methods 1, 2, 3, 5 - standard, they even have designations.
If we assume the position “at the coil” is 1, and the position “between the coils” is 2, the following notation will become clear:
Mode 1 will be called 1 phase (full-step) (the arrow stops only in phase “1”), but it is almost not used - the traction is not good and in general.
Mode 2: 2 phase (full-step) (only in phase “2”).
Mode 5: 1-2 phase (half-step) (we stop at “1” and “2”).
Mode 3: Depending on the frequency of splitting:
4 (The cycle from the position “before the coil” to “before the next coil” is equal to four steps): 2W1-2 phase (2 * 2 = 4)
8: 4W1-2 phase (4 * 2 = 8)
In Russian microstage.

Mode 3 is not called in any way, because it is not used, and method 4 is patented.

Thus, the dependence of the current on time on coils A and B (A 'and B' correspond to negative values ​​of current) should be approximately the same (for the case of 1-2 phase).
image

Driver.

You can, of course, supply the current of the corresponding power in the right sequence directly to the motor, and you can use a chip that greatly simplifies the control. Such a chip is called a driver. We set the necessary mode settings (in registers), constantly send a timer signal to the driver, and the driver itself generates the output of the desired configuration.
We need: the driver itself (with a motor), a timer of sufficient frequency and a controlling device (processor, microcontroller or fpga).

In the general case, the driver has pins responsible for setting the mode and control pins.
For example:
Mode itself
image
The maximum current (from the maximum specification).
image
Control pins: timer, direction of rotation (clockwise, counterclockwise), reset pin and enabled pin.
image
CW - clock-wise
CCW - counter clock-wise
Initial mode - a predetermined state of the coils, corresponding to the "initial". It can be different for different modes. For example, 100% on A and 0% on B for 1-2 phase, 100% on A and -100% on B for 2 phase. Having held the motor in this mode for some time, we guarantee that the motor is turned in a certain way known in advance. You can start counting from this state (we also need to know at what point in time what position the motor is at).

Finally, we have a correctly set mode (for example, 1-2 phase) and a running timer. Then the driver output will look like this:
image

In general, everything.

For example, the driver from Toshiba TB6560AHQ / AFG was used, although the details are not very important, since the purpose of the article is to tell the general principle, without going into details.

Source: https://habr.com/ru/post/135950/


All Articles