LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

samples and sampling rate for analog inputs

Then it must be working, the available samples being zero means that the buffer is being emptied properly. If you put timing into the VI, you will see this number increase until the buffer is full and you get the error message that you originally asked about.

National Instruments
Applications Engineer
0 Kudos
Message 21 of 37
(1,635 Views)

The available samples are showing how many elements are in the buffer, if it is holding at zero, then you are not filling the buffer and your program will run without errors. If you add timing to the loop, you will see the indicator increase until you completely fill the buffer and then it will give you the same error message that you orignially posted about.

National Instruments
Applications Engineer
0 Kudos
Message 22 of 37
(1,631 Views)

Thanks! This is interesting and I am glad I learned something new. But, This is what I don't understand.

 

When there is no delay timing in the loop, it shows 0 available samples and no error pops out and the program seems to run fine.

WHen an error of say 200ms is included, I can see the available samples changing, it increases and as an when it reads it decreases and then fills up. kind of like FIFO. But, here is where I am bummed. When the available samples comes back to 0, error - 200279 attempted to read samples is no longer available error pops up.

 

How is the first case different from the second? why doesnt an error pop up in the first case.?

I may not be perfect, but I'm all I got!
0 Kudos
Message 23 of 37
(1,629 Views)

The available samples will jump from a large number (~8500) straight to zero and will throw the error because when the buffer is full it completely clears out to zero and then throws the error message.

National Instruments
Applications Engineer
0 Kudos
Message 24 of 37
(1,606 Views)

Hi SCott,

 

There seems to be an inconsistency with this working of my code. with respect to sampling rate and samples to read etc. sometimes it works fine, sometimes it pops up the error. And I have tried umpteen combinations. I must state I do have other software running on the computer along with my LabVIEW program. Would that make any difference with the functioning of the DAQ buffer? Please let me know.

 

THanks!

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 25 of 37
(1,577 Views)

Hi Vijay,

 

If you specify a sample rate of 3KHz, DAQmx will automatically configure a buffer of 10 KSamples. Data will be DMA'd from the small FIFO (512 Bytes) onboard your 6008 to the 10KSamples buffer in RAM. This happens continuously. Every time you execute a DAQmx read, you transfer data from the buffer to LV RAM. The default is to read all available samples (-1) but I would recommend setting it to 1/10th of your sample rate, so 300 in your case. Keep in mind that this is on a per channel basis, so each channel is reading at 3KHz and 300 samples are being read from the buffer on  each DAQmx read. Having other software running in the background could cause this error because LabVIEW may not read data from the buffer fast enough. Another common cause for this error is performing too much processing within the loop containing the DAQmx read. 

 

If you want to process the data in real time, you should use a producer/consumer architecture. Here's a link to the theory and here's an example. If you want to post-process the data then you could just use TDMS to stream the data directly to disk. Here's an example.\

 

Best of luck!

Sean Ferguson
Application Engineering Specialist | RF and Reconfigurable Test
0 Kudos
Message 26 of 37
(1,557 Views)

Thanks Sean! THat was really helpful. Especially the example for PC architecture. I have been looking to convert my code into the PC architecture but theory on it is very bad. It is examples like this that make total sense.

 

With regards to TDMS, are we creating a log and reading values from the log? Is the log a replacement for the buffer (kind of)?

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 27 of 37
(1,543 Views)

Hi Sean and Scott,

 

I have implemented or tried my application using the PC architecture. Please refer the vi and send comments my way.

 

I have 2 producer loops and one consumer loop that will be a State machine. Currently I use references between multiple vis and subvis. but l like this concept and probably need help with implementation.

 

THnks

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 28 of 37
(1,526 Views)

Veejay, I would probably make a separate consumer loop for the AI task since the loop will not iterate unless the dequeue VI executes (you have no timeout). What exactly are you trying to do in this VI? Is there a particular reason why you're sharing 1 consumer loop between two queues? If the two can run independently, I would just have them do so.

Sean Ferguson
Application Engineering Specialist | RF and Reconfigurable Test
0 Kudos
Message 29 of 37
(1,511 Views)

One producer loop listens to SErial port to receive commands and data. ACK's and feedback are sent thru the SErial port as well.

Based on the received commands, certain actions have to be performed and to reach required levels.

 

Required level is measured based of of data coming in from AI loop.

 

eg. RS232 send command to increase elevation by say 10 deg. Consumer loop raises the device 10 deg. 10 deg is equivalent to some analog voltage on the position sensor which we are reading from producer 2. In summation, consumer loop receives command from P1 and sends ACK to P1 and consumer does the action until required position is reached, which is judged ffrom what values we see from P2.

 

Hope this is clear. This is why, I need just one consumer loop because there is one action based on two separate incoming datasets.

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 30 of 37
(1,506 Views)