A method and device for accurate time synchronization using RS232 serial port

By transmitting serial port signals and second pulse signals on the RS232 serial port interface, and using the PID algorithm to correct the microsecond time counter step value, the problem of insufficient timing accuracy of the RS232-C serial port is solved, and high-precision time synchronization is achieved, which is suitable for Secondary monitoring device for power systems.

CN110611544BActive Publication Date: 2024-08-23CHENGDU FUHE POWER AUTOMATION COMPLETE EQUIP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910863173.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-09-12
Publication Date
2024-08-23
Estimated Expiration
2039-09-12

AI Technical Summary

Technical Problem

The existing RS232-C serial port time synchronization method cannot meet the high-precision time requirements in secondary monitoring devices in substations. In particular, the old devices only support serial port time synchronization and have large errors, making it impossible to achieve accurate time synchronization.

Method used

By transmitting serial port signals and second pulse signals between the RXD and DCD pins of the RS232 serial port interface, the PID algorithm is used to calculate the microsecond time counter step value and correct the system time to achieve higher precision time synchronization.

Benefits of technology

It achieves the accuracy of RS232 serial port timing to less than 20us without increasing the hardware cost and interface. It is compatible with the original protocol, has high precision, good compatibility, high reliability and good real-time performance, and is suitable for power transformation and distribution. Station and other power secondary monitoring devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110611544B
    Figure CN110611544B
Patent Text Reader

Abstract

A method for accurate time synchronization using an RS232 serial port comprises the following steps: S1. A timing device outputs a serial port signal to the RXD pin of the RS232 serial port of a secondary monitoring device; S2. After the serial port of the secondary monitoring device responds to an interrupt, the system time information above the second level is synchronized according to the year, month, day, hour, minute, and second time information contained in the serial port; S3. The timing device outputs a second pulse signal to the DCD pin of the RS232 interface, and the rising edge of the second pulse signal triggers the serial port controller interrupt of the DCD pin, and the microsecond time counter step value of the system is corrected based on the microsecond time deviation and the step value calculated by the PID algorithm; S4. The secondary monitoring device synchronizes the system time above the second level and corrects the system microsecond time counter step value according to steps S2 and S3, thereby performing overall time synchronization on the device system time. The present invention also discloses a device for accurate time synchronization using an RS232 serial port. The present invention can achieve accurate time synchronization using the original device hardware serial port without increasing the hardware cost and interface.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of electric power systems, relates to a timing technology, and specifically relates to a method and a device for accurate time synchronization using an RS232 serial port. Background Art

[0002] As the requirements for time accuracy of secondary monitoring devices in substations become higher and higher, especially for devices such as recorders, measurement and control, protection and PMU (synchronous phasor measurement unit), this has prompted timing devices such as GPS or Beidou to output higher-precision timing signals. At present, the timing signals output by GPS / Beidou timing devices include PTP (high-precision time synchronization protocol), B code, pulse (hour, minute, second), NTP (SNTP), serial port and other methods. The timing signals that can achieve microsecond-level accuracy include PTP and B code, and the timing signals that can achieve millisecond-level accuracy include NTP (network time protocol) or SNTP (simple network time protocol), serial port, and the combination of serial port + second pulse can also achieve microsecond-level accuracy. At present, B code (optical, electrical) timing is widely used in substation monitoring devices. Other timing methods either have poor timing accuracy or have high requirements on device hardware and increase costs, and some older monitoring devices only support serial port timing.

[0003] At present, the substation secondary monitoring device often uses the following two methods through the RS232-C serial port:

[0004] The first is to use the RS232-C serial port to synchronize the time, and synchronize the secondary monitoring device by connecting to the serial port on the GPS (or Beidou) timing device. The synchronization can only be accurate to seconds, and there is no synchronization capability for milliseconds and microseconds. The synchronization error is ≤±1s, and the synchronization accuracy cannot meet the requirements of precise synchronization. The second is to use the RS232-C serial port + second pulse combination to synchronize the time; synchronize the secondary monitoring device by connecting to the serial port + second pulse on the GPS (or Beidou) timing device. It can meet the requirements of synchronization accuracy, but some secondary monitoring devices do not have a pulse interface and cannot access the second pulse, nor can they complete precise synchronization, so the scope of application is limited. Summary of the invention

