Abstract: Using the graphical programming language LabVIEW, based on the communication protocol of Panasonic FP1 programmable controller, a communication driver for FP1 PLC and LabVIEW was developed, and PLC virtual control objects such as traffic lights at a crossroads and material transport carts were constructed using LabVIEW as a platform to realize the control of virtual objects by PLC. Keywords: LabVIEW; PLC control; virtual objects; serial communication To realize the control of virtual objects by PLC, on the one hand, it can get rid of the limitation of physical models, and on the other hand, it can greatly save the production cost of physical models. Reference [1] developed several simulation models of PLC control objects using Turbo C, but certain programs need to be written to realize them. LabVIEW is a virtual instrument development platform software developed by National Instruments, USA. It is powerful and flexible and widely used in various fields such as automatic measurement systems, industrial process automation, and laboratory simulation [2-4]. Although Reference [5] developed a set of PLC control objects using LabVIEW: virtual carts, the data exchange between PLC and host PC still requires the single-chip microcomputer 8052 as a signal converter. This paper uses LabVIEW to construct virtual control objects such as traffic lights at a crossroads and material transport carts. Based on the Panasonic FP1 PLC communication protocol, a driver program for serial communication between LabVIEW and FP1 PLC was developed, which effectively realizes the control of virtual objects by the PLC, thus freeing it from the limitations of the hardware model. 1 Serial Communication between FP1 PLC and LabVIEW The communication of FP series PLCs is implemented in accordance with the Panasonic Electric Works dedicated communication protocol MEWTOCOL[6]. The computer can read, write and monitor the PLC through the commands in the MEWTOCOL-COM protocol. 1. Multi-point Read Command (RCP) The format of the read sending frame is as follows: 2. Multi-point Write Command (WCP) The format of the write sending frame is as follows: To realize the control of virtual objects by the PLC, the key is to develop a communication driver program between the PLC and LabVIEW based on the FP1 PLC communication protocol. Now, in combination with the virtual traffic light model, the multi-point read command and multi-point write command are used as examples to illustrate. 1.1 Multi-Connection Read Command [align=center] Figure 1 Initialization Serial Port Block Diagram Program [/align] Reading the status values of PLC output relays Y1, Y2, and Y3 can be divided into the following three steps: First, initialize the serial port: Serial port initialization is achieved through the Serial Port Init module. Set the port number to 0, the baud rate to 9600bps, the data bits to 8 bits, the stop bits to 1 bit, and the parity to odd. The block diagram program is shown in Figure 1. Second, send the command parameters of the multi-connection read command to the PLC: Sending the command parameters of the multi-connection read command to the PLC is accomplished through the Serial Port Write module. Its block diagram program is shown in Figure 2. The function on the left side of the block diagram program is to generate the BCC checksum of the input command. The MEWTOCOL-COM protocol uses XOR checksum. The rule for generating the BCC checksum is that the sender performs a bitwise XOR operation on all the ASCII characters to be sent from beginning to end, and sends the result as the BCC checksum. The Number To Hexadecimal String sub-VI converts the input number into a string of a specified number of bytes. The third step is to read PLC feedback information: its block diagram is shown in Figure 3. The Serial Port Read module is used to read PLC feedback information. Before reading data, the Bytes at Serial Port module is used to query the number of data bytes in the current serial port receive buffer and store this value in byte count. If the number of bytes to be read by Serial Port Read is greater than the number of data bytes in the buffer, the Serial Port Read operation will wait until a timeout occurs or the number of data bytes in the buffer reaches the required number. The Subset String function in Figure 3 extracts the characters needed to control the output relay status value of the intersection traffic lights from the string output by the Serial Port Read module. The Scan From String function converts the string extracted by the Subset String function into data of a specified type. To control the intersection traffic lights, they are converted into Boolean data that can control switch variables. 1.2 Multi-contact write command For the control of the emergency vehicle pass signal, an external hard switch can be used, or two switches can be set in a virtual model built with LabVIEW for control. This control method requires changing the emergency vehicle pass signal (X1, X2) in the PLC program to an intermediate relay. When the emergency vehicle switch on the LabVIEW front panel is closed, the state of the emergency switch is written to the PLC intermediate relays R3 and R4, causing the program to enter the emergency operation state. The result is displayed on the LabVIEW front panel. The block diagram of writing data to the intermediate relays is shown in Figure 4. The serial port initialization part is the same as the multi-connector read command. [align=center] Figure 2 Block diagram of sending multi-connector read command to PLC Figure 3 Block diagram of reading PLC feedback information Figure 4 Writing data to PLC intermediate relays[/align] 2 Control implementation of the virtual object of traffic lights at the intersection [align=center] Figure 5 Front panel state when there is an emergency vehicle in the east-west direction[/align] In order for the model built based on LabVIEW to correctly simulate the normal operation of the traffic lights at the intersection, all read and write operations should be edited into sub-VI programs that can be called by the top-level VI. The PLC controls the emergency vehicle forced passage traffic lights at an intersection using the following sub-VIs: Sub-VI 2A1, which reads the output relay status values controlling the east-west red and yellow lights; Sub-VI 2A2, which reads the output relay status values controlling the east-west green lights and the north-south red lights; Sub-VI 2B1, which reads the output relay status values controlling the north-south yellow and green lights; and Sub-VI 34, which writes the emergency vehicle forced passage signal. These sub-VIs are then combined and connected to the traffic lights on the front panel to create a complete intersection traffic light simulation control system. Figure 5 shows the front panel status when there is an emergency vehicle forced passage in the east-west direction. At this time, the emergency vehicle forced passage switch for the east-west direction is closed, and the roof warning lights of vehicles approaching in the east-west direction illuminate. After the call, the east-west traffic lights turn green, allowing the emergency vehicle to pass; the north-south red lights illuminate to facilitate the emergency vehicle's passage. Once the emergency vehicle forced passage signal is OFF, the lights switch to flash green for the oncoming traffic direction three times, and then proceed sequentially downwards. 3. Control Implementation of the Automatic Direction Selection and Positioning System for the Cart The front panel design of the car model includes a running frame, a material handling trolley, and several photoelectric switches for detecting the trolley's position. It utilizes a cluster structure for editing. For the dynamic effects of the trolley's movement, an attribute node method is used. The position attribute nodes are added to or subtracted from by constants or zero to achieve the trolley's movement and stopping. Figure 6 shows a partial block diagram of the car model's program. Sub-VI SE reads the control signals from the PLC, determining whether the trolley is moving left, right, or stopped. When the PLC sends a forward ("2"), reverse ("1"), or stop ("0") signal, the program is redirected to the corresponding position using a Case structure, allowing the position attribute nodes to be added to or subtracted from by constants or zeroed out. Sub-VI R detects the trolley's position using photoelectric switches and transmits the position signal to the PLC's intermediate relay. The PLC program then controls the trolley to achieve positioning. [align=center]Figure 6. Block Diagram of the Car Model[/align] 4. Conclusion This paper constructs virtual control objects for a traffic light at an intersection and a material transport cart using LabVIEW as the platform. Based on LabVIEW serial communication functions, a LabVIEW-PLC communication driver program is developed. Finally, the PLC controls the virtual objects of the traffic light and material transport cart, achieving good control results and demonstrating excellent intuitiveness. It has been applied to PLC experimental teaching. Based on this, more widely applicable virtual industrial control objects can be developed, enabling the virtual design and debugging of PLC-based industrial control systems, providing a technical foundation for the development of virtual prototypes for mechatronics products. The author's innovation: Based on the Panasonic FP1 programmable controller communication protocol, a LabVIEW-based communication driver program for FP1 PLC and LabVIEW was developed, successfully realizing PLC control of LabVIEW-based virtual objects. References [1] Zhao Yukun. Computer simulation of PLC controlled objects. Computer Measurement and Control. 2001, 9 (6): 30-31, 34 [2] Liu Junhua et al. LabVIEW tutorial on graphical programming language for virtual instruments. Xi'an: Xi'an University of Electronic Science and Technology Press. 2001 [3] Wang Minsheng. LabVIEW basic tutorial. Beijing: Electronic Industry Press, 2002: 4-49 [4] Robert H. Bishop. Translated by Qiao Ruiping, Lin Xin et al. Practical tutorial of LabVIEW 6i. Beijing: Electronic Industry Press. 2003 [5] Shan Shiyuan, Zhang Liangzu, Liu Meilan. A system design for controlling virtual objects. Microcomputer Information, 2003, 19 (11): 21-22 [6] Wang Xiaoguang, Sun Xiaoying et al. Principles and applications of programmable controllers, 2nd edition. Beijing: Machinery Industry Press. 2001