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.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

AnalogWaveform time infromation

Solved!
Go to solution

buffer.IsPrecisionTimingInitialized.Equals(true) - this is a bolean statement.

 

if(buffer.IsPrecisionTimingInitialized.Equals(true))

{

. . .

 

It is the same as

if (buffer.IsPrecisionTimingInitialized) 

{

. . .

}

0 Kudos
Message 11 of 14
(1,107 Views)

Gremlm, 

 

DAQmx stores a time in the waveform at the time that DAQmx Start Task was called.  That is the only time that DAQmx will ever set.  What you want is a timestamp for each time a trigger happened, correct? Unfortunately, an S-series board alone won't be able to do that automatically.  

 

What you need to do is a finite acquisition. Then, you'll need to generate your own timestamp as soon as your read completes and then subtract some time to account for the samples that were acquired. It might look something like this:

 

DateTime triggerTime = DateTime.Now.Subtract(TimeSpan.FromSeconds(numSamples / sampleRate));

 

Katie

 
Katie Collette
National Instruments
0 Kudos
Message 12 of 14
(1,079 Views)

According to the WaveformTiming.StartTime description, it 
        "Gets the time that the first sample in the waveform was acquired."

 

It is different than WaveformTiming.TimeStamp.

According the NI documentationWaveformTiming.TimeOffset  =  WaveformTiming.StartTime - WaveformTiming.TimeStamp 

i.e.. WaveformTiming.TimeOffset is a difference between acquisition time.

So, information about time of the first sample is available directly, right?

 

What I have seen, that for each acquired record in the continues mode, the  WaveformTiming.StartTime.Ticks are different foe each record!

Question:

  Should we use WaveformTiming.StartTime.Ticks directly for each record, or something like

       TimeSpan ts = DateTime.Now - WaveformTiming.StartTime;

0 Kudos
Message 13 of 14
(1,072 Views)
Solution
Accepted by topic author gremlm

Ouch. I was mistaken. Apparently we did things different in the .NET API than in LabVIEW.  For the LabVIEW waveform, the start time is always set to the time that DAQmx Start Task was called.

 

In .NET, however, we take a timestamp at the moment that the read completes, subtract the correct amount of time (sampleRate/numSamples) and call that the StartTime.  And so, for your application, you should use WaveformTiming.StartTime directly.

 

I would also recommend that you use a finite task instead of continous and that you set numSamples in two places: the last parameter in ConfigureSampleClock() and the first argument in BeginReadWaveform().

0 Kudos
Message 14 of 14
(1,058 Views)