[0005] In order to solve the problem that the serial port timing error of the secondary monitoring device of the current power system substation is large and cannot meet the requirements of time accuracy, especially some old secondary monitoring devices only support serial port timing, without increasing hardware costs and interfaces, the present invention discloses a method and device for accurate timing using the RS232 serial port.

[0006] The method for accurately synchronizing time by using RS232 serial port of the present invention comprises the following steps:

[0007] S1. The timing device outputs the serial port signal to the RXD pin of the RS232 interface of the secondary monitoring device.

[0008] S2. After the secondary monitoring device responds to the serial port interruption, it will align the time information of the system with the time information above the second level according to the year, month, day, hour, minute, and second time information contained in the serial port signal;

[0009] The S3 timing device outputs a second pulse signal to the DCD pin of the RS232 interface, and the rising edge of the second pulse signal triggers the serial port controller interrupt of the DCD pin of the RS232 interface;

[0010] The secondary monitoring device is set to use the moment when the interrupt is triggered by the rising edge of the second pulse signal as the starting point of the microsecond time zero, read the system microsecond time to calculate the time deviation, and then based on the microsecond time deviation, the step value of the system microsecond time counter is corrected by the step value calculated by the PID algorithm;

[0011] S4. The secondary monitoring device synchronizes the system time information above the second level according to steps S2 and S3 and corrects the step value of the system microsecond time counter, thereby synchronizing the system time of the device as a whole.

[0012] Preferably, the algorithm used for correction in step S3 is a PID algorithm, and the PID algorithm is specifically:

[0013] In each sampling cycle, according to the PID algorithm, based on the current real-time time deviation Xn, the integral time error Xy=Xn+X(n-1)+…+X(nk), n=1, 2, 3… and the differential time error Xz=Xn-X(n-1), the integrated calculation system microsecond counter adjusts the step value y, y=AXn+BXy+DXz, until the real-time time deviation Xn measured in S3 is less than the error tolerance C;

[0014] Yn is the microsecond counter step value, A, B, D are the weight coefficients of time deviation, integral time error and differential time error respectively, and A+B+D=1, k is the integral accumulation number, and n represents the nth sampling period

[0015] Preferably, in step S1, after the timing device outputs a serial port signal to the RXD pin of the RS232 interface of the secondary monitoring device, the TXD pin of the RS232 interface outputs a response signal to the timing device.

[0016] The present invention also discloses a device for accurate time synchronization using an RS232 serial port, characterized in that it comprises a timing device and a secondary monitoring device, wherein the TXD pin of the timing device is connected to the RXD pin of the RS232 interface of the secondary monitoring device, the RXD pin of the timing device is connected to the TXD pin of the RS232 interface of the secondary monitoring device, and the PPS pin of the timing device is connected to the DCD (carrier detection) pin of the RS232 interface of the secondary monitoring device.

[0017] Specifically, the timing device is a GPS or Beidou timing device.

[0018] Specifically, the secondary monitoring device is provided with a large time register of system second level or above and a system microsecond counter.

[0019] Specifically, the secondary monitoring device is a fault recorder, a signal protection substation, a measurement and control device or a telecontrol device.

[0020] The method and device for accurate time synchronization using the RS232 serial port described in the present invention can provide accurate serial port time synchronization. Without increasing hardware costs and interfaces, accurate time synchronization can be achieved using the hardware serial port of the original device. The method and device have the characteristics of high accuracy, good compatibility, high reliability, good real-time performance, and a wide range of practical applications, and can meet the requirements for accurate time synchronization of secondary power monitoring devices such as substations and power plants.

[0021] The advantages of the present invention are:

[0022] 1. Use an RS232-C serial interface to complete precise timing, and the timing accuracy can be less than 20us.

[0023] 2. Compatible with the original serial port timing protocol software, adding time PID algorithm software to ensure timing accuracy.

[0024] 3. Compatible with the serial port timing method of the original device, no need to increase hardware cost and interface, on-site connection

