Hi All, So I've two sensors (One analog and the other one digital) need to collect data at the same time. For this, I'm thinking of using two arduinos. My problem is how do I sync the data collection between the two arduinos so that the time stamps of the collected data align well.
I've been thinking about an external clock for both of the Arduino, RTC or using the clock signal of one of the Arduino and inputting it as an external clock to the other one. I've not been able to find a good solution if anyone can give me some direction that would be helpful.
You could direct port read and mask the digital pin in about 2 cycles, the analog read takes 1680. Is that not close enough to same time? The ADC can run quicker, the Nick Gammon blog on ADC's explores changing the speed vs output accuracy.
To read digital then ADC, do minimal if any processing and record that with a stamp on SD, if you keep it down to 1 or 2 reads per millisecond just be aware that sometimes SD holds things up and at 1 report a milli, you can be recording 40KB/s easily.
If you have a USB or Ethernet or Wifi channel, you might manage 8 read pairs a milli.
I've done data log work before. The best thing is to never "fix the clock". Time stamp every line at the start in 8 hex chars, it keeps the lines even. Get RTC data and print that with the controller clock time stamp at the start of that line too. Every RTC line provides a synch to the controller as close as you could make it. Do your math right and you can show what any clock would tell for any line within reasonable timing. Consider that serial data does not happen in an instant, work your tolerances out from there.