1 System Design Principles
The stepper motor control system mainly consists of four modules: a microcontroller, a keyboard/LED, a driver/amplifier, and a PC host computer. The PC module is the software control part. To protect the hardware circuitry of the microcontroller control system, an overcurrent protection circuit is added between the microcontroller and the stepper motor. Figure 1 shows the block diagram of the stepper motor control system.
2 System Hardware Circuit Design
2.1 Microcontroller Module
The microcontroller module mainly consists of an MSP430FG4618 microcontroller and peripheral circuits such as filtering, power management, and crystal oscillator.
The MSP430FG4618 microcontroller has 8KB of RAM and 116KB of Flash memory to meet the storage requirements of the control system. During the operation of the stepper motor, the P1 and P2 ports determine whether to jump to the interrupt service routine based on the button status to change the working state of the stepper motor. The USART module realizes the communication between the microcontroller and the PC host computer, enabling the PC to control the stepper motor.
2.2 Keyboard/LED Module
To enable human-computer interaction, the system is designed with an expanded 3x4 button matrix keyboard and four 8-segment LED digital tubes, allowing for direct manual operation of the control system.
After the system is powered on, the start/stop, step count, speed, and direction of the stepper motor are input via the keyboard, and the speed and direction of the stepper motor are dynamically displayed by LEDs. The keyboard input and LED output are controlled by an 8279, reducing the workload of the microcontroller.
The 8279 is programmed to operate in keyboard scanning input mode and features debouncing when reading keyboard input to prevent accidental triggering. Figure 3 shows the block diagram of the keyboard LED module design.
2.3 Driver/Amplification Module
The control system uses the PMM8713 pulse distributor (also known as a logic converter) for stepper motor control. This device is a CMOS integrated circuit with a phase output drive capability (source current or power input) of 20mA. It is suitable for controlling three-phase or four-phase stepper motors and can select the following six excitation methods: three-phase stepper motors: 1 phase, 2 phases, 1-2 phases; four-phase stepper motors: 1 phase, 2 phases, 1-2 phases. The input method can be selected as single clock (with direction signal) or dual clock (forward or reverse clock). It has functions such as forward/reverse control, initialization reset, origin monitoring, excitation method monitoring, and input pulse monitoring.
3 System Software Design
3.1 Microcontroller Program
The microcontroller uses the TIMER_A (TA) interrupt of the microcontroller to generate pulse signals. The corresponding interrupt routine accurately counts the steps and revolutions of the stepper motor, and speed control is achieved through PWM. The TA interrupt routine is disabled using the P1.0 port interrupt and pushed onto the stack, stopping the motor. The P1.1 interrupt enables the TA interrupt, pushes the program counter (PC) onto the stack, and starts the motor. A high-level output from the P3.1 port controls the motor's direction of rotation via the PMM8713's U/D port. Ports P3.0 to P3.7 connect to the eight data interfaces of the 8279. When the microcontroller detects a key press on the matrix keypad, the TA is set using the P2 port interrupt, controlling start/stop, speed adjustment, and direction. Simultaneously, the microcontroller feeds back to the 8279 to control the LED display of speed and direction. The program flow is shown in Figure 5.
3.2 PC Host Computer Module
The PC host computer module enables PC control of the stepper motor. Communication between the MSP430 microcontroller and the PC is achieved using the MSP430 microcontroller's USART module. The PC sends control commands to the microcontroller via serial port to control the motor.
The control commands received by the microcontroller are temporarily stored in the RXBUFFER, and then compared with the entry address of the interrupt routine stored in the on-chip Flash. If they match, an interrupt is triggered, thus controlling the stepper motor. Operating this module requires enabling an 8MHz crystal oscillator and setting the baud rate for the USART module (the baud rate is set to 9600).
The control software was written in VB6.0 and uses the MSComm control to implement serial communication functionality. Its interface is shown in Figure 6.
4 System Testing
To verify the actual operation of the control system, the maximum static torque of the stepper motor was measured using the energy conversion method under a given PMM2101 output operating current. With an output current interval of 0.2A selected, the static characteristic curve showing the relationship between the maximum static torque of the stepper motor and the current was measured, as shown in Figure 7. This indicates that the control system design is reasonable.