Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure synchronized AI and AO on PCI-6111 in VB.NET?

I am in the process of converting code for simulataneous analog in and out on the PCI-6111 from VB6 to VB.NET.  Is there an example that shows how to route the signals to sychronize input and output on this board? With the traditional DAQ system, I used the RouteSignal function to connect PFI2 to AIConvert.

 

I put my current DAQmx code below:

 

Private Sub cmdSetupNIchannels_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSetupNIchannels.Click
        OutTask = New Task("My Out Task")
        InTask = New Task("My In Task")
        OutTask.AOChannels.CreateVoltageChannel("dev1/ao0", "", OutRangeMin, OutRangeMax, AOVoltageUnits.Volts)
        OutTask.AOChannels.CreateVoltageChannel("dev1/ao1", "", OutRangeMin, OutRangeMax, AOVoltageUnits.Volts)
        OutTask.Timing.ConfigureSampleClock("", SampleRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, NumSamples)
        InTask.AIChannels.CreateVoltageChannel("dev1/ai0", "", AITerminalConfiguration.Pseudodifferential, InRangeMin, InRangeMax, AIVoltageUnits.Volts)
        InTask.Timing.ConfigureSampleClock("", SampleRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, NumSamples)
    End Sub


    Private Sub cmdTestNIin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTestNIin.Click
        InTask.Stop()
        OutTask.Stop()
        Dim i As Long
        Dim writer As AnalogMultiChannelWriter
        writer = New AnalogMultiChannelWriter(OutTask.Stream)
        Dim dataOutA() As Double
        Dim dataOutB() As Double
        ReDim dataOutA(NumSamples - 1)
        ReDim dataOutB(NumSamples - 1)
        For i = 0 To NumSamples - 1 ' put in test waveforms
            dataOutA(i) = i / 50000
            dataOutB(i) = -1 * (i / 25000)
        Next
        Dim dataWaveOut(1) As NationalInstruments.AnalogWaveform(Of Double)
        dataWaveOut(0) = NationalInstruments.AnalogWaveform(Of Double).FromArray1D(dataOutA)
        dataWaveOut(1) = NationalInstruments.AnalogWaveform(Of Double).FromArray1D(dataOutB)
        writer.WriteWaveform(False, dataWaveOut)
        AddHandler InTask.Done, AddressOf AnalogInFinished
        OutTask.Start()
        InTask.Start()
    End Sub


    Private Sub AnalogInFinished()
        Dim reader As AnalogSingleChannelReader
        reader = New AnalogSingleChannelReader(InTask.Stream)
        Dim dataWave = New NationalInstruments.AnalogWaveform(Of Double)(NumSamples)
        dataWave = reader.ReadWaveform(NumSamples)

        Dim data() As Double
        data = dataWave.GetRawData
        MsgBox(data(23).ToString) ' for testing purposes
    End Sub


    Private Sub cmdDisposeNI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDisposeNI.Click
        InTask.Dispose()
        OutTask.Dispose()
    End Sub

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

Hi bws,

 

If you navigate to your National Instruments folder and follow this path, there should be a MultiFunction AIAO Dig Start.vb example in .NET framework.  Your .NET might be a different version, but the code will be the same.  To view the code you are interested in, right click the MainForm.vb and View Code.  Let me know if this helps, thank you!

 

\National Instruments\NI-DAQ\Examples\DotNET3.5\Synchronization\Multi-Function\SyncAIAO_DigStart\VB

 

 

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 2 of 2
(2,819 Views)