Research on parallel communication for controlling stepper motors using LabVIEW
2026-04-06 04:52:06··#1
Abstract: This paper presents a method for controlling stepper motors based on LabVIEW, describes the structure of the control system, and demonstrates the advantages of parallel communication through comparison with other stepper motor control methods. The system has a good software interface, is simple to program, runs efficiently, and has practical application value. Keywords : LabVIEW; stepper motor; parallel communication 1 Introduction In the design of stepper motor control systems, the traditional design method uses logic circuits or microcontrollers to implement stepper motor control. However, due to the complexity of the circuit and the difficulty in adjusting it after manufacturing, there are certain limitations. Later, virtual instrument graphical programming software was used to control stepper motors, which greatly simplified the hardware structure, made software programming simple, and provided a good human-computer interaction interface. The control mode can be adjusted at any time according to different requirements. Compared with the current common method of controlling stepper motors in China, which uses motion acquisition cards, the method of using a computer parallel port as the communication medium between the computer and the stepper motor driver to transmit pulse signals is not only inexpensive but also easier to promote. 2. System Control Research Scheme 2.1 Overall Electrical Control Structure Diagram of the System The stepper motor is the power mechanism for the entire system. The drive control system consists of two main parts: the stepper motor drive part (hardware drive) and the software drive part (software system). These two parts are connected by a computer parallel port. Parallel communication completes the connection between software and hardware in the entire system, mainly used for data transmission, control, and data acquisition. The control system structure diagram is shown in the figure. The entire hardware control system is composed of several interconnected single-function modules. Modularizing the system allows us to understand the functions performed by each module in the entire system. The application software installed on the computer controls the motor, converting the corresponding coordinate quantities obtained through algorithms into motor rotation. The stepper motor driver converts and amplifies the pulse signals transmitted from the parallel port, then sends them to the stepper motor to ultimately control it. 2.2 Technical Scheme The stepper motor driver used in this design employs a classic integrated circuit combination circuit, driving a bipolar two-phase permanent magnet stepper motor and a two-phase/four-phase combined stepper motor. The main controller uses machine control, and the software is developed using a programming language. Signal communication is achieved via a parallel port. The technical parameters of the ten-stepper motor driver are: power supply drive voltage is one, pre-input is the output current peak value, phase activation mode is constant phase current, and excitation mode is full-step and half-step microstepping. 3. Introduction to Parallel Port Module Programming This section introduces a virtual instrument development platform from the United States. It uses icons instead of text code to create applications and possesses the characteristics of a flowchart programming language. The execution order is determined by the flow of data between blocks, unlike general programming languages which execute line by line. When writing block diagram programs, users only need to select different function icons from the functional modules and then connect them with lines to achieve data transmission. Compared to general programs, it provides three floating graphical tool templates: a tool template, a control template, and a function template. These three templates are powerful, easy to use, and intuitive, serving as the main tools for user programming. 3.2 Introduction to Parallel Interface In the entire system, the design of the parallel port programming module is a crucial link connecting the electrical control section and the mechanical system. There are three main types of parallel interfaces: standard parallel interfaces, enhanced parallel interfaces, and extended parallel ports. A typical computer is equipped with one to three parallel ports, which connect to other devices via pin sockets. This interface contains an output latch input buffer. These occupy three ports. The first address is [address], which is the data port. The second address is [address], which is the status input port. The third address is [address], which is the control signal output port. Usually, to make the program more versatile, this address can be obtained from the registry. For [specific program], this value is stored in [registration]. Then, simple parallel port programming can be achieved by controlling these three ports. The entire parallel port has one usable signal line, and the other lead is the ground wire. 3.3 Parallel Port Cable Design, Connection Method, and Modification For the movement of a stepper motor control system, as long as two signals can be sent to the driver, the requirements are met: one is a control pulse square wave signal, and the other is a forward/reverse control direction level signal. However, the interface of the stepper motor driver box is not designed and connected according to the parallel port standard, while the computer's parallel port pin configuration is allocated according to the parallel port standard. Therefore, to match the circuitry of the stepper motor driver, the wiring inside the parallel port cable must be redesigned to ensure stable and efficient transmission of signals from the stepper motor driver. The parallel port cable has a total of 10 wires, but only 10 are needed to control the stepper motor. These include three pulse signal control lines, three direction signal control lines, three limit switch signal receiving lines, and one ground wire. The remaining 10 wires are either unconnected or left floating at one end to prevent interference that could affect the normal data transmission and reception of other data lines. The computer's parallel port wiring does not need to be modified; only the interface cable of the motor driver box needs to be changed. Through analysis of the program and the definitions and characteristics of the parallel port pins, pins 2, 3, 4, 5, 6, 15, 17, 18, and 19 of the stepper motor driver box's parallel port are connected to pins 10, 11, 4, 5, 6, 12, 7, 8, and 9 of the stepper motor driver's parallel port, respectively. Additionally, pin 1 of the stepper motor driver box's parallel port is connected to any pin 1 of the stepper motor driver's parallel port. In the stepper motor driver box, pins 4, 5, 6 and 7, 8, 9 of the parallel port correspond to the X, Y, and Z pulse signal control lines and forward/reverse control lines for the motor, respectively. Pins 2, 3, and 15 correspond to the limit switch control lines, and pin 14 is connected to the system ground. 3.4 Parallel Port Programming Methods and Data Transmission: The application of LabVIEW as the front-end interface and data processing tool greatly simplifies the software development of the host computer and facilitates the calling of various data processing programs, providing a better human-computer interaction interface. In LabVIEW, there is no function for reverse transmission of the parallel port; only traditional forward transmission is possible, so direct calling is not possible. However, there are sub-programs for direct register reading and writing, allowing direct register read and write operations to change the value of the parallel port and thus output corresponding signals. This greatly ensures the accurate transmission of pulse signals and the effective reception of limit switch signals. The diagram illustrates the parallel port programming and data transmission methods. The computer program controls the output value of the parallel port line by changing the value of the parallel port register. The register has 32 bits, each corresponding to one of two values: 0 or 1. Through continuous exploration and experimentation, it was finally determined that bits 26, 27, 28, 29, 30, and 31 of the register correspond to the 4th, 5th, 6th, 7th, 8th, and 9th ports of the parallel port, respectively. Therefore, by writing a program to input pulse signals into the corresponding registers of the parallel port, the required pulse can be output to the corresponding bit of the parallel port. The acquisition of the travel signal is achieved through this sub-program. 4. System Control Program Implementation This paper adopts a modular programming approach to design the system's control program. The designed system is connected to a plotter for drawing experiments to verify the rationality of the design. 4.1 Overall Program Flowchart of the Drawing System Before starting drawing, the tool needs to be reset to the initial origin for accurate positioning during drawing. Therefore, the motor is first rotated to move the drawing pen closer to the origin. After the travel switch is triggered, a pulse is input to the motor, and then the motor is stopped. At this point, the tool is in the starting position. Next, input pulses are used to rotate the motor to the initial drawing position, bringing the tool close to or in contact with the object being drawn. Once the initial position is reached, the motor is started to begin drawing. After drawing is complete, the motor stops rotating and then returns to the tool's initial position. Figure 4 shows the overall system program flowchart. 4.2 Drawing from the Acquired Graphical Data Array LabVIEW, as a graphical editing software, can continuously acquire external signals and generate various regular signals. Therefore, the acquired analog signals digitized or the data of the generated signals can be used as the pulse program control source. By controlling the timing, the signal waveform can be drawn by rotating the stepper motor. In the programming, a sine wave is used as the input signal. First, a sine wave data array is generated by a sine wave generator and then sent to the waveform display for display. Simultaneously, a pulse control signal is branched off from the data array line and input into the timing loop as the pulse control signal line. Within the timed loop, the sinusoidal signal is sampled using a method with equal time intervals. The sampled values are then stored in an array, and the array data is realigned. This data is then converted into corresponding pulse counts for the axle and yle motor drivers, controlling the speed and direction of the axle and yle motors. Finally, the sinusoidal signal is plotted on a drawing platform using the corresponding movement of the stepper motors. Once the sinusoidal waveform can be plotted, other waveforms can be similarly input into the loop and plotted according to the program settings. Figure 5 shows the program control diagram for plotting the sinusoidal graph. 5. Summary The system software was developed using virtual instrument development software from an American company. A corresponding trajectory control program was written, and a simple and easy-to-control control panel was designed. Furthermore, based on the characteristics of parallel communication, the parallel port was used as the communication medium between the connector and the stepper motor driver to transmit pulse signals. This overcomes the problems of voltage mismatch between the parallel port and the stepper motor driver's pulse drive voltage, as well as the matching of the parallel port signal transmission rate with the pulse response rate. During the debugging process, the problem of unstable signal frequency emitted by the stepper motor was successfully solved by controlling it through a timed loop method, and the optimal pulse control frequency range for driving the stepper motor was found. Finally, the stepper motor was controlled and displayed using LabVIEW graphical programming software.