Microcontroller interface based on L297/298 stepper motor operating mode
2026-04-06 04:51:27··#1
Abstract: As a driver for hybrid stepper motors, the combination based on the L297/298 driver chip is quite common. This paper discusses in detail the three working modes of hybrid stepper motors based on this type of driver, and gives the corresponding microcontroller interface scheme, which includes the hardware circuit and software programming of the interface. Keywords: Stepper motor; L297/298; Microcontroller 0 Introduction A stepper motor is an actuator that converts electrical pulses into angular displacement. When a stepper motor driver receives a pulse signal, it drives the stepper motor to rotate a fixed angle (i.e., step angle) in a set direction. By controlling the number of pulses, the amount of angular displacement is controlled, thereby achieving accurate positioning; by controlling the pulse frequency, the speed and acceleration of the motor rotation are controlled, thereby achieving speed regulation. Stepper motors are divided into three types: permanent magnet (PM), reactive (VR), and hybrid (HB). Permanent magnet stepper motors are generally two-phase, with small torque and size, and a step angle of 7.5 degrees or 15 degrees; reactive stepper motors are generally three-phase, which can achieve large torque output, and a step angle of 1.5 degrees, but with large noise and vibration; hybrid stepper motors combine the advantages of permanent magnet and reactive types. They are divided into two-phase and five-phase types. The step angle of a two-phase hybrid stepper motor is generally 1.8 degrees, while that of a five-phase hybrid stepper motor is generally 0.72 degrees. Among them, hybrid stepper motors are the most widely used [1]. [align=center] Figure 1: L297/298 driver[/align] The two-phase bipolar hybrid stepper motor driver based on the L297/298 driver chip (see Figure 1) is driven by constant current chopper, and the current per phase can reach 2A. Among them, L297 is a stepper motor controller, which is suitable for the control of bipolar two-phase stepper motors or unipolar four-phase stepper motors. The L297 output signal can control the L298 dual-bridge driver integrated circuit, which is used to drive stepper motors with a maximum voltage of 46V and a total current of less than 4A. The L297 can also be used to control discrete circuits composed of Darlington transistors to drive stepper motors with higher voltage and larger current. The L297 only requires clock, direction and mode input signals, and the phase is generated internally, thereby reducing the burden of microprocessor and program design. The L297 works in a fixed chopping frequency PWM constant current chopping mode. The L297 is mainly composed of a decoder, two fixed chopping frequency PWM constant current choppers and output control logic [2]. The L298 is an integrated circuit used to drive stepper motors. It is driven in a dual full-bridge mode. Since it is a bipolar drive, the stator excitation winding coil of the stepper motor can be fully utilized, so that the stepper motor can achieve the best drive [3]. 1. Principle The hybrid stepper motor based on the L297/298 driver has three different operating modes: half-step mode (see Figure 2), full-step one-phase excitation mode (see Figure 3), and full-step two-phase excitation mode (see Figure 4). When the stepper motor operates in half-step mode, the excitation of its internal stator windings alternates between one and two phases. In this mode, the stepper motor rotates only half a step angle for each pulse received. The torque obtained by the stepper motor in half-step mode is smaller than the normal value. When the stepper motor operates in full-step one-phase excitation mode, the excitation of its internal stator windings is always one phase. In this mode, the stepper motor rotates one step angle for each pulse received. The stepper motor obtains the normal torque when operating in full-step one-phase excitation mode. When the stepper motor operates in full-step two-phase excitation mode, the excitation of its internal stator winding is two-phase at any given time. At this time, the stepper motor rotates one step angle for each pulse received. When the stepper motor operates in full-step two-phase excitation mode, the torque obtained by the stepper motor is the largest compared to the previous two [4]. The core of L297 is its internal decoder, which generates three phase sequence signals to correspond to three different operating modes. The decoder is controlled by the direction input pin signal and the half-step mode/full-step mode input pin signal of L297. The decoder is a 3-bit counter, plus some combinational logic, to generate a Gray code timing signal of 8 steps per cycle (see Figure 5), which is the timing signal of half-step mode. At this time, the input pin signal of L297 is high. If the pin is low, the full-step operating mode is obtained. If the pin is low when the eight-step Gray code timing signal of the decoder is in an odd-numbered state, a full-step two-phase excitation mode is obtained; if the pin is low when the eight-step Gray code timing signal of the decoder is in an even-numbered state, a full-step one-phase excitation mode is obtained. 2. Scheme The microcontroller interface hardware circuit for the hybrid stepper motor operating mode based on the L297/298 driver is shown in Figure 6. In Figure 6, the clock signal input pin of the L297 is connected to pin P1.3 of the 89C51 microcontroller, pin P1.6 is connected to pin P1.7, and pin P1.8 is connected to pin P1.9. The software programming [5] that works in conjunction with the hardware circuit of this interface is as follows: (The assembly language source code is given only for the full-step one-phase excitation mode) [align=center] Figure 6: Microcontroller interface hardware circuit [/align] … MOV TMOD,#11H MOV TH1,#0D8H ; Timer 1 initialization, interrupt once every 10ms MOV TL1,#0F0H CLR P1.7 ; L297 internal counter reset, the initial count value is 0101 NOP NOP SETB P1.7 SETB P1.3 ; High level of the first clock SETB P1.6 ; Set the current working mode to half-step mode SETB TR1 LCALL TT ; Low level of the first clock LCALL TT ; High level of the second clock, i.e., the even-numbered state bit of the timing signal NOP NOP CLR P1.6 ; Set the pin to low level, the current working mode is full-step one-phase excitation mode LCALL TT ; Low level of the second clock … TT: JNB TF1,TT CLR TF1 CLR TR1 MOV TH1,#0D8H MOV TL1,#0F0H CPL P1.3 SETB TR1 RET … … 3 Conclusion This interface scheme is designed and studied for the stepper motor suspension system for small heavy objects. The interface circuit is simple, and the working mode of the hybrid stepper motor can be easily switched by software programming. Especially for applications where the stepper motor torque requirement is not high, the heat generation of the stepper motor can be controlled by changing the working mode of the stepper motor [6]. The innovation of this paper lies in the in-depth study of a potential advantage of the commonly used stepper motor driver chip combination based on L297/298 that has not been fully recognized in practical applications, namely the three working modes of L297, and the corresponding microcontroller interface is given, so as to better give play to the application potential of this driver chip combination in hybrid stepper motor driving and improve the flexibility of the driver combination in different working situations. References: [1] Liu Baoting. Stepper Motor and its Drive Control System [M]. Harbin Institute of Technology Press, 1997 [2] L297 STEPPER MOTOR CONTROLLERS [Z]. STMicroelectronics, 2001 [3] L298 DUAL FULL-BRIDGE DRIVE [Z]. STMicroelectronics, 2000 [4] AN470 APPLICATION NOTE OF THE L297 STEPPER MOTOR CONTROLLER [Z]. STMicroelectronics, 2003 [5] Xu Huimin, An Dening. Principles, Interfaces and Applications of Single-Chip Microcomputers (Second Edition) [M]. Beijing University of Posts and Telecommunications Press, 2000 [6] Yang Zhongbao, Lin Haibo. Implementation of Stepper Motor Chopper Constant Current Uniform Subdivision Circuit Based on 80C196MC [J]. Microcomputer Information, 2003, 7: 27-32