Abstract: This paper constructs a stepper motor turntable control system using an AT89C51 microcontroller, a keyboard, an LED-specific intelligent control chip HD7279A, a stepper motor ring distributor L297, and a stepper motor driver L298N. The system enables the microcontroller to recognize and output the keyboard input data (rotation angle) and generate continuous pulses to control the stepper motor's rotation, thereby driving the turntable. Keywords: Microcontroller, Stepper motor driver I. Introduction In studying the temperature characteristics of a thermal convection accelerometer, the sensor system needs to be placed on a turntable that can rotate 360 degrees longitudinally. The turntable is then placed in a constant temperature test chamber. The change in gravitational acceleration sensed by the sensor's sensitive surface when the turntable rotates is used to detect the change in sensor sensitivity. To ensure reliable measurement data, the control system uses a stepper motor as the drive. By controlling the number of rotation steps (angles), the turntable rotates through a certain angle. Once the sensor's output data stabilizes, the relevant data can be recorded. To achieve this function, a stepper motor turntable controlled by a microcontroller was developed. II. System Overall Design The operation of a stepper motor requires an excitation signal from the stepper motor coil, and a power amplifier to generate a drive current based on this signal. A ring distributor and power driver specifically designed for stepper motors can achieve this function. Control information, including the motor's direction and angle, is input via a keyboard. The microcontroller receives this information and generates corresponding control signals, which are then transmitted to the motor controller. Simultaneously, the microcontroller also controls a multi-digit LED display to show the information input from the keyboard and the actual rotation status. Based on actual needs, human-computer interaction is achieved through a 4×4 matrix keypad and a pair of 4-cell LED digital tubes; key input and LED display are controlled by the HD7279A control chip; the microcontroller selected is the AT89C51 Flash microcontroller; since the measurement range does not require very fine division of tilt angle changes, a low-cost two-phase stepper motor 42BYG121 is selected, with a step angle of 1.8 degrees, which can be subdivided to 0.9 degrees through half-step drive; the ring distributor and motor driver are L297 and L298N chips, respectively. The L297 converts the continuous pulses given by the microcontroller into the phase winding pulse sequence required by the stepper motor; then the L298N amplifies the phase pulse signal to drive the stepper motor to rotate. The final overall system scheme is shown in Figure 1. Figure 1 shows the control system structure block diagram. The system's operation is as follows: The system uses a keyboard to input values. The HD7279A chip transmits the input key values to the microcontroller. The microcontroller identifies whether the key value represents data or a function key. It either transmits data to drive the LED digital tube display via the HD7279A, or determines the stepper motor's rotation angle based on the input value, outputting a specific pulse signal. This pulse signal is then converted into phase pulses for each phase of the stepper motor by the L297 chip, amplified by the L298N chip, and drives the stepper motor, which in turn drives the mechanical parts to rotate. III. Main Interfaces and Programming Implementation The data input and display interface chip uses the HD7279A, an intelligent display driver chip with a serial interface that can simultaneously drive 8-bit common-cathode LED digital tubes. This chip can also connect to a keyboard matrix of up to 64 keys, allowing a single chip to complete all functions of LED display and keyboard interface. The HD7279A includes a built-in decoder that can directly accept BCD or hexadecimal codes, offering both decoding modes. It also provides various control instructions, such as blanking, blinking, left shift, right shift, and segment addressing. The HD7279A's control instructions are divided into two categories: pure instructions and instructions with data. Pure instructions include six commands such as test, shift display, and reset, with corresponding control codes from 0xBF to 0xA4. Instructions with data include display data, blanking control, and key code reading; the instruction format is control word + data. The following is a C51 programming routine for sending a single byte of instruction or data to an HD7279A: `void send_byte( unsigned char out_byte) { unsigned char i; cs=0; long_delay(); for (i=0;i<8;i++) { if (out_byte&0x80) dat=1; else dat=0; clk=1; short_delay(); clk=0; short_delay(); out_byte=out_byte*2; } dat=0; }` Sending instructions with data can be implemented using the following routine: `void write7279(unsigned char cmd, unsigned char dta) { send_byte(cmd); send_byte(dta); }` The following is a routine for reading data from an HD7279A: `unsigned char read7279(unsigned char...` The command is defined as follows: `#define CMD_RESET 0xa4 #define DECODE0 0x80 #define DECODE1 0xc8 #define CMD_READ 0x15 #define UNDECODE 0x90 #define BLINKCTL 0x88 ...` To control the LED connected to the HD7279A, the following code snippets can be used: `send_byte(CMD_RESET); // Reset HD7279A write7279(BLINKCTL,0xf8); // Set bits 1, 2, and 3 to blink write7279(UNDECODE,0X08); // Display an underscore in bit 1 write7279(DECODE0,value); // Decode and display numbers in 0 mode write7279(DECODE1,value);` The core of the L297 digital ring distributor, decoded and displayed in mode 1, is a pulse distributor that can generate three phase sequence signals, corresponding to three different operating modes: half-step mode, single-phase excitation mode, and two-phase excitation mode. It receives the following signals from the controller: CW/CCW forward/reverse (pin 17), HALF/FULL half-step/basic step (pin 19), and STEP step pulse (pin 18). To achieve optimal performance with the existing hardware, the stepper motor operates in half-step mode. The timing sequence of the L297 in this mode is shown in Figure 2. The system uses the L298N power amplifier, an H-type bipolar driver, with diodes D1-D4 forming a bridge freewheeling circuit. Using this H-bridge power amplifier, each phase winding must use one H-bridge. The L298N is a dual H-bridge high-voltage, high-current power integrated circuit that can drive inductive loads such as relays, coils, DC motors, and stepper motors. The L297 stepper motor controller and the L298N dual H-bridge driver form a typical integrated stepper motor microcontroller. Its connection circuit is shown in Figure 3. Eight diodes, D1 to D8, are connected to the L298N chip and the stepper motor, forming the freewheeling circuit of the H-bridge. IV. System Control Implementation Figure 4. To facilitate control and programming, the button response uses an interrupt mode. When a button is pressed, the HD7279 sends a low-level signal to trigger an interrupt. The interrupt handler handles the button response, providing corresponding display and control. The program flowchart is shown on the right. The stepper motor turntable controller implemented according to the above scheme can easily input the rotation angle and direction, and accurately indicate the rotation angle and direction while rotating, achieving good results.