Driver for stepper motor from epson printer. Stepper motor control. Connecting a stepper motor

Sooner or later, when building a robot, there will be a need for precise movements, for example, when you want to make a manipulator. There are two options here - servo, with feedback on current, voltage and coordinate, or a stepper drive. The servo drive is more economical, more powerful, but at the same time it has a very non-trivial control system and not everyone can do it, but stepper motor this is closer to reality.

Stepper motor this, as its name implies, is a motor that rotates discrete movements. This is achieved due to the clever shape of the rotor and two (less often four) windings. As a result, by alternating the direction of voltage in the windings, it is possible to ensure that the rotor will alternately occupy fixed values.
On average, a stepper motor takes about one hundred steps per shaft revolution. But this greatly depends on the engine model, as well as on its design. In addition, there are half-step And microstepping mode, when a PWM voltage is applied to the motor windings, forcing the rotor to stand between steps in an equilibrium state, which is maintained by different voltage levels on the windings. These tricks dramatically improve the accuracy, speed and noiselessness of operation, but the torque is reduced and the complexity of the control program greatly increases - after all, it is necessary to calculate the voltages for each step.

One of the disadvantages of steppers, at least for me, is that the current is quite high. Since voltage is supplied to the windings all the time, and such a phenomenon as back-EMF is not observed in it, unlike commutator motors, then, in fact, we are loading on the active resistance of the windings, and it is small. So be prepared for the fact that you will have to fence a powerful driver with MOSFET transistors or packed with special microcircuits.

Stepper Motor Types
If you don’t delve into the internal design, the number of steps and other subtleties, then from a user point of view there are three types:

  • Bipolar- has four outputs, contains two windings.
  • Unipolar- has six outputs. It contains two windings, but each winding has a tap from the middle.
  • Four-winding— has four independent windings. In essence, it is the same unipolar circuit, only its windings are separated. I haven’t met it in real life, only in books.
Unipolar differs from bipolar only in that it requires a much simpler control circuit, and it also has a much weaker torque. Since it only works with half windings. BUT! If we tear off the middle terminal of the unipolar, we get a regular bipolar. It is not difficult to determine which of the terminals is the middle one; just ring the resistance with a tester. From medium to extreme, the resistance will be equal to exactly half the resistance between the extreme terminals. So if you got a unipolar one, and the connection diagram is for a bipolar one, then don’t worry and tear off the middle wire.

Where can I get a stepper motor?
In general, steppers are found in many places. The most bready place - five-inch drives and old dot matrix printers. You can also profit from them in ancient 40MB hard drives, if, of course, you dare to damage such an antique.
But in three-inch floppers, a bummer awaits us - the fact is that the stepper is of a very flawed design - it has only one rear bearing, and the front end of the shaft rests against a bearing mounted on the drive frame. So you can only use it in its original mount. Or fence a high-precision fastening structure. However, you may be lucky and find an atypical flopper with a full-fledged engine.

Stepper motor control circuit
I got my hands on stepper controllers L297 and a powerful double axle L298N.

Lyrical digression, you can skip it if you wish


Connection diagram L298N+L297 It’s ridiculously simple - you just need to stupidly connect them together. They are so created for each other that in the datasheet on L298N there is a direct reference to L297, and in the dock at L297 on L298N.

All that remains is to connect the microcontroller.
  • At the entrance CW/CCW set the direction of rotation - 0 in one direction, 1 in the other.
  • at the entrance CLOCK- impulses. One impulse - one step.
  • entrance HALF/FULL sets the operating mode - full step/half step
  • RESET resets the driver to the default state ABCD=0101.
  • CONTROL determines how PWM is set, if it is zero, then PWM is generated through the enable outputs INH1 And INH2, and if 1 then through the outputs to the ABCD driver. This may come in handy if instead L298 which has somewhere to connect the permission inputs INH1/INH2 there will be either a homemade transistor bridge or some other microcircuit.
  • At the entrance Vref it is necessary to apply voltage from the potentiometer, which will determine the maximum overload capacity. If you apply 5 volts, the buder will work at its limit, and in case of overload it will burn out L298 If you supply less, it will simply stall at the maximum current. At first I stupidly drove the power there, but then I changed my mind and installed a tuning resistor - protection is still a useful thing, it would be bad if the driver L298 will burn.
    If you don’t care about protection, then you can also throw out the resistors hanging at the sense output. These are current shunts, from them L297 finds out what current flows through the driver L298 and decides whether he’ll die and it’s time to cut him off or whether he’ll last longer. More powerful resistors are needed there, given that the current through the driver can reach 4A, then with a recommended resistance of 0.5 Ohms, there will be a voltage drop of about 2 volts, which means the released power will be about 4 * 2 = 8 W - wow for a resistor! I installed two-watt ones, but my stepper was small and not capable of absorbing 4 amperes.

True, in the future, when I make a stepper drive for a robot, I will not take a bunch L297+L293, and mikruhu L6208 which may be a little weaker in current, but it’s two in one! Immediately connect the engine and start working. If you buy them, then the L6208 is even a little cheaper.

Stepper motors have long been successfully used in a wide variety of devices. They can be found in disk drives, printers, plotters, scanners, faxes, as well as in a variety of industrial and special equipment. Currently, there are many different types of stepper motors available for all occasions. However, choosing the right engine type is only half the battle. It is equally important to choose the right driver circuit and its operating algorithm, which is often determined by the microcontroller program. The purpose of this article is to systematize information about the structure of stepper motors, methods of controlling them, driver circuits and algorithms. As an example, a practical implementation of a simple and cheap stepper motor driver based on a microcontroller of the AVR family is given.

What is a stepper motor and why is it needed?

A stepper motor is an electromechanical device that converts electrical impulses into discrete mechanical movements. So, perhaps, we can give a strict definition. Probably everyone has seen what a stepper motor looks like externally: it is practically no different from other types of motors. Most often it is a round housing, a shaft, and several terminals (Fig. 1).

Rice. 1. Appearance of stepper motors of the DSHI-200 family.

However, stepper motors have some unique properties, which sometimes make them extremely convenient for use or even irreplaceable.

What is good about a stepper motor?

  • The angle of rotation of the rotor is determined by the number of pulses that are supplied to the motor
  • the motor provides full torque in stop mode (if the windings are energized)
  • Precise positioning and repeatability. Good stepper motors have an accuracy of 3-5% of the step size. This error does not accumulate from step to step
  • possibility of quick start/stop/reverse
  • high reliability due to the absence of brushes, the service life of the stepper motor is actually determined by the service life of the bearings
  • unambiguous position dependence on input pulses ensures positioning without feedback
  • possibility of obtaining very low rotation speeds for a load connected directly to the motor shaft without an intermediate gearbox
  • a fairly large range of speeds can be covered, the speed is proportional to the frequency of the input pulses

But not everything is so good...

  • Stepper motor is characterized by resonance phenomenon
  • Possible loss of position control due to operation without feedback
  • Energy consumption does not decrease even without load
  • difficult to work on high speeds
  • low power density
  • relatively complex control scheme

What to choose?

Stepper motors belong to the class of brushless DC motors. Like any brushless motors, they have high reliability and long service life, which allows them to be used in critical applications, such as industrial applications. Compared to conventional DC motors, stepper motors require significantly more complex control circuits that must handle all winding switching when the motor is running. In addition, the stepper motor itself is an expensive device, so where precise positioning is not required, conventional brushed motors have a distinct advantage. To be fair, it should be noted that in Lately To control commutator motors, controllers are increasingly being used, which are almost as complex as stepper motor controllers.

One of the main advantages of stepper motors is the ability to perform precise positioning and speed control without a feedback sensor. This is very important, since such sensors can cost much more than the engine itself. However, this is only suitable for systems that operate at low acceleration and with a relatively constant load. At the same time, systems with feedback are capable of operating with high accelerations and even with a variable load. If the load on the stepper motor exceeds its torque, then information about the rotor position is lost and the system requires basing using, for example, a limit switch or other sensor. Feedback systems do not have this disadvantage.

When designing specific systems, you have to make a choice between a servomotor and a stepper motor. When precision positioning and precise speed control are required, and the required torque and speed are within acceptable limits, a stepper motor is the most economical solution. As with conventional engines, a reduction gear can be used to increase torque. However, a gearbox is not always suitable for stepper motors. Unlike commutator motors, in which the torque increases with increasing speed, a stepper motor has greater torque at low speeds. In addition, stepper motors have a much lower maximum speed compared to brushed motors, which limits the maximum gear ratio and, accordingly, the increase in torque using a gearbox. Although ready-made stepper motors with gearboxes exist, they are exotic. Another fact that limits the use of the gearbox is its inherent backlash.

The ability to achieve low speeds is often the reason why designers, unable to design a gearbox, use stepper motors unnecessarily often. At the same time, the commutator motor has higher power density, low cost, simple control circuit, and together with a single-stage worm gearbox, it can achieve the same speed range as a stepper motor. In addition, this provides significantly greater torque. Drives based on commutator motors are very often used in military equipment, and this indirectly indicates the good parameters and high reliability of such drives. And in modern household appliances, cars, industrial equipment commutator motors are quite common. However, stepper motors have their own, albeit rather narrow, scope of application where they are irreplaceable.

Types of stepper motors

There are three main types of stepper motors:

  • variable reluctance motors
  • permanent magnet motors
  • hybrid engines

You can even determine the type of motor by touch: when the shaft of a de-energized permanent magnet motor (or hybrid) rotates, a variable resistance to rotation is felt, the motor rotates as if clicking. At the same time, the shaft of a de-energized motor with variable magnetic reluctance rotates freely. Hybrid motors are a further improvement of permanent magnet motors and are no different from them in their control method. The type of motor can also be determined by the configuration of the windings. Motors with variable reluctance usually have three (less often four) windings with one common terminal. Permanent magnet motors most often have two independent windings. These windings may have taps from the middle. Sometimes permanent magnet motors have 4 separate windings.

In a stepper motor, torque is generated by the magnetic fluxes of the stator and rotor, which are suitably oriented relative to each other. The stator is made of a material with high magnetic permeability and has several poles. A pole can be defined as some region of a magnetized body where the magnetic field is concentrated. Both the stator and the rotor have poles. To reduce eddy current losses, magnetic cores are assembled from separate plates, like the core of a transformer. The torque is proportional to the magnitude of the magnetic field, which is proportional to the current in the winding and the number of turns. Thus, the torque depends on the parameters of the windings. If at least one winding of the stepper motor is energized, the rotor takes a certain position. It will remain in this position until the externally applied torque exceeds a certain value called the holding torque. After this, the rotor will turn and will try to take one of the following equilibrium positions.

Variable reluctance motors

Stepper motors with variable magnetic reluctance have several poles on the stator and a gear-shaped rotor made of soft magnetic material (Fig. 2). There is no rotor magnetization. For simplicity, in the picture the rotor has 4 teeth and the stator has 6 poles. The motor has 3 independent windings, each of which is wound on two opposite poles of the stator. This motor has a pitch of 30 degrees.

Rice. 2. Motor with variable magnetic reluctance.

When the current is turned on in one of the coils, the rotor tends to take a position where the magnetic flux is closed, i.e. the rotor teeth will be opposite those poles on which the powered winding is located. If you then turn off this winding and turn on the next one, the rotor will change position, again closing the magnetic flux with its teeth. Thus, in order to carry out continuous rotation, you need to turn on the phases alternately. The motor is not sensitive to the direction of current in the windings. The actual engine may have large quantity stator poles and more rotor teeth, which corresponds to more steps per revolution. Sometimes the surface of each stator pole is geared, which, together with the corresponding rotor teeth, provides a very small pitch angle, on the order of several degrees. Variable reluctance motors are rarely used in industrial applications.

