09-22-2017 11:15 PM
HI Everyone
I am encountering an issue with long term syncronization of the DAQ and CAN signals.
Problem: On program start everything looks to be synchronized, after 20-40 minutes the signals from the CAN start the LAG the DAQ by 10ms after an hour or 2 its nearly 100ms off then continue to be around 2-300ms difference for days. Is it normal..
Below are some of the specifications of the program and system
System: Windows 7, CVI 2015 sp1, Xnet 17.0
PCI Xnet 8513 , Pcie 6563 x-series daq. RTSI cable connected.
Program normal running conditions (continuously reading 24-7) no stopping or re-stating: The DAQ and CAN synchronization was setup using the example from x-net and daqmx syncronization. CAN is read using the function ReadSignalWaveform, Timeout is set to be equal to One Read of the DAQ (if the DAQ is set to 500hz with 100 samples per read then the Timeout would be 200ms and the resample is 500Hz. DAQ is configured to readeveryNSamples. Both the DAQ and the CAN are on 2 completely different threads during runtime, and the data is transferred to another thread for processing (not using thread safe queue, maybe i should..). CAN read thread is also set to highest critical Thread 15, and their are close to 25 CAN signals coming in. Is this a Computer and Windows issue, are their any suggestions ?? My next alternative would be, to go wit nxReadSignal
Solved! Go to Solution.
09-26-2017 08:43 AM
Which example did you use?
09-26-2017 08:45 AM
synchronize PCI-CAN to DAQ-mx
09-27-2017 03:38 PM
"Problem: On program start everything looks to be synchronized, after 20-40 minutes the signals from the CAN start the LAG the DAQ by 10ms after an hour or 2 its nearly 100ms off then continue to be around 2-300ms difference for days."
What do you mean by the 2-300 ms range? Do you mean that it varies between lagging for 2 ms and 300 ms and is this random? Periodic?
09-28-2017 06:29 AM
The Lag or Latency time after days is 200-300ms. I installed 2 time stamps in the function which calls the nxReadSignalWaveform for a start and finish time to see if the entire function is actually finishing within the required period and it seems to have a random fluctuation of around 10ms very inconsistent.The only thing in the function call is the nxReadSignalWaveform I'm going to re-evaluate the function calls to have the function write to a TSQ and install timestamps to the CAN messages and the DAQ measurements. maybe even switch to nxReadSignalxy while i'm at it
09-29-2017 11:43 AM
If you are using PCI-CAN to DAQmx synchronization example, your data is hardware-synchronized. nxReadSignalWaveform reads data from the buffer, but that data is already synchronized (the data is taken according hardware timing, in this case, according to the DAQ start trigger and clock routed in via RTSI).
nxReadSignalWaveform
http://zone.ni.com/reference/en-XX/help/372841M-01/nixnet/nxreadsignalwaveform/
So, yes, this fluctuation is normal for nxReadSignalWaveform and you should not be benchmarking this function to determine whether the synchronization is good between CAN and your DAQ Reference Clock signal, since what this function does is pull already-synchronized data out of the buffer. Do you have concerns about how closely the data is synchronized? Does the data look unexpected? You are not losing data unless you get a buffer overflow error.
11-09-2017 10:27 AM
Solution to the problem:
Yes the hardware is synchronized as the above in AvatarAang mentioned. but the problem was the so called latency of the signals, which in actuality was the position of when the two routines DAQ read and CANwaveform read functions are called. So to solve the situation what i did was
1) Both functions were already in separate threads, but i had to remove any other functions that were not needed.
2) make more threads to seperate and process the read for CAN and DAQ and make thread queue callbacks
2) after the read of CAN and DAQ i got a time stamp of the read complete using a CVI read absolute time to get a time stamp
3) put the read data and the timestamp into thread safequeues with thread safe queuecallbacks for the seperate threads
4) read out the queues from the callbacks and take the time stamp and make an array of time stamps calculated by the sample rate and number of samples.
5) compare the time stamps of both arrays and do a CompareCVIAbsoluteTimesWithTolerance and find the point where the two timestamps fall within the same sample time.
6) cut or shift from the point