Linear Motor Motion Control Experiment System Design Based on LabVIEW

In order to meet the needs of experimental training of electrical information industry, a linear motor motion experiment system based on LabVIEW was developed. This system is based on the STM32F103ZET6 system processor controller, a state signal when the motor moves through the grating encoder feedback controller to form a closed loop, through the RS232 serial port communication with the host computer, the host computer is designed in the LabVIEW interactive environment monitoring software. Combined with the modular design concept proposed overall program, given the detailed hardware circuit, targeted for the software function design, to achieve manmachine interface. The system control of high accuracy, good stability, meet the training requirements for laboratory equipment, but also as a reference embodiment of the linear motor monitoring system.


Introduction
With the rapid development of intelligent manufacturing technology, the manufacturing industry has put forward higher requirements for the control accuracy, which makes the linear motor widely researched and developed [1].There are many advantages like simple structure, low noise, fast speed, high accuracy to use linear motor as driving device.It greatly improve the level of manufacturing [2].Recently many electrical and information majors in related universities have set up experimental training courses for industrial movement control in order to better train students' ability and carry out the training policy of applied talents.These courses are different in contents and forms among colleges.But traditional linear control system of rotating motor drive is used in common experimental devices, which can not meet the requirements for talent training in existing industrial enterprises [11].The virtual instrument used as experimental development equipment, has powerful function, easy debugging and many advantages like this [3][4].Therefore, this paper takes Labview as development platform and proposes an experimental equipment system for monitoring and debugging the linear motor.

System overall design
The block diagram of linear motor monitoring system is shown in Figure 1.This controller uses linear actuator to control linear motor driving and dragging load.State signal while motor running obtained by linear actuator detection, feeds back to the controller after grating encoder processing and forms a closed loop system [12].The controller controls the linear motor moving to the specified position according to the deviation value produced by the target value and the feedback value.The controller communicates with the host computer by RS232 serial port mode.The controller receives the target value sent by the host computer, and then adjusts the movement mode of the linear motor according to the instruction, in order to make the motor move to the new position.The controller can also send the motor state signal obtained by the feedback circuit to the host computer.3 System hardware design The system uses STM32F103ZET6 (hereinafter referred to as STM32) as the main controller, which mainly includes power module, control module, detection and as shown in Figure 2.

Power module
The 220V voltage after step-down transform, rectification and filtration, then through the voltage regulator LM2576 will be output to 24V voltage, then use SPX29300 rise 3.3V to 5V power supply to various parts of the system.

Control module
In STM32, PWM generated from CH1 channel of timer TIME3 is taken as PUL.PWM generated from CH2 channel of timer TIME3 is taken as DIR.The PUL pulse and the DIR pulse are converted into differential control signals through the operational amplifier OPA2662, and output to the linear motor driver.The driver controls the motion of the linear motor according to the number of pulses.

Detection and feedback module
The encoder of the linear driver can automatically detect the motion state of the motor and produce EA+ and EA-, EB+ and EB-, EZ+ and EZ-differential state signals [14].
After the grating encoder MC3486, those state signals will be converted into two orthogonal coded pulse signals EA, EB and one reference point pulse signal EZ and feed back to STM32 [7].STM32 uses a timer TIME4 encoder mode to determine and count the direction of the feedback pulse signal.After the converter, the SN74LVC4245 converts the 5V pulse to 3.3V so that the STM32 is easy to collect samples [8].

Serial communication module
The communication module adopts serial port RS232 mode which can realize communication within the distance of 20 meters and can adapt to the teaching conditions in most environments.The transform of communication power level between the host computer and the lower computer is realized by MAX232.
4 System software design

Communication protocol
In order to ensure the normal communication between the host computer and the lower computer, communication protocol is defined.The communication protocol mainly includes communication start, communication enable, communication enable close, positive direction, negative position and other functions.Each function is defined by the corresponding command format [9].For example, when the system receives the "communication start" command, open communication channel to send and receive data.When the system needs to be shut down, then send "communication close" command to close and set memory free, so that the second time to update data.The specific agreement as shown in Table

