How stepper drivers work - an attempt at an explanation ;-)

To administration: If this is not a suitable place for such an explanation, feel free to move ( or delete ) it.

Here in the forum it happens again and again that people ask for stepper motors for projects and which ones are suitable. The topic of stepper drivers with current control often comes up.
Unfortunately, incorrect advice is often given, which shows that the principles of current control have not been understood. At best, this leads to confusion for the questioner, at worst to wrong decisions.

I would therefore like to try to shed some light on the principles of current control (only simplified, without going deeper into the mathematical calculations). Nevertheless it's a lot of stuff, but maybe someone will read it after all :wink:
( Since English is not my native language, there will certainly be linguistic errors. I hope it is still understandable )

Let's go:
The principle of current control is also described in the A4988 data sheet, for example. However, in order to understand this description, a basic knowledge of electrical engineering is required that goes far beyond Ohm's law. This applies in particular to the behaviour of inductors and capacitors, which cannot be described using Ohm's law. Without understanding the function of these components, it is also impossible to understand the current control of steppers. Therefore, here are a few explanations of these components.

In contrast to an ohmic resistor, which is a consumer and converts electrical energy into heat, capacitors and coils are storage devices for electrical energy. This means that they can store electrical energy and also provide it again. Capacitors store energy as electrical charge, coils as a magnetic field.
The relationship between current and voltage in these components differs fundamentally from the relationship in an ohmic resistor. If, for example, a constant current flows into a capacitor, the voltage increases continuously over time. Conversely, the following applies to a coil: If a constant voltage is applied, the current increases continuously. The fact that this does not go on indefinitely is only due to the fact that neither the current/voltage source nor the real coils/inductances and capacitances are ideal components.

The following applies to a capacitor: The current is the externally specified value, which can also change abruptly. The voltage is the derived value, which is determined by the energy stored in the capacitor and therefore cannot change abruptly.

The following applies to an inductor: The applied voltage is the externally specified value that can change abruptly, the current is the derived value that depends on the stored energy and therefore cannot change abruptly.

N.B. A real capacitor is generally much 'closer' to the ideal than a real inductance (coil). A real inductance can easily understood as a series connection of an ideal inductance and an ohmic resistor. Thats why the coils of a stepper heat up very much.

So how does current control work in a stepper motor driver? Essentially, it consists of an H-bridge for each coil of the stepper and a circuit for measuring the current that flows through the H-bridge from the outside. In addition, a buffer capacitor is required at the input of the driver, which is charged via the power supply unit ( and via the stepper coils as we will see later ).

Here is an extract from the A4988 data sheet:

Now let's see how the driver controls the current:

Step 1
If a certain current is now to flow through one of the stepper coils, the coil is connected to the buffer capacitor via the H-bridge. The full capacitor voltage is now applied to the coil. The current flowing through the coil increases. Ultimately, some of the electrical energy stored in the buffer capacitor is now transferred to the coil. This current also flows through the current measuring shunt, and when the voltage drop at the shunt reaches the set reference value, the H-bridge switches off.

As already mentioned, however, the current through the coil cannot simply be switched off - it continues to flow in any case.
Here the current drivers have 2 modes: 'Fast decay' and 'Slow decay'

Step 2
In fast decay mode, the H-bridge is switched so that the current flows back into the buffer capacitor.

The external current flow is reversed - the voltage drop at the shunt becomes negative and the voltage at the coil also changes sign. The coil is now a generator and part of the energy just transferred from the capacitor to the coil is now pumped back into the capacitor. This causes the current to drop relatively quickly ('fast decay'). Current measurement is no longer possible, which is why this mode is time-controlled (approx. 10µs for the a4988).

Step 3
After this, the system switches to 'slow decay'. The coil is short-circuited via the H-bridge.


No more external current flows in this phase, the voltage drop at the shunt is 0. Energy is now only drawn from the coil via the losses in its ohmic resistance and possibly (during movement) via the magnetic fields in the motor. The current now only drops more slowly. However, the driver cannot measure this current either, which is why this mode is also terminated in a time-controlled manner and it reverts to step 1

To be continued ... ?

5 Likes

What we can see from the pictures above, the coil ( and its impedance ) and the bulk capacitor near the Vmot of driver are integral parts of the current controlling system. The driver itself (the A4988 in this case) isn't able to work correctly without these components. That also means the stepper must be connected for the driver to work. And you should never cut the connection to the stepper coils while the driver is working.

Looking at the 3 steps above, only in step 1 the driver is able to measure the coil current. This time is variable. It depends on how quickly the switch-off value of the current is reached. This in turn depends on the voltage across the buffer capacitor, the inductance of the coil and the energy drawn from the coil by the movement and ohmic losses.

Now let's have a look at a real working device. The 3 phases can be easily observed on the voltage curve of the shunt and the coil:


The green line is the voltage curve at the coil. You can see how the polarity of the voltage suddenly changes when switching to fast-decay mode. The coil changes from an energy consumer to an energy source and loads the buffer capacitor. When switchng to slow decay mode the coil is short-circuited, so there is no voltage anymore.

