I'm making a posture control experiment in which a series of images (stimuli) are presented to a person and I'm trying to measure the displacement of this person as a result of these stimuli. To do so I'm planning to use 3 Arduinos:

1) "Arduino Tx 1": an Arduino nano with an Xbee shield and an MPU unit attached for sensing displacement. This implementation has to be wireless because the subject must be able to move freely.

2) "Arduino Tx 2": an arduino uno for reading an analog signal that indicates when an image (stimulus) is presented to the person

3) "Arduino Rx": an arduino uno connected to a computer and reading data from both "Arduino Tx 1" and "Arduino Tx 2"

I want to make sure that signals coming from "Arduino Tx 1" and "Arduino Tx 2" are synchronised. That is: if an image is presented at t=t0 (signal sensed by "Arduino Tx 2") then I want to be able to tell that the displacement sensed by "Arduino Tx 1" at t=t0+dt corresponds to this stimulus.

My question is: is it possible to ensure that signals coming from "Arduino Tx 1" and "Arduino Tx 2" are synchronised when read by "Arduino Rx"?

  • What do you mean "are synchronized"? If you get signals that arrive at the same moment, that would be synchronized wouldn't it? – Nick Gammon Mar 6 '16 at 4:47
  • 1
    What level of accuracy are we talking about? What is the reaction time? 1-10 ms would imply with 1% error 10-100 us. I would suggest broadcasting a start message, measuring and then fetching the results. – Mikael Patel Mar 6 '16 at 15:41
  • Why is the image indication analog? You should get a digital pulse (with interrupt) to time when the picture is shown. And you can then, from that point measure the displacement. – Paul Mar 10 '16 at 17:39
  • Even though one is wireless and hence will be using a battery: can't the Arduinos simply send continuously? – Arjan Mar 10 '16 at 17:52

Have TX2 also emit an infrared pulse that initiates the timing reported by TX1. TX1 should report dt rather than t_tx1.

The common real-time clocks for for Arduino report at 1 second resolution, which does not sound as if it is accurate enough for your needs.

| improve this answer | |
  • Most RTC devices also have a 32,768kHz output which should be more than precise enough. – CharlieHanson Mar 6 '16 at 20:36

IMHO the delays are negligible if you are detecting times in the range of milliseconds. Just give us some more info (e.g. what is the maximum error you can tolerate).

In any case you can implement a round-trip-time estimator. For instance

  • RX sends a packet (or even just a single byte) to one TX to set it in "RTT measuring mode".
  • TX reads the packet and sends an ack. This is required for avoiding errors when the TX is busy doing something else.
  • When the ACK is received, the RX sends a message and starts measuring the time.
  • When TX receives the message, immediately sends back a reply
  • When RX receives the reply, stops the timer. The communication delay is half the time measured

Just repeat this procedure for both TX1 and TX2; this way you will have an estimate on how long it takes to receive a message from each of them. Then, when you receive a packet, you know how much time passed since it was transmitted (and so you can synchronize them)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.