Hello guys. I have a problem with time synchronization.
Situation
My goal is to get data transfer time between 2 Arduino Uno.
For this, I used time stamp method just like picture below;
Problem
I used the code that master send "K" and slave send ASCII code of count.
My code was running very well, but the time (I used micros() function) between master and slave was not synchronize.
// Master Result //
16:27:23.512 -> Master sent at: 3946640
16:27:23.543 -> Received data: :
16:27:23.543 -> Master received at: 3946656
16:27:23.579 -> Total time: 16
// Slave Result //
16:27:23.511 -> Slave received at: 3301460
16:27:23.544 -> Slave sent at: 3301464
Question
So, is there any solution for synchronize hardware clock between 2 Arudino Uno?
Especially, using only software not additional devices (etc. GPS, RTC, NTP).
What do you mean about "pass the time"?
You mean transfer time stamp with data?
I was trying to use SPI between Nvidia Jetson Nano & Arduino, but I don't have any level shifters.
So before this, I was using 2 Arduinos check SPI communication.
My final goal is to transfer float type data from Arduino to Jetson Nano using SPI under 10ms. So I asked the solution for software not additional hardware.
You are transmitting data to Slave over SPI Port and you should expect the response from the Slave over the same SPI Port. You may study the following diagram (Fig-1) to implement the SPI's back-to-back communication.
what do you call the "hardware clock" ? There is a timer that counts the time since the arduino booted up, so if they were not started at the exact same microsecond you can expect the count won't match
Does it matter to have such synchronisation? Not sure I understand the use case.
I can use "Round-trip time (RTT)" method to check the data transfer time between devices.
But, RTT is not very exact if the network is asymmetric...
So I have to check using time stamp if RTT is exact or not.
but what are you using this for? why do you need the "data transfer time between devices"?
(the SPI exchange happens through an interrupt and millis() will be blocked and micros() can be wrong if the timer rolls over as the associated iSR won't be called)
I'm not that familiar with SPI but did you do the theoretical calculation? Let's say that you transfer a float (4 bytes) at 100kBits/second. That will take 32/100000 = 320 microseconds; there might be a bit of overhead but it's far from your 5-10 milliseconds.
Well, I'm actually planning about sending 30 float type data in a list from arduino & receive it with list in Jetson Nano.
So I tried UART to USB connection before which takes about 10ms with round-trip time.
But I need to stack that data list about 50, so I need to check the fastest way to communicate.
The result was SPI which is about 2Mbps (max) while using level shifter and Analog kit for Jetson Nano use SPI.