In industrial control, projects controlled by PLC generally use RS-232/RS-485 serial communication for upper/lower computer communication. This method is difficult to meet the communication needs of control systems with large data volumes, long communication distances, and high real-time requirements.
In recent years, with the rapid development of computer network technology, networked numerical control has become an inevitable trend in the development of modern manufacturing industry. Control systems are developing in the direction of virtualization, networking, integration, distribution and node intelligence. [1] Many PLCs produced by large PLC manufacturers are equipped with corresponding Ethernet communication modules. This paper discusses the Ethernet communication architecture of OMRON PLC and takes the ENT2l Ethernet module of CP1H PLC as an example to realize communication with the computer.
1. Winsock network communication control
The Winsock control is a non-visual control that allows programmers to develop client/server applications without having to understand the details of TCP or call low-level Winsock API functions. They can directly connect to a remote computer and implement two-way data exchange simply by setting the properties of the Winsock control and calling its methods.
WinSock mainly supports two types of sockets: ① Stream Socket, also known as connection-oriented mode, corresponds to the TCP protocol, and its transmission characteristics are high communication reliability, which can ensure that the transmission of data streams is reliable, orderly, and non-repetitive, and can provide bidirectional data streams. Data is regarded as byte streams with no length restrictions. ② Datagram Socket, also known as connectionless mode, corresponds to the UDP protocol. This mode does not provide correctness, orderliness, and non-repetitiveness of data transmission CONTROL, because it supports record-oriented data streams. Therefore, the transmitted data may be lost and repeated, and the receiving order is chaotic, and the message length is limited. Considering that this system has high requirements for communication reliability and correctness, the stream socket method is selected. The stream socket communication process based on the Client/Server mode is shown in Figure 1.
Figure 1 Sequence diagram of streaming socket process communication
2. Setting up the Ethernet network communication unit
When building a network, each node in the network needs to be installed with a corresponding communication unit according to the different network types, and the PLC needs to be installed with an Ethernet network communication module, such as the CJ1W-ETN21 Ethernet module from OMRON. Before application, the network must be set up, which is divided into switch settings and CPU bus unit system settings.
The switch settings mainly include the following items: determine the memory working area (CIO area, DM area) allocated to the CJ1W-ETN21 unit. The address is in the CPU bus area. The unit number range of the ETN unit is determined by the UNIT No. switch, which is 0 to F; the NODE No. rotary switch sets two groups of hexadecimal numbers as the node number of the ETN unit in the network, ranging from O1 to 7E; the IP address sets the network number and the host node number, which consists of a 32-bit binary number and is expressed in decimal in 4 segments.
The CPU bus unit settings are mainly set through programming devices such as CX-Programmer software or programmers to set the network unit mode, local IP address, subnet mask, FINS port number, FTP login name and password, and IP router table. If the FINS/TCP protocol is used, it is also necessary to modify some parameters of the FINS/TCP item in the Ethernet unit settings, such as: automatically assigned FINS node number, whether to keep activated, etc.
3. Communication protocol for host computers
As shown in Figure 2, the layered model of Ethernet is divided into the physical layer, the Internet layer, the transport layer, and the application layer. Among them: the transport layer can use the connectionless UDP or the TCP protocol that requires a connection; the application layer is the FINS (Factory InteRFace Network Service) protocol. The FINS protocol is a command response system developed by OMRON for factory automation control networks. It mainly stipulates the operation methods such as reading and writing data in the PLC storage space. The communication implementation method that uses the FINS protocol in the application layer and the TCP protocol in the transport layer is called the FINS/TCP method.
Figure 2 Network layered structure
The FINS protocol includes a command system and a response system. Its command frame consists of several parts, including a FINS header, a command code, a response code, and a body. The commands and responses sent from the host computer must comply with the format requirements of the following frames and provide appropriate FINS header information. [3-4] FINS communication services are implemented through the exchange of FINS command frames and their corresponding response frames.
The FINS command/response frame format is shown in Figure 3. The FINS/TCP header specifies five commands for communication between the client (host computer) and the server (PLC): (1) Send the client node address; (2) Send the server node address; (3) Send the Fins frame; (4) Send the Fins frame error notification; (5) Confirm the client and server are online.
Figure 3 FINS command/response frame format [page]
4. Specific implementation of communication program
After creating a new VB project, you need to execute the "Project/Component" command in the VB toolbar to add the Winsock control to the project and name it "WskClient". The program uses the TCP/IP protocol for communication, and its main properties are set as follows:
After the initialization is completed, a connection request is made to the PLC. After the PLC accepts the request and sends a response message, the client program builds the information frame to be sent according to various frame formats, and then two-way data communication can be carried out with the PLC. In this process, a retransmission mechanism can be established after a transmission failure to enhance the reliability of communication.
First, create and send a "handshake information" instruction (20 bytes) to indicate the client node number; when the computer receives the PLC return frame (24 bytes), check whether the PLC has received the command and obtain the server and client node numbers. When the computer receives the data returned by the PLC, a DataArrival event is generated, and the parameter BytesTotal contains the number of bytes of data received. In the DataArrival event, you can call the GetData method to receive data. If a Close event is received, use the Close method to close the connection. In addition, the State property of Winsock can be used to reflect the current TCP/IP connection status. Here are only the main procedures listed as follows:
After receiving the information, when the PLC receives the transmitted information, it will send back the corresponding command feedback value. The program in this event program will display it in the text box and can be further processed. The main program flow chart is shown in Figure 4.
Figure 4 Program flow chart
If the UDP protocol is used, the basic communication process is the same as TCP, except that there is no need to establish a connection. In addition, UDP applications can be either clients or servers, without having to establish client programs and server programs separately like TCP applications. Since UDP does not need to establish a connection between the client and the server before transmitting datagrams, and there is no timeout retransmission mechanism, the transmission speed is very fast. Therefore, if there are not many devices in the network and the amount of data sent is not large, the UDP protocol that consumes less computer "resources" can be selected for communication.
5. Conclusion
The host computer Ethernet communication program implemented by Winsock control has been successfully applied to the digital sample drawing machine monitoring system. This method is simple and practical. It can realize the function of real-time monitoring of network data of workshop equipment without additional investment, and achieve the ideal effect. Moreover, with VB as the development platform of monitoring software, the secondary development of software is not restricted, saving costs, and the program can be upgraded at any time as needed. In order to realize effective information management and monitoring of the control system, the PLC control system based on Ethernet will have a wider application. The discussion in this article provides a certain reference value for solving such problems.
Previous article:Design and implementation of binocular vision monitoring system based on DM642
Next article:Simulation Debugging Based on DSP TMS320F206
Recommended ReadingLatest update time:2024-11-16 19:38
- Popular Resources
- Popular amplifiers
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Share a video series by Hou Jie C++
- GD32L233C-START Evaluation (3) On-chip hardware oversampling ADC
- Anxinke PB-02 module review (3) - PHY62XX GPIO usage guide
- How to fix the Rx FIFO overrun error?
- Motor current and regenerative current when PWM driving is performed with one MOSFET
- Recruiting embedded software engineers (work location: Nanjing)
- AMS Christmas Gift Campaign: Scan the QR code, follow, play games, and win gifts!
- Case Study: Application of Doherty Power Amplifier Module in Large-Scale Antenna Array System
- MicroPython emergency update 1.19.1
- EEWORLD University Hall----Isolated power supply for PLC I/O modules