A practical design of a PROFIBUS-DP valve controller
2026-04-06 03:22:56··#1
Abstract: This paper introduces a valve controller design scheme for controlling ordinary valves. This valve controller has an interface with the industrial fieldbus PROFIBUS-DP, enabling remote and network control of the valve. The main focus of this paper is to introduce some issues that need attention when developing PROFIBUS-DP devices using the dedicated PROFIBUS-DP chip SPC3, including hardware interface design, some design points related to the PROFIBUS-DP specification standard, and methods for utilizing PROFIBUS-DP diagnostic functions. Keywords: Valve; PROFIBUS-DP; SPC3 1. Introduction In the traditional field of valve control, the introduction of embedded system technology and industrial fieldbus technology is one of the important directions for the development of valve controllers, and also an objective requirement for the realization of intelligent, networked, and remote control of industrial actuators. The design scheme in this paper is an attempt to address this issue. It is hoped that it can provide some reference for the design of valve controllers in China. In valve selection, we chose the most widely used and simplest structure, the ordinary valve, as the research object. Ordinary valves are also relatively simple to operate, with only three movement states: open, closed, and stopped, making remote control modification easy to implement. In terms of industrial fieldbus technology selection, we chose PROFIBUS-DP industrial fieldbus technology because PROFIBUS-DP technology is mature, has a wide range of application examples, and has a huge market share in the world [2]. It is also currently the recommended standard for the machinery industry in China. Therefore, the design of a PROFIBUS-DP valve controller for ordinary valves has certain advantages in terms of technical feasibility and market significance. The ultimate goal of this design is to realize a practical ordinary valve controller that can be used as a slave station compatible with the PROFIBUS-DP system and accept the control of the remote master station. 2. PROFIBUS-DP Hardware Interface Circuit Design In the design scheme of the PROFIBUS-DP hardware interface circuit of the valve controller, we adopted a single-chip microcomputer + dedicated integrated chip SPC3 + RS485 driver scheme. SPC3 is a smart communication dedicated chip used by Siemens to develop PROFIBUS-DP slave stations. It integrates the complete PROFIBUS-DP protocol and can independently complete all PROFIBUS-DP communication functions. SPC3 provides a convenient hardware interface suitable for different microprocessors, such as the Intel core 80C32, 80X86, 80C165 and Motorola microcontrollers. This design uses a 51 core microcontroller, so it adopts the Intel 8-bit connection method. In order to save microcontroller resources, it also adopts the address-data multiplexing mode. SPC3 is a 44-pin PQFP package. [align=center] Figure 1 DP hardware interface structure[/align] SPC3 has 1.5Kbyte message memory. This 1.5K storage space includes: processor parameters, organizational parameters, and all input/output buffers DP buffer[1]. The operation of SPC3 by the central processing unit is similar to the operation of a 1.5K RAM. It's worth noting that the SPC3's 1.5K memory space only requires 11 address lines to provide addresses, while the SPC3 and CPU are actually connected using 16 address lines. This is because the SPC3 internally uses the highest 5 bits of the address lines all zero as the strobe signal for memory space. Therefore, the 16 address lines of the SPC3 should be in the range of 0000H and 05FFH to access the SPC3's memory space. When the CPU has other external data memories, attention should be paid to address conflicts with the SPC3's memory space. Generally, an address decoding circuit is used to place the SPC3's memory space at the highest part of the CPU's address space. The SPC3 chip has a pin called XDATAEXCH, which is high in the reset state and goes low when the SPC3 enters data exchange mode and can communicate. This can be used as an indicator of whether communication is normal. Generally, an LED is connected to this pin as a convenient visual indicator of normal data communication. 3. Communication Address Scheme The valve controller, as a slave station in PROFIBUS-DP communication, must have an address that does not conflict with other stations. There are two design schemes for the PROFIBUS-DP slave communication address: one is that the slave address is set or modified by a remote PROFIBUS-DP master station through specific data communication; the other is that the PROFIBUS-DP master station is prohibited from setting and modifying the slave address, and the slave address is set locally by the slave station. This design adopts the latter scheme. The address of the valve controller is manually set through an 8-bit DIP switch, and then the central processing unit reads and writes it to a specific storage location in SPC3, specifically the organization parameter R_TS_Adr at storage address 16H in SPC3, thus enabling SPC3 to obtain the communication address. Since the master station is prohibited from changing the slave address, the organization parameter R_Real_No_Add_Change = FFH needs to be set during SPC3 initialization, along with two other organization parameters R_SSA_Buf_Ptr = 0 and R_Len_SSA_Data = 0. The meanings of these two organization parameters are: the former is the starting address of the buffer storing the address setting frame from the master station, and the latter is the data length of the received address setting frame. This prevents the activation of the service access point SAP55, responsible for address setting, during SPC3 initialization, thus preventing the master station from setting the slave station address. Simultaneously, the valve controller's device description file (GSD) needs the statement: `Set_Slave_Add_supp = 0`, indicating that the slave station is prohibited from having its address set or changed by the master station. PROFIBUS-DP supports 127 station addresses from 0 to 126, which can be set by changing the lower 7 bits of an 8-bit DIP switch. The highest bit of the DIP switch sets whether the valve is under remote or local control. As a practical controller, for safety and reliability, in addition to remote control, local control functionality is also necessary. This design allows field operators to disable remote control and manually operate the valve. In this state, the valve controller discards valve movement control commands received from the master station but still transmits various valve statuses to the master station. Therefore, the remote operator will be aware that remote control has failed and can still view various valve data, but cannot operate the valve. 4. Identifier Design and Use An identifier is a crucial parameter for a PROFIBUS-DP product. Typically consisting of one or several bytes, an identifier represents the width and characteristics of the input and output data during communication. For example, if a PROFIBUS-DP product controls eight switching signals and requires the master station to provide the content of these eight signals, then the data received from the master station by the product is 8 bits, totaling one byte. The product's identifier must describe this characteristic and width: one byte. The identifier is written to the product's device description file (GSD) for easy configuration during system setup. The identifier must also be written to a specific buffer in the SPC3 during SPC3 initialization for verification by the master station. The dedicated identifier is represented by one byte, and its format is as follows: [align=center] Figure 2 Dedicated Identifier Format[/align] The lower 4 bits of the dedicated identifier, bits 0 to 3, represent the data width of the device's data input or output. Values from 0 to 15 correspond to widths of 1 to 16 bytes or words. Bit 6 indicates whether the unit of the width value is bytes or words: 0 represents bytes, and 1 represents words. Bits 4 and 5 together indicate whether the data of the above width is output data, input data, or input/output data. It should be noted that in the PROFIBUS-DP system, input and output are relative to the master station. Data sent from the master station to the slave station is called output data, and data read from the slave station by the master station is called input data. The highest bit, bit 7, represents the degree of consistency. The so-called consistency requirement means that data in a certain area must be written or read simultaneously. In a specific system, this means that the master station must complete the reading or writing of the data area with consistency requirements in one upload or download, and cannot split it into several uploads or downloads. The definition of this bit is: 0 indicates that there is a consistency requirement only within the byte or word, and 1 indicates that there is a consistency requirement for the entire width defined by the identifier. In this design, the valve controller identifier is defined as B1H. This means it is 2 bytes long, for both input and output, and requires full consistency. When the PROFIBUS-DP system is powered on, this identifier is sent from the master station to the slave station to verify whether the actual slave station characteristics are consistent with those in the master station's data set. When writing the slave station program, the slave station designer needs a specific process to compare the identifier sent from the master station with their own and respond accordingly. Furthermore, this identifier must be written to a specific SPC3 buffer, the Read Config Buffer, by the central processing unit during SPC3 initialization. The starting address of this buffer is stored by the organization parameter R_Read_Cfg_Buf_Ptr, and the buffer length is defined by R_Len_Read_Cfg_Data. This is also for remote master station querying. The identifier must also be specified in the GSD file, with the following statement format: Module = "2 Bytes Input and Output" 0x31 EndModule. These two bytes contain the data exchanged between the master station and the valve controller, so they should include the valve control commands and the valve status. Based on the requirements of valve control and the function of the valve, this design defines the structure of these two bytes. The structure is as follows: [align=center] Figure 3 Data Exchange First and Second Bytes[/align] As shown in the figure, in the first byte of data exchange, bits 0 and 1 define the valve control command. When the valve controller receives data from the master station, it will analyze these two bits of the first byte and drive the valve to perform the corresponding action based on their contents. The remaining bits are valid when the master station reads the status of the valve controller. Bits 2 and 3 indicate whether the valve has reached the limit position of closed and open, bits 4 and 5 indicate the current movement state of the valve, and bit 7 indicates the current control mode of the valve controller. The control mode is determined by the highest bit of the address DIP switch mentioned above, and its meaning is consistent. In the second byte of data exchange, bits 0 to 6 store the valve opening degree, with a value range of 0 to 100, where 100 represents fully open and 0 represents fully closed. When the master station reads this value from the valve controller, it indicates the current valve opening degree; when the master station sends a certain value to the valve controller, it indicates that the valve is required to open to that value. Bit 7 is reserved. 5. Use of Diagnostic Functions Diagnostic functions refer to the capabilities defined in the PROFIBUS-DP specification, allowing a master station to read error and status information from the slave stations it controls. This is a separate function from data exchange, occurring during data exchange intervals and initiated by the master station. Within the existing definitions of the PROFIBUS-DP specification, the master station can diagnose communication errors and status information from slave stations, such as slave stations failing to reach the bus or providing unreasonable responses. In addition, the PROFIBUS-DP specification allows users to use extended diagnostic information. By extending the diagnostic information, users can program their own product-defined error and status information. This allows PROFIBUS-DP product designers to utilize the reliable and optimized communication capabilities provided by PROFIBUS-DP to meet specific user requirements, a necessary step. Therefore, diagnostic information design is a crucial part of PROFIBUS-DP product design. Diagnostic information consists of two parts: standard PROFIBUS-DP diagnostic information and extended diagnostic information. The former is the mandatory part of the diagnostic information, consisting of a fixed 6 bytes, storing the standard error and status information defined in the PROFIBUS-DP specification. The latter is set by the user according to the requirements of their developed product, and it can be divided into three levels of diagnostics: diagnostics about the device, diagnostics about the identifier, and diagnostics about the channel. These three levels of diagnostics are divided into three byte blocks arranged sequentially in the extended diagnostics section, with each part having its own specific header byte as the start marker for that level of diagnostics. The valve controller in this design uses the first level of extended diagnostics, which is the diagnostics about the device. Specifically, on the SPC3 chip used in this design, a dedicated buffer is first allocated for diagnostic information during SPC3 initialization. There are two buffers, with four organization parameters defining them: R_Diag_Buf_Ptr1 and R_Diag_Buf_Ptr2 store the starting addresses of the two diagnostic buffers, and R_Len_Diag_buf1 and R_Len_Diag_buf2 define the lengths of the two buffers. Different lengths of the two buffers are allowed. When the diagnostic function is needed, generally when the valve controller has experienced a certain event that requires notification to the master station, the diagnostic information is filled into the user-held buffer. The first 6 bytes of the buffer, which represent the first 6 bytes of diagnostic information, are standard diagnostic information. Users generally don't need to assign values to these, except for the last bit (bit 0) of the first diagnostic byte, which needs to be set to 1 by the user. This bit is the "extended diagnostic bit," and setting it to 1 indicates that extended diagnostics follow the 6 bytes of standard diagnostics. This bit must be set in all designs using extended diagnostics. The 7th byte is the header byte for the first level of extended diagnostics regarding device diagnostics. The highest two bits of the header byte are fixed at 00, and the last 6 bits store the block length of the device diagnostics, which includes the header byte itself and ranges from 2 to 63. This design's valve controller has relatively few diagnostic events, requiring only 1 byte to store the device diagnostic information, so the block length for device diagnostics is 2 bytes. The final length of the valve controller's diagnostic information is 8 bytes: "6 bytes of standard diagnostics + 1 byte of header + 1 byte of device diagnostics". The allocation of the 8 bits of the device diagnostic byte is as follows: bit0 corresponds to the valve motor phase loss event, bit1 corresponds to the valve over-torque event, and setting a bit to 1 indicates that the corresponding event has occurred; bits2 to 5 contain certain error codes, and the events corresponding to these four error codes are as follows: 0000 No error 0001 Insufficient working voltage 0010 Abnormal AD acquisition 0011 Abnormal local display 0100 Control conflict 0101 Control command error 0110~1111 Reserved In order to implement the above device diagnostic byte allocation, in addition to the valve controller user program correctly processing the correct bits when the corresponding event occurs, the following statements are also required in the valve controller device description file GSD file: Unit_Diag_Bit (0) = "Lack power" Unit_Diag_Bit (1) = "Over-moment" The above two statements allocate bit0 and bit1 to the corresponding events. Unit_Diag_Area = 2-5 Value (0) = "No error" Value (1) = "Low voltage" Value (2) = "AD error" Value (3) = "Display error" Value (4) = "Control conflict" Value (5) = "Command error" Unit_Diag_Area_End The above statements assign bits 2 to 5 to the corresponding error codes. This completes the design of the valve controller diagnostic information. 6. Conclusion The purpose of this design is to effectively combine the industrial fieldbus PROFIBUS-DP technology with the actual requirements of valve control engineering, highlighting practicality and meeting the requirements of technological updates in the valve control field. It has been proven that remote and networked valve control is an important development trend, and the application of fieldbus technology in this field is indeed feasible. References [1] Siemens AG..SPC3 and DPS2 User Description. Siemens AG in Fed Rep of Germany. 1998. [2] Yang Xianhui (ed.). Fieldbus Technology and Its Applications [M]. Beijing: Tsinghua University Press, 1998. [3] Wang Fulai, Wu Shihong et al. Development of Intelligent PROFIBUS-DP Fieldbus Interface Using SPC3 [J]. Electrical Drive, 2000, 2.