Irig b code generation method based on standard serial interface
By modifying the baud rate and operating clock of the serial interface, IRIGB code patterns are generated and sent, solving the problems of complex structure and high debugging difficulty of existing equipment, and realizing convenient generation and efficient time synchronization on common devices.
Patent Information
- Application Number
- CN202510840082.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-23
- Publication Date
- 2026-03-20
- Estimated Expiration
- 2045-06-23
AI Technical Summary
Existing IRIGB source devices are complex in structure and bulky in size, making them difficult to use in mobile operations or space-constrained environments. Furthermore, they lack error mode generation methods, which increases the difficulty and time cost of debugging.
By modifying the baud rate or operating clock of the device's serial interface driver, IRIGB codes can be constructed and sent, and time synchronization can be achieved through the serial interface. It supports the cyclic transmission of 100 codes and the automatic increment of Coordinated Universal Time (UTC).
It enables convenient generation of IRIGB codes on common devices, reducing resource waste, improving equipment utilization, simplifying the debugging process, and ensuring the accuracy and stability of time synchronization.
Smart Images

Figure CN121124986B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of IRIGB code generation and debugging, and particularly relates to an IRIGB code generation method based on a standard serial interface. BACKGROUND
[0002] In the field of modern science and technology, time synchronization is the key basis for the collaborative work of many devices and systems. As a time code standard formulated by the American Instrumentation Group (IRIG), IRIGB code plays an important role in time synchronization between different devices and systems with its unique serial transmission mode and pulse width encoding mechanism. It transmits at a speed of one frame per second, with each code element having a width of 10ms, and a time frame period containing 100 code elements. Through binary "0", "1" and position identifier three code types, it can accurately provide time information such as year, day, hour, minute, second, etc., and realize high-precision time synchronization.
[0003] IRIGB code exists in two types: IRIGB(AC) code and IRIGB(DC) code. Among them, IRIGB(DC) code can achieve synchronization accuracy of dozens of nanoseconds with TTL interface and RS422(V.11) interface; IRIG-B(AC) code adopts a balanced interface, and the synchronization accuracy is generally between 10ms-20ms. These two types of IRIGB code are widely used in frequency calibration and time synchronization links in many fields such as power systems, and have become a standard time code encoding format.
[0004] At present, the existing IRIGB code sources on the market are mostly based on satellite timekeeping systems such as Beidou or GPS, and are equipped with high-precision crystal oscillators, which can provide nanosecond-level time accuracy and have rich external interfaces such as RS232, RS485 and network interface. However, such existing technologies still have obvious defects: first, the overall structure of the existing IRIGB source device is complex and bulky, which is extremely inconvenient to carry and deploy in actual application scenarios, especially in mobile operation or space-limited environments; second, the existing device lacks an IRIGB source error mode generation method, which makes it difficult to simulate various error scenarios during system debugging, fault troubleshooting and performance testing, and cannot fully evaluate the stability and reliability of the device and system, greatly increasing the debugging difficulty and time cost, and seriously affecting the work efficiency and product quality optimization process. SUMMARY
[0005] Therefore, the application provides an IRIGB code generation method based on a standard serial interface, which comprises the following steps: modifying the baud rate or working clock of a serial interface driver of a device; setting the baud rate corresponding to the serial interface in response to the modification of the baud rate or working clock of the serial interface driver of the device; obtaining a required initial coordinated universal time, constructing 100 code types according to the requirements of IRIGB and sending the code types through the serial interface; adding 1 to the coordinated universal time after sending a group of 100 IRIGB code types; and repeating the above steps of sending the code types and adding 1 to the coordinated universal time.
[0006] In a possible implementation, the serial interface of the device is an RS485 interface.
[0007] In a possible implementation, in response to the serial interface of the device being an RS232 interface, an RS485 converter is used to convert to an RS485 interface.
[0008] In a possible implementation, the baud rate of the driver of the serial interface is modified to support 1000 baud rate.
[0009] In a possible implementation, the working clock of the serial interface is increased by 1.2 times, and the baud rate of the serial interface is set to 1200.
[0010] In a possible implementation, the required initial coordinated universal time is obtained through a network time synchronization mode.
[0011] In a possible implementation, the 100 code types are represented by data bits, 2ms code types send 0xFE, 5ms code types send 0xF0, and 8ms code types send 0x80.
[0012] In a possible implementation, the sending queue of the serial interface for sending the code types is not empty.
[0013] In a possible implementation, the device is a personal computer, a notebook computer or a single-chip microcomputer.
[0014] In a possible implementation, the method further comprises the step of storing and backing up the IRIGB code data after sending.
[0015] Advantages of the application:
[0016] From the applicability of the device, the method can generate IRIGB code types by using any existing serial port device in the field. This means that there is no need to additionally purchase special and complex devices, thereby reducing the use cost and resource investment. No matter whether it is a personal computer, a notebook computer or a single-chip microcomputer, as long as the device has a serial port, the method can be easily applied, thereby greatly improving the utilization rate of the device and reducing resource waste.
[0017] In terms of code type generation convenience, the method can conveniently generate various IRIGB code types. By modifying the baud rate or working clock of the device serial interface driver, the baud rate corresponding to the serial interface is flexibly set, and the code type is constructed and sent according to the requirements of IRIGB. After each group of code types is sent, the coordinated universal time is automatically incremented by 1 and continuously circulates, and the operation process is simple and efficient. At the same time, the starting coordinated universal time can be accurately obtained through network time, further ensuring the accuracy and convenience of code type generation. In addition, the sent IRIGB code data can be stored and backed up, which is convenient for subsequent query and analysis.
[0018] Other features and aspects of the present application will become apparent from the following detailed description of exemplary embodiments, taken in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate examples of the present application and together with the description, serve to explain the principles of the present application.
[0020] Figure 1 A flow chart showing the generation of IRIGB codes by embodiments of the present application;
[0021] Figure 2 A structural diagram showing a possible IRIGB code generation device according to the present application;
[0022] Figure 3 A flow chart showing the serial port-based IRIGB code configuration and sending process according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] Various exemplary embodiments, features and aspects of the present application will be described in detail below with reference to the accompanying drawings. The same reference numerals in the drawings represent functionally the same or similar elements. Although various aspects of the embodiments are shown in the drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
[0024] It should be understood that the terms "center", "longitudinal", "transverse", "length", "width", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application or simplifying the description, and therefore cannot be understood as indicating or implying that the indicated device or element must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as limiting the present application.
[0025] In addition, the terms "first", "second", etc. are used only for descriptive purposes and do not connote or imply relative importance or a quantity of the indicated technical features. Thus, a feature defined with "first", "second", etc. can include one or more of the features explicitly or implicitly. In the description of the present application, the meaning of "a plurality" is two or more, unless otherwise expressly and specifically defined.
[0026] The word "exemplary" is used herein to mean "serving as an example, instance, or illustration." Any implementation described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other implementations.
[0027] In addition, numerous specific details are set forth in the following description in order to provide a thorough understanding of the present application. Those skilled in the art will understand, however, that the present application can be practiced without certain specific details being presented. In some instances, well-known methods, structures, elements, and circuits have not been described in detail in order to avoid obscuring the present application.
[0028] The present application is a method for generating IRIG B code based on standard serial interface, which is applied in the field / equipment of IRIG B code generation and debugging, and plays a role of generating IRIG B code conveniently and quickly and debugging the generated IRIG B code.
[0029] With specific reference to Figure 1 , as a specific embodiment of the present application scheme includes the following steps:
[0030] Step 101, modify the baud rate or working clock of the serial interface driver of the device. In this step, the device to be used as an IRIG B signal source is first set up. Since the standard serial port needs to set a baud rate, which represents the time interval of each bit. The serial port physical layer protocol stipulates that for each byte of data sent, a start bit is sent, then a byte of data is sent, a check bit is sent, and finally an end bit is sent. The start bit is low, and the end bit is high. Taking 8-bit user data as an example, for each group of 8-bit user data sent, a total of 10 bits of data are actually sent. Then combined with the characteristics of IRIG B code, the pulse width of each code type is 2ms, 5ms and 8ms when the high level. If the time interval of a bit is 1ms, then 10 bits can be used to represent any one code type. The serial port baud rate is set to 1KBps, and 1+10000000+0 is sent to represent 2ms, 1+11110000+0 is sent to represent 5ms, and 1+11111110+0 is sent to represent 8ms. In this way, the serial port can be used to send any code type combination of IRIG B code. Therefore, to use a device with a serial port as an IRIG B signal source, the function of the serial port must first be set. This setting includes two ways, one is to modify the baud rate of the driver, and the other is to adjust the working clock. In the specific implementation process, either way can be selected for setting.
[0031] Specifically, the serial interface is configured as 8-bit data bits, 1-bit stop bits, and no check bits.
[0032] In step 102, in response to modifying the baud rate or working clock of the serial interface driver of the device, the baud rate corresponding to the serial interface is set. The baud rate is set to 1KBps, ensuring that the time interval of each bit is 1ms, so that 10 bits of data can accurately represent the IRIG B code type, i.e. 2ms, 5ms or 8ms.
[0033] Specifically, if the serial port working clock remains unchanged, the baud rate is directly set to 1000 (i.e. 1KBps), at which time the time interval of each bit is 1ms, because the value of the baud rate directly corresponds to the number of code elements transmitted per second, and a baud rate of 1000 means that 1 bit is transmitted per 1ms. If the serial port working clock is increased by 1.2 times through hardware adjustment in step 101, the baud rate needs to be set to 1200. Through the coordinated adjustment of the clock and the baud rate, the time interval of each bit can still be stabilized at 1ms, thereby meeting the precise requirements of the IRIG B code type on pulse width.
[0034] The core principle of the setting is that IRIGB code type represents different data bits through different pulse widths (2ms, 5ms, 8ms), and each pulse width needs to be composed of multiple consecutive bits (such as 2ms corresponding to 2 bit intervals). By accurately setting the matching relationship between the baud rate and the clock, it is ensured that each group of 10-bit data sent by the serial port can be accurately mapped to the target pulse width, laying a foundation for subsequent code type construction and time synchronization.
[0035] In step 103, the required initial coordinated universal time is obtained, 100 code types are constructed according to the requirements of IRIGB and sent through the serial interface. The construction of 100 code types corresponds to the IRIGB second frame format, contains time information (year, day, hour, minute, second), and realizes time synchronization through serial transmission.
[0036] When constructing the code type, different data bit combinations are used to represent specific pulse widths: 0xFE corresponds to a 2ms code type, 0xF0 corresponds to a 5ms code type, and 0x80 corresponds to an 8ms code type. Each group of 100 code types needs to be strictly arranged according to the time coding rules of the IRIGB protocol, for example, the first, second, and eleventh bytes are fixed as 0x80, and the other bytes are assigned values according to the time information.
[0037] After completing the construction of the code type, the data is sent byte by byte through the serial port (such as the RS485 interface). During the sending process, it is necessary to ensure that the serial port sending queue is not empty to avoid code type distortion due to transmission interruption, so as to ensure that the receiving device can continuously and accurately analyze the time synchronization signal.
[0038] In step 104, after sending a group of 100 IRIGB code types, the coordinated universal time is incremented by 1; and the above steps of sending code types and incrementing the coordinated universal time by 1 are repeated. After sending 1 second of data, that is, 100 code types, the coordinated universal time is updated, and the continuous time code output is realized to maintain the continuity of clock synchronization.
[0039] IRIGB code is transmitted at a rate of 1 frame per second, that is, 100 code types, so after completing the sending of a group of code types, the UTC time needs to be automatically incremented by 1 second to realize the continuous evolution of time. This process is automatically triggered by software logic and does not require manual intervention: after the serial port completes the sending of 100 code types, the system reads the current accumulated UTC time, reconstructs the next frame of 100 code types, contains the updated time information, and sends it again through the serial port.
[0040] The design of the cycle mechanism ensures the continuity of the time code output, meeting the needs of real-time synchronization scenarios. For example, in power systems, each device needs to continuously receive the latest time code to maintain microsecond-level synchronization. Through this cycle process, system deviation caused by time interruption can be avoided. At the same time, the strict alignment of time accumulation and code type transmission ensures the timing accuracy of the IRIGB code, enabling the receiving end to achieve high-precision time synchronization by analyzing the timestamp in the code type.
[0041] In a possible implementation, the serial interface of the device is an RS485 interface. The RS485 interface supports multi-point communication and long-distance transmission, has strong anti-interference ability, and is suitable for industrial environments. Using this interface can achieve reliable communication between the device and multiple slaves, reduce signal attenuation and noise interference, improve data transmission stability, reduce communication failure probability, and is particularly suitable for clock synchronization applications in distributed control systems.
[0042] In a possible implementation, in response to the serial interface of the device being an RS232 interface, an RS485 converter is used to convert to an RS485 interface. By converting RS232 to RS485 through the converter, the resources of existing RS232 devices can be fully utilized, protecting investment costs. The differential signal transmission characteristics of RS485 significantly enhance communication reliability, solving the problems of short transmission distance and susceptibility to interference of RS232, enabling old devices to also meet industrial communication needs and extending the service life of the device.
[0043] In a possible implementation, in step 101, the baud rate of the drive of the serial interface is modified to support 1000 baud rate. Increasing the baud rate to 1000 bps can speed up data transmission, shorten the transmission delay of clock synchronization information, and improve system real-time performance. For distributed systems that need frequent synchronization, higher baud rates can reduce synchronization periods, reduce clock accumulation errors, and make the times of each device more accurately consistent, which is particularly suitable for industrial measurement and control scenarios with high time accuracy requirements.
[0044] In a possible implementation, in step 101, the working clock of the serial interface is increased by 1.2 times, and the baud rate of the serial interface is set to 1200. By increasing the working clock and baud rate to 1200 bps, data transmission efficiency is further optimized, and the transmission time of a single frame of data is reduced. This not only improves the response speed of clock synchronization, but also transmits more synchronization information in the same time, enhances the processing capacity of the system for sudden synchronization needs, while maintaining compatibility with standard baud rates and reducing protocol adaptation costs.
[0045] In a possible implementation, the required initial Coordinated Universal Time is obtained in step 103 by network time synchronization. The Coordinated Universal Time is obtained by using network time synchronization such as NTP / PTP protocol, which can automatically calibrate the device clock without manual intervention, eliminating the human error caused by manual setting. The network time synchronization has a precision of milliseconds or even higher, ensuring that the device time is synchronized with the international standard time, providing a unified time reference for the distributed system, and improving the consistency of cross-device data interaction.
[0046] In a possible implementation, the 100 code types in step 103 are represented by data bits, in which the 2 ms code type sends 0xFE, the 5 ms code type sends 0xF0, and the 8 ms code type sends 0x80. Different lengths of code types are used to represent specific data, forming an encoding mechanism, which can realize parallel transmission of multiple information on a single serial channel. This encoding method has strong anti-interference ability, and the receiving end can accurately analyze the data by detecting the pulse width, improving the transmission reliability of the clock synchronization signal, reducing the bit error rate, and being especially suitable for time synchronization applications in complex electromagnetic environments.
[0047] In a possible implementation, the sending queue of the serial interface of the code type sent in step 103 is not empty. Ensuring that the sending queue is not empty can avoid data loss caused by queue overflow, and ensure that the code type data is sent continuously and completely. By monitoring the queue state and dynamically adjusting the sending strategy, the data flow control can be optimized, the communication congestion caused by burst data flood can be prevented, the system stability can be improved, and the method is especially suitable for IRIGB clock synchronization systems that need to continuously send long time sequence code types.
[0048] In a possible implementation, the device is a personal computer, a notebook computer, or a single-chip microcomputer. Supporting multiple device types makes the clock synchronization technology have wide applicability. The personal computer and the notebook computer can be used as a monitoring center to realize centralized time synchronization management, and the single-chip microcomputer is suitable for embedded applications, providing accurate clocks for small and low-power devices. This flexibility allows the selection of hardware platforms according to actual needs, reduces the difficulty of system integration, and expands the application scenarios of the technology.
[0049] In a possible implementation, the method further includes a step 105 of storing and backing up the IRIGB code data sent. Storing and backing up the IRIGB code data can establish a time synchronization log, which is convenient for subsequent fault tracing and data analysis. In the case of clock deviation or communication anomaly, the synchronization process can be restored through historical data to quickly locate the problem source. At the same time, the backup data can provide a time rollback mechanism for the system, ensuring that a certain precision time reference can be maintained when the main clock source fails, and enhancing the fault tolerance of the system.
[0050] Specific reference Figure 2 as a specific embodiment of the present application, Figure 2A structure diagram of a possible IRIGB code generating device of the present application is shown. The device comprises a host computer 201, RS232 to RS485 serial interface 202 and IRIGB signal receiving equipment 203. The host computer 201 comprises serial interface IRIGB software 210 and RS232 serial port 211. The RS232 serial port 211 is connected to the RS232 to RS485 serial interface 202. The RS232 to RS485 serial interface 202 is connected to the IRIGB signal receiving equipment 203.
[0051] Specific reference Figure 3 , as a specific embodiment of the present application, Figure 3A serial port based IRIG B code configuration and sending process flowchart of the embodiment of the application is shown. In step 301, the command parameters are parsed. In step 302, it is judged whether the parsing is successful. If the parsing is successful, step 303 is entered, and if the parsing fails, step 312 is entered. In step 303, according to the command parameters, the serial interface device for sending is opened. In step 304, it is judged whether the opening is successful. If the opening is successful, step 305 is entered, and if the opening fails, step 312 is entered. In step 305, the IRIG B code frame buffer data is initialized and assigned. The 1st, 2nd, 11th, 21st, 31st, 41st, 51st, 61st, 71st, 81st, 91st byte data is assigned a value of 0x80, the 7th, 16th, 26th, 36th, 36th, 46th, 56th, 62nd, 63rd, 64th, 65th, 78th, 79th, 80th, 82nd, 83rd, 84th, 85th, 86th, 87th, 88th, 89th, 9th, 92nd, 93rd, 94th, 95th, 96th, 97th, 98th, 99th, 100th byte data is assigned a value of 0xFE, and the 66th, 67th, 68th, 69th, 70th byte data is assigned according to the time zone offset configuration of the command line parameters, the 72nd byte data is assigned according to the half-hour offset configuration of the command line parameters, and the 73rd, 74th, 75th, 76th byte data is assigned according to the time quality configuration of the command line parameters. In step 306, it is judged whether the time information is configured by the command line parameters. If the time information is configured, step 307 is entered, and if the time information is not configured, step 313 is entered. In step 307, the time configured by the command line is parsed, and the second time is initialized using the same. In step 308, the IRIG B code frame buffer data is updated and assigned. According to the second time data, the 3rd, 4th, 5th, 6th, 8th, 9th, 10th byte time-second value, the 12th, 13th, 14th, 15th, 17th, 18th, 19th, 20th byte time-minute value, the 22nd, 23rd, 24th, 25th, 27th, 28th, 29th, 30th byte time-hour value, the 32nd, 33rd, 34th, 35th, 37th, 38th, 39th, 40th, 42nd, 43rd, 44th, 45th, 47th, 48th, 49th, 50th byte time-day value, the 52nd, 53rd, 54th, 55th, 57th, 58th, 59th, 60th byte time-year value are calculated and assigned, and the 77th byte data is calculated and assigned as the parity check value according to the parity check configuration of the command line parameters. In step 309, the IRIG B code frame buffer data is written into the serial interface device file. In step 310, the second time is incremented by one. In step 311, it is judged whether the program receives a termination signal. If the program receives a termination signal, step 311 is entered, and if the program does not receive a termination signal, step 308 is entered. In step 312, the serial port device is closed, and the program exits. In step 313, the current system time is acquired, and the second time is initialized using the same, and step 308 is entered.
[0052] Having described various embodiments of the application, it is to be understood that the above description is meant not to limit and not to encompass all of the possible embodiments. Many modifications and variations of this application can be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. It is intended that the scope of the application be defined by the scope of the patent and by the claims as allowed by the patent office, which can include adaptations based on the description, equivalents, and / or substitutions of elements individually or collectively to the entire disclosure.
Claims
1. A method for generating IRIGB codes based on a standard serial interface, characterized in that, Includes the following steps: S100: Modify the baud rate or operating clock of the device's serial interface driver; S200: In response to changes in the baud rate or operating clock of the device's serial interface driver, set the baud rate corresponding to the serial interface. S300: Obtain the required initial Coordinated Universal Time, construct 100 code patterns according to IRIGB requirements, and send the code patterns through the serial interface. When constructing the code patterns, a specific pulse width is represented by different combinations of data bits. S400: After each group of 100 IRIGB codes is sent, the Coordinated Universal Time (UTC) is incremented by 1; as well as Repeat steps S300 and S400.
2. The IRIGB code generation method based on a standard serial interface according to claim 1, characterized in that, The serial interface of the device is an RS485 interface.
3. The IRIGB code generation method based on a standard serial interface according to claim 1, characterized in that, Since the serial interface of the device is RS232, an RS485 converter is used to convert it to an RS485 interface.
4. The IRIGB code generation method based on a standard serial interface according to claim 2 or 3, characterized in that, Modify the baud rate of the serial interface driver to support 1000 baud rate.
5. The IRIGB code generation method based on a standard serial interface according to claim 2 or 3, characterized in that, The operating clock of the serial interface is increased by 1.2 times, and the baud rate of the serial interface is set to 1200.
6. The IRIGB code generation method based on a standard serial interface according to claim 1, characterized in that, In step S300, the required initial Coordinated Universal Time (UTC) is obtained through network time synchronization.
7. The IRIGB code generation method based on a standard serial interface according to claim 1, characterized in that, In step S300, the 100 code patterns are represented by data bits, wherein the 2ms code pattern sends 0xFE, the 5ms code pattern sends 0xF0, and the 8ms code pattern sends 0x80.
8. The IRIGB code generation method based on a standard serial interface according to claim 1, characterized in that, In step S300, the transmission queue of the serial interface that transmits the code pattern is not empty.
9. The IRIGB code generation method based on a standard serial interface according to claim 1, characterized in that, The device is a personal computer, a laptop computer, or a microcontroller.
10. The IRIGB code generation method based on a standard serial interface according to claim 1, characterized in that, It also includes steps for storing and backing up the transmitted IRIGB code data.
Citation Information
Patent Citations
Baud rate adaptive method for UART, device and UART
CN103684678A
IRIG-B type code (DC) time service realization system and method based on FPGA
CN109687928A