Design of an integrated control system for stepper motors
2026-04-06 06:20:24··#1
Abstract: This paper constructs a stepper motor control system integrating a stepper motor controller and driver using a microcontroller, stepper motor driver chip, character LCD, and keyboard array. A two-dimensional worktable, as the controlled object, is driven by a stepper motor to move a ball screw in the X/Y axes. The paper discusses an interpolation method to determine a circular arc trajectory with minimal parameters and a stepper motor frequency conversion speed regulation method. The development of the stepper motor control system adopts a hardware-software co-simulation method, which can effectively reduce the system development cycle and cost. Finally, an application example of the stepper motor control system is given. Keywords: Stepper motor control system, interpolation algorithm, frequency conversion speed regulation, hardware-software co-simulation 1 Introduction As a digital servo actuator, the stepper motor has advantages such as simple structure, reliable operation, convenient control, and good control performance, and is widely used in CNC machine tools, robots, and automated instruments. To achieve simple motion control of the stepper motor, a microcontroller is generally used as the microprocessor of the control system, and the speed and position positioning control of the stepper motor is realized through a dedicated stepper motor driver chip. 2 Improved Algorithm for Circular Interpolation The point-by-point comparison interpolation algorithm is widely used in the position control of stepper motors because of its simplicity, ease of implementation, and maximum error not exceeding one pulse equivalent [1]. In circular interpolation, in order to determine the trajectory of a circular arc, the following methods can be used: give the coordinates of the center, the starting point, and the ending point; give the radius, the starting point, and the ending point; give the coordinates of the three points of the arc, etc. If these parameters are stored in the limited data memory (RAM) inside the microcontroller during algorithm implementation, and if a segment of the arc needs to be determined through complex calculations, it will not only burden the microprocessor, but also require multiple steps of calculation, which will often affect the accuracy of the algorithm. Therefore, it is necessary to select a simple and highly accurate interpolation algorithm. This paper proposes an improved algorithm: In circular interpolation, regardless of the position of the arc, whether it is clockwise or counterclockwise, the center of the arc is used as the origin to determine other coordinates. Therefore, only the starting point coordinates and the arc angle need to be given to determine the arc. If an axis coordinate is stored using 4 bytes (e.g., 12.36) and an angle is stored using 2 bytes (e.g., 45°), then only 10 bytes are needed to determine a two-dimensional arc. Compared to other methods, this saves up to 14 storage units. Taking the inverse arc in the I quadrant as an example, we calculate its endpoint coordinates. As shown in Figure 1, (X0, Y0) are the starting coordinates of the arc, (Xe, Ye) are the endpoint coordinates, and θ is the angle of the arc. [align=center] Figure 1 Schematic diagram of the arc trajectory[/align] Arc radius: , Endpoint coordinates: Angle of endpoint coordinates relative to the X-axis: This system requires the input angle to be accurate to 1 degree, and the resolution of the input coordinates is 0.01. The floating-point operation of the microcontroller's C language can be accurate to 0.000001. Although there is an error in the endpoint coordinates calculated according to the above formula, this error is less than 1%, which meets the required accuracy. 3 Variable frequency speed regulation of stepper motors Although stepper motors have the characteristics of fast start and stop, high precision, and easy speed control, in actual operation, due to improper start and stop control, stepper motors will still exhibit jitter during start and overshoot during stop, which will affect the control accuracy of the system. This phenomenon is more obvious when the stepper motor is working with frequent start and stop [2]. To this end, this paper proposes a discrete control method for stepper motor acceleration and deceleration based on single-chip microcomputer control. The acceleration and deceleration curves are shown in Figure 2. The vertical axis is the frequency f, and the unit is pulse/second or step/second. The horizontal axis is the time t, and the unit is second. The stepper motor starts at f0 and accelerates to the highest operating frequency f at time t1. Then it runs at a constant speed and starts to decelerate at time t2. The motor stops at time t5. The total number of steps is N. Among them, the acceleration from the standstill to the highest operating frequency and the deceleration from the highest operating frequency to the stop are the key to stepper motor control. The uniform acceleration and uniform deceleration methods are usually adopted. [align=center]Figure 2 Time vs. Frequency Function Graph Figure 3 Discretized Time-Frequency Graph[/align] Using a microcontroller to control the acceleration and deceleration of a stepper motor essentially involves changing the time interval of the output pulses. This can be achieved using both software and hardware methods. The software method relies on a delay program to change the frequency of the pulse output, where the delay length is dynamic. This method consumes a significant amount of CPU time because it continuously generates control pulses. The hardware method relies on the microcontroller's internal timer. After each timer interrupt, the timer constant (timer load value) is changed, thus gradually increasing the pulse frequency during acceleration and gradually decreasing it during deceleration. This method consumes less CPU time and is a more efficient stepper motor speed control method. Considering the microcontroller's resources (word length) and programming convenience, it is not necessary to calculate the timer load value for each step. As shown in Figure 3, the acceleration and deceleration curves are discretized using a discretization method. After discretization, the speed increases in steps, and each step is held for a period of time to overcome the speed lag caused by the rotor inertia of the stepper motor. Only when the actual running speed reaches the preset value can it accelerate rapidly, which is actually an automatic correction of local speed error. 4 System hardware and software co-design For the software development of 51 series microcontrollers, the traditional method is to use development tools such as Keil on a PC to design, compile, and debug the program. After the program is debugged, the target file is generated and downloaded to the microcontroller hardware circuit for hardware debugging [3]. This method can only be used for system function testing after the hardware circuit is completed. If a design problem is found in the hardware circuit and it must be modified at this time, it will significantly affect the cost and cycle of system development. Therefore, this paper adopts the system hardware and software co-simulation development method, which makes it possible to perform functional testing before the hardware circuit is implemented. At the same time, the software simulation of the hardware circuit provides a strong guarantee for the design and implementation of the hardware circuit. In the Keil uVision2 integrated development environment, the program design, compilation, and debugging of the stepper motor control system are realized, and the target file *.hex is finally generated. The EDA tool Proteus provided by Proteus Labcenter electronics in the UK uses the target file *.hex to test the function of the hardware circuit of the stepper motor control system. [align=center]Figure 4 Hardware Circuit Simulation of Stepper Motor Control System[/align] As shown in Figure 4, the AT89C55 microcontroller acts as the stepper motor controller. It controls two L298 stepper motor driver chips by running a program developed in the Keil uVision2 environment, thereby achieving coordinated control of the AXIS_X / AXIS_Y two-axis stepper motors. The stepping pulse input signal of the L298 driver chip comes from the P0 port of the AT89C55. The enable signals ENABLE A and ENABLE B are connected in parallel to the P3.0 and P3.1 ports of the AT89C55. The program controls the enabling of the stepper motors, thus preventing the motor coils from being short-circuited and burning out the driver chips. A 4 x 4 keyboard array is connected to the P1 port of the AT89C55. The specific function of each key is defined through program design. The LCD data ports DB0~DB7 are connected to the P2 port of the AT89C55, and the control ports RS, RW, and E are connected to the P3.5, P3.6, and P3.7 ports of the microcontroller, respectively. Relevant parameter values and X/Y axis coordinate values can be displayed as text on the LCD. This paper adopts a hardware-software co-simulation method, iterating through design → testing → correction → retesting, allowing for testing of the entire system's functionality before manufacturing the control system hardware circuit. Once the system program and hardware circuit design are finalized, the hardware circuit shown in Figure 5 can be actually manufactured. Clearly, this method significantly improves the success rate of system hardware and software development, effectively reducing the system's development cycle and cost. 5 Application Example Figure 5 shows the stepper motor control system circuit board manufactured based on the final result of the hardware circuit simulation in Figure 4. This circuit drives the X/Y axis stepper motor to move the two-dimensional worktable via a ball screw, and a pencil simulates a machining tool to depict the two-dimensional trajectory to be processed. [align=center] Figure 5 Stepper Motor Control System Hardware Circuit Diagram 6 Two-Dimensional Simulation Work Platform Motion Trajectory[/align] 6 Conclusion Based on the analysis of the traditional point-by-point comparison interpolation principle, this paper proposes an interpolation method to determine a circular arc trajectory with the fewest parameters. An effective method for stepper motor frequency conversion speed regulation is realized. The development method of system hardware and software co-simulation makes functional testing before hardware circuit implementation a reality, thereby significantly improving the cost and cycle of system development. This method can also be applied to the development of other types of control systems. References [1] Liao Xiaohuang, Zhu Qiqiu. Digital Control Machine Tools. Wuhan: Huazhong University of Science and Technology Press. 1999.3 [2] Huang Shiyong, Wang Xiaochu et al. Design of a high-performance stepper motor motion control system. Microcomputer Information. 2006 (6-1). pp38-39 [3] Ma Zhongmei et al. C language application design of single-chip microcomputer. Beijing: Beijing University of Aeronautics and Astronautics Press. 2003. Design data download of integrated stepper motor control system