Permanent magnet motors

Permanent magnet motors consist of a stator, which has windings, and a rotor containing permanent magnets (Fig. 3). The alternating poles of the rotor have a rectilinear shape and are located parallel to the axis of the motor. Due to the magnetization of the rotor, such motors provide greater magnetic flux and, as a result, greater torque than motors with variable reluctance.

Rice. 3. Permanent magnet motor.

The motor shown in the figure has 3 pairs of rotor poles and 2 pairs of stator poles. The motor has 2 independent windings, each of which is wound on two opposite poles of the stator. Such a motor, like the previously discussed motor with variable magnetic reluctance, has a step size of 30 degrees. When the current is turned on in one of the coils, the rotor tends to take a position where the opposite poles of the rotor and stator are opposite each other. To carry out continuous rotation, you need to turn on the phases alternately. In practice, permanent magnet motors typically have 48 - 24 steps per revolution (step angle 7.5 - 15 degrees).

A cross-section of a real permanent magnet stepper motor is shown in Fig. 4.

Rice. 4. Section of a stepper motor with permanent magnets.

To reduce the cost of engine design, the stator magnetic circuit is made in the form of a stamped glass. Inside there are pole pieces in the form of lamellas. The phase windings are placed on two different magnetic cores, which are installed on top of each other. The rotor is a cylindrical multi-pole permanent magnet.

Permanent magnet motors are subject to back EMF from the rotor, which limits the maximum speed. To operate at high speeds, variable reluctance motors are used.

Hybrid engines

Hybrid motors are more expensive than permanent magnet motors, but they provide smaller pitch, higher torque and higher speed. Typical steps per revolution for hybrid engines range from 100 to 400 (step angle 3.6 - 0.9 degrees). Hybrid motors combine the best features of variable reluctance motors and permanent magnet motors. The rotor of a hybrid engine has teeth located in the axial direction (Fig. 5).

Rice. 5. Hybrid engine.

The rotor is divided into two parts, between which there is a cylindrical permanent magnet. Thus, the teeth of the upper half of the rotor are the north poles, and the teeth of the lower half are the south poles. In addition, the upper and lower halves of the rotor are rotated relative to each other by half the pitch angle of the teeth. The number of pairs of rotor poles is equal to the number of teeth on one of its halves. The toothed rotor pole pieces, like the stator, are assembled from separate plates to reduce eddy current losses. The stator of the hybrid motor also has teeth, providing a large number of equivalent poles, as opposed to the main poles on which the windings are located. Typically 4 main poles are used for 3.6 deg. motors and 8 main poles for 1.8- and 0.9 deg. engines. Rotor teeth provide less resistance to the magnetic circuit at certain rotor positions, which improves static and dynamic torque. This is ensured by the appropriate arrangement of the teeth, when part of the rotor teeth is strictly opposite the stator teeth, and part is between them. The relationship between the number of rotor poles, the number of equivalent stator poles and the number of phases determines the pitch angle S of the motor:

S = 360/(Nph*Ph) = 360/N,

where Nph - number of equivalent poles per phase = number of rotor poles,
Ph - number of phases,
N is the total number of poles for all phases together.

The rotor of the motor shown in the figure has 100 poles (50 pairs), the motor has 2 phases, so the total number of poles is 200, and the pitch, accordingly, is 1.8 degrees.

The longitudinal section of the hybrid stepper motor is shown in Fig. 6. The arrows indicate the direction of the magnetic flux of the permanent magnet of the rotor. Part of the flux (shown as a black line in the figure) passes through the rotor pole pieces, air gaps and the stator pole piece. This part is not involved in creating momentum.

Rice. 6. Longitudinal section of a hybrid stepper motor.

As can be seen in the figure, the air gaps at the upper and lower pole pieces of the rotor are different. This is achieved by turning the pole pieces by half the tooth pitch. Therefore, there is another magnetic circuit that contains minimal air gaps and, as a result, has minimal magnetic resistance. This circuit closes another part of the flow (shown in the figure by a dashed white line), which creates the torque. Part of the chain lies in a plane perpendicular to the figure and is therefore not shown. The magnetic flux of the stator coil is created in the same plane. In a hybrid motor, this flux is partially closed by the rotor pole pieces, and the permanent magnet “sees” it weakly. Therefore, unlike DC motors, the magnet of a hybrid motor cannot be demagnetized at any level of winding current.

The gap between the rotor and stator teeth is very small - typically 0.1 mm. This requires high precision during assembly, so the stepper motor should not be disassembled to satisfy curiosity, otherwise its service life may end.
To prevent the magnetic flux from closing through the shaft that passes inside the magnet, it is made of non-magnetic steel grades. They usually have increased fragility, so shafts, especially small ones, should be handled with care.

To obtain large torques, it is necessary to increase both the field created by the stator and the field of the permanent magnet. This requires a larger rotor diameter, which worsens the torque to inertia ratio. Therefore, powerful stepper motors are sometimes constructed from several sections in the form of a stack. Torque and moment of inertia increase in proportion to the number of sections, and their ratio does not deteriorate.

There are other designs of stepper motors. For example, motors with a magnetized disk rotor. Such motors have a low rotor moment of inertia, which is important in some cases.

Most modern stepper motors are hybrid. Essentially, a hybrid motor is a permanent magnet motor, but with a large number poles. In terms of the control method, such motors are identical; only such motors will be considered further. Most often in practice, motors have 100 or 200 steps per revolution, respectively, the step is 3.6 degrees or 1.8 degrees. Most controllers allow half-stepping, where this angle is half the size, and some controllers offer micro-stepping.

Bipolar and unipolar stepper motors

Depending on the winding configuration, motors are divided into bipolar and unipolar. A bipolar motor has one winding in each phase, which must be reversed by the driver to change the direction of the magnetic field. This type of motor requires a bridge driver, or a half-bridge driver with bipolar power supply. In total, the bipolar motor has two windings and, accordingly, four outputs (Fig. 7a).

Rice. 7. Bipolar motor (a), unipolar (b) and four-winding (c).

A unipolar motor also has one winding in each phase, but a tap is made from the middle of the winding. This allows you to change the direction of the magnetic field created by the winding by simply switching the winding halves. At the same time, the driver circuit is significantly simplified. The driver should only have 4 simple keys. Thus, a unipolar motor uses a different method of changing the direction of the magnetic field. The middle terminals of the windings can be combined inside the motor, so such a motor can have 5 or 6 terminals (Fig. 7b). Sometimes unipolar motors have 4 separate windings, for this reason they are mistakenly called 4-phase motors. Each winding has separate terminals, so there are 8 terminals in total (Fig. 7c). With appropriate winding connections, such a motor can be used as unipolar or bipolar. A unipolar motor with two windings and taps can also be used in bipolar mode if the taps are left unconnected. In any case, the winding current should be selected so as not to exceed the maximum power dissipation.

Bipolar or unipolar?

If we compare bipolar and unipolar motors, then the bipolar motor has a higher power density. With the same dimensions, bipolar motors provide greater torque.

The torque produced by a stepper motor is proportional to the magnitude of the magnetic field created by the stator windings. The way to increase the magnetic field is to increase the current or the number of turns of the windings. A natural limitation when increasing winding current is the danger of saturation of the iron core. However, in practice this restriction rarely applies. Much more significant is the limitation on motor heating due to ohmic losses in the windings. This fact demonstrates one of the advantages of bipolar engines. In a unipolar motor, only half of the windings are used at any given time. The other half simply takes up space in the core window, which forces the windings to be made with smaller diameter wire. At the same time, in a bipolar motor all windings are always working, i.e. their use is optimal. In such a motor, the cross-section of the individual windings is twice as large, and the ohmic resistance is correspondingly half as large. This allows you to increase the current to the root of two times with the same losses, which gives a gain in torque of approximately 40%. If increased torque is not required, a unipolar motor allows you to reduce dimensions or simply operate with lower losses. In practice, unipolar motors are still often used, since they require significantly more simple circuits winding control. This is important if the drivers are implemented on discrete components. Currently, there are specialized driver microcircuits for bipolar motors, using which the driver is no more complicated than for a unipolar motor. For example, these are chips L293E, L298N or L6202 from SGS-Thomson, PBL3770, PBL3774 from Ericsson, NJM3717, NJM3770, NJM3774 from JRC, A3957 from Allegro, LMD18T245 from National Semiconductor.

Diagrams, diagrams...

There are several ways to control the phases of a stepper motor.

The first method is provided by alternating switching of phases, while they do not overlap; only one phase is switched on at one time (Fig. 8a). This method is called “one phase on” full step or wave drive mode. The rotor equilibrium points for each step coincide with the “natural” rotor equilibrium points of an unpowered motor. The disadvantage of this control method is that for a bipolar motor, 50% of the windings are used at the same time, and for a unipolar motor, only 25%. This means that the full torque cannot be obtained in this mode.

Rice. 8. Various ways to control the phases of a stepper motor.

The second method is phase overlap control: two phases are switched on at the same time. It is called “two-phase-on” full step or simply full step mode. With this control method, the rotor is fixed in intermediate positions between the stator poles (Fig. 8b) and approximately 40% more torque is provided than in the case of one phase on. This control method provides the same step angle as the first method, but the position of the rotor balance points is shifted by half a step.

The third method is a combination of the first two and is called half-step mode, “one and two-phase-on” half step or simply half step mode, when the engine takes half the main step. This control method is quite common since a lower pitch motor costs more and it is very tempting to get 200 steps per revolution out of a 100 step motor. Every second step, only one phase is powered, and in other cases two are powered (Fig. 8c). As a result, the angular movement of the rotor is half the pitch angle for the first two control methods. In addition to reducing the step size, this control method allows us to partially get rid of the resonance phenomenon. Half-stepping usually does not provide full torque, although the most advanced drivers implement a modified half-stepping mode in which the motor provides almost full torque without dissipating more than rated power.

Another control method is called microstepping mode. With this control method, the current in the phases must be changed in small steps, thus ensuring the splitting of a half step into even smaller microsteps. When two phases are switched on simultaneously, but their currents are not equal, then the equilibrium position of the rotor will not lie in the middle of the step, but in a different place, determined by the ratio of the phase currents. By changing this ratio, it is possible to provide a certain number of microsteps within one step. In addition to increasing resolution, microstepping mode has other advantages, which will be described below. At the same time, to implement the microstepping mode, much more complex drivers are required, which make it possible to set the current in the windings with the required discreteness. The half-step mode is a special case of the microstep mode, but it does not require the formation of a stepwise current to supply the coils, so it is often implemented.

Hold him!

In full-step mode with two phases turned on, the positions of the rotor equilibrium points are shifted by half a step. It should be noted that the rotor takes these positions when the engine is running, but the position of the rotor cannot remain unchanged after the winding current is turned off. Therefore, when turning the motor power on and off, the rotor will shift by half a step. To prevent it from shifting when stopped, it is necessary to supply a holding current to the windings. The same is true for half-stepping and microstepping modes. It should be noted that if the motor rotor was turning when the engine was turned off, then when the power was turned on, the rotor could shift by more than half a step.

The holding current may be less than the rated current, since a motor with a fixed rotor usually does not require much torque. However, there are applications where the motor must provide full torque when stopped, which is possible for a stepper motor. This property of the stepper motor allows in such situations to do without mechanical braking systems. Since modern drivers allow you to regulate the supply current to the motor windings, setting the required holding current is usually not a problem. The task is usually simply to provide appropriate software support for the control microcontroller.

Half-step mode

The basic principle of operation of a stepper motor is to create a rotating magnetic field that causes the rotor to turn. The rotating magnetic field is created by the stator, the windings of which are energized accordingly.

