Quantcast
Channel: Measurement Studio for .NET Languages topics
Viewing all articles
Browse latest Browse all 1999

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

$
0
0

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

 


Viewing all articles
Browse latest Browse all 1999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>