PC as a Profibus-DP single master station implementation
2026-04-06 07:38:41··#1
Abstract: This paper mainly introduces the basic characteristics and communication protocol of Profibus fieldbus, discusses the feasibility of implementing Profibus-DP as a single master using a PC, and provides a C language implementation program. Keywords: Profibus, fieldbus, single master, PC, Profibus-DP , C language I. Overview of Profibus Profibus is an open fieldbus standard launched by SIEMENS. It became the German standard DIN19245 in 1989, the European standard EN50170 in 1996, and was accepted as part of the international standard IEC61158 in December 1999. Profibus is currently the most widely used bus system in Europe and even globally. It is fast and low-cost, and almost all PLC products and a large number of automation peripheral products provide Profibus interfaces. Profibus provides three compatible versions according to different application scenarios: ProfibusDP, ProfibusFMS, and ProfibusPA. ProfibusDP is suitable for high-speed data transmission between field-level distributed automation peripherals (DP means distributed peripheral device). Its architecture includes ISO/OSI reference model layers 1 and 2, as well as a user interface. The transmission technology uses RS485 (referred to as H2), ensuring real-time communication and low system implementation cost. The user interface uses application functions defined for users and the system, and rules describing the behavior of field devices. Profibus FMS (Fieldbus Message Specification) is a general solution for field-level and unit-level communication, primarily addressing communication between unit-level masters (PLC and PC). Therefore, advanced functionality is more important than rapid system response time. FMS uses ISO/OSI reference model layers 1, 2, and 7. Layers 1 and 2 are compatible with Profibus DP, and layer 7 includes application protocols and provides users with a wide range of communication services. Profibus PA is an optimized and extended version of Profibus DP, mainly used in chemical and other applications with high safety requirements. Communication uses an extended Profibus DP protocol. The transmission technology is changed to IEC11582 (referred to as H1), ensuring intrinsic safety and enabling field devices to be powered via the bus. Through segmented couplers, it can be easily connected to Profibus DP and Profibus FMS. II. Profibus Communication Protocol The Profibus communication protocol is implemented through Layer 2 of the ISO/OSI reference model, referred to as FDL (Fieldbus Data Link) in Profibus. Devices on the Profibus bus fall into two categories: masters and slaves. A master has control over the bus for a limited time (TokenHoldTime), during which it can send data to or request data from slaves. Slave devices do not have control over the bus; they only respond to a master's request or acknowledge data sent by the master. Therefore, the Profibus communication protocol includes a token passing protocol between masters and a master-slave protocol between masters and slaves. The token passing protocol ensures that each master has sufficient time to fulfill its communication tasks; the maximum time for a token to circulate among all masters is fixed. The master-slave protocol guarantees communication between the master and slave during the token holding time. III. ProfibusDP Single-Master System ProfibusDP allows for single-master or multi-master systems. In a multi-master configuration, each master and its respective slave constitute an independent subsystem involving token passing. As a fieldbus system, many systems are single-master systems consisting of a PLC as the controller and master. If this system is not closed (operating independently without exchanging data with the outside world), it may connect to larger networks such as workshop units via Profibus FMS or other fieldbuses. Alternatively, the PLC may communicate with a host PC (monitoring layer) via RS232 serial communication, as shown in Figure 1. IV. Software Implementation 1. Profibus DP Single Master Protocol Master Read Command: $①①R②13 Slave Response Data Format: =③③③13 Master Write Command: $①①W②③③③13 Slave Acknowledgment Format: 6 13 is the ASCII code for the Enter key, 6 is the ASCII code for ACK, $, R, and W represent the corresponding ASCII codes, ①① represents two ASCII codes for the address, ② represents one ASCII code for the variable number, and ③③③ represents three ASCII codes for the data. RS232 only uses three signal lines: TXD, RXD, and GROUND. Each frame contains 8 data bits, even parity, and 1 end bit. Data transmission rate is 9600 b/s. 2. The flowchart for querying and setting each slave station as a lower-level machine is shown in Figure 3. 3. The flowchart for controlling the PID output of one slave station as a regulator is shown in Figure 4; the specific program is omitted. As a process monitoring layer, it is also possible to use a loop to poll each slave station, with the PID program only processing one slave station. The software can also use Simatic WinCC configuration, VC++6.0, etc., to write a graphical interface PC application to achieve both monitoring and control functions. V. Conclusion The program ran successfully on the PC in the system shown in Figure 2, and communicated well with the ProfibusDP slave station using the ASIC protocol chip. The PID output program achieved the same accuracy as the PLC in the belt scale batching control, verifying the feasibility of using a PC to complete PLC functions in some ProfibusDP single-master systems.