PROFIBUS is a fieldbus technology with the highest market share in the field of industrial automation. It includes PROFIBUS-DP for manufacturing automation and PROFIBUS-PA for process industry. It is currently the only national fieldbus standard in China. As more and more industrial control systems adopt PROFIBUS fieldbus technology, specific, intuitive and real-time online analysis and diagnosis of these control systems has become the most basic requirement. To complete such a task, corresponding engineering analysis and diagnosis tools are needed. The bus performance analysis and diagnosis engineering tools currently studied at home and abroad have problems such as insufficient functions, imperfect interfaces, high prices, and unsuitability for China's national conditions. Developing a convenient and cost-effective analysis and diagnosis engineering tool that can analyze and diagnose the bus system will surely become a much-needed product.
Because the PRIFBUS transmission message can reflect many parameters of the bus performance, including various fault states. For example, the relationship between the master station and the slave station, the operation mode of the slave station, including channel parameters, function settings, device parameters and ID number, can be seen from the parameterized message. The I/O type and nature of the slave station, as well as the I/O nature and data type of the module can be seen from the configuration message. From the diagnostic message, we can see the various parameter setting errors, various configuration errors, and device module error types of the slave station. Therefore, the author of this article developed a PROFIBUS performance analysis and diagnostic software based on serial communication using VC++ 6.0 based on a detailed analysis of the PROFIBUS-DP message.
1 PROFIBUS working mechanism
1.1 PROFIBUS-DP encoding technology
PROFIBUS-DP uses asynchronous transmission technology and NRZ encoding to exchange data. The signal level of the NRZ-encoded binary signal "0" or "1" remains unchanged during the duration of the signal. Figure 1 shows the NRZ code signal diagram.
Figure 1 Non-return-to-zero signal
Each data link layer protocol data unit should consist of a certain number of characters, each of which is a start-stop character for asynchronous transmission.
Each character consists of 11 bits, including a start bit (ST) that is always binary "0", 8 information bits that can be either binary "0" or binary "1", an even parity bit (P) that can be either binary "1" or binary "0", and a stop bit that is always binary "1", as shown in Figure 2.
Figure 2 Single character format
The bit synchronization of the receiver always starts from the falling edge of the start bit, that is, it starts at the transition from binary "1" to binary "0". The start bit and all subsequent bits should be scanned in the middle of the bit time. In the middle of the bit time, the start bit should be binary "0", otherwise the synchronization is considered to have failed and the synchronization process is stopped. The synchronization of the character is ended with a stop bit of binary "1". If a binary "0" appears to replace this stop bit at this time, a synchronization error or character error should be considered and reported, and the leading edge of the next start bit should be waited.
1.2 Message format
As shown in Figure 3, PRFIBUS-DP has the following 5 message formats. Among them, SYN is the synchronization period, which is a minimum time interval. During this time interval, each station should receive an idle state (idle = binary "1") from the transmission medium before it can receive the send/request message frame or the start part of the token. The minimum synchronization cycle is 33 line idle bits; SD is the start delimiter, DA is the destination address, SA is the source address, FC is the control frame; FCS is the frame checksum, ED is the end delimiter, the value is 16h, L is the information field length, where SD1 = 10h, used to request FDL status, find a new active site, the message length is fixed, there is no data unit; SD2 = 68h, used for SRD service, the data length of the message is variable; SD3 = A2h, the data unit length is fixed (L is always 8 bytes); SD4 = DCh, indicating that the message is a token message; SC = E5h, short confirmation message.
Figure 3 PROFIBUS-DP link layer message format
2 Implementation of message diagnosis software
2.1 Experimental platform
Figure 4 is the structure diagram of the PROFIBUS-DP network experimental system built by the author. In the network system, the class 1 master station is the CPU315-2DP PLC of SIEMENS, the PC industrial computer is the class 2 master station, connected to the DP bus through the fieldbus interface card CP5611, and PLC devices such as WAGO's 750-333, BECKHOFF's BK3120, SIEMENS' ET200-L and Hollysys' LM3107 PLC are connected to the DP network as slave stations.
Figure 4 PROFIBUS-DP network experimental system structure diagram
2.2 Software Development Environment
The software development tool is VC++6.0. Through the computer standard serial port communication, the PROFIBUS-DP message is collected to the host computer for processing. The PROFIBUS-DP system is used as an experimental platform. The RS485/RS232 communication cable is used to connect the RS485 end of the PROFIBUS-DP network connector to the back plug interface, and the RS232 end is directly connected to the serial port of the PC.
2.3 Basic program flowchart of the software system
The basic program architecture flowchart of the software system is shown in Figure 5.
Figure 5 Basic program framework flow chart
The entire system software includes the following modules:
1) Program main control module: responsible for implementing program logic and main interface, calling serial communication module and receiving display module.
2) Serial communication module: responsible for implementing serial communication tasks, PROFIBUS-DP message data collection and serial port parameter settings.
3) Data processing module: according to the PROFIBUS-DP protocol message format, the collected data is processed according to the message format and stored in the temporary buffer.
4) Receiving display module: responsible for processing and displaying received data.
5) Database module and data query module, used to analyze and query the historical data collected from the message.
2.4 Key technologies
The software mainly realizes the extraction of PROFIBUS messages, realizes the online collection of PROFIBUS-DP message data, analyzes various messages from the perspective of the data link layer, completes the display of various types of messages, completes the extraction and display of information such as message type, service type, address, data length and data unit, and performs detailed analysis on the data units of diagnostic messages, parameterized messages and configuration messages, etc., obtains various parameters of bus performance and causes of failures, stores the analyzed data into the database, stores it in the temporary buffer, and stores the analyzed message information into the database as needed to realize historical query.
How to realize the extraction of message frames is a key issue in the design of this software. Since there are many types of PROFIBUS message formats, including variable messages with unfixed data length. Although various messages have fixed headers and trailers, the problem is that the headers and trailers are not specific characters, and may be the same as the content of the data unit in the message, so it is not feasible to use the headers and trailers to extract messages here. Here, the author uses the synchronization characters before various message frames to extract messages. That is to say, before each complete message frame is transmitted, there is a synchronization time of no less than 33 bits in front of it. There is no interval in the middle of the message frame. Using this synchronization time, the timeout function is used in VC++ to completely extract the message frame.
In addition, due to the large amount of communication data and the high speed, WINDOWS multi-threading technology is used here. One thread is the monitoring thread, which monitors the serial port communication, one is the main thread for data processing, and the other is the thread for timing database refresh. When the monitoring thread monitors that data has arrived in the serial port, it triggers a message to notify the main thread for data processing. The main thread for data processing takes out the data from the serial port buffer and processes the data. The timer thread regularly refreshes the database display to realize the real-time display function.
During the process of writing the program, the author found that the database could not be refreshed in real time. Later, it was found that the problem was with the WM_TIMER timer of WINDOWS. Since the priority of the timer message is low, it may cause the loss of WM_TIMER message, so the real-time refresh of the database cannot be realized. The solution is to use the multimedia timer of WINDOWS. In the process of using multimedia timers, the selection of timing intervals is a key issue. If the timing interval is too small, a large amount of CPU memory will be consumed, causing the system to "freeze". If the timing interval is too large, the "real-time" display function cannot be completed. This involves the issue of PROFIBUS bus information cycle time, which is related to the baud rate of bus transmission, the number of slave stations, the number of I/O data, the delay time required by the slave station, and the idle time of the master station. The author has found a suitable timer interval through a lot of calculations and multiple experimental debugging.
2.5 Display interface
The program interface of the PROFIBUS-DP message analysis software includes the main interface, serial port configuration interface, message filtering interface, message query interface, database storage interface, and historical query interface. The
main interface of the PROFIBUS-DP analysis and diagnosis software is shown in Figure 6. The "Current Profibus Message" group box in the upper left part of the window stores the recently collected PROFIBUS-DP message information, and the record can be scrolled through the record move button on the toolbar; the "Information Panel" in the upper right is used to display the detailed information of all viewed messages. The lower part of the window displays the PROFIBUS-DP historical information in a grid format.
If you need to open the serial port and start receiving PROFIBUS message information, you can select the "Start Receiving" item under the "Command" menu; if you need to stop receiving PROFIBUS message information, you can select the "Stop Receiving" item under the "Command" menu; if you need to configure the serial port parameters, you can select the "Serial Port Configuration" item under the "Command" menu, and the "Serial Port Configuration Dialog Box" will pop up. If you need to clear all current records, you can select the "Clear All Record Items" command under the "Record" menu. If you need to view various messages by category, you can select "Message Query" under the "View" command menu, and the "Message Query Dialog Box" will pop up, and you can view the messages by category as needed.
Figure 6 Main interface of software operation
3 Conclusion
The author has repeatedly run and debugged the software on the PROFIBUS network experimental system. The results show that the software can analyze several PROFIBUS messages and complete the functions of acquisition, display, analysis, storage and query, laying a foundation for future research and development, and has certain practical value.
Previous article:Design of infrared remote control keyboard for industrial control computers
Next article:Application of Modbus Communication in PLC Channel Detection
Recommended ReadingLatest update time:2024-11-16 19:50
- 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
- About the difference between CC1312R LAUNCHPAD versions
- About the signal input mode of the power amplifier
- My Journey of MCU Development (Part 1)
- How to understand the accuracy parameter (1.5% + 3) of the Fluke F17B+ multimeter?
- Another bottleneck.
- Easy-to-use and cheap microcontroller is here
- Inverting proportional operational amplifier circuit
- Upper computer displays waveform acquisition
- Evaluation Weekly Report 20211129: There are 4 days left for Anxinke NB-IoT and domestic FPGA applications, and the wireless charging mouse pad is waiting to be disassembled (Extra)
- Are there any pmos and nmos tubes with working current |Ids|=1.2A;|Vds|<0.2V, which don't matter if they are enhanced or not, and have low leakage current when turned off?