labjack/labjack-ljm-python

Getting bad voltage readings with ljm.eReadName until I open ljStream

Closed this issue · 4 comments

When I first start my python IDE and run my code the voltage reading on my thermocouple is ~1.7 volts. If I close my program, start ljstream (without loading anything), wait for the voltage readings come in then close out ljstream I get ~ 8e-05 volts. The second value is the expected voltage as my thermal couple is close to room temp. Is there some initializing I need to do in my code? Here is the relevant code:

class labControl:
    
    def __init__(self):
        self.handle = ljm.openS("T7", "ANY","ANY")
        
        info = ljm.getHandleInfo(self.handle)
        print("\nOpened a LabJack with Device type: %i, Connection type: %i,\n"
              "Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" %
              (info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5]))
    
    def thermo(self,channel,cj,cal_data):
        volts = ljm.eReadName(self.handle, channel)
        # Sometimes this reading is way off and I dont know why. Opening and starting then closing lj-stream seems to clear it
        print(volts)
        mV = volts * float(1000)

By running ljStream do you mean our LJStreamM application or one of our stream Python examples?

The issue here should not be related to the Python wrapper, but rather some configuration issue. I would recommend backing up and doing some basic testing. We recommend you start by testing in our Kipling software before moving on to testing using your preferred software. Similarly, we recommend testing without any external connections before troubleshooting with external signals.

  1. Remove all external connections from the T7 besides USB and/or Ethernet. Try the basic tests described on the following page using Kipling. The dashboard and Analog inputs tab of Kipling show AIN readings:
    https://labjack.com/support/app-notes/test-AIN
  2. Try the basic AIN tests using your software/script instead of Kipling. Do you see correct readings? If you did see correct readings in Kipling but not in your software, there is likely some issue in your software configuration. In that case, please provide more information about what you are running in Python. Try modifying one of our basic examples such as eReadName.py to read the AIN.
  3. Connect a single thermocouple to test. If 1 and 2 seem okay but you are still seeing poor thermocouple measurements, troubleshoot hardware: How do you have the thermocouple connected? See our thermocouple troubleshooting:
    https://labjack.com/support/app-notes/thermocouples#Troubleshooting

This is almost certainly not an issue or bug in labjack-ljm-python. Instead, it appears to be some configuration or hardware problem. In the future, please direct any general support inquiries to us (LabJack) via one of the contact methods described on our website such as email (support@labjack.com) or live chat:
https://labjack.com/contact

The line volts = ljm.eReadName(self.handle, channel) gives a different result depending if I have ran the LJStreamM application on my computer or not before I run my script. This issue normally arises first thing in the morning when I haven't been using my computer for a number of hours. If I start the LJStreamM program first thing in the morning I will get good readings all day. And by running LJStreamM I mean opening it, seeing the voltage readings and closing it out. I will see wrong readings in my python software, open and close LJStreamM(see correct readings) and then see good readings in my python software. Regardless of what I do the python script connects to the T7 Pro and reads out the correct serial number.

Am I supposed to start kipling or LJStreamM before I use python script to access the T7 readings?

No, you do not need to run other software before using our Python wrapper. These other software should also not typically affect operation in Python. Kipling allows you to change settings such as the analog input resolution, but you would have to change those explicitly.

Getting a decent reading after running LJStreamM does not really tell us anything definitive to help isolate the core issue. I would recommend trying the previously suggested troubleshooting.

Something else I would recommend is that you upgrade firmware and LJM if you are on an old version. Firmware can be updated using the device updater tab in Kipling. Our LJM installers are on the following page:
https://labjack.com/support/software/installers/ljm

I am going to close this issue. If your problem persists, please contact LabJack support:
https://labjack.com/contact