Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuously acquire a finite number of samples

So what I would like to do is the following: with every external hardware trigger I want to get a finite number of samples at the maximum acquisition rate.This should go on until a certain number of external triggers have been received. I'm using a USB6211 and Visual Basic Express 2010.

 

My code now simply reads:

            'Create a new virtual channel
            myTask.AIChannels.CreateVoltageChannel("Dev3/ai0", "", AITerminalConfiguration.Rse, 0.0, scalemax, AIVoltageUnits.Volts)

            'Create a trigger
            myTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/Dev3/PFI0", DigitalEdgeStartTriggerEdge.Rising)

            'Configure Timing Specs
            maxAcqRate = 250000.0
            NsamplesPerPulse = 4
            myTask.Timing.ConfigureSampleClock("", maxAcqRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, NsamplesPerPulse)

            'Create reader

            reader = New AnalogSingleChannelReader(myTask.Stream)

 

           'Get 200000 samples created by 50000 external trigger events

            NsamplesTotalToGet = 200000
            NsamplesTotalReceived = 0
            While NsamplesTotalReceived < NsamplesTotalToGet            
                pulse = reader.ReadMultiSample(4)
                For i = 0 To 3
                    fileBinaryWriter.Write(pulse(i))
                Next i
                NsamplesTotalReceived = NsamplesTotalReceived + 4
            End While

 

The problem now is that this works ok, but only upto a trigger rate of about 20 Hz. My expected trigger frequency however will be about 10 kHz. Apparently the acquisition stops every time the finite number of 4 samples has been acquired and only after I'ver read them a new acquisition starts. I suppose that that makes the whole re-trigger timing software-based and thus slow.

Typically I'd like to read a few seconds worth of data, i.e. e.g. 5 seconds of data at a trigger rate of 10 kHz and 4 samples per trigger at 250000 Samp/s.

 

So how can I modify my task such that it will continue to acquire 4 samples per trigger without missing any trigger and put them all in a buffer that I can then read out either asynchronously or when the buffer is full?

 

Hope someone can point me in the right direction cause I can't believe that it is not possible.

 

cheers,

Marc

 

 

 

 

0 Kudos
Message 1 of 2
(4,919 Views)

Hello,

Sorry for the late reply. You might have solved this already, but if not yu could have a look at the "ContAcq-IntClk-DigStart-Retrig.c" example which is installed with the DAQmx driver. The type of trigger used is different: DAQmxSetStartTrigRetriggerable.

 

With kind regards,

Jos

0 Kudos
Message 2 of 2
(4,790 Views)