For a motor with one winding energized, the dependence of the torque on the angle of rotation of the rotor relative to the equilibrium point is approximately sinusoidal. This dependence for a two-winding motor, which has N steps per revolution (step angle in radians S = (2*pi)/N), is shown in Fig. 9.

Rice. 9. Dependence of torque on the angle of rotation of the rotor for one powered winding.

In reality, the nature of the dependence may be somewhat different, which is explained by the non-ideal geometry of the rotor and stator. The peak value of the torque is called the holding torque. The formula describing the dependence of torque on the angle of rotation of the rotor is as follows:

T = - Th*sin((pi/2)/S)*Ф),

where T is the moment, Th is the holding moment,
S - step angle,
Ф - rotor rotation angle.

If an external torque is applied to the rotor that exceeds the holding torque, the rotor will rotate. If the external torque does not exceed the holding torque, then the rotor will be in equilibrium within the pitch angle. It should be noted that for a de-energized motor the holding torque is not zero due to the action of the permanent magnets of the rotor. This torque is usually about 10% of the maximum torque provided by the engine.

The terms “mechanical rotor angle” and “electrical rotor angle” are sometimes used. The mechanical angle is calculated based on the fact that a complete rotation of the rotor is 2 * pi radians. When calculating the electric angle, it is assumed that one revolution corresponds to one period of the angular dependence of the moment. For the above formulas, Ф is the mechanical angle of rotation of the rotor, and the electrical angle for a motor having 4 steps on the period of the torque curve is equal to ((pi/2)/S)*Ф or (N/4)*Ф, where N is the number steps per revolution. The electrical angle actually determines the angle of rotation of the stator magnetic field and allows us to build a theory independent of the number of steps per revolution for a particular motor.

If two motor windings are powered simultaneously, the torque will be equal to the sum of the torques provided by the windings separately (Fig. 10).

Rice. 10. Dependence of torque on the angle of rotation of the rotor for two powered windings.

Moreover, if the currents in the windings are the same, then the point of maximum torque will be shifted by half the step. The rotor equilibrium point (point e in the figure) will also shift by half a step. This fact forms the basis for the implementation of the half-step mode. The peak value of the torque (holding torque) will be the root of two times greater than with one powered winding.

Th 2 = 2 0.5 *Th 1,

where Th 2 is the holding torque with two energized windings,
Th 1 - holding torque with one energized winding.

It is this moment that is usually indicated in the characteristics of the stepper motor.

The magnitude and direction of the magnetic field are shown in the vector diagram (Fig. 11).

Rice. 11. Magnitude and direction of the magnetic field for different phase power modes.

The X and Y axes coincide with the direction of the magnetic field created by the windings of the first and second phases of the motor. When the engine operates with one phase turned on, the rotor can occupy positions 1, 3, 5, 7. If two phases are turned on, the rotor can occupy positions 2, 4, 6, 8. In addition, in this mode there is more torque, since it is proportional to the length of the vector in the figure. Both of these control methods provide a full step, but the rotor equilibrium positions are shifted by half a step. If you combine these two methods and apply appropriate sequences of pulses to the windings, you can force the rotor to sequentially occupy positions 1, 2, 3, 4, 5, 6, 7, 8, which corresponds to a half step.

Compared to full-step mode, half-step mode has the following advantages:

  • higher resolution without the use of more expensive motors
  • less problems with the phenomenon of resonance. Resonance leads to only a partial loss of torque, which usually does not interfere with the normal operation of the drive.

The disadvantage of the half-step mode is that the torque fluctuates quite significantly from step to step. In those rotor positions when one phase is energized, the torque is approximately 70% of the total when two phases are energized. These vibrations can cause increased vibration and noise, although they are still less than in full-step mode.

A way to eliminate torque fluctuations is to raise the torque in positions with one phase engaged and thus ensure the same torque in all rotor positions. This can be achieved by increasing the current in these positions to approximately 141% of rated current. Some drivers, such as the PBL 3717/2 and PBL 3770A from Ericsson, have logic inputs for changing the current value. It should be noted that the value of 141% is theoretical, therefore, in applications requiring high accuracy of torque maintenance, this value must be selected experimentally for a specific speed and a specific engine. Since the current only rises when one phase is on, the power dissipated is equal to full-step power at 100% of the rated current. However, such an increase in current requires a higher supply voltage, which is not always possible. There is another approach. To eliminate torque fluctuations when the motor is running in half-step mode, you can reduce the current at those moments when two phases are turned on. To obtain a constant torque, this current must be 70.7% of the rated current. In this way, the half-step mode is implemented, for example, by the A3955 driver chip from Allegro.

For half-step mode, the transition to a state with one phase off is very important. To force the rotor into the appropriate position, the current in the off phase must be reduced to zero as quickly as possible. The duration of the current decay depends on the voltage on the winding at the time it loses its stored energy. By shorting the winding at this time to the power source, which represents the maximum voltage available in the system, the fastest possible decrease in current is ensured. To obtain a rapid drop in current when powering the motor windings with an H-bridge, all transistors must be turned off, while the winding through diodes is connected to the power source. The rate of current decay will be significantly reduced if one transistor of the bridge is left open and the winding is short-circuited across the transistor and diode. To increase the rate of current decay when controlling unipolar motors, it is preferable to suppress self-induction EMF surges not with diodes, but with varistors or a combination of diodes and a zener diode, which will limit the surge to a higher but safe level for transistors.

Microstepping mode

Microstepping is achieved by obtaining a stator field that rotates more smoothly than in full or half-stepping modes. The result is less vibration and virtually silent operation down to zero frequency. In addition, a smaller step angle can provide more accurate positioning. There are many different microstepping modes, with step sizes ranging from 1/3 of a full step to 1/32 or even smaller. The stepper motor is a synchronous electric motor. This means that the equilibrium position of the stationary rotor coincides with the direction of the stator magnetic field. When the stator field turns, the rotor also turns, trying to take a new equilibrium position.

Rice. 12. Dependence of torque on the angle of rotation of the rotor in the case different meanings phase current.

To obtain the desired direction of the magnetic field, it is necessary to choose not only the correct direction of the currents in the coils, but also the correct ratio of these currents.

If two motor windings are simultaneously powered, but the currents in these windings are not equal (Fig. 12), then the resulting torque will be

Th = (a 2 + b 2) 0.5,

and the rotor equilibrium point will shift to the point

x = (S / (pi/2)) arctan(b / a),

where a and b are the torque created by the first and second phases, respectively,
Th is the resulting holding moment,
x is the rotor equilibrium position in radians,
S - step angle in radians.

The displacement of the rotor equilibrium point indicates that the rotor can be fixed in any arbitrary position. To do this, you just need to correctly set the ratio of currents in the phases. It is this fact that is used when implementing the microstepping mode.
Once again, it should be noted that the above formulas are correct only if the dependence of the torque on the angle of rotation of the rotor is sinusoidal and if no part of the motor’s magnetic circuit is saturated.

In the limit, a stepper motor can operate as a synchronous motor in continuous rotation mode. To do this, the currents of its phases must be sinusoidal, shifted relative to each other by 90 degrees.

The result of using microstepping is that the rotor rotates much smoother at low frequencies. At frequencies 2 - 3 times higher than the natural resonant frequency of the rotor and load, the microstepping mode provides minor advantages compared to half- or full-stepping modes. The reason for this is the filtering effect of the rotor and load inertia. A stepper motor system works like a low pass filter. In microstepping mode, you can only perform acceleration and deceleration, and most of the time you can work in full-stepping mode. In addition, to achieve high speeds in microstepping mode, a very high repetition rate of microsteps is required, which the control microcontroller cannot always provide. To prevent transient processes and loss of steps, switching engine operating modes (from microstepping mode to full-stepping mode, etc.) must be done at those moments when the rotor is in the position corresponding to one phase turned on. Some microstepping mode driver microcircuits have a special signal that informs about this position of the rotor. For example, this is the A3955 driver from Allegro.

In many applications where small relative movements and high resolution are required, microstepping can replace a mechanical gearbox. Often the simplicity of the system is a decisive factor, even if this means using a large motor. Despite the fact that the driver providing microstepping mode is much more complex than a conventional driver, the system can still turn out to be simpler and cheaper than a stepper motor plus gearbox. Modern microcontrollers sometimes have built-in DACs that can be used to implement microstepping instead of dedicated controllers. This makes it possible to make the cost of equipment for full-step and microstep modes almost the same.

Sometimes microstepping is used to increase the precision of the step size beyond that stated by the motor manufacturer. The nominal number of steps is used. To improve accuracy, correction of the rotor position at the equilibrium points is used. To do this, first take a characteristic for a specific motor, and then, changing the ratio of currents in the phases, adjust the rotor position individually for each step. This method requires preliminary calibration and additional resources of the control microcontroller. In addition, an initial rotor position sensor is required to synchronize its position with the table of correction coefficients.

In practice, when performing each step, the rotor does not immediately stop in a new equilibrium position, but carries out damped oscillations around the equilibrium position. The settling time depends on the load characteristics and the driver circuit. In many applications such fluctuations are undesirable. You can get rid of this phenomenon by using a microstepping mode. In Fig. Figure 13 shows the rotor movements when operating in full-step and microstep modes.

Rice. 13. Rotor movements in full-step and microstep modes.

It can be seen that in the full-step mode there are surges and oscillations, while in the microstep mode there are none. However, even in this mode, the rotor position graph differs from a straight line. This error is explained by the error in the geometry of the engine parts and can be reduced by calibration and subsequent compensation by adjusting the phase currents.
In practice, there are some factors that limit the accuracy of a microstepping drive. Some of them relate to the driver, and some directly to the engine.

Typically, stepper motor manufacturers indicate a parameter such as step accuracy. The pitch accuracy is indicated for the rotor equilibrium positions with two phases turned on, the currents of which are equal. This corresponds to full-step mode with phase overlap. For microstepping mode, when the phase currents are not equal, no data is usually provided.

An ideal stepper motor, when feeding phases with sinusoidal and cosine current, should rotate at a constant speed. A real engine in this mode will experience some speed fluctuations. This is due to the instability of the air gap between the poles of the rotor and stator, the presence of magnetic hysteresis, which leads to errors in the magnitude and direction of the magnetic field, etc. Therefore, the equilibrium positions and moment have some deviations. These deviations depend on the error in the shape of the rotor and stator teeth and on the magnetic core material used.

Some motor designs are optimized for best full-step accuracy and maximum holding torque. The special shape of the rotor and stator teeth is designed so that in the equilibrium position for full-step operation, the magnetic flux increases greatly. This leads to deterioration of precision in microstepping mode. top scores make it possible to obtain motors with a lower de-energized holding torque.

Deviations can be divided into two types: deviations in the magnitude of the magnetic field, which lead to deviations of the holding torque in microstepping mode, and deviations in the direction of the magnetic field, which lead to deviations in the equilibrium position. Deviations of the holding torque in microstepping mode are usually 10 - 30% of the maximum torque. It must be said that even in full-step mode, the holding torque can fluctuate by 10 - 20% due to distortions in the geometry of the rotor and stator.

If you measure the equilibrium positions of the rotor when the engine rotates clockwise and counterclockwise, you will get slightly different results. This hysteresis is primarily due to magnetic hysteresis of the core material, although friction also contributes. Magnetic hysteresis leads to the fact that the magnetic flux depends not only on the winding current, but also on its previous value. The error created by hysteresis can be equal to several microsteps. Therefore, in high-precision applications, when moving in one direction, you need to go beyond the desired position and then return back, so that the desired position is always approached in one direction.

It is quite natural that any desired increase in resolution encounters some physical limitations. Do not think that the positioning accuracy for 7.2 degrees. motor in microstepping mode is not inferior to the accuracy of 1.8 degrees. engine.