At the same time, the current through the shunt changes sign.

Positive voltage drop during the 'charging phase', negative voltage drop during 'fast decay' and no voltage drop during 'slow decay'.

N.B. Here you can also see why the current and shunt must be dimensioned so that 0.5V is not exceeded at the shunt: The negative voltage drop during switching is just as large as the positive one. If this were greater than 0.5V, the parasitic substrate diode would switch through in 'fast decay', which would destroy the driver.

The power supply unit must be dimensioned in such a way that it can compensate for the average energy drain from the buffer capacitor. The current flow diagram of the shunt shows that this average current is considerably lower than the current peaks in and out of the buffer capacitor.
As the voltage at the buffer capacitor generally fluctuates somewhat due to the energy flowing back and forth, a voltage-regulated 'hard' power supply unit is unfavourable here. Current and voltage regulation get in each other's way. However, many PSU will not be able to regulate these relatively high-frequency voltage fluctuations anyway.

to be continued ... :wink:

2 Likes

Stepper in motion

Next we will look at a stepper in motion and see how the current from the PSU changes depending on the state/load of the stepper.

The current driver tries to keep the current through the coil constant - that is what it has to do. And with a higher step frequency, it will get increasingly difficult. But this is only very indirectly related to the current drawn from the power supply unit. As with any motor, this is at its lowest at standstill. Just not 0, as with a DC motor. In contrast to a DC motor, our stepper also has a holding torque. The supply current therefore varies much less with a stepper between standstill and full load than with a DC motor. This is particularly the case with small steppers, where the losses are relatively high compared to the power. But generally as with all motors: the more load, the more current.

The current through the coil can be visualised a bit like a flywheel. Once it is turning, you only have to 'push' it a little at regular intervals to maintain its speed. The better the bearing, the less I have to push it. If someone else brakes, I have to push harder. The 'bearing' compares to the ohmic losses in the coils. The 'braking' compares to the load of the spinning rotor, which draws energy from the magnetic field of the coil.

Let's look at some measured values. The coil current is set to 1A , the power supply delivers 24V - a common value in the data sheets for current-controlled steppers. The motor is operated in full step mode. The buffer capacitor is generously dimensioned so that the current from the power supply unit is fairly steady and does not contain significant peaks.

1 - Standstill:


Violet: PSU current

Yellow: voltage at the shunt ( current to/from buffer capacitor).

Current from PSU (A):


The current through the coils (both are energised) is obout 2A! Nevertheless, the power supply unit only has to supply just under 300mA.

2 - Moving without load:

Step frequency is 1250 steps/sec
PSU current and shunt current:


green: step pulse

coil current:


Due to the measuring circuit, the step pule is shown inverted.

PSU current:


The current increases because kinetic energy is now also required. You can also see from the coil current that it does not increase linearly, but is somewhat 'bent'. This is due to the back-winding of the rotating rotor, which also counteracts the increase in current. At 24V, however, the effect is only very small. This can become very extreme with lower voltages ( see below )

3 - Load at the torque limit:



grafik
The non-linearity in the current rise in the coils is now more clearly visible. Switching the current off is faster, switching it on in the other direction of flow takes longer. Due to this pole reversal losses, the average coil current is lower than at standstill. Nevertheless, the current from the PSU unit is higher due to the higher mechanical load.


In the last two pictures you can see how worse it gets at lower voltages:
at 15V:

at9V:

The average current through the coils and thus the torque drops significantly


I hope this helps a little bit to understand some problems with stepper drivers. Of course there are much more sophisticated stepper drivers than the A4988. But the main principle of current control is always the same.

2 Likes

It might also be interesting to see how the current rises when the stepper blocks due to excessive load. As there is no longer any magnetic feedback from the rotating motor, the current now increases linearly - even at 9V:


But of course only as long as the Voltage is considerable higher than the rated coil voltage (I*Rcoil).

1 Like

@MicroBahner
Can we discuss the pictures here or you prefer leave the tutorial untouched?

I think we can discuss that here. So everything stays together. And if new insights arise, I can change or add to one of the first four posts accordingly. So if anyone is not interested in the discussion, you can just read the posts #1 to #4 only.

I apologize in advance for possibly stupid questions.

Where on the graph can you see that the current through the coils is 2 amperes?

In the graph above:
Why the shunt current affected by step pulse A, but not in case of B?
What causes the "wiggles" (selection C) on the shunt current graph without of step pulses?

The A4988 was set to 1A per coil. Because in fullstep both coils are energized at the same time this means 2A are flowing summarized. And you could see that if an a-meter in series with the coils ( I didn't show that, so you must believe me :wink: ).

What you see is only the shunt of one coil. At time 'B' the current in the other coil is switched.

That's how the driver regulates the current.
[Edit] In the end it is the same as in this picture:

But with another timebase, so you cannot see the details.

1 Like