Device and implementation method for simulating high-speed communication of Profibus master station

Through the combination of MCU controller, RS-485 transceiver and RS-232 interface module, the problem of low communication rate of Profibus-DP master station is solved, and efficient and low-cost high-speed communication is realized, which is suitable for the development and testing of industrial automation equipment.

CN119676026BActive Publication Date: 2025-08-15天津七一二移动通信股份有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510174063.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-18
Publication Date
2025-08-15
Estimated Expiration
2045-02-18

AI Technical Summary

Technical Problem

In the prior art, the communication rate of the simulated Profibus-DP master station is low and cannot reach 12Mbps, resulting in unstable communication, high cost and low testing efficiency.

Method used

The MCU controller, RS-485 transceiver, RS-232 communication interface and Flash memory module are adopted to achieve up to 12Mbps of Profibus-DP master station communication through precise clock control and signal conversion, reducing hardware costs and simplifying user operations.

Benefits of technology

It realizes stable communication at a rate of 12Mbps, reduces development and testing costs, improves testing efficiency, reduces message errors, and simplifies user operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119676026B_ABST
    Figure CN119676026B_ABST
Patent Text Reader

Abstract

The present invention relates to a device and implementation method 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 the Profibus-DP bus via the RS-485 transceiver and communicates with the PC via the RS-232 module. The user can select the transmission rate, source address, destination address, and message type in the configuration software installed on the PC. The Flash memory module stores the user's most recently sent messages and the slave's reply data. This device solves the instability and data error problems of high-baud-rate communication in the prior art, has low cost, simple structure, and is widely applicable to the development and testing of industrial automation equipment, thereby improving the communication efficiency and reliability of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of industrial automation field bus communication, and in particular relates to a device and an implementation 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 these areas of production and is an open digital communication system with a wide range of applications, suitable for a variety of communication tasks requiring fast speed, strict time constraints, and high reliability. Profibus network communication is essentially RS485 serial communication. Depending on the industry application, there are three main communication profiles: DP (Decentralized Peripherals), FMS (Field Message Specification), and PA (Process Automation).

[0003] Profibus DP (distributed I / O) is a field-level communications network that complies with the IEC 61158-2 / EN 61158-2 standard and uses a mixed token bus and master / slave access protocol. Networking is via a twisted-pair cable or fiber-optic cable, enabling data transfer rates from 9.6 kbps to 12 Mbps.

[0004] The development and testing of Profibus-DP devices typically uses a Profibus communication card, such as the Siemens CP5611. This card is installed in a PCI slot, enabling the PC to function as a Profibus master and communicate with slave devices. However, this approach is not only inconvenient but also expensive (a single Profibus communication card can cost several thousand yuan). Furthermore, manufacturers of modules with this communication function face inconvenient testing, resulting in slow testing, low efficiency, and high costs.

[0005] Existing patents and literature primarily focus on using a computer with an RS232 serial communication port, coupled with an RS232-to-RS485 adapter, to implement a test device that simulates Profibus-DP master communications. However, while computers with RS232 serial communication ports are commercially available, their communication rates are often only 115,200 bps, failing to reach 12 Mbps. Another method involves using a PC's USB port with a USB-to-RS485 converter to simulate a Profibus-DP master. However, even if the USB-to-RS485 converter can achieve a 12 Mbps communication rate and the PC serial port can be configured for 12 Mbps, field tests have shown that when the serial port is configured for a high rate (1.5 Mbps and above), the Profibus messages sent by the converter are not recognized by the Profibus-DP slave device and are considered dirty data. Oscilloscope waveform observation reveals that between each byte of a message, in addition to the even parity bit and stop bit of the previous byte and the start bit of the next byte, there is an idle state (corresponding to a binary "1") of approximately 400ns after the stop bit. Profibus messages should only contain even parity bits, stop bits, and start bits between each byte; no idle state should exist. At low data rates (500Kbps and below), this idle state is negligible relative to the Tbit (transmission time per bit), for example, 1 / 500K = 2μs. However, at higher data rates, the idle state becomes significantly larger relative to the Tbit, for example, 1 / 1.5M ≈ 666.7ns. This can cause bit information deviation in the entire message and extend the transmission time (by approximately the number of message bytes × 400ns). Consequently, devices on the Profibus-DP bus will not recognize the message as a Profibus message, and the corrupted data will be discarded. Further testing revealed that the idle state had nothing to do with the USB-to-RS485 converter. Instead, it was caused by the PC adding a start bit, even parity bit, and stop bit to each transmitted byte. This slowed the serial port's data processing, requiring simultaneous calculations as the message was sent, resulting in an idle state between each byte. Therefore, using the PC's serial port to emulate a Profibus master at high baud rates was not feasible. Summary of the Invention

