Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Reading Internal Tempeature on U3


  • Please log in to reply
13 replies to this topic

#1 amitchell

amitchell
  • Members
  • 11 posts

Posted 15 September 2010 - 09:24 AM

I am having trouble reading the internal temperature of a U3 via the Python driver. This is something I have successfully done on an older LabJack running with an older Labjack Python driver. With the problem setup, I get an accurate temperature reading using the LJControlPanel utility. But the following code gives me a reading of about 0.878 instead of a temperature value in degrees K: import u3 dev = u3.U3() print dev.getAIN(30) I even tried resetting to Factory defaults before reading channel 30, using the setDefaults() method. I just reinstalled the newest LabJack Python driver, 7_20_2010 with the same result. Thanks for any help you can give. --Alan

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 15 September 2010 - 10:05 AM

We added a getTemperature() method to the U3 class. It's' on the bleeding edge, not the 7/20 release, so please download the latest source. (We're going to package the latest source into another release on Monday, 9/20.) Now you can do:

>>> import u3
>>> d = u3.U3()
>>> d.getTemperature()
299.52797377109528

I'm not sure, but you may want to add a call to getCalibrationData(), as in

>>> d.getCalibrationData()
>>> d.getTemperature()
299.52797377109528

I didn't make a difference for me. In the U6 and UE9 class, we decided to always read the device's calibration constants before getting the temperature. I don't know if we do on the U3, or if we don't why not.

#3 amitchell

amitchell
  • Members
  • 11 posts

Posted 15 September 2010 - 10:39 AM

Just to be clear, is there a bug in the 7-20-2010 Labjack Python driver (or somewhere else) that is causing my getAIN(30) approach not to work? If so, will that be fixed in a later release of the driver, as I have some code out there using getAIN(30) that will break if I upgrade the Python driver and a bug exists.

#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 15 September 2010 - 11:25 AM

Just to be clear, is there a bug in the 7-20-2010 Labjack Python driver (or somewhere else) that is causing my getAIN(30) approach not to work? If so, will that be fixed in a later release of the driver, as I have some code out there using getAIN(30) that will break if I upgrade the Python driver and a bug exists.


It sounds like there is a backwards incompatibility between your older Python module and the current LabJackPython. I don't know when getAIN(30) returned Kelvin, but it was before my time. I'm afraid you'll have to update your code to call getTemperature(). In the current version of LabJackPython, you can't call getAIN() because it applies the wrong calibration constants for temperature. Your older Python module must have made a special case for channel 30.

The current version of getTemperature() is simple, and it does call getCalibrationData() for you.

def getTemperature(self):
		"""
		Name: U3.getTemperature()
		
		Args: None
		
		Desc: Reads the internal temperature sensor on the U3. Returns the
			  temperature in Kelvin.
		"""
		
		# Get the calibration data first, otherwise the conversion is way off (10 degC on my U3)
		if self.calData is None:
			self.getCalibrationData()

		bits, = self.getFeedback( AIN(30, 31) )
		
		return self.binaryToCalibratedAnalogTemperature(bits)


#5 amitchell

amitchell
  • Members
  • 11 posts

Posted 15 September 2010 - 11:36 AM

The getAIN(30) code that worked and returned Kelvin was done in the May 2010 timeframe and used the drivers current then. You may want to rewrite the U3 docs as the current docs imply that you read channel 30 and it returns temperature in degrees K. My assumption was that the channel 30 read worked through the Python interface as well. It certainly will be easy to use the getTemperature method, and I will do so from now on out.

#6 amitchell

amitchell
  • Members
  • 11 posts

Posted 15 September 2010 - 11:45 AM

One other question: Will there be any changes to the Python driver source code between now and 9/20? Just wondering if I need to wait til the 20th before upgrading.

#7 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 15 September 2010 - 12:07 PM

The getAIN(30) code that worked and returned Kelvin was done in the May 2010 timeframe and used the drivers current then.


My mistake. I didn't know that. Sorry for the confusion.


You may want to rewrite the U3 docs as the current docs imply that you read channel 30 and it returns temperature in degrees K. My assumption was that the channel 30 read worked through the Python interface as well.


I just pushed up a change that removed a docstring example that read from AIN 30. Are there others that I'm missing.


It certainly will be easy to use the getTemperature method, and I will do so from now on out.


Thank you.

One other question: Will there be any changes to the Python driver source code between now and 9/20? Just wondering if I need to wait til the 20th before upgrading.


No, not to u3.py. The SkyMote module is under heavy development, and it is changing every day.

#8 amitchell

amitchell
  • Members
  • 11 posts

Posted 15 September 2010 - 01:02 PM

As far as the documentation, I was mostly thinking of the statement in the U3 User's Guide at 2.6.4:

"With the UD driver, the internal temperature sensor is read by acquiring single-ended analog input channel 30, and returns degrees K.



#9 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 16 September 2010 - 09:04 AM

As far as the documentation, I was mostly thinking of the statement in the U3 User's Guide at 2.6.4:

"With the UD driver, the internal temperature sensor is read by acquiring single-ended analog input channel 30, and returns degrees K.


Thanks a bunch for reminding me of that passage in the User's Guide.

We discussed this matter, and we decided that in a future LabJackPython release (not 9/20) we're going to match the way the UD driver handles special channels (like channel 30 on the U3 for internal temperature).

You'll be fine because you're using getTemperature(), but I thought you'd like to know that getAIN(30) will work as you expected someday.

#10 Efried

Efried
  • Members
  • 20 posts

Posted 07 December 2010 - 03:49 AM

As far as the documentation, I was mostly thinking of the statement in the U3 User's Guide at 2.6.4:

"With the UD driver, the internal temperature sensor is read by acquiring single-ended analog input channel 30, and returns degrees K.


Thanks a bunch for reminding me of that passage in the User's Guide.

We discussed this matter, and we decided that in a future LabJackPython release (not 9/20) we're going to match the way the UD driver handles special channels (like channel 30 on the U3 for internal temperature).

You'll be fine because you're using getTemperature(), but I thought you'd like to know that getAIN(30) will work as you expected someday.



I find that a waste of time - a lot of documentation spread accross servers...
For me it does not work:

The U3B returned an error:
INVALID_BLOCK

lowlevelerrorexception in checkCommandBytes

It would be really good to have a syntax description of the high level functions and also defining on what firmware revision they work....

I'm wasting to much time!

thanks

#11 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 07 December 2010 - 12:59 PM

Download and install the latest LabJackPython on github. I fixed the "INVALID_BLOCK" exception so that getTemperature() works on all U3 hardware versions. The exception was caused by calibration data reads. When reading the memory blocks where the calibration data is located, the code accesses blocks that only exist on hardware version 1.30 (U3C) causing "INVALID_BLOCK" errors on older hardware versions. These errors are now taken into account.

#12 Efried

Efried
  • Members
  • 20 posts

Posted 08 December 2010 - 03:14 PM

Download and install the latest LabJackPython on github. I fixed the "INVALID_BLOCK" exception so that getTemperature() works on all U3 hardware versions. The exception was caused by calibration data reads. When reading the memory blocks where the calibration data is located, the code accesses blocks that only exist on hardware version 1.30 (U3C) causing "INVALID_BLOCK" errors on older hardware versions. These errors are now taken into account.


Thanks a lot - very fast response indeed.

Do you have a proposal fpr project management - donwloading via git needs to remove the directories in which my scripts do reside...
There could be also a *.sh doing the download and compilation of LabJackPython.
Last but not least a Python interface restrieving the syntax would be great like

help(getAIN)

thanks

#13 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 08 December 2010 - 04:31 PM

What git command are you using to get the LabJackPython files? I believe using the "git pull" git command should only merge changes and not delete files/directorys not in the LabJackPython repository, so give that a try. Here's a Git cheat sheet found on github, http://help.github.c...t-cheat-sheets/ , that has a list of helpful commands.

As for using help, it can be used with LabJackPython after you import the module. For example, help on getAIN would look like this:

import u3
help(u3.U3.getAIN) #help(module.class.function)

or

import u3
u3Class=u3.U3
help(u3Class.getAIN)

#14 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 08 December 2010 - 04:57 PM

I also updated the u3.py file in the LabJackPython repository again to fix a syntax error in the new code. The syntax was Python 2.6+ friendly, but not backwards compatible with Python 2.5.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users