Stepper motors are widely used in control systems. They can convert pulse signals into angular displacement and can be used as electromagnetic brake wheels, electromagnetic differentiators, or angular displacement generators. Sometimes, if a stepper motor removed from some old equipment (this type of motor is generally not damaged) is to be used for other purposes, it is generally necessary to design a driver yourself. This article introduces a driver designed for a stepper motor removed from an old Japanese printer.
This article first introduces the working principle of the stepper motor, and then introduces the software and hardware design of its driver.
1. Working principle of stepper motor
This stepper motor is a four-phase stepper motor powered by a unipolar DC power supply. As long as the phase windings of the stepper motor are energized in the appropriate sequence, the stepper motor can be made to rotate step by step. Figure 1 is a schematic diagram of the working principle of the four-phase reactive stepper motor.
Figure 1 Schematic diagram of four-phase stepper motor stepping
At the beginning, switch SB is connected to the power supply, SA, SC, and SD are disconnected, and the magnetic pole of phase B is aligned with the 0th and 3rd teeth of the rotor. At the same time, the 1st and 4th teeth of the rotor are staggered with the magnetic poles of the C-phase winding and the D-phase winding, and the 2nd and 5th teeth are staggered
with the magnetic poles of the D-phase winding. When switch SC is connected to the power supply and SB, SA, and SD are disconnected, the magnetic lines of force between the C-phase winding and the 1st and 4th teeth cause the rotor to rotate, and the magnetic poles of teeth 1 and 4 are aligned with the magnetic poles of the C-phase winding. The 0th and 3rd teeth are staggered with the A-phase winding and the 2nd and 5th teeth are staggered with the magnetic poles of the A-phase winding. By analogy, the four-phase windings A, B, C, and D are powered in turn, and the rotor will rotate in the directions of A, B, C, and D.
According to the different power-on sequences, the four-phase stepper motor can be divided into three working modes: single four-beat, double four-beat, and eight-beat. The step angles of single four-beat and double four-beat are equal, but the torque of single four-beat is small. The step angle of eight-beat working mode is half of that of single four-beat and double four-beat. Therefore, eight-beat working mode can maintain a high torque and improve control accuracy.
The power supply timing and waveform of single four-beat, double four-beat and eight-beat working modes are shown in Figure 2.a, b, and c respectively:
a. Single four-beat b. Double four-beat c. Eight-beat
Figure 2. Stepper motor working timing waveform
2. Circuit principle of stepper motor driver system based on AT89C2051
The circuit principle of stepper motor driver system is shown in Figure 3:
Figure 3 Stepper motor driver system circuit diagram
AT89C2051 outputs the control pulse from P1.4~P1.7 of P1 port, and enters 9014 after being inverted by 74LS14. After being amplified by 9014, it controls the photoelectric switch. After photoelectric isolation, the power tube TIP122 amplifies the pulse signal in voltage and current to drive each phase winding of the stepper motor. The stepper motor can perform forward rotation, reverse rotation, acceleration, deceleration and stop according to different pulse signals. In the figure, L1 is a single-phase winding of the stepper motor. AT89C2051 uses a crystal oscillator with a frequency of 22MHz. The purpose of using a higher crystal oscillator is to minimize the influence of AT89C2051 on the pulse signal cycle of the host computer under mode 2.
RL1~RL4 in Figure 3 are the internal resistance of the winding, and the 50Ω resistor is an external resistor, which plays a current limiting role and is also a component to improve the loop time constant. D1~D4 are freewheeling diodes, which attenuate the back electromotive force generated by the motor winding through the freewheeling diodes (D1~D4), thereby protecting the power tube TIP122 from damage.
A 200μF capacitor is connected in parallel to the 50Ω external resistor to improve the leading edge of the current pulse injected into the stepper motor winding and improve the high-frequency performance of the stepper motor. The 200Ω resistor connected in series with the freewheeling diode can reduce the discharge time constant of the loop, make the trailing edge of the current pulse in the winding steeper, and reduce the current drop time, which also plays a role in improving the high-frequency working performance.
3. Software Design
The driver has three working modes to choose from according to the different combinations of the dial switches KX and KY:
Mode 1 is the interrupt mode: P3.5 (INT1) is the step pulse input terminal, and P3.7 is the forward and reverse pulse input terminal. The host computer (PC or single-chip microcomputer) is connected to the driver with only two lines.
Mode 2 is the serial communication mode: the host computer (PC or single-chip microcomputer) sends the control command to the driver, and the driver completes the relevant control process according to the control command.
Mode 3 is the control mode of the code switch: the stepper motor is directly controlled through different combinations of K1~K5.
When the power is turned on or the reset button KR is pressed, the AT89C2051 first detects the status of the code switches KX and KY, and enters different working modes according to different combinations of KX and KY. The following is the program flow chart and source program of mode 1.
In the compilation of the program, special attention should be paid to the processing of the stepper motor during reversing. In order to make the stepper motor transition smoothly during reversing and avoid misstepping, the flag bit should be set in each step. Among them, each bit of the 20H unit is the forward flag bit of the stepper motor; each bit of the 21H unit is the reverse flag bit. When rotating forward, not only the forward flag bit is assigned a value, but also the reverse flag bit is assigned a value; the same is true when reversing. In this way, when the stepper motor is reversing, the previous position can be used as the starting point for reverse movement, avoiding misstepping when the motor is reversing.
Figure 4: Method 1 program flowchart
Mode 1 source program:
MOV 20H,#00H ;20H unit is initialized, motor forward position pointer
MOV 21H,#00H ;21H unit is initialized, motor reverse position pointer
MOV P1,#0C0H ;P1 port is initialized to prevent motor power-on short circuit
MOV TMOD,#60H ;T1 counter is initialized, interrupt is enabled
MOV TL1,#0FFH
MOV TH1,#0FFH
SETB ET1
SETB EA
SETB TR1
SJMP $
;***********Counter 1 interrupt program************
IT1P: JB P3.7,FAN ;Motor forward and reverse pointers
;****************Motor forward********************
JB 00H,LOOP0
JB 01H,LOOP1
JB 02H,LOOP2
JB 03H,LOOP3
JB 04H,LOOP4
JB 05H,LOOP5
JB 06H,LOOP6
JB 07H,LOOP7
LOOP0: MOV P1,#0D0H
MOV 20H,#02H
MOV
21H
,#40H
AJMP
QUIT
LOOP1: MOV P1,
#090H
MOV 20H,
#04H
MOV 21H,#20H
AJMP
QUIT
LOOP2
: MOV P1
,#
0B0H MOV
AJMP
QUIT
LOOP5
: MOV P1,#060H
MOV 20H,#40H
MOV
21H,#02H
AJMP QUIT
LOOP6: MOV P1,#0E0H
MOV 20H,#80H
MOV 21H,#01H
AJMP QUIT
LOOP7: MOV P1,#0C0H
MOV 20H,#01H
MOV 21H,#80H
AJMP QUIT
; ***************Motor reverse************************
FAN: JB 08H,LOOQ0
JB 09H,LOOQ1
JB 0AH,LOOQ2
JB 0BH,LOOQ3
JB 0CH,LOOQ4
JB 0DH,LOOQ5
JB 0EH,LOOQ6
JB 0FH,LOOQ7
LOOQ0: MOV P1,#0A0H
MOV 21H,#02H
MOV 20H,#
40H MOV P1
,#0E0H MOV 21H,#04H
MOV 20H,#20H
AJMP
QUIT
LOOQ2: MOV P1,#0C0H
MOV 21H,#08H
MOV 20H,#10H
AJMP QUIT
LOOQ3: MOV P1,#0D0H
MOV 21H,#10H
MOV 20H,#08H
AJMP QUIT
LOOQ4: MOV P1,#050H
MOV 21H,#20H
MOV 20H,#04H
AJMP QUIT
LOOQ5: MOV P1, #070H
MOV 21H,#40H
MOV 20H,#02H
AJMP
QUIT
LOOQ6
:
MOV
P1,#030H
MOV 21H
,#80H
MOV 20H,#01H
QUIT: RETI
END
4.
Conclusion The driver has been verified by experiments to be able to drive a 0.5Nm stepper motor. By adjusting the parameters of the resistance, capacitance and freewheeling diode of the driver part, it can drive a 1.2Nm stepper motor. The driver circuit is simple and reliable, with a compact structure. It is especially suitable for systems with limited I/O port lines and microcontroller resources.
Previous article:Design of driving circuit for electronic expansion valve of air conditioner temperature control
Next article:Distributed detection method of vibration signal based on 51 single chip microcomputer and MXA2500GL sensor
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Application of depletion-mode MOSFET in industrial sensors and smart transmitters
- Last two days! Free trial: Tailing Micro's new generation of low-power, high-performance multi-protocol wireless kit B91
- Award-winning live broadcast: Beneng International launches millimeter-wave radar module based on Infineon technology, perfectly solving the pain points of PIR market
- Practical information - Modbus communication protocol 1
- [RISC-V MCU CH32V103 Evaluation] 3. USB HID routine operation
- 01_Basic principles of static timing analysis and timing analysis model
- 12V700MA power supply solution
- Award-winning live broadcast: ON Semiconductor's advanced packaging and drive technology helps silicon carbide energy applications. Registration is now open~
- MSP430 MCU Example 15 - Watchdog Timer Timing Application
- [IoT development based on Raspberry Pi educational kit] openCV environment construction and testing