[0006] The present invention provides a device and 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, thereby significantly improving production test efficiency.

[0007] To achieve the above-mentioned objectives, 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 communicatively 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 enter the required message data fields through configuration software installed on the PC; the MCU records the user's most recently sent message data and the slave's reply data through the Flash memory module, so that the user can view the communication records.

[0008] The implementation method of the present invention comprises the following steps:

[0009] Step 1: The UART interface of the MCU controller is connected to the RS-485 transceiver, and the RS-485 transceiver extends 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.

[0010] Step 2: The user enters the Profibus rate, message type, source address, destination address, and message data content through the Profibus master configuration software; after the user clicks "Single Send" or "Continuous Send", the configuration software sends the information to the MCU through the Config interface.

[0011] Step 3: The 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.

[0012] 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.

[0013] 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.

[0014] The technical effects of the present invention are:

[0015] First, the present invention enables Profibus-DP master station communication at rates up to 12 Mbps, resolving the problem of existing analog Profibus-DP master stations being limited to low baud rates. This enables the device to meet the demands of high-speed communication. This significantly improves communication efficiency and meets the high-speed communication requirements of modern industrial automation equipment.

[0016] Secondly, this invention reduces development and testing costs: Compared to traditional Profibus communication cards (such as the Siemens CP5611), this invention implements the Profibus-DP master functionality using an MCU and RS-485 transceiver, eliminating the need for additional expensive hardware. This significantly reduces development and testing costs, enabling developers and manufacturers to develop and test devices more economically.

[0017] Thirdly, the present invention improves test efficiency: existing technologies typically employ lower rates or use adapters, but these methods cannot effectively simulate a Profibus-DP master at high baud rates. Through optimized hardware design and Profibus message transmission control procedures, the present invention can accurately transmit high-rate Profibus messages that can be recognized by slaves without generating corrupted data, significantly improving test efficiency.

[0018] The present invention also reduces message errors: By optimizing the MCU's clock source and message transmission process, the present invention eliminates message errors caused by the serial port's idle state in existing USB-to-RS485 converters. Precise clock configuration and control ensure that there are no idle states between bytes when sending Profibus messages, thus preventing message information deviation.

[0019] Finally, the present invention is easy to use. By providing an RS-232 interface for connection to a PC, users can conveniently set parameters such as transmission rate, address, and message content through a PC-based configuration tool, eliminating the need to learn complex Profibus-DP network configuration. This design simplifies user operation and improves the convenience of production and testing.

[0020] Through the above improvements, the present invention overcomes the problems of unstable communication at high baud rates, high cost and low testing efficiency in the prior art, 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

[0021] Figure 1 It is a circuit structure block diagram for implementing the present invention;

[0022] Figure 2 This is the schematic diagram of the MCU circuit of the present invention;

[0023] Figure 3 Power supply circuit diagram of the present invention;

[0024] Figure 4 This is the schematic diagram of the RS-485 transceiver and Profibus bus interface circuit of the present invention;

[0025] Figure 5 This is a schematic diagram of the Profibus bus interface of the present invention;

[0026] Figure 6 Schematic diagram of differential signals transmitted on the Profibus bus of the present invention;

[0027] Figure 7 This is a schematic diagram of the RS-232 chip and configuration interface circuit of the present invention;

[0028] Figure 8 This is the schematic diagram of the external NOR FLASH circuit of the present invention;