The obstacles are the following physical limitations:

  • The torque rise with rotation angle of the 7.2 degree engine is four times flatter than that of a true 1.8 degree engine. Due to the frictional moment or moment of inertia of the load, the positioning accuracy will be worse
  • as will be shown below, if there is friction in the system, then due to the appearance of dead zones, the positioning accuracy will be limited
  • Most commercial motors are not precision designed and the relationship between torque and rotor angle is not exactly sinusoidal. As a result, the relationship between the phase of the sinusoidal supply current and the shaft rotation angle will be nonlinear. As a result, the motor rotor will accurately pass through the positions of each step and half-step, and quite significant deviations will be observed between these positions

These problems are most pronounced for motors with a large number of poles. However, there are motors that are optimized for operation in microstepping mode even at the development stage. The rotor and stator poles of such motors are less pronounced due to the beveled shape of the teeth.

Another source of positioning errors is the quantization error of the DAC, with the help of which the phase currents are formed. The fact is that the current must be formed according to a sinusoidal law, therefore, to minimize the error, the linear DAC must have an increased bit capacity. There are specialized drivers with a built-in nonlinear DAC, which allows you to immediately obtain calculations of the sin function. An example is the A3955 driver from Allegro, which has a built-in 3-bit DAC that provides the following phase current values: 100%, 92.4%, 83.1%, 70.7%, 55.5%, 38.2%, 19.5%, 0%. This allows you to work in microstepping mode with a step size of 1/8, while the error in setting the phase current does not exceed 2%. In addition, this driver has the ability to control the rate of decay of the current of the motor windings during operation, which allows for “fine tuning” of the driver for a specific motor to obtain the smallest positioning error.

Even if the DAC has accurately generated a sinusoidal reference voltage, it needs to be amplified and turned into a sinusoidal winding current. Many drivers have significant nonlinearity near zero current, which causes significant shape distortion and, as a result, significant positioning errors. If high quality drivers are used, such as Ericsson's PBM3960 and PBL3771, the error associated with the driver is vanishingly small compared to the error of the motor.

Sometimes stepper motor controllers allow you to adjust the shape of the output signal by adding or subtracting its third harmonic from the sine. However, such adjustment must be made individually for a specific engine, the characteristics of which must first be measured.

Because of these limitations, microstepping is used primarily to ensure smooth rotation (especially at very low speeds), to eliminate noise and resonance phenomena. Microstepping can also reduce settling time mechanical system, since, unlike the full-step mode, there are no surges or oscillations. However, in most cases, precise microstepping positioning cannot be guaranteed for conventional motors.

Sinusoidal phase current can be provided by using special drivers. Some of them, for example A3955, A3957 from Allegro, already contain a DAC and require only digital codes from the microcontroller. Others, such as L6506, L298 from SGS-Thomson, require external sinusoidal reference voltages, which must be generated by the microcontroller using DACs. It must be said that too many sine discretions do not lead to increased positioning accuracy, since the error associated with the non-ideal geometry of the motor poles begins to dominate. Moreover, in this case, the readings must follow with a high frequency, which is a problem when generating them programmatically. When operating at high speeds, the resolution of DACs can be reduced. Moreover, at very high speeds it is generally recommended to operate in the normal full-step mode, since controlling the harmonic signal loses its advantages. This happens for the reason that the motor windings are inductance; therefore, any specific driver circuit with a specific supply voltage provides a very specific maximum rate of current rise. Therefore, as the frequency increases, the current shape begins to deviate from sinusoidal and at very high frequencies becomes triangular.

Dependence of torque on speed, influence of load

The torque produced by a stepper motor depends on several factors:

  • speed
  • current in windings
  • driver circuits

In Fig. Figure 14a shows the dependence of torque on the angle of rotation of the rotor.

Rice. 14. The emergence of dead zones as a result of friction.

For an ideal stepper motor, this dependence is sinusoidal. Points S are the rotor equilibrium positions for an unloaded motor and correspond to several successive steps. If an external torque less than the holding torque is applied to the motor shaft, the angular position of the rotor will change by a certain angle Ф.

Ф = (N/(2*pi))*sin(Ta/Th),

where Ф is the angular displacement,
N is the number of engine steps per revolution,
Ta is the external applied moment,
Th - holding moment.

Angular displacement Ф is the positioning error of the loaded motor. If a torque exceeding the holding torque is applied to the motor shaft, then under the influence of this torque the shaft will rotate. In this mode, the rotor position is uncontrolled.
In practice, there is always an external torque applied to the engine, if only because the engine has to overcome friction. Frictional forces can be divided into two categories: static friction or static friction, which requires a constant torque to overcome, and dynamic friction or viscous friction, which depends on speed. Let's consider static friction. Let's assume that to overcome it, a torque of half the peak is required. In Fig. 14a the dashed lines show the friction moment. Thus, for the rotor to rotate, only the torque lying on the graph outside the dashed lines remains. Two conclusions follow from this: friction reduces the torque on the motor shaft and dead zones appear around each rotor equilibrium position (Fig. 14b):

d = 2 (S / (pi/2)) arcsin(T f /T h) = (S / (pi/4)) arcsin(T f / Th),

where d is the width of the dead zone in radians,
S - step angle in radians,
Tf - friction moment,
Th - holding moment.

Dead zones limit positioning accuracy. For example, the presence of static friction at half the peak torque of the engine in increments of 90 degrees. will cause dead zones of 60 degrees. This means that the motor step can fluctuate from 30 to 150 degrees, depending on at what point in the dead zone the rotor stops after the next step.

The presence of dead zones is very important for microstepping. If, for example, there are dead zones of magnitude d, then a microstep of less than d will not move the rotor at all. Therefore, for systems using microstepping, it is very important to minimize static friction.

When a motor is running under load, there is always some shift between the angular position of the rotor and the orientation of the stator's magnetic field. A particularly unfavorable situation is when the engine begins to brake and the load torque is reversed. It should be noted that lag or advance refers only to position, not speed. In any case, if the synchronism of the engine is not lost, this delay or advance cannot exceed two full steps. This is a very pleasant fact.

Each time the stepper motor takes a step, the rotor rotates S radians. In this case, the minimum torque occurs when the rotor is located exactly between adjacent equilibrium positions (Fig. 15).

Rice. 15. Holding torque and operating torque of the stepper motor.

This torque is called the operating torque, it means the maximum torque the motor can overcome when rotating at low speed. With a sinusoidal dependence of the torque on the angle of rotation of the rotor, this torque Tr = Th/(2 0.5). If the motor takes a step with two energized windings, then the operating torque is equal to the holding torque for one energized winding.

The parameters of a stepper motor drive are highly dependent on the load characteristics. In addition to friction, a real load has inertia. Inertia prevents changes in speed. The inertial load requires the engine to produce large torques during acceleration and deceleration, thus limiting maximum acceleration. On the other hand, increasing load inertia increases speed stability.

Such a stepper motor parameter as the dependence of torque on speed is the most important when choosing the type of motor, choosing a phase control method and choosing a driver circuit. When designing high-speed stepper motor drivers, it must be taken into account that the motor windings represent inductance. This inductance determines the rise and fall times of the current. Therefore, if a rectangular voltage is applied to the winding, the current shape will not be rectangular. At low speeds (Fig. 16a), the rise and fall times of the current cannot greatly affect the torque, but at high speeds the torque drops. This is due to the fact that at high speeds the current in the motor windings does not have time to reach the rated value (Fig. 16b).

Rice. 16. Shape of the current in the motor windings at different operating speeds.

In order for the torque to drop as little as possible, it is necessary to ensure a high rate of current rise in the motor windings, which is achieved by using special circuits to power them.

The behavior of the torque with increasing phase switching frequency is approximately as follows: starting from a certain cutoff frequency, the torque monotonically decreases. Typically, two curves of torque versus speed are given for a stepper motor (Fig. 17).

Rice. 17. Dependence of torque on speed.

The internal curve (start curve, or pull-in curve) shows at what maximum friction torque for a given speed the stepper motor is able to start. This curve intersects the speed axis at a point called the maximum starting frequency or pickup frequency. It determines the maximum speed at which an unloaded engine can start moving. In practice, this value lies in the range of 200 - 500 full steps per second. The inertia of the load greatly influences the appearance of the internal curve. Greater inertia corresponds to a smaller area under the curve. This area is called the start area. The outer curve (acceleration curve, or pull-out curve) shows at what maximum friction torque for a given speed the stepper motor is able to maintain rotation without skipping steps. This curve intersects the speed axis at a point called the maximum acceleration frequency. It shows the maximum speed for a given motor without load. When measuring maximum speed It must be borne in mind that due to the phenomenon of resonance, the torque is also zero at the resonant frequency. The area that lies between the curves is called the acceleration area.

It should be noted that the driver circuit greatly influences the course of the torque-velocity curve, but this issue will be discussed below.

Disperse!

In order to work for high speed from the acceleration area (Fig. 17), it is necessary to start at low speed from the start area and then accelerate. When stopping, you need to act in the reverse order: first perform braking, and only after entering the start area can you stop supplying control pulses. Otherwise, a loss of synchronism will occur and the rotor position will be lost. The use of acceleration and deceleration makes it possible to achieve significantly higher speeds - in industrial applications speeds of up to 10,000 full steps per second are used. It should be noted that continuous operation of the stepper motor at high speed is not always acceptable due to heating of the rotor. However, high speed can be used briefly for positioning purposes.

When accelerating, the engine goes through a series of speeds, and at one of the speeds you may encounter the unpleasant phenomenon of resonance. For normal acceleration, it is desirable to have a load whose moment of inertia is at least equal to the moment of inertia of the rotor. On an unloaded engine, the resonance phenomenon is most pronounced. Methods to combat this phenomenon will be described in detail below.
When accelerating or braking, it is important to correctly select the law of speed change and maximum acceleration. The higher the load inertia, the lower the acceleration should be. The criterion for choosing the correct acceleration mode is to accelerate to the required speed for a specific load in the minimum time. In practice, acceleration and deceleration with constant acceleration are most often used.

The implementation of the law according to which the motor will be accelerated or decelerated is usually carried out by a software-controlled microcontroller, since it is the microcontroller that is usually the source of the clock frequency for the stepper motor driver. Although previously voltage-controlled generators or programmable frequency dividers were used for these purposes. To generate a clock frequency, it is convenient to use a hardware timer, which is included in almost any microcontroller. When the motor rotates at a constant speed, it is enough to load the timer with a constant value for the step repetition period (step duration). If the engine accelerates or decelerates, this period changes with each new step. When accelerating or braking with constant acceleration, the frequency of repetition of steps should change linearly; accordingly, the value of the period that must be loaded into the timer should change according to a hyperbolic law.

For the most general case, it is required to know the dependence of the step duration on the current speed. The number of steps the engine takes during acceleration in time t is:

N = 1/2At 2 +Vt, where N is the number of steps, t is time, V is speed expressed in steps per unit time, A is acceleration expressed in steps divided by time squared.

For one step N = 1, then step duration t 1 = T = (-V+(V 2 +2A) 0.5)/A

As a result of the step, the speed becomes equal to Vnew = (V 2 +2A) 0.5

Calculations using the above formulas are quite labor-intensive and require significant CPU time. At the same time, they allow you to change the acceleration value at any moment. Calculations can be significantly simplified if we require constant acceleration during acceleration and deceleration. In this case, we can write down the dependence of the step duration on the acceleration time:
V = V 0 +At, where V is the current speed, V 0 - starting speed(minimum speed at which acceleration begins), A - acceleration;
1/T = 1/T 0 +At, where T is the step duration, T 0 is the initial step duration, t is the current time;

Where does T = T 0 /(1+T 0 At)

Calculations using this formula are much simpler, but in order to change the acceleration value, you need to stop the engine.

Resonance

