Realize with microcontroller or DSP, control the method of stepping motor

Stepper motors have penetrated into every aspect of our lives. This article introduces some important stepper motor related technologies, which provides developers with sufficient information to understand the working principle of stepper motors. At the same time, it also introduces the use of microcontrollers or digital The signal processor controls the method of stepping motor.

Stepper motors have penetrated into every aspect of our lives. This article introduces some important stepper motor related technologies, which provides developers with sufficient information to understand the working principle of stepper motors. At the same time, it also introduces the use of microcontrollers or digital The signal processor controls the method of stepping motor.

Stepper motors are also called steppers. They use the principle of electromagnetics to convert electrical energy into mechanical energy. People began to use this motor as early as the 1920s. With the increasing popularity of embedded systems (such as printers, disk drives, toys, wipers, vibrating pagers, robotic arms, and video recorders, etc.), the use of stepper motors has also begun to skyrocket.

Whether in industry, military, medical, automotive, or entertainment, as long as an object needs to be moved from one position to another, a stepper motor will definitely come in handy. Stepper motors have many shapes and sizes, but regardless of the shape and size, they can be classified into two categories: variable reluctance stepper motors and permanent magnet stepper motors. This article focuses on the simpler and more commonly used permanent magnet stepper motors.

Structure of stepping motor

As shown in Figure 1, the stepper motor is driven by a set of coils wound on the stator cogging, the fixed part of the motor. Normally, a wire wound in a loop is called a solenoid, while in a motor, the wire wound around a tooth is called a winding, coil, or phase. If the current flow in the coil is shown in Figure 1, and we look down at the top of the cogging slot from the top of the motor, then the current is flowing counterclockwise around the two cogging slots. According to Ampere’s law and the right-hand rule, such a current generates a magnetic field with the north pole upward.

Now suppose we construct a motor with two windings wound on the stator, with a built-in permanent magnet that can rotate arbitrarily around the center. This rotatable part is called the rotor. Figure 2 shows a simple motor called a two-phase bipolar motor, because its stator has two windings and its rotor has two magnetic poles. If we send current to winding 1 in the direction shown in Figure 2a, and no current flows in winding 2, then the south pole of the motor rotor will naturally point to the north pole of the stator magnetic field as shown in the figure.

Suppose that we cut off the current in winding 1 and deliver current to winding 2 in the direction shown in Figure 2b. Then the magnetic field of the stator will point to the left, and the rotor will rotate accordingly, keeping the direction of the magnetic field of the stator consistent.

Next, we cut off the current in winding 2 and deliver current to winding 1 in the direction shown in Figure 2c. Note: At this time, the current in winding 1 flows in the opposite direction to that shown in Figure 2a. Then the north pole of the stator’s magnetic field will point downward, causing the rotor to rotate and its south pole pointing downward.

Then we cut off the current in winding 1 and deliver current to winding 2 in the direction shown in Figure 2d. Then the stator magnetic field will point to the right again, causing the rotor to rotate, and its south pole also points to the right.

Finally, we once again cut off the current in winding 2 and deliver the current shown in Figure 2a to winding 1, so that the rotor will return to its original position.

So far, we have completed a cycle of electrical excitation to the motor windings, and the motor rotor has rotated a full circle. In other words, the electrical frequency of the motor is equal to the mechanical frequency of its rotation.

If we complete the 4 steps shown in Figure 2 in 1 second sequence, then the electrical frequency of the motor is 1Hz. Its rotor rotates once, so its mechanical frequency is also 1Hz. In short, the relationship between the electrical frequency and mechanical frequency of a two-phase stepper motor can be expressed by the following formula:

fe=fm*P/2 (1)

Among them, fe represents the electrical frequency of the motor, fm represents its mechanical frequency, and P represents the number of equidistant magnetic poles of the motor rotor.

From Figure 2 we can also see that each step of operation will make the rotor rotate 90°, that is to say, the degree of rotation caused by each step of a two-phase stepper motor can be expressed by the following formula:

1 step= 180°/P (2)

From equation (2), we can see that a bipolar motor can rotate 180°/2=90° every time, which is exactly in line with the situation we saw in Figure 2. In addition, the equation also shows that the greater the number of poles of the motor, the higher the step accuracy. Common are two-phase stepper motors with magnetic poles between 12 and 200. The stepping accuracy of these motors is between 15° and 0.9°.

The example given in Figure 3 is a two-phase, 6-pole stepper motor, which contains 3 permanent magnets, so there are 6 magnetic poles. In the first step, as shown in Figure 3a, we apply a voltage to winding 1 to generate a magnetic field with the north pole pointing to the top of the stator. As a result, the south pole of the rotor (the red “S” end in Figure 3a) turns to that of the figure. Above. Next, in Figure 3b, we apply a voltage to winding 2, and a magnetic field with a north pole pointing to its left is generated in the stator.

