Go Down

Topic: Accurate timing synchronization between two arduinos (Read 530 times) previous topic - next topic

mjbailey2012

Hello, this is my first time posting on the forum as I generally find solutions to my problems with a bit of research or trial and error.

My current project is the design of a laser 'tripwire' with a gateway design to accurately measure the time lapsed between a starting and finishing point. I have built two gateways, one start and one finish, with laser dot diodes and photoresistors to create a trigger when breached.

My original plan was to find a wireless method, which I attempted with a Bluetooth module, but timing restrictions required me to design a wired backup which relies on only one Arduino. To achieve wireless communication with accurate timekeeping, I have two issues that I cannot seem to solve: synchronizing timing between two separate Arduino modules, most likely nanos, and finding a wireless method that maintains an error range beneath one second.

I no longer have any timing restrictions on my project as I do have a working wired model, but I do not enjoy wasting wire and solder when a $0.30 solution might be available.

Any help would be sincerely appreciated. :)

wvmarle

So you need to keep the time error less than a second?
That's easy. Just about any wireless method will be able to send a "start" (or "stop", for that matter) signal to the other side, tell it to start counting the time. Shouldn't take more than 100 ms, probably less than 10 ms.
Depending on the kind of dollars you use, I think it will be a bit more than $0.3 for a wireless solution. Actually I cant think of any flavour of $ that can do this for that low a number.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

jremington

The cost criterion suggests a mass-produced commercial product, in which case you will probably be negotiating with an Asian supplier.

The Arduino forum is not the place to look.

alesam

You can use NRF24 module. https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial/

What is a distance between gateways?

6v6gt

I guess you need a counter (equivalent to say millis()) running on both systems, and by exchanging messages between themselves, both systems maintain the same value of this counter (within tolerance) at any instant. Then the "start" system can inform the "stop" system of a "start event" and the timing of the transmission is non-critical.

1 second tolerance does not sound too ambitious, but radio modules may introduce unpredictable latency (multiple retries in poor signal conditions etc.). The problem is similar to that of the network time protocol maintaining accurate time across unpredictable networks.

The Arduino Nano (depending on the clone) may have only a resonator which is not particularly accurate.

MarkT

The simplest protocol is to send a packet to the remote station, which places its value of micros() in the
reply packet.

You record your values of micros() before sending packet and after receiving reply packet and average them.

The discrepancy between your average timestamp and the remote's timestamp indicates the clock skew
between them (assuming packet transmission behaves the same in both directions).  Any automatic
retry mechanism must be disabled for this to work.  The packet and its reply must be the same size.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

wildbill

#6
Jan 18, 2019, 02:02 pm Last Edit: Jan 18, 2019, 02:02 pm by wildbill
Hardly a cheap solution but a GPS module for each gate should allow you to be synchronized.

Go Up