08-15-2014 07:39 PM
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.
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
Solved! Go to Solution.
08-18-2014 05:27 PM
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))