A SOE time scale generation method, system, control device and IO module

CN122923640APending Publication Date: 2026-10-16XJ ELECTRIC CO LTD +2
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202610872276.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-16
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

[0004]本发明的目的在于提供一种SOE时标生成方法、系统、控制装置及IO模块,用以解决现有SOE时标生成方法成本较高和软件复杂度高的问题

Benefits of technology

[0022]This method eliminates the need to maintain an absolute time on the IO module, thus avoiding the need for a dedicated time synchronization module and signal lines. Instead, it utilizes the existing counting function to record the corresponding data, synchronizing the IO module's count with the controller's. When an IO change event occurs, the IO module uses the corresponding count as a relative time stamp, while the controller converts the count sent at the time of the IO change event into an absolute time stamp, which serves as the SOE time stamp for the IO change event. This solves the problem of generating SOE time stamps in the IO module without increasing hardware costs, reducing the cost and complexity of the IO module software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122923640A_ABST
    Figure CN122923640A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of electric power automation control, and particularly relates to a SOE time mark generation method, system, control device and IO module. The controller sends a first time synchronization message including a time sequence number to the IO module according to a period, records an absolute time when the sending of the first time synchronization message is completed and a first count in a sending completion interrupt, and then sends a second time synchronization message including the time sequence number and the first count to the IO module. The IO module records a second count of receiving the first time synchronization message in a receiving completion interrupt, and performs synchronization of the counts of the controller and the IO module based on the difference between the second count and the first count, so as to correct the count of the IO module when an IO change event occurs, and send the corrected count to the controller as a time mark. The controller determines the SOE time mark under the absolute time based on the first count, the absolute time corresponding to the first count and the time mark sent by the IO module, so that a clock module of the absolute time does not need to be maintained in the IO module, and the cost of the IO module is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of power automation control technology, specifically relating to an SOE time stamp generation method, system, control device, and IO module. Background Technology

[0002] In industrial control, industrial control systems need to upload SOE (Sequence of Event) records to ensure the timing accuracy of control nodes when performing actions such as sending and receiving messages, control, and recording incidents. In the power sector, the system needs to upload SOE records to document I / O changes. Generally, the SOE timestamp resolution is required to be no greater than 2ms, while power equipment design specifications typically require 1ms. Because PLCs or DCS controllers in the power sector have numerous I / O modules, and communication between the controller and these modules is via a bus, the limitations of bus communication mean that when the controller refreshes to an I / O change event, the actual occurrence time of the event exceeds 2ms. Therefore, the I / O modules usually need to provide precise timestamps for these events.

[0003] To meet SOE time stamp accuracy requirements, existing technologies often employ absolute time stamp synchronization methods to synchronize the I / O module's time. For example, the I / O module maintains a time module, using EtherCAT clock synchronization or adding independent time synchronization signals (such as B-code or second pulses) to synchronize the clock module within the I / O module. When an I / O change event occurs, the current absolute time stamp is obtained through the time module and sent to the controller along with the I / O change event. For instance, Chinese patent application CN113225151A discloses a clock synchronization system, method, and apparatus based on a CAN bus. Both the I / O communication module and the SOE module are configured with clocks. The I / O communication module connects to the controller via Ethernet and calibrates its own absolute time based on the received second pulse signal. The I / O communication module sends clock synchronization data frames to the SOE module. The SOE module parses the clock synchronization data frames to obtain the calibrated time and updates its clock when the calibrated time is deemed valid, thereby improving the accuracy of the SOE in recording action times. These methods that use absolute time stamps usually require increased hardware investment, such as adding time synchronization modules and clock modules. Furthermore, the IO module needs to maintain a time module, resulting in high software complexity and increased IO module costs. Summary of the Invention

[0004] The purpose of this invention is to provide an SOE timescale generation method, system, control device, and IO module to solve the problems of high cost and high software complexity in existing SOE timescale generation methods.

[0005] To address the aforementioned technical problems, the first aspect of this invention provides a method for generating SOE timescales, comprising: The controller sends the first pair of time messages to the IO module according to the cycle. Upon completion of the transmission, it records the absolute time and count when the first pair of time messages are sent. This count is used as the first count. The first pair of time messages includes the time sequence number. After the first pair of time messages is sent, the controller sends a second pair of time messages to the IO module. The second pair of time messages includes the time sequence number and the first count. The IO module records the count of the first pair of messages received during the receive completion interrupt, which is used as the second count; and obtains the first count from the second pair of messages, calculates the difference between the second count and the first count, and records it as the current deviation; The IO module records the count of IO change events, corrects the count using the current deviation, and sends the corrected count as a time stamp to the controller. The controller determines the SOE time stamp under absolute time based on the first count, the absolute time corresponding to the first count, and the time stamp sent by the IO module.

[0006] In one possible implementation, the SOE time stamp in absolute time is calculated by superimposing the absolute time corresponding to the first count with the time stamp sent by the IO module and the deviation of the first count.

[0007] In one possible implementation, the correction refers to the count at the time the event occurred minus the current deviation.

[0008] In one possible implementation, the IO module also sends a time stamp quality to the controller, which includes abnormal and normal time stamp quality. An abnormal time stamp quality includes: the time when the IO module has not received the correct time synchronization message has reached a set time. The time synchronization message includes a first time synchronization message and a second time synchronization message.

[0009] In one possible implementation, the counting is obtained using clock ticks.

