CN112152747B - Time synchronization method and system for vehicle-mounted multi-controller - Google Patents

Time synchronization method and system for vehicle-mounted multi-controller Download PDF

Info

Publication number
CN112152747B
CN112152747B CN202011096841.9A CN202011096841A CN112152747B CN 112152747 B CN112152747 B CN 112152747B CN 202011096841 A CN202011096841 A CN 202011096841A CN 112152747 B CN112152747 B CN 112152747B
Authority
CN
China
Prior art keywords
synchronization
controller
internal
time
external
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011096841.9A
Other languages
Chinese (zh)
Other versions
CN112152747A (en
Inventor
孟德远
胡庭波
安向京
张梦轩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Changsha Xingshen Intelligent Technology Co Ltd
Original Assignee
Changsha Xingshen Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Changsha Xingshen Intelligent Technology Co Ltd filed Critical Changsha Xingshen Intelligent Technology Co Ltd
Priority to CN202011096841.9A priority Critical patent/CN112152747B/en
Publication of CN112152747A publication Critical patent/CN112152747A/en
Application granted granted Critical
Publication of CN112152747B publication Critical patent/CN112152747B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0644External master-clock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0682Clock or time synchronisation in a network by delay compensation, e.g. by compensation of propagation delay or variations thereof, by ranging
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Abstract

The invention discloses a time synchronization method and device for a vehicle-mounted multi-controller, wherein the method comprises the following steps: one controller of the controllers to be synchronized is configured as a master synchronization controller, the other controllers are configured as slave synchronization controllers, the master synchronization controller uses a GNSS clock to perform external synchronization, the master synchronization controller calculates an external synchronization time difference, the master synchronization controller performs internal synchronization with the slave synchronization controllers, the master controller generates an internal synchronization signal according to internal time and sends the internal synchronization signal and external synchronization information to the slave synchronization controllers, the slave synchronization controllers calculate an internal synchronization time difference after receiving the internal synchronization signal, and the slave synchronization controllers realize external synchronization with the GNSS clock according to the internal synchronization time difference and the received external synchronization information. The invention has the advantages of simple implementation method, low cost, high synchronization precision, capability of preventing local time jump when controlling time synchronization, and the like.

Description

Time synchronization method and system for vehicle-mounted multi-controller
Technical Field
The invention relates to the technical field of time synchronization of vehicle-mounted equipment, in particular to a time synchronization method and system for vehicle-mounted multi-controller.
Background
In a vehicle system, a plurality of different types of controllers, such as an industrial personal computer, TX2, xavier, FPGA, MCU, etc., are generally required to be configured, and in a distributed system of this type, a global time is often required to be used to determine the occurrence sequence of various events in the system, coordinate the transmission of various messages, etc., so as to control and monitor the state of the system, so that local time of each component in the system needs to be unified, i.e. clock synchronization is required.
The distributed high-precision time synchronization method commonly used at present mainly comprises the following steps:
1. GNSS clock synchronization
GNSS clock synchronization is a process of synchronizing a local clock with time on a GPS satellite using GNSS geosynchronous satellite signals, using a receiver to receive 1pps and serial time information. The accuracy of GNSS clock synchronization is on the order of sub-microseconds.
However, GNSS clock synchronization requires satellite signal reception, requires an outdoor antenna to be installed, and cannot be synchronized in a region without GNSS signals, and when the GNSS clock synchronization is applied to synchronization of a plurality of controllers, each controller needs to be separately connected to a receiver, which causes a problem that all controllers cannot be synchronized when interference exists.
2. NTP clock synchronization
The network time protocol NTP (Network Time Protocol) is developed from a time protocol, ICMP timestamp messages, and IP timestamp options, NTP is used to synchronize the time of a computer client or server with another server, using a hierarchical time distribution model. In configuration, NTP may utilize redundant servers and multiple network paths to achieve high accuracy and high reliability of time. Even if a client cannot be associated with a certain time server for a long time, a high accuracy time can be provided. The synchronization time based on NTP is generated in the protocol layer of the NTP server and is influenced by the load of the local area network, and the synchronization precision is in millisecond level.
However, the NTP clock synchronization method has the following problems: firstly, an NTP server needs to be erected for NTP clock synchronization, so that the cost and the wire harness are increased; secondly, the NTP clock synchronization precision is lower and is influenced by the load of a local area network; thirdly, NTP clock synchronization modifies local time, which results in local time hopping or time period variation.
3. PTP clock synchronization
The PTP (Precision Time Protocol) protocol is a precision clock synchronization protocol defined in IEEE-1588, and the PTP protocol is designed mainly for relatively localized, networked systems, sub-networks, and environments where internal components are relatively stable. The PTP protocol is easy to realize, and has the advantages of small occupied network and computing resources, and the like, so that the PTP protocol is widely applied to a distributed system. The PTP protocol may be implemented in hardware or in software. Sub-micron precision can be achieved when implemented in hardware and millisecond precision can be achieved when implemented in software.
However, the PTP clock synchronization method has the following problems: firstly, PTP servers are required to be erected for PTP clock synchronization, so that cost and wire harness are increased; secondly, a network node (switch) is required to support a PTP protocol to realize sub-microsecond precision time synchronization; thirdly, PTP clock synchronization modifies local time, and local time hopping or time period change is caused during synchronization.
And some controllers in the vehicle-mounted system may not support NTP and PTP protocols, and the above-mentioned NTP and PTP clock synchronization methods are not suitable for clock synchronization of each controller in the vehicle-mounted system. When the clock synchronization method is applied to time synchronization among multiple controllers, the controllers are required to be connected with a receiver or a server respectively in the prior art, so that all the controllers cannot be synchronized when interference exists, the clock synchronization method is not suitable for application with high requirements on time synchronization precision, if an unmanned vehicle system with microsecond precision is required to be achieved, local time jump can exist during time synchronization of the controllers, the requirements of the unmanned vehicle system on the time synchronization are high, and microsecond precision is required to be achieved.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: aiming at the technical problems existing in the prior art, the invention provides the vehicle-mounted multi-controller time synchronization method and system which are simple in implementation method, low in cost and high in synchronization precision and can prevent local time jump when controlling time synchronization.
In order to solve the technical problems, the technical scheme provided by the invention is as follows:
a vehicle-mounted multi-controller time synchronization method, the method comprising: one controller of the controllers to be synchronized is configured as a master synchronization controller, the other controllers are configured as slave synchronization controllers, the master synchronization controller uses a GNSS clock to perform external synchronization, the master synchronization controller calculates the time difference between the internal time of the master synchronization controller and the GNSS time to obtain an external synchronization time difference, the master synchronization controller performs internal synchronization with each slave synchronization controller, the master controller generates an internal synchronization signal according to the internal time and sends the internal synchronization signal and the external synchronization information message containing the external synchronization time difference to each slave synchronization controller, after each slave synchronization controller receives the internal synchronization signal, the internal time difference between each slave synchronization controller and the master synchronization controller is calculated to obtain an internal synchronization time difference, and each slave synchronization controller realizes external synchronization with the GNSS clock according to the internal synchronization time difference and the received external synchronization information message.
Further, when the master synchronization controller uses the GNSS clock to perform external synchronization, the master synchronization controller specifically receives the external synchronization 1PPS signal and the GPRMC message sent by the GNSS receiver, and when the valid external synchronization 1PPS signal and the GPRMC message are continuously received for a preset number of times, the master synchronization controller synchronizes with the GNSS clock, and calculates the external synchronization time difference.
Further, the method further comprises the step of setting a first external synchronization zone bit used for marking whether external synchronization between the main synchronization controller and GNSS time is completed or not, wherein when the main synchronization controller performs external synchronization, the first external synchronization zone bit is initially set to be invalid, and when the external synchronization time difference is calculated, the first external synchronization zone bit is set to be valid.
Further, the specific steps of the master synchronization controller performing external synchronization by using the GNSS time signals include:
s11, waiting for an external synchronization 1PPS signal sent by a GNSS receiver, and jumping to the step S12 when the external synchronization 1PPS signal is received;
s12, judging whether the external synchronous 1PPS signal is effective, if so, accumulating the effective number of the 1PPS signal, jumping to the step S13, otherwise, returning to the step S11 after clearing 0 the effective number of the 1PPS signal and the effective number of the GPRMC message;
s13, judging whether the effective number of the 1PPS signal and the effective number of the GPRMC message are larger than a preset value, if so, jumping to the step S14, otherwise, returning to the step S11;
s14, subtracting the GPRMC time received by the previous frame from the internal time maintained by the main synchronous controller after adding 1 second to obtain the external synchronous time difference, setting an external synchronous flag bit to be effective, and jumping to the step S15;
s15, waiting for a GPRMC message sent by a GNSS receiver, and if the GPRMC message is received and is valid, jumping to the step S16; otherwise, the 1PPS signal effective number times and the GPRMC message effective number times are cleared to be 0, and then the step S11 is skipped;
s16, accumulating the effective numbers of the GPRMC messages, and continuing to wait for the next external synchronization 1PPS signal in a jumping step S11.
Further, when the master synchronization controller performs internal synchronization with each slave synchronization controller, specifically, the master synchronization controller generates an internal 1PPS signal and an internal GPRMC time based on its own internal time, and sends the generated internal 1PPS signal and internal GPRMC time, and the external synchronization information to each slave synchronization controller, respectively.
Further, when each slave synchronization controller performs internal synchronization, each slave synchronization controller receives the internal 1PPS signal, the internal GPRMC message, and the external synchronization information message sent by the master control, and when the internal 1PPS signal and the internal GPRMC message which are valid are continuously received and reach a preset number of times after being stabilized, each slave synchronization controller performs synchronization with the master synchronization controller, calculates the internal synchronization time difference, and if the external synchronization information message is valid, updates the external synchronization state of each slave synchronization controller by using the external synchronization time difference in the external synchronization information message.
Further, setting a second external synchronization flag bit for identifying whether external synchronization between the slave synchronization controller and the GNSS time is completed or not, and setting an internal synchronization flag bit for identifying whether internal synchronization between the slave synchronization controller and the master synchronization controller is completed or not, setting the second external synchronization flag bit and the internal synchronization flag bit to be invalid initially, setting the internal synchronization flag bit to be valid when the internal synchronization time difference is calculated, and setting the second external synchronization flag bit to be valid when the external synchronization information message is received and the external synchronization information message is valid.
Further, the specific steps of the slave synchronization controller for internal synchronization include:
s21, waiting for an internal 1PPS signal sent by the main synchronous controller, and jumping to the step S22 when the internal 1PPS signal is received;
s22, judging whether the internal 1PPS signal is effective, if yes, jumping to the step S23, otherwise, returning to the step S21;
s23, accumulating the effective numbers of the internal 1PPS signals, and jumping to the step S24;
s24, judging whether the effective number count of the internal 1PPS signal and the effective number count of the internal GPRMC signal are larger than a preset value, if yes, jumping to the step S25, otherwise jumping to the step S21;
s25, subtracting the self-government time of the current slave synchronous controller from the GPRMC time in the last frame by 1 second, calculating the internal synchronous time difference, setting an internal synchronous flag bit to be effective, and jumping to the step S26;
s26, waiting for the internal GPRMC message, and if the internal GPRMC message is received and valid, jumping to the step S27; otherwise, the step S21 is skipped after the number of the effective numbers of the internal 1PPS signal and the number of the effective numbers of the internal GPRMC are both cleared to 0;
s27, accumulating the effective numbers of the internal GPRMCs, and jumping to the step S28;
s28, waiting for the external synchronization information message, if the external synchronization information message is received and is valid, setting an external synchronization mark of a slave synchronization controller to be valid, and setting external synchronization time to be the received external synchronization time; the jump step S21 continues to wait for the next internal 1PPS signal.
The vehicle-mounted multi-controller time synchronization system comprises a plurality of controllers to be synchronized, wherein each controller to be synchronized performs time synchronization according to the synchronization method, one end of a master synchronization controller is connected with a GNSS receiver, and the other end of the master synchronization controller is respectively connected with each slave synchronization controller.
Further, the controller is provided with one or more of an IO interface, a serial interface, an SPI interface and a network interface.
Compared with the prior art, the invention has the advantages that:
1. according to the vehicle-mounted multi-controller time synchronization method and device, the secondary synchronization time is adopted, the master synchronization controller uses the GNSS clock for synchronization, the time difference between the internal time and the external GNSS time is calculated, meanwhile, the master synchronization controller sends the external synchronization information and the internal synchronization signal generated according to the internal time to each slave synchronization controller, and the slave controllers use the analog GNSS clock for synchronization, so that the master synchronization controller only needs to maintain the internal time and the external synchronization time difference between the master synchronization controller and the GNSS, and each slave synchronization controller only needs to maintain the internal time and the internal synchronization time difference between the slave synchronization controller and the master synchronization controller, and high-precision time synchronization of each controller can be ensured.
2. According to the vehicle-mounted multi-controller time synchronization method and device, only the master synchronization controller is required to be connected with the GNSS receiver, and through the use of GNSS clock synchronization by the master synchronization controller, each slave synchronization controller and the master synchronization controller perform internal synchronization, the problem of local time jump can not exist in the time synchronization process, and the problem of local time jump generated in the time synchronization of the traditional controllers can be solved.
3. The time synchronization method and the device for the vehicle-mounted multi-controller can achieve microsecond synchronization accuracy, and can meet the time synchronization requirements of unmanned vehicle systems and the like.
Drawings
Fig. 1 is a schematic diagram of an implementation principle of the time synchronization method of the vehicle-mounted multi-controller of the present embodiment.
Fig. 2 is a schematic diagram of an internal synchronization flow of the master synchronization controller in this embodiment.
Fig. 3 is a schematic diagram of an internal synchronization signal issued by a master synchronization controller in a specific application embodiment of the present invention.
Fig. 4 is a schematic flow chart of implementing external synchronization of the master synchronization controller in a specific application embodiment of the present invention.
Fig. 5 is a schematic flow chart of implementation of internal synchronization from a synchronization controller in a specific application embodiment of the present invention.
Detailed Description
The invention is further described below in connection with the drawings and the specific preferred embodiments, but the scope of protection of the invention is not limited thereby.
As shown in fig. 1, the time synchronization method for the vehicle-mounted multi-controller of the present embodiment includes: one controller of the controllers to be synchronized is configured as a master synchronization controller, the other controllers are configured as slave synchronization controllers, the master synchronization controller uses a GNSS clock to perform external synchronization, the master synchronization controller calculates the time difference between the internal time of the master synchronization controller and the GNSS clock to obtain external synchronization time difference, the master synchronization controller performs internal synchronization with each slave synchronization controller, the master controller generates internal synchronization signals according to the internal time and sends external synchronization information messages containing the internal synchronization signals and the external synchronization time difference to each slave synchronization controller, each slave synchronization controller calculates the internal time difference between each slave synchronization controller and the master synchronization controller to obtain internal synchronization time difference after receiving the internal synchronization signals, and each slave synchronization controller realizes external synchronization with the GNSS clock according to the internal synchronization time difference and the received external synchronization information messages.
In this embodiment, by adopting two-level synchronization time, the time is divided into external GNSS time and internal time, after each controller to be synchronized is configured as a master controller and a slave controller, the master synchronization controller uses GNSS clock synchronization to calculate the time difference between the internal time and the external GNSS time, and simultaneously the master synchronization controller sends external synchronization information and an internal synchronization signal generated according to the internal time to each slave synchronization controller, the slave controller uses analog GNSS clock synchronization to calculate the time difference between the autonomous time and the internal time, and then the mapping from the autonomous time of the current controller to the external GNSS time is: external GNSS time = autonomous time + internal synchronization time difference + external synchronization time difference. By the method, only the master synchronization controller is required to be connected with the GNSS receiver, in the time synchronization process, only the internal time and the external synchronization time difference between the master synchronization controller and the GNSS are required to be maintained, and each slave synchronization controller only needs to maintain the internal time and the internal synchronization time difference between the slave synchronization controller and the master synchronization controller, so that the problem of local time jump can not exist in the time synchronization process, and the controllers can be ensured to realize high-precision time synchronization.
In this embodiment, when the master synchronization controller uses the GNSS clock to perform external synchronization, the master synchronization controller specifically receives the external synchronization 1PPS signal and the GPRMC message sent by the GNSS receiver, and when the valid external synchronization 1PPS signal and the GPRMC message are continuously received for a preset number of times, the master synchronization controller performs synchronization with the GNSS clock, so as to calculate the external synchronization time difference.
In this embodiment, when the master synchronization controller performs internal synchronization with each slave synchronization controller, specifically, the master synchronization controller generates an internal 1PPS signal and an internal GPRMC time based on its own internal time, and sends the generated internal 1PPS signal, internal GPRMC time, and external synchronization information to each slave synchronization controller.
As shown in fig. 2, in this embodiment, the main controller specifically counts the time with its own internal time, determines whether the current time of the main controller is whole second, if so, generates an internal 1PPS signal and a GPRMC message, sends the 1PPS signal through the IO port, and sends the GPRMC message and the external synchronization information message through the serial port; if not, the master controller generates an internal 1PPS signal and an internal GPRMC message by taking the own time as a reference, and issues a 1PPS signal, a serial port issued GPRMC message and an external synchronization information message through IO ports connected with the slave controllers.
In this embodiment, when each slave synchronization controller performs internal synchronization, each slave synchronization controller receives an internal 1PPS signal, an internal GPRMC message, and an external synchronization information message sent by the master control, and when a valid internal 1PPS signal is continuously received and the internal GPRMC message is stable and reaches a preset number of times, each slave synchronization controller performs synchronization with the master synchronization controller, calculates an internal synchronization time difference, and if the external synchronization information message is valid, updates the external synchronization state of each slave synchronization controller by using the external synchronization time difference in the external synchronization information message.
Referring to fig. 1, in this embodiment, a specific GNSS receiver is connected to a master synchronization controller, receives a 1PPS (Pulse Per Second) Pulse synchronization signal sent by the GNSS receiver from an IO port, receives a GPRMC message sent by the GNSS receiver from a serial port, and after the two external synchronization signals are stabilized, synchronizes the master synchronization controller with external time, so as to calculate an external synchronization time difference; the master synchronous controller generates an internal 1PPS signal and an internal GPRMC time by taking the internal time of the master synchronous controller as a reference, issues the same 1PPS signal through an IO port connected with each slave synchronous controller, issues an internal GPRMC message and an external synchronous information message to each slave controller through a serial port, receives the internal 1PPS signal sent by the master synchronous controller from the IO port, receives the internal GPRMC message and the external synchronous information message sent by the master controller from the serial port, synchronizes the slave synchronous controller with the internal time after the 1PPS signal and the GPRMC message are stable, calculates an internal synchronous time difference, and updates the external synchronous state of the slave synchronous controller if the external synchronous information message is valid. In a specific application embodiment, the internal synchronization signal issued by the main controller is shown in fig. 3, where Δt is represented as a synchronization pulse error of the internal 1PPS signal.
According to the method, the master synchronous controller receives the 1PPS signal and the GPRMC signal of the GNSS receiver, GNSS clock synchronization is used, and meanwhile the same analog 1PPS signal, internal time GPRMC message and external synchronization information message are sent to each slave synchronous controller, so that GNSS clock synchronization can be simulated, time synchronization among controllers can be conveniently and rapidly realized, and local time jump is avoided.
The GPRMC message and the external synchronization message are not limited to serial port transmission, but may be transmitted in an SPI, a lan, or the like.
In this embodiment, the method further includes setting a first external synchronization flag bit for identifying whether external synchronization between the master synchronization controller and the GNSS clock is completed, when the master synchronization controller performs external synchronization, setting the first external synchronization flag bit to be invalid initially, and when an external synchronization time difference is calculated, setting the first external synchronization flag bit to be valid. In this embodiment, the first external synchronization flag bit is set to false at the initial time when the false corresponds to invalid and True corresponds to valid, and is set to True when the external synchronization time difference is calculated.
In this embodiment, the method further includes setting a second external synchronization flag bit for identifying whether external synchronization between the slave synchronization controller and the GNSS clock is completed, and setting an internal synchronization flag bit for identifying whether internal synchronization between the slave synchronization controller and the master synchronization controller is completed, where the second external synchronization flag bit and the internal synchronization flag bit are both invalid in the initial stage, setting the internal synchronization flag bit to be valid when the internal synchronization time difference is calculated, and setting the second external synchronization flag bit to be valid when the external synchronization information message is received and the external synchronization information message is valid. In this embodiment, the second external synchronization flag bit and the internal synchronization flag bit are respectively invalid and valid by using false correspondence and True correspondence, and are respectively false in the initial stage, and when the internal synchronization time difference is calculated, the internal synchronization flag bit is set to True, and when the external synchronization information message is received, the second external synchronization flag bit is set to True.
As shown in fig. 4, in this embodiment, the steps of the master synchronization controller using GNSS time signals for external synchronization include:
s11, waiting for an external synchronization 1PPS signal sent by a GNSS receiver, and jumping to the step S12 when the external synchronization 1PPS signal is received;
s12, judging whether the external synchronous 1PPS signal is effective, if so, accumulating the effective number of the 1PPS signal (namely, adding 1 to the count), jumping to the step S13, otherwise, returning to the step S11 after clearing 0 the effective number of the 1PPS signal and the effective number of the GPRMC message;
s13, judging whether the effective number of the 1PPS signal and the effective number of the GPRMC message are larger than a preset value, if so, jumping to the step S14, otherwise, returning to the step S11;
s14, subtracting the GPRMC time received by the previous frame from the internal time maintained by the main synchronous controller after adding 1 second to obtain an external synchronous time difference, setting an external synchronous flag bit to be effective, and jumping to the step S15;
s15, waiting for a GPRMC message sent by a GNSS receiver in a specified time period, and if the GPRMC message is received and valid in the time period, jumping to the step S16; otherwise, the step S11 is skipped after the effective number of the 1PPS signal and the effective number of the GPRMC message are cleared to 0;
s16, accumulating the effective number of the GPRMC message (namely adding 1 to the count), and continuing to wait for the next external synchronization 1PPS signal in the step S11.
When judging whether the 1PPS signal is valid, specifically judging whether the current time and the rising edge time of the last 1PPS signal are in the range of [ 1-deltat, 1+deltat ], wherein deltat is expressed as the synchronous pulse error of the external synchronous 1PPS signal, if yes, judging that the signal is valid, and otherwise, judging that the signal is invalid. In step S12, if the external synchronization signal triggers an interrupt (1 PPS rising edge), judging whether the current time and the last 1PPS rising edge time are within the range of [ 1-deltat, 1+deltat ], if so, jumping to step S13; otherwise, the 1pps signal valid time count and the GPRMC valid time count are both cleared to 0, and the process goes to step S11.
As shown in fig. 5, in the embodiment of the present invention, the specific steps of performing internal synchronization from the synchronization controller include:
s21, waiting for an internal 1PPS signal sent by the main synchronous controller, and jumping to the step S22 when the internal 1PPS signal is received;
s22, judging whether an internal 1PPS signal is effective, if yes, jumping to the step S23, otherwise, returning to the step S21;
s23, accumulating the effective number of the internal 1PPS signal (namely adding 1 to the count), and jumping to the step S24;
s24, judging whether the effective number count of the internal 1PPS signal and the effective number count of the internal GPRMC signal are larger than a preset value, if yes, jumping to the step S25, otherwise jumping to the step S21;
s25, subtracting the self-government time of the current slave synchronous controller from the GPRMC time in the last frame by 1 second, calculating an internal synchronous time difference, setting an internal synchronous flag bit to be effective, and jumping to the step S26;
s26, waiting for an internal GPRMC message, and if the internal GPRMC message is received and valid, jumping to the step S27; otherwise, the step S21 is skipped after the number of the effective numbers of the internal 1PPS signal and the number of the effective numbers of the internal GPRMC are both cleared to 0;
s27, accumulating the effective numbers of the internal GPRMCs (namely adding 1 to the count), and jumping to the step S28;
s28, waiting for an external synchronization information message in a specified time period, if the external synchronization information message is received in the time period and the external synchronization information message is valid, setting an external synchronization mark of a slave synchronization controller to be valid, and setting external synchronization time as the received external synchronization time; the jump step S21 continues to wait for the next internal 1PPS signal.
In the step S22, if the internal synchronization signal triggers an interrupt (1 PPS rising edge), it is determined whether the current time and the last 1PPS rising edge time are within a range of [1- Δt,1+Δt ], wherein Δt represents an internal synchronization 1PPS pulse error, which varies with the model of the master synchronization controller (100 us for FPGA, 1ms for mcu, and 10ns for high-precision clock synchronizer), and if the jump step S23 is satisfied; otherwise, the step S21 is skipped after the internal 1pps signal valid count and the internal GPRMC valid count are both cleared to 0.
The embodiment also provides a vehicle-mounted multi-controller time synchronization system, which comprises a plurality of controllers to be synchronized, wherein each controller to be synchronized performs time synchronization according to the time synchronization method, one end of a master synchronization controller is connected with a GNSS receiver, the other end of the master synchronization controller is respectively connected with each slave synchronization controller, and an IO interface, a serial interface, an SPI interface, a network interface and the like are arranged on the controllers and are used for communication between the master synchronization controller and the GNSS receiver, and communication between the master synchronization controller and each slave synchronization controller.
The foregoing is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. While the invention has been described with reference to preferred embodiments, it is not intended to be limiting. Therefore, any simple modification, equivalent variation and modification of the above embodiments according to the technical substance of the present invention shall fall within the scope of the technical solution of the present invention.

Claims (10)

1. A vehicle-mounted multi-controller time synchronization method, which is characterized by comprising the following steps: one controller of the controllers to be synchronized is configured as a master synchronization controller, the other controllers are configured as slave synchronization controllers, the master synchronization controller uses a GNSS clock to perform external synchronization, namely, the master synchronization controller and the GNSS clock perform synchronization, the master synchronization controller calculates the time difference between the internal time of the master synchronization controller and the GNSS time to obtain an external synchronization time difference, the master synchronization controller performs internal synchronization with each slave synchronization controller, the master synchronization controller generates an internal synchronization signal according to the internal time and sends the internal synchronization signal and an external synchronization information message containing the external synchronization time difference to each slave synchronization controller, each slave synchronization controller calculates the internal synchronization time difference between each slave synchronization controller and the master synchronization controller after receiving the internal synchronization signal, the slave synchronization controller performs synchronization according to the internal synchronization time difference and the master synchronization controller, if the external synchronization information message is valid, the external synchronization time difference is used for updating the external synchronization state of each slave synchronization controller, and the slave synchronization controller realizes external synchronization according to the internal synchronization time difference and the external synchronization information received by each slave synchronization controller.
2. The vehicle-mounted multi-controller time synchronization method according to claim 1, wherein: when the main synchronization controller uses the GNSS clock to perform external synchronization, the main synchronization controller receives the external synchronization 1PPS signal and the GPRMC message sent by the GNSS receiver respectively, and when the effective external synchronization 1PPS signal and the GPRMC message are continuously received for a preset number of times, the main synchronization controller synchronizes with the GNSS clock, and calculates the external synchronization time difference.
3. The method for time synchronization of on-board multiple controllers according to claim 2, further comprising setting a first external synchronization flag bit for identifying whether external synchronization between a master synchronization controller and GNSS time is completed, wherein the master synchronization controller initially sets the first external synchronization flag bit to be invalid when external synchronization is performed, and sets the first external synchronization flag bit to be valid when the external synchronization time difference is calculated.
4. The method for time synchronization of on-board multi-controller according to claim 3, wherein the specific step of external synchronization of the master synchronization controller using GNSS time signals comprises:
s11, waiting for an external synchronization 1PPS signal sent by a GNSS receiver, and jumping to the step S12 when the external synchronization 1PPS signal is received;
s12, judging whether the external synchronous 1PPS signal is effective, if so, accumulating the effective number of the 1PPS signal, jumping to the step S13, otherwise, returning to the step S11 after clearing 0 the effective number of the 1PPS signal and the effective number of the GPRMC message;
s13, judging whether the effective number of the 1PPS signal and the effective number of the GPRMC message are larger than a preset value, if so, jumping to the step S14, otherwise, returning to the step S11;
s14, subtracting the GPRMC time received by the previous frame from the internal time maintained by the main synchronous controller after adding 1 second to obtain the external synchronous time difference, setting an external synchronous flag bit to be effective, and jumping to the step S15;
s15, waiting for a GPRMC message sent by a GNSS receiver, and if the GPRMC message is received and is valid, jumping to the step S16; otherwise, the 1PPS signal effective number times and the GPRMC message effective number times are cleared to be 0, and then the step S11 is skipped;
s16, accumulating the effective numbers of the GPRMC messages, and continuing to wait for the next external synchronization 1PPS signal in a jumping step S11.
5. The method according to any one of claims 1 to 4, wherein when the master synchronization controller performs internal synchronization with each of the slave synchronization controllers, specifically, the master synchronization controller generates an internal 1PPS signal and an internal GPRMC time based on its own internal time, and the generated internal 1PPS signal and internal GPRMC time, and the external synchronization information message are respectively transmitted to each of the slave synchronization controllers.
6. The method according to claim 5, wherein each slave synchronization controller performs synchronization with the master synchronization controller when the slave synchronization controller performs internal synchronization, and calculates the internal synchronization time difference, and if the external synchronization information message is valid, updates the external synchronization state of each slave synchronization controller using the external synchronization time difference in the external synchronization information message when the internal 1PPS signal, the internal GPRMC message, and the external synchronization information message which are sent from the master synchronization controller are continuously received and the internal 1PPS signal and the internal GPRMC message are stable for a predetermined number of times.
7. The on-vehicle multi-controller time synchronization method according to claim 6, further comprising setting a second external synchronization flag bit for identifying whether external synchronization between a slave synchronization controller and GNSS time is completed, and an internal synchronization flag bit for identifying whether internal synchronization between a slave synchronization controller and a master synchronization controller is completed, initially setting both the second external synchronization flag bit and the internal synchronization flag bit to be inactive, setting the internal synchronization flag bit to be active when the internal synchronization time difference is calculated, and setting the second external synchronization flag bit to be active when the external synchronization information message is received and the external synchronization information message is active.
8. The method for time synchronization of multiple controllers on a vehicle according to claim 7, wherein the specific step of performing internal synchronization from the synchronization controller comprises:
s21, waiting for an internal 1PPS signal sent by the main synchronous controller, and jumping to the step S22 when the internal 1PPS signal is received;
s22, judging whether the internal 1PPS signal is effective, if yes, jumping to the step S23, otherwise, returning to the step S21;
s23, accumulating the effective numbers of the internal 1PPS signals, and jumping to the step S24;
s24, judging whether the effective number count of the internal 1PPS signal and the effective number count of the internal GPRMC signal are larger than a preset value, if yes, jumping to the step S25, otherwise jumping to the step S21;
s25, subtracting the self-government time of the current slave synchronous controller from the GPRMC time in the last frame by 1 second, calculating the internal synchronous time difference, setting an internal synchronous flag bit to be effective, and jumping to the step S26;
s26, waiting for the internal GPRMC message, and if the internal GPRMC message is received and valid, jumping to the step S27; otherwise, the step S21 is skipped after the number of the effective numbers of the internal 1PPS signal and the number of the effective numbers of the internal GPRMC are both cleared to 0;
s27, accumulating the effective numbers of the internal GPRMCs, and jumping to the step S28;
s28, waiting for the external synchronization information message, if the external synchronization information message is received and is valid, setting an external synchronization mark of a slave synchronization controller to be valid, and setting external synchronization time to be the received external synchronization time; the jump step S21 continues to wait for the next internal 1PPS signal.
9. A vehicle-mounted multi-controller time synchronization system comprising a plurality of controllers to be synchronized, wherein each controller to be synchronized performs time synchronization according to the synchronization method as set forth in any one of claims 1 to 8, one end of the master synchronization controller is connected to a GNSS receiver, and the other end is connected to each slave synchronization controller.
10. The on-board multi-controller time synchronization system of claim 9, wherein: and one or more of an IO interface, a serial interface, an SPI interface and a network interface are arranged on the controller.
CN202011096841.9A 2020-10-14 2020-10-14 Time synchronization method and system for vehicle-mounted multi-controller Active CN112152747B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011096841.9A CN112152747B (en) 2020-10-14 2020-10-14 Time synchronization method and system for vehicle-mounted multi-controller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011096841.9A CN112152747B (en) 2020-10-14 2020-10-14 Time synchronization method and system for vehicle-mounted multi-controller

Publications (2)

Publication Number Publication Date
CN112152747A CN112152747A (en) 2020-12-29
CN112152747B true CN112152747B (en) 2023-07-21

Family

ID=73953036

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011096841.9A Active CN112152747B (en) 2020-10-14 2020-10-14 Time synchronization method and system for vehicle-mounted multi-controller

Country Status (1)

Country Link
CN (1) CN112152747B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103401672A (en) * 2013-07-24 2013-11-20 福建星网锐捷网络有限公司 Time synchronization device, equipment and system

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU2006273784A1 (en) * 2005-07-27 2007-02-01 Selex Galileo Ltd System and method for determining the time difference between two platforms
CN101895383B (en) * 2010-07-07 2013-07-10 中国人民解放军国防科学技术大学 External clock synchronization system and synchronization method thereof
JP6523497B1 (en) * 2018-01-17 2019-06-05 三菱電機株式会社 Master controller and synchronous communication system using the same
CN110113127B (en) * 2019-06-05 2021-08-20 深圳市英特瑞半导体科技有限公司 Method and system for transmitting time based on 1588 protocol

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103401672A (en) * 2013-07-24 2013-11-20 福建星网锐捷网络有限公司 Time synchronization device, equipment and system

Also Published As

Publication number Publication date
CN112152747A (en) 2020-12-29

Similar Documents

Publication Publication Date Title
US9606219B2 (en) Systems and methods for locating a target in a GPS-denied environment
US9712270B2 (en) Transfer of synchronization in a hybrid global navigation satellite packet network system
US20110090925A1 (en) Method for synchronization in networks
CN101442375B (en) Time distribution service apparatus compatible with multiple networks and working method thereof
KR20090032306A (en) Time synchronization system and method on the network
MX2014005686A (en) Systems and methods for time synchronization of ieds via radio link.
CN112929122A (en) Time synchronization method and device, terminal equipment and computer readable storage medium
CN110492965A (en) The method and apparatus of serial message clock synchronization in a kind of master-slave system
CN112119365A (en) Time synchronization method, multi-sensor system and movable platform
EP3352392B1 (en) Time synchronization packet processing method and device
WO2021077289A1 (en) Synchronization method and device
CN115576295A (en) Domain controller time service system, domain controller and engineering machinery
EP3812875B1 (en) Time synchronization over redundant and deterministic switch-based avionics networks
CN112152747B (en) Time synchronization method and system for vehicle-mounted multi-controller
JP6012535B2 (en) Time information transmission device
CN106789196B (en) Flexibly configurable high-redundancy high-precision time synchronization system
CN112583508B (en) Clock synchronization communication system and method for rail train
RU172628U1 (en) TIME SYNCHRONIZATION SERVER
CN112583513A (en) Cloud platform clock time service method and system
CN108844544B (en) Information synchronism design method for main and sub navigation devices
CN112468254B (en) Reconfigurable distributed node high-precision time service synchronization system and method
CN116455498B (en) Time service method, system and intelligent driving equipment
KR20170124213A (en) UTC Time Synchronization Method for a Device using GPS Module
EP3876442A2 (en) Distributed network time synchronization
JP2018157462A (en) Log storage method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant