LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

data acquisition in a while loop

HI!
 
I have two versions of my program. The first program has the data-acquisition in the while loop, also the "start task" and "clear task" vi!
In the second program there are the "start task" and "clear task" outside of the loop.
When i start each program and compare dates, there are two different dates. I think there*s no difference in the acquisition.
Why are there two several dates??? :mansurprised:
 
Could somebody help me???
 
Best regards,
 
Peter
Labview 7.1 on Windows 2000
0 Kudos
Message 1 of 6
(3,204 Views)
Hello Peter,

In general, you are right. In terms of the acquired date it should not make a difference if you start a tsk within the loop ore outside it.
But it is difficult for me to tell why youre program is behaving just the way it does because I know nothing about the tasks you have configured in MAX.
With the DAQmx read you are fetching one sample from each channel. If you configured a continuous daq task you would not have to start the task over and over again. Just start it once (before entering the loop) and stop it after exiting the loop. The board will continuosly acquire data and write it into a buffer - where you can fetch it with the daqmx read.

Have a look at the shipped examples - they are programmed just this way.
If you have further questions, please reduce your VIs to the AI part that you are having the problems with. And please add the task configuration to the vi. The easiest to do this in that case would be to rightclick the task-constant in the blockdiagram and choose generate code -> configuration.

btw. By generate code -> example you will get an example VI just fitting for that specific task.
Hope this helps
Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 2 of 6
(3,174 Views)

Hello!

Thank you for your informative message!!!

I have configured my task to continuous! Yoo can see it in my configuration.  I have a question because i don*t know where i have to move my start task and stop task vi. I have studied several examples but i am not sure where i have to place the task vi's. Do i have to place them outside from the while loop in the case structure or outside from the main while loop??

I have tried the "generate code" function and it helps me how the acquistion works.

Best regards,

 

Peter

Message Edited by Steirer on 07-28-2005 03:11 PM

Labview 7.1 on Windows 2000
0 Kudos
Message 3 of 6
(3,167 Views)
Hello Peter,

it seems that you are starting different acquisition or output tasks in the different frames of your sequence structure.
In this case it is allright to have the start and clear task VIs inside the sequence frames.
If you are using the same task in different frames you could create and start the task before entering the sequence - or tzransmit the taskID from one frame to the other using a sequence local variable.

Concerning the analog input task I would start the task inside the sequence frame but before the while loop, have the read VI inside the loop, and stop the task behind the loop but inside the sequence frame.

Message Edited by IngoS on 07-29-2005 12:05 PM

Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 4 of 6
(3,147 Views)

HI!

I tried your solution, but when i get the results of my acqusition, a part of my acquistion-dates is missing. I think when i start the acqusition outside of my loop, the computer or the loop is too slow to receive the data. Could that be possible???

Best regards,

Peter

Labview 7.1 on Windows 2000
0 Kudos
Message 5 of 6
(3,119 Views)
Hi Peter,
in general it works like this:
If you create a DAQmx task, add some channels to it and specify the timing, the driver allocates a certain amount of buffer space in the RAM of your PC. Starting the task later on initiates the Data acquisition. With the desired speed, data is sampled and stored into that buffer. This is done either by DMA (default) or by IRQ. The Daqmx Read function is then accessing that buffer and fetching the date from there. Sure, you have to be quick enough calling that function. If it takes too long to enter the loop and calling the read function data inside the buffer might be overwritten. You should get an error message in that case.

To find out how big the buffer is, read the article below. I copied it from the helpfile. You see, that it can store about a second of the measurement. I am pretty sure that it does not take so long to call the daqmy read vi.

Using a buffer property node you might manually resize the buffer if you need it to be larger.

How Is Buffer Size Determined?

Input Tasks

If your acquisition is finite (sample mode on the Timing function/VI set to Finite Samples), NI-DAQmx allocates a buffer equal in size to the value of the samples per channel attribute/property. For example, if you specify samples per channel of 1,000 samples and your application uses two channels, the buffer size would be 2,000 samples. Thus, the buffer is exactly big enough to hold all the samples you want to acquire.

If the acquisition is continuous (sample mode on the Timing function/VI set to Continuous Samples), NI-DAQmx allocates a buffer equal in size to the value of the samples per channel attribute/property, unless that value is less than the value listed in the following table. If the value of the samples per channel attribute/property is less than the value in the table, NI-DAQmx uses the value in the table.

Sample Rate Buffer Size
no rate specified 10 kS
0–100 S/s 1 kS
100–10,000 S/s 10 kS
10,000–1,000,000 S/s 100 kS
>1,000,000 S/s 1 MS

You can override the default buffer size by calling the Input Buffer Config function/VI.

NI-DAQmx does not create a buffer when the sample mode on the Timing function/VI is set to hardware-timed single point.

Note  Using very large buffers may result in diminished system performance due to excessive reading and writing between memory and the hard disk. Reducing the size of the buffer or adding more memory to the system can reduce the severity of these problems.

Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 6 of 6
(3,108 Views)