Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Get All Devices, Modules, and Channel from cDAQ using VB.Net

Solved!
Go to solution

There is an example ("AnalogDataFileProcessor") included in Measurement Studio shows how to get  AI Physical Channel but it is advanced for people who just starts with Measurement Studio.

 

Bascially, I just want to populate the DevicesComboBox with a list of available cDAQ and USBDaq devices and physical channel available on selected devices from DevicesComboBox.  I am unable to do it.

 

 

test.jpg

 

 

 

    Public Property DaqTask() As Task
        Get
            Return _task
        End Get

        Set(ByVal Value As Task)
            _task = Value
        End Set
    End Property

    Private Sub okButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btPopulate.Click
        If _task Is Nothing Then
            '
            ' No previous task information. Use the control default values.
            '
            Return
        End If
        If _task.AIChannels.Count = 0 Then
            '
            ' No previous channel information. Use the control default values.
            '
            Return
        End If
        Dim channel As AIChannel = _task.AIChannels(0)
        physicalChannelComboBox.Text = channel.PhysicalName

        terminalConfigurationComboBox.SelectedItem = channel.TerminalConfiguration.ToString()

        minimumValueNumericEdit.Value = channel.Minimum
        maximumValueNumericEdit.Value = channel.Maximum

        numberOfSamplesNumericEdit.Value = _task.Timing.SamplesPerChannel
        samplingRateNumericEdit.Value = _task.Timing.SampleClockRate
    End Sub

    Private Function ConfigureTaskFromControls(ByVal daqTask As Task) As Boolean
        Try
            daqTask.AIChannels.CreateVoltageChannel(physicalChannelComboBox.Text, "Voltage", DirectCast([Enum].Parse(GetType(AITerminalConfiguration), terminalConfigurationComboBox.SelectedItem.ToString()), AITerminalConfiguration), minimumValueNumericEdit.Value, maximumValueNumericEdit.Value, AIVoltageUnits.Volts)
            daqTask.Timing.ConfigureSampleClock("", samplingRateNumericEdit.Value, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, CType(numberOfSamplesNumericEdit.Value, Integer))
            daqTask.Control(TaskAction.Verify)
        Catch ex As DaqException
            MessageBox.Show(ex.Message, "Error Configuring DAQ Task")
            Return False
        End Try

        Return True
    End Function

 

0 Kudos
Message 1 of 2
(5,140 Views)
Solution
Accepted by topic author muahang1234

I'm assuming the code you included is your own. Unfortunately, I can't debug your code, but I can show you were to look in the example file if you'd like.

 

You want to use the GetPhysicalChannels method as illustrated below:

physicalChannelComboBox.Items.AddRange(DaqSystem.Local.GetPhysicalChannels(PhysicalChannelTypes.AI, PhysicalChannelAccess.External))

 

GetPhysicalChannels.PNG

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