Stepper motors have an undesirable effect called resonance. The effect manifests itself as a sudden drop in torque at some speeds. This can lead to missed steps and loss of synchronicity. The effect manifests itself if the step frequency coincides with the natural resonant frequency of the engine rotor.

When the engine takes a step, the rotor does not immediately move to a new position, but performs damped oscillations. The fact is that the rotor - magnetic field - stator system can be considered as a spring pendulum, the frequency of oscillations of which depends on the moment of inertia of the rotor (plus load) and the magnitude of the magnetic field. Due to the complex configuration of the magnetic field, the resonant frequency of the rotor depends on the amplitude of the oscillations. As the amplitude decreases, the frequency increases, approaching the low-amplitude frequency, which is more easily calculated quantitatively. This frequency depends on the pitch angle and on the ratio of the holding moment to the moment of inertia of the rotor. A larger holding torque and a smaller moment of inertia lead to an increase in the resonant frequency.
The resonant frequency is calculated using the formula:

F 0 = (N*T H /(J R +J L)) 0.5 /4*pi,

where F 0 is the resonant frequency,
N is the number of complete steps per revolution,
T H - holding torque for the used control method and phase current,
J R - moment of inertia of the rotor,
J L - moment of inertia of the load.

It should be noted that the resonant frequency is determined by the moment of inertia of the motor rotor itself plus the moment of inertia of the load connected to the motor shaft. Therefore, the resonant frequency of the rotor of an unloaded motor, which is sometimes given among the parameters, has little practical value, since any load connected to the motor will change this frequency.
In practice, the resonance effect leads to difficulties when operating at frequencies close to the resonant one. The moment at the resonance frequency is zero and without acceptance special measures The stepper motor cannot pass the resonant frequency when accelerating. In any case, the phenomenon of resonance can significantly degrade the precision characteristics of the drive.

Low damping systems run the risk of losing steps or increasing noise when the motor operates near its resonant frequency. In some cases, problems may also arise at harmonics of the fundamental resonance frequency.

When a non-microstepping mode is used, the main cause of oscillation is intermittent rotation of the rotor. When taking a step, some energy is imparted to the rotor by a push. This push excites vibrations. The energy supplied to the rotor in half-step mode is about 30% of the energy of a full step. Therefore, in the half-step mode, the oscillation amplitude is significantly smaller. In microstepping mode with a step of 1/32 of the main one, only about 0.1% of the energy of the full step is reported for each microstep. Therefore, in microstepping mode, the phenomenon of resonance is practically unnoticeable.

There are electrical methods to combat resonance. An oscillating rotor leads to the appearance of an EMF in the stator windings. If you short-circuit windings that are not being used in this step, this will dampen the resonance.

And finally, there are methods to combat resonance at the level of the driver operating algorithm. For example, you can use the fact that when working with two phases on, the resonant frequency is approximately 20% higher than with one phase on. If the resonant frequency is precisely known, then it can be passed by changing the operating mode.

If possible, frequencies above resonant should be used when starting and stopping. Increasing the moment of inertia of the rotor-load system reduces the resonant frequency.

However, the most effective measure to combat resonance is the use of microstepping mode.

What should I feed him?

To power a conventional DC motor, only a DC voltage source is required, and the necessary switching of the windings is performed by the commutator. With a stepper motor everything is more complicated. All commutations must be performed by an external controller. Currently, approximately 95% of cases use microcontrollers to control stepper motors. In the simplest case, controlling a stepper motor in full-step mode requires only two signals, 90 degrees out of phase. The direction of rotation depends on which phase is leading. The speed is determined by the pulse repetition rate. In half-step mode, everything is somewhat more complicated and a minimum of 4 signals are required. All stepper motor control signals can be generated in software, but this will cause large load microcontroller. Therefore, special stepper motor driver chips are more often used, which reduce the number of dynamic signals required from the processor. Typically these chips require a clock frequency, which is the frequency at which the steps are repeated, and a static signal, which specifies the direction. Sometimes there is still a signal to turn on the half-step mode. Driver ICs that operate in microstepping mode require more signals. A common case is when the necessary sequences of phase control signals are generated using one microcircuit, and the necessary phase currents are provided by another microcircuit. Although recently more and more drivers have appeared that implement all functions in one chip.

The power required from the driver depends on the size of the motor and is a fraction of a watt for small motors and up to 10-20 watts for large motors. The maximum level of power dissipation is limited by engine heating. The maximum operating temperature is usually specified by the manufacturer, but it can be approximately assumed that the normal case temperature is 90 degrees. Therefore, when designing devices with stepper motors that continuously operate at maximum current, it is necessary to take measures to prevent maintenance personnel from touching the motor housing. In some cases, it is possible to use a cooling radiator. Sometimes this allows you to use a smaller engine and achieve a better power/cost ratio.

For a given size stepper motor, the space occupied by the windings is limited. Therefore, it is very important to design the driver in such a way as to provide the best efficiency for given winding parameters.

The driver circuit must perform three main tasks:

  • be able to turn the current in the windings on and off, as well as change its direction
  • maintain the set current value
  • provide the fastest possible rise and fall of current for good speed characteristics

Ways to change the direction of current

When operating a stepper motor, a change in the direction of the magnetic field is required independently for each phase. Changing the direction of the magnetic field can be done in different ways. In unipolar motors, the windings are center-tapped or there are two separate windings for each phase. The direction of the magnetic field is changed by switching halves of windings or entire windings. In this case, only two simple switches A and B are required for each phase (Fig. 18).

Rice. 18. Power supply to the winding of a unipolar motor.

In bipolar motors, the direction is changed by reversing the polarity of the winding terminals. For such a polarity reversal, a full H-bridge is required (Fig. 19). Key management in both cases must be carried out by a logical circuit that implements the desired operating algorithm. It is assumed that the power supply of the circuits has the voltage rated for the motor windings.

Rice. 19. Power supply to the winding of a bipolar motor.

This is the simplest way to control winding current, and as will be shown later, it significantly limits the capabilities of the motor. It should be noted that with separate control of the H-bridge transistors, situations are possible when the power source is short-circuited by the switches. Therefore, the control logic circuit must be designed in such a way as to eliminate this situation even in the event of failures of the control microcontroller.

The motor windings are inductance, which means that the current cannot rise indefinitely quickly or fall off indefinitely quickly without attracting an infinite potential difference. When the winding is connected to a power source, the current will increase at a certain speed, and when the winding is disconnected, a voltage surge will occur. This surge can damage switches that use bipolar or field-effect transistors. To limit this release, special protective chains are installed. In the diagrams of Fig. 18 and 19, these chains are formed by diodes; capacitors or their combination with diodes are used much less often. The use of capacitors causes electrical resonance, which can cause an increase in torque at some speed. In Fig. 18 required 4 diodes for the reason that the halves of the windings of a unipolar motor are located on a common core and are strongly connected to each other. They work like an autotransformer and surges occur at the terminals of both windings. If MOS transistors are used as switches, then only two external diodes are sufficient, since they already have diodes inside. Integrated circuits containing high-power open-collector output stages also often contain such diodes. In addition, some microcircuits, such as ULN2003, ULN2803 and the like, have both protection diodes inside for each transistor. It should be noted that in the case of using high-speed switches, diodes of comparable speed are required. When using slow diodes, they need to be bypassed with small capacitors.

Current stabilization

To adjust the torque, you need to adjust the current in the windings. In any case, the current must be limited so as not to exceed the power dissipation across the ohmic resistance of the windings. Moreover, in the half-step mode it is still necessary to ensure at certain moments that the current value in the windings is zero, and in the microstep mode it is generally necessary to set different current values.

For each motor, the manufacturer indicates the rated operating voltage of the windings. Therefore, the simplest way to power the windings is to use a constant voltage source. In this case, the current is limited by the ohmic resistance of the windings and the voltage of the power source (Fig. 20a), therefore this power supply method is called L/R power. The current in the winding increases exponentially at a rate determined by the inductance, active resistance of the winding and the applied voltage. As the frequency increases, the current does not reach the rated value and the torque drops. Therefore, this power supply method is only suitable for operation at low speeds and is used in practice only for low-power engines.

Rice. 20. Powering the winding with rated voltage (a) and using a limiting resistor (b).

When operating at high speeds, it is necessary to increase the rate of current rise in the windings, which is possible by increasing the voltage of the power source. In this case, the maximum winding current must be limited using an additional resistor. For example, if a supply voltage is used that is 5 times higher than the rated one, then such an additional resistor is required so that the total resistance is 5R, where R is the ohmic resistance of the winding (L/5R-supply). This power supply method provides a faster increase in current and, as a result, a larger torque (Fig. 20b). However, it has a significant drawback: additional power is dissipated by the resistor. The large dimensions of powerful resistors, the need for heat removal and the increased required power of the power source - all this makes this method ineffective and limits its application to small motors with a power of 1 - 2 watts. It must be said that until the early 80s of the last century, the parameters of stepper motors given by manufacturers related precisely to this method of power supply.

An even faster increase in current can be obtained if you use a current generator to power the engine. The current will increase linearly, this will allow the rated current value to be reached faster. Moreover, a pair of powerful resistors can cost more than a pair of powerful transistors along with radiators. But as in the previous case, the current generator will dissipate additional power, which makes this power supply inefficient.

There is another solution that provides a high rate of current rise and low power loss. It is based on the use of two power sources.

Rice. 21. Power supply of the motor winding with step voltage.

At the beginning of each step, the windings are briefly connected to a higher voltage source, which ensures a rapid increase in current (Fig. 21). Then the supply voltage to the windings decreases (time t 1 in Fig. 21). The disadvantage of this method is the need for two switches, two power supplies and a more complex control circuit. In systems where such sources already exist, the method can be quite cheap. Another difficulty is the impossibility of determining the moment of time t 1 for the general case. For a motor with a lower winding inductance, the rate of current rise is higher and, at a fixed t 1, the average current may be higher than the nominal current, which can lead to overheating of the motor.

Another method of stabilizing the current in the motor windings is key (pulse-width) regulation. Modern stepper motor drivers use this method. The key stabilizer provides a high rate of current rise in the windings, along with ease of regulation and very low losses. Another advantage of the circuit with key current stabilization is that it maintains the motor torque constant, regardless of fluctuations in the supply voltage. This allows the use of simple and cheap unstabilized power supplies.

To ensure a high rate of current rise, a power source voltage several times higher than the rated voltage is used. By adjusting the duty cycle of the pulses, the average voltage and current are maintained at the nominal level for the winding. Maintenance occurs as a result of feedback. A resistor is connected in series with the winding - current sensor R (Fig. 22a). The voltage drop across this resistor is proportional to the current in the winding. When the current reaches the set value, the switch turns off, causing the current to drop. When the current drops to the lower threshold, the switch turns on again. This process is repeated periodically, keeping the average current constant.

Rice. 22. Various key current stabilization schemes.

By controlling the value of Uref, you can regulate the phase current, for example, increase it during acceleration and deceleration and decrease it when operating at a constant speed. You can also set it using a DAC in the form of a sine wave, thus implementing a microstepping mode. This method of controlling a key transistor ensures a constant value of current ripple in the winding, which is determined by the hysteresis of the comparator. However, the switching frequency will depend on the rate of change of current in the winding, in particular, on its inductance and on the supply voltage. In addition, two such circuits feeding different phases of the motor cannot be synchronized, which can cause additional interference.

