Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Async Read of analog port

Hello,

 

I am confused about Async reading of samlples on analog ports. Refering to the example ContAcqSamples_IntClk.2012 of Measurement Studio. I have following questions

// Configure the timing parameters
myTask.Timing.ConfigureSampleClock("", Convert.ToDouble(rateNumeric.Value), SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 1000);
analogInReader.BeginReadWaveform(Convert.ToInt32(samplesPerChannelNumeric.Value), analogCallback, myTask)

 Q1: What is the role of 1000? In help file I could see that it represents the buffer size for ContinousSamples. Buffer size of what? If samplesPerChannel = 10,000 then the callback occurs when there are 10,000 "unread" samples available and if it is 100 then it occurs when 100 samples are available. It is independent of Buffer size.

Q2. On setting samplesPerChannel = -1, the callback occurs even when there is no sample to be read. Why is it so?

 

Although in my program I set samplesPerChannel = 50 and dropped the buffersize which is optional and it works fine, it works fine but still I would like to know the reason for having 2 parameters samplesPerChannel and bufferSize.

 

Thankyou!

Regards,

Ricky

0 Kudos
Message 1 of 2
(5,460 Views)

The number samples per Channel stands for he size of the package which is read on one event. You might compare it to a package size. You pack packages of 1000 items. Whenever the number is full, the package is delivered. The buffer is something else, there might occur the case, when more than one package are ready to read. This might occur because your PC does other tasks first. These are saved in the buffer. If your buffer is full, you get an error, and in general your data is lost.

 

The Number of Samples per Channel input specifies the number of scans (where a scan is one sample from each specified channel) to retrieve from the buffer. A value of -1 tells NI-DAQmx to retrieve all of the scans from the buffer.

 

Please also refer to this webpages:

http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/dbe7ac32661bcf9b86256ac000682154?O...

http://ae.natinst.com/public.nsf/webPreview/3E3D74E26B8A5B83862575CA0053E4B5?OpenDocument

0 Kudos
Message 2 of 2
(5,432 Views)