[0025] Online ordering, convenient construction and wide range of uses. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 This is a schematic diagram of a specific implementation of the device for accurate time synchronization using an RS232 serial port according to the present invention. DETAILED DESCRIPTION

[0027] The specific embodiments of the present invention are described in further detail below.

[0028] The method for accurate time synchronization using an RS232 serial port of the present invention is based on a device for accurate time synchronization using an RS232 serial port, which comprises a timing device and a secondary monitoring device, wherein the TXD pin of the timing device is connected to the RXD pin of the RS232 interface of the secondary monitoring device, the RXD pin of the timing device is connected to the TXD pin of the RS232 interface of the secondary monitoring device, and the PPS pin of the timing device is connected to the DCD (carrier detection) pin of the RS232 interface of the secondary monitoring device.

[0029] The DCD (carrier detection) pin is the carrier detection pin of the RS2329 serial port. The level change of this pin can trigger the interrupt of the serial port controller, thereby obtaining accurate system microsecond time.

[0030] Among them, the timing device outputs the serial port signal to the RXD pin of the RS232 interface of the secondary monitoring device through the TXD pin. After the secondary monitoring device responds to the serial port signal, it reads the year, month, day, hour, minute and second time information contained in the serial port information, and corrects the large time information above the second level of its own system.

[0031] The timing device outputs a serial signal to the DCD pin of the RS232 interface of the secondary monitoring device through the PPS pin. After the secondary monitoring device responds to the serial signal, it reads the sub-second time information contained in the serial information and corrects the sub-second time information of its own system.

[0032] After the RXD of the secondary monitoring device receives the serial port time information, it can send a response to the RXD pin of the timing device through its own TXD pin, so that the timing device knows that the time information is received successfully.

[0033] The timing device is a time synchronization device that uses a GPS or Beidou module as a receiving module and expands various timing interfaces to publish precise time outputs. The secondary monitoring device is an auxiliary device in the substation that protects, monitors, measures, and operates and controls primary equipment such as the main transformer and its ancillary equipment, such as a fault recorder, a signal protection substation, a measurement and control device, or a telecontrol device.

[0034] The method for accurately synchronizing time based on the above-mentioned device for accurately synchronizing time using the RS232 serial port may include the following steps:

[0035] S1. The timing device outputs the serial port signal to the RXD pin of the RS232 interface of the secondary monitoring device.

[0036] S2. After the secondary monitoring device responds to the serial port interrupt, the software reads the serial port information containing the year, month, day, hour, minute, and second time information to align the time system with the second-level large time information;

[0037] The serial port signal contains time information at the year, month, day, hour, minute, and second level. The secondary monitoring device responds to the serial port interruption, reads the year, month, day, hour, minute, and second level or above time information contained in the serial port signal, and aligns the time information at the second level or above with the time system.

[0038] After the RXD of the secondary monitoring device receives the serial port time information, it can send a response to the RXD pin of the timing device through its own TXD pin, so that the timing device knows that the time information is received successfully.

[0039] The time synchronization of large time information above the second level refers to synchronizing the large time information above the second level of the secondary monitoring device system receiving information through the year, month, day, hour, minute, and second level in the signal transmitted by the serial port of the timing device. The large time above the second level after the synchronization can be stored in the system register above the second level.

[0040] The secondary monitoring device is set to trigger the interruption at the rising edge of the second pulse signal as the starting point of the microsecond time zero. When the rising edge arrives, the system time value is read immediately. Since the system time value includes two 32-bit integers of seconds and microseconds, the number of microseconds is theoretically 0. Due to the existence of errors, the microsecond time value is usually compared with 0.5S. If it is greater than or equal to 0.5S, it is considered to be a negative deviation. At this time, Xn (time deviation) = microsecond time value-1000000; less than 0.5mS is considered to be a positive deviation. At this time, Xn (time deviation) = microsecond time value-0; the size and direction of the microsecond time deviation value are obtained by calculation and stored in the buffer cache. Then, based on the system time deviation, the step value is calculated by the PID algorithm to correct the step value of the system's microsecond time counter.