A circuit with a constant switching frequency is free from these disadvantages (Fig. 22b). The key transistor is controlled by a trigger, which is installed by a special generator. When the trigger is installed, the key transistor opens and the phase current begins to increase. Along with it, the voltage drop at the current sensor also increases. When it reaches the reference voltage, the comparator switches, resetting the flip-flop. At the same time, the key transistor turns off and the phase current begins to decrease until the trigger is re-installed by the generator. This circuit provides a constant switching frequency, but the magnitude of the current ripple will not be constant. The generator frequency is usually chosen to be at least 20 kHz so that the engine does not create an audible sound. At the same time, too high a switching frequency can cause increased losses in the motor core and switching losses in transistors. Although losses in the core do not grow so quickly with increasing frequency due to the decrease in the amplitude of current ripples with increasing frequency. Ripple on the order of 10% of the average current usually does not cause loss problems.

A similar circuit is implemented inside the L297 chip from SGS-Thomson, the use of which minimizes the number of external components. Key regulation is also implemented by other specialized microcircuits.

Rice. 23. Current shape in the motor windings for in various ways nutrition.

In Fig. Figure 23 shows the current shape in the motor windings for three power supply methods. The best method in terms of the moment is the key method. In addition, it provides high efficiency and allows you to easily regulate the current value.

Fast and slow current decay

In Fig. Figure 19 showed switch configurations in the H-bridge to enable different directions of current in the winding. To turn off the current, you can turn off all the H-bridge switches or leave one switch on (Fig. 24). These two situations differ in the rate of decay of the current in the winding. After disconnecting the inductance from the power source, the current cannot stop instantly. A self-induced emf appears, having the opposite direction to the power source. When using transistors as switches, it is necessary to use bypass diodes to ensure conduction in both directions. The rate of change of current in the inductance is proportional to the applied voltage. This is true for both current rise and fall. Only in the first case, the source of energy is the power supply, and in the second, the inductance itself releases the stored energy. This process can occur under different conditions.

Rice. 24. Slow and fast current decay.

In Fig. Figure 24a shows the state of the H-bridge switches when the winding is turned on. Switches A and D are turned on, the direction of the current is shown by the arrow. In Fig. 24b the winding is turned off, but switch A is on. The self-induction EMF is short-circuited through this switch and diode VD3. At this time, there will be a small voltage at the winding terminals, equal to the forward drop across the diode plus the drop across the switch (saturation voltage of the transistor). Since the voltage at the winding terminals is small, the rate of change of current will also be small. Accordingly, the rate of decay of the magnetic field will also be small. This means that for some time the engine stator will create a magnetic field, which should not exist at this time. This field will have a braking effect on the rotating rotor. At high engine speeds, this effect can seriously interfere with normal engine operation. The rapid decay of current when turned off is very important for high-speed controllers operating in half-stepping mode.

Another way to turn off the winding current is possible, when all the H-bridge switches are opened (Figure 24c). In this case, the self-induction EMF is short-circuited through diodes VD2, VD3 to the power source. This means that during the current decline there will be a voltage on the winding, equal to the sum power supply voltage and forward drop across two diodes. Compared to the first case, this is a significantly higher voltage. Accordingly, the decrease in current and magnetic field will be faster. This solution, using the power supply voltage to accelerate the decay of the current, is the simplest, but not the only one. It must be said that in some cases surges may appear on the power source, to suppress which special damper circuits will be needed. It makes no difference how the increased voltage is provided to the winding during a decrease in current. To do this, you can use zener diodes or varistors. However, these elements will dissipate additional power, which in the first case was given back to the power source.

For a unipolar motor the situation is more complicated. The fact is that the halves of the winding, or two separate windings of the same phase, are strongly connected to each other. As a result of this connection, surges of increased amplitude will occur on the closing transistor. Therefore, transistors must be protected by special circuits. To ensure a rapid decay of the current, these circuits must provide a fairly high clamping voltage. Most often, diodes are used together with zener diodes or varistors. One of the methods of circuit implementation is shown in Fig. 25.

Rice. 25. An example of the implementation of a fast current decay for a unipolar motor.

With key regulation, the magnitude of the current ripple depends on the rate of its decay. There are different options here.

If you short-circuit the winding with a diode, a slow decay of the current will be realized. This leads to a decrease in the amplitude of current ripples, which is very desirable, especially when the engine operates in microstepping mode. For a given level of ripple, the slow current decay allows operation at lower switching frequencies, which reduces motor heating. For these reasons, slow current decay is widely used. However, there are several reasons why a slow current rise is not always optimal: firstly, due to the negative back EMF, due to the low voltage on the winding during the current decline, the actual average winding current may be overestimated; secondly, when it is necessary to sharply reduce the phase current (for example, in half-step mode), a slow decline will not allow this to be done quickly; thirdly, when it is necessary to set a very low value of the phase current, regulation may be disrupted due to the existence of a limitation on the minimum time the switches are on.

A high rate of current decay, which is realized by shorting the winding to the power source, leads to increased ripple. At the same time, the disadvantages inherent in a slow current decay are eliminated. However, the accuracy of maintaining the average current is less, and losses are also greater.

The most advanced driver chips have the ability to regulate the rate of current decay.

Practical implementation of drivers

The stepper motor driver must solve two main tasks: generating the necessary timing sequences of signals and providing the required current in the windings. In integrated implementations, these tasks are sometimes performed by different chips. An example is the L297 and L298 chipset from SGS-Thomson. The L297 chip contains the timing logic, and the L298 is a powerful dual H-bridge. Unfortunately, there is some confusion in the terminology regarding such microcircuits. The term "driver" is often applied to many chips, even if their functions vary greatly. Sometimes logic chips are called “translators”. In this article, the following terminology will be used: “controller” - a microcircuit responsible for the formation of time sequences; "driver" - powerful circuit power supply to the motor windings. However, the terms "driver" and "controller" can also refer to a complete stepper motor control device. It should be noted that recently, more and more often, the controller and driver are combined in one chip.

In practice, you can do without specialized microcircuits. For example, all functions of the controller can be implemented in software, and a set of discrete transistors can be used as a driver. However, the microcontroller will be heavily loaded, and the driver circuit may turn out to be cumbersome. Despite this, in some cases such a solution will be cost-effective.
The simplest driver is required to control the windings of a unipolar motor. The simplest switches are suitable for this, which can be bipolar or field-effect transistors. Power MOSFETs controlled by logic level, such as IRLZ34, IRLZ44, IRL540, are quite effective. They have an open resistance of less than 0.1 ohm and a permissible current of about 30A. These transistors have domestic analogues KP723G, KP727V and KP746G respectively. There are also special chips that contain several powerful transistor switches. An example is the ULN2003 microcircuit from Allegro (our analogue of K1109KT23), which contains 7 switches with a maximum current of 0.5 A. Schematic diagram one cell of this microcircuit is shown in Fig. 26.

Rice. 26. Schematic diagram of one cell of the ULN2003 microcircuit.

Similar microcircuits are produced by many companies. It should be noted that these microcircuits are suitable not only for powering the windings of stepper motors, but also for powering any other loads. In addition to simple driver chips, there are also more complex chips that have a built-in controller, PWM current control, and even a DAC for microstepping mode.

As noted earlier, controlling bipolar motors requires more complex circuitry such as H-bridges. Such circuits can also be implemented on discrete elements, although recently they are increasingly being implemented on integrated circuits. An example of a discrete implementation is shown in Fig. 27.

Rice. 27. Implementation of a bridge driver on discrete components.

This H-bridge is controlled by two signals, so it does not provide all possible combinations. The winding is energized when the input levels are different and short-circuited when the levels are the same. This allows only a slow decay of the current to be obtained (dynamic braking). Integrated bridge drivers are produced by many companies. An example is L293 (KR1128KT3A) and L298 from SGS-Thomson.

Until recently, a large number of chips for controlling stepper motors were produced by Ericsson. However, on June 11, 1999, it transferred the production of its industrial chips to New Japan Radio Company (New JRC). At the same time, the designations of the microcircuits changed from PBLxxxx to NJMxxxx.

Both simple switches and H-bridges can form part of a key current stabilizer. The key control circuit can be implemented on discrete components or in the form of a specialized chip. A fairly popular microcircuit that implements PWM current stabilization is the L297 from SGS-Thomson. Together with the L293 or L298 bridge driver chip, they form a complete control system for the stepper motor (Fig. 28).

Rice. 28. Typical scheme inclusion of microcircuits L297 and L298N.

The L297 microcircuit greatly relieves the control microcontroller, since it only requires the clock frequency CLOCK (step repetition frequency) and several static signals: DIRECTION - direction (the signal is internally synchronized, you can switch at any time), HALF/FULL - half-step/full-step mode, RESET - sets the phases to their original state (ABCD = 0101), ENABLE - resolution of the microcircuit, V ref - reference voltage, which sets the peak current value during PWM control. In addition, there are several additional signals. The CONTROL signal sets the operating mode of the PWM controller. When its level is low, PWM regulation occurs at the outputs INH1, INH2, and at a high level, at the outputs ABCD. SYNC - output of the internal PWM clock generator. It serves to synchronize the operation of several microcircuits. Can also be used as an input when clocking from an external oscillator. HOME - home position signal (ABCD = 0101). It is used to synchronize HALF/FULL mode switching. Depending on the moment of transition to full-step mode, the microcircuit can operate in a mode with one phase turned on or with two phases turned on.

Many other microcircuits also implement key regulation. Some microcircuits have certain features, for example, the LMD18T245 driver from National Semiconductor does not require the use of an external current sensor, since it is implemented internally based on a single cell of a key MOSFET transistor.

Some ICs are designed specifically to operate in microstepping mode. An example is the A3955 chip from Allegro. It has a built-in 3-bit nonlinear DAC to set a sinusoidally varying phase current.

Rice. 29. Current and rotor displacement vector.

The rotor displacement depending on the phase currents that are generated by this 3-bit DAC is shown in Fig. 29. The A3972 chip has a built-in 6-bit linear DAC.

Selecting the driver type

The maximum torque and power that a stepper motor can provide on the shaft depends on the size of the motor, cooling conditions, operating mode (work/pause ratio), the parameters of the motor windings and the type of driver used. The type of driver used greatly influences the power at the motor shaft. With the same power dissipation, a driver with pulse current stabilization provides a gain in torque at some speeds up to 5 - 6 times, compared to powering the windings with rated voltage. This also expands the range of permissible speeds.

Stepper motor drive technology is constantly evolving. The development is aimed at obtaining the highest torque on the shaft with minimal engine dimensions, wide speed capabilities, high efficiency and improved accuracy. An important element of this technology is the use of microstepping mode.

In practice, the development time of a drive based on a stepper motor is also important. Developing a specialized design for each specific case requires a significant investment of time. From this point of view, it is preferable to use universal control circuits based on PWM current stabilization, despite their higher cost.

A practical example of a stepper motor controller based on an AVR family microcontroller

Despite the fact that currently there are a large number of specialized microcircuits for controlling stepper motors, in some cases you can do without them. When the requirements are not too stringent, the controller can be implemented entirely in software. At the same time, the cost of such a controller is very low.

The proposed controller is designed to control a unipolar stepper motor with an average current of each winding of up to 2.5A. The controller can be used with common stepper motors such as DSHI-200-1, -2, -3. It can also be used to drive less powerful motors, such as those used to position the heads in 5-inch drives. In this case, the circuit can be simplified by abandoning the parallel connection of key transistors and key current stabilization, since for low-power motors a simple L/R power supply is sufficient.

Rice. 30. Schematic diagram of a stepper motor controller.

The basis of the device (Fig. 30) is a microcontroller U1 type AT90S2313 from Atmel. Motor winding control signals are generated on ports PB4 - PB7 by software. To switch the windings, two field-effect transistors of the KP505A type connected in parallel are used, a total of 8 transistors (VT1 - VT8). These transistors have a TO-92 package and can switch current up to 1.4A, the channel resistance is about 0.3 ohm. In order for the transistors to remain closed during the “reset” signal of the microcontroller (the ports are in a high-impedance state at this time), resistors R11 - R14 are connected between the gates and sources. To limit the recharging current of the gate capacitance, resistors R6 - R9 are installed. This controller does not pretend to have high speed characteristics, so it is quite satisfied with the slow decline of the phase current, which is ensured by shunting the motor windings with diodes VD2 - VD5. To connect a stepper motor, there is an 8-pin XP3 connector, which allows you to connect a motor that has two separate leads from each winding (such as DSHI-200). For engines with inner join windings, one or two common contacts of the connector will remain free.

