0 Introduction
Stepper motor is a widely used motor in industrial control. It can directly convert digital signals into angular displacement or linear displacement. The driving speed and command pulse can be strictly synchronized. It has high positioning accuracy and low control system cost. It is widely used in economical CNC machine tools and other fields. Here, for occasions with strong electromagnetic interference and low-cost applications, the super-strong anti-interference, compact and low-power industrial-grade STC12C series microcontroller is used to make full use of the hardware resources inside the microcontroller to design a practical stepper motor control and drive system.
1 Overall design of control system
The schematic
diagram of system function principle is shown in Figure 1.
In this system, the microcontroller directly outputs the motor's phase control pulse sequence, the optocoupler performs the necessary optoelectronic isolation, and the discrete components form the power MOSFET tube drive circuit to drive the motor to rotate. The keyboard interface and LED display function are realized by the ZLG7289 with SPI serial interface function. The motor's working mode and speed can be accurately set by key input, the motor speed can be continuously adjusted by the speed knob, and the motor's working mode can be adjusted and controlled by the host computer. [page]
2 Hardware circuit design
2.1 Control circuit design
The control chip uses STC12C4052AD, which is a 1 clock/machine cycle microcontroller, 8 to 12 times faster than the ordinary 8051 microcontroller, with 20 pins and a compact package. The microcontroller has super strong anti-interference and anti-static characteristics, can easily pass 4 kV fast pulse interference, and its power consumption is ultra-low, with a typical power consumption of 2.7 to 7 mA in normal working mode. The chip has its own hardware watchdog, high-speed SPI communication port, 8-channel 8-bit A/D conversion, 2-way PWM output, 4 KB FLASH memory, 256 B SRAM, 4 timers, and 1 full-duplex serial communication port. Due to the rich internal resources of the microcontroller and its high cost performance, it can meet the requirements of this design, reduce the design of hardware circuits, and improve work efficiency. The external pin definition of the microcontroller and its resource distribution in this design are shown in Figure 2.
The P1.4 (ADC4) port is connected to a 4.7 kΩ adjustable potentiometer, which is converted into a digital quantity using the analog/digital conversion function inside the microcontroller, and then controls the output pulse frequency to complete the "continuous" adjustment of the stepper motor speed. The result of the overcurrent detection is directly introduced into the external interrupt 0 to achieve rapid control of the current.
[page]
2.2 Drive circuit design
Part of the drive circuit of the power MOSFET is shown in Figure 3. The design of this circuit can improve the fast turn-on time of the power MOSFET, increase the steepness of the leading and trailing edges of the drive current, and improve the high-frequency response. The impedance between the gate and source of the power MOSFET is very high. The sudden change of the drain-source voltage in the switching state will be coupled to the gate through the inter-electrode capacitance, generating a VGS pulse voltage of considerable amplitude. The positive VGS pulse voltage may cause mis-conduction of the device. For this reason, it is necessary to appropriately reduce the impedance of the gate drive circuit, connect a damping resistor in parallel between the gate and source, or connect a Zener diode with a voltage regulation value less than 20 V but close to 20 V to prevent the gate from working in an open circuit.
In order to suppress the fast recovery in the power tube and the reverse recovery effect of the diode, four fast recovery diodes are connected in the circuit. Among them, the anti-parallel fast recovery diode is used to provide a freewheeling path for the motor phase winding, and the other two are only used to prevent the fast recovery diode inside the power MOSFET tube from flowing reverse current, so as to ensure that the power MOSFET tube can play a normal switch role during dynamic operation.
2.3 Display and key processing circuit
In the single-chip microcomputer application system, the typical keyboard display interface circuit is composed of 8155 and 8279 based on parallel expansion technology to form a control circuit. Modern single-chip microcomputer application systems widely use serial expansion technology. Compared with the parallel method, the serial expansion wiring is flexible and occupies less single-chip microcomputer resources.
ZLG7289A is an intelligent display driver chip with SPI serial interface function that can drive 8-bit digital tubes or 64 independent LEDs at the same time. A single chip can complete all the functions of display and keyboard interface. It communicates with the microprocessor in serial mode, and the data is sent to the chip from the DIO pin and synchronized by the CLK end. After the selected signal becomes low, the data on the DIO pin is written into the buffer register of ZLG7289A at the rising edge of the CLK pin. Figure 4 is a typical application of ZLG7289. ZLG7289A is connected to a common cathode digital tube. The digital tubes and keyboards that are not needed in the application can be disconnected. The digital tubes can be omitted or the digital tubes can be set to blanking properties, which will not affect the use of the keyboard. The entire circuit does not need to add latches and drivers, consumes less power, does not need to write display decoding programs in software design, eliminates static display expansion chips, and greatly saves CPU time. Only 4×4 keyboards and 4-digit digital tubes are used in this circuit design, which fully meets the design needs.
[page]
3 Software Design
The software part adopts modular structure design. The control of the stepper motor speed is realized by the timer working in interrupt mode. The timer timing interrupt generates a periodic pulse sequence, not a software delay method, which does not occupy the CPU time. The CPU can handle other events during the non-interrupt time, and only drives the stepper motor to rotate one step when an interrupt occurs. According to the excitation state conversion of the stepper motor, the required output state is obtained by table lookup method, and stored in the memory inside the single-chip computer in binary code; then the state word of the address is taken out in forward or reverse order, and sent to STC12C4052AD to output each excitation state, thereby realizing the function of the ring distributor.
The overall framework of the program includes: main program, overcurrent detection interrupt service subroutine, timer interrupt service subroutine, and other subroutines (including forward, reverse subroutines, keyboard display control subroutine, A/D conversion subroutine, etc.), due to space limitations, they are not described one by one here.
4 System Test
The system uses the super anti-interference, compact and low-power industrial-grade STC12C4052AD single-chip microcomputer as the control core, with high working reliability and strong anti-interference ability. The system test is carried out in a special testing laboratory. The system voltage change immunity, fast transient pulse group immunity, anti-static and lightning surge parameters are tested using special instruments such as group pulse generator (EFT-4001), cycle voltage drop generator (VDG-1105), electrostatic discharge generator (ESD-20) and lightning surge generator (SG-5006). After the experiment, the system functions normally and all parameters have reached the standard.
5 Conclusion
Electronic technology is developing rapidly, and new single-chip microcomputers are emerging in an endless stream. In the process of motor control system development, if the single-chip microcomputer and the models of each circuit module are properly selected, the design process can be simplified and the effect of getting twice the result with half the effort can be achieved. This system uses the STC12C4052AD single-chip microcomputer, and its working mode, rotation speed and torque can be input through the keyboard, or adjusted through ordinary knobs or host computers. The keyboard display module is implemented using ZLG7289. This system is versatile, and by appropriately changing the output port control terminals, stepper motors with different phases can be controlled.
Previous article:Design of Universal Data Acquisition and Communication Instrument Based on W77E58 Single Chip Microcomputer
Next article:Design of Computer Monitor Based on Single Chip Microcomputer
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
- Millimeter wave sensors enable edge intelligence
- A few key points about interrupts
- EEWORLD University - Make your design easier - Get to know TI's latest reference design for motor drive
- 32 MCU reset problem during operation
- Highly reliable medical bubble detection
- [National Competition Interview] “Three weaklings” won the first prize for question H, and the winners who won by luck are here! ?
- Kuyuan Electric Allegro video training
- What are the differences between precision op amps, instrument op amps, and general-purpose op amps?
- Detailed explanation of the principle of lora spread spectrum technology
- Questions about oscilloscope and USB flash drive