[0029] Figure 9 It is the single-byte format of the Profibus message of the present invention;

[0030] Figure 10 It is the interface of the PC-side simulation Profibus-DP master station configuration tool of the present invention;

[0031] Figure 11 It is the frame format of the data link layer specified by the Profibus protocol of the present invention;

[0032] Figure 12 This is a flow chart of the MCU of the present invention sending a Profibus message byte by byte;

[0033] Figure 13 This is the interface for querying the historical data sent by the simulated Profibus-DP master station of the present invention;

[0034] Figure 14 The present invention queries and simulates the Profibus-DP master station receiving data recording interface. DETAILED DESCRIPTION

[0035] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0036] 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 in the prior art that the simulated Profibus-DP master station can only communicate at a low baud rate.

[0037] like Figure 1 As shown, the device simulating high-speed communication of a 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 MCU controller's UART interface connects to the RS-485 transceiver module, converting the TTL-level signals output by the UART peripheral into differential RS-485-level signals. This interface is then connected to the Profibus-DP bus and can be connected to a Profibus-DP slave station. The communication rate of the RS-485 transceiver and the rate supported by the MCU's UART interface can reach at least 12 Mbps. Another set of MCU UART interfaces connects to the RS-232 interface module chip, converting the TTL-level signals output by the UART peripheral into RS-232-level signals, enabling communication between the MCU and a PC. Users can select the transmission rate, source address, destination address, message type, and enter the required message data fields in the configuration software installed on the PC. The MCU connects to the Flash memory module, communicating with the Flash chip via the SPI protocol. This module stores the user's most recently sent message data and the slave station's reply data, making it easy for the user to view the records.

[0038] MCU controller module: As the core control unit, the MCU is responsible for generating Profibus-DP protocol messages, managing communication parameters, and processing data transmission and reception. It uses an internal clock to ensure high-precision timing control and reliable data transmission.

[0039] RS-485 transceiver module: This module converts between TTL and differential signals, supports communication rates up to 12Mbps, and ensures signal stability and anti-interference capabilities during long-distance transmission. It is responsible for both sending data and receiving signals from the Profibus bus.

[0040] RS-232 communication interface module: Used for communication between the MCU and the PC, it provides a convenient configuration and monitoring interface. This module allows users to modify communication parameters in real time through configuration software and obtain system operating status and historical data.

[0041] Flash memory module: Used to store historical sent and received data, ensuring data traceability and reliability. Users can query stored records at any time, facilitating subsequent analysis and troubleshooting.

[0042] like Figure 2 As shown in the figure, the MCU controller module mainly includes a controller chip model STM32F722RET6. Its circuit is connected to the high-speed external clock signal HSE, providing a relatively accurate and stable clock source. HSE is provided by an 8MHz passive crystal oscillator X1 with resonant capacitors C3 and C4 and resistor R2. The specific connection method is: after the passive crystal oscillator X1 is connected in parallel with resistor R2, its two ends are connected to the MCU's PH0-OSC_IN (Pin5) and PH1-OSC_OUT (Pin6), respectively, and are grounded (GND) through capacitors C3 and C4 respectively. The system clock SYSCLK is selected as the source of HSE. After the phase-locked loop PLL multiplication, it is configured to a maximum of 216MHz. This ensures a more accurate baud rate of the serial port USART1 for sending and receiving Profibus messages, which can be configured to a maximum of 27Mbit / s. The low-speed external clock signal LSE provides a low-speed, yet highly accurate clock source for the real-time clock (RTC). To implement the RTC function, the MCU's external clock signal LSE is connected to a 32.768 kHz passive crystal oscillator X2, providing a low-speed, high-precision clock source. Resonant capacitors C1 and C2 are used to generate this signal. Specifically, the two ends of the passive crystal oscillator X2 are connected to the MCU's PC14-OSC32_IN (Pin 3) and PC15-OSC32_OUT (Pin 4), respectively, and then to ground (GND) through capacitors C1 and C2, respectively. To minimize clock output distortion and shorten startup stabilization time, X1, C3, C4, and R2 must be placed as close as possible to PH0-OSC_IN (Pin 5) and PH1-OSC_OUT (Pin 6). X2, C1, and C2 must be placed as close as possible to PC14-OSC32_IN (Pin 3) and PC15-OSC32_OUT (Pin 4). 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 by the VBAT pin (Pin1). Figure 3 As shown, the VBAT pin is connected to the positive terminal of the rechargeable lithium-ion battery BT1. Even in a power outage, the RTC maintains operation, achieving time synchronization. It is connected to a 3.3V external power supply via diode VD1. Resistor R8 is connected in series between VD1 and 3V3_BAT. The 3.3V power supply is connected via parallel capacitors C7, C8, C9, C10, C11, and C12. This allows the simulated Profibus master device to charge the lithium battery when powered on and, in the event of a power outage, the lithium battery provides power to VBAT.

[0043] The Profibus network is based on the RS485 serial communication standard and uses half-duplex mode for data exchange. The EIA-defined RS485 transmission method is the most common communication method in Profibus systems due to its high reliability and interference resistance in industrial automation applications. The network uses shielded twisted-pair cables with balanced differential transmission for signal transmission, effectively reducing noise interference during transmission. The Profibus network offers a flexible transmission rate range from 9.6 Kbit / s to 12 Mbit / s, depending on application requirements and network load. The network topology uses a linear structure, with all devices on the bus using the same transmission rate to ensure synchronized and stable data transmission. A single segment can support up to 32 devices, including both master and slave devices. If an application requires more than 32 devices or requires longer bus lengths due to long cabling distances, RS485 repeaters can be used to extend the segment, allowing for larger Profibus networks. The maximum bus length per segment is closely related to the transmission rate; higher transmission rates generally result in shorter maximum bus lengths. 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.

[0044] 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 TxD (Pin7) pin is connected to the MCU's USART1_TX, namely PA9 (Pin42), and the RxD (Pin4) pin is connected to the MCU's USART1_RX, namely PA10 (Pin43). In addition, the RS-485 transceiver is connected to the Profibus bus interface, the Y (Pin13) pin is connected to the Profibus bus interface's Pin3, and the Z (Pin15) pin is connected to the Profibus bus interface's Pin8. Figure 5 As shown, its pins are defined as:

[0045]

[0046] Pin 3 is connected to signal line B of the Profibus cable, and pin 8 is connected to signal line A of the cable. 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.

[0047] During transmission, binary "1" corresponds to the positive potential on the RXD / TXD-P (Receive / Transmit-Data-P) line, and the opposite on the RXD / TXD-N line. The idle state between each message corresponds to the binary "1" signal, such as Figure 6 shown.

[0048] In order to facilitate information exchange between users and the Profibus master, the message sent by the Profibus master 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 exposed 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 in the figure, the RS-232 chip's pin T1IN (Pin 11) connects to the MCU's USART2_TX: PA2 (Pin 16); the pin R1OUT (Pin 12) connects to the MCU's USART2_RX: PA3 (Pin 17); the MCU and the RS-232 chip share a common ground. The RS-232 chip is connected to an external RS-232 interface, which is the interface (Config) used by the PC to configure the Profibus master. Pin T1OUT (Pin 14) connects to the TXD (Pin 2) of the Config interface; pin R1IN (Pin 13) connects to the RXD (Pin 3) of the Config interface; and pin GND (Pin 15) connects to the GND (Pin 5) of the Config interface. VD2 is a TVS diode that protects the circuit from transient high-voltage spikes (such as electrostatic discharge and lightning surges). R5 is the Profibus bus termination resistor, which eliminates signal reflections in the communication cable. VD2 and R5 should be placed close to the XS1 interface.

[0049] 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 MCU to a PC's COM port via the Config port, or to a PC's USB port via a USB-to-RS-232 serial cable, enabling communication between the MCU and the PC. F1 and F2 are resettable fuses and should be placed near port XS2. With a trip current of 300mA, they protect the internal circuitry from damage caused by accidental connection to high-voltage or high-current external signals.

