1 Introduction
Programmable controller (PLC) has been widely used in the field of industrial control due to its compact structure, high reliability, simple programming, powerful instructions, strong flexibility, and adaptability to relatively harsh environments. The touch screen plus PLC method is now commonly used to monitor equipment, but the touch screen has a narrow viewing angle and is not suitable for harsh environments. In addition, the data storage capacity is limited and it is not easy to achieve large-scale network interconnection. Therefore, we use the method of PLC and computer communication to achieve real-time monitoring, which overcomes the shortcomings of the touch screen.
2 Application of s7-200 cpu free port communication method
There are many world-renowned brands of PLCs, such as Siemens, Omron, Panasonic, Mitsubishi, etc. I will only take the CPU22× series of Siemens S7-200 small programmable controller as an example to introduce the function of PLC communicating with computers in computer networks.
The S7-200 CPU supports a variety of communication functions. Depending on the S7-200 CPU used, its network can support one or more of the following protocols:
Point-to-point interface (PPI)
Multi-point interface (mpi)
profibus
User defined protocol (free port)
Freeport communication is an operation mode in which the communication port of the S7-200 CPU can be controlled by the user program. Using freeport mode, user-defined communication protocols can be implemented to connect a variety of intelligent devices. The user program controls the operation of the communication port by using receive interrupts, send interrupts, send instructions, and receive instructions. In freeport communication mode, the communication protocol is completely controlled by the user program. Freeport mode is enabled through smb30 (port 0) and is only enabled when the CPU is in run mode. When the CPU is in stop mode, freeport communication stops and the communication port is converted to normal PPI protocol operation.
In recent years, with the improvement of my country's railway transportation environment, the speed of trains has become higher and higher, which is bound to put forward higher requirements for railway vehicles, which is reflected in the requirements for train comfort, operation reliability and safety. Therefore, the degree of automation of equipment on vehicles is getting higher and higher. The increase in the degree of automation has driven the application of network technology in train control and monitoring. The schematic diagram of vehicle network control and monitoring is shown in Figure 1.
The whole train is equipped with a vehicle-level computer, and each car is equipped with a car computer. The vehicle-level computer and each car computer form the main network of the vehicle, and the car computer and each device in the car form a subnet. Due to its own advantages, PLC is used as a control core in many devices on the vehicle, such as the control of train automatic doors and train air conditioners, so that it can be used as a node in the entire train network system.
3 Communication Protocol
Siemens S7-200 series PLC can use user-defined communication protocol (free port) mode to realize computer-PLC and PLC-PLC communication. In the example described by the author, although the vehicle computer system and other equipment on the vehicle are products of multiple equipment suppliers, as long as the communication protocol is well formulated, the requirements for mutual communication can be met. The S7-200 series PLC can easily communicate with the vehicle computer because its free port communication is an operation mode that controls the CPU serial communication port through the user program.
The computer (master station) queries the PLC (slave station) every 100ms. The master station sends a slave station action control command to the slave station. After receiving the command, the slave station sends a response frame to the master station. The slave station receives a frame of data sent by the master station, calculates its check code FCS, and compares it with the FCS in the received frame of data to check whether there is any data error. If there is any data error, the slave station sends information to the master station and requests retransmission.
l Character structure: Each character consists of 11 bits, and the parity bit uses odd check mode.
Start bit Data Parity bit Stop bit
1 bit 8 bits d7…d0 1 bit 1 bit
l Transmission data frame format
byte(0)…byte(n) fcs
byte(0)…byte(n) for a string;
fcs is the XOR check code, which is the XOR value of all data bytes and address bytes sent.
l Master station command frame structure
Slave address Slave address complement Control byte Command byte fcs
l Slave station response frame structure
Slave address Slave address complement Control byte Response byte fcs
4 Communication port initialization
The PLC internal special memory bits SMB30 and SMB130 configure communication ports 0 and 1 respectively, selecting the baud rate, parity check, and number of data bits for freeport communication. The control byte description of the freeport is shown in Table 1.
For example: the communication protocol stipulates that the parity check is odd, the data of each character is 8 bits, the baud rate is 19200, the free port protocol is used, and the communication port 0 is used, then smb30 is assigned to 0c5h in the PLC initialization program.
Example: //Serial port initialization┋
network
7
ld sm0.0
movb 16#c5, smb30 //Baud rate is 19200 odd parity //1 start bit 1 stop bit 8 data bits
eni //Enable interrupts
movb 2, smb34
movb 20, smb35
atch int_0, 8
┋
5 PLC real-time data processing
Since the communication protocol of the S7-200 series PLC is completely controlled by the ladder diagram program or STL editor in free port mode, the program can use receive interrupts, send interrupts, send instructions and receive instructions to control communication operations. The CPU continuously scans the user program and executes user tasks. During the program execution process of the PLC, based on stability, speed and flexibility, the CPU performs actual input and output operations through the input and output image registers in each scan cycle, that is, reading the actual input point value to the image register and writing the image register value to the actual output point. Since data reading and writing operations cannot be performed smoothly in the interrupt, it is possible to use programming to utilize the characteristics of the PLC cyclic scanning execution program to achieve data exchange between the data storage area and the input and output image register area during the program scan.
In this example, after the PLC is powered on and initialized, it enters the receive character interrupt. When the host computer sends a query command, the PLC determines whether the address and address complement of the command are correct. If correct, it determines whether the host computer sends a command to the PLC or queries the PLC status. If the command is executed, the PLC enters the main program to execute the relevant command. If the PLC status is queried, the information defined by the protocol is sent to the host computer. After receiving the information, the host computer sends a response frame to the PLC.
Example: interrupt0 //start receiving
network 1
ldn sm3.0
ab= smb2, vb0
movw +0, ac0
movd &vb600, vd638
movb smb2, *vd638
xorw smw1, ac0
movb ac0, vb300
atch int_1, 8
atch int_6, 11
creti
network 2
ld sm0.0
dtch 8
atch int_6, 10
interrupt1 //receive address complement
network 1
ldn sm3.0
an sm1.0
movb smb2, *vd638
xorw smw1, ac0
network 2
ld sm0.0
atch int_6, 10
interrupt2 //judge after receiving command
┋
network 3 //send information
ldw= ac2, +0
ab= vb301, vb604
ab= vb603, 16#00
atch int_4, 10
dtch 11
creti
network 4
ld sm0.0
wdr
┋
network 7
ld sm0.0
s m31.0, 1
dtch 11
atch int_5, 10
interrupt3 //receive response bytenetwork
1
ldn sm3.0
an sm1.0
movb smb2, *vd638
incd vd638
xorw smw1, ac0
decw ac2
network 2
ldw= ac2, 16#0000
movw ac0, vw300
network 3
ld sm0.0
dtch 8
atch int_6, 10
interrupt4 //send information
code┋
network 6
ld sm0.0
movw ac0, vw105
xmt vb100, 0
atch int_6, 9
┋
interrupt5 //Send response flag
┋
network 9
ld sm0.0
movw ac0, vw105
xmt vb100, 0
r m31.0, 1
atch int_6, 9
┋
interrupt6 //Transfer to accept interrupt
network 1
ld sm0.0
dtch 9
dtch 10
dtch 11
atch int_0, 8
6 Computer real-time data processing
The computer program is provided by the vehicle-level network supplier and is usually written in VB or VC according to the communication protocol established by both parties. It will not be described in detail here.
7 Conclusion
From the above description, we can see that the key to the vehicle-level real-time monitoring system composed of vehicle computers and PLCs (or other intelligent programmable devices) is to solve the problem of real-time communication between computers and PLCs, and real-time monitoring of the status of on-board equipment by PLCs. The vehicle real-time monitoring system formed in this way only adds a communication program to the original equipment controller software, so it does not increase the cost of the equipment supplier. Therefore, the development cost of this monitoring system is low, and it has good real-time performance, simple operation, and strong versatility. Then, by using the computer's easy networking function, real-time monitoring of the entire train is realized, which greatly improves the reliability and safety of the train during travel. Therefore, this network system has been widely used in passenger trains, especially high-speed trains.
Previous article:Design and implementation of a three-degree-of-freedom manipulator control system based on PLC
Next article:Design of power supply control system for server room based on PLC
Recommended ReadingLatest update time:2024-11-16 17:33
- Popular Resources
- Popular amplifiers
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- 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
- Could you please help me with how to calculate the VGS of this current mirror? Thank you very much!
- GigaDevice's new GD32F470xx series with TFT and Ethernet port
- MicroPython adds support for operator @
- Frequency calculation
- The chip shortage will end in 2023 and there may be overcapacity in 2024. Do you believe it?
- Can the shared power bank industry really make money?
- I have a question about the antenna. I want to ask you guys
- BlueNRG-series level 1 training materials
- Motor Control Advanced 2——PID Position Control
- A detailed introduction to the control technology of various DC motors