Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

ni daqmx python - how to get channel configuration

Hi, I wanted to know what is the channel configuration (diff, RSE, NRSE) of the channel I'm working, 'Dev1/ai0'. I want to do this all in python.

On the documentation under the nidaqmx.task.ai_channel there is something called ai_term_cfg

so I suppose thats how you get it, but I don't understand how you use it. I supose you have to create an instance of: nidaqmx._task_modules.channels.ai_channel.AIChannel(task_handle, virtual_or_physical_name), but I don't know what task_handle is, and I've looked a lot a didn´t find anywhere explaining it.

Thank you

 

0 Kudos
Message 1 of 12
(9,582 Views)

Just been working on this same problem, and I know this answer is too late for the OP, but here's how to do this (it may help someone in the future):

 

First of all, when you import nidaqmx, also import the TerminalConfiguration constants file:

import nidaqmx
from nidaqmx.constants import TerminalConfiguration

 

Then create a task/channel object as follows (assumes your NIDAQ is "Dev1" in MAX, and the channel is analog-in 0). The "print(ai_channel.ai_term_cfg)" line below then shows how to read back the configuration of your channel, before you do anything to set it. 

 

with nidaqmx.Task() as task:
    ai_channel = task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
    print(ai_channel.ai_term_cfg)

For example, you may see something like:

 

TerminalConfiguration.DIFFERENTIAL

 

To change the terminal configuration to, for example, NRSE, you should instead create your task as follows:

with nidaqmx.Task() as task:
    ai_channel = task.ai_channels.add_ai_voltage_chan("Dev1/ai0", terminal_config = TerminalConfiguration.NRSE)

 

Message 2 of 12
(9,325 Views)

Hey,

bit late to the party but how can I configurate the Output Terminal to RSE? I know that it is possible to do it in Labview, but i can not find the method in Python.

For Input ist is:

task.ai_channels.add_ai_voltage_chan("Dev1/ai0", terminal_config = TerminalConfiguration.DEFAULT)
 
But for Output:
task_2.ai_channels.add_ao_voltage_chan("Dev1/ao0", terminal_config = TerminalConfiguration.DEFAULT)
does not work
(unexpected argument)
 
Is there an other way to do it?
Thank
0 Kudos
Message 3 of 12
(4,979 Views)

@jo_dkt wrote:

Hey,

bit late to the party but how can I configurate the Output Terminal to RSE? I know that it is possible to do it in Labview, but i can not find the method in Python.

For Input ist is:

task.ai_channels.add_ai_voltage_chan("Dev1/ai0", terminal_config = TerminalConfiguration.DEFAULT)
 
But for Output:
task_2.ai_channels.add_ao_voltage_chan("Dev1/ao0", terminal_config = TerminalConfiguration.DEFAULT)
does not work
(unexpected argument)
 
Is there an other way to do it?
Thank

Do you know if your output supports different terminal configurations? it is not about software but about whether your hardware can do that.

 

Typically, AFAIK, none of the NI DAQs can change their terminal configuration for AO, which means either it is RSE or DIFF and cannot switch.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 4 of 12
(4,974 Views)

Hey Santhosh,

my task is to rewrite a script in Python. The original script was in Labview. I am using a NI USB-6366. In the original Labview script i can configurate the output terminal (see screenshot). I need to set the terminal to RSE. Because it works in Labview it should work in Python to but i am not 100% sure if my Hardware supports output terminal configurations.

 

Thank

jo_dkt

Download All
0 Kudos
Message 5 of 12
(4,949 Views)

Hey,

came to the conclusion that my screenshot is wrong. But i still have to set my Input Terminal to "RSE". With my Code i get the Error ↓.

 

task_2.ai_channels.add_ai_voltage_chan("Dev1/ai0", "DAQmx_Val_Ai", terminal_config = TerminalConfiguration.RSE)
 
i get this error: 
nidaqmx.errors.DaqError: Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
Property: DAQmx_AI_TermCfg
Requested Value: DAQmx_Val_RSE
Possible Values: DAQmx_Val_Diff
Channel Name: DAQmx_Val_Ai
 
Someone knows how to solve it?
Thanks
jo_dkt
0 Kudos
Message 6 of 12
(4,937 Views)

It looks like you have got a misunderstanding about how things were configured in LabVIEW (as per your image)

  1. AI is configured to be "Default" terminal configuration
  2. AO is configured to be "RSE" terminal configuration
  3. Both AI and AO are in different tasks

In your Python script, you've mixed and matched all the above information and ended up with errors.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 7 of 12
(4,930 Views)

Hey Santosh,

thanks for the reply, My Labview screenshot is wrong, I can ignore the output terminal configuration. My Problem is now that i get the mentioned error when setting the AI inputterminal to "RSE".

 

Do you have any idea, how to solve it?

 

Thanks,

jo_dkt

0 Kudos
Message 8 of 12
(4,919 Views)

@jo_dkt wrote:

Hey Santosh,

thanks for the reply, My Labview screenshot is wrong, I can ignore the output terminal configuration. My Problem is now that i get the mentioned error when setting the AI inputterminal to "RSE".

 

Do you have any idea, how to solve it?

 

Thanks,

jo_dkt


Yes, of course, please refer to your device specification to check if really supports "RSE" terminal configuration, I would bet that your device supports only "Differential" input configuration. BTW, what is your device model?

 

The error text is pretty clearly saying that your device supports only "Differential" as the input configuration.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 9 of 12
(4,899 Views)

Hey Santhosh,

thanks for the reply. I am using a NI USB-6366. I guess you are right and the Hardware does not support RSE. We still found a way by wireing the AI0- to the AI GND channel. So we did the same thing but not in the software but in the hardware. 

Thanks for your replys again, they were very helpfull.

 

jo_dkt

0 Kudos
Message 10 of 12
(4,880 Views)