Re: Time sync in CAN

Shreyas Ravishankar <[email protected]> Thu, 22 Oct 2015 15:42:07 +0200
Newsgroups gmane.comp.hardware.bus.can
Message-ID <CAOci+M2veMp++UX-Fwwwpv-qPxa7iEGu9jjmg6BEogY7Aq8RPg@mail.gmail.com>
Hello,
Thanks for the quick reply. If I use the first method, can you tell me how
I can set timestamps for sent and received CAN mesaages. I am using
Socketcan now. Kindly let me know.
On Oct 22, 2015 3:12 PM, "Stephen Glow" <[email protected]>
wrote:

> Hi Shreyas;
>
> Depending on how accurate the time synchronization needs to be, I can
> think of two possible implementations:
>
> - The simplest would be for the time master to send out a CAN message
> periodically containing it's current time.  All receiving devices use this
> data to update their clocks.  There will be some error here, because the
> master can't know exactly when it's message will be sent out when it loads
> it's time into the message, so the time the slaves receive will always be
> off by a small and variable amount.  This is probably good enough if you
> only need millisecond accuracy.
>
> - A slightly more complex method would give higher accuracy.  Periodically
> the master sends out some sort of sync message.  This doesn't need to
> contain any data, just an ID that devices can identify.  All receiving
> devices take a local time stamp of when they received the sync message, and
> the master keeps a time stamp of when it's sync message actually made it
> onto the bus.  After the sync, the master broadcasts it's time when the
> sync message actually got onto the bus.  This corresponds to the time the
> slaves received it, so they can adjust their clocks accordingly.
>
> If you can capture the time a message is sent/received in hardware, then
> this should be very accurate.  If you have to capture it in software (i.e.
> in an ISR), then the accuracy will depending on interrupt latency/jitter.
> Still should be pretty accurate for most systems.
>
> The latter method is used by the CANopen protocol and works quite well in
> my experience.
>
> Rgds,
> Steve
>
> On 10/22/2015 08:54 AM, Shreyas Ravishankar wrote:
>
> I am trying to implement a quality of service policy such that old data is
> not forwarded to the application that is to set a life span. All the ECU's
> in the network which are providers or consumers are connected via CAN and
> all have to be synchronized to some master clock because there is a
> Publish/Subscribe pattern in the communication protocol. So all data sent
> and received should have timestamps and then after the time sync mechanism,
> I can compare current time with the timestamps and drop data when specified
> lifespan expires. Hope you understood. I saw a mechanism which sends SYNC
> and FollowUp messgaes to provide time sync but I need an implementation.
> Kindly let me know.
> On Oct 22, 2015 14:41, "heikki saha" <[email protected]> wrote:
>
>> Hello,
>>
>> Please refine, what do you mean with "time sync"?
>>
>> Best regards,
>>
>> -H
>>
>> Heikki Saha, CTO
>>   M.Sc. Automation
>>   Dr.Tech. Electronics
>> TK Engineering Oy
>> Mail address:  P.O. box 810, FIN-65101 VAASA
>> Visit address: Yrittäjänkatu 17, FIN-65380 VAASA
>> +358 (0)50 588 6894
>> [email protected]
>> http://www.tke.fi/
>> http://www.canopen.fi/
>>
>> ----- Original Message -----
>> From: "Shreyas Ravishankar" <[email protected]>
>> To: [email protected]
>> Sent: Thursday, October 22, 2015 3:07:02 PM
>> Subject: [CANLIST] Time sync in CAN
>>
>>
>>
>> Hello,
>>
>> I am trying to implement time sync in CAN. Can anyone help me with the
>> implementation?
>> --
>> Archives and useful links: http://groups.yahoo.com/group/CANbus
>> Subscribe and unsubscribe at www.vector.com/canlist/
>> Report any problems to <[email protected]>
>>
>
>