[0050] In order to store and record the historical Profibus messages sent 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); pin CLK (Pin6) is connected to the MCU's SPI1_SCK: PA5 (Pin21); pin DO (IO1) (Pin2) is connected to the MCU's SPI1_MISO: PA6 (Pin22); pin DI (IO0) (Pin5) is connected to the MCU's SPI1_MOSI: PA7 (Pin23).

[0051] According to the Profibus protocol, the transmission procedure for Profibus RS-485 is based on half-duplex, asynchronous, and 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: Figure 9 When a bit is transmitted, the signal shape does not change during the transition from binary "0" to "1".

[0052] First, you need to initialize the GPIO pins of the MCU. Figure 2 The corresponding pins used in the multiplexing are USART1 / USART2 / SPI1. USART1 is configured for 8 data bits, 1 stop bit, even parity, and a modifiable baud rate, determined by the user. USART2 is configured for a baud rate of 115200 bps, 8 data bits, 1 stop bit, and no parity, consistent with the communication parameters in the configuration tool on the PC. The USART clock source is the system clock frequency (up to 216 MHz), with 8x oversampling. The RS-485 transceiver is switched to receive mode, with PA8 (Pin 41) configured in GPIO push-pull output mode and a low output level. This monitors the Profibus-DP bus and records any data frames received from slaves along with the current time in the NOR flash.

[0053] The user runs the simulated Profibus-DP master configuration tool on the PC. The configuration software interface is as follows: Figure 10As shown, the configuration software enters the Profibus master rate, message type, source address, destination address, and specific message data content. When the user clicks "Single Send" or "Continuous Send," the configuration software transmits this information to the MCU via the Config interface. Upon receiving data from the USART2 interface, the MCU changes the baud rate of USART1 to the user-selected communication rate. Based on the source address, destination address, message type, and content, the MCU constructs the corresponding Profibus message according to the specified data frame format, as specified in the Profibus protocol. The software then writes the relevant information, including the real-time time record of the transmission, to the Flash chip.

[0054] According to the Profibus protocol, the frame format of the data link layer is as follows Figure 11 shown.

[0055] in:

[0056] SYN synchronization time, minimum 33 line idle bits;

[0057] SD1 to SD4 start delimiters, distinguishing different types of frame formats;

[0058] SD1=0x10, SD2=0x68, SD3=0xA2, SD4=0xDC;

[0059] LE / LEr 8-bit group length, usually LE=LEr, its allowed value is 4 to 249;

[0060] DA destination address, indicating the station receiving the frame;

[0061] SA source address, indicating the station that sent the frame;

[0062] FC frame control byte, which contains detailed description of the service and priority of the frame;

[0063] DATA_UNIT data field, containing valid data information;

[0064] FCS frame check byte, the sum of all frame characters without carry;

[0065] ED frame end delimiter (16H);

[0066] SC single character (E5H), used in short response frame;

[0067] L Information field length.

[0068] The transmission rules for fixed-length frames with or without a data field, as well as token frames, are as follows: these frames include both active and acknowledgment / reply frames. The idle state corresponds to a binary "1" signal level; there are no idle bits between characters in the frame. The preambles of active and acknowledgment / reply frames differ slightly. Each active frame header has at least 33 synchronization bits, meaning that each handshake message must remain idle for at least 33 bits (a binary 1 corresponds to a level signal) before establishing communication. These 33 synchronization bits serve as the frame synchronization interval, known as the SYN bit. This requirement is not applied to acknowledgment and reply frames; response time depends on system settings and receiver checks.

[0069] Frames with variable data field lengths shall, in addition to the above, have the following additional requirements: 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.

[0070] There are also certain differences between acknowledgment frames and reply frames. An acknowledgment frame is a frame without a data field (DATA_UNIT) in the response frame sent from the slave to the master, while a reply frame is a frame with a data field (DATA_UNIT) in the response frame. Furthermore, a short reply frame is used only for replies and is a simplified form of a fixed-length frame without a data field.

