LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time Synchronization Between Multiple Sensors

Solved!
Go to solution

I am working with a VI right now that is trying to read from multiple sensors (a force sensor via Arduino and a position/motor sensor, both serial) of varying sample frequencies and plot this sensor data all on the same time axis. The problem I am having is synchronizing all the sensors so that they acquire a sample at the exact same time. Currently, I have parallel while loops running where each while loop is reading from a single sensor. I have added a time stamp VI in each loop at the moment the data is recorded and then export all the sensor data to an excel sheet once the code is finished and plot the data with the time stamp as the X-axis. I notice that there is a slight delay (~10ms) in the force being recording versus the position being recorded (mm).

 

I am looking to investigate the best ways to synchronize these two sensors so that they record data at the exact same moment. Using the DAQ devices is not possible for my application. Is there a way to do this or has this been done? From reading the forums, it seems that syncing the data to a an external sample clock as reference might work, but I haven't the slightest clue where to start. Any information for time synchronization in data acquisition in Labveiw would be greatly appreciated, thank you.

 

I will post an example of VI shortly as well.

0 Kudos
Message 1 of 5
(7,305 Views)
Solution
Accepted by Vaevin

Good news and bad news.

 

The good news is you don't need to spend a lot of time pursuing exact time sync of sensor data acquired over different serial connections, with at least one Arduino in between.  The bad news is the reason why: you ain't gonna get there that way.  Trying to sync sample timed using distinct serial streams is not generally feasible -- it's like trying to cross the ocean using only a bicycle.

 

Right now you're time-stamping upon *receipt* of data.  As you've seen, this doesn't account for the unknown amount of time between sampling and receipt.  Baud rate usually only accounts for a small part of it -- there's more built into the micro that's sampling and transmitting the serial data.  That part of the latency frequently isn't well-defined or consistent.

 

If you need to sync samples, you should use a DAQ device.  If you must use your present serial communication setup, you shouldn't expect perfect sync.   That's just how it is.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 5
(7,288 Views)

Thank you for the very clear response. So it seems it is not possible to get an accurate time sync between multiple serial communication sensors.

 

Would a NI Serial Interface Device, such as the USB-485, work for my application (connecting multiple serial communications and syncing them via the USB-485)? Not sure if this device can accomplish time synchronization.

 

I have used DAQs before but I have never used a DAQ to read a serial communication output, such as from Arduino (Rx to Tx), and am not even sure if this is possible actually.

 

I do have a NI cRIO-9025 real-time controller, but am not sure if this can be used to synchronize between serial outputs. Perhaps I need to directly read the sensor output (analog) from the force sensor and position encoder to a DAQ device? 

 

For more clarity, the sensors I am sampling are:

 - Force Sensor 0-5N : Honeywell FSG005WNPB https://sensing.honeywell.com/fsg005wnpb-force-sensors2

- Maxon Motor via EPOS 24/2 controller with an Encoder MR, Type S, 100 CPT, 2 Channels. https://www.maxonmotorusa.com/maxon/view/product/sensor/encoder/Magnetische-Encoder/ENCODERMR/ENCODE...

- IMU 9 DOF Sensor - Adafruit IMU Fusion Breakout - BNO055: https://www.adafruit.com/product/2472

 

I appreciate any info / input / guidance on this matter, thank you.

0 Kudos
Message 3 of 5
(7,261 Views)

While I'm quite sure serial communication won't be a good way to establish sensor sync, I'm not sure I can give definitive advice on what *is* the best way to sync those particular sensors.  They have pretty distinct interface requirements that aren't supported by NI's more common DAQ boards that I'm most familiar with.

 

Force sensor - specified in V/V/N, implying the need for a bridge circuit interface

Encoder - specified with a line driver, implying differential digital output

9-DOF sensor - specified as an I2C interface. Specs refer to Arduino support.  Soldering required.

 

I'm assuming at this point that you're reasonably comfortable with the Arduino (unlike me).  If so, I'd start there.  The 9-DOF sensor is *expected* to be used with Arduinos.  Then I'd work on how to bring the other sensor signals into the same Arduino.  You may need some additional interface circuitry in between.  The point is that all the signals arrive first at the Arduino which can take charge of sampling them in sync.  Once that's done, you can *then* transmit the combo of sample timestamp and sensor data together over serial to your collection & logging PC.

 

It's likely you could outfit the cRIO with modules to interface with the force sensor and encoder, but I'm not so confident about the 9-DOF sensor.   Cost would likely be very much higher, but the quality would be higher too.  

 

Actually, before you get too far with things, do you *have* to use those exact sensors?  There's a big wide world of sensors out there, and there's likely a trio you could put together that'd be *much* much more straightforward to sync and capture.  You could save an awful lot of time and troubleshooting by selecting things that are more compatible.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 4 of 5
(7,250 Views)

I suppose I do not HAVE to use those particular sensors; I am partial to whatever will be the easiest way to interface all of them together for time sync. I guess my next steps will be to look at possible sensors that can be easily time synced and interfaced with Labview, especially.

 

If you have any more thoughts on this matter, I'd love to hear them; I'm always looking to improve my Labview skill. Thank you for the info, you've given me a lot to consider! 

0 Kudos
Message 5 of 5
(7,244 Views)