LabjackPython giving unstable analog input readings | LabJack
 

LabjackPython giving unstable analog input readings

3 posts / 0 new
Last post
cherring
cherring's picture
LabjackPython giving unstable analog input readings

Hi all,

I am using a labjack EU9 to read two analog voltages. One is the voltage directly output from a 3.3v regulator (henceforth reference), the other is the voltage from an NTC thermistor voltage divider (via a unity gain OPAMP buffer) - henceforth called signal.

I have a python script using the eu9 library from the UD Driver which just reads the ADC for each analog input, converts it to a voltage and prints it to console every time I press the any key. I also have some test code that is reading the voltage using getAIN().

The problem that I am having is that the signal voltage that I read is extremely noisy. The reference voltage however is very stable and accurate. I believe the problem lies in my python code as when I open LJControlPanel, the signal voltage shown is spot on what my (calibrated) multimeter reads. I have tried physically switching the analog inputs, however the reference voltage is always good and the signal voltage is always bad regardless of which analog input I use.

LJControlPanel Test Screen: (signal voltage matches multimeter to the mV)

http://imgur.com/a/FGINI

The Circuit:

Four connection go to the Labjack, Vcc and ground go to the labjack VS and GND pins. Sig goes to AIN3 and Vref goes to AIN2

https://i.imgur.com/OwbSuiq.jpg

My Code:


import ue9
import sys
import time


def main():

# Create an instance of the labjack
try:
lj_UE9 = ue9.UE9()
except:
print "Failed to find or connect to the labjack."
safe_exit()

print "Connected to labjack device: \n{}".format(lj_UE9.getCalibrationData())

AIN_reference = 3
AIN_thermistor_divider = 2

while True:
batman_is_a_jerk = raw_input("Press any key to take a reading, 'q' to exit.\n")
if batman_is_a_jerk == 'q': break
rawSig = lj_UE9.singleIO(4, AIN_thermistor_divider, BipGain=0x00, Resolution=12, SettlingTime=100000)
time.sleep(0.1)
temp_vSig = lj_UE9.getAIN(AIN_thermistor_divider)
time.sleep(0.1)
rawRef = lj_UE9.singleIO(4, AIN_reference, BipGain=0x00, Resolution=12, SettlingTime=100000)
vRef = lj_UE9.binaryToCalibratedAnalogVoltage(rawRef["AIN%s" % AIN_reference], 0x00, 12)
vSig = lj_UE9.binaryToCalibratedAnalogVoltage(rawSig["AIN%s" % AIN_thermistor_divider], 0x00, 12)

print "ref: {} ({} V)\tsig {} ({} V) -- ({}V)".format(rawRef["AIN%s"%AIN_reference], vRef, rawSig["AIN%s"%AIN_thermistor_divider], vSig, temp_vSig)


lj_UE9.close()




def safe_exit():
print "Exiting..."
sys.exit()

# Entry point when this function is called directly
if __name__ == '__main__':
main()

And output from that code: (note sig should read 1.06V)

Connected to labjack device: 

{'ProAINOffsets': {'0': None, '8': None}, 'DACSlopes': {'1': 837.614071714459, '0': 837.9161202218384}, 'AINSlopes': {'1': 3.9082253351807594e-05, '0': 7.818220183253288e-05, '3': 9.747687727212906e-06, '2': 1.951633021235466e-05, '8': 0.0001576784998178482}, 'TempSlope': 0.012650741264224052, 'ProAINSlopes': {'0': None, '8': None}, 'AINOffsets': {'1': -0.01301439804956317, '0': -0.01243095682002604, '3': -0.013334714574739337, '2': -0.013114978792145848, '8': -5.213795782998204}, 'DACOffsets': {'1': -22.210517883533612, '0': 2.330915938830003}}

Press any key to take a reading, 'q' to exit.

ref: 42400.0 (3.30249440088 V) sig 15120.0 (1.16968393489 V) -- (0.952024684986V)

Press any key to take a reading, 'q' to exit.

ref: 42400.0 (3.30249440088 V) sig 12336.0 (0.952024684986 V) -- (1.0420905815V)

Press any key to take a reading, 'q' to exit.

ref: 42400.0 (3.30249440088 V) sig 12320.0 (0.950773769757 V) -- (1.34981572791V)

Press any key to take a reading, 'q' to exit.

ref: 42416.0 (3.30374531611 V) sig 18720.0 (1.45113986148 V) -- (0.949522854527V)

Press any key to take a reading, 'q' to exit.

ref: 42400.0 (3.30249440088 V) sig 13360.0 (1.03208325966 V) -- (0.950773769757V)

Press any key to take a reading, 'q' to exit.

ref: 42400.0 (3.30249440088 V) sig 19056.0 (1.4774090813 V) -- (1.39985233708V)

Press any key to take a reading, 'q' to exit.

ref: 42400.0 (3.30249440088 V) sig 12256.0 (0.945770108839 V) -- (0.945770108839V)

Press any key to take a reading, 'q' to exit.

ref: 42400.0 (3.30249440088 V) sig 12288.0 (0.948271939298 V) -- (0.948271939298V)

Press any key to take a reading, 'q' to exit.

ref: 42400.0 (3.30249440088 V) sig 12624.0 (0.974541159114 V) -- (0.948271939298V)

Press any key to take a reading, 'q' to exit.

q

Process finished with exit code 0

LabJack Support
LabJack Support's picture
In LJControlPanel your AIN

In LJControlPanel your AIN readings are using resolution 17 (16-bit with minimum noise) and in Python you are using resolution 12. If you change your resolution to 17 in Python for the signal readings, does it match the LJControlPanel readings which are the voltages you expect? 

LabJack Support
LabJack Support's picture
When the UE9 selects an input

When the UE9 selects an input channel some capacitance suddenly gets put onto the line. Try a larger cap in place of the 1 nF. 1-10 µF may improve things.