LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to clear Read Buffer before AI Read

Hi!,

I am using AI Config + AI Start (at the very beginning of my vi) and then multiple AI Reads in the vi. The AI Read is used to read data from the same channel each time.

I would like to clear the buffer from which AI Read picks data so that previously filled data (which is not needed) is flsuhed out and I get only new/relevant data.

I am using NI-PDS 6.1, PCI-6034, NI-DAQ 6.2

Thanks in advance!

- Gurdas
gurdas@qagetech.com
Gurdas Sandhu, Ph.D.
ORISE Research Fellow at US EPA
0 Kudos
Message 1 of 6
(4,135 Views)
Hi Gurdas,

you can use AI control to stop and restart the acqusition. With control code "pause immediatly" you stop the clock, then start again with "start".
AI control is in "Analog input">>"Advanced analog input" palette.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 2 of 6
(4,135 Views)
Thanks Waldemar!
Looks like this would work.

However, I am not clear how to club the AI Control vi with my AI Read vi.
Do I need to place the "start" right BEFORE my AI Read and "pause immediately" right AFTER my AI Read?
Please clarify.

To restate my objective: Whenever I use AI Read, the input buffer should be cleared of all previus data. LabVIEW's Help for the 'AI Control' function says "If you start after a pause, the acquisition starts at the beginning of the buffer and overwrites existing data." I hope the overwriting does not create an error code!

Best wishes,
Gurdas
Gurdas Sandhu, Ph.D.
ORISE Research Fellow at US EPA
0 Kudos
Message 3 of 6
(4,135 Views)
Rather than restart your data acquisition, you could wire a cluster into the AI Read on the terminal "read/search position". Tell it to read "relative to the end of data" with a 0 offset. That way, you always get the newest data in the buffer.

The buffer isn't really "cleared" per se, but you get the most current data from the time the AI Read was called, and as long as your acquisition is continuous, it will keep running--thus pretty much the same as clearing the buffer.

Mark
0 Kudos
Message 4 of 6
(4,135 Views)
You are right to put "start" before and "pause" after AI Read.

In the time between your AI Read and the "pause" the buffer will be filled with new data. If you start after a pause this data will be lost. There will be no error. This was only to clarify the difference to the "resume" where these old data in the buffer will not be lost.

Another problem can occur if you start your AI with a trigger. You have to reach the trigger condition with each "start". If you have only one trigger for your first AI Read the method of markwysong or the following sequence must be used:
Call AI Read with 0 "number of scans to read". Connect the "Backlog" output to "number of scans to read" of another AI Read. Then call your final AI Read to get the d
ata you need.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 5 of 6
(4,135 Views)

I am facing the similar issue and would like to clear the DAQ everytime I read it. As of now, I see a spike at t=0 from the ai channel I am reading from (ai2).

 

To Markwysong

 

I am using LabView 2010 with SP1 and do not see the option for read/ search position for the DAQmx Read.vi for a Analog Wfm 1 Chan NSamp.

 

To Gurdas,

 

Were you able to clear the buffer? and what approach did you go with?

 

Deepak Arora

Scientist

deepakarora04@gmail.com

 

 

 

 

LAB View 2010 SP1
0 Kudos
Message 6 of 6
(3,305 Views)