Device for simulating high-rate communication of Profibus master station and implementation method
By designing an analog Profibus master device including MCU and RS-485 transceiver, the problems of unstable, high cost and low test efficiency of high baud rate communication in the prior art are solved, and efficient and low-cost high-speed communication of Profibus-DP master is achieved.
Patent Information
- Application Number
- CN202510174063.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2045-02-18
AI Technical Summary
The prior art is difficult to realize high-speed communication of Profibus-DP master stations at high baud rates, resulting in unstable communication, high cost and low testing efficiency.
A device that simulates high-speed communication of Profibus main station is designed, including an MCU controller module, an RS-485 transceiver module, an RS-232 communication interface module and a Flash memory module. By optimizing hardware design and the Profibus message sending control process, it supports a data transmission rate of up to 12Mbps.
It enables communication with other devices on the Profibus-DP bus at a maximum rate of 12Mbps, significantly reducing development and testing costs, improving testing efficiency, and reducing message errors.
Smart Images

Figure CN119676026A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of industrial automation field bus communication, and particularly relates to a device and a realization method for simulating high-speed communication of a Profibus master station. Background Art
[0002] Profibus is an international fieldbus standard for factory automation and process automation. It is widely used in the field of factory automation and process automation production. It is an open digital communication system with a wide range of applications, suitable for various communication tasks with fast speed, strict time requirements and high reliability requirements. The essence of Profibus network communication is RS485 serial port communication. According to different industry applications, there are three main communication rules: DP (Decentralized Peripherals), FMS (Field Message Specification) and PA (Process Automation) rules.
[0003] Profibus DP (distributed I / O) is a communication network for field level, which complies with IEC 61158-2 / EN 61158-2 standard and adopts mixed access protocol of token bus and master / slave. Networking is carried out through a pair of twisted pair or optical cable, which can achieve data transmission rate of 9.6kbps to 12Mbps.
[0004] In the development and testing of Profibus-DP equipment, Profibus communication cards are usually used, such as Siemens CP5611 communication card, which is installed in the PCI slot of the PC, so that the PC can act as the Profibus master station and communicate with the slave station equipment. However, the above method is not only inconvenient to use, but also has high investment costs (a Profibus communication card costs several thousand yuan). In addition, it is inconvenient for manufacturers to test modules with such communication functions, and the test is slow, inefficient, and costly.
[0005] Existing patents and literature mainly focus on using a computer with an RS232 serial communication port and an adapter from the RS232 port to the RS485 port to implement a test device that simulates Profibus-DP master station communication. However, although there are computers with RS232 serial communication ports on the market, their communication rate is often only 115200bps, which cannot reach 12Mbps. Another method is to use the USB interface of the PC with a USB to RS485 converter to simulate the Profibus-DP master station. However, even if the communication rate of the USB to RS485 converter can reach 12Mbps and the PC serial port can be configured to 12Mbps, it has been found through actual measurements that when the serial port is configured to a high rate (1.5Mbps and above), the Profibus message sent by the converter will not be recognized by the Profibus-DP slave device and will be considered as dirty data. By observing the waveform with an oscilloscope, it is found that between each byte of a message, in addition to the even parity bit, stop bit of the previous byte and the start bit of the next byte, there will be an idle state of about 400ns after the stop bit (corresponding to the binary "1" signal). There should be only even parity bits, stop bits and start bits between each byte of the Profibus message, and there should be no idle state. At low rates (500Kbps and below), it can be ignored relative to Tbit (transmission time per bit), for example, 1 / 500K=2μs, but when it reaches a high rate, the idle state cannot be ignored relative to Tbit, for example, 1 / 1.5M≈666.7ns, which will cause deviations in the bit information of the entire message and extend the transmission time of the entire message (the extension time is about the number of message bytes × 400ns), so that it will not be recognized as a Profibus message by the devices on the Profibus-DP bus, and the dirty data will be directly discarded. Further testing found that the idle state has nothing to do with the USB to RS485 converter. It is because the PC needs to add a start bit, an even parity bit, and a stop bit to each byte sent, and the serial port data processing task cannot keep up. It needs to calculate while sending messages, resulting in an idle state between each byte. Therefore, it is not feasible to use the PC's serial port to simulate the Profibus master station at a high baud rate. Summary of the invention
[0006] The present invention provides a device and an implementation method for simulating high-speed communication of a Profibus master station, which can communicate with other devices on the bus at a maximum rate of 12Mbps, and can effectively reduce the development and testing costs of Profibus-DP devices according to user-specified content, and can significantly improve production test efficiency.
[0007] To achieve the above-mentioned purpose, the technical solution of the present invention is: a device for simulating high-speed communication of a Profibus master station, comprising: an MCU controller module, an RS-485 transceiver module, an RS-232 communication interface module and a Flash memory module; the MCU controller module is connected to an external Profibus-DP bus through the RS-485 transceiver module, and is connected to a PC through the RS-232 communication interface module; the communication rate of the RS-485 transceiver and the UART interface of the MCU support a data transmission rate of up to 12Mbps; a user can select a transmission rate, a source address, a destination address, a message type and input the required message data field through the configuration software installed on the PC; the MCU records the message data recently sent by the user and the reply data of the slave station through the Flash storage module, so that the user can view the communication records.
[0008] The implementation method of the present invention comprises the following steps: Step 1: The UART interface of the MCU controller is connected to the RS-485 transceiver, and the RS-485 transceiver expands the Profibus-DP bus interface and connects to the Profibus slave station; another UART interface of the MCU is connected to the RS-232 module, and the RS-232 module is connected to the PC; the MCU is connected to the Flash chip through the SPI peripheral.
[0009] Step 2: The user inputs the Profibus rate, message type, source address, destination address and message data content through the Profibus master station configuration software; after the user clicks "single send" or "continuous send", the configuration software sends the information to the MCU through the Config interface.
[0010] Step 3: MCU adjusts the baud rate of USART1 to the user-specified rate and generates a Profibus message based on the source address, destination address and message type.
[0011] Step 4: The MCU switches the RS-485 transceiver to the sending mode, and sends the message to the Profibus-DP bus through the USART1 interface, and stores the sending time and message data in the Flash chip.
[0012] Step 5: After the MCU completes the message transmission, it switches the RS-485 transceiver to the receiving mode and listens to the Profibus-DP bus; if a reply is received from the slave station, the reply time and data are stored in the Flash chip; when the user clicks "Historical Send Data" or "Receive Data Record", the MCU transmits the Flash storage data to the PC through the USART2 interface for the user to view.
[0013] The technical effects of the present invention are: First, the present invention can perform Profibus-DP master station communication at a maximum rate of 12Mbps, solving the problem that the analog Profibus-DP master station in the prior art can only communicate at a low baud rate, so that it can meet the demand for high-speed communication. This significantly improves communication efficiency and meets the demand for high-speed communication of modern industrial automation equipment.
[0014] Secondly, the present invention reduces development and testing costs: compared with traditional Profibus communication cards (such as Siemens CP5611), the present invention uses MCU and RS-485 transceiver to implement the function of Profibus-DP master station, without the need for additional expensive hardware support. This greatly reduces the development and testing costs, allowing developers and manufacturers to develop and test equipment more economically.
[0015] Thirdly, the present invention improves the test efficiency: the prior art generally adopts a lower rate or uses an adapter, but these methods cannot effectively simulate the Profibus-DP master station at a high baud rate. The present invention can accurately send high-rate Profibus messages through optimized hardware design and Profibus message sending control flow, and can be recognized by the slave station without generating dirty data, thereby significantly improving the test efficiency.
[0016] Then, the present invention reduces message errors: In the design of the present invention, by optimizing the clock source of the MCU and the message sending process, the message error caused by the idle state of the serial port in the existing USB to RS485 converter is eliminated. Through precise clock configuration and control, it is ensured that there is no idle state between each byte when sending the Profibus message, thereby avoiding the deviation of the message information.
[0017] Finally, the present invention is easy to use. By providing an RS-232 interface to connect to a PC, users can conveniently set parameters such as transmission rate, address, and message content through a PC-side configuration tool without having to learn additional complex Profibus-DP bus network configuration. This design simplifies user operations and improves the convenience of production and testing.
[0018] Through the above improvements, the present invention overcomes the problems of unstable communication, high cost and low test efficiency in the prior art at high baud rates, and provides an efficient, low-cost and easy-to-operate solution for the development and testing of industrial automation equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a circuit structure block diagram for implementing the present invention; Figure 2It is the schematic diagram of the MCU circuit of the present invention; Figure 3 The power supply circuit diagram of the present invention; Figure 4 It is the principle diagram of the RS-485 transceiver and Profibus bus interface circuit of the present invention; Figure 5 It is a schematic diagram of the Profibus bus interface of the present invention; Figure 6 It is a schematic diagram of differential signals transmitted on the Profibus bus of the present invention; Figure 7 It is the schematic diagram of the RS-232 chip and configuration interface circuit of the present invention; Figure 8 This is the schematic diagram of the external NOR FLASH circuit of the present invention; Fig. 9 It is the single-byte format of the Profibus message of the present invention; Fig.10 It is the interface of the configuration tool for simulating the Profibus-DP master station on the PC side of the present invention; Fig.11 It is the frame format of the data link layer specified by the Profibus protocol of the present invention; Fig.12 It is a flow chart of the MCU of the present invention sending a Profibus message by byte; Fig.13 The present invention queries the simulated Profibus-DP master station historical transmission data interface; Fig.14 The present invention queries and simulates the Profibus-DP master station receiving data recording interface. DETAILED DESCRIPTION
[0020] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0021] The purpose of the present invention is to provide a device and implementation method for simulating high-speed communication of a Profibus master station, which can achieve the highest rate of 12Mbps of the Profibus network and solve the problem that the simulated Profibus-DP master station in the prior art can only communicate at a low baud rate.
[0022] like Figure 1As shown, the device for simulating high-speed communication of the Profibus master station includes: an MCU controller module, an RS-485 transceiver module, an RS-232 communication interface module, and a Flash memory module; the UART interface of the MCU controller is connected to the RS-485 transceiver module, converts the TTL level signal output by the UART peripheral into a differential RS-485 level signal, and is externally connected to the Profibus-DP bus, and can be connected to the Profibus-DP slave station. The communication rate of the RS-485 transceiver and the rate supported by the UART interface of the MCU can reach at least 12Mbps; another set of UART interfaces of the MCU is connected to the RS-232 interface module chip, converts the TTL level signal output by the UART peripheral into an RS-232 level signal, so that the MCU can establish communication with the PC, and the user can select the transmission rate, source address, destination address, message type, and input the required message data field in the configuration software installed on the PC; the MCU is connected to the Flash memory module, and communicates with the Flash chip through the SPI protocol, which is used to store the message data recently sent by the user and the data replied by the slave station, so that the user can view the records.
[0023] MCU controller module: As the core control unit, MCU is responsible for generating Profibus-DP protocol messages, managing communication parameters, and processing data transmission and reception. It ensures high-precision timing control through an internal clock to ensure reliable data transmission.
[0024] RS-485 transceiver module: This module realizes the conversion between TTL signal and differential signal, supports communication rate up to 12Mbps, and ensures the stability and anti-interference ability of the signal during long-distance transmission. It is responsible for sending data and receiving signals from the Profibus bus.
[0025] RS-232 communication interface module: used for communication between MCU and PC, providing a convenient configuration and monitoring interface. This module allows users to modify communication parameters in real time through configuration software and obtain system operation status and historical data.
[0026] Flash memory module: used to store historical sent and received data to ensure data traceability and reliability. Users can query stored records at any time to facilitate subsequent analysis and troubleshooting.
[0027] like Figure 2As shown, the MCU controller module mainly includes a controller chip of model STM32F722RET6, whose circuit is connected to a high-speed external clock signal HSE to provide a more accurate and stable clock source. HSE is provided by an 8MHz passive crystal oscillator X1 with resonant capacitors C3, C4 and resistor R2; the specific connection method is: after the passive crystal oscillator X1 is connected in parallel with the resistor R2, the two ends are respectively connected to the OSC_IN (Pin5) and OSC_OUT (Pin6) of the MCU, and are grounded (GND) through capacitors C3 and C4 respectively; the system clock SYSCLK source selects HSE, and after the phase-locked loop PLL multiplication, it is configured to a maximum of 216MHz, so as to ensure that the baud rate of the serial port USART1 for sending and receiving Profibus messages is more accurate, which can be configured to a maximum of 27Mbit / s. The low-speed external clock signal LSE can provide a low-speed but high-precision clock source for the real-time clock component (RTC); in order to realize the real-time clock function, the external clock signal LSE of the MCU is connected to a 32.768KHz passive crystal oscillator X2 to provide a low-speed and high-precision clock source, and the resonant capacitors C1 and C2 generate the signal; the specific connection method is: the two ends of the passive crystal oscillator X2 are respectively connected to the MCU's OSC32_IN (Pin3) and OSC32_OUT (Pin4), and are grounded (GND) through capacitors C1 and C2 respectively. In order to minimize the distortion of the clock output and shorten the startup stabilization time, X1 and C3, C4, and R2 must be placed as close as possible to OSC_IN (Pin5) and OSC_OUT (Pin6), and X2 and C1, C2 must be placed as close as possible to OSC32_IN (Pin3) and OSC32_OUT (Pin4). The real-time clock circuit RTC supports a calendar with year, month, day, hour, minute, and second in BCD (binary coded decimal) format, which can record the time when an event occurs. The RTC is powered from the VBAT pin (Pin1). Figure 3 As shown, the VBAT pin is connected to the positive electrode of the rechargeable lithium-ion battery BT1. Even in the case of power failure, the RTC can keep working to achieve time synchronization, and is connected to the 3.3V external power supply through the diode VD1. A resistor R8 is connected in series between VD1 and 3V3_BAT, and the 3.3V power supply is connected through parallel capacitors C7, C8, C9, C10, C11, and C12, so that the simulated Profibus master station device can charge the lithium battery when powered on, and the lithium battery will supply power to VBAT after power failure.
[0028] The Profibus network is built based on the RS485 serial communication standard and uses half-duplex mode for data exchange. The RS485 transmission method defined by EIA is the most common communication method in the Profibus system because it has high reliability and anti-interference ability in industrial automation applications. The network uses a shielded twisted pair cable to transmit signals in a balanced differential transmission mode, which effectively reduces noise interference during transmission. The transmission rate of the Profibus network can be flexibly selected between 9.6Kbit / s and 12Mbit / s, depending on the application requirements and network load. The network topology adopts a linear structure, and all devices on the bus use the same transmission rate to ensure the synchronization and stability of data transmission; in a single network segment, up to 32 devices can be connected, including master devices and slave devices. If more than 32 devices need to be connected in the application, or the bus length needs to be extended due to the long wiring distance, RS485 repeaters can be used in the network to achieve segment expansion, thereby building a larger-scale Profibus network. The maximum bus length allowed for each network segment is closely related to the transmission rate. The higher the rate, the shorter the maximum achievable bus length is usually. Therefore, when designing a Profibus network, it is necessary to reasonably select the transmission rate and network topology based on the number of devices and wiring distance to ensure the reliability and efficiency of the system.
[0029] Since the Profibus interface is an RS-485 serial port, the MCU performs signal level conversion by connecting to the RS-485 transceiver. The specific connection relationship between the MCU and the RS-485 transceiver is as follows: Figure 2 and Figure 4 As shown. The RS-485 transceiver's pins DE (Pin6) and RE# (Pin5) are connected to one of the MCU's GPIO pins PA8 (Pin41), the pin TxD (Pin7) is connected to the MCU's USART1_TX, namely PA9 (Pin42), and the pin RxD (Pin4) is connected to the MCU's USART1_RX, namely PA10 (Pin43). In addition, the RS-485 transceiver is connected to an external Profibus bus interface, the pin Y (Pin13) is connected to the Profibus bus interface's Pin3, and the pin Z (Pin15) is connected to the Profibus bus interface's Pin8. As shown Figure 5 As shown, its pins are defined as:
[0030] Pin 3 is connected to the signal line B of the Profibus cable, and pin 8 is connected to the signal line A of the cable. A resistor R5 is connected in series between pins 3 and 8. Generally, only pins 3 and 8 need to be connected, and the other pins of the interface can be left idle.
[0031] During transmission, a binary "1" corresponds to a positive potential on the RXD / TXD-P (Receive / Transmit-Data-P) line, and vice versa on the RXD / TXD-N line. The idle state between messages corresponds to a binary "1" signal, such as Figure 6 shown.
[0032] In order to facilitate information exchange between users and the Profibus master station, the message sent by the Profibus master station is formed according to the actual needs of the user and sent to the specified address. Therefore, the MCU is connected to the RS-232 chip and the Config interface is externally introduced to support users to configure through the PC. The specific connection relationship between the MCU and the RS-232 chip is as follows Figure 2 , Figure 7 As shown. The pin T1IN (Pin11) of the RS232 chip is connected to the USART2_TX: PA2 (Pin16) of the MCU; the pin R1OUT (Pin12) is connected to the USART2_RX: PA3 (Pin17) of the MCU; the MCU and the RS-232 chip share the same ground. The RS-232 chip is connected to the RS-232 interface externally, that is, the interface (Config) of the PC configuration Profibus master. The pin T1OUT (Pin14) is connected to the TXD (Pin2) of the Config interface; the pin R1IN (Pin13) is connected to the RXD (Pin3) of the Config interface; the pin GND (Pin15) is connected to the GND (Pin5) of the Config interface. VD2 is a TVS tube that protects the circuit from transient high-voltage spike pulses (such as electrostatic discharge, lightning surge, etc.). R5 is the terminal resistor of the Profibus bus, which can eliminate signal reflections in the communication cable. VD2 and R5 should be placed close to the interface XS1.
[0033] The Config interface is an RS-232 serial port, which generally uses a DB9 nine-hole female connector. Figure 5 As shown. Generally, only pins 2 (TXD), 3 (RXD), and 5 (GND) are used. Users can connect the COM port of the PC through the Config interface, or connect to the USB interface of the PC through the USB to RS-232 serial port data cable, so that the MCU can establish communication with the PC. F1 and F2 are self-recovery fuses, which should be placed close to the interface XS2. The tripping current is 300mA, which plays a role in protecting the internal circuit and avoiding damage to components caused by users mistakenly connecting high voltage or high current external signals.
[0034] In order to store and record the Profibus messages sent historically and the messages received from other devices on the bus, an external NOR FLASH is used to connect the MCU. The specific connection relationship between the MCU and the Flash chip is as follows: Figure 2 , Figure 8 As shown. Its pin CS# (Pin1) is connected to the MCU's SPI1_NSS: PA4 (Pin20); the pin CLK (Pin6) is connected to the MCU's SPI1_SCK: PA5 (Pin21); the pin DO (IO1) (Pin2) is connected to the MCU's SPI1_MISO: PA6 (Pin22); the pin DI (IO0) (Pin5) is connected to the MCU's SPI1_MOSI: PA7 (Pin23).
[0035] According to the Profibus protocol, the transmission procedure for Profibus RS-485 is based on half-duplex, asynchronous, gapless synchronization. Each frame consists of several frame characters (UART characters), which expand an 8-bit character into 11 bits, namely NRZ (non-return to zero) code: First is a start bit (ST), which is always binary "0". Then there are 8 information bits, which can be "0" or "1". After that is a parity bit (P), which is binary "0" or "1" (specified as even parity). Finally, there is a stop bit (SP), which is always binary "1", and its structure is as follows: Fig. 9 When a bit is transmitted, the signal shape does not change during the transition from binary "0" to "1".
[0036] First, you need to initialize the GPIO pins of the MCU. Figure 2 The corresponding pins used in the multiplexing are USART1 / USART2 / SPI1, and then USART1 is configured to 8 data bits, 1 stop bit, even parity bit, and the baud rate is a modifiable parameter, depending on the value selected by the user. USART2 is configured to a baud rate of 115200bps, 8 data bits, 1 stop bit, no parity bit, and the communication parameters of the configuration tool on the PC are consistent. The USART clock source is the system clock frequency (up to 216MHz), and 8 times oversampling is used. Switch the RS-485 transceiver to the receiving state, that is, configure PA8 (Pin41) to GPIO push-pull output mode, and output low level, listen to the Profibus-DP bus, if a data frame sent by the slave is received, it will be recorded and written into NOR FLASH together with the current time.
[0037] The user runs the simulated Profibus-DP master station configuration tool on the PC. The configuration software interface is as follows Fig.10As shown in the figure, enter the Profibus master station rate, message type, source address, destination address, and specific data content of the message in the configuration software. When the user clicks "Single Send" or "Continuous Send", the configuration software passes the information entered by the user to the MCU through the Config interface. After the MCU receives the data from the USART2 interface, it changes the baud rate of USART1 to the communication rate selected by the user, and forms the corresponding Profibus message according to the specified data frame format based on the source address, destination address, message type and content, and refers to the Profibus protocol, and writes the relevant information including the real-time time record sent to the Flash chip.
[0038] According to the Profibus protocol, the frame format of the data link layer is as follows Fig.11 shown.
[0039] in: SYN synchronization time, minimum 33 line idle bits; SD1 to SD4 start delimiters, distinguishing different types of frame formats; SD1=0x10, SD2=0x68, SD3=0xA2, SD4=0xDC; LE / LEr 8-bit group length, usually LE=LEr, the allowed value is 4 to 249; DA destination address, indicating the station receiving the frame; SA source address, indicating the station that sent the frame; FC frame control byte, containing detailed description of the frame service and priority, etc.; DATA_UNIT data field, containing valid data information; FCS frame check byte, the sum of all frame characters without carry; ED frame end delimiter (16H); SC single character (E5H), used in short response frame; L Information field length.
[0040] The transmission rules for fixed-length frames with / without data fields and token frames are as follows: these frames include both active frames and response / answer frames. When in the online idle state, the signal level is equivalent to binary "1"; there is no idle bit between characters in the frame. The gaps before the frames of active frames and response / answer frames are slightly different. Each active frame header has at least 33 synchronization bits, that is, before each communication handshake message is established, an idle state of at least 33 bits must be maintained (binary 1 corresponds to a level signal). These 33 synchronization bits are used as the frame synchronization time interval, called the synchronization bit SYN. There is no such regulation before the response and answer frames. The response time depends on the system settings and the receiver inspection.
[0041] Frames with variable data field length have the following additions in addition: LE shall be equal to LEr; the number of information octets shall be counted from the destination address (DA) to the frame check sequence (FCS) (excluding the FCS), and this result shall be compared with LE.
[0042] There are also some differences between response frames and answer frames. A response frame refers to a frame without a data field (DATA_UNIT) in the response frame from the slave station to the master station, while an answer frame refers to a frame with a data field (DATA_UNIT) in the response frame. In addition, the short response frame is only used for response, and it is a simple form of a frame with a fixed length without a data field.
[0043] After the MCU calculates the frame length and frame check byte and forms the corresponding Profibus message, it switches the RS-485 transceiver to the sending state, that is, PA8 (Pin41) is configured to output a high level, and sends it to the RS-485 transceiver through the USART1 interface, and then sends it to the Profibus-DP bus. If the user selects "single transmission", the message can be sent once; if "continuous transmission i times" is selected, after each message is sent, i is reduced by 1, and the delay is specified until i=0.
[0044] The function for sending a single message by byte can be referred to as follows: void USART1_SendMsg(const void* buffer,uint16_t Lenth) { const unsigned char *p =(unsigned char *)buffer; for(int m = 0; m <Lenth;m++) { HAL_UART_Transmit(&huart1,(p+m),1,1000); } } Where buffer is the Profibus message array, and Lenth is the message length. The process of the MCU's peripheral UART sending a message by byte is as follows: Fig.12 The specific steps include the sending and receiving process of serial communication: a.Serial port sending process: a1. Initialization completed: After the initialization process of serial communication is completed, the sending process begins.
[0045] a2. Prepare to send data and call send: The serial port sending module prepares the data and calls the send function.
[0046] a3. Check if the send register is empty: -If the send register is empty, it means that new data can be sent and proceed to the next step.
[0047] - If the transmit register is not empty, wait for it to be cleared.
[0048] a4. Send next character: Send the next character in the data to the send register.
[0049] a5. Clear the sending flag: Clear the sending flag to detect the sending status of the next data.
[0050] a6. Check whether the sending is completed: -If the sending is not completed, return to step 3 and continue sending the next character.
[0051] -If the sending is completed, it enters the sending end state.
[0052] a7.End sending: The sending process is completed and the current sending task is ended.
[0053] b. Serial port receiving process b1. Initialization completed: After the initialization process of serial communication is completed, it enters the receiving process.
[0054] b2. Is the receiving buffer empty? -If the receiving buffer is empty, it means there is no new data and you need to wait for the next data.
[0055] - If the receive buffer is not empty, proceed to the next step.
[0056] b3. Serial port interrupt reception: trigger the serial port reception interrupt and read the received data from the hardware buffer into the software reception buffer.
[0057] b4. Write to receive buffer: Write the received data into the specified receive buffer for subsequent processing.
[0058] b5. Clear the receive flag: Clear the receive flag to prepare for receiving the next data.
[0059] b6. End receiving: The receiving process is completed and the current receiving task ends.
[0060] After the MCU sends the message, it switches the RS-485 transceiver back to the receiving state, that is, PA8 (Pin41) is configured to output low level, listen to the Profibus-DP bus, and if a reply frame is received from the slave station, it is written into NORFLASH together with the current time record. If the user clicks "Historical Send Data" or "Receive Data Record", the MCU reads the content stored in the Flash chip and sends it to the PC through the USART2 interface for the user to view. The historical send data and receive data record interfaces are as follows: Fig.13 , Fig.14 As shown in the figure, message types 1, 2, 3, 4, and 5 correspond to SD1, SD2, SD3, SD4, and short response frames, respectively. In this way, a device simulating a Profibus master station can be realized, and it can communicate with other devices on the bus at any agreed rate and user-specified content.
[0061] The implementation method of the device for simulating high-speed communication of a Profibus master station of the present invention specifically comprises the following steps: Step 1: The UART interface of the MCU controller is connected to the RS-485 transceiver, and the RS-485 transceiver expands the Profibus-DP bus interface to the Profibus-DP slave. The other UART interface of the MCU is connected to the RS-232 chip, and the RS-232 chip expands the Config interface to the PC. The MCU is connected to the Flash chip through the SPI peripheral.
[0062] Step 2: The user enters the Profibus master rate, message type, source address, destination address, and specific data content of the message in the simulated Profibus-DP master configuration tool. When the user clicks "Single Send" or "Continuous Send", the configuration software sends the information entered by the user to the MCU through the Config interface.
[0063] Step 3: After receiving the corresponding information, MCU changes the baud rate of USART1 to the communication rate selected by the user, and composes the corresponding Profibus message according to the specified data frame format in reference to the Profibus protocol based on the source address, destination address, message type and content.
[0064] Step 4: MCU switches the RS-485 transceiver from receiving state to sending state, sends it to the RS-485 transceiver through the USART1 interface, and then sends it to the Profibus-DP bus. And the MCU writes the relevant information including the real-time time record sent to the Flash chip.
[0065] Step 5: After the MCU sends the message, it switches the RS-485 transceiver back to the receiving state and listens to the Profibus-DP bus. If it receives a reply frame from the slave station, it writes it into the NOR FLASH together with the current time record. When the user clicks "Historical Send Data" or "Receive Data Record", the MCU reads the content stored in the Flash chip, sends it to the PC through the USART2 interface, and displays it in the simulated Profibus-DP master station configuration tool for easy viewing by the user.
Claims
1. A device for simulating high-speed communication of a Profibus master station, characterized in that: include: MCU controller module, RS-485 transceiver module, RS-232 communication interface module and Flash memory module; the MCU controller module is connected to an external Profibus-DP bus through the RS-485 transceiver module, and is connected to a PC through the RS-232 communication interface module; the communication rate of the RS-485 transceiver and the UART interface of the MCU support a data transmission rate of up to 12Mbps; the user can select the transmission rate, source address, destination address, message type and input the required message data field through the configuration software installed on the PC; the MCU records the message data recently sent by the user and the reply data from the slave station through the Flash storage module, so that the user can view the communication records.
2. The device for simulating high-speed communication of a Profibus master station according to claim 1, characterized in that: The MCU controller module includes a controller chip of model STM32F722RET6, and is externally connected to a high-speed clock signal HSE and a low-speed external clock signal LSE; the HSE provides a high-frequency clock signal to improve system performance and support high-speed peripheral operation, and the LSE provides a low-frequency clock signal for low-power mode and precise time timing; the HSE includes an 8MHz passive crystal oscillator X1, resonant capacitors C3, C4 and a resistor R2, X1 and R2 are connected in parallel, respectively connected to the OSC_IN and OSC_OUT ports of the MCU, and grounded through capacitors C3 and C4; the LS E includes a 32.768KHz passive crystal oscillator X2, resonant capacitors C1 and C2, two ends of X2 are respectively connected to the OSC32_IN and OSC32_OUT ports of the MCU, and are grounded through C1 and C2; the X1, C3, C4, and R2 are located near the OSC_IN and OSC_OUT ports, and the X2, C1, and C2 are located near the OSC32_IN and OSC32_OUT ports; the VBAT pin of the MCU is connected to the positive electrode of the lithium-ion battery BT1, and is connected to a 3.3V power supply through a diode VD1 to power the real-time clock circuit RTC.
3. The device for simulating high-speed communication of a Profibus master station according to claim 2, characterized in that: The MCU performs signal level conversion through the RS-485 transceiver module; the DE and RE# pins of the RS-485 transceiver are connected to the GPIO pin PA8 of the MCU, the TxD pin is connected to the PA9 of the MCU, and the RxD pin is connected to the PA10 of the MCU; the pins Y and A of the RS-485 transceiver module are connected to Pin3 of the Profibus bus interface, the pins Z and B are connected to Pin8, Pin3 is connected to the Profibus cable signal line B, and Pin8 is connected to the signal line A; the terminal resistor R5 and the TVS tube VD2 are connected between Pin3 and Pin8, and VD2 and R5 are located near the Profibus bus interface XS1.
4. The device for simulating high-speed communication of a Profibus master station according to claim 2, characterized in that: The MCU is connected to the Config interface of the external PC through an RS-232 module; pin T1IN of the RS-232 module is connected to PA2 of the MCU, pin R1OUT is connected to PA3 of the MCU, and the MCU and RS-232 chip share a common ground; T1OUT of the RS-232 module is connected to TXD of the Config interface through a resettable fuse F1, R1IN is connected to RXD of the Config interface through a resettable fuse F2, pin GND is connected to GND of the Config interface, and F1 and F2 are placed close to the Config interface XS2 to protect the internal circuit.
5. The device for simulating high-speed communication of a Profibus master station according to claim 2, characterized in that: The MCU is externally connected to a NOR Flash chip for storing historically sent Profibus messages and received message data; the CS# pin of the Flash chip is connected to PA4 of the MCU, the CLK pin is connected to PA5 of the MCU, the DO pin is connected to PA6 of the MCU, and the DI pin is connected to PA7 of the MCU.
6. A method for realizing the high-speed communication device for simulating a Profibus master station according to any one of claims 1 to 5, characterized in that: The following steps are involved: Step 1: The UART interface of the MCU controller is connected to the RS-485 transceiver, and the RS-485 transceiver expands the Profibus-DP bus interface and connects to the Profibus slave station; another UART interface of the MCU is connected to the RS-232 module, and the RS-232 module is connected to the PC end; the MCU is connected to the Flash chip through the SPI peripheral; Step 2: The user enters the Profibus rate, message type, source address, destination address and message data content through the Profibus master station configuration software; after the user clicks "single send" or "continuous send", the configuration software sends the information to the MCU through the Config interface; Step 3: MCU adjusts the baud rate of USART1 to the user-specified rate, and generates a Profibus message according to the source address, destination address and message type; Step 4: The MCU switches the RS-485 transceiver to the sending mode, and sends the message to the Profibus-DP bus through the USART1 interface, and stores the sending time and message data in the Flash chip; Step 5: After the MCU completes the message transmission, it switches the RS-485 transceiver to the receiving mode and listens to the Profibus-DP bus; if a reply is received from the slave station, the reply time and data are stored in the Flash chip; when the user clicks "Historical Send Data" or "Receive Data Record", the MCU transmits the Flash storage data to the PC through the USART2 interface for the user to view.
7. The method for implementing the simulated Profibus master station high-speed communication device according to claim 6, characterized in that: The process of the MCU's peripheral UART sending a message by byte includes the sending and receiving process of serial communication, and the specific steps are as follows: a.Serial port sending process: a1. Initialization completed: After the initialization process of serial communication is completed, the sending process begins; a2. Prepare to send data and call send: the serial port sending module prepares the data and calls the send function; a3. Check if the send register is empty: If the send register is empty, it means that new data can be sent and proceed to the next step; If the send register is not empty, wait for it to be cleared; a4. Send next character: Send the next character in the data to the send register; a5. Clear the sending flag: clear the sending flag to detect the sending of the next data; a6. Check whether the sending is completed: If the sending is not completed, return to step a3 and continue to send the next character; If the sending is completed, it enters the sending end state; a7. End sending: the sending process is completed, and the current sending task ends; b. Serial port receiving process: b1. Initialization completed: After the initialization process of serial communication is completed, the receiving process begins; b2. Check whether the receive buffer is empty: If the receiving buffer is empty, it means there is no new data and you need to wait for the next data; If the receive buffer is not empty, proceed to the next step; b3. Serial port interrupt reception: trigger the serial port reception interrupt and read the received data from the hardware buffer into the software reception buffer; b4. Write to receive buffer: Write the received data to the specified receive buffer for subsequent processing; b5. Clear the receiving flag: Clear the receiving flag to prepare for receiving the next data; b6. End receiving: The receiving process is completed and the current receiving task ends.
Citation Information
Patent Citations
Method for realizing PROFIBUS master station communication protocol based on FPGA (Field Programmable Gate Array) technology
CN101841542A
Protocol conversion device based on PROFIBUS-DP master station field bus
CN101964737A
Integration slave node device of Profibus-DP (profibus-data processing) and Modbus
CN102710478A
Package production line high-speed operation device
CN104407582A
Realization method of optical fiber interface conversion module used of PROFIBUS
CN105262542A