02-27-2018 10:15 AM
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.
Solved! Go to Solution.
02-28-2018 05:48 PM
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/
03-01-2018 12:05 AM
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!
03-01-2018 09:08 AM
Use the PhysicalChannel.DIPortWidth (or DOPortWidth) properties.
03-07-2018 12:09 AM
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
03-08-2018 09:48 AM
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
03-08-2018 09:56 AM
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.
03-09-2018 12:57 PM
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
03-11-2018 06:55 AM
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
}