LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx acq to queue, queue grows too fast

Solved!
Go to solution

Hi, 

 

I'm trying to save DAQmx acquired data to a queue to log to file in another loop. 

However the number of elements in the queue grows like 10k elements/second even if I set the sampling rate to 10s/second. 

The Waveform Graph updates at the acquisition rate just fine. 

 

I attached a simplified version of just the acquisition to queue part. 

For info I'm using a simulated PCI-6224 DAQ to test this. 

 

There must be just a little thing I'm missing. 

 

Thank you, 

0 Kudos
Message 1 of 13
(2,986 Views)

You left out the most important part, the dequeuing.  What are you doing with the data when you dequeue it?

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 13
(2,972 Views)

I'm writing it to a file. Left that out to simplify. 

But my problem is the queue is growing too fast vs my acquisition rate. 

0 Kudos
Message 3 of 13
(2,969 Views)

You do not have anything limiting how fast the queue is being updated.

 

Put a 100 ms wait in that loop and it should only push 10 queue elements a second.

 

Ben

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

Yeah, after I clicked Post, I realized the point of your question.  I misread it. 

You're dealing with simulated devices and I'm willing to bet that is the source of this. Do a search for Simulated devices and learn how they behave. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 5 of 13
(2,961 Views)

Hi ben,

 

I can't put a wait in the program this is from. 

Isn't the queue supposed to update just when the DAQmx read sends it data? 

Which would be based on the acquisition rate?  

0 Kudos
Message 6 of 13
(2,959 Views)
Solution
Accepted by topic author Patrem1

It's because you have the Number of Samples to Read set to -1. In the VI Description for DAQmx read it says:

 

"If the task acquires samples continuously and you set this input to -1, this VI reads all the samples currently available in the buffer."

 

If there are no points available, the VI outputs an array of waveforms that don't actually contain any data. Try setting the sampling rate to 1 and probe the output, you'll see that all the waveforms are empty because there are no new samples to read yet.

 

Two ideas:

 

  • Use the sampling rate to set the number of samples to read. Say you want to read the available points 10 times a second, divide the sampling rate by 10 and wire that to the Nbr of Samples to Read.
  • Put a Wait in the loop, or use a Timed While Loop, to control how often you read data. This lets you still use -1 to read everything, but also controls how often the loop runs.
0 Kudos
Message 7 of 13
(2,957 Views)

What version of DAQmx are you using?

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 8 of 13
(2,926 Views)

@Patrem1 wrote:

Hi ben,

 

I can't put a wait in the program this is from. 

Isn't the queue supposed to update just when the DAQmx read sends it data? 

Which would be based on the acquisition rate?  


You should qualify that statement.

 

Then change two things.

 

Outside the loop, set the sample rate to 10/sec

Inside the loop wire a "1" to the number of samples to acquire.

 

That should give you 10 Queue entries/sec with one sample in each queue entry.

 

As you have already been told, you are queueing up a lot of empty updates to the queue.

 

Ben

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

Thank you ng,

 

I did not know this behavior of the DAQmx Read to send empty data in this case. Was not that clear in the help. 

Putting something else than 1 works. 

 

Ben, what do you mean quality this? 

To explain what this goes into I'm in the process of learning QMH architecture and doing a data acquisition and logging program to pratice this. 

 

In my program the samping rate can be modified and I want the data to be read as fast as possible and send to the queue to be logged in a file by another loop.

 

0 Kudos
Message 10 of 13
(2,916 Views)