LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Playing back a waveform

Solved!
Go to solution

Continuing... I found that if I add Waveform Duration and waveform "Final Time" I get closer to real time playback.

 

But 2 minutes of waveform capture plays back in 1:55

 

I don't understand why real time playback is so difficult. I must be going about it completely wrong?

 

playback2.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 11 of 44
(1,384 Views)

Sounds like your file I/O is slow.

 

Consider using a producer consumer with a fixed size queue between them.

 

Let the Producer spin as fast as it can and wait when the queue us full.

In the consumer pull the records from the queue one at a time (like you are trying to do in your attached image) and pace the chart updates on the duration.

 

Quoting an old associate:

 "Queues are almost always nearly full or nearly empty."

 

Using the above approach your queue should always be almost empty until you run out of data.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 12 of 44
(1,381 Views)

@RTSLVU wrote:

Continuing... I found that if I add Waveform Duration and waveform "Final Time" I get closer to real time playback.

 

But 2 minutes of waveform capture plays back in 1:55

 

I don't understand why real time playback is so difficult. I must be going about it completely wrong?

 

playback2.png


File I/O requires the OS to get the data from disk, and sooner or latter your process going into a resource wait state between when you ask for the data and it shows up. There is also going to be seek latency as the disk gathers the data from the scattered sectors on the disk. When writing using TDMS, the data does not go directly to the disk but rather into a memory buffer that is when possible written to disk.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 13 of 44
(1,378 Views)

Do you have a small # samples per waveform record, like maybe around 5?

 

In addition to Ben's suggestion to use a queue to separate file access from gui updates & timing control, I'm wondering if your use of the "waveform duration" function might be leading you to an off-by-1 problem.

 

By default, the duration function gives you an "open interval" time rather than a "closed interval" time.  When you have N samples in a waveform record, an "open interval" will return (N-1)*dt while a "closed interval" will return N*dt.

 

Your original attempt ran in 4/5 of the expected time, which is exactly what you might expect with 5 samples per waveform record while using the "open interval" version of duration.  You should plot the first N samples then wait for N samples worth of time by specifying a "closed interval".

 

Note: adding duration to "final time" should not be meaningful nor should it be pursued.

 

 

-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 14 of 44
(1,362 Views)

If you take a look at the "get waveform components" you will see it returns T0 (start time), delta T (time delay between points), attributes and Y array.

When playing back the T0 and attributes are unimportant, but you want to output each element from the Y array, delaying by delta T each time.

 

0xDEAD

0 Kudos
Message 15 of 44
(1,360 Views)

@deceased wrote:

If you take a look at the "get waveform components" you will see it returns T0 (start time), delta T (time delay between points), attributes and Y array.

When playing back the T0 and attributes are unimportant, but you want to output each element from the Y array, delaying by delta T each time.

 

0xDEAD


That didn't seem to work 2 minutes of waveform capture played back in 10 seconds.

 

Waveform playback from a file is too fast is the issue I am having

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 16 of 44
(1,329 Views)

@Kevin_Price wrote:

Do you have a small # samples per waveform record, like maybe around 5?

 

In addition to Ben's suggestion to use a queue to separate file access from gui updates & timing control, I'm wondering if your use of the "waveform duration" function might be leading you to an off-by-1 problem.

 

By default, the duration function gives you an "open interval" time rather than a "closed interval" time.  When you have N samples in a waveform record, an "open interval" will return (N-1)*dt while a "closed interval" will return N*dt.

 

Your original attempt ran in 4/5 of the expected time, which is exactly what you might expect with 5 samples per waveform record while using the "open interval" version of duration.  You should plot the first N samples then wait for N samples worth of time by specifying a "closed interval".

 

Note: adding duration to "final time" should not be meaningful nor should it be pursued.

 

 

-Kevin P


The waveform are being captured using  NI-Scope and a NI USB-5132. 

 

The most common scope setting is:

  1. 200K samples/sec 
  2. 10mS/Div
  3. Min Record Length = Tdiv*Sample rate*10 (#Divisions)

 

I am basically dumping every sweep into a queue then saving to waveform file. 

 

So I obviously do not understand understand the file format. Because shouldn't there be a "record" for each "sweep"? There does not seem to be nearly enough records. 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 17 of 44
(1,325 Views)

Is your "duration" indicator showing values that you would expect?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 18 of 44
(1,317 Views)

@Ben wrote:

Is your "duration" indicator showing values that you would expect?

 

Ben


What duration indicator? 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 19 of 44
(1,315 Views)

@RTSLVU wrote:

@Ben wrote:

Is your "duration" indicator showing values that you would expect?

 

Ben


What duration indicator? 


The one on your front panel that is controls the wait.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 20 of 44
(1,311 Views)