LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ai read in while loop

I am acquiring data from a DAQ e series card. i intialized the daq by using AI config out side while loop . i used AI start and AI read in while loop . iam acquiring data from 5 channels. the buffer size ia 1000 and so is the scan rate in AI start.I want to save the acquired data in the file. i am also displaying data o n chart. every thing is working fine. my problem is i want to save 500 points in one seconds. for this i changed the while loop execution time by using waint until multiple sec VI and assign it 10  i was expecting that now iwll save more data point in file as now loop will execute more fast but it does not happen like this. is there any way to minimize the executing time of whil loop.i checked if i deleted AI start and AI read then loop execute very very quickly. should i place AI start and AI read out side loop but then how will it acquire data contiously. I m attaching gif file of the protion of my VI .any suggestion?
0 Kudos
Message 1 of 6
(2,595 Views)
Suggestions:



  • Don't use AI-START inside the loop. Use AI-start with a #SAMPLES value of zero. That means read indefinitely.
  • Don't use five ARRAY INDEX operations, use a single ARRAY INDEX operation, and stretch it to output your five channels.
  • The first step to solving ANY runs-too-slow problem is to find out WHERE the slowdown is. I have no idea what your #1 subVI is doing. How much time is it taking? I don't know, but you should.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 6
(2,584 Views)
Also, the AI Read VI will wait until it has collected the full buffer of data, unless it times out. Since you have the buffer set to 1000 samples, and the scan rate to 1000 Hz, that means it can take up to 1 s before it returns. Changing the timing of the While loop has no effect on this. I'm not sure why you say you want to record 500 samples/s, but have the scan rate set at 1000 samples/s.
0 Kudos
Message 3 of 6
(2,579 Views)

thanks for the reply  .The reason i want to store more points in a seconds is that i want to do FFT and for this i need more data points.

secondly i want to know what do u mean by placing samples = zero in the AI start  as there is no sample input in this VI.

 
0 Kudos
Message 4 of 6
(2,571 Views)
I believe CoastalMaineBird meant the number of scans to read input for AI Start.
0 Kudos
Message 5 of 6
(2,560 Views)
I was working quickly, and from memory, so my apologies for errors or non-clarity in my previous post. 😞

The AI START VI, should be used OUTSIDE the loop, since you only want to START the task ONCE.

When the task is complete (your WHILE loop is done), then call the AI CLEAR task to clean up (ONCE).


If you set the NUMBER OF SCANS TO ACQUIRE input to AI START to zero, that has a special meaning: acquire data indefinitely. It will not stop on it's own (assuming no errors occur), you have to explicitly stop it.

If you do this, you have to read the data often enough to avoid buffer overflow, which means the incoming data is filling up the buffer faster than you're emptying it.

I have attached a picture of the general idea. If you really want to use the CPU efficiently, then consider the shift-register idea in the picture - you process on batch of data WHILE the next batch is coming in. If you want a simpler solution, forget the shift-reg, and process it directly after reading it. If your buffer is twice the size of your processing size, you'll be OK.

Message Edited by CoastalMaineBird on 09-14-2005 07:45 PM

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 6
(2,560 Views)