Field bus data receiving and decoding method
By receiving fieldbus data in real time and performing Manchester decoding, the problem of fieldbus transmitter communication interfaces relying on dedicated chips has been solved, realizing low-cost, easily domestically produced data reception and decoding, which is suitable for industrial sites such as petrochemical, cement and pharmaceutical industries.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NORTHEASTERN UNIV CHINA
- Filing Date
- 2026-03-30
- Publication Date
- 2026-06-19
Smart Images

Figure CN121940241B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, specifically a fieldbus data receiving and decoding method. Background Technology
[0002] Fieldbus is a digital communication system used to connect measurement, control, and display devices in production sites. It features full digitalization, bidirectional transmission, saving wiring and control room space, openness, and intelligence. Currently, the development of communication interfaces for fieldbus transmitters relies on dedicated fieldbus communication controller chips. These dedicated chips have complex interfaces, are difficult and costly to develop, and are mostly imported. Only one domestic manufacturer has a small production capacity, which severely limits the promotion and application of fieldbus technology.
[0003] Therefore, there is an urgent need for a low-cost, simplified interface, and easily localized software implementation solution to reduce terminal equipment costs and development difficulty. Summary of the Invention
[0004] To address the shortcomings of existing technologies, the present invention aims to provide a fieldbus data receiving and decoding method, comprising:
[0005] Real-time reception of fieldbus data;
[0006] For real-time received fieldbus data: determine the preamble; determine the start delimiter and end delimiter based on the preamble; define the data between the start delimiter and end delimiter as valid data;
[0007] Manchester decoding is performed on the valid data to obtain the decoded data.
[0008] Optionally, the preamble is determined in the following way:
[0009] The system presets a first pulse width interval; it then determines whether the current pulse width of the real-time received fieldbus data is within the first pulse width interval. If so, it identifies the symbol corresponding to the current pulse width as the preamble and increments the preamble count by one. It then determines whether the next pulse width of the real-time received fieldbus data is within the first pulse width interval. If not, it determines whether the preamble count has reached a preset value. If the preamble count has not reached the preset value, it returns to the previous state: Real-time reception of fieldbus data. If the preamble count reaches the preset value, it indicates that the preamble determination is complete.
[0010] Optionally, the start delimiter is determined in the following way:
[0011] A second pulse width interval is preset. When the number of preambles reaches a preset value, it is determined whether the current pulse width is within the second pulse width interval. If not, the preamble is re-determined. If so, it waits for the next 8 pulse widths of the fieldbus data received in real time to obtain 8 first pulse widths. It is then determined whether the 8 first pulse widths meet the requirements of the start delimiter. If not, the preamble is re-determined. If so, the code elements corresponding to the 8 first pulse widths are used as the start delimiter.
[0012] Optionally, the eight first pulse widths that meet the requirements of the start delimiter include:
[0013] The first pulse width is within the first pulse width interval, the second pulse width is within the first pulse width interval, the third pulse width is within the second pulse width interval, the fourth pulse width is within the first pulse width interval, the fifth pulse width is within the second pulse width interval, the sixth pulse width is within the first pulse width interval, the seventh pulse width is within the first pulse width interval, and the eighth pulse width is within the second pulse width interval.
[0014] Optionally, the end delimiter is determined in the following way:
[0015] When the first 8 pulse widths meet the requirements of the start delimiter, wait for the next 8 pulse widths of the fieldbus data to be received in real time, and obtain 8 second pulse widths. Determine whether the 8 second pulse widths meet the requirements of the end delimiter. If the 8 second pulse widths do not meet the requirements of the end delimiter, then return to execution: wait for the next 8 pulse widths of the fieldbus data to be received in real time; if the 8 second pulse widths meet the requirements of the end delimiter, then use the code elements corresponding to the 8 second pulse widths as the end delimiter.
[0016] Optionally, the eight second pulse widths that meet the requirements of the end delimiter include:
[0017] The first second pulse width is within the second pulse width interval, the second second pulse width is within the first pulse width interval, the third second pulse width is within the first pulse width interval, the fourth second pulse width is within the first pulse width interval, the fifth second pulse width is within the first pulse width interval, the sixth second pulse width is within the second pulse width interval, the seventh second pulse width is within the first pulse width interval, and the eighth second pulse width is within the first pulse width interval.
[0018] Optionally, the preset value is 4.
[0019] The beneficial effects of adopting the above technical solution are as follows:
[0020] This invention solves the problem that the development of fieldbus transmitter communication interfaces requires a dedicated fieldbus communication controller chip, while being compatible with both Foundation Fieldbus and PROFIBUS PA fieldbuses, thus eliminating the bottleneck problem of imported chips.
[0021] Currently, none of the fieldbus chips on the market have pass-through functionality. The advantage of UART-based pass-through functionality is that it simplifies the hardware interface, eliminates the need for complex memory bus interfaces, makes it easier for users to select microcontrollers, reduces the development difficulty of fieldbus transmitters, and further reduces costs and enables product miniaturization.
[0022] Furthermore, based on its cost advantages and transparent transmission function, existing industrial communication protocols widely used in industry, such as MODBUS and HART, which are based on UART, can be easily modified to run on this invention, achieving broad protocol compatibility. Attached Figure Description
[0023] Figure 1 This is a flowchart illustrating a fieldbus data receiving and decoding method according to an embodiment of the present invention;
[0024] Figure 2 This is a schematic diagram of the encoding format of the preamble, start delimiter, and end delimiter in an embodiment of the present invention. Detailed Implementation
[0025] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.
[0026] To address the problems existing in the prior art, this invention provides a fieldbus data receiving and decoding method, combining... Figure 1 This may include the following steps:
[0027] Step 1: Receive fieldbus data in real time;
[0028] This invention can be applied in petrochemical fields, as well as in industrial fields such as cement and pharmaceuticals.
[0029] Step 2: For the real-time received fieldbus data: determine the preamble; determine the start delimiter and end delimiter based on the preamble; define the data between the start delimiter and end delimiter as valid data;
[0030] In the I / O interrupt handler, the logic level and time of the current fieldbus data are saved. The time can be obtained by reading the time of the microcontroller's timer. The handler waits for the next edge of the real-time received fieldbus data, saves the trigger time and the changed logic level, calculates the difference between the trigger time of this edge and the trigger time of the previous edge, and uses this as the current pulse width. A first pulse width interval is preset, approximately 32µs. The handler determines whether the current pulse width of the real-time received fieldbus data is within the first pulse width interval. If so, the symbol corresponding to the current pulse width is determined as the preamble, and the preamble count is incremented by one. The handler then determines whether the next pulse width of the real-time received fieldbus data is within the first pulse width interval. If not, the handler determines whether the preamble count has reached a preset value (in this invention, the preset value can be set to 4). If the preamble count has not reached the preset value, the handler returns to execute: Real-time reception of fieldbus data. If the preamble count reaches the preset value, it indicates that the preamble determination is complete.
[0031] A second pulse width interval is preset, approximately 16µs. When the number of preambles reaches a preset value, it is determined whether the current pulse width is within the preset second pulse width interval. If not, the preamble is redefined. If so, it waits for 8 pulse widths of the real-time received fieldbus data to obtain 8 first pulse widths. Specifically, it waits for the next 8 edges of the real-time received fieldbus data, saves the trigger time and changed logic level of each edge, and calculates the difference in trigger time between adjacent edges for the 8 edges and the previous edge corresponding to the first edge to obtain 8 first pulse widths. It is then determined whether the 8 first pulse widths meet the requirements of the start delimiter. If not, the preamble is redefined. If so, the code corresponding to the 8 first pulse widths is used as the start delimiter.
[0032] Among them, combined Figure 2 The eight first pulse widths that meet the requirements of the start delimiter include:
[0033] The first pulse width is within the first pulse width interval, the second pulse width is within the first pulse width interval, the third pulse width is within the second pulse width interval, the fourth pulse width is within the first pulse width interval, the fifth pulse width is within the second pulse width interval, the sixth pulse width is within the first pulse width interval, the seventh pulse width is within the first pulse width interval, and the eighth pulse width is within the second pulse width interval.
[0034] In another implementation, each edge can be waited for in turn, and the pulse width between two edges can be calculated in turn, while determining whether the pulse width meets the requirements of the start delimiter.
[0035] When the first 8 pulse widths meet the requirements of the start delimiter, wait for the next 8 pulse widths of the fieldbus data to be received in real time, and obtain 8 second pulse widths. Specifically, wait for the next 9 edges of the fieldbus data to be received in real time, save the trigger time and the changed logic level of each edge, calculate the difference in trigger time between two adjacent edges among the 9 edges, and obtain 8 second pulse widths; determine whether the 8 second pulse widths meet the requirements of the end delimiter. If the 8 second pulse widths do not meet the requirements of the end delimiter, then return to execute: wait for the next 8 pulse widths of the fieldbus data to be received in real time; if the 8 second pulse widths meet the requirements of the end delimiter, then use the corresponding symbols of the 8 second pulse widths as the end delimiter.
[0036] Among them, combined Figure 2 The eight second pulse widths that meet the requirements of the end delimiter include:
[0037] The first second pulse width is within the second pulse width interval, the second second pulse width is within the first pulse width interval, the third second pulse width is within the first pulse width interval, the fourth second pulse width is within the first pulse width interval, the fifth second pulse width is within the first pulse width interval, the sixth second pulse width is within the second pulse width interval, the seventh second pulse width is within the first pulse width interval, and the eighth second pulse width is within the first pulse width interval.
[0038] Step 3: Perform Manchester decoding on the valid data to obtain the decoded data;
[0039] Furthermore, the present invention also includes sending the decoded data to the microcontroller UART interface, performing Manchester encoding on the data received by the UART, and outputting the encoded data to the fieldbus MAU interface through the microcontroller SPI interface.
[0040] The Manchester encoding includes preamble encoding, start delimiter encoding, data encoding, and end delimiter encoding. Each encoding is in 16-bit format (corresponding to 8 code elements). After each byte of Manchester data is encoded, it is immediately output to the fieldbus MAU interface via the SPI port.
[0041] In this invention, one bit of raw data is encoded into two bits, meaning one byte of raw data is encoded into two bytes of data. After the UART receives the first byte, it first sends a preamble (0x9999) and a start delimiter (0xB24D) via SPI, and then sends the encoded data. Each subsequent byte of data received is encoded and then sent. When all data has been received, an end delimiter (0xB326) is sent last.
[0042] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in the embodiments of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in the embodiments of this disclosure.
Claims
1. A method of field bus data reception and decoding, characterized in that, include: Real-time reception of fieldbus data; For real-time received fieldbus data: determine the preamble; The start and end delimiters are determined based on the preamble; the data between the start and end delimiters is defined as valid data. The preamble is determined in the following way: The first pulse width interval is preset; it is determined whether the current pulse width of the real-time received fieldbus data is within the first pulse width interval. If so, the symbol corresponding to the current pulse width is determined as the preamble, and the number of preambles is incremented by one. It is then determined whether the next pulse width of the real-time received fieldbus data is within the first pulse width interval. If not, it is determined whether the number of preambles has reached a preset value. If the number of preambles has not reached the preset value, the process returns to: Real-time reception of fieldbus data. If the number of preambles reaches the preset value, it indicates that the preamble determination is complete. The starting delimiter is determined in the following way: A second pulse width interval is preset. When the number of preambles reaches a preset value, it is determined whether the current pulse width is within the second pulse width interval. If not, the preamble is re-determined. If so, it waits for the next 8 pulse widths of the fieldbus data received in real time to obtain 8 first pulse widths. It is then determined whether the 8 first pulse widths meet the requirements of the start delimiter. If not, the preamble is re-determined. If so, the code elements corresponding to the 8 first pulse widths are used as the start delimiter. The end delimiter is determined in the following way: When the first 8 pulse widths meet the requirements of the start delimiter, wait for the next 8 pulse widths of the fieldbus data to be received in real time, and obtain 8 second pulse widths. Determine whether the 8 second pulse widths meet the requirements of the end delimiter. If the 8 second pulse widths do not meet the requirements of the end delimiter, then return to execution: wait for the next 8 pulse widths of the fieldbus data to be received in real time; if the 8 second pulse widths meet the requirements of the end delimiter, then use the code elements corresponding to the 8 second pulse widths as the end delimiter. The valid data is subjected to Manchester decoding to obtain the decoded data, which is then sent to the microcontroller's UART interface to achieve data pass-through.
2. The field bus data receiving and decoding method according to claim 1, wherein, The eight first pulse widths that meet the requirements of the start delimiter include: The first pulse width is within the first pulse width interval, the second pulse width is within the first pulse width interval, the third pulse width is within the second pulse width interval, the fourth pulse width is within the first pulse width interval, the fifth pulse width is within the second pulse width interval, the sixth pulse width is within the first pulse width interval, the seventh pulse width is within the first pulse width interval, and the eighth pulse width is within the second pulse width interval.
3. The fieldbus data receiving and decoding method according to claim 1, characterized in that, The eight second pulse widths that meet the requirements of the end delimiter include: The first second pulse width is within the second pulse width interval, the second second pulse width is within the first pulse width interval, the third second pulse width is within the first pulse width interval, the fourth second pulse width is within the first pulse width interval, the fifth second pulse width is within the first pulse width interval, the sixth second pulse width is within the second pulse width interval, the seventh second pulse width is within the first pulse width interval, and the eighth second pulse width is within the first pulse width interval.
4. The fieldbus data receiving and decoding method according to claim 1, characterized in that, The preset value is 4.