LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rate of Obtaining Data

Solved!
Go to solution

Hi everyone,

 

I have recently constructed a VI which obtains data from a DAQmx, and saves it to a log file, a long with the time duration of the test (Hence the Elapsed time VI).

 

The data saves to a immediatley a file, which can be analysed later using the same software.

 

The problem i seem to have, is that the data seems to save every 19 msec, yet I need it to be roughly 1msec or quicker. From things i have read on the forum, the constant saving of data directly to a file is what is slowing my code down, yet i can't seem to save the full 30 seconds worth of data to an array and then export that to a file once my data collection has finished.

 

The max length of a data sample would be 120 secs (ie 120,000 data points).

 

Here is a snippet of the data aquasition part of my code.

Data Aqu Speed.png

 

Any help would be greatly appreciated.

 

Thanks,

 

Oli

0 Kudos
Message 1 of 8
(2,455 Views)

Is the snippet inside a While Loop?

What is the value for Time Target?

 

Do you (really) need to write to the file every 1ms? OR do you need to acquire data every 1ms?  (there's a big difference)

Have you considered the Producer / Consumer design?

Message 2 of 8
(2,446 Views)

Hi Ray,

 

Thanks for the reply.

 

Sorry, yes the snippet is within a while loop. The time target value is the duration of the data capture, as the software will be running continuously, yet the data will only be captured for a small, defined period.  

 

You are correct, I would like to acquire data at the rate of 1msec, and then maybe save all the data points at this rate afterward the sampling period, as this file is then analysed afterwards (Analysis in same VI, yet in a Case structure and only ran when data capture has completed) .

 

'Producer/Consumer'? I am not familiar with this method, as I am pretty new to lab VIEW, and have used it intermittently.

 

Thanks,

 

Oli

0 Kudos
Message 3 of 8
(2,438 Views)
Solution
Accepted by topic author Clubber

If you can write to the file after acquiring the data, then that simplifies your solution.

Since you know the number of samples that you expect, you could initialize an array to a size slightly larger than the size to accommodate all your data and then write (insert) into that array.  You would pass the array around the loop using shift registers.  After the While Loop, you would write the entire array to file. 

 

Place a 1ms delay within the While Loop.  If your loop actually takes 1ms to obtain (read from DAQmx), then a little trick would be to set the value of the Delay to 0ms.  Yes zero.  0ms will still allow the processor to handle other tasks, although the CPU will show high % useage.  It is different than not having a Delay at all...

 

And get rid of the Elapsed Time..

Message 4 of 8
(2,433 Views)

Hi Ray,

 

Thanks again for the reply.

 

This sounds great, but I seem to be having troubles with actually appending all the data point to the Array.

 

I have created the Array to the that the correct size, yet the data is the same for each point within the Array, which is usually the final value taken.

 

Thanks,

 

Oli

0 Kudos
Message 5 of 8
(2,415 Views)

Hi Ray,

 

I was overcomplicating things, that's why I wasn't able to obtain all the live data. Think i have got it cracked.

 

 

Thanks for all the help.

 

Cheers,

 

Oli 

0 Kudos
Message 6 of 8
(2,405 Views)

Hello Ray,

 

Thanks for helping Oli out!

 

Just a quick note on your 0ms delay advice, I believe this "glitch" has been eliminated in LabVIEW 2010.

Can you confirm this?

I tried 0ms delay in LabVIEW 2010 and all I can see is max CPU usage, no indication that other tasks are attended to. Is there a way to prove your point? I would greatly appreciate your feedback.

 

Thanks again, and hope to hear from you soon.

 

Kind Regards,

Michael S.
Applications Engineer
NI UK & Ireland

0 Kudos
Message 7 of 8
(2,400 Views)

 


@sahpe wrote:

Just a quick note on your 0ms delay advice, I believe this "glitch" has been eliminated in LabVIEW 2010.


 

Oh really?  That was a good "glitch" .  I will soon be using LV2010 regularly, so I will pay special attention to that.

I may create some test VI's and observe the behaviour.  Seeing the max CPU usage is (was?) normal.

0 Kudos
Message 8 of 8
(2,397 Views)