09-19-2021 11:44 PM
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.
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()
09-19-2021 11:56 PM
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?
Can you share your exact wiring to be sure how you connected? some pictures or a simple wiring drawing (exactly how things are connected)
09-20-2021 12:20 AM - edited 09-20-2021 12:29 AM
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.