It should be noted that the controller can be used to control a motor with a large average phase current. To do this, you just need to replace transistors VT1 - VT8 and diodes VD2 - VD5 with more powerful ones. Moreover, in this case, parallel connection of transistors may not be used. The most suitable are MOSFETs controlled by logic level. For example, these are KP723G, KP727V and others.

Current stabilization is carried out using PWM, which is also implemented in software. For this, two current sensors R15 and R16 are used. The signals taken from the current sensors are fed through the low-pass filters R17C8 and R18C9 to the inputs of the comparators U3A and U3B. Low-pass filters prevent false alarms of comparators due to interference. The second input of each comparator must be supplied with a reference voltage, which determines the peak current in the motor windings. This voltage is generated by the microcontroller using a built-in timer operating in 8-bit PWM mode. To filter the PWM signal, a two-tier low-pass filter R19C10R22C11 is used. At the same time, resistors R19, R22 and R23 form a divider, which sets the scale of adjustment of the phase currents. In this case, the maximum peak current corresponding to code 255 is 5.11A, which corresponds to a voltage of 0.511V at the current sensors. Considering the fact that the DC component at the PWM output varies from 0 to 5V, the required division factor is approximately 9.7. The comparator outputs are connected to the microcontroller interrupt inputs INT0 and INT1.

To control the operation of the engine, there are two logical inputs: FWD (forward) and REW (reverse), connected to connector XP1. When a LOW logic level is applied to one of these inputs, the motor begins to rotate at a given minimum speed, gradually accelerating with a given constant acceleration. Acceleration ends when the engine reaches the set operating speed. If a command is given to change the direction of rotation, the motor decelerates at the same acceleration, then reverses and accelerates again.

In addition to the command inputs, there are two inputs for limit switches connected to the XP2 connector. The limit switch is considered to be triggered if there is a LOW logic level at the corresponding input. At the same time, rotation in in this direction forbidden. When the limit switch is triggered while the motor is rotating, it starts decelerating at a given acceleration and then stops.

The command inputs and limit switch inputs are protected from overvoltage by circuits R1VD6, R2VD7, R3VD8 and R4VD9, consisting of a resistor and a zener diode.

The microcontroller's power supply is generated using a 78LR05 stabilizer chip, which simultaneously functions as a power monitor. When the supply voltage drops below the set threshold, this microcircuit generates a “reset” signal for the microcontroller. Power is supplied to the stabilizer through diode VD1, which, together with capacitor C6, reduces ripple caused by switching a relatively powerful load, which is a stepper motor. Power is supplied to the board through a 4-pin XP4 connector, the contacts of which are duplicated.

The demo version of the program allows you to accelerate and decelerate the engine with constant acceleration, as well as rotate at a constant speed in full-step or half-step mode. This program contains the entire necessary set of functions and can be used as a base for writing specialized programs. Therefore, it makes sense to consider its structure in more detail.

The main task of the program is to generate pulse sequences for 4 motor windings. Since timing relationships are critical for these sequences, the formation is performed in the timer 0 interrupt handler. We can say that the program does the main work in this handler. The block diagram of the processor is shown in Fig. 31.

Rice. 31. Block diagram of timer 0 interrupt handler.

It would certainly be more convenient to use Timer 1, since it is 16-bit and is capable of causing periodic interrupts to coincide with automatic reset. However, he is busy generating the reference voltage for the comparators using PWM. Therefore, it is necessary to reset timer 0 in the interrupt, which requires some adjustment of the loaded value and causes some jitter, which, however, does not interfere in practice. An interval of 25 μs was selected as the main time base, which is formed by the timer. With such discreteness, time sequences of phases can be formed; the PWM current stabilization in the motor phases has the same period.

To form the step repetition period, a software 16-bit timer STCNT is used. Unlike timer 0, its load value is not a constant, since it determines the engine rotation speed. Thus, phase switching occurs only when the software timer overflows.

The sequence of phase rotation is given in a table. There are three different tables in the microcontroller program memory: for full-step mode without phase overlap, full-step with overlap, and for half-step mode. All tables have the same length of 8 bytes. The required table is loaded into RAM at the beginning of operation, which makes it easier to switch between different engine operating modes. Values ​​are retrieved from the table using the PHASE pointer, so switching the direction of motor rotation is also very simple: to rotate forward, you need to increment the pointer, and to rotate backward, you need to decrement it.

The most “important” variable in the program is the 24-bit signed variable VC, which contains the current speed value. The sign of this variable determines the direction of rotation, and the value determines the frequency of steps. A zero value for this variable indicates that the engine is stopped. The program in this case turns off the current of all phases, although in many applications in this situation it is necessary to leave the current phases on and only slightly reduce their current, thereby ensuring that the motor position is maintained. If necessary, such a change in the logic of the program is very easy to do.

Thus, in case of overflow of the software timer STCNT, the value of the VC variable is analyzed, in case positive value the PHASE pointer is incremented, and if negative, decremented. Then the next phase combination is selected from the table and output to the port. If VC is zero, the PHASE pointer is not changed and all zero values ​​are output to the port.

The value of T with which the STCNT timer should be loaded is uniquely related to the value of the variable VC. However, converting frequency into period takes quite a lot of time, so these calculations are performed in the main program, and not at every step, but much less frequently. In general, these calculations need to be performed periodically only during acceleration or deceleration. In other cases, the speed, and, accordingly, the period of repetition of steps, does not change.

To implement PWM current stabilization, the phases must be periodically turned on and then, when the current reaches a given level, turned off. Periodic switching is carried out in the timer 0 interrupt, for which, even in the absence of overflow of the software timer STCNT, the current phase combination is output to the port. This happens with a period of 25 µs (which corresponds to a PWM frequency of 40 kHz). Phase switching is controlled by comparators whose outputs are connected to the interrupt inputs INT0 and INT1. Interrupts are enabled after the phase current is turned on, and disabled immediately after switching the comparators. This eliminates their re-processing. In interrupt handlers, only the corresponding phases are turned off (Fig. 32).

Rice. 32. Block diagram of the INT0 and INT1 interrupt handlers.

The processes occurring during PWM current stabilization are shown in Fig. 33. It should be especially noted that the current in the current sensor is intermittent even if the winding current is not interrupted. This is due to the fact that during a decay of the current, its path does not pass through the current sensor (but passes through the diode).

Rice. 33. Process of PWM current stabilization.

It must be said that the analog part of the PWM system for stabilizing the motor phase current is quite “capricious”. The fact is that the signal taken from the current sensor contains a large amount of noise. Interference occurs mainly at the moments of switching the motor windings, both “own” and “foreign” phases. Correct operation of the circuit requires correct layout of the printed circuit board, especially for ground conductors. You may have to select the values ​​of the low-pass filter at the input of the comparator or even introduce a small hysteresis into the comparator. As noted above, when controlling low-power motors, PWM current stabilization can be completely abandoned by using a conventional L/R winding power supply circuit. To eliminate PWM stabilization, it is enough to simply not connect the INT0 and INT1 inputs of the microcontroller; of course, you can not install a comparator and current sensors at all.

In this program, the frequency of calculating new speed and period values ​​is chosen to be 15.625ms. This value was not chosen by chance. This interval is 1/64s, and most importantly, it contains an integer number of timer 0 overflow periods (25µs). It is convenient if the values ​​of speed and acceleration are specified in natural units, i.e. in steps per second and in steps divided by a second squared. In order to be able to calculate the instantaneous speed 64 times per second in integer arithmetic, you need to go to the internal representation of speed, increased by 64 times. Multiplying and dividing by 64 reduces to simple shifts and therefore requires very little time. The specified frequency of calculations is provided by another software timer URCNT, which is decremented in the timer 0 interrupt (once every 25 μs). This timer is always loaded with a constant value, which ensures a constant overflow period of 15.625ms. When this timer overflows, the UPD bit flag is set, which signals to the main program that “it’s time to update the speed and period values.”

The main program (Fig. 34) calculates the instantaneous speed values ​​and the period of steps, providing the necessary acceleration curve. In this case, acceleration and deceleration are carried out with constant acceleration, so the speed changes linearly. In this case, the period changes according to the hyperbolic law, and its calculation is the main work of the program.

Rice. 34. Block diagram of the main program cycle.

The main program updates the speed and step period values ​​periodically; the frequency is set by the UPD flag. The program makes the update based on comparing the values ​​of two variables: the instantaneous speed VC and the required speed VR.

The required speed is also determined in the main program. This is done based on the analysis of control signals and signals from limit switches. Depending on these signals, the main program loads the VR variable with the value of the required speed. In this program it is V for forward, -V for reverse, and 0 for stop. In general, the set of speeds (as well as accelerations and phase currents) can be arbitrarily large, depending on the requirements.

If the speeds VC and VR are equal, then the stepper motor is running in stationary mode and no update is required. If the velocities are not equal, then the value of VC with a given acceleration approaches VR, i.e. The motor accelerates (or decelerates) until it reaches rated speed. In the case where even the signs of VR and VC are different, the engine slows down, reverses and then reaches the required speed. This happens as if by itself, thanks to the structure of the program.

If during the next check it is discovered that the speeds VR and VC are not equal, then the value of acceleration A is added (or subtracted) to the value VC. If as a result of this operation the required speed is exceeded, the resulting value is corrected by replacing it with the exact value of the required speed.

Then the period T is calculated (Fig. 35).

Rice. 35. Block diagram of the period calculation subroutine.

First, the module of the current speed is calculated. Then the minimum speed is limited. This restriction is necessary for two reasons. Firstly, an infinitesimal speed corresponds to an infinitely long period, which will cause an error in the calculations. Secondly, stepper motors have a fairly long start zone in terms of speed, so there is no need to start at a very low speed, especially since rotation at low speeds causes increased noise and vibration. The minimum speed value VMIN must be selected based on the specific application and engine type. After limiting the minimum speed, the period is calculated using the formula T = 2560000/|VC|. At first glance, the formula is not obvious, but if you consider that the period must be obtained in 25 microsecond intervals, and the internal representation of VC is its true value multiplied by 64, then everything falls into place. When calculating T, a 24/24 unsigned division operation is required, which an AVR at a clock frequency of 10 MHz does in about 70 μs. Considering that period calculations occur no more often than once every 15.625ms, the processor load is very low. The main load is carried out by the timer 0 interrupt, and it is mainly performed along a short branch (without STCNT overflow) with a duration of approximately 3 μs, which corresponds to 12% processor load. This means that there are significant reserves of computing resources.

The printed circuit board of the stepper motor controller is shown in Fig. 36.

Rice. 36. Printed circuit board for stepper motor controller.

The demo program provided does not have many of the features that should be present in a complete stepper motor controller. The implementation of these functions highly depends on the specific application of the stepper motor and can hardly be made universal. At the same time, the above program can serve as the basis for writing special programs that have one or another set of capabilities. For example, a number of specialized stepper motor controllers have been created based on this board. One of the models of such a controller has the following capabilities:

  • maximum phase switching frequency 3 kHz
  • acceleration with constant acceleration
  • programmable direction of rotation
  • High Resolution Graphic LCD Controller





Radio amateur Household appliances

Driver for stepper motor from printer

Simple driver for stepper motor

