Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Keeping time accross multiple boards

2013-03-20 by Chuck Hackett

In my application I have many (>20) ATMega1284p based controller boards
connected by a long (over 2,000') CAN data bus.

Up until now I have not needed to coordinate time across the boards but I am
now implementing logic where I need that ability.

I think my needs are served if I can coordinate the clocks to within a
second of each other.

I was thinking of having a controller (picked by an algorithm) periodically
(interval set by drift results I see in the field) send a time message which
all other controllers would (should) receive.

Upon receiving the time message the controller would compare it to its
internal clock.  If its time is less than the received time I would have it
send its time out on the bus.  If its time was greater than or equal to the
received time it would set its internal time equal to the received time and
send no time message on the bus.  This would continue until no more time
messages were sent.

In this way all controllers would have their clocks (re)set to match the
controller with the slowest clock.  Hopefully this reset would be kept to
sub-second adjustments, if not I would either decrease the adjustment
interval or go a different route ...

I realize that I will have to implement the sending of the bus time messages
to avoid as much latency as possible (avoid all queuing as much as possible
including the CAN controller transmit buffers and assign the highest
possible CAN bus message priority).

I used "slowest time" in an attempt to allow for the inevitable latency that
will occur in message sending (since any latency will tend to make the local
clock seem fast).

Does this sound reasonable?  Other approaches?

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.