[0010] In one possible implementation, the first and second time synchronization messages contain a checksum. The IO module may fail to receive the correct time synchronization message if: the first time synchronization message fails to checksum, the second time synchronization message fails to checksum, or the synchronization sequence numbers of the first and second time synchronization messages are inconsistent.

[0011] In one possible implementation, the period for sending the first pair of messages is determined based on the maximum duration of the timestamp sent by the IO module, which is determined based on the maximum value of the timestamp and the counting unit.

[0012] To address the aforementioned technical problems, a second aspect of the present invention provides a control device, including a controller. The controller is configured to communicate with an I / O module via a bus. The controller is further configured to periodically send a first pair of time messages to the I / O module, and upon completion of the transmission, interrupt and record the absolute time and count at the time the first pair of time messages are completed, using this count as a first count. The first pair of time messages includes a timing sequence number. After the first pair of time messages are transmitted, a second pair of time messages is sent to the I / O module, the second pair of time messages including the timing sequence number and the first count. The controller also includes a time stamp sent by the I / O module after correcting the count for I / O changes based on the first and second pair of time messages, and determining an SOE time stamp under absolute time based on the first count, the absolute time corresponding to the first count, and the time stamp sent by the I / O module.

[0013] To address the aforementioned technical problems, a third aspect of the present invention provides an I / O module for communicating with a controller via a bus. The I / O module is also used to receive a first pair of time messages and a second pair of time messages sent by the controller periodically. The first pair of time messages includes a timing sequence number, and the second pair of time messages includes the timing sequence number and a first count. The first count is the count taken by the controller when the first pair of time messages in the transmission completion interrupt record are completed. The count received in the reception completion interrupt record of the first pair of time messages is used as a second count. The first count is obtained from the second pair of time messages, and the difference between the second count and the first count is calculated and recorded as the current deviation. The current deviation is used to correct the count at the time of the I / O change event, and the corrected count is sent to the controller as a time stamp.

[0014] To address the aforementioned technical problems, a fourth aspect of the present invention provides an SOE timescale generation system, including a controller and an I / O module. This system is used to implement the steps of an SOE timescale generation method, which includes: The controller sends the first pair of time messages to the IO module according to the cycle. Upon completion of the transmission, it records the absolute time and count when the first pair of time messages are sent. This count is used as the first count. The first pair of time messages includes the time sequence number. After the first pair of time messages is sent, the controller sends a second pair of time messages to the IO module. The second pair of time messages includes the time sequence number and the first count. The IO module records the count of the first pair of messages received during the receive completion interrupt, which is used as the second count; and obtains the first count from the second pair of messages, calculates the difference between the second count and the first count, and records it as the current deviation; The IO module records the count of IO change events, corrects the count using the current deviation, and sends the corrected count as a time stamp to the controller. The controller determines the SOE time stamp under absolute time based on the first count, the absolute time corresponding to the first count, and the time stamp sent by the IO module.

[0015] In one possible implementation, the SOE time stamp in absolute time is calculated by superimposing the absolute time corresponding to the first count with the time stamp sent by the IO module and the deviation of the first count.

[0016] In one possible implementation, the correction refers to the count at the time the event occurred minus the current deviation.

[0017] In one possible implementation, the IO module also sends a time stamp quality to the controller, which includes abnormal and normal time stamp quality. An abnormal time stamp quality includes: the time when the IO module has not received the correct time synchronization message has reached a set time. The time synchronization message includes a first time synchronization message and a second time synchronization message.

[0018] In one possible implementation, the counting is obtained using clock ticks.

[0019] In one possible implementation, the first and second time synchronization messages contain a checksum. The IO module may fail to receive the correct time synchronization message if: the first time synchronization message fails to checksum, the second time synchronization message fails to checksum, or the synchronization sequence numbers of the first and second time synchronization messages are inconsistent.

[0020] In one possible implementation, the period for sending the first pair of messages is determined based on the maximum duration of the timestamp sent by the IO module, which is determined based on the maximum value of the timestamp and the counting unit.

[0021] The beneficial effects of this invention are as follows: This invention utilizes the communication between the controller and the IO module. The controller sends two synchronization messages to the IO module. The first message sends the synchronization sequence number. Upon interruption after the first synchronization message is sent, the controller's counting function records the current count and obtains the current absolute time using the controller's original absolute time clock. Subsequently, the synchronization sequence number and the count are sent to the IO module. Upon interruption after receiving the first synchronization message, the IO module uses its counting function to record the current count and determines the difference between the two counts based on the count sent by the controller. This difference is used to correct the count recorded by the IO module when the IO change event occurs, thereby compensating for the count, eliminating the zero time difference between the controller and the IO module's counting and the deviation in their communication delay, restoring the count to the one corresponding to the controller, and sending it to the controller as a time stamp. The controller uses the count from the first synchronization message and the corresponding absolute time to restore the absolute time corresponding to this time stamp, thereby generating the SOE coordinates under absolute time.

[0022] This method eliminates the need to maintain an absolute time on the IO module, thus avoiding the need for a dedicated time synchronization module and signal lines. Instead, it utilizes the existing counting function to record the corresponding data, synchronizing the IO module's count with the controller's. When an IO change event occurs, the IO module uses the corresponding count as a relative time stamp, while the controller converts the count sent at the time of the IO change event into an absolute time stamp, which serves as the SOE time stamp for the IO change event. This solves the problem of generating SOE time stamps in the IO module without increasing hardware costs, reducing the cost and complexity of the IO module software. Attached Figure Description

