I have 2 devices with analog signals. I want to acquire their signal with 2 MCU's (preferably ARM). fully synchronized with the same sampling frequencies, starting and ending simultaneously user controlled (for example by pressing a button). I know that if I could connect them together via wires, I could use oscillator and triggers for this. But is there any way to do this over WiFi? Thanks
Synchronizing end points over a channel like WiFi requires some setup and a reference to a time signal to both devices. One way to envision this is:
- Both devices have access to a GPS service to get time information from the GPS network.
- Both devices synchronize their local RTCs to the GPS time. The RTC resolution needs to be as good as the maximum latency between ADC triggers in the devices.
- The first device sends a test packet to the second device that contains the first device RTC time stamp.
- Second device receives this timestamp and comparing it to its local RTC it knows how long the message transmission takes between devices.
- Second device acknowledges the test message and sends back the latency time back to first device.
- These steps to calibrate may need to be run multiple times to ensure consistent results or re-run periodically do to changing conditions.
- First device becomes the master trigger source. It send a trigger message to the second device with the same packet size as the previous test messages. Second device triggers its ADC upon receipt of the message.
- First device delays its ADC trigger by the amount of the message latency sent over from the second device during the calibration process.
Note that you will never get triggers at "exactly the same time" using a communications channel for the trigger sync but you can get as close as you can based upon your RTC resolutions and the packet handling variations on each end due to MCU instruction sync and possibly even other interrupt interference on each end.
Not an easy task. You can look for Ethercat master/slave device Ethercat.org. Ethercat uses a distributed clock for synchronising data. Similarly there is a Profinet, also an industrial protocol over ethernet, but it proprietary while the Ethercat is open source.
They are both used in industrial control, where synchronism is important, CNC machines, servo drives,... As far I know, there is no such hardware that supports synchronism through WiFi. Perhaps you could dig into Ethercat and find how these clocks are actually synchronised and implement something for your needs.