[0071] The MCU calculates the frame length and frame check byte, composing the corresponding Profibus message. It then switches the RS-485 transceiver to transmit mode, configuring PA8 (Pin 41) to output a high level. This signal is then sent to the RS-485 transceiver via the USART1 interface, and subsequently to the Profibus-DP bus. If the user selects "Single Send," the message is sent once. If "Continuous Send i Times" is selected, the value "i" is decremented after each message is sent, and a delay of the specified duration is applied until i = 0.

[0072] The function for sending a single message by byte can be referred to as follows:

[0073] void USART1_SendMsg(const void* buffer,uint16_t Lenth)

[0074] {

[0075] const unsigned char *p =(unsigned char *)buffer;

[0076] for(int m = 0;m <Lenth;m++)

[0077] {

[0078] HAL_UART_Transmit(&huart1,(p+m),1,1000);

[0079] }

[0080] }

[0081] 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: Figure 12 The specific steps include the sending and receiving process of serial communication:

[0082] a.Serial port sending process:

[0083] a1. Initialization completed: After the initialization process of serial communication is completed, the sending process begins.

[0084] a2. Prepare to send data and call send: The serial port sending module prepares the data and calls the send function.

[0085] a3. Check if the send register is empty:

[0086] -If the send register is empty, it means that new data can be sent and proceed to the next step.

[0087] - If the transmit register is not empty, wait for it to be cleared.

[0088] a4. Send next character: Send the next character in the data to the send register.

[0089] a5. Clear the sending flag: Clear the sending flag to detect the sending of the next data.

[0090] a6. Check whether the sending is completed:

[0091] -If the sending is not completed, return to step 3 and continue sending the next character.

[0092] -If the sending is completed, it enters the sending end state.

[0093] a7. End sending: The sending process is completed and the current sending task ends.

[0094] b. Serial port receiving process

[0095] b1. Initialization completed: After the initialization process of serial communication is completed, it enters the receiving process.

[0096] b2. Is the receiving buffer empty?

[0097] -If the receive buffer is empty, it means there is no new data and you need to wait for the next data.

[0098] - If the receive buffer is not empty, proceed to the next step.

[0099] b3. Serial port interrupt reception: Trigger the serial port receive interrupt and read the received data from the hardware buffer into the software receive buffer.

[0100] b4. Write to receive buffer: Write the received data to the specified receive buffer for subsequent processing.

[0101] b5. Clear the receive flag: Clear the receive flag to prepare for receiving the next data.

[0102] b6. End receiving: The receiving process is completed and the current receiving task ends.

[0103] After the MCU sends the message, it switches the RS-485 transceiver back to the receiving state, that is, configures PA8 (Pin41) to output low level, listens to the Profibus-DP bus, and if it receives a reply frame from the slave, it writes it into NORFLASH along 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 easy viewing by the user. The historical send data and receive data record interfaces are as follows: Figure 13 、 Figure 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. This allows a device to simulate a Profibus master station and communicate with other devices on the bus at any agreed rate and user-specified content.

[0104] The present invention provides a method for implementing a device for simulating high-speed communication of a Profibus master station, which specifically comprises the following steps:

[0105] Step 1: Connect the MCU's UART interface to an RS-485 transceiver. The RS-485 transceiver expands a Profibus-DP bus interface to connect to a Profibus-DP slave. Connect the MCU's other UART interface to an RS-232 chip. The RS-232 chip expands a Config interface to connect to a PC. The MCU connects to the Flash chip via the SPI peripheral.

[0106] Step 2: In the simulated Profibus-DP master configuration tool, enter the Profibus master rate, message type, source address, destination address, and message data. When you click "Single Send" or "Continuous Send," the configuration software sends this information to the MCU through the Config interface.

[0107] Step 3: After receiving the corresponding information, the 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 based on the source address, destination address, message type and content, referring to the Profibus protocol.

[0108] Step 4: The MCU switches the RS-485 transceiver from receiving to transmitting mode, sends the data to the RS-485 transceiver via the USART1 interface, and then sends it to the Profibus-DP bus. The MCU also writes the relevant information, including the real-time time record of the transmission, into the Flash chip.

