Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with DAQmx Write and timed loop: Cycle Time depending on size of playback file

Dear all,

 

I am having an issue with the attached VI regarding the cycle time of the timed loop. Purpose of the VI is to "playback" csv files (values in 1 column, sampling rate 500Hz) and to create an analogue voltage signal between -9,9V and 9,9V from the csv files. Acc. to the constant sampling rate of the csv files the "dt" of the 1kHz timed loop is "2" which is supposed to yield 500Hz loop frequency.

 

The issue is that the cycle time of the timed loop seems to depend on the size of the playback file:

 

  • With relatively short files (60000 rows => 120 secs) the loop runs faster than "real time" (120 file seconds played in 71 real seconds => 1,685 times too fast).
  • With relatively large files (1574000 rows => 3148 secs) the loop runs slower than "real time" (3148 file seconds played in 5036 real seconds => 0,625 times too slow).
  • A file with 1009000 rows => 2018 secs almost runs in "real time". 

 

There seems to be a linear correlation between what I call "playback factor" PF (e.g. 0,625 or 1,685) and Filelenght FL which is like: 

PF = -0,00035*FL + 1,73

 

The positive thing about that is: Since small files run faster than real time it doesn't look like a hardware limitation (e.g. caused by desktop DAQ via USB) which is described in other posts here. Playback with a sampling rate of 500Hz seems to  be achievable with the hardware used.

 

When I remove only the "DAQmx Write" from the schematic the playback always is correct (500Hz, neither too fast nor to slow) and independent from filelength.

 

What can be the reason for that undesired feedback of filelength to cycle time? Any idea is highly appreciated.

 

Thanks in advance.

Christoph

 

 

NI-cDAQ-9172 with NI9263 (1 AO used)

LabView 2017

 

Zeiserich_0-1596008024117.png

 

0 Kudos
Message 1 of 9
(1,630 Views)

You should be trying to use a hardware sample clock when you want precise output timing.  Here's a minimum working example (MWE) to show how you can replay column 0 of the data in your file at 500 Hz.

 

 

-Kevin P

 

MWE DataPlayer - modKP.png

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 2 of 9
(1,586 Views)

Dear Kevin, thank you very much, your VI works almost perfectly. I had to add a "-1" to the "DAQmx Wait until done" because I received an error 200560 for each of my playback files regardless of their lenght.

Zeiserich_0-1596185854402.png

 

The only drawback with the VI is that without the loop (timed loop or any other) I seem to have no chance to observe my playback data online e.g. using a waveform chart. The files are of 1 minute to 45 minutes playback duration (@500Hz sampling rate). Do you see any possibility to add such a feature as I used it in my original VI? I would really like to be able to monitor the signal like in an oscilloscope.

 

0 Kudos
Message 3 of 9
(1,558 Views)

Here's a head start.  Each iteration of the loop sends an appropriate subset of data to a chart based on acquisition progress so far.  You may want to display a different amount of the chart history or maybe even change from chart to graph -- this is just a starting point to show how to get your display to stay sync'ed up with the hardware signal being generated.

 

 

-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 4 of 9
(1,551 Views)

Dear Kevin. Thanks again for your help. Could you please post the VI again using version 2017?

0 Kudos
Message 5 of 9
(1,531 Views)

Sure, here it is.  It's actually saved back to 2016  so that I could verify that it saved correctly.  I made a small mod to get rid of the not-yet-available-in-2016 "Stall Data Flow" function.

 

 

-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 6 of 9
(1,525 Views)

Maybe I'm doing something wrong, but I keep receiving this errror message.

Zeiserich_0-1596434798828.png

 

0 Kudos
Message 7 of 9
(1,513 Views)

Must be my mistake.  I've got both and it looks like I attached the wrong one.

 

 

-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 9
(1,501 Views)

Thank you very much. It works perfectly!! I will now try to add some comfort features like resetting the playback to the start, open a different file during a running playback and adding the possibility to deliver constant values to the output channel (for calibration), and I am curious if I'll manage that myself. Kind regards!

0 Kudos
Message 9 of 9
(1,481 Views)