[0041] In order to avoid repeated oscillation of the clock signal caused by excessive correction, the algorithm used for correction in step S3 is the PID algorithm, which uses proportional, integral, and differential algorithms to calculate the system microsecond counter adjustment step value, and continuously reduces the microsecond time error in each sampling cycle, rather than directly correcting according to the calculated time error.

[0042] P stands for proportional control: currently, proportional control is the simplest control method. The output of its controller is proportional to the input error signal. When there is only proportional control, there is a steady-state error in the system output.

[0043] I stands for integral: after control, the output of the controller is proportional to the integral of the input error signal. For an automatic control system, if there is a steady-state error after entering the steady state, the control system is called a system with a steady-state error or simply a system with a steady-state error. In order to eliminate the steady-state error, an "integral term" must be introduced in the controller. The integral term is the integral of the error depending on time, and the integral term will increase as time increases. In this way, even if the error is very small, the integral term will increase as time increases, which drives the controller's output to increase and further reduce the steady-state error until it is equal to zero. Therefore, the proportional + integral (PI) controller can make the system have no steady-state error after entering the steady state.

[0044] D stands for differential: in the future, the controller output is proportional to the differential of the input error signal (i.e. the rate of change of the error). Increasing the differential time is conducive to speeding up the system response, reducing the system overshoot, and increasing stability, but the system's ability to suppress disturbances is weakened. Differential control has the characteristics of advance and prediction.

[0045] In each sampling cycle of 1 second, according to the PID algorithm, in each sampling cycle, according to the current real-time time deviation Xn, the integral time error Xy=Xn+X(n-1)+…+X(nk)(n=1, 2, 3…), and the differential time error Xz=Xn-X(n-1), the comprehensive calculation system microsecond counter adjusts the step value y, y=AXn+BXy+DXz, until the real-time time deviation Xn measured in S3 is less than the error tolerance C;

[0046] In the formula y=AXn+BXy+DXz, the calculated result y represents the adjustment value of the system microsecond counter step value in each cycle. The three items on the right side of the equal sign represent the three elements of the system adjustment: proportion P, integration I, and differentiation D. Xn represents the current error, and the adjustment of its weight coefficient A represents the error proportion control. Xy is the sum of the accumulated time deviations of k consecutive cycles, representing the system static error. Xz is the difference in time deviations between the most recent two cycles, reflecting the future trend of the error.

[0047] The purpose of adjustment is to make Xn less than the error tolerance C in the shortest possible period, and to avoid the oscillation caused by overshoot. The values ​​of weight coefficients A, B, and D follow the above principles. For example, if the overshoot is too large, the A value can be appropriately reduced. If the constant error disappears slowly, the B value can be appropriately increased. If the error after adjustment is prone to instability, the D value can be appropriately reduced. Since Xy is the sum of the time deviations accumulated over k consecutive periods, k is generally 5-10 periods.

[0048] The default step value Y of the microsecond counter is 1, the error tolerance C=20 microseconds, and the PID algorithm is used to calculate y once per second, that is, it is calculated according to the second pulse period sampling. Yn=Y(n-1)+y, Yn is the step value of the microsecond counter each time, that is, the counter unit.

[0049] The microsecond calculator step value of each cycle is Yn=Y(n-1)+y. By continuously adjusting Yn, the system microsecond time continuously changes in the direction of zero real-time error until the real-time error Xn measured in S3 is less than the error tolerance C.

[0050] The Yn is the step value of the microsecond counter, and the error tolerance C is a self-set parameter. Since the interrupt time triggered by the rising edge of the second pulse in response to the operating system is uncertain, the error tolerance C=20 microseconds is set as an acceptable error.

[0051] The system time of the secondary monitoring device is calculated based on the microsecond counter value of the system. If the microsecond counter value is 1000000, the counter step value = 1uS, the time value = 1000000*1 = 1000000uS = 1000mS = 1S; if the counting step value is changed to 0.9995 uS, the time value = 1000000*0.9995 = 999500uS = 999.5mS = 0.9995S, that is, the system time is advanced in the next cycle after the step size is reduced; vice versa, the system time is delayed in the next cycle after the step size is increased. It can be seen that by changing the system counter step value, the system timing unit basis can be changed, thereby changing the system time of the secondary monitoring device including large times above seconds and small times in microseconds.

