From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-23-2020 11:51 AM
Hi everyone ! I am a student and very new to this and am still getting familiar with the basics. I am working on a project with an electronic card.
I have to send some commands on the serial link of the card to activate and deactivate some I/O in order to measure different voltages on the card and to validate some tests. I want to automate these tests using python and the NI-DAQmx Python API.
Currently, I have 28 analog voltages to measure and 2 analog voltages to send that's why I am using the DAQ USB-6218 with its 32 analog inputs and its 2 analog outputs. Also, the input range of 10 V suits me perfectly due to the fact that most of my voltages are between 0 and 10 V.
However, I am getting some issues while measuring analog voltages greater than 5.44 V with my DAQ and the Python API ... for example, if I put a power source of 9 V on the AI4 in RSE MODE (I connected the ground to a AI GND port), when I am using the test panels, I can see my correct voltage but if I use the nidaqmx library on Python and if I am running this code :
import nidaqmx
import time
task_ai4 = nidaqmx.Task() #port 24
task_ai4.ai_channels.add_ai_voltage_chan("Dev1/ai4",terminal_config=nidaqmx.constants.TerminalConfiguration.RSE)
time.sleep(2.0)
voltage_ai4 = task_ai4.read()
print("Tension sur le port AI 4 : ", voltage_ai4)
voltage_ai4 = task_ai4.read()
print("Tension sur le port AI 4 : ", voltage_ai4)
voltage_ai4 = task_ai4.read()
print("Tension sur le port AI 4 : ", voltage_ai4)
voltage_ai4 = task_ai4.read()
print("Tension sur le port AI 4 : ", voltage_ai4)
I get these outputs :
I can't see where the problem comes from ... in fact this code is running perfectly for lower voltages ...
Here, a picture of the test I realised :
I tested for different voltages and if it's greater than 5.44 V I will not get the correct voltage output on my python programm ...
Any help would be greatly appreciated!! Thank you.
Solved! Go to Solution.
07-24-2020 10:30 AM
It sounds to me like maybe your device is defaulting to a +/- 5V input range and you're saturating it by feeding in >5V.
I don't know the Python syntax, but when you add your channel to the task there should be a way to specify a +/- 10V range.
-Kevin P
07-27-2020 02:29 AM
Hi Mr Price,
Thank you a lot for your answer, you are right, I had to add a minimum value and a maximum value in the declaration of the task, it's working perfectly now.
Best regards,
Quertsy