Share this

A novel stepper motor motion controller based on a microcontroller

2026-04-06 07:28:51 · · #1
Abstract: Motion controllers play a crucial role in open CNC systems. A novel stepper motor motion controller based on a microcontroller was developed. The hardware aspects focused on the design and analysis of the motion controller's pulse frequency divider circuit, RS-232 communication interface circuit, D/A conversion circuit, V/I conversion circuit, switch signal input circuit, and system anti-interference circuit. The software aspects presented the overall system architecture. Keywords: Motion Control; Step Motor; SoC; Circuit Design Abstract: The motion controller plays a significant role in the open-architecture NC system. A new motor controller for step motor based on SoC is developed in this article. It designs the hardware system of motion controller, lays stress on analyzing the pulse output circuit, serial communication interface circuit, D/A conversion circuit, V/I conversion circuit, switch input circuit and the anti-interference circuit. At last, it confirms the general architecture of software. Keywords: Motion Control; Step Motor; SoC; Circuit Design 1 Introduction Numerical control technology is a high-tech technology that uses a computer to digitally process various control information in the machining process and to automatically control mechanical actuators through a high-performance drive unit. Modern mechanical processing industry is gradually developing towards flexibility, integration and intelligence. Therefore, the new generation of numerical control technology must emphasize the characteristics of openness, intelligence and networking [1]. This article uses a new microprocessor and high-performance integrated circuit to study and develop an intelligent step motor control card. 2 System Overall Structure Design Through analysis, research, and comparison of key technologies of stepper motor controllers, and considering the development trends of intelligentization, integration, and openness of motion controller products both domestically and internationally, the overall structure of the stepper motor motion controller we propose is shown in Figure 1. [align=center] Figure 1 System Overall Structure[/align] 3 System Hardware Circuit Design 3.1 Pulse Frequency Divider Circuit Design The main controlled object of this system is a stepper motor. A stepper motor is an actuator that converts electrical pulses into angular displacement; therefore, generating stepper motor drive pulses that meet the system requirements is crucial in the entire system design. The pulse frequency divider circuit of this system is shown in Figure 2. The entire circuit uses three 8254 chips to generate drive pulse signals for the X, Y, and Z axes. Since the circuits for the Y and Z axes are the same as those for the X axis, only the circuit principle of the X axis pulse count output is shown in the figure. The Inte18254 is a programmable timer/counter, containing three independent channels, each of which is a 16-bit counter with the same function. The operating mode and counting length of each counter are selected by software programming. The 8254 is an improved version of the 8253, with identical operation and pinout. While the 8253 has a counting frequency of 2.6MHz, the 8254 boasts a higher counting frequency, reaching 6MHz. This system selects the 8254 as the main control chip for the pulse frequency divider circuit. [align=center] Figure 2 Pulse Frequency Divider Circuit Diagram[/align] 3.2 RS-232 Communication Interface Circuit Design In microcontroller systems, RS-232 and RS-485 standard buses are the most mature applications. To broaden the applicability of the motion controller and utilize existing PC interfaces, we choose the RS-232 standard bus to implement communication between the controller and the PC. The interface circuit is shown in Figure 3. In Figure 3, the MAX232 is selected as the system's communication interface chip. The MAX232 is a low-power, single-supply dual RS-232 transmitter/receiver manufactured by Maxim Integrated, suitable for various EIA-232E and V.28/V.24 communication interfaces. The MAX232 chip can convert the input +5V power supply to the ±10V voltage required for RS-232 output level. Therefore, a serial communication system using this chip interface only requires a single +5V power supply. [align=center]Figure 3 Communication Interface Circuit[/align] The MAX232 requires four electrolytic capacitors: C1, C2, C3, and C4, which are for internal power conversion and are all 0.1μF/25V. C44 is a 0.1μF decoupling capacitor. The MAX232 pins T1IN, T2IN, R1OUT, and R2OUT are for TTL/CMOS level connections. The pins T1OUT, T2OUT, R1IN, and R2IN are for RS-232C level connections. Therefore, the TTL/CMOS level pins T1IN and T2IN should be connected to the MCS-51's serial transmit pin TXD; R1OUT and R2OUT should be connected to the MCS-51's serial receive pin RxD. The corresponding RS-232C level T1OUT and T2OUT should be connected to the PC's receiving terminal RD; R1IN and R2IN should be connected to the PC's transmitting terminal. 3.3 D/A Conversion and V/I Conversion Circuit Design This motion controller needs to control the speed of the electric spindle, which is achieved through its driver. The electric spindle driver determines the spindle speed based on the input voltage or current. Therefore, the system needs to output a voltage of 0-5V or a current of 0-20mA, requiring the processed digital quantity to be converted into an analog output via D/A conversion. The D/A conversion of this controller is mainly implemented by the DAC0832 chip. The DAC0832 is an 8-bit microprocessor-compatible digital-to-analog converter chip, part of the DAC0830 series. The DAC0832 has convenient interface with microcomputers and can fully utilize the microprocessor's control capabilities to achieve D/A conversion control, thus it has been widely used in practice. Different electric spindle drivers have different requirements for input signals. Some require a voltage signal of 0-5V, while others require a current signal of 0-20mV. Therefore, we also designed a V/I conversion circuit to enable the system to output a current signal, thus enhancing the system's adaptability. 3.4 Design of Switch Signal Input Circuit During the movement of a stepper motor, mechanical switches and photoelectric switches are often used to form a switch signal input circuit. The working condition of the stepper motor is reflected in the form of a level by the closing or opening of the switch. This includes X, Y, and Z axis limit; tool setting during machining; and zero-return operation of the X, Y, and Z axis motors, etc. [2-3]. Due to the mechanical design of the switch, mechanical jitter occurs when the contacts close or open, which will cause the output signal waveform to oscillate. If this signal is input into the counter of the microcontroller, it will cause incorrect counting and lead to system control chaos. Input interference of switch signals is an objective problem in system design. Therefore, after obtaining the switch signal, we must process the switch signal to make it a digital signal that the microcontroller can recognize before it can make a corresponding response. The system provides 12 switch signal interfaces. The limit switch signal processing is shown in Figure 4. [align=center] Figure 4 Schematic diagram of limit switch signal processing circuit[/align] Before the switch signal is input to the CPU, it is first filtered by a capacitor to suppress the high frequency components in the signal. TPL optocoupler isolation realizes the level conversion between photoelectric switch, limit switch signal and controller, and realizes the isolation between two different circuits, ensuring that the controller circuit is not affected by the switch signal circuit. 3.5 Hardware anti-interference technology In order to overcome various possible interferences and ensure that the system can operate reliably, the existing anti-interference technology takes the following measures in terms of hardware [4]: ​​① Suppress power interference. Conducted interference is usually introduced into the system from the AC power supply end. In order to suppress this interference, the system usually connects a low-pass LC filter in series at the AC input end. This method has achieved significant results in practice, but in order to suppress the impact of power surge voltage, the system must also install varistor between power lines and between power lines and ground. ② Suppress transmission line interference. For the long transmission distance of the system, shielded cables are usually selected to realize the connection of each part of the system to achieve the purpose of anti-interference. In systems with harsh operating environments, to further suppress interference, opto-isolation can be used to separate the system control section from the I/O port section, and dual power supply can be used. ③ Minimize the impact of interference. Common practices include: 1) Adding a hardware watchdog circuit. 2) Adding a voltage monitoring circuit. 3) Selecting a microcontroller series with strong anti-interference capabilities. 4) Using the microcontroller's internal program memory and internal data memory as much as possible instead of using external buses to connect these devices. 5) Coordinating the level matching of different types of ICs in the circuit. 6) When forming board-to-board connections between the data bus and the control bus, a bus driver should be added. 4 System Software Design The main program of the system consists of a message loop and an initialization program, and its flow is shown in Figure 5. In the main program of the system, the initialization program completes the setting of various special function registers of the microcontroller, the initialization of each data area, and the setting of external hardware devices after the system is reset; the system's message loop is used to implement the judgment of message validity and the calling of message processing function modules. [align=center]Figure 5 System Main Program Flowchart[/align] To determine the validity of messages, we define a corresponding validity check flag for each message in the message group. If the validity check flag for a message is "1", it indicates that the message is valid, and the system should call the corresponding message processing module to process the message; if it is "0", it indicates that the message is invalid, and the system should ignore the message. To implement the "watchdog" function, we also added a watchdog output operation in the message loop. It is worth noting that in the serial communication processing module of the system, the flag bits in the message sequence are set according to the received data to determine whether it is automatic processing, manual processing, or parameter setting, so as to ensure that the main program can correctly implement the call of each processing module. 5 Innovations of this paper This system uses an MCS51 series microcontroller to process data and control motion state, and uses an 8254 programmable timer/counter to realize the frequency division output of pulses, ensuring the real-time requirements of motion control. In order to enable the motion controller to work reliably in harsh environments, we use the X5045 integrated chip as the main component to form a low-cost, high-reliability anti-interference circuit to realize automatic protection of the stepper motor motion control card. Since the system was put into use, it has generated direct economic benefits of more than 500,000 yuan. References [1] Wang Zhengbing, Ren Si. Open architecture - the trend of CNC system development [J]. Manufacturing Technology and Machine Tool, 2002, 42 (1): 42. [2] Xu Yahui, Cheng Mingxiao, Zhang Yuhua. Stepper motor control system based on 80196 and PBL3717 [J]. Microcomputer Information, 2007, 23 (4-2): 123-125. [3] Xun Diandong, Xu Zhijun. Digital Circuit Design Handbook [M]. Beijing: Electronic Industry Press, 2003. [4] Song Xuejun, Zhu Minggang, Wu Hongyan. Digital Electronics Technology [M]. Beijing: Science Press, 2002.
Read next

Application and Development Trends of Machine Vision in China's Printing Industry

Machine vision has a 15-year history of development. As an application system, its functional characteristics have gradu...

Articles 2026-02-22
CATDOLL Ava Hard Silicone Head

CATDOLL Ava Hard Silicone Head

Articles
2026-02-22
CATDOLL 136CM Vivian

CATDOLL 136CM Vivian

Articles
2026-02-22