From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Erratic AI startup

Hi,

I am somewhat confused as to what is happening in my program when I read AI from the USB 6221.

A code fragment is attached.

 Samples per Channel=1000

 Sample rate=1000

 AI I/O reads channels 0:1

 Timeout = -1

 Samples2Get = -1 (Read all)

 SampleIntervalMD =0.5 seconds

The "Wait before Reading" was introduced to give the board some time to accumulate data after the "DAQmx Start Task" before I enter the While to do "DAQmx Read".

The sequence structure first loops until the next SampleInterval increment has passed, then continues to the DAQmx Read seen.

 

I do some processing of the waveform before I go to the "Loop until next SampleInterval increment has passed" again. One of the things I do is to extract the mean from the waveform (that's all I need) and process that further. Another thing is that I record the amount of data fetched each cycle.

 

With my precautions I expected the buffer to be ready when I get there, but my first few rounds through the while give me the following number of AI readings (per channel) - 0, 0, 503, 484, 500, 499, 500...

 

Changing the reading Interval to 5 seconds yields the following number of AI readings - 0, 5004, 2, 4981, 5000, 5000...

(These numbers are typical, but vary from time to time)

 

Q1- I find it odd that I get, despite my efforts, Zero Readings on the first DAQmq Read (I would rather have expected too many).

 

Q2- And what could possibly be the reason for obtaining Zero Readings the second round through (first example), or a full  buffer the second time and then Two readings on the third pass (as in the second example).

In fact it seems that the pattern, although irregular from time to time, follows the general rule of Zero the first time through, then a small Overshoot, then Too few and finally "it" settles on the expected number of readings each time through (give or take one). I cannot imagine how there could be a "Cycling/settling effect" on the order of 5  five second cycles...??

 

Q3- If I change to read some predefined number of samples and let too many data accumulate before I read it out (by extending the Sample Interval) I am alerted that data has been overwritten (fair enough). However, with the other settings as above this seems to happen only until some 9000-10000 values have accumulated (abouts). I expected it to happen much sooner. Why is that?

 

Q4- The Alert I get refers to data in the buffer being overwritten, but I have not found any reference to how that buffer size is being determined. Is it related to something I can change?

 

The program is working good enough so my questions are mostly to satisfy my own curiosity.

If you could shed some light on this issue I would be very grateful. 🙂

 

Kind regards / Ake

0 Kudos
Message 1 of 1
(2,061 Views)