Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

List of devices/ports/ lines?

   Hi folks. I'm new to using the NI hardware. My lab uses several different NI I/O boards with different abilities. I need to write a program which will work on all of them, hence a need to obtain a list of installed devices and their available ports/lines.

I've been looking through documentation and it doesn't seem to match what is installed in my VS 2005, so I'm confused. I am using code generated by others to create a task and channel:

            digitalWriteTask = New Task
            digitalWriteTask.DOChannels.CreateChannel("Dev1/Port0/line0:7", "port0", ChannelLineGrouping.OneChannelForAllLines)
            'digitalWriteTask.DOChannels.CreateChannel("Dev1/Port1/line0:7", "port1", ChannelLineGrouping.OneChannelForAllLines)
            'digitalWriteTask.DOChannels.CreateChannel("Dev1/Port2/line0:7", "port2", ChannelLineGrouping.OneChannelForAllLines)

The board it was written for had three ports, the one I'm using has one, so I've had to comment out those lines. I'd like this to work no matter what, so how can I determine within a program what devices/ports/lines are available?

Nick
cassa1nd@cmich.edu
0 Kudos
Message 1 of 3
(2,516 Views)

Hello Nick,

I believe that what you want to do it populate a list of available channels programmatically.  I assumed that you are using Visual Studio 2005 with a NI-DAQmx device.  If this is not the case then please reply with the specific programming environment and language as well as the hardware you are using.

For an example of how to populate a drop down list please look at the examples located here:  C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0\Analog In\Measure Voltage\AcqVoltageSamples_ExtClk\cs

Any of these examples should have a Channels box that will demonstrate what you want to see. 

If you right click on the Channel drop down box and select "view code" you should see the following line:

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

 

This line of code basically populates this list from the Measurement and Automation Explorer so all available channels should show up.  This will allow you to choose the channels you want from a list of available channels so if you remove a device those channels won’t show up.

 

I hope this helps get you started.  If you have any further questions or if I misinterpreted your question then please respond back and clarify what it is you’d like to know.

 

Have a good night!



Message Edited by Brooks_C on 02-11-2008 06:27 PM
Brooks
0 Kudos
Message 2 of 3
(2,491 Views)
I'm finally getting back to this project. That helps very much, thank you. I think I can figure it out from here.

Nick
0 Kudos
Message 3 of 3
(2,372 Views)