Abstract: This paper analyzes the PROFIBUS-DP transmission protocol and message structure, and designs a PROFIBUS-DP bus performance analysis and diagnostic software based on serial communication. The implementation method and key technologies of the program are presented, and it was tested and run on a PROFIBUS-DP experimental platform. The results show that the software runs well and can basically complete the functions of PROFIBUS-DP message acquisition, analysis, and storage.
Keywords : fieldbus, PROFIBUS-DP, communication protocol, message, serial port.
The design of soft for analysis and the study of FCS's performance based on PROFIBUS-DP
(1 Shanghai Arcel Co., Ltd, Jiading Shanghai 201801 CHINA)
Abstract : Introduced communication protocol and message structure of PROFIBUS-DP, designed one software based on serial port communication, The software can analyze and diagnose the performance of PROFIBUS-DP. Presented the method and the key functions technique, The software is run on the communication network platform The debugging results indicate that the software can gather, analyze and memorize some kind of message of PROFIBUS-DP.
Keywords : FieldBus , PROFIBUS, communication protocol, message, serialport
0 Introduction
PROFIBUS is the most widely used fieldbus technology in industrial automation. It includes PROFIBUS-DP for manufacturing automation and PROFIBUS-PA for process industries, and is currently my country's only national standard for fieldbuses. With the increasing adoption of PROFIBUS fieldbus technology in industrial control systems, specific, intuitive, and real-time online analysis and diagnosis of these systems has become a fundamental requirement. To accomplish this, corresponding engineering analysis and diagnostic tools are needed. Currently, existing bus performance analysis and diagnostic engineering tools, both domestically and internationally, suffer from limitations such as insufficient functionality, imperfect interfaces, high prices, and unsuitability for China's specific circumstances. Therefore, developing a convenient, cost-effective analysis and diagnostic engineering tool capable of analyzing and diagnosing bus systems is urgently needed.
Because PROFIBUS transmission messages can reflect many parameters of bus performance, including various fault states. For example, parameterized messages can reveal the relationship between the master and slave stations, the slave station's operating mode, including channel parameters, function settings, device parameters, and ID numbers. Configuration messages can reveal the slave station's I/O types and properties, as well as the module's I/O properties and data types. Diagnostic messages can reveal various parameter setting errors, configuration errors, and device module error types. Therefore, based on a detailed analysis of PROFIBUS-DP messages, the author developed a PROFIBUS performance analysis and diagnostic software based on serial communication using VC++ 6.0.
1. PROFIBUS Working Mechanism
1.1 PROFIBUS-DP Encoding Technology
PROFIBUS-DP exchanges data using asynchronous transmission technology and NRZ encoding. The signal level of an NRZ-encoded binary signal "0" or "1" remains constant throughout the signal duration. Figure 1 shows an NRZ code signal diagram.
Each data link layer protocol data unit should consist of a certain number of characters, and each character is a start-stop character used for asynchronous transmission.
Each character consists of 11 bits, including a start bit (ST) that is always binary "0", eight information bits that can be either binary "0" or binary "1", one parity bit (P) that can be either binary "1" or binary "0", and one stop bit that is always binary "1", as shown in Figure 2.
Bit synchronization of the receiver always begins with the falling edge of the start bit, that is, when transitioning 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, synchronization is considered a failure and the synchronization process stops. Synchronization ends with a binary "1" stop bit. If a binary "0" replaces this stop bit, a synchronization error or character error should be considered and reported, and the receiver should wait for the leading edge of the next start bit.
1.2 Message Format
As shown in Figure 3, PRFIBUS-DP has the following five message formats. SYN is the synchronization period, a minimum time interval during which each station should receive an idle state (idle = binary "1") from the transmission medium before it can receive send/request message frames or the start of a token. The minimum synchronization period is 33 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 with a value of 16h, and L is the information field length. SD1 = 10h, used to request the FDL state and find a new active station; the message length is fixed and there is no data unit. SD2 = 68h, used for SRD service; the message data length 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, a short acknowledgment message.
2. Implementation of Message Diagnostic Software
2.1 Experimental Platform
Figure 4 shows the structure of the PROFIBUS-DP network experimental system built by the author. In the network system, the Class 1 master station is the SIEMENS CPU315-2DP PLC, and the PC industrial control computer acts as the Class 2 master station, connected to the DP bus via the CP5611 fieldbus interface card. PLC devices such as the WAGO 750-333, BECKHOFF BK3120, SIEMENS ET200-L, and Hollysys LM3107 PLC are connected to the DP network as slave stations.
2.2 Software Development Environment
The software development tool used is VC++ 6.0. PROFIBUS-DP messages are acquired and processed by a host computer via standard serial communication. The PROFIBUS-DP system serves as the experimental platform, using an RS485/RS232 communication cable. One end of the RS485 cable is connected to the back connector of the PROFIBUS-DP network connector, and the other end is directly connected to the PC's serial port.
2.3 Basic Program Flowchart of the Software System
The basic program architecture flowchart of the software system is shown in Figure 5.
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, acquiring PROFIBUS-DP message data and setting serial port parameters.
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 a temporary buffer.
4) Receiver and display module: responsible for processing and displaying received data.
5) Database module and data query module, used to analyze and query historical data of collected messages.
2.4 Key Technologies
This software primarily extracts PROFIBUS messages, enabling online acquisition of PROFIBUS-DP message data. It analyzes various messages from the data link layer perspective, displays different message types, and extracts and displays information such as message type, service type, address, data length, and data unit. It also performs detailed analysis of the data units of diagnostic, parameterized, and configuration messages to derive various bus performance parameters and fault causes. The analyzed data is stored in a database and a temporary buffer. Historical queries are also possible by storing analyzed message information in the database as needed.
Extracting message frames is a key issue in this software design. Since there are many PROFIBUS message formats, including variable-length messages with indefinite data lengths, and while all messages have fixed headers and trailers, the headers and trailers are not specific characters and may be identical to the data units within the message. Therefore, using headers and trailers for message extraction is not feasible. The authors utilize synchronization characters preceding each message frame for extraction. Specifically, each complete message frame is preceded by a synchronization period of at least 33 bits, with no intervals in between. This synchronization period is used in VC++ with a timeout function to completely extract the message frame.
In addition, due to the large volume and high speed of communication data, Windows multithreading technology is employed. One thread serves as a monitoring thread to monitor serial port communication, another as the main data processing thread, and a third as a thread for periodically refreshing the database. When the monitoring thread detects data arriving at the serial port, it triggers a message to notify the main data processing thread, which then retrieves the data from the serial port buffer and processes it. The timer thread periodically refreshes the database display to achieve real-time display functionality.
During program development, the author encountered a problem where the database could not be refreshed in real time. The issue was later discovered to be with the Windows WM_TIMER timer. Because this timer has a low message priority, WM_TIMER messages might be lost, preventing real-time database updates. The solution was to use Windows' multimedia timer. However, selecting the appropriate time interval is crucial. Too small an interval consumes excessive CPU and memory, potentially causing system crashes; too large an interval fails to provide real-time display. This also involves the PROFIBUS bus information loop time, which is related to the bus baud rate, the number of slave stations, the amount of I/O data, the slave station's required delay time, and the master station's idle time. Through extensive calculations and numerous experimental debugging sessions, the author found a suitable timer interval.
2.5 Display Interface
The PROFIBUS-DP message analysis software's interface includes a main interface, a serial port configuration interface, a message filtering interface, a message query interface, a database storage interface, and a historical query interface.
The main interface of the PROFIBUS-DP analysis and diagnostic software is shown in Figure 6. The "Current PROFIBUS Messages" group box in the upper left corner of the window stores the most recently acquired PROFIBUS-DP message information, and the records can be scrolled through using the record movement buttons on the toolbar. The "Information Panel" in the upper right corner displays detailed information for all viewed messages. The lower half of the window displays PROFIBUS-DP historical information in a grid format.
To open the serial port and start receiving PROFIBUS messages, select "Start Receiving" under the "Command" menu. To stop receiving PROFIBUS messages, select "Stop Receiving" under the "Command" menu. To configure serial port parameters, select "Serial Port Configuration" under the "Command" menu, which will open the "Serial Port Configuration" dialog box. To clear all current records, select "Clear All Records" under the "Records" menu. To view different types of messages by category, select "Message Query" under the "View" menu, which will open the "Message Query" dialog box, allowing you to view messages by category as needed.
3. Conclusion
After repeated testing and debugging on the PROFIBUS network experimental system, the results show that the software can analyze several PROFIBUS messages and perform functions such as acquisition, display, analysis, storage and query. This lays the foundation for future research and development and has certain practical value.
References
- People's Republic of China Machinery Industry Standard. Fieldbus Type 3 for Industrial Control Systems: Measurement and Control Digital Data Communication: PROFIBUS Specification [M]. Beijing: Machinery Industry Press, 2006.
- Wang Yonghua, Andy Verwer. Fieldbus Technology and Application Tutorial [M] - From PROFIBUS to AS-i. Beijing: China Machine Press, 2006.
- IEC. Digital data communications for measurment and control-Fieldbus for use in industrial control systems-Part 3: Data Link Layer service definition[M]. Third edition. 1999.10
- IEC. Digital data communications for measurment and control-Fieldbus for use in industrial control systems-Part 4: Data Link Layer protocol specification[M]. Third edition. 1999.10
- Chen Youping, Zhou Yan, Chen Bing, et al. Design of Profibus-DP message receiver based on CPLD [J]. Measurement & Control Technology, 2005, 24(6).
- Wu Fangyu, Zhou Yong. A database-based serial port data acquisition and storage scheme [J]. Computer and Modernization, 2005, 10.
- Gong Jianwei, Xiong Guangming. Visual C++/Turbo C Serial Communication Programming Practice [M]. Electronic Industry Press, 2004.
Shanghai Acrel Electric Co., Ltd.
Address: No. 253, Yulu Road, Madong Industrial Park, Jiading District, Shanghai
Technical Support: Xu Min 13917119065 021-69158332
Service Hotline: 800-8206632
Postal code: 201801
Fax: 021-69158303