[0023] Figure 1 This is a diagram of the SOE timescale generation system architecture of the present invention; Figure 2 This is a flowchart of the SOE timescale generation method of the present invention; Figure 3 This is a flowchart of how the controller of the present invention restores the SOE timescale to absolute time. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of the present invention clearer, the specific embodiments of the present invention will be further described below with reference to the accompanying drawings.

[0025] This invention utilizes communication between the controller and the I / O module to synchronize only the I / O module's tick count with the controller's tick count. When an I / O change event occurs, the I / O module only records the current tick count. The controller converts the uploaded I / O change event tick count into an absolute timescale, which serves as the SOE timescale for the I / O change event. This method solves the problem of generating SOE timescales for the I / O module without increasing hardware costs. Furthermore, the I / O module does not use an absolute timescale, eliminating the need to maintain an absolute time on the I / O module and avoids issues such as leap seconds (a leap second is added or subtracted to reconcile the difference between Universal Time (UTC) and Earth's rotation time (UT1). Failure to handle leap seconds can lead to SOE timescale errors). This reduces the complexity of the I / O module software, lowers the cost of SOE timescale generation, and significantly improves the accuracy of the SOE timescale.

[0026] SOE Timescale Generation Method Implementation This invention provides a method for generating SOE time stamps, enabling the system to generate SOE time stamps without increasing hardware costs. This method can be used in systems where the controller and I / O modules are connected via a bus. Typical applications include modular PLCs and distributed control systems (DCS). The system bus typically uses high-speed serial communication, and the system architecture is as follows: Figure 1As shown. The communication process generally adopts a master-slave mode, where the controller initiates communication, and the IO module responds after receiving the controller's command.

[0027] like Figure 2 As shown, the SOE timescale generation method of the present invention includes the following process: 1. The controller sends out time messages via broadcast communication.

[0028] The controller maintains two clocks during operation (two clocks maintained by software): one clock supporting absolute timescales of year, month, and day, and the other for counting. In the power system field, the counting module is a core module, generating periodic interrupts to implement task scheduling, delay, timeout, or timing functions. The software systems running the controller and I / O modules generally include a counting module.

[0029] The counting can be done using a tick (clock tick), with one tick cycle as the unit of counting.

[0030] The accuracy of the counting determines the accuracy of the SOE time scale. In embedded systems, system ticks are typically counted in milliseconds (ms). The power industry requires a resolution of 1 ms. When the tick counting unit is large (e.g., 1 ms), even a small error in the tick will make it impossible to distinguish between two events that are just over 1 ms apart. Therefore, the tick counting unit must be smaller than 1 ms to meet the 1 ms resolution requirement of the power industry. Preferably, 100 μs is used as the tick counting unit, which greatly improves the accuracy of the time scale. The tick counting unit can also be set as needed, such as 200 μs, 300 μs, or 500 μs. That is, the counting unit must be smaller than the resolution requirement of the time scale.

[0031] When the controller is working normally, it sends synchronization messages at regular time intervals. The synchronization messages are sent in two parts: the first pair of messages is sent, and the second pair of messages is sent. The first pair of messages is used to send the synchronization sequence number, and the controller records the exact Tick1 and Time1 sent. Subsequently, a broadcast message (i.e., the second pair of messages) is sent again, sending the aforementioned synchronization sequence number and the recorded exact Tick1.

[0032] The message format of the first pair of messages is shown in Table 1. In Table 1, the destination address is the address of the IO module, the source address is the address of the controller, the message type refers to the pair of messages, and the checksum data corresponds to the checksum value of the first pair of messages. The checksum value is used to improve message security. In other implementations, a checksum value may not be set.

[0033] Table 1 Target address Source address Message type For time sequence number check 1 byte (broadcast) 1 byte 1 byte time pair 1 byte 1 byte Each time the first pair of time messages is sent, the sequence number in the first pair of time messages is automatically incremented by one to correspond with the second pair of time messages. The sending period of the first pair of time messages is determined based on the maximum duration of the time stamp sent by the IO module, and must be less than the maximum duration of that time stamp. The maximum duration of the time stamp sent by the IO module is determined based on the maximum value of that time stamp and the counting unit.

[0034] For example, when the time stamp is 14 bits, the maximum value of the time stamp is 16383. If the unit of the time stamp is 0.1ms, the tick will overflow every 1.6383 seconds. Therefore, the transmission period of the first pair of time messages must be less than 1.6383 seconds. In this case, the transmission period can be selected as 1 second, that is, the first pair of time messages is sent once per second. In the interrupt when the first pair of time messages is sent, the current count Tick1 and absolute time Time1 (when the first pair of time messages is sent) are obtained. At this time, the controller records the current count Tick1 and absolute time Time1 on each rising edge of the second.

[0035] Then, a second pair of time messages is sent, transmitting the count Tick1. The message format of the second pair of time messages is shown in Table 2. The sequence number is the same as the sequence number in the first pair of time messages, and Tick is the count Tick1 received when the first pair of time messages was sent. The checksum data corresponds to the checksum value in the second pair of time messages.

[0036] Table 2 Target address Source address Message type For time sequence number Tick check 1 byte (broadcast) 1 byte 1 byte 1 byte 2 bytes 1 byte Checksums are used to improve message security. In other implementations, checksums may not be set.

[0037] The check value can be obtained using the CRC algorithm, or other check algorithms such as hash algorithm, MD5 algorithm or SHA algorithm.

[0038] 2. Processing procedure at the IO module end.

[0039] The IO module only needs to maintain one counting module, such as maintaining a tick with a counting unit of 0.1ms.

[0040] The processing steps of the IO module include: 1) Time-based process.