[0109] Step 5: After the MCU sends the message, it switches the RS-485 transceiver back to receive mode and listens to the Profibus-DP bus. If it receives a reply frame from the slave, it writes it, along with the current time, to the NOR Flash. When the user clicks "Historical Transmit Data" or "Receive Data Record," the MCU reads the contents stored in the Flash chip and sends them to the PC via the USART2 interface. The data is then displayed in the simulated Profibus-DP master configuration tool for easy viewing.

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 the external Profibus-DP bus through the RS-485 transceiver module, and is connected to the PC through the RS-232 communication interface module; the communication rate of the RS-485 transceiver module and the UART interface of the MCU controller module 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 controller module records the message data recently sent by the user and the reply data from the slave station through the Flash memory module, so that the user can view the communication record; the MCU controller module includes a controller chip with model number 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 The LSE provides a low-frequency clock signal for low-power mode and precise timekeeping. The HSE includes an 8MHz passive crystal oscillator X1, resonant capacitors C3 and C4, and a resistor R2. X1 and R2 are connected in parallel and connected to the PH0-OSC_IN and PH1-OSC_OUT ports of the MCU, respectively, and are grounded through capacitors C3 and C4. The LSE includes a 32.768KHz passive crystal oscillator X2, resonant capacitors C1 and C2, and the two ends of X2 are connected to the PC14-OSC32 of the MCU respectively. _IN and PC15-OSC32_OUT ports, and are grounded through C1 and C2; the X1, C3, C4, and R2 are located near the PH0-OSC_IN and PH1-OSC_OUT ports, and the X2, C1, and C2 are located near the PC14-OSC32_IN and PC15-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.

2. The device for simulating high-speed communication of a Profibus master station according to claim 1, characterized in that: The MCU controller module performs signal level conversion through the RS-485 transceiver module; the DE and RE# pins of the RS-485 transceiver are connected to the MCU's GPIO pin PA8, the TxD pin is connected to the MCU's PA9, and the RxD pin is connected to the MCU's PA10; the Y and A pins of the RS-485 transceiver module are connected to Pin3 of the Profibus bus interface, the Z and B pins 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.

3. The device for simulating high-speed communication of a Profibus master station according to claim 1, characterized in that: The MCU controller module is connected to the Config interface of the external PC through the RS-232 communication interface module; the pin T1IN of the RS-232 chip is connected to PA2 of the MCU, the pin R1OUT is connected to PA3 of the MCU, and the MCU and the RS-232 chip share a common ground; the T1OUT of the RS-232 chip 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, and the pin GND is connected to the GND of the Config interface. F1 and F2 are placed close to the Config interface XS2 to protect the internal circuit.

4. The device for simulating high-speed communication of a Profibus master station according to claim 1, characterized in that: The MCU is connected to an external NOR Flash chip to store historical Profibus messages sent and received. 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.

5. A method for simulating a high-speed communication device of a Profibus master station according to any one of claims 1 to 4, characterized in that: The following steps are involved: Step 1: The UART interface of the MCU controller module is connected to the RS-485 transceiver module, and the RS-485 transceiver module extends the Profibus-DP bus interface and connects to the Profibus slave station; another UART interface of the MCU controller module is connected to the RS-232 communication interface module, and the RS-232 communication interface module is connected to the PC end; the MCU controller module 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 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: The 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. 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 receiving mode and listens to the Profibus-DP bus. If a reply is received from the slave, the reply time and data are stored in the Flash chip. When the user clicks "Historical Sent Data" or "Received Data Record", the MCU transmits the Flash stored data to the PC via the USART2 interface for the user to view.

6. The method for simulating a device for high-speed communication of a Profibus master station according to claim 5, wherein: The process of the peripheral UART of the MCU controller module 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 send flag: clear the send flag to detect the next data transmission; 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: triggers the serial port receive interrupt and reads the received data from the hardware buffer into the software receive buffer; b4. Write to receive buffer: Write the received data to the specified receive buffer for subsequent processing; b5. Clear the receive flag: Clear the receive 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

  • Protocol conversion device based on PROFIBUS-DP master station field bus

    CN101964737A