Stepper Motor Driver Based on 51 Single Chip Microcomputer

Publisher:和谐的24号Latest update time:2016-05-11 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
 Stepper motors are widely used in control systems. They can convert pulse signals into angular displacements and can be used as electromagnetic brake wheels, electromagnetic differentiators, or angular displacement generators.

  Sometimes, if you want to use a stepper motor removed from some old equipment (this type of motor is generally not damaged) for other purposes, you usually need to design your own driver. This article introduces the 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

  The stepper motor is a four-phase stepper motor, which is powered by a unipolar DC power supply. As long as the phase windings of the stepper motor are energized in a suitable timing, 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 B-phase magnetic pole is aligned with the rotor teeth 0 and 3. At the same time, the rotor teeth 1 and 4 are staggered with the C and D-phase winding magnetic poles, and the teeth 2 and 5 are staggered with the D and A-phase winding magnetic poles.

  When the switch SC is connected to the power supply and SB, SA, and SD are disconnected, the rotor rotates due to the magnetic lines of force between the C-phase winding and the 1st and 4th teeth, and the 1st and 4th teeth are aligned with the magnetic poles of the C-phase winding. However, the 0th and 3rd teeth are staggered with the A- and B-phase windings, and the 2nd and 5th teeth are aligned with the A- and D-phase windings.

 
By analogy, if the four-phase windings A, B, C, and D are powered in turn, the rotor will rotate in the directions A, B, C, and D.

  Four-phase stepper motors can be divided into three working modes according to the different power-on sequences: 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 higher torque and improve control accuracy.

  The power-on timing and waveform of the single four-beat, double four-beat and eight-beat working modes are shown in Figure 2.a, b, and c respectively:

  Figure 2. Stepper motor working timing waveform  


 

 

  2. Circuit principle of stepper motor driver system based on AT89C2051

  Figure 3 Stepper motor driver system circuit diagram  

 



 

  AT89C2051 outputs the control pulse from P1.4 to 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 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.

  In Figure 3, RL1~RL4 are the internal resistance of the winding, and the 50Ω resistor is an external resistor that acts as a current limiter and is also a component that improves 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.

  Connecting a 200μF capacitor in parallel with a 50Ω external resistor can 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 in series with the freewheeling diode can reduce the discharge time constant of the loop, making the trailing edge of the current pulse in the winding steeper and the current falling time shorter, 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 DIP 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 MCU) is connected to the driver with only two lines.

  Mode 2 is 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 DIP switch control mode: directly control the stepper motor through different combinations of K1 to K5.

  When the power is turned on or the reset button KR is pressed, AT89C2051 first detects the status of the DIP switches KX and KY, and enters different working modes according to the different combinations of KX and KY. The following is the program flow chart and source program of mode 1.

  When compiling the program, special attention should be paid to the handling of the stepper motor during commutation. In order to make the stepper motor transition smoothly during commutation and avoid step errors, a flag should be set in each step. The 20H unit is the forward flag of the stepper motor; the 21H unit is the reverse flag. When rotating forward, not only the forward flag is assigned a value, but also the reverse flag is assigned a value; the same is true when reversing. In this way, when the stepper motor commutates, the previous position can be used as the starting point for reverse movement, avoiding step errors when the motor commutates.

  Figure 4: Method 1 program flowchart

  

 



 

  Method 1 source program:

  MOV 20H,#00H; 20H unit is reset to initial value, motor forward position pointer

  MOV 21H,#00H; 21H unit is reset to initial value, motor reverse position pointer

  MOV P1,#0C0H; Initialize the P1 port to prevent the motor from short circuiting when powered on

  MOV TMOD,#60H; Initialize T1 counter and enable interrupt

  MOV TL1,#0FFH

  MOV TH1,#0FFH

  SETB ET1

  SETB EA

  SETB TR1

  SJMP$

  ;***********Counter 1 interrupt procedure************

 

  IT1P: JB P3.7, FAN; Motor forward and reverse pointer

  ;****************Motor rotates 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 20H,#08H

  MOV 21H,#10H

  AJMP QUIT

  LOOP3: MOV P1,#030H

  MOV 20H,#10H

  MOV 21H,#08H

  AJMP QUIT

  LOOP4: MOV P1

 
