Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog input on Python NiDaq

I am trying to controlling a NIDAQ 6001 via NI-DAQMx Python API. When trying to collect voltage from AI channel, I encountered wired result.

I let AO0 to output 1 V, and then tell AI0 and AI4 to collect result. 

  • Not wire anything, both channel give random readings
  • Wire AO0 to AI0, AI0 gives random reading within 1-1.2 V, AI4 gives random reading 0.2-0.5 V
  • Wire AO0 to AI4, AI0 gives random within (-1.1)-(-0.6) V, AI4 gives 1.00014 V as expected
  • Wire AO0 to AI0 and AI4, AI0 gives 2.2e-5 V (almost 0), AI4 gives 1.00014 V.

I wonder how I could get AI0 to get correct readings?

Following is the code:

import nidaqmx
import time


Task_AO_Chan0 = nidaqmx.Task()
Task_AO_Chan0.ao_channels.add_ao_voltage_chan('Dev1/ao0')

Task_AI_Chan0 = nidaqmx.Task()
Task_AI_Chan4 = nidaqmx.Task()
Task_AI_Chan0.ai_channels.add_ai_voltage_chan('Dev1/ai0')
Task_AI_Chan4.ai_channels.add_ai_voltage_chan('Dev1/ai4')

Task_AO_Chan0.write(1)

for i in range (0,10):
    time.sleep(0.5)
    out0 = Task_AI_Chan0.read()
    out4 = Task_AI_Chan4.read()
    print(out0,'\t',out4)


Task_AO_Chan0.stop()
Task_AO_Chan0.close()

Task_AI_Chan0.stop()
Task_AI_Chan0.close()
Task_AI_Chan4.stop()
Task_AI_Chan4.close()

0 Kudos
Message 1 of 3
(1,703 Views)

AI0 and AI4 are a differential pair as AI0+ and AI0-, in your code, I don't observe you configuring these two channels as single-ended.

 

Also, have you connected AI GND and AO GND together?

 

santo_13_0-1632113697633.png

 

Can you share your exact wiring to be sure how you connected? some pictures or a simple wiring drawing (exactly how things are connected)

 

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 2 of 3
(1,699 Views)

Thank you for the prompt reply!

Yes connecting the GND of AO and AI0/4 helps, but AI0 still have larger errors than AI4. 

In the following figure, if I set AO0=0.2V, then

            the black+red connection gives AI0 = 0.22-0.27 V

            the black+green gives AI4 = 0.20004 V

It may due to the AI0 and 4 should be set to single-ended. Sorry I did not know that and wonder how the code should be written. 

santo_13_0-1632113697633.png

0 Kudos
Message 3 of 3
(1,679 Views)