Sometimes the question arises about how to control a stepper motor. As a rule, this needs to be done when designing some kind of homemade product or a more serious project, for example, a machine with numerical control. Naturally, such control can be purchased. But, a driver for a stepper motor can also be made from a printer. This will be the simplest option, which will clearly demonstrate the ability to control this device.

You will need an old printer or scanner, maybe a non-working one. From there, in fact, the stepper motor will be removed, if one is not available. You will also need to remove a control chip called ULN2003 from the board. It may be different; different technologies have different microcircuits. Its analogs are suitable: TD62003, domestic K1109KT22, more popular MC1413, L203 and SG2003.

In principle, the brothers of these microcircuits, such as ULN2023A, ULN2803 and the like, are also suitable. You just have to look at the datasheets. Microcircuits can be bought or soldered from similar equipment. When desoldering, you should be careful, as such electronic components are more difficult to remove and there is a risk of damage to their legs.

The connection diagram is simple.

You will need to purchase a DB-25 connector, which will connect to the computer port to control the motor, if you are constructing a CNC machine. Input voltage ranges are indicated for this particular microcircuit. Other microcircuits may require a different supply voltage from this one.
A computer power supply is ideal as a power source. In principle, any charger or power supply with a voltage from 12V to 24V, with a current of 350mA or more, will do.
It is worth noting that it is advisable to have technical documentation for the model of the engine being used, which will simplify its connection to the driver.

The driver itself looks like this:

If documentation for the engine is not found, then you need to try to find the power bus first. This can be done either at random, with the possibility of burning the microcircuit, or using a battery, for example, if the engine is designed for low voltage.

If the design is made for a CNC machine, then you will need to download the Turbo CNC program to your computer and configure it to suit your needs.

A simple Stepper Motor controller from computer junk worth ~150 rubles.

My machine tool building began with a random reference to a German machine for 2000DM, which in my opinion looked childish, but could perform quite a lot of interesting functions. At that moment, I became interested in the opportunity to draw boards (this was even before LUT appeared in my life).

As a result of extensive searches on the Internet, several sites devoted to this problem were found, but not a single one was Russian-speaking (this was about 3 years ago). In general, in the end, I found two CM6337 ​​printers (by the way, they were produced by the Oryol UVM plant), from where I tore out unipolar stepper motors (Dynasyn 4SHG-023F 39S, analogue of DSHI200-1-1). In parallel with getting the printers, I also ordered ULN2803A microcircuits (with the letter A - DIP package). I collected everything and started it up. What I got, I got wildly heating key chips and a barely rotating engine. Since, according to the scheme from Holland, to increase the current, the keys are connected in pairs, the maximum output current did not exceed 1A, while the engine needed 2A (who knew that I would find such voracious, as it seemed to me then, J engines). In addition, these switches are built using bipolar technology, for those who do not know, the voltage drop can be up to 2V (if the power supply is from 5, then in fact half drops at the transition resistance).

In principle, for experiments with engines from 5” disk drives, it’s a very good option; you can make, for example, a plotter, but they can hardly pull anything heavier than a pencil (for example, a Dremel).

I decided to assemble my own circuit from discrete elements, fortunately one of the printers had untouched electronics, and I took KT829 transistors from there (Current up to 8A, voltage up to 100V)... Such a circuit was assembled...

Fig. 1 – Driver circuit for a 4-phase unipolar motor.

Now I will explain the principle. When a logical “1” is applied to one of the terminals (the others are “0”), for example, to D0, the transistor opens and current flows through one of the motor coils, while the motor performs one step. Next, the unit is supplied to the next pin D1, and at D0 the unit is reset to zero. The engine executes the next step. If current is supplied to two adjacent coils at once, the half-step mode is implemented (for my motors with a rotation angle of 1.8’, 400 steps per revolution are obtained).

The leads from the middle of the motor coils are connected to the common terminal (there are two of them if there are six wires). The theory of stepper motors is described very well here - Stepper motors. Stepper motor control, here is a diagram of a stepper motor controller on an Atmel AVR microcontroller. To be honest, it seemed to me like hammering nails for hours, but it has a very good function like PWM control of the winding current.

Having understood the principle, it is easy to write a program that controls the motor via the LPT port. Why are there diodes in this circuit, but because the load is inductive, when a self-inductive emf occurs, it is discharged through the diode, which prevents breakdown of the transistor, and therefore its failure. Another part of the circuit is the RG register (I used a 555IR33), which is used as a bus driver, since the current supplied by, for example, an LPT port is small - you can simply burn it, and therefore, it is possible to burn the entire computer.

The circuit is primitive, and you can assemble it in 15-20 minutes if you have all the parts. However, this control principle has a drawback - since the formation of delays when setting the rotation speed is set by the program relative to internal clock computer, then it won’t work in a multitasking system (Win)! The steps will simply be lost (maybe there is a timer in Windows, but I don’t know). The second drawback is the unstabilized current of the windings; maximum power cannot be squeezed out of the engine. However, in terms of simplicity and reliability, this method suits me, especially since in order not to risk my 2GHz Athlone, I assembled 486 tarantas from junk, and besides DOS, there is, in principle, little that can be installed that is normal.

The scheme described above worked and, in principle, was not bad, but I decided that the scheme could be slightly altered. Apply MOSFETJ). transistors (field-effect), the advantage is that you can switch huge currents (up to 75 - 100A), at voltages that are respectable for stepper motors (up to 30V), and at the same time, the circuit parts practically do not heat up, well, except for the limiting values ​​(I would like I see the one that will consume a current of 100A

As always in Russia, the question arose of where to get the parts. I had an idea - to extract transistors from burnt motherboards, fortunately, for example, Atlons eat a fair amount and the transistors there cost a lot. I advertised in FIDO and received an offer to pick up 3rd mat. fees for 100 rubles. Figuring that you could buy at most 3 transistors in a store for this money, he took it, picked it apart, and lo and behold, although they were all dead, not a single transistor in the processor power circuit was damaged. So I got a couple dozen field effect transistors for a hundred rubles. The resulting diagram is presented below.

Rice. 2 – Also on field-effect transistors

There are few differences in this circuit; in particular, a normal buffer chip 75LS245 was used (soldered above the gas stove from the 286 J motherboard). Any diodes can be installed, the main thing is that their maximum voltage is not less than the maximum supply voltage, and the maximum current is not less than the supply current of one phase. I installed KD213A diodes, these are 10A and 200V. Perhaps this is unnecessary for my 2-amp motors, but there was no point in buying parts, and it seems that the current reserve would not be superfluous. Resistors serve to limit the recharging current of the gate capacitance.

Below is a printed circuit board of a controller built according to this scheme.

Rice. 3 – Printed circuit board.

The printed circuit board is laid out for surface mounting on a single-sided PCB (I’m too lazy to drill holes). Microcircuits in DIP packages are soldered with bent legs, SMD resistors are from the same motherboards. The file with the layout in Sprint-Layout 4.0 is attached. It would be possible to solder the connectors onto the board, but laziness, as they say, is the engine of progress, and when debugging the hardware, it would have been more convenient to solder longer wires.

It should also be noted that the circuit is equipped with three limit switches, on the board at the bottom right there are six contacts vertically, next to them there are seats for three resistors, each connecting one pin of the switches to +5V. Limit switch diagram:

Rice. 4 – Scheme of limit switches.

This is what it looked like during the process of setting up the system:

As a result, I spent no more than 150 rubles on the presented controller: 100 rubles for motherboards (you can get them for free if you want) + a piece of PCB, solder and a can of ferric chloride in total amount to ~50 rubles, and there will still be a lot of ferric chloride left over later. I think it makes no sense to count wires and connectors. (By the way, the power connector was sawed off from the old hard drive.)

Since almost all the parts are made at home, using a drill, a file, a hacksaw, hands and such and such, the gaps are of course gigantic, but modifying individual components during operation and experimentation is easier than initially doing everything exactly.

If it weren’t so expensive to grind individual parts at the Oryol factories, then of course it would be easier for me to draw all the parts in CAD, with all the quality and roughness, and give them to the workers to eat. However, there are no turners I know... And it’s more interesting to use your hands, you know...

P.S. I want to express my opinion about the negative attitude of the site’s author towards Soviet and Russian engines. Soviet DSHI engines are quite good, even the low-power DSHI200-1-1. So if you managed to dig up such goodness for “beer”, don’t rush to throw them away, they will still work... checked... But if you buy, and the difference in cost is not great, it is better to take foreign ones, since their accuracy will of course be higher.

P.P.S. E: If I wrote something incorrectly, write it down, we’ll correct it, but... IT WORKS...

Any development begins with the selection of components. At development of a CNC machine it is very important to choose the right one stepper motor. If you have money to buy new motors, then you need to determine the operating voltage and power of the motor. I bought myself for the second CNC machine Stepper motors are like this: Nema17 1.7 A.

If you don’t have enough money or you’re just trying your hand at this area. Then you will most likely use printer engine. This is the most inexpensive option. But here you will encounter a number of problems. The motor can have 4, 5, 6, 8 wires for connection. How to connect them to drivers L298n And .

Let's take it in order. What kind of stepper motors are there? If you see an even number of pins it is bipolar stepper motor. The winding arrangement for this motor is like this.

If the motor has 5 leads, it is unipolar stepper motor. This is how his diagram looks like.

Our Drivers are designed for motors with 4 terminals. What should I do? How to connect them?

Bipolar step motors with 6 pins are connected to the driver in two ways:

In this case, the motor has a torque 1.4 times greater. The torque is more stable at low frequencies.

With this type of connection, it is necessary to reduce the current supplied to the motor windings by √2 times. For example, if the rated operating current of the motor is 2 A, then when the windings are connected in series, the required current is 1.4 A, that is, 1.4 times less.

This can be easily understood from the following reasoning.

The rated operating current indicated in the catalog is designed for the resistance of one winding (R - this is exactly what is given in the catalog). When the windings are connected in series, the resistance of the combined winding doubles (2R).

SD power consumption - I*2 * R

When the windings are connected in series, the power consumption becomes Iseries*2 * 2 * R

Power consumption does not depend on the type of connection, therefore I*2 * R = Isequence*2 * 2* R, from where

Iseq.= I/ √2, i.e.

Ilast = 0.707 *I.

Since the motor torque is directly proportional to the magnitude of the magnetic field created by the stator windings, it increases with the number of turns of the winding and decreases with a decrease in the current passed through the windings. But since the current decreased by √2 times, and the number of turns of the winding increased by 2 times, the torque will increase by √2 times.

Tlast = 1.4 * T.

In the second case, the torque is more stable at high frequencies. The parameters of the SD with this connection correspond to those stated in datasheet, (torque, current), torque is more stable at high frequencies.

A unipolar stepper motor can be rebuilt.

To do this, you need to disassemble the stepper motor and cut the wire connecting the center of the windings. And when connecting, there is no need to connect the common wire anywhere.

As a result, we get a bipolar motor with 4 leads.

Stepper motors with 8 pins can be connected in three ways.

Connection A - the stepper works with the characteristics stated in the description (torque, current), the torque is more stable at high frequencies.

Connection B – torque 1.4 times, the torque is more stable at low frequencies (relative to A).

Connection C – torque 1.96 times, the torque is more stable at high frequencies (relative to A).

So we solved the problem of connecting stepper motors. But not all of our engines will work. It is also necessary to determine the operating voltage of the motors. The best way is to find datasheet.That's itoptionsThere is. But notcoall motors from the printer can be founddatasheet. In such cases, I use this table .

I don’t know how accurate this table is, but everything matches and works as it should.

I choose the motor so that the operating voltage is less than or equal to the voltage of the power source. For motors designed for lower voltages, it is necessary to set the current lower.

Tune We'll be in the next article. Notskip it!

Subscribe to my channel on Youtube and join groups in



What else to read