,#070H

  MOV 20H,#20H

  MOV 21H,#04H

  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 reverses*****************

  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

  AJMP QUIT

  LOOQ1: 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

  AJMP QUIT

  LOOQ7: MOV P1,#0B0H

  MOV 21H,#01H

  MOV 20H,#80H

  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 relevant 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, and is particularly suitable for systems with tight I/O port lines and microcontroller resources.

Reference address:Stepper Motor Driver Based on 51 Single Chip Microcomputer

Previous article:A brief discussion on modular programming of single-chip microcomputers in C language - with ds1302 clock chip driver
Next article:STC89C52 controls the on and off of the running light through the serial port

Recommended ReadingLatest update time:2024-11-16 21:45

Primary-side regulation of PFC flyback LED driver solution
The consumer electronics market, especially the LED driver market, has developed rapidly in recent years. These markets require power supplies/drivers with low power consumption, small size and ultra-low cost. In addition, due to the increasing requirements for power quality, the use of power factor correction ( PFC)
[Power Management]
Primary-side regulation of PFC flyback LED driver solution
LPC1768 USB driver (Part 3) ----LPC1768 USB module
(Figure 1) USB device controller block diagram Module Introduction: AHB: Mainly used for connection between high-performance modules (CPU, DMA and DSP, etc.); USB ATX: The analog transceiver built into the USB device controller is used to send and receive D+ and D- signals on the USB bus; SIE (SERIAL INTERFACE ENGIN
[Microcontroller]
LPC1768 USB driver (Part 3) ----LPC1768 USB module
Design of Class D Headphone Driver Circuit Based on 555 Timer
  This Design Idea provides two simple, inexpensive drivers for headphones and audio lines, as shown. These drivers are designed for electric guitar and violin, but can be used in many other applications. For simple applications like this, noise and total harmonic distortion (THD) are not important considerations, so
[Power Management]
Design of Class D Headphone Driver Circuit Based on 555 Timer
Proteus simulation of relay driving light bulb
1. Brief description of relay A relay (as shown in Figure 1) is an electrical control device that has an interactive relationship between the control system (input circuit) and the controlled system (output circuit). In fact, it is an "automatic switch" that uses a small current to control a large current. It plays th
[Microcontroller]
Improvement of MEMS switch based on low voltage driving RFMEMS switch
In recent years, radio frequency microelectronic system (RF MEMS) devices have attracted widespread attention for their small size and low power consumption. In particular, the phase shifters and antennas constructed by MEMS switches are key technologies for realizing phased array radars with tens of thousands of
[Analog Electronics]
Optimization scheme for inverter motor drive power module
Electric motors are used to drive a wide variety of loads - fans used in air conditioning systems, pumps that provide fresh water, and motors used in factories to drive manufacturing equipment are just a few examples. Traditionally, these motors were connected directly to the power supply from the grid. Since the op
[Embedded]
Optimization scheme for inverter motor drive power module
Hisense's ultra-high-definition display driver chip project was nominated for the Qingdao Science and Technology Progress First Prize
Recently, the official website of Qingdao Science and Technology Bureau issued an announcement that the review work of the 2020 Qingdao Science and Technology Award project team has been completed. 由海信视像、青岛信芯微、上海顺久电子、宏祐图像完成的《超高清显示驱动系列化芯片开发及应用》项目,入选2020年度青岛市科学技术奖建议授奖项目(科技进步奖一等奖)。 In 2019, the project's chip HS3710 pa
[Mobile phone portable]
Hisense's ultra-high-definition display driver chip project was nominated for the Qingdao Science and Technology Progress First Prize
Driving a Brushed DC Motor Using PWM Output: Losses and Considerations
Using PWM output to drive a brushed DC motor: Loss thinking Since PWM drive is a pulse drive, its power consumption is only the average of the power consumption during the voltage application (conduction) period and the current regeneration (off) period of the motor in one cycle. Strictly speaking, as shown in
[Embedded]
Driving a Brushed DC Motor Using PWM Output: Losses and Considerations
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号