Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital IO Port Width

Solved!
Go to solution

Hi all,

 

Does anyone knows how to extract a DIO Port Width from a C# code? That means the number of digital lines of a DIO port.

Thanks in advance.

0 Kudos
Message 1 of 9
(3,282 Views)

That is a property of the hardware, so if you can do it I would look at property nodes.

 

If it is NI hardware you may be able to find if with system configuration

http://zone.ni.com/reference/en-XX/help/373107L-01/nisyscfg/get_system_experts/

Chase
NI Technical Support Engineer
0 Kudos
Message 2 of 9
(3,261 Views)

Sorry, maybe I wasn't clear enough. I'm using an NI Daq card number - NI USB 6356.

Also I'm coding in c# not LabVIEW. So I wish to know how to extract a DIO ports width programmatically in c# coding (i.e. the number of lines that the port will expose).

 

Thanks!

0 Kudos
Message 3 of 9
(3,253 Views)

Use the PhysicalChannel.DIPortWidth (or DOPortWidth) properties.

——
Brandon Streiff
ni.com/compactdaq · ni.com/daq
0 Kudos
Message 4 of 9
(3,245 Views)

Hi Brandon,

 

Your reply looks a big step forward towards conclusion of my case. But I still can't find a good example of how to utilize the command that you mentioned. So suppose I get each Device that is connected to my machine can you spare an example of how to get or create the physical channel object that corresponds to that device so I can use the DOPortWidth as you mentioned?

 

thanks much

0 Kudos
Message 5 of 9
(3,208 Views)

Have you seen this?

http://www.ni.com/product-documentation/2835/en/#toc11

 

The last section is on how to access the properties in C. Additionally, I would look at the 

 

NI-DAQmx Example Locations for LabVIEW and Text-Based in Windows

http://www.ni.com/product-documentation/54394/en/

 

I think this is the example you will want:

C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital\Read Values\Read Dig Chan

Chase
NI Technical Support Engineer
0 Kudos
Message 6 of 9
(3,192 Views)

Thanks your reply. Unfortunately I'm a c# coder not in LabVIEW nor C which I studied but noting is there that refers to handling a PhysicalChannel object. Hopefully there's a good example out there.

Thanks again. 

0 Kudos
Message 7 of 9
(3,190 Views)
Solution
Accepted by topic author Arik2017

The C# examples are linked in the document above. I would also reference the DAQmx help for how to create these channels. 

 

Channels: Physical, Virtual, Local Virtual, and Global Virtual

http://zone.ni.com/reference/en-XX/help/370466Y-01/mxcncpts/chans/

 

If the examples are not installed, you will need to modify the installation to include the.NET Examples form the Windows Add/Remove Programs

Chase
NI Technical Support Engineer
Message 8 of 9
(3,174 Views)
Solution
Accepted by topic author Arik2017

So finally I managed to conclude how this is done in c#. I wish to place here the solution that I'm using for the "next generations" of c# coders 🙂

So to create a physical channel in c# and use it for instance to know the number of bits in each port in that physical channel, as follow:

 

 string[] terminals = DaqSystem.Local.Devices;
 foreach (var s in terminals)
 {    
    string[] phcs = DaqSystem.Local.GetPhysicalChannels

                           (PhysicalChannelTypes.DOPort,

                            PhysicalChannelAccess.External);                                                 

    PhysicalChannel physicalChannel = DaqSystem.Local.LoadPhysicalChannel(phcs[0]);
    long numLines = physicalChannel.DOPortWidth;  // one usage for this effort
  }

0 Kudos
Message 9 of 9
(3,157 Views)