[0041] During the time synchronization process, the IO module will receive two synchronization messages from the controller. The process is as follows: After the IO module receives the first communication message, it records the reception time Tick2 in the reception completion interrupt, which is the exact Tick2 after receiving the first communication message (IO module side).

[0042] After receiving the second pair of time messages sent for the second time, the system retrieves Tick1 from the second pair of time messages. Using Tick1 and Tick2, it calculates the time difference between the controller and the I / O module, and uses this time difference to correct the I / O module's tick count. This time difference includes the zero time difference between the controller and the I / O module's tick counts and the deviation in communication latency.

[0043] If the first and second time pairs contain checksums, the IO module, upon receiving the first time pair, will perform a check on it, such as a CRC check. If the check is successful, the synchronization sequence number in the current time pair will be recorded. If the check fails, the synchronization is invalid.

[0044] After receiving the second time synchronization message, the IO module verifies it. If the verification is successful, it retrieves the synchronization sequence number and Tick1 from the message. If the verification fails, the synchronization is invalid.

[0045] Determine whether the synchronization sequence number of the second synchronization message is consistent with the synchronization sequence number of the first synchronization message. If they are inconsistent, the synchronization is invalid. If they are consistent, record the current Tick deviation of the IO module, Tick3, where Tick3 = Tick2 - Tick1.

[0046] 2) Generate time stamps.

[0047] After detecting an I / O change event, the I / O module generates a timestamp for the event, stores the timestamp in a buffer, and sends the timestamp to the controller during data interaction. The process of the I / O module generating the timestamp is as follows: Get the tick number when the IO change event occurs, and denote it as Tick4.

[0048] Tick4 is corrected using the current Tick deviation Tick3 to obtain the Tick at the controller end corresponding to Tick4, i.e., Tick5, where Tick5 = Tick4 - Tick3.

[0049] Tick5 is sent to the controller as a time stamp.

[0050] In one embodiment, the status of an IO change event is sent to the controller along with a timestamp. The status of the IO change event includes a response and an action.

[0051] In one embodiment, timescale quality is also sent to the controller. Timescale quality includes normal and abnormal, for example, 1 represents abnormal and 0 represents normal.

[0052] In a preferred embodiment, the IO module assembles the state, timescale quality, and timescale of the IO change event into an SOE and sends it to the controller.

[0053] To reduce bus data traffic, each SOE occupies 2 bytes. The highest bit of the high byte indicates the SOE's status (i.e., the status of IO change events), the second bit indicates the time stamp quality, and the remaining 14 bits represent the SOE's time stamp. The maximum time stamp value is 16383. If the time stamp's counting unit is 0.1ms, the tick will overflow every 1.6383 seconds. The controller must then read the IO module's SOE within 1.6383 seconds and restore it to an absolute time stamp; otherwise, a time stamp restoration error will occur. The SOE format at this time is shown in Table 3.

[0054] Table 3 Bit Bit15 Bit14 Bit13-Bit0 significance Status (0 - Return, 1 - Action) Time-scaled quality (0 - normal, 1 - abnormal) Time Scale In other embodiments, the time stamp may be placed in the first 14 bits.

[0055] The number of data bits for the time stamp can be set as needed, and more data bits can be set, such as 22 data bits, in which case SOE occupies 3 bytes.

[0056] 3. The controller restores the time stamp to absolute time and uses the obtained absolute time as the SOE time stamp.

[0057] After receiving the SOE data from the IO module, the controller needs to restore the time stamp in the SOE to absolute time. As shown in Table 3, when the time stamp occupies the lower 14 bits of the SOE data, the process of restoring the time stamp to absolute time is as follows: Figure 3 As shown, it includes: 1) Take the lower 14 bits of Tick1 and save them as tick_pps.

[0058] 2) Take the lower 14 bits (Tick5) of the SOE data and save it as tick_soe.

[0059] 3) Calculate the deviation between Tick1 and Tick5: tick_diff = tick_soe - tick_pps.

[0060] 4) Take the lower 14 bits of tick_diff.

[0061] 5) Correct Time1 with tick_diff to get Time_soe, which is the SOE timescale of absolute time.

[0062] If the IO module fails to receive a correct synchronization message for a set period of time, resulting in abnormal time synchronization and a time stamp quality issue, the time stamp quality will be set to 1 to prevent time stamp corruption. The set period can be designed according to requirements; for example, if no normal synchronization message is received within 60 seconds, an error is considered.

[0063] When the controller determines that the time stamp quality (e.g., Bit 14) of the received SOE is 1, it sets the SOE to an abnormal flag.

[0064] Based on the specific implementation methods described above, the SOE timescale generation method of the present invention includes the following steps: S1: The controller sends the first pair of time messages to the IO module periodically. Upon completion of the transmission, an interrupt is triggered to record the absolute time and count at which the first pair of time messages are completed. This count is used as the first count. The first pair of time messages includes a timing number. After the first pair of time messages is transmitted, the controller sends the second pair of time messages to the IO module. The second pair of time messages includes the aforementioned timing number and the first count.

[0065] S2: The IO module records the count of the first pair of messages received during the interrupt of receiving, and uses it as the second count; it also obtains the first count from the second pair of messages, calculates the difference between the second count and the first count, and records it as the current deviation.