[0052] In step S4, the secondary monitoring device synchronizes the system time as a whole according to the large time information above the second level in steps S2 and S3 and corrects the step value of the system microsecond time counter.

[0053] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0054] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0055] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0056] The method and device for accurate time synchronization using the RS232 serial port described in the present invention can provide accurate serial port time synchronization. Without increasing hardware costs and interfaces, accurate time synchronization can be achieved using the hardware serial port of the original device. The method and device have the characteristics of high accuracy, good compatibility, high reliability, good real-time performance, and a wide range of practical applications, and can meet the requirements for accurate time synchronization of secondary power monitoring devices such as substations and power plants.

[0057] The foregoing describes various preferred embodiments of the present invention. Unless the preferred implementation modes in various preferred embodiments are obviously self-contradictory or based on a certain preferred implementation mode, various preferred implementation modes can be arbitrarily superimposed and used in combination. The embodiments and specific parameters in the embodiments are only for clearly describing the invention verification process of the inventor, and are not used to limit the patent protection scope of the present invention. The patent protection scope of the present invention shall still be based on its claims. All equivalent structural changes made using the contents of the description and drawings of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for accurate time synchronization using RS232 serial port, characterized in that: The steps include: S1. The timing device outputs the serial port signal to the RXD pin of the RS232 interface of the secondary monitoring device. S2. After the secondary monitoring device responds to the serial port interruption, it will align the time information of the system with the time information above the second level according to the year, month, day, hour, minute, and second time information contained in the serial port signal; The S3 timing device outputs a second pulse signal to the DCD pin of the RS232 interface, and the rising edge of the second pulse signal triggers the serial port controller interrupt of the DCD pin of the RS232 interface; The secondary monitoring device is set to use the moment when the interrupt is triggered by the rising edge of the second pulse signal as the starting point of the microsecond time zero, read the system microsecond time to calculate the time deviation, and then based on the microsecond time deviation, the step value of the system microsecond time counter is corrected by the step value calculated by the PID algorithm; S4. The secondary monitoring device synchronizes the system time with the time information of the second level or above according to steps S2 and S3 and corrects the step value of the system microsecond time counter, thereby synchronizing the system time of the device as a whole; The algorithm used for correction in step S3 is the PID algorithm, and the PID algorithm is specifically: In each sampling cycle, according to the PID algorithm, based on the current real-time time deviation Xn, the integral time error Xy=Xn+X(n-1)+…+X(nk), n=1, 2, 3… and the differential time error Xz=Xn-X(n-1), the integrated calculation system microsecond counter adjusts the step value y, y=AXn+BXy+DXz, until the real-time time deviation Xn measured in S3 is less than the error tolerance C; A, B, and D are the weight coefficients of time deviation, integral time error, and differential time error, respectively, and A+B+D=1, k is the integral accumulation number, and n represents the nth sampling period.

2. The method for accurately synchronizing the time using the RS232 serial port as claimed in claim 1, characterized in that: In the step S1, after the timing device outputs a serial port signal to the RXD pin of the RS232 interface of the secondary monitoring device, the TXD pin of the RS232 interface outputs a response signal to the timing device.

3. A device for accurate time synchronization using RS232 serial port, characterized in that: Used to implement the method described in any one of claims 1 to 2, comprising a timing device and a secondary monitoring device, wherein the TXD pin of the timing device is connected to the RXD pin of the RS232 interface of the secondary monitoring device, the RXD pin of the timing device is connected to the TXD pin of the RS232 interface of the secondary monitoring device, the PPS pin of the timing device is connected to the DCD pin of the RS232 interface of the secondary monitoring device, and the timing device is a GPS or Beidou timing device; the secondary monitoring device is provided with a system large time register above the second level and a system microsecond counter.

4. The device for accurate time synchronization using RS232 serial port as claimed in claim 3, characterized in that: The secondary monitoring device is a fault recorder, a signal protection substation, a measurement and control device or a telecontrol device.