Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

NI DAQmx, cDAQ 9174, Python. Variables in .Task

I'm writing a real time plotting program to record from pressure and temperature cards in four separate cDAQ 9174 modules. The user selects which module, then which pressure and temperature inputs they would like to plot and record. I have a GUI thread to run the user/program interaction, and a worker thread to read the inputs from the modules and emits them back. The GUI thread builds the channel ID and saves it to a dictionary, then the worker thread reads from the dictionary to enter the channel ID as a variable.

 

with nidaqmx.Task() as task:

                       for i in channel_list_dict:

                       cha_id = channel_list_dict.get(i)

 

1) task.ai_channels.add_ai_voltage_chan("cDAQ4Mod1/ai2")

2) task.ai_channels.add_ai_voltage_chan(cha_id)

 

The problem I'm having is when I enter the values as in (1), everything works properly. When I enter the channel as a variable as in (2), the worker thread freezes at that line. No errors are called. The GUI thread keeps working.

 

Does the NI DAQmx not accept variables for channel IDs? Or am I inputting it incorrectly so it doesn't understand what I'm asking?

 

Any solution or ideas would be greatly appreciated.

0 Kudos
Message 1 of 2
(921 Views)

I figured out what I did wrong. I had a typo in my string concatenation. Classic rookie mistake. 🙄

0 Kudos
Message 2 of 2
(869 Views)