[0066] S3: The IO module records the count when IO change events occur, corrects the count using the current deviation, and sends the corrected count as a time stamp to the controller.

[0067] Correction refers to subtracting the current deviation from the count when an IO change event occurs.

[0068] S4: The controller determines the SOE time stamp under absolute time based on the first count, the absolute time corresponding to the first count, and the time stamp sent by the IO module.

[0069] The SOE time stamp in absolute time is calculated by superimposing the absolute time corresponding to the first count with the deviation between the time stamp sent by the IO module and the first count.

[0070] The IO module also sends time stamp quality to the controller, which includes abnormal and normal time stamp quality. Abnormal time stamp quality includes: the time when the IO module does not receive the correct time synchronization message reaches the set time. The time synchronization message includes the first time synchronization message and the second time synchronization message.

[0071] If the difference between the current time of the count sent by the I / O module and the SOE time stamp exceeds the period of the first pair of messages sent, the controller will set the quality of the received time stamp to abnormal.

[0072] The first and second pairing messages contain a checksum. The IO module may not receive the correct pairing message if: the first pairing message fails to checksum, the second pairing message fails to checksum, or the pairing sequence numbers of the first and second pairing messages are inconsistent.

[0073] The period for sending the first pair of messages is determined based on the maximum duration of the timestamp sent by the IO module, which is determined based on the maximum value of the timestamp and the counting unit.

[0074] SOE Timescale Generation System Implementation The present invention provides an SOE timescale generation system, including a controller and an I / O module, which is used to implement the steps of an SOE timescale generation method.

[0075] The controller and I / O module of the SOE timescale generation system communicate via a bus. The system can be a modular PLC or a distributed control system (DCS). The bus can use high-speed serial communication. The communication process generally adopts a master-slave mode, where the controller initiates the communication and the I / O module responds after receiving the controller's command.

[0076] The SOE timescale generation method includes the following steps: S1: The controller sends the first pair of time messages to the IO module periodically. Upon completion of the transmission, an interrupt is triggered to record the absolute time and count at which the first pair of time messages are completed. This count is used as the first count. The first pair of time messages includes a timing number. After the first pair of time messages is transmitted, the controller sends the second pair of time messages to the IO module. The second pair of time messages includes the aforementioned timing number and the first count.

[0077] S2: The IO module records the count of the first pair of messages received during the interrupt of receiving, and uses it as the second count; it also obtains the first count from the second pair of messages, calculates the difference between the second count and the first count, and records it as the current deviation.

[0078] S3: The IO module records the count when IO change events occur, corrects the count using the current deviation, and sends the corrected count as a time stamp to the controller.

[0079] Correction refers to subtracting the current deviation from the count when an IO change event occurs.

[0080] S4: The controller determines the SOE time stamp under absolute time based on the first count, the absolute time corresponding to the first count, and the time stamp sent by the IO module.

[0081] The SOE time stamp in absolute time is calculated by superimposing the absolute time corresponding to the first count with the deviation between the time stamp sent by the IO module and the first count.

[0082] The IO module also sends time stamp quality to the controller, which includes abnormal and normal time stamp quality. Abnormal time stamp quality includes: the time when the IO module does not receive the correct time synchronization message reaches the set time. The time synchronization message includes the first time synchronization message and the second time synchronization message.

[0083] The first and second pairing messages contain a checksum. The IO module may not receive the correct pairing message if: the first pairing message fails to checksum, the second pairing message fails to checksum, or the pairing sequence numbers of the first and second pairing messages are inconsistent.

[0084] The period for sending the first pair of messages is determined based on the maximum duration of the timestamp sent by the IO module, which is determined based on the maximum value of the timestamp and the counting unit.

[0085] The method will be described below with a specific implementation process.

[0086] 1. The controller sends out time messages via broadcast communication.

[0087] The controller maintains two clocks during operation: one supporting absolute timescales of year, month, and day, and the other for counting. In the power system field, the counting module is a core component, generating periodic interrupts to perform task scheduling, delays, timeouts, or timing functions. The software systems running the controller and I / O modules typically include a counting module.

[0088] The counting can be done using a tick (clock tick), with one tick cycle as the unit of counting.

[0089] The counting unit for ticks must meet the resolution requirements of the power industry. Preferably, 100µs is used as the counting unit for ticks, which greatly improves the accuracy of the time scale. The counting unit for ticks can also be set as needed, such as 200µs, 300µs, or 500µs. That is, the counting unit must be smaller than the resolution requirement of the time scale.

[0090] When the controller is working normally, it sends synchronization messages at regular time intervals. The synchronization messages are sent in two parts: the first pair of messages is sent, and the second pair is sent. The first pair of messages sends the synchronization sequence number, and the controller records the exact Tick1 and Time1 of the transmission. Subsequently, a broadcast message (the second pair of messages) is sent again, sending the synchronization sequence number and the recorded exact Tick1.

[0091] The first pair of messages includes a destination address, a source address, a message type, a sequence number, and a checksum. The destination address is the address of the I / O module, the source address is the address of the controller, the message type refers to the pairing message, and the checksum data corresponds to the checksum of the first pair of messages. The checksum is used to improve message security. In other implementations, a checksum may not be set.

[0092] Each time the first pair of time messages is sent, the time sequence number in the first pair of time messages is automatically incremented by one, so that it can correspond to the second pair of time messages.

