PLC Communication Technology Design in Virtual Elevator System
2026-04-06 07:50:48··#1
Abstract: This paper introduces the concept and function of virtual elevators and their communication technology. An extensible protocol format for communication is designed, and the communication process of the virtual elevator system is analyzed. A communication program is developed using VB language and Siemens S7-200 PLC ladder diagrams, realizing real-time communication between the computer and the PLC. This program has been successfully applied to a virtual elevator system with multiple elevators. Keywords: Virtual elevator; PLC; Communication protocol; VB 0. Introduction With the development of computer technology, people are increasingly using computer software to simulate actual physical models. A "virtual model" is a model studied and utilized based on computer technology and supported by digital interface technology. A virtual elevator system refers to a computer and PLC controlling a virtual elevator that is actually running. The computer displays the elevator car and shaft through animation and simulates the elevator's operation, while simultaneously transmitting signals to the PLC controller. The PLC controller runs the elevator control program and transmits the control results back to the computer through the communication program. The virtual elevator on the computer operates the elevator and receives signal indications according to the control signals, thus simulating the elevator's operation process and various operating and fault states of the actual elevator. Compared with traditional physical elevator models, virtual elevators have the following advantages: (1) Low cost, easy to use, and convenient for designing and developing elevator control functions. (2) Virtual elevators can be used as training software for elevator operators to familiarize themselves with the normal operation rules of elevators and the functions of various control signals. Virtual elevators are flexible in setting up, and the number of floors, elevator speed, and number of elevators can all be changed, while the actual physical model is immutable. (3) Virtual elevators can be used as the control object of PLC controllers to debug and improve the PLC control program and functions of the actual elevator control system. Therefore, virtual elevator technology provides a good application prospect for the development of elevator control systems and the training of elevator operators. 1. Structure and Principle of Virtual Elevator System The virtual elevator control system consists of three parts: PLC elevator control program, system communication program, and virtual elevator simulation interface. As shown in Figure 1. The virtual elevator simulation interface is shown in Figure 2. This is a group control of two elevators. The screen is symmetrically divided into two elevator systems, left and right. Taking the left elevator as an example, the left side simulates the car and parallel rail of the virtual elevator, the right side shows the car door and internal and external call signals as well as the floor display signal, and the upper part shows the elevator's operating status. The number of elevators, the number of floors, and the elevator operation mode (automatic, driver-operated, fire-fighting, and maintenance modes) can be configured through the menu settings. [align=center] Figure 1: The structure of the virtual elevator system. Figure 2: The interface of the virtual elevator.[/align] The system hardware mainly consists of a computer, a Siemens S7-200 PLC, and communication cables. The system's operation process is as follows: By setting the operating status and clicking buttons on the simulation interface, the computer sends virtual elevator signals to the PLC through the communication program. The PLC, based on the received information, runs the elevator control program and sends the control signals of the control program back to the computer. The computer, through a corresponding interpreter, displays the operating status on the simulation interface and controls the actions of the virtual elevator animation module, thereby achieving the purpose of virtual elevator control. The software in the computer uses VB programming, and the communication method is serial communication. 2. Communication Protocol Format Design The communication program between the computer and the PLC organically connects the computer virtual elevator model and the elevator controller PLC in the entire system. The communication protocol is a defined communication format that enables the computer and PLC to recognize the communication data between them. In this system, data transmission between the S7-200 and the computer is performed in units of "frames". This system uses fixed-length communication frames, each with the following format: Definitions: 1) The start character marks the beginning of the communication frame and is defined as "@" in ASCII code in this system. 2) The end character marks the end of the communication frame and is defined as "#" in ASCII code in this system. 3) The checksum is the XOR sum of all data in the text, represented by two bytes of hexadecimal ASCII code. To avoid communication conflicts, a master-slave mode is used when the computer communicates with the PLC, with the computer as the master and the PLC as the slave. Only the master has the right to actively send request messages (or request frames). The slave receives the request, verifies it, and if the verification is correct, returns a response message. 4) The command type in the communication frame reflects the data type of the communication between the master and slave. The command type is represented by a two-character format: CT represents the control word, ST represents the status word, and RS represents the response word. The communication data frame format for different command types is defined as follows: (1) The status word is the data transmitted from the computer to the PLC, indicating the status of the virtual elevator and the call command. The communication frame data format is as follows: The main data includes: elevator operating status (up, down, stopped), safety signals (yes, no), elevator door opening/closing, elevator internal and external call signals, leveling signals, etc., represented by decimal numbers in the following defined order: Operating mode is defined as 1 bit: automatic is 0, driver is 1, maintenance is 2, fire protection is 3; Operating status is defined as 1 bit: elevator up is 2, down is 1, stopped is 0, fault is 3; Elevator door opening/closing is defined as 3 bits, the first bit means: button not pressed is 0, elevator door is open is 1, elevator door is closed is 2; the second and third bits indicate the door status: door opening process is 00, door is open is 01, door closing process is 10, door is closed is 11; Elevator internal call data starts with N and ends with W, each two bits represent the internal call floor number, such as N0413W indicating that there are internal internal call signals to the 4th and 13th floors; Elevator external call data starts with the internal call end character W and ends with the character S. Each three digits represent the outbound call floor number: the first digit indicates the outbound call direction, 0 for downbound, 1 for upbound, 2 for both upbound and downbound calls, and the other two digits indicate the floor number. For example, data W005112S indicates that there is a downbound call on the fifth floor and an upbound call on the 12th floor. The level signal is represented by two digits. The text data consists of data from elevators A and B, which have the same format, with elevator A data first and elevator B data second. (2) The response word is the response returned by the computer or PLC to the sender after receiving the data. It is used to determine whether the communication data is correct. The text includes: 00 when the XOR check code is correct, and 11 when it is incorrect. When the computer sends the status word as shown above to the PLC, the response returned by the PLC to the computer is: (3) When the data format sent by the computer to the PLC indicates that the computer is the host and requests the PLC to transmit data, and the host is in the data receiving state, the data frame transmitted by the PLC to the computer at this time is called the control word, which is used to control the operation of the virtual elevator. The control word format is that the main data includes: elevator up and down stop, elevator door opening and closing instructions, signal indication (internal call, external call, floor). The definition format is similar to that of the status word. 3. Communication program design The design of the communication program is to complete the data transmission task between the computer and the PLC in the format of the above protocol. It is divided into computer communication program and PLC communication program. 3.1 Computer communication program When developing the computer serial communication program, the VB programming language is used, mainly using the MSComm (Microsoft Comm Control 6.0) communication control, which provides various operations on the serial port. MSComm provides two communication methods: event-driven method and polling method. This system uses a query method, which is suitable for smaller applications. After each serial port operation is completed, the application will continuously check the CommEvent property of the MSComm control to check the execution result or whether a certain event has occurred. The main properties of the MSComm control are: (1) Commport property, which sets and returns the communication port number to specify which serial port of the PC is used. (2) Setting property, which sets and returns the baud rate, parity, data bits and stop bits in the form of a string. (3) Portopen property, which sets and returns the status of the communication port to open or close the port. (4) Output property, which is used to send data, which can be text data or binary data. (5) Input property, which returns and deletes characters from the receive buffer to receive data. (6) InputLen, which sets and returns the number of characters read from the receive buffer each time the Input property is used. (7) CommEvent, which returns the most recent communication event or error. The communication process of the computer virtual elevator is shown in Figure 3. [align=center]Figure 3. Communication process of computer[/align] 3.2 PLC Communication Program The Siemens S7-200 PLC provides three communication modes: PPI (point-to-point), MPI (multi-point), and free port. Free port communication allows the S7-200 to communicate with any device with a serial port. Free port communication uses an RS-485 interface. Communication operations can be controlled using receive interrupts, transmit interrupts, transmit instructions (XMT), and receive instructions (RCV). During communication, the computer, acting as the master station, sends instructions to the PLC's PORT0 port via the COM port. The PLC receives the instructions via RCV, decodes them, performs the required operations, and returns the execution status information. The PLC communication program uses an interrupt-driven approach. The special storage bytes SMB30 and SMB130 within the S7-200 series PLC are used to select the baud rate, parity, and data bits for communication ports 0 and 1 in free port communication mode. The XMT instruction is used to send the contents of the buffer, and an interrupt event is generated after the transmission is complete. The RCV instruction is used to receive data, and an interrupt is also generated after the reception is complete. The PLC communication process is shown in Figure 4. [align=center] Figure 4 PLC Communication Process[/align] 3.3 System Working Process The communication process of the virtual elevator system is also divided into two parts: computer and PLC. The computer part of the communication process is as follows: After the virtual elevator simulation interface runs, every certain period of time (set to 100ms), the computer sends the mouse commands on the virtual elevator simulation interface and the elevator status to the PLC. After receiving the data, the PLC uses it as input port data to run the elevator control program, generates output data, and transmits the data to the computer according to the protocol format. After receiving the data, the computer parses it and then runs the elevator and indicates signals according to the control instructions. 4 Conclusion The design of the communication program is an important part of the virtual elevator, which determines whether the system can achieve real-world operation, as well as its scalability and versatility. This system features an extensible communication protocol format. A communication program between the computer and the PLC was developed using VB language and a Siemens S7-200 PLC, enabling real-time communication between the two systems. This communication technology was successfully applied to a virtual multi-elevator system. This virtual elevator system, serving as a virtual object in an open PLC laboratory, has been successfully used in single-elevator and multi-elevator control, and offers promising prospects for the development of elevator control systems and the training of elevator operators. References [1] Liao Changchu. PLC Programming and Application [M]. Beijing: Machinery Industry Press, 2002 [2] SIMATIC S7-200. Programmable Controller System Manual [3] SIEMENS Co. SIMATIC S7-200 Programmable Controller System Manual [Z] 2002.4 [4] Zong Qun, Luo Xinyu, Wang Zhonghai. Development and Application of Virtual Elevator System [J]. Manufacturing Automation, 2002 (8): 56-59. [5] Chen Liding, Wu Yuxiang, Chen Liding. Electrical Control and Programmable Controller [M]. Guangzhou: South China University of Technology Press, 2001. [6] Cao Hui et al. Application of S7-200 PLC Free Port Communication in Cement Plant Batching Control System [J]. Microcomputer Information, 2004.5