As a result, the nearest south pole of the rotor turns to the left of the figure, that is, the rotor rotates 30° clockwise. In the third step, in Figure 3c, we apply a voltage to the winding 1 to generate a magnetic field with the north pole pointing downwards in the stator, so that the rotor rotates clockwise by 30° to the position shown in Figure 3c. In Figure 3d, we apply a voltage to the winding 2 to generate a magnetic field with a north pole pointing to the right side of the stator in the stator, and once again make the rotor rotate 30° clockwise to reach the position shown in Figure 3d.

Finally, we apply a voltage to winding 1 to generate a magnetic field with the north pole pointing above the stator as shown in Figure 3a, which makes the rotor rotate 30° clockwise, ending an electrical cycle. It can be seen that the 4-step electrical excitation caused a mechanical rotation of 120°. In other words, the electrical frequency of the motor is 3 times the mechanical frequency, and this result conforms to equation (1). In addition, we can also see from Figure 3 and equation (2) that the rotor of the motor rotates 30° every step.

If the current is delivered to the two windings at the same time, the torque of the motor can be increased, as shown in Figure 4. At this time, the magnetic field of the stator of the motor is the vector sum of the magnetic fields generated by the two windings. Although this magnetic field still only rotates the motor by 90° per action, as shown in Figure 2 and Figure 3, because we are excited both at the same time. There are two motor windings, so the magnetic field at this time is stronger than when a single winding is excited. Since the magnetic field is the vector sum of the two vertical fields, it is equal to 2×1.414 times of each field alone, so the torque applied by the motor to its load also increases proportionally.

Motor excitation sequence

Now that we know that a series of excitations will cause the stepper motor to rotate, the next step is to design the hardware to implement the required stepping sequence. A piece of hardware (or a set of equipment that combines hardware and software) that can make a motor move is called a motor driver.

It can be seen from Figure 4 how we can excite the windings of the two-phase motor to make the motor rotor rotate. In the figure, the winding taps in the motor are marked as 1A, 1B, 2A, and 2B. Among them, 1A and 1B are the two taps of winding 1, and 2A and 2B are the two taps of winding 2.

First, apply a positive voltage to pins 1B and 2B, and ground 1A and 2A. Then, apply a positive voltage to pins 1B and 2A, and ground 1A and 2B. This process actually depends on the direction in which the wire is wound around the slot. It is assumed that the direction in which the wire is wound is consistent with the previous section. Proceeding in sequence, we get the excitation sequence summarized in Table 1, where “1” means positive voltage and “0” means grounding.

There are two possible directions of current in the motor windings. Such a motor is called a bipolar motor and a bipolar drive sequence. A bipolar motor is usually driven by a circuit called an H-bridge. Figure 5 shows the circuit connecting the two taps of the H-bridge and the stepper motor.

The H bridge is connected to a fixed voltage DC power supply through a resistor (the amplitude can be selected according to the requirements of the motor), and then the circuit is connected to the two windings through four switches (labeled S1, S2, S3, and S4, respectively) Root tapped. The distribution of this circuit looks a bit like a capital letter H, so it is called an H bridge.

As can be seen from Table 1, to excite the motor, the first step should be to set tap 2A to logic 0 and 2B to logic 1, so we can close switches S1 and S4, and open switches S2 and S3. Next, we need to set tap 2A to logic 1, 2B to logic 0, so we can close S2, S3, and open S1 and S4. Similarly, in the third step we can close S2 and S3 and disconnect S1 and S4, and in the fourth step we can close S1 and S4 and disconnect S2 and S3.

The excitation method for winding 1 is nothing more than this, and the required excitation signal sequence can be generated by using a pair of H bridges. Table 2 shows the position of the switch at each step in the excitation process.

Note that if R=0, and switches S1 and S3 are accidentally closed at the same time, the current flowing through the switch will reach infinity. At this time, not only the switch will be burned out, the power supply may also be damaged, so a non-zero resistance resistor is used in the circuit. Although this resistor will bring some power consumption and reduce the efficiency of the motor driver, it can provide short-circuit protection.

Unipolar motor and its driver

We have discussed bipolar stepper motors and drivers earlier. Unipolar motors are similar to bipolar motors. The difference is that in unipolar motors, only the center tap of each winding can be accessed, as shown in Figure 6. We label the tap drawn from the top of the winding as tap B, the one drawn from the bottom as tap A, and the middle one as tap C.

Sometimes we will encounter some motors whose taps are not marked. If we know the structure of a stepper motor, it is easy to identify which taps belong to which winding by measuring the resistance between the taps. The impedance between the taps of different windings is usually infinite. If measured, the impedance between taps A and C is 100 ohms, then the impedance between taps B and C should also be 100 ohms, and the impedance between A and B is 200 ohms. The impedance value of 200 ohms is called winding impedance.