[0093] Then, a second pair of time messages is sent, transmitting the count Tick1. The second pair of time messages includes the destination address, source address, message type, sequence number, Tick value, and checksum. The sequence number is the same as the sequence number in the first pair of time messages, and Tick is the count Tick1 that appeared when the first pair of time messages was sent. The checksum is used to improve message security. In other implementations, a checksum may not be set.

[0094] The check value can be obtained using the CRC algorithm, or other check algorithms such as hash algorithm, MD5 algorithm or SHA algorithm.

[0095] 2. Processing procedure at the IO module end.

[0096] The IO module only needs to maintain one counting module, such as maintaining a tick with a counting unit of 0.1ms.

[0097] The processing steps of the IO module include: 1) Time-based process.

[0098] During the time synchronization process, the IO module will receive two synchronization messages from the controller. The process is as follows: After the IO module receives the first communication message, it records the reception time Tick2 in the reception completion interrupt, which is the exact Tick2 after receiving the first communication message (IO module side).

[0099] After receiving the second pair of time messages sent for the second time, the system retrieves Tick1 from the second pair of time messages. Using Tick1 and Tick2, it calculates the time difference between the controller and the I / O module, and uses this time difference to correct the I / O module's tick count. This time difference includes the zero time difference between the controller and the I / O module's tick counts and the deviation in communication latency.

[0100] If the first and second time pairs contain checksums, the IO module, upon receiving the first time pair, will perform a check on it, such as a CRC check. If the check is successful, the synchronization sequence number in the current time pair will be recorded. If the check fails, the synchronization is invalid.

[0101] After receiving the second time synchronization message, the IO module verifies it. If the verification is successful, it retrieves the synchronization sequence number and Tick1 from the message. If the verification fails, the synchronization is invalid.

[0102] Determine whether the synchronization sequence number of the second synchronization message is consistent with the synchronization sequence number of the first synchronization message. If they are inconsistent, the synchronization is invalid. If they are consistent, record the current Tick deviation of the IO module, Tick3, where Tick3 = Tick2 - Tick1.

[0103] 2) Generate time stamps.

[0104] After detecting an I / O change event, the I / O module generates a timestamp for the event, stores the timestamp in a buffer, and sends the timestamp to the controller during data interaction. The process of the I / O module generating the timestamp is as follows: Get the tick number when the IO change event occurs, and denote it as Tick4.

[0105] Tick4 is corrected using the current Tick deviation Tick3 to obtain the Tick at the controller end corresponding to Tick4, i.e., Tick5, where Tick5 = Tick4 - Tick3.

[0106] Tick5 is sent to the controller as a time stamp.

[0107] In one embodiment, the status of an IO change event is sent to the controller along with a timestamp. The status of the IO change event includes a response and an action.

[0108] In one embodiment, timescale quality is also sent to the controller. Timescale quality includes normal and abnormal, for example, 1 represents abnormal and 0 represents normal.

[0109] In a preferred embodiment, the IO module assembles the state, timescale quality, and timescale of the IO change event into an SOE and sends it to the controller.

[0110] To reduce bus data traffic, each SOE occupies 2 bytes. The highest bit of the high byte indicates the SOE's status (i.e., the status of IO change events), the second bit indicates the time stamp quality, and the remaining 14 bits represent the SOE's time stamp. The maximum time stamp value is 16383. If the time stamp's counting unit is 0.1ms, the tick will overflow every 1.6383 seconds. The controller must then read the IO module's SOE within 1.6383 seconds and restore it to an absolute time stamp; otherwise, time stamp restoration errors will occur. In other embodiments, the time stamp can also be placed in the first 14 bits.

[0111] The number of data bits for the time stamp can be set as needed, and more data bits can be set, such as 22 data bits, in which case SOE occupies 3 bytes.

[0112] 3. The controller restores the time stamp to absolute time and uses the obtained absolute time as the SOE time stamp.

[0113] After receiving SOE data from the IO module, the controller needs to restore the time stamp in the SOE to absolute time. When the time stamp occupies the lower 14 bits of the SOE data, the process of restoring the time stamp to absolute time includes: 1) Take the lower 14 bits of Tick1 and save them as tick_pps.

[0114] 2) Take the lower 14 bits of the SOE data (i.e., Tick5) and save it as tick_soe.

[0115] 3) Calculate the deviation between Tick1 and Tick5: tick_diff = tick_soe - tick_pps.

[0116] 4) Take the lower 14 bits of tick_diff.

[0117] 5) Correct Time1 with tick_diff to get Time_soe, which is the SOE timescale of absolute time.

[0118] If the IO module fails to receive a correct synchronization message for a set period of time, resulting in abnormal time synchronization and a time stamp quality issue, the time stamp quality will be set to 1 to prevent time stamp corruption. The set period can be designed according to requirements; for example, if no normal synchronization message is received within 60 seconds, an error is considered.

[0119] When the controller determines that the time stamp quality (e.g., Bit 14) of the received SOE is 1, it sets the SOE to an abnormal flag.

[0120] Control device implementation method A control device of the present invention includes a controller for communicating with an I / O module via a bus. The controller is also configured to periodically send a first pair of time messages to the I / O module, and upon completion of the transmission, interrupt and record the absolute time and count at the time of completion of the transmission of the first pair of time messages, the count being used as a first count. The first pair of time messages includes a timing sequence number. After the first pair of time messages are transmitted, a second pair of time messages is sent to the I / O module, the second pair of time messages including the aforementioned timing sequence number and the first count. The controller is also configured to receive a time stamp sent by the I / O module after correcting the count for changes in I / O based on the first and second pair of time messages, and to determine the SOE time stamp under the absolute time based on the first count, the absolute time corresponding to the first count, and the time stamp sent by the I / O module.

[0121] The controller maintains two clocks during operation: one clock supporting absolute timescales of year, month, and day, and the other for counting. In the power system field, counting is a core module, generating periodic interrupts to achieve task scheduling, delay, timeout, or timing functions. Counting can be done using ticks (clock ticks), with one tick cycle as the counting unit.

[0122] The controller sends communication messages via broadcast. The process of the controller sending communication messages includes: When the controller is working normally, it sends synchronization messages at regular time intervals. The synchronization messages are sent in two parts: the first pair of messages is sent, followed by the second pair. The first pair of messages sends the synchronization sequence number, and the controller records the precise Tick1 (first count) and Time1 (absolute time). Then, a broadcast message (the second pair of messages) is sent again, sending the synchronization sequence number and the recorded precise Tick1.

[0123] The first pair of time messages includes a destination address, a source address, a message type, a synchronization number, and a checksum. The destination address is the address of the I / O module, the source address is the address of the controller, the message type refers to the pairing time message, and the checksum data corresponds to the checksum of the first pair of time messages. The checksum is used to improve message security. In other implementations, a checksum may not be set. Each time the first pair of time messages is sent, the synchronization number in the first pair of time messages is automatically incremented by one to correspond with the second pair of time messages.

[0124] The second time pair message includes the destination address, source address, message type, time pair number, Tick value, and checksum. The time pair number is the same as the time pair number in the first time pair message, and the Tick value is the count Tick1 that appeared when the first time pair message was sent. The checksum is used to improve message security. In other implementations, a checksum may not be set.

[0125] The check value can be obtained using the CRC algorithm, or other check algorithms such as hash algorithm, MD5 algorithm or SHA algorithm.

[0126] After receiving SOE data from the IO module, the controller needs to restore the time stamp in the SOE to absolute time. When the time stamp occupies the lower 14 bits of the SOE data, the process of restoring the time stamp to absolute time includes: 1) Take the lower 14 bits of Tick1 and save them as tick_pps.

[0127] 2) Take the lower 14 bits of the SOE data (i.e., Tick5) and save it as tick_soe.

[0128] 3) Calculate the deviation between Tick1 and Tick5: tick_diff = tick_soe - tick_pps.

[0129] 4) Take the lower 14 bits of tick_diff.

[0130] 5) Correct Time1 with tick_diff to get Time_soe, which is the SOE timescale of absolute time.

[0131] If the IO module fails to receive a correct synchronization message for a set period of time, resulting in abnormal time synchronization and a time stamp quality issue, the time stamp quality will be set to 1 to prevent time stamp corruption. The set period can be designed according to requirements; for example, if no normal synchronization message is received within 60 seconds, an error is considered.

[0132] When the controller determines that the time stamp quality (e.g., Bit 14) of the received SOE is 1, it sets the SOE to an abnormal flag.

[0133] The specific implementation process of the control device has been described in detail in the implementation method of SOE time stamp generation, and will not be repeated here.

[0134] IO module implementation The present invention provides an I / O module for communicating with a controller via a bus.

[0135] The IO module only needs to maintain a counting module, and does not need to maintain a clock module that records absolute time. For example, it can maintain a tick with a counting unit of 0.1ms.

[0136] The IO module is used to receive the first pair of time messages and the second pair of time messages sent by the controller periodically. The first pair of time messages includes a timing number, and the second pair of time messages includes the timing number in the first pair of time messages and a first count. The first count is the count that the controller recorded when the first pair of time messages was sent after the transmission completion interrupt record was completed. The count of the first pair of time messages received in the reception completion interrupt record is used as the second count. The first count is obtained from the second pair of time messages, and the difference between the second count and the first count is calculated and recorded as the current deviation. The current deviation is used to correct the count when the IO change event occurs, and the corrected count is sent to the controller as a time stamp.

[0137] The IO module includes a time synchronization process and a time stamp generation process.

[0138] During time synchronization, the IO module receives two time synchronization messages from the controller. The time synchronization process is as follows: After the IO module receives the first communication message, it records the reception time Tick2 (second count) in the reception completion interrupt, which is the exact Tick2 (IO module end) after receiving the first communication message.

[0139] After receiving the second pair of time messages sent for the second time, the system retrieves Tick1 from the second pair of time messages. Using Tick1 and Tick2, it calculates the time difference between the controller and the I / O module, and uses this time difference to correct the I / O module's tick count. This time difference includes the zero time difference between the controller and the I / O module's tick counts and the deviation in communication latency.

[0140] If the first and second time pairs contain checksums, the IO module, upon receiving the first time pair, will perform a check on it, such as a CRC check. If the check is successful, the synchronization sequence number in the current time pair will be recorded. If the check fails, the synchronization is invalid.

[0141] After receiving the second time synchronization message, the IO module verifies it. If the verification is successful, it retrieves the synchronization sequence number and Tick1 from the message. If the verification fails, the synchronization is invalid.

[0142] Determine whether the synchronization sequence number of the second synchronization message is consistent with the synchronization sequence number of the first synchronization message. If they are inconsistent, the synchronization is invalid. If they are consistent, record the current Tick deviation of the IO module, Tick3, where Tick3 = Tick2 - Tick1.

