Low-Level Code Problem | LabJack
 

Low-Level Code Problem

2 posts / 0 new
Last post
RGrunwell
RGrunwell's picture
Low-Level Code Problem

Hi-

I have been trying to use low-level commands to communicate with a U3 and am running into something I cannot understand.

I am attempting to send the AIN command for measuring the internal temperature. The data sent is:
0x39 F8 02 00 3E 00 00 01 1E 1F

The first byte is the 8-bit checksum

This translates to Command sequence F8 02 00 (Destination=1, Cmd Num=15 -> F, DataWords/Ext=0 -> 1 1111 000 -> F8; Number of Data Words = 2;ExtCmdNum = 0)

The next two bytes (3E 00) are the 16-bit checksum

The next 00 is the Echo number

IOType = 01

The next two bytes specify the channel and sampling options. 30 decimal (0x1E) is the internal temperature sensor, and 31 decimal (0x1F) is the internal reference.

This is sent, and the response is:
0xB8 F8 03 00 BC 00 00 00 00 60 5C 00

The first is again the 8-bit checksum (which checks out)

The next three bytes are the Command sequence F8 03 00 (Destination=1, Cmd Num=15 -> F, DataWords/Ext=0 -> 1 1111 000 -> F8; Number of Data Words = 3;ExtCmdNum = 0)

The next is unused = 0x00

The next two bytes (BC 00) are the 16-bit checksum (which checks out)

The ErrorCode is 00

The ErrorFrame is 00

The Echo is 00 (I have verified other numbers as well)

Data: 0x60 5C 00

This is where I'm having troubles. Although warm where I am, I cannot believe the temperature is 0x5C60 on any scale!

What am I doing wrong?

Thanks!

 

LabJack Support
labjack support's picture
The reading from the low

The reading from the low-level command-response is the raw binary value before conversion. Converting 0x5C60 to Kelvin, the uncalibrated reading is about 307.92 K, which is 34.77 C. This is based on U3 Calibration Formula and the nominal Temp Slope documented here:

https://labjack.com/support/datasheets/u3/low-level-function-reference/calibration-constants

For a more accurate conversion, read the calibration constants from the U3 and use its Temp Slope for the conversion.

For a low-level example on reading the calibration constants and converting the temperature with it, see the getCalibrationInfo and getTempKCalibrated functions in u3.c from the C examples in the Exodriver download:

https://github.com/labjack/exodriver/blob/master/examples/U3/u3.c