Figure 7 shows a single-phase drive circuit for a unipolar motor. It can be seen that when S1 is closed and S2 is disconnected, current will flow through the motor windings from right to left; when S1 is disconnected and S2 is closed, the current flow will change from left to right. Therefore, we can change the direction of current flow with only two switches (in a bipolar motor, we need 4 switches to do this). Table 3 shows the position of the switch when each step is activated in the unipolar motor drive circuit.

Although the drive of a unipolar motor is relatively simple to control, it is more complicated than a bipolar motor because of the use of a center tap in the motor, and its price is usually more expensive than that of a bipolar motor. In addition, since the current only flows through half of the motor windings, a unipolar motor can only generate half of the magnetic field.

After knowing the construction principles of unipolar motors and bipolar motors, when we encounter a motor that has no taps and no data sheet, we can deduce the relationship between taps and windings. A motor with 4 taps is a two-phase bipolar motor. We can tell which two taps belong to the same winding by measuring the impedance between the wires. The motor with 6 taps may be a two-phase unipolar motor or a three-phase bipolar motor. The specific situation can be determined by measuring the impedance between the wires.

motor control

The motor control theory discussed earlier in this article can be implemented with a full hardware solution, or with a microcontroller or DSP. Figure 8 illustrates how to use a transistor as a switch to control a two-phase unipolar motor. The base of each transistor must be connected to a digital output of the microcontroller through a resistor. The resistance can be from 1 to 10M ohms to limit the current flowing into the base of the transistor. The emitter of each transistor is grounded, and the collector is connected to the 4 taps of the motor winding. The center taps of the motors are all connected to the positive terminal of the power supply voltage.

The collector of each transistor is connected to a voltage source through a diode to protect the transistor from being burned out by the induced current on the motor winding when it is rotating. When the rotor rotates, an induced voltage will appear on the motor windings. If the collector of the transistor is not connected to a voltage source through a diode, the current caused by the induced voltage will rush into the collector of the transistor.

For example, suppose the digital output do1 is high and do2 is low, so do1 turns on transistor T1, and current flows from +V through the center tap and the base of T1, and then is output by the emitter of T1. But at this time do2 is in the off state, so current cannot flow through T2. Following this reasoning, we can change Table 3 to the sequence of changing the digital output of the microcontroller required to drive the motor.

Once we understand the sequence of hardware and digital output required to drive the motor, we can write software for the most comfortable microcontroller or DSP to implement these sequences.

Firmware control

I personally implemented the motor controller mentioned above on a Microchip PIC16F877 using 1N4003 diodes and 2SD1276A Darlington transistors. Bits 0 to 3 of PortA of PIC are used for digital output. The motor adopts the 5V dual-phase unipolar motor purchased from Jameco (Airpax [Thomson]Production, the model is M82101-P1), and use the same 5V power supply to power the PIC and the motor. However, in real applications, in order to avoid introducing noise to the power signal of the microcontroller, it is recommended that you use different power supplies to power the motor and the microcontroller.

Listing 1 shows the assembly source code of the control program, which rotates the motor every 50 milliseconds. First, the program initializes the digital output of the microcontroller to the value of the first step in Table 4, and then outputs the digital signals in the correct order every 50 milliseconds (this time constant is defined by the constant waitTime in the program). If you need to make the motor rotate in the reverse direction, just output the digital signal in the reverse order shown in Table 4.

The motor used by the author is a 24-pole motor, that is, each step of the output can control the motor to rotate 180°/24=7.5°. The motor rotates 7.5° every 50 milliseconds, that is, one revolution every 2.4 seconds. If the constant waitTime is reduced by half, the motor speed will double. However, because the rotor is restricted by inertia, friction and other mechanical forces, the motor speed has an upper limit. When the stator magnetic field rotates too fast, the rotor speed cannot keep up, causing the motor to fail to keep up and start skipping. If the ohm aitTime is lowered at this time, the motor may stop rotating altogether.

In addition to the two-phase motors discussed in this article, there are other types of stepper motors, such as three-phase stepper motors or four-phase stepper motors. There are also some dual-phase stepper motors, they have only one center tap, and are connected to the center points of the two windings at the same time. This type of stepper motor has 5 taps to lead out.

Similarly, stepper motors are not the only member of the motor family. The oldest and simplest motor is a direct current (DC) motor. Early DC motors used brushes, but they are no longer popular. Today’s common brushless DC motors are DC motors that use Electronic circuits to replace brushes for commutation. There is no brush aging problem in this type of motor, so its life is much longer than that of brushed DC motors.

There is also an induction motor whose working principle is completely different from that of a stepper motor or a DC motor. The DC motor uses a DC voltage source, and the induction motor uses an alternating current (AC) voltage source, and the rotation of the rotor and the stator magnetic field in the stepper motor and the DC motor is synchronized, while the rotation speed of the rotor in the induction motor lags behind the stator magnetic field.的rpm。

The Links:   AT93C46-10TI-27 NL4827HC19-05A MY-IGBT