[0143] After detecting an I / O change event, the I / O module generates a timestamp for the event, stores the timestamp in a buffer, and sends the timestamp to the controller during data interaction. The process of the I / O module generating the timestamp is as follows: Get the tick number when the IO change event occurs, and denote it as Tick4.

[0144] Tick4 is corrected using the current Tick deviation Tick3 to obtain the Tick at the controller end corresponding to Tick4, i.e., Tick5, where Tick5 = Tick4 - Tick3.

[0145] Tick5 is sent to the controller as a time stamp.

[0146] In one embodiment, the status of an IO change event is sent to the controller along with a timestamp. The status of the IO change event includes a response and an action.

[0147] In one embodiment, timescale quality is also sent to the controller. Timescale quality includes normal and abnormal, for example, 1 represents abnormal and 0 represents normal.

[0148] In a preferred embodiment, the IO module assembles the state, timescale quality, and timescale of the IO change event into an SOE and sends it to the controller.

[0149] To reduce bus data traffic, each SOE occupies 2 bytes. The highest bit of the high byte indicates the SOE's status (i.e., the status of IO change events), the second bit indicates the time stamp quality, and the remaining 14 bits represent the SOE's time stamp. The maximum time stamp value is 16383. If the time stamp's counting unit is 0.1ms, the tick will overflow every 1.6383 seconds. The controller must then read the IO module's SOE within 1.6383 seconds and restore it to an absolute time stamp; otherwise, time stamp restoration errors will occur. In other embodiments, the time stamp can also be placed in the first 14 bits.

[0150] The number of data bits for the time stamp can be set as needed, and more data bits can be set, such as 22 data bits, in which case SOE occupies 3 bytes.

[0151] The specific implementation process of the IO module has been described in detail in the SOE time stamp generation method implementation method, and will not be repeated here.

Claims

1. A method for generating SOE timescales, characterized in that, include: The controller sends the first pair of time messages to the IO module according to the cycle. Upon completion of the transmission, it records the absolute time and count when the first pair of time messages are sent. This count is used as the first count. The first pair of time messages includes the time sequence number. After the first pair of time messages is sent, the controller sends a second pair of time messages to the IO module. The second pair of time messages includes the time sequence number and the first count. The IO module records the count of the first pair of messages received upon completion of the reception interrupt, and uses this count as the second count; The first count is obtained from the second pair of messages, and the difference between the second count and the first count is calculated and recorded as the current deviation. The IO module records the count of IO change events, corrects the count using the current deviation, and sends the corrected count as a time stamp to the controller. The controller determines the SOE time stamp under absolute time based on the first count, the absolute time corresponding to the first count, and the time stamp sent by the IO module.

2. The SOE timescale generation method according to claim 1, characterized in that, The SOE time stamp in absolute time is calculated by superimposing the absolute time corresponding to the first count with the deviation between the time stamp sent by the IO module and the first count.

3. The SOE timescale generation method according to claim 1, characterized in that, The correction refers to the count at the time the event occurred minus the current deviation.

4. The SOE timescale generation method according to any one of claims 1-3, characterized in that, The IO module also sends time stamp quality to the controller, which includes abnormal and normal values; Timing quality anomalies include: the IO module not receiving the correct synchronization message for a set time; the synchronization message includes the first synchronization message and the second synchronization message.

5. The SOE timescale generation method according to any one of claims 1-3, characterized in that, The counting is obtained using clock ticks.

6. The SOE timescale generation method according to claim 4, characterized in that, The first and second pairing messages contain a checksum. The IO module may not receive the correct pairing message if: the first pairing message fails to checksum, the second pairing message fails to checksum, or the pairing sequence numbers of the first and second pairing messages are inconsistent.

7. The SOE timescale generation method according to claim 1, characterized in that, The period for sending the first pair of messages is determined based on the maximum duration of the timestamp sent by the IO module, which is determined based on the maximum value of the timestamp and the counting unit.

8. A control device, comprising a controller for communicating with an I / O module via a bus, characterized in that, The controller is also used to send a first pair of time messages to the IO module according to a period, and to record the absolute time and count when the first pair of time messages are sent and the count is used as the first count. The first pair of time messages includes a time sequence number. After the first pair of time messages are sent, a second pair of time messages is sent to the IO module. The second pair of time messages includes the time sequence number and the first count. And a time stamp sent by the IO module after correcting the count when the IO changes based on the first pair of time messages and the second pair of time messages, and a SOE time stamp under absolute time based on the first count, the absolute time corresponding to the first count and the time stamp sent by the IO module.

9. An I / O module, the I / O module being used to communicate with a controller via a bus, characterized in that, The IO module is also used to receive a first pair of time messages and a second pair of time messages sent by the controller periodically; the first pair of time messages includes a time sequence number, and the second pair of time messages includes the time sequence number and a first count, which is the count of the controller when the first pair of time messages in the transmission completion interrupt record are completed; the count of the first pair of time messages received in the reception completion interrupt record is used as the second count; the first count is obtained from the second pair of time messages, the difference between the second count and the first count is calculated and recorded as the current deviation; the count when the IO change event occurs is corrected using the current deviation, and the corrected count is sent to the controller as a time stamp.

10. A SOE timescale generation system, comprising a controller and an I / O module, characterized in that, The system is used to implement the steps of the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Clock synchronization system, method and device based on CAN bus

    CN113225151A