TWI751466B - Time synchronization method and time synchronization system - Google Patents
Time synchronization method and time synchronization system Download PDFInfo
- Publication number
- TWI751466B TWI751466B TW108147782A TW108147782A TWI751466B TW I751466 B TWI751466 B TW I751466B TW 108147782 A TW108147782 A TW 108147782A TW 108147782 A TW108147782 A TW 108147782A TW I751466 B TWI751466 B TW I751466B
- Authority
- TW
- Taiwan
- Prior art keywords
- time information
- host
- time
- data packet
- test
- Prior art date
Links
Images
Landscapes
- Synchronisation In Digital Transmission Systems (AREA)
Abstract
Description
本發明是有關於一種時間同步技術,且特別是有關於一種時間同步方法與時間同步系統。The present invention relates to a time synchronization technology, and in particular, to a time synchronization method and a time synchronization system.
控制器區域網路(Controller Area Network, CAN)是一種匯流排標準,其可用於車載電子系統或其他產業的電子系統中,以使電子系統中的晶片及/或電子儀器相互通訊。CAN系統中的節點亦稱為CAN裝置(或CAN匯流排裝置)。多個CAN裝置之間可透過雙絞線彼此連接以進行通訊。A Controller Area Network (CAN) is a bus standard that can be used in automotive electronic systems or electronic systems in other industries to enable chips and/or electronic devices in the electronic systems to communicate with each other. Nodes in a CAN system are also referred to as CAN devices (or CAN bus devices). Multiple CAN devices can be connected to each other through twisted pairs for communication.
一般來說,當CAN裝置接收到資料封包時,此CAN裝置會根據裝置內建的時鐘對接收到的資料封包加上一個時間戳,並將此資料封包暫存於緩存器中。爾後,外接的電腦裝置可以經由通用序列匯流排(Universal Serial Bus, USB)或乙太網路等通訊協定來從此CAN裝置的緩存器中讀取資料封包與相關的封包接收時間等資訊。但是,在實務上,CAN裝置內建的時鐘往往與真實時間存在誤差,且不同CAN裝置的時鐘可能也彼此不同步,從而造成應用程式對資料封包的接收時間發生誤判。Generally speaking, when a CAN device receives a data packet, the CAN device adds a time stamp to the received data packet according to the built-in clock of the device, and temporarily stores the data packet in a register. Afterwards, the external computer device can read information such as data packets and related packet reception time from the register of the CAN device through communication protocols such as Universal Serial Bus (USB) or Ethernet. However, in practice, the built-in clock of a CAN device often has errors with the real time, and the clocks of different CAN devices may be out of sync with each other, resulting in misjudgment of the receiving time of the data packet by the application program.
本發明提供一種時間同步方法與時間同步系統,可將CAN裝置所接收的資料封包的接收時間與主機裝置的時間進行同步。The invention provides a time synchronization method and a time synchronization system, which can synchronize the reception time of the data packet received by the CAN device with the time of the host device.
本發明的實施例提供一種時間同步方法,其用於控制器區域網路(Controller Area Network, CAN)系統,所述時間同步方法包括:在所述CAN系統中的CAN裝置的測試模式下,建立所述CAN裝置與主機裝置之間的時間映射關係;在所述CAN裝置的正常模式下,從所述CAN裝置讀取至少一資料封包的CAN時間資訊;以及根據所述時間映射關係與所述CAN時間資訊,記錄所述至少一資料封包的主機時間資訊。An embodiment of the present invention provides a time synchronization method, which is used in a Controller Area Network (CAN) system. The time synchronization method includes: in a test mode of a CAN device in the CAN system, establishing the time mapping relationship between the CAN device and the host device; in the normal mode of the CAN device, read CAN time information of at least one data packet from the CAN device; and according to the time mapping relationship and the CAN time information, recording the host time information of the at least one data packet.
本發明的實施例另提供一種時間同步系統,其包括主機裝置與至少一CAN裝置。所述至少一CAN裝置包括第一CAN裝置並耦接至所述主機裝置。所述主機裝置用以在所述第一CAN裝置的測試模式下,建立所述第一CAN裝置與所述主機裝置之間的時間映射關係。所述主機裝置更用以在所述第一CAN裝置的正常模式下,從所述第一CAN裝置讀取至少一資料封包的CAN時間資訊。所述主機裝置更用以根據所述時間映射關係與所述CAN時間資訊,記錄所述至少一資料封包的主機時間資訊。An embodiment of the present invention further provides a time synchronization system, which includes a host device and at least one CAN device. The at least one CAN device includes a first CAN device and is coupled to the host device. The host device is used for establishing a time mapping relationship between the first CAN device and the host device in the test mode of the first CAN device. The host device is further configured to read CAN time information of at least one data packet from the first CAN device in the normal mode of the first CAN device. The host device is further configured to record host time information of the at least one data packet according to the time mapping relationship and the CAN time information.
基於上述,在CAN裝置的測試模式下,CAN裝置與主機裝置之間的時間映射關係可被建立。此外,在CAN裝置的正常模式下,至少一資料封包的CAN時間資訊可從CAN裝置中讀取。根據所述時間映射關係與所述CAN時間資訊,所述至少一資料封包的主機時間資訊可被記錄,使得所述至少一資料封包的接收時間與主機裝置的時間進行同步。Based on the above, in the test mode of the CAN device, the time mapping relationship between the CAN device and the host device can be established. In addition, in the normal mode of the CAN device, CAN time information of at least one data packet can be read from the CAN device. According to the time mapping relationship and the CAN time information, the host time information of the at least one data packet can be recorded, so that the reception time of the at least one data packet is synchronized with the time of the host device.
圖1是根據本發明的一實施例所繪示的時間同步系統的示意圖。請參照圖1,時間同步系統100包括控制器區域網路(Controller Area Network, CAN)系統10與主機裝置12。CAN系統10包括多個CAN裝置11(1)~11(n)。CAN裝置11(1)~11(n)裝置彼此之間可透過雙絞線連接以相互通訊。FIG. 1 is a schematic diagram of a time synchronization system according to an embodiment of the present invention. Please refer to FIG. 1 , the
CAN裝置11(1)~11(n)中的每一者可包括CAN控制器(例如微控制器)與CAN收發器。CAN控制器用以控制CAN裝置的運作,而CAN收發器則可用以從其他CAN裝置接收資料封包或發送資料封包至其他CAN裝置。Each of the CAN devices 11(1)-11(n) may include a CAN controller (eg, a microcontroller) and a CAN transceiver. The CAN controller is used to control the operation of the CAN device, and the CAN transceiver can be used to receive data packets from other CAN devices or send data packets to other CAN devices.
CAN裝置11(1)~11(n)中的每一者可連接至一或多個電子控制單元(Electronic Control Unit, ECU)。在一實施例中,是假設時間同步系統100與CAN系統10設置於車載系統中。因此,所述ECU可以是用以控制此車載系統中特定車用電子組件的控制器。此外,多個ECU可經由CAN系統10(例如CAN裝置11(1)~11(n))彼此通訊。然而,在另一實施例中,時間同步系統100與CAN系統10亦可以設置於其他類型的電子系統中,而不限於車載系統。Each of the CAN devices 11(1)-11(n) may be connected to one or more Electronic Control Units (ECUs). In one embodiment, it is assumed that the
主機裝置12耦接至CAN系統10。主機裝置12可經由通用序列匯流排(Universal Serial Bus, USB)或乙太網路等通訊協定來連接至CAN系統10中的第一CAN裝置並與第一CAN裝置通訊。例如,主機裝置12可為任意類型的電腦裝置或電腦主機。例如,主機裝置12可包括中央處理單元(CPU)、或是其他可程式化之一般用途或特殊用途的微處理器、數位訊號處理器(Digital Signal Processor, DSP)、可程式化控制器、特殊應用積體電路(Application Specific Integrated Circuits, ASIC)、可程式化邏輯裝置(Programmable Logic Device, PLD)或其他類似裝置或這些裝置的組合。The
在一實施例中,主機裝置12可在第一CAN裝置的測試模式下,建立第一CAN裝置與主機裝置12之間在時間上的映射關係(亦稱為時間映射關係)。此時間映射關係可用於將主機裝置12的時鐘與第一CAN裝置的時鐘同步。In one embodiment, the
在一實施例中,測試模式亦稱為回授(loopback)模式。當第一CAN裝置處於測試模式時,若第一CAN裝置接收到來自主機裝置12的封包(亦稱為測試封包),第一CAN裝置可直接將此測試封包回傳給主機裝置12,而不將此測試封包發送給CAN系統10中的其餘CAN裝置。In one embodiment, the test mode is also referred to as a loopback mode. When the first CAN device is in the test mode, if the first CAN device receives a packet (also referred to as a test packet) from the
在一實施例中,主機裝置12可在第一CAN裝置的正常模式下,從第一CAN裝置讀取至少一封包(亦稱為資料封包)的CAN時間資訊。例如,當第一CAN裝置從CAN系統10中的其餘CAN裝置接收到一個資料封包時,第一CAN裝置可記錄其接收到此資料封包的時間(即CAN時間資訊)。換言之,一個資料封包的CAN時間資訊可反映第一CAN裝置接收到此資料封包的時間。第一CAN裝置可將所接收到的資料封包與相關的資訊(例如封包ID、封包內容及CAN時間資訊)儲存於其內部的緩存器。當第一CAN裝置處於正常模式時,主機裝置12可從第一CAN裝置的緩存器中讀取資料封包以及與此資料封包相關的資訊(例如所述CAN時間資訊)。In one embodiment, the
在一實施例中,主機裝置12可根據所述時間映射關係與所述資料封包的CAN時間資訊,記錄所述資料封包的主機時間資訊。此主機時間資訊是指當第一CAN裝置接收到某一資料封包時,此時的主機裝置12的時鐘所指示的時間。換言之,在從第一CAN裝置讀取的某一資料封包的CAN時間資訊後,主機裝置12可根據所述時間映射關係將此資料封包的CAN時間資訊轉換為當第一CAN裝置接收到此資料封包時,此時的主機裝置12的時鐘所指示的時間(即主機時間資訊)。In one embodiment, the
在以下的實施例中,是以CAN裝置11(1)作為第一CAN裝置的範例。然而,在另一實施例中,第一CAN裝置亦可以是指CAN裝置11(2)~11(n)中的一或多者。In the following embodiments, the CAN device 11(1) is used as an example of the first CAN device. However, in another embodiment, the first CAN device may also refer to one or more of the CAN devices 11(2)˜11(n).
圖2是根據本發明的一實施例所繪示的建立第一CAN裝置與主機裝置之間的時間映射關係的示意圖。請參照圖1與圖2,在時間範圍21內,主機裝置12可將CAN裝置11(1)設定為測試模式(亦稱為第一測試模式)。在第一測試模式下(即時間範圍21內),主機裝置12可發送測試封包(亦稱為第一測試封包)PT(1)至CAN裝置11(1)。然後,主機裝置12可記錄測試封包PT(1)的主機時間資訊(亦稱為第一主機時間資訊)TP(1)與測試封包PT(1)的CAN時間資訊(亦稱為第一CAN時間資訊)TC(1)。FIG. 2 is a schematic diagram of establishing a time mapping relationship between a first CAN device and a host device according to an embodiment of the present invention. Referring to FIGS. 1 and 2 , within the
在一實施例中,當送出測試封包PT(1)時,主機裝置12可記錄送出測試封包PT(1)時的主機時間資訊T1(Tx)。例如,主機時間資訊T1(Tx)可反映主機裝置12送出測試封包PT(1)的時間。當CAN裝置11(1)接收到測試封包PT(1)時,CAN裝置11(1)可記錄測試封包PT(1)的CAN時間資訊TC(1)。例如,CAN時間資訊TC(1)可反映CAN裝置11(1)接收到測試封包PT(1)的時間。當主機裝置12接收到CAN裝置11(1)回傳的測試封包PT(1)時,主機裝置12可記錄測試封包PT(1)的另一主機時間資訊T1(Rx)。例如,主機時間資訊T1(Rx)可反映主機裝置12接收到測試封包PT(1)的時間。主機裝置12可根據主機時間資訊T1(Tx)與T1(Rx)決定主機時間資訊TP(1)。例如,主機時間資訊TP(1)可等於(T1(Tx)+T1(Rx))/2。在一實施例中,記錄主機時間資訊TP(1)與CAN時間資訊TC(1)的操作類似於建立主機時間資訊TP(1)與CAN時間資訊TC(1)之間的映射關係。In one embodiment, when the test packet PT(1) is sent, the
在記錄主機時間資訊TP(1)與CAN時間資訊TC(1)後,在時間範圍22內,主機裝置12可控制CAN裝置11(1)從第一測試模式切換至正常模式。在CAN裝置11(1)的正常模式下(即時間範圍22內),主機裝置12可從CAN裝置11(1)讀取至少一資料封包的CAN時間資訊。After recording the host time information TP(1) and the CAN time information TC(1), within the
須注意的是,在圖2的實施例中,是以讀取資料封包PN(k)的CAN時間資訊TC(k)作為範例。其中,資料封包PN(k)是暫存在CAN裝置11(1)的緩存器的資料封包,且CAN時間資訊TC(k)可反映CAN裝置11(1)接收到資料封包PN(k)的時間。主機裝置12可記錄資料封包PN(k)的CAN時間資訊TC(k)。資料封包PN(k)的數目可以是一或多個,本發明不加以限制。It should be noted that, in the embodiment of FIG. 2 , the CAN time information TC(k) of the data packet PN(k) is read as an example. The data packet PN(k) is a data packet temporarily stored in the register of the CAN device 11(1), and the CAN time information TC(k) can reflect the time when the CAN device 11(1) received the data packet PN(k) . The
在記錄資料封包PN(k)的CAN時間資訊TC(k)後,在時間範圍23內,主機裝置12可將CAN裝置11(1)再次設定為測試模式(亦稱為第二測試模式)。在第二測試模式下(即時間範圍23內),主機裝置12可發送測試封包(亦稱為第二測試封包)PT(2)至CAN裝置11(1)。然後,主機裝置12可記錄測試封包PT(2)的主機時間資訊(亦稱為第二主機時間資訊)TP(2)與測試封包PT(2)的CAN時間資訊(亦稱為第二CAN時間資訊)TC(2)。After recording the CAN time information TC(k) of the data packet PN(k), within the
在一實施例中,當送出測試封包PT(2)時,主機裝置12可記錄送出測試封包PT(2)時的主機時間資訊T2(Tx)。例如,主機時間資訊T2(Tx)可反映主機裝置12送出測試封包PT(2)的時間。當CAN裝置11(1)接收到測試封包PT(2)時,CAN裝置11(1)可記錄測試封包PT(2)的CAN時間資訊TC(2)。例如,CAN時間資訊TC(2)可反映CAN裝置11(1)接收到測試封包PT(2)的時間。當主機裝置12接收到CAN裝置11(1)回傳的測試封包PT(2)時,主機裝置12可記錄測試封包PT(2)的另一主機時間資訊T2(Rx)。例如,主機時間資訊T2(Rx)可反映主機裝置12接收到測試封包PT(2)的時間。主機裝置12可根據主機時間資訊T2(Tx)與T2(Rx)決定主機時間資訊TP(2)。例如,主機時間資訊TP(2)可等於(T2(Tx)+T2(Rx))/2。在一實施例中,記錄主機時間資訊TP(2)與CAN時間資訊TC(2)的操作類似於建立主機時間資訊TP(2)與CAN時間資訊TC(2)之間的映射關係。In one embodiment, when the test packet PT(2) is sent, the
圖3是根據本發明的一實施例所繪示的根據時間映射關係與CAN時間資訊,記錄資料封包的主機時間資訊的示意圖。請參照圖1至圖3,主機裝置12可根據主機時間資訊TP(1)、CAN時間資訊TC(1)、主機時間資訊TP(2)、CAN時間資訊TC(2)及資料封包PN(k)的CAN時間資訊TC(k)決定主機時間資訊TP(k)。主機時間資訊TP(k)可反映當CAN裝置11(1)接收到資料封包PN(k)時,此時的主機裝置12的時鐘所指示的時間。3 is a schematic diagram of recording host time information of a data packet according to a time mapping relationship and CAN time information according to an embodiment of the present invention. Referring to FIGS. 1 to 3 , the
在一實施例中,主機裝置12可根據主機時間資訊TP(1)、CAN時間資訊TC(1)、主機時間資訊TP(2)及CAN時間資訊TC(2),將CAN時間資訊TC(k)映射至主機時間資訊TP(k)。在一實施例中,主機裝置12可獲得CAN時間資訊TC(k)相較於CAN時間資訊TC(1)與TC(2)的至少其中之一的偏移時間資訊。然後,主機裝置12可根據主機時間資訊TP(1)、主機時間資訊TP(2)及此偏移時間資訊獲得主機時間資訊TP(k)。In one embodiment, the
在一實施例中,主機裝置12可根據CAN時間資訊TC(1)、TC(2)及TC(k)獲得差值r(1)與r(2)。差值r(1)反映CAN時間資訊TC(1)與TC(k)之間的時間差(例如r(1)=TC(k)-TC(1))。差值r(2)反映CAN時間資訊TC(k)與TC(2)之間的時間差(例如r(2)=TC(2)-TC(k))。差值r(1)及/或r(2)可為所述偏移時間資訊。主機裝置12可根據差值r(1)與r(2)的比值(或者差值r(1)與(r(1)+r(2))的比值)來在主機時間資訊TP(1)與TP(2)之間決定主機時間資訊TP(k)。In one embodiment, the
須注意的是,主機時間資訊TP(1)與所決定的主機時間資訊TP(k)之間具有差值r(3),且主機時間資訊TP(2)與所決定的主機時間資訊TP(k)之間具有差值r(4)。差值r(3)反映主機時間資訊TP(1)與TP(k)之間的時間差(例如r(3)=TP(k)-TP(1))。差值r(4)反映主機時間資訊TP(k)與TP(2)之間的時間差(例如r(4)=TP(2)-TP(k))。差值r(3)與r(4)之間的比值可相同(或實質相同)於差值r(1)與r(2)之間的比值。It should be noted that there is a difference r(3) between the host time information TP(1) and the determined host time information TP(k), and the host time information TP(2) and the determined host time information TP( There is a difference r(4) between k). The difference r(3) reflects the time difference between the host time information TP(1) and TP(k) (eg, r(3)=TP(k)−TP(1)). The difference r(4) reflects the time difference between the host time information TP(k) and TP(2) (eg, r(4)=TP(2)-TP(k)). The ratio between the differences r(3) and r(4) may be the same (or substantially the same) as the ratio between the differences r(1) and r(2).
在一實施例中,主機裝置12可獲得主機時間資訊TP(1)與TP(2)之間的時間差Td。主機裝置12可將時間差Td乘上(r(1)/(r(1)+r(2)))獲得差值r(3)。然後,主機裝置12可將主機時間資訊TP(1)加上差值r(3)以獲得主機時間資訊TP(k)。須注意的是,主機裝置12還可藉由其他的邏輯運算方法來獲得主機時間資訊TP(k),只要符合上述數值比例之規範即可。In one embodiment, the
在一實施例中,主機裝置12可將所獲得的資料封包PN(k)的主機時間資訊TP(k)藉由主機裝置12的顯示器呈現。藉此,主機裝置12的操作者可以根據主機裝置12的顯示器所呈現的訊息清楚得知資料封包PN(k)是在主機裝置12的時鐘所指示的時間點TP(k)被CAN裝置11(1)接收。此外,主機裝置12的應用程式可根據同步後的主機時間資訊TP(k)來對資料封包PN(k)進行處理。In one embodiment, the
圖4是根據本發明的一實施例所繪示的時間同步方法的流程圖。請參照圖4,在步驟S401中,在CAN系統中的CAN裝置的測試模式下,建立所述CAN裝置與主機裝置之間的時間映射關係。在步驟S402中,在所述CAN裝置的正常模式下,從所述CAN裝置讀取至少一資料封包的CAN時間資訊。在步驟S403中,根據所述時間映射關係與所述CAN時間資訊,記錄所述至少一資料封包的主機時間資訊。FIG. 4 is a flowchart of a time synchronization method according to an embodiment of the present invention. Referring to FIG. 4 , in step S401 , in the test mode of the CAN device in the CAN system, a time mapping relationship between the CAN device and the host device is established. In step S402, in the normal mode of the CAN device, read CAN time information of at least one data packet from the CAN device. In step S403, the host time information of the at least one data packet is recorded according to the time mapping relationship and the CAN time information.
圖5是根據本發明的一實施例所繪示的時間同步方法的流程圖。請參照圖5,在步驟S501中,將CAN裝置設定為測試模式。在步驟S502中,在所述CAN裝置中建立接收器排程(receiver thread)。在步驟S503中,從主機裝置送出測試封包並記錄封包送出時的時間。在步驟S504中,從主機裝置的接收器排程接收從所述CAN裝置返回的測試封包並記錄主機裝置與所述CAN裝置分別接收到此測試封包的時間。在步驟S505中,根據步驟S503與S504所記錄的時間記錄測試封包的主機時間資訊以及測試封包的CAN時間資訊。例如,圖5的流程與相關操作可於圖2中的時間範圍21與23內執行。FIG. 5 is a flowchart of a time synchronization method according to an embodiment of the present invention. Referring to FIG. 5 , in step S501 , the CAN device is set to a test mode. In step S502, a receiver thread is established in the CAN device. In step S503, the test packet is sent from the host device and the time when the packet is sent is recorded. In step S504, the receiver of the host device schedules to receive the test packet returned from the CAN device and records the time when the host device and the CAN device respectively receive the test packet. In step S505, the host time information of the test packet and the CAN time information of the test packet are recorded according to the times recorded in steps S503 and S504. For example, the process and related operations of FIG. 5 may be performed within time ranges 21 and 23 in FIG. 2 .
圖6是根據本發明的一實施例所繪示的時間同步方法的流程圖。請參照圖6,在步驟S601中,將CAN裝置設定為正常模式。在步驟S602中,建立一記錄檔。在步驟S603中,從所述CAN裝置讀取至少一資料封包以及與所述至少一資料封包相關的CAN資訊,並將這些資訊記載於所述記錄檔。例如,圖6的流程與相關操作可於圖2中的時間範圍22內執行。FIG. 6 is a flowchart of a time synchronization method according to an embodiment of the present invention. Referring to FIG. 6, in step S601, the CAN device is set to the normal mode. In step S602, a record file is created. In step S603, at least one data packet and CAN information related to the at least one data packet are read from the CAN device, and the information is recorded in the log file. For example, the flow and related operations of FIG. 6 may be performed within the
圖7是根據本發明的一實施例所繪示的時間同步方法的流程圖。請參照圖7,在步驟S701中,開啟所述記錄檔。在步驟S702中,從所述記錄檔中讀取所述至少一資料封包的CAN資訊,包含CAN時間資訊。在步驟S703中,根據所建立的時間映射關係與所述CAN資訊記錄所述至少一資料封包的主機時間資訊。例如,圖7的步驟S703可參照圖3的實施例之說明,在此不重複贅述。FIG. 7 is a flowchart of a time synchronization method according to an embodiment of the present invention. Referring to FIG. 7, in step S701, the record file is opened. In step S702, the CAN information of the at least one data packet is read from the record file, including CAN time information. In step S703, the host time information of the at least one data packet is recorded according to the established time mapping relationship and the CAN information. For example, for step S703 in FIG. 7 , reference may be made to the description of the embodiment in FIG. 3 , and details are not repeated here.
然而,圖4至圖7中各步驟已詳細說明如上,在此便不再贅述。值得注意的是,圖4至圖7中各步驟可以實作為多個程式碼或是電路,本發明不加以限制。此外,圖4至圖7的方法可以搭配以上範例實施例使用,也可以單獨使用,本發明不加以限制。However, each step in FIG. 4 to FIG. 7 has been described in detail as above, and will not be repeated here. It should be noted that each step in FIG. 4 to FIG. 7 can be implemented as a plurality of codes or circuits, which is not limited by the present invention. In addition, the methods of FIG. 4 to FIG. 7 can be used in conjunction with the above exemplary embodiments, and can also be used alone, which is not limited by the present invention.
綜上所述,在CAN裝置的測試模式下,CAN裝置與主機裝置之間的時間映射關係可被建立。此外,在CAN裝置的正常模式下,至少一資料封包的CAN時間資訊可從CAN裝置中讀取。根據所述時間映射關係與所述CAN時間資訊,所述至少一資料封包的主機時間資訊可被記錄,使得所述至少一資料封包的接收時間與主機裝置的時間進行同步。藉此,可有效改善以往CAN裝置的時鐘與主機裝置的時鐘之間在時間上不同步而衍生的問題(例如主機裝置的應用程式對資料封包的接收時間及/或順序發生誤判)。To sum up, in the test mode of the CAN device, the time mapping relationship between the CAN device and the host device can be established. In addition, in the normal mode of the CAN device, CAN time information of at least one data packet can be read from the CAN device. According to the time mapping relationship and the CAN time information, the host time information of the at least one data packet can be recorded, so that the reception time of the at least one data packet is synchronized with the time of the host device. In this way, the problems caused by the time synchronization between the clock of the CAN device and the clock of the host device in the past can be effectively improved (for example, the application of the host device misjudged the receiving time and/or sequence of the data packets).
100:時間同步系統
10:控制器區域網路(CAN)系統
11(1)~11(n):CAN裝置
12:主機裝置
21、22、23:時間範圍
PT(1)、PT(2):測試封包
PN(k):資料封包
TP(1)、TP(2)、TP(k):主機時間資訊
TC(1)、TC(2)、TC(k):CAN時間資訊
r(1)、r(2)、r(3)、r(4):差值
S401~S403、S501~S505、S601~S603、S701~S703:步驟100: Time Synchronization System
10: Controller Area Network (CAN) system
11(1)~11(n): CAN device
12:
圖1是根據本發明的一實施例所繪示的時間同步系統的示意圖。 圖2是根據本發明的一實施例所繪示的建立第一CAN裝置與主機裝置之間的時間映射關係的示意圖。 圖3是根據本發明的一實施例所繪示的根據時間映射關係與CAN時間資訊,記錄資料封包的主機時間資訊的示意圖。 圖4是根據本發明的一實施例所繪示的時間同步方法的流程圖。 圖5是根據本發明的一實施例所繪示的時間同步方法的流程圖。 圖6是根據本發明的一實施例所繪示的時間同步方法的流程圖。 圖7是根據本發明的一實施例所繪示的時間同步方法的流程圖。FIG. 1 is a schematic diagram of a time synchronization system according to an embodiment of the present invention. FIG. 2 is a schematic diagram of establishing a time mapping relationship between a first CAN device and a host device according to an embodiment of the present invention. 3 is a schematic diagram of recording host time information of a data packet according to a time mapping relationship and CAN time information according to an embodiment of the present invention. FIG. 4 is a flowchart of a time synchronization method according to an embodiment of the present invention. FIG. 5 is a flowchart of a time synchronization method according to an embodiment of the present invention. FIG. 6 is a flowchart of a time synchronization method according to an embodiment of the present invention. FIG. 7 is a flowchart of a time synchronization method according to an embodiment of the present invention.
S401~S403:步驟S401~S403: Steps
Claims (8)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW108147782A TWI751466B (en) | 2019-12-26 | 2019-12-26 | Time synchronization method and time synchronization system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW108147782A TWI751466B (en) | 2019-12-26 | 2019-12-26 | Time synchronization method and time synchronization system |
Publications (2)
Publication Number | Publication Date |
---|---|
TW202126089A TW202126089A (en) | 2021-07-01 |
TWI751466B true TWI751466B (en) | 2022-01-01 |
Family
ID=77908859
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW108147782A TWI751466B (en) | 2019-12-26 | 2019-12-26 | Time synchronization method and time synchronization system |
Country Status (1)
Country | Link |
---|---|
TW (1) | TWI751466B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO1998054872A1 (en) * | 1997-05-27 | 1998-12-03 | Micro Motion, Inc. | Deterministic serial bus communication system with 'controller area (can)' protocol |
US8504864B2 (en) * | 2010-12-01 | 2013-08-06 | GM Global Technology Operations LLC | Data sensor coordination using time synchronization in a multi-bus controller area network system |
CN106603367A (en) * | 2017-02-28 | 2017-04-26 | 北京艾利特科技有限公司 | CAN bus communication method for time synchronization |
-
2019
- 2019-12-26 TW TW108147782A patent/TWI751466B/en active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO1998054872A1 (en) * | 1997-05-27 | 1998-12-03 | Micro Motion, Inc. | Deterministic serial bus communication system with 'controller area (can)' protocol |
US8504864B2 (en) * | 2010-12-01 | 2013-08-06 | GM Global Technology Operations LLC | Data sensor coordination using time synchronization in a multi-bus controller area network system |
CN106603367A (en) * | 2017-02-28 | 2017-04-26 | 北京艾利特科技有限公司 | CAN bus communication method for time synchronization |
Also Published As
Publication number | Publication date |
---|---|
TW202126089A (en) | 2021-07-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110213143B (en) | 1553B bus IP core and monitoring system | |
US6845416B1 (en) | System and method for interfacing a CAN device and a peripheral device | |
CN101937253B (en) | Method, device and system for clock synchronization | |
JP6469365B2 (en) | Method for providing general-purpose interface and microcontroller having general-purpose interface | |
JP6149150B2 (en) | Timestamp correction in skewed multilane communication links | |
AU2013204757A1 (en) | Synchronisation of a system of distributed computers | |
KR20140140508A (en) | Method for providing a generic interface and microcontroller with generic interface | |
KR20140140507A (en) | Method for providing a generic interface and microcontroller with generic interface | |
CN112448874A (en) | Vehicle-mounted communication device and time synchronization method thereof | |
TWI751466B (en) | Time synchronization method and time synchronization system | |
US8837473B2 (en) | Single timestamp engine for generating timing information for inclusion in packets complying with multiple networking protocols | |
CN103107862A (en) | Logic device and management data input/output (MDIO) data transmission method thereof | |
CN101300773A (en) | Data interface and method of seeking synchronization | |
US20180083800A1 (en) | Aggregation Device, System, And Method Thereof | |
CN111506461B (en) | Back pressure module based on bus and used for testing and implementation method thereof | |
JP2020527316A (en) | Time stamp unit and communication control unit for subscriber stations of communication networks | |
CN113132042A (en) | Time synchronization method and time synchronization system | |
JP2008512942A (en) | Low latency data packet reception and processing | |
CN114967559A (en) | Novel industrial communication bus controller | |
US7694176B2 (en) | Fault-tolerant computer and method of controlling same | |
CN113704045A (en) | Clock synchronization test method, system and chip | |
US12063287B1 (en) | Methods, systems, and computer readable media for determining an internal time of a time-sensitive networking (TSN) network card | |
US9081743B2 (en) | Communication system and communicaton method | |
CN111930582A (en) | System management bus detection platform, processor and system management bus detection method | |
US11990904B1 (en) | Field Programmable Gate Array system |