From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding PFI channels in Python

Solved!
Go to solution

Hi,

 

How can one loop over the PFI ports of a device in Python (which we are using for setting triggers/clocks)?

 

For the ai/ao/di/do we did this with the following format:

deviceName = "Dev1"
device = nidaqmx.system.device.Device(deviceName) 
for di in device.di_lines:
print(di.name)

(In our program we are adding it to a list that the user can choose out in the UI).

However, it gives the name only in the format: Dev#/port#/line# and for setting/exporting an external/internal clock it seems the syntax only accepts /Dev#/PFI#. 

 

Therefore my question is:

Can you loop over the PFI ports in Python in a similar way as the example above? Where you would get it in a format similar to Dev#/PFI#?

 

Thanks in advance

 

0 Kudos
Message 1 of 3
(2,795 Views)
Solution
Accepted by topic author LHD

I don't know anything about the python API into DAQmx, but I *can* report that the LabVIEW API has "Device property node" that allows one to specify a device by name and then query for an array containing all the terminal names.

 

Hopefully that means that a similar capability is available from python, I just don't have any particular ideas about how to access it.

 

(FWIW, in LabVIEW, the same Device property node can be used to query for an array of all the DI lines.  Perhaps that means that the python method for terminals will look like the python method for DI lines?)

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 3
(2,765 Views)

Awesome!

 

It helped, I was aware that you could acces the terminal but I did not know this was the place where these ports are "accessed". Also the syntax is slightly different, which is why I did not find them in the first place. However, for people having the same problem, I believe the following should work:

device = nidaqmx.system.device.Device("Dev#")
for tr in device.terminals: print(tr)

 No need to use tr.name here as this will only result an in empty string. 

Thanks again for the input!

 

0 Kudos
Message 3 of 3
(2,756 Views)