From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stamp GPS time alongside DAQ data

I'm trying to acquire data using DAQmx from a sensor.  The DAQ type is Analog to digital converter (NI-9229). The acquired data should be stamped with GPS time at the first sample. The used sampling frequency is 25K for acquiring 250000 samples. So, the needed time is 10 Seconds to acquire these samples.

My question is about how to ensure that the stamp is related to the first acquired sample. My suggestion in the following picture failed to do this task. The stamp arrived before the actual starting time of the DAQ.

Please, how can I solve this problem? 

 

NI_forum_Ques.PNG

 

0 Kudos
Message 1 of 15
(1,207 Views)

How precisely does this GPS timestamping of the first sample have to be? +/- 1 second?

 

If you need anything better than 1-second precision, you need the timestamping at the hardware level inside the instrument.

 

https://www.ni.com/en-us/support/documentation/supplemental/08/gps-synchronization-architecture-for-...

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 15
(1,203 Views)

Hi Emad,

 

side note:

Why do you use FromDDT to convert from an array of waveforms to a scalar waveform?

Why don't you use IndexArray to index an array element instead?

Why do you try to read 250k samples (at a sample rate of 25kS/s) at once? This will block your VI for exactly 10s - very bad UX…

 


@Emad_NRIAG wrote:

My suggestion in the following picture failed to do this task. The stamp arrived before the actual starting time of the DAQ.


You are reading a local variable in parallel to reading data from your DAQmx device. Why do you even think this would be synchronized in any way?

Where/how do you even read this GPS timestamp? You don't show this in your image!

Where/how do you try to sync the GPS reading with your DAQmx reading?

 

Keep in mind:

We cannot edit/debug/run images with LabVIEW. Most often it's just plain silly to attach just images of (parts of) code…

It also would help to use AutoCleanup before creating images of code!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 15
(1,158 Views)

Great Thanks, Mr. santo_13 for your cooperation. Probably, your suggestion is the best solution. However, the project deadline is too close and there is no time for purchasing  NI PXI-6683.

So, we need an urgent solution that somehow achieves an acceptable solution.

0 Kudos
Message 4 of 15
(1,137 Views)

Great Thanks, Mr.  for your notes. The answers to your questions are as follows:

 

1- I don't know the IndexArray method, this is a simple method. 

2- Indeed the VI is blocked at 10s. Did you mean that to make the number of reading samples << Sampling rate? 

3- I was reading a local variable in parallel to reading data from your DAQmx device. Was it better to read them in the same loop?

 

Regarding to, GPS time stamp, kindly, check the following link:

 

https://forums.ni.com/t5/Example-Code/GPS-gather/ta-p/3494576

 

I tried to illustrate my question briefly. Also, not all people have the used Hardware, and the project code is large to include in the same image even after using the AutoCleanup. 

 

All I need is to take feedback to correct and optimize the code. 

 

Best Regards

0 Kudos
Message 5 of 15
(1,122 Views)

I'm trying to acquire data using DAQmx from three channels sensor.  The DAQ type is Analog to digital converter (NI-9229). An external GPS from Ublox company is used to update system time every second. The acquired data should be stamped with GPS time at the first sample.

The used sampling frequency that suitable for the application is 25K for acquiring 25000 samples continuously.  So, the needed time is 10 Seconds to acquire these samples.

 

Regarding to, GPS time stamp, kindly, check the following link:

 

https://forums.ni.com/t5/Example-Code/GPS-gather/ta-p/3494576

 

My question is about how to ensure that the stamp is related to the first acquired sample. My suggestion in the following picture failed to do this task. The stamp arrived before the actual starting time of the DAQ.

Please, how can I solve this problem? 

 

NI_forum_Ques.PNG

0 Kudos
Message 6 of 15
(1,067 Views)

As LabVIEW is dataflow, you will have to use the function to get the GPS time in the same loop as your acquisition to "sync" GPS time and first acquired sample.

If the function giving you the GPS time is in a FGV that is updated several times per second, there is a possibility to use a "get" from this FGV to have the same information even if generated somewhere else.

0 Kudos
Message 7 of 15
(1,035 Views)

@Emad_NRIAG wrote:

...An external GPS from Ublox company is used to update system time every second. 

I haven't worked with GPS timestamping, but if the sentence above means what it *sounds* like it means, you might have almost nothing to do.  When you say "system time", do you mean the PC's time-of-day clock?  That's what I'd consider the normal meaning of "system time."

 

If so, then just retain the original t0 from your DAQmx waveform read.  DAQmx queries system time on your first read and calculates t0 based on time-right-now, the task's sample interval dt, and the # samples retrieved.  And if some other process is keeping "system time" sync'ed to GPS time, you can just accept the t0 from DAQmx.   I'd expect you to be sync'ed to GPS time to within somewhere in the sub-millisec realm.

 

To do any better than that, you'd probably need to make use of GPS pulse signals to drive hardware-level sync, likely using them to trigger your AI task.

 

Your *immediate* problems in the code you posted are several-fold.  There's no dataflow to enforce the sequence of when DAQmx Read is called vs. when "GPS Time" is queried.  And if "GPS Time" is only updated once a second somewhere else, that's *entirely* independent of when you happen to query the latest value.  It could be stale by literally anywhere from 0-1  seconds, with no relation to when your first sample was taken.

    Not being familiar with your (or really any) GPS setup, I can't really give more detailed suggestions.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 15
(1,018 Views)

Thank you for your cooperation. As I understand from your comment that it's better to integrate the DAQ and GPS in the same loop, isn't it ?

What's the abbreviation of FGV ?

0 Kudos
Message 9 of 15
(1,004 Views)

Great Thanks, Mr. Kevin for your fruitful discussion. Actually, the system time is the PC time as you mentioned. I'll take your comments into consideration. I'll modify the code and attach it soon for any modifications.

 

0 Kudos
Message 10 of 15
(1,000 Views)