Design of main program
The main program flow chart of the system is shown in Figure 3. the system first completes the clock, serial port, timer initialization, then automatically starts the detection.Then it will send the detected speed and location information to the host computer every 0.5 second.The system will start the control program when receiving the start command from the host computer [10].
In the control program, the controller processes the feedback data, then generates a control pulse signal according to the target value and the feedback value, and then transmits the signal to the driver.The number of pulses transmitted by the controller determines the moving distance of the overload in the linear motor.That is to say, the moving distance is equal to the width of a single pulse multiplied by the number of pulses.The movement direction is controlled by a I/O port.The high power level is at positive direction, and the low power level is at the negative direction.
In the detection program, the STM32 universal timer TIM4 encoder mode is set.The main idea is to judge whether the EA phase is in advance of the EB phase.If advanced, the output pulse will increase.If not, then reduce.If the EZ phase comes a pulse, it will count to zero [8].

Host computer monitor program
The program mainly adopts event structure to write.The host computer receives the data according to the receiving protocol "communication input z exp_position p speed v position s dir d /n".Then it will separate character string z, p, v, s and d by using 6 regular expressions.And then display data represented by these strings into the interactive interface.At the same time, a data function is needed to create and a shift register is needed to add to store last time date.If <Motor enable> is "ENABLE", then the host computer will send command "communication enable 1" to the lower computer.If <Motor enable> is "DISABLE", then the host computer will send command "communication enable 0" to the lower computer.If the moving direction is positive, then the host computer will send "communication direction 0" to the lower computer.If the moving direction is negative, then the host computer will send "communication direction 1" to the lower computer [15].Once the "communication start" value is set, the data type of distance on the interactive interface is default.The value of the form of digital conversion into a decimal string, and put the string to connect, then the host computer will send " communication distance x " to the lower computer.Once the "origin motion" value is set, the host computer will send "communication back move" to the lower computer [13].Once the "I/O port" is set and the "Actual level" is high level, the Enable will keep steady; While the "Actual level" is low level, then first untie all the I/O port value and reverse and then tie up.If the data type of new value of event branch is hexadecimal, it will send command "communication output y" to the lower computer.If "Stop" value is set, it will send command "communication close" to the lower computer.It will delay 50ms through a tiled sequential structure and turn off the VISA resource name, and then the lower computer will close the communication protocol.

Interactive interface design of the host computer
The "motion control interface" is designed on the LabVIEW platform, as shown in Figure 5.It uses VISA to write serial drive.VISA is a multi type function library, which supports multi platform work and multi interface control.When the external device changes, you only need to replace several program modules [10].In LabVIEW, the basic steps of serial communication are divided into 3 steps: First, serial initialization, it uses VI SA Configure Serial Port.vi nodes to set the serial port number, baud rate, stop bits, parity bits, data bits.Second, read and write serial port.It uses VISA Read node and VISA Write node to read and write the serial port.Third, close the serial port, which is to close all the read or write operations.

System test analysis
Each control function is tested one by one through the interaction interface, and the state value of the motor, such as the current speed, current position, current direction, can be monitored in real time, as shown in Figure 6.The lower computer can responds in time and correctly, as shown in Figure 6.When the position is set at the minimum interval, the moving distance of the load is 26 μ m, which meets the requirements of the experimental expect accuracy.

6
The system composed of the host computer, controller, linear drive and linear motor realizes the monitoring of linear motor movement.The closed-loop control circuit ensures the stability of the system.The host computer and controller communicates in accordance with the protocol through RS232 serial port.The host computer monitoring program is designed under the LabVIEW environment and the interactive property is good.According to the test result show in table 2 and figure 6, the accuracy of control and monitoring is higher.The function of the system has reached the expected design requirements, and the cost is low.It can be used as a practical teaching equipment, and it also provides a reference for the linear motor monitoring system program.

Figure 1 .
Figure 1.The block diagram of linear motor monitoring system.

Figure 4 .
Figure 4. I/O port control program.

Figure 6 .
Figure 6.The relation between error and distance.