How to synchronize many arduinos - shared clock

Hi ,
I need to synchronise many arduinos so that they share the same clock.
What can you suggest as a solution to do that ?

  • Connect them to an extern clock maybe ?
  • Is there a soft solution?

I have really no idea on how this can be done.

You could connect one of them with a reliable clock (ethernet/gps/RTC) and have it send the time to the other arduino's. There are several ways, wireless/wired, you could send the time.
By sending the data periodically one needs a reliable clock and the rest could be synchronized.

Question may be how accurate the clocks need to be and how you want to communicate.

I don't think this would work for me. I will have 4 arduinos. I need them to start a given behavior (let's say : execute a function) at the same time. For example, in the loop function I'll tell each of them to run the function MyFunction() when time = 2 s.
The problem is that each arduino has its own clock so I can't make them start in the same instant. time = 2s for the first arduino is different from time = 2s for the others etc.
Any time lag would cause trouble even few nanoseconds.

Any time lag would cause trouble even few nanoseconds.

No chance. Take a step back where did the need to sync the processors this closely come from. What is it your realy trying to do.

Mark

I need that precision because my arduinos will be reading data and sending it at high frequencies. Arduinos should start transmitting data at the same time otherwise it will make no sense for the device which will collect it.
Suppose that we send temperature at the pair iterations and pressure at the odd iterations. The device to which arduinos will send these values shouldn't be receiving at t time the temprature related to T = 3s and the pressure related to T= 5s. I don't know if that seems clear.

Think about the problem from first principles.

Assume one device is the master and has the time. How long will it take it to transmit the time? What time will it be when the time has been received and saved?

Do you really need separate Arduinos or could one of them do everything?

Would it be possible to run several Arduinos from a single crystal oscillator? Then maybe you could have a common reset button to get them to start their internal counters at the same time?

If you explain the totality of your project you might get some useful advice.

...R

ilaam:
I need to synchronise many arduinos

How many Arduinos, how closely do they need to be synchronised, and what connectivity do you have between them?

Could you have the master send an interrupt pulse to the slaves that would then kickoff the funtion needed? All would perform it within 4-8uS of each other. Is that close enough?

The other way of course is to have the slaves send the readings and the master add a time stamp when they are received. Interpolation (just point the dots) can be used for every thing else.

Mark

Probably the most accurate time base you can provide remote Arduinos is using the pulse per second (PPS) option on GPS receivers assuming you have receivers at each Arduino, it is used to re-zero the clock, but the Arduino crystal is still the timer. Trying to provide resolution of 10-9 sec with a clock that has a crystal with a period of 6.25 x 10-8 sec. is not going to work.

How is the device going to ingest the data from the four Arduinos at the same time without some buffering? Do you have 4 receivers or does the receiver have a baud rate fast enough to collect 4 messages inside of a couple nanoseconds.

I think you need to explain in detail what you are trying to do and then the incredible body of experience here may be able to help, all we can do without detail is tell you why it won't work not how you achieve your desired result.

My understanding of the op was that the nanosecnd accuracy is required between edges (jitter ?) across the 4 devices ,actual frequency not being the problem.

Well, nanosecond accuracy isn't possible unless all have their fuses re-burned to run from same external clock source, and then all sit in setup ( ) waiting for a start signal to ensure the code is all doing the same thing at the same time.

Yes, im not sure even then though if the accuracy he requires is achievable.
Im thinking that differences between chips could be sufficient to cause too much phase delay.

I think we need a new feature for the Forum in which there can be no more than (say) 4 replies before the OP responds.

...R

IEEE 1588
Overview of issues attached

2008_Clock.pdf (321 KB)

mrburnette:
IEEE 1588
Overview of issues attached

Thanks Ray, I've taken a copy.

...R

So the problem is that the master and its slaves may have different times due to latency? This would mean that the master is performing the same task as its slaves. Why not just have a separate master that only acts as a clock and outputs to the other Arduinos at the exact same time? I mean you could just have a simple digitalout wire and then attach a lead from each slave to it thus each get the signal at the same time. I think. I'm really new to this stuff but that seems like an easier way of doing things if it would actually work lol.

@andrewt, that sounds like an interesting idea. The synchronizing signal could be generated with a 555 timer chip or something else much simpler than a whole Arduino.

How do you envisage the slaves using the signal to synchronize themselves. I can imagine the sync pulse causing an interrupt simultaneously in each of the slaves. But what then?

...R