A stepping motor is a micro-motor that converts electrical pulse signals into angular displacement to control rotor rotation. It serves as an actuator in automatic control devices. Each input pulse signal causes the stepping motor to move one step forward, hence it is also called a pulse motor. Stepping motors are widely used in peripherals of digital computers, as well as printers, plotters, and disk drives. The drive power supply for a stepping motor consists of a frequency converter pulse signal source, a pulse distributor, and a pulse amplifier, which provides pulse current to the motor windings.
The performance of a stepper motor depends on the proper coordination between the motor and the drive power supply. The advantages of stepper motors are the absence of cumulative error, simple structure, ease of use and maintenance, low manufacturing cost, and high load inertia capacity, making them suitable for small and medium-sized machine tools and applications where speed accuracy requirements are not high. The disadvantages are lower efficiency, higher heat generation, and occasional "step loss." Stepper motors are classified into three basic types: electromechanical, magnetoelectric, and linear.
An electromechanical stepper motor consists of an iron core, coils, and a gear mechanism. When the solenoid coil is energized, it generates magnetic force, which drives the iron core to move. This movement causes the output shaft to rotate by an angle through the gear mechanism, and the anti-rotation gear keeps the output shaft in the new working position. When the coil is energized again, the shaft rotates by another angle, and so on, performing stepping motion.
Magnetoelectric stepper motors are simple in structure, highly reliable, inexpensive, and widely used. They mainly include permanent magnet, reluctance, and hybrid types.
(1) Permanent magnet stepper motor.
The basic principle of a permanent magnet stepper motor is that its rotor has permanent magnet poles that generate an alternating magnetic field in the air gap. The stator consists of four-phase windings (see figure). When phase A winding is energized, the rotor will rotate in the direction of the magnetic field determined by that phase winding. When phase A is de-energized and phase B winding is energized, a new magnetic field direction is generated. At this time, the rotor rotates by an angle and is located in the new magnetic field direction. The order of the energized phases determines the direction of rotor rotation.
If the stator excitation changes too rapidly, the rotor will not be able to keep pace with the change in the stator magnetic field direction, resulting in rotor loss of synchronization. The relatively low starting and operating frequencies are a drawback of permanent magnet stepper motors. However, permanent magnet stepper motors consume less power and have higher efficiency. In the early 1980s, permanent magnet disc stepper motors with disc rotors emerged, enabling step angles and operating frequencies to reach the levels of reluctance stepper motors.
(2) Reluctance stepper motor.
The stator and rotor cores have closely spaced teeth and slots distributed according to a certain pattern on their inner and outer surfaces. The change in the relative position of these teeth and slots causes a change in the magnetic reluctance of the magnetic circuit, thereby generating torque. The rotor core is made of silicon steel sheets or soft magnetic materials. When a phase of the stator is energized, the rotor rotates to the position where the magnetic reluctance is minimized. When another phase is energized, the rotor rotates to another position, and when the magnetic reluctance is minimized, the motor stops rotating. At this point, the rotor has rotated through one step angle θb, where N is the number of operating steps the rotor takes to rotate one tooth pitch; ZR is the number of rotor teeth. Reluctance stepper motors have various structural forms. The stator core can be single-section or multi-section; the magnetic circuit can be radial or axial; and the number of winding phases can be three-phase, four-phase, or five-phase. Reluctance stepper motors can achieve step angles of 1° to 15°, or even smaller, with easily guaranteed precision and high starting and running frequencies, but they have higher power consumption and lower efficiency.
(3) Hybrid stepper motor.
Its stator and rotor core structure is similar to that of a reluctance stepper motor. The rotor has permanent magnets that generate a unipolar magnetic field in the air gap, which is also modulated by the slots of the soft magnetic material on the rotor. The hybrid stepper motor combines the advantages of both permanent magnet and reluctance stepper motors, featuring a small step angle, high precision, high operating frequency, low power consumption, and high efficiency.
Stepper motor forward and reverse rotation control methods:
1. A stepper motor has four-phase windings A, B, C, and D. When one winding is energized, it forms N and S poles inside the motor, generating a magnetic field. When the energized phase changes, the magnetic field rotates. Under the action of the magnetic field, the rotor will rotate. If the stepper motor works in a double four-phase manner.
2. When the pulse input sequence on the four-phase windings A, B, C, and D is AB→BC→CD→DA→AB, the stepper motor will rotate clockwise (forward). If the pulse input sequence is AB→DA→CD→BC→AB, the stepper motor will rotate counterclockwise (reverse). The motor's internal data parameters can remain as they are and do not need to be adjusted.
Overall program results:
(1) First, rotate clockwise once, wait one second, and then rotate counterclockwise once. This process can be modified by removing it from the program, i.e., the part before the while loop in the main function will only be executed once.
while(1)
{
(2) Press button 1, and the entire motor will start to rotate forward N times. As long as the detection button is pressed, the entire motor will continue to rotate forward. When other buttons are detected to be pressed, the program will immediately jump to the corresponding program of those other buttons.
(3) Press button 2, which is the opposite of button 1.
(4) Button 3, to stop the entire motor from working.
}
Parts 2, 3, and 4 above are continuously scanned and detected in a loop.
#include
#include
unsigned char code z[]={0x02,0x06,0x04,0x0c,0x08,0x09,0x01,0x03//315,270,225......360(0)
};//Eight beats
unsigned char code f[]={0x01,0x09,0x08,0x0c,0x04,0x06,0x02,0x03//45,90,145......360(0)
};
sbit K1 = P3^0; // Define the forward rotation button
sbit K2 = P3^1; // Define the reverse button
sbit K3 = P3^2; // Define the stop button
void zz(unsigned char n);
void fz(unsigned char n);
void delay();
void step();
void main()
{
unsigned char N = 1; // Since the data for one revolution has been set, N is set here to indicate how many revolutions.
TMOD=0X10;
TL1=0XF0;
TH1=0XD8;
EA=0;
ET1=0; // Timer interrupts are not used here; only the timer's timing function is used.
zz(N);
delay();
fz(N);
while(1)
{
if(K1 == 0)
{
while(1)
{
P0 = 0xfe;
zz(N);
if(K3 == 0||K2==0) break;
}
}
else if (K2 == 0)
{
while(1)
{
P0 = 0xfd;
fz(N);
if(K3 == 0||K1==0) break;
}
}
else
{
P0 = 0xfb;
P1 = 0x03;
}
}
}
void zz(unsigned char n) // Rotate forward
{
unsigned char i,j;
for(i=0;i
{
for(j=0;j<8;j++) // The entire for loop rotates one step angle. Since it is a four-phase eight-beat loop, it is half a step angle, i.e., half a step.
{
if(K3 == 0) break;
P1 = z[j];
step();
}
}
}
void fz(unsigned char n) // Reverse
{
unsigned char i,j;
for(i=0;i
{
for(j=0;j<8;j++)
{
if(K3 == 0) break;
P1 = f[j];
step();
}
}
}
void delay() // Defines a time interval of 1 second
{
unsigned char i,j,k;
_nop_();
i=8;
j=154;
k=122;
do
{
do
{
while(--k);
while(--j);
while(--i);
}
void step() // Timer counts down 10ms
{
TF1=0;
TR1=1;
while(TF1==0);
TR1=0;
TL1=0XF0;
TH1=0XD8;
}
1. The delay used in the program can be written according to your own habits. However, due to the delay during the motor rotation process, the 10ms timer in the for loop mentioned above is adjusted according to the actual situation. Theoretically speaking, the minimum delay of the motor simulated by Proteus is 1ms. If it is less than 1ms, you will not see the ideal result of your code in the experiment.
2. Since the step angle is different, the parameters for executing the `zz` or `fz` function will need to be different to make the motor rotate one revolution. Take my program above as an example.
Eight beats make one cycle, rotating 360 degrees, with a step angle of 90 degrees.
So, if the step angle is 45°, it would take 16 beats to turn 360°.
You'll need to modify the program and experiment yourself; this is just a heads-up. If you're working with more than 256 frames, unsigned char won't be enough; you'll need unsigned int.
A stepper motor driver is an actuator that converts electrical pulses into angular displacement. When a stepper driver receives a pulse signal, it drives the stepper motor to rotate a fixed angle (called the "step angle") in a set direction. Its rotation occurs step by step at fixed angles. The amount of angular displacement can be controlled by controlling the number of pulses, thereby achieving accurate positioning. Next, we will explain in detail how to control the direction of a stepper driver and how to set the stepper driver to rotate in both directions.
Pulse control is used because pulses have a quantity, which facilitates precise control. Therefore, the direction of a stepper motor is controlled by pulses.
How to control it: Generally, a high level controls one direction, and a low level controls the other direction.
Some systems use two-pulse control. One pulse's high level controls one direction, and the other pulse's high level controls the other direction.
By controlling the sequence of pulses input to the four-phase windings, the forward/reverse rotation of the motor can be controlled. (The speed can be controlled by adjusting the delay.)
The direction level signal DIR is used to control the rotation direction of the stepper motor. When this terminal is high, the motor rotates in one direction; when this terminal is low, the motor rotates in the other direction. Motor commutation must be performed after the motor has stopped, and the commutation signal must be sent after the last CP pulse of the previous direction and before the first CP pulse of the next direction.
If the controller (host) sends double pulses (e.g., positive and negative pulses) or the pulse signal amplitudes are mismatched, a signal module is needed to convert them to 5V single pulses.
1. Input is a single pulse
The DIP switches of the signal module should be set to the "single pulse" position. The motor will rotate if a pulse is output. Changing the direction signal by high and low levels will change the direction of rotation. Refer to the signal module manual for specific timing instructions.
2. Input is a double pulse.
The DIP switches of the signal module should be set to the "Dual Microphone: Middle" position. Sending a positive pulse will cause the motor to rotate in the forward direction, while sending a negative pulse will cause the motor to rotate in the reverse direction. Positive and negative pulses cannot be sent simultaneously; please refer to the signal module manual for specific timing instructions.
The stepper motor is running in the opposite direction to the desired direction. How should I adjust it? Shanshe Motor's technical engineers have proposed two solutions:
One approach is to change the direction signal of the control system.
Another method is to change the direction by adjusting the wiring of the stepper motor. The specific method is as follows:
For a two-phase motor, simply switch one of the motor lines to a stepper motor driver that exchanges A+ and A.
For a three-phase motor, you cannot replace one of the motor wires, but you must replace two phases in sequence, for example, swapping A+ and B+.
A- and B- are interchanged.