Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

cDAQ - getting pretrigger samples in callback

Hello,

I am using code that worked fine on a multi-function daq system on a compact daq system.  I've got everything working so far except for a strange artifact.  It seems I am getting 40 samples

of pretrigger data in my async callback routine.

 

I am testing a simple two channel analog input acquisition with a digital start trigger.  The trigger source is the cDAQ chassis PFI0.  I also have wires running from the PFI0 to one of the analog input channels.

I am just touching 5 volts to PFI0 for the trigger.  Since the PFI0 is in parallel with the analog channel, I should see this 5 volts on the first sample of my data.  But the 5 volts always shows up 40 samples later ???

 

Here is configure code:

Try
            'AnalogIn Task(s)
            aiDAQTask = New Task
            aiDAQTask.AIChannels.CreateVoltageChannel("cDAQ1Mod8/ai0", "S1", AITerminalConfiguration.Differential, -10, 10, AIVoltageUnits.Volts)
            aiDAQTask.AIChannels.CreateVoltageChannel("cDAQ1Mod8/ai1", "S2", AITerminalConfiguration.Differential, -10, 10, AIVoltageUnits.Volts)

            'trigger setup
            aiDAQTask.Timing.ConfigureSampleClock("", 10000, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, ANALOG_IN_SAMPLES)
            aiDAQTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/cDAQ1/PFI0", DigitalEdgeStartTriggerEdge.Rising)

            'set no timeout for trigger
            aiDAQTask.Stream.Timeout = -1

            'verify the task
            aiDAQTask.Control(TaskAction.Verify)

            aiReader = New AnalogMultiChannelReader(aiDAQTask.Stream)

            '.NET Framework 2.0
            aiReader.SynchronizeCallbacks = True

            aiReader.BeginReadMultiSample(ANALOG_IN_SAMPLES, AddressOf aiReaderCallback, Nothing)



        Catch ex As DaqException

            If aiDAQTask IsNot Nothing Then
                aiDAQTask.Dispose()
            End If

            MessageBox.Show(ex.Message)

        End Try

 

 

Here is code for callback routine:

Try
            'get data
            data = aiReader.EndReadMultiSample(ar)

            'display first 100 samples
            For i As Int32 = 0 To 99
                ListBox1.Items.Add(i.ToString & " " & data(0, i).ToString("F3"))
            Next


        Catch ex As DaqException
            MessageBox.Show(ex.Message)

        Catch ex As Exception
            MessageBox.Show(ex.Message)

        Finally

            aiDAQTask.Dispose()
            
        End Try

 

Any suggestions would be appreciated.

Thanks,

Mike

0 Kudos
Message 1 of 5
(4,644 Views)

Hi jendrom,

 

There are a couple of questions I have for you to try to help you with this issue. What card ar you using in the cDAQ system? Also, what card were you using in the Multi-Function DAQ system? It is possible that the card you are using has a certain filter delay that could be causing this behaviour. 

 

Have you tried to use any of the example code with the current hardware set-up? 

 

With more information hopefully we can deduce what is causing the problem and take it from there.

 

Regards,

James D.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(4,633 Views)

Hello James,

The module I am currently testing is the NI 9239.  There are also (2) NI 9401, (1) NI 9263,  and (4) NI 9237 modules in a USB cDAQ 9178 chassis.

 

The multi-function DAQ that I used before was the USB 6221.  I recently updated my NIDAQmx to version 9.4.  So I tested this code again with the 6221 and it worked fine.  (The 5 volt signal

showed up on the second sample.)

 

I have tried the NI AnalogIn/Measure Voltage example code and this also had the 5 volt signal showing up on the 40th sample.

 

I've also tried different sample rates to see any effect but there was no change.  Consistently 40 samples late.

 

Thanks for your reply,

Mike

 

0 Kudos
Message 3 of 5
(4,627 Views)

You are right James............it is from the internal digital filter.

http://digital.ni.com/public.nsf/allkb/F989B25FF6CA55C386256CD20056E27D

 

 

0 Kudos
Message 4 of 5
(4,624 Views)

Hi jendrom,

 

I'm glad you were able to find the appropriate documentation! If you have any further questions feel free to submit another post.

 

Regards,

 

James D.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 5
(4,621 Views)