Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

circular buffer

Any one have any example code in Visual Basic.NET for acquiring multiple analog channels continuously using NIDAQmx asynchronous calls (with callback) and dumping the data into a circular buffer of known size so that it can be concurrently accessed by a background program for processing? Or any documentation outside of the brief description in the NI-DAQmx Key Concepts doc?
 
Thanks
 
Steve
0 Kudos
Message 1 of 5
(4,049 Views)
Hi Steve,
 
Your best bet is to start from one of the shipping examples found here - C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DAQmx\Analog In\Measure Voltage\
 
There are a few continuous acquisitions to start from, but there isn't one that adresses something that specific.
 
Is it a requirement that you have the circular buffer? That is going to introduce some intensive coding and usually users find it easier to read in the data and then perform post processing. The "ContAcqVoltageSamples_IntClk_ToFile" example would be a good starting point for that setup.
 
Hope this helps,
Andrew S.
National Instruments
Message 2 of 5
(4,025 Views)
The problem I'm having is that I'm streaming analog data to a file over a long (24 hours)  @ 1khz. I can' t allocate enough memory to do it in one large buffer (345MBytes) or if I use the Begin ReadWaveform - EndReadWaveform pair I lose some data ( glitch ) in the callback routine. If there is some C++ code that would be Ok too.
0 Kudos
Message 3 of 5
(4,023 Views)
In the example program that you suggested the data drops in the call back routine:
 

Private

Sub AnalogInCallback(ByVal ar As IAsyncResult)

'Read the available data from the channels

data = analogInReader.EndReadMultiSample(ar)

The data drops here. I have tried to copy the data to another array and then starting the read again, same problem.

analogInReader.BeginReadMultiSample(Convert.ToInt32(samplesPerChannelNumeric.Value), analogCallback,

Nothing)

End If

End Sub 'AnalogInCallback

0 Kudos
Message 4 of 5
(4,019 Views)
Hi Steve,
 
When you say that the "data drops", do you mean that it not being written to file with the LogData(), or do you not acquire the correct number of samples? Also, what DAQ card and DAQmx Driver version are you using?
 
I ran this and read the expected number of values, and the text file had the expected number of values with a PCI 6251 and DAQmx 8.3. Let us know what you find out.
 
Thanks,
Andrew S.
National Instruments 
0 Kudos
Message 5 of 5
(3,992 Views)