Adafruit_I2C on LTC2991

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
hollla
 
Posts: 5
Joined: Sat May 10, 2014 4:58 am

Adafruit_I2C on LTC2991

Post by hollla »

Hi,

I'm using Adafruit_I2C on a Beaglebone Black.
I connected the LTC2991 via I²c to the BBB and a MMBT3904 to V1, V2 of the LTC299
as seen in http://cds.linear.com/docs/en/datasheet/2991fd.pdf (bottom of page 27).
B and C to V1 and E to V2.

But now I don't know how to get the temperature in Celsius.
That's how fare I got

Code: Select all

#!/usr/bin/python
 
import time
from Adafruit_I2C import Adafruit_I2C

# LTC2991 address
address = 0x48

i2c = Adafruit_I2C( address )

# LTC2991 registers
V1_MSB = 0x0a
V1_LSB = 0x0b
V2_MSB = 0x0c
V2_LSB = 0x0c


# enable all chanals
i2c.write8( 0x01, 0xF8);
# reset V1-V4
i2c.write8( 0x06, 0x00)   
# set V1-V4 to temperature
i2c.write8( 0x06, 0xAA)   
But now I don't know who to check for the data_vaild bit.
Should I read a byte a word or a list from V1, V2 MSB or LSB to get the raw temp data and how to convert it to Celsius.
There I a explanation on page 13 of the linked pdf but I don't get it.

please help

br
Daniel
Attachments
IMG_20140514_150013.jpg
IMG_20140514_150013.jpg (780.24 KiB) Viewed 1624 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit_I2C on LTC2991

Post by adafruit_support_rick »

Does that board have breadboard pin headers on it?

hollla
 
Posts: 5
Joined: Sat May 10, 2014 4:58 am

Re: Adafruit_I2C on LTC2991

Post by hollla »

Do you mean something like this
http://boardzoo.com/index.php/beaglebon ... board.html ?

From the hardware point of view, I think everything is as I should.
The problem is I don't know how to read the temperature from the LTC2991 I²C bus.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit_I2C on LTC2991

Post by adafruit_support_rick »

Just wondering how it connects to the breadboard - it obviously doesn't have through-hole pins - they must be surface-mount.

The datasheet for the chip should tell you what registers to read for the temperature.

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Adafruit_I2C on LTC2991

Post by Franklin97355 »

Are you communicating with the chip at all? If not could we have an extreme closeup of the chip itself?

hollla
 
Posts: 5
Joined: Sat May 10, 2014 4:58 am

Re: Adafruit_I2C on LTC2991

Post by hollla »

@ adafruit_support_rick
The chip is soldered on this adapter board
http://www.proto-advantage.com/store/pr ... id=3100089
which was pretty tricky due to the 0,5mm pin pitch and a soldering iron which was not made for this...

@ franklin97355:
I can communicate with the chip, set register, read register.
The problem is that I don't know what exactly to read and how to transform it to temperature Celsius.

This is from the data sheet
http://cds.linear.com/docs/en/datasheet/2991fd.pdf
Data Format
The data registers are broken into 8-bit upper and lower
bytes. V
oltage and temperature conversions are 13-bits.
The upper bits in the MSB registers provide status on the
resulting conversions. These status bits are different for
temperature and voltage conversions.

Temperature
Temperature conversions are reported as Celsius or Kelvin
results described in Tables 11 and 12, each with 0.0625
degree weighted LSBs. The format is controlled by the
control registers. The temperature MSB result register
most significant bit (Bit 7) is the DATA_VALID bit, which
indicates whether the current register contents have been
accessed since the result was written to the register. This
bit will be set when new data is written to the register,
and cleared when accessed. The LTC2991 internal bias
circuitry maintains this voltage above this level during
normal operating conditions. Bit 4 through bit 0 of the
MSB register are the conversion result bits D[12:8], in
two’s compliment format. Note in Kelvin results, the
result will always be positive. The LSB register contains
temperature result bits D[7:0]. To convert the register
contents to temperature, use the following equation: T =
D[12:0]/16. See Table 16 for conversion value examples.
Remote diode voltage is digitized at ~50μA of bias current.
The ADC LSB value during these conversions is typically
38.15μV. Voltages are only available for the remote diodes,
not the internal sensor. This code repeats at a diode volt
age of approximately 0.3125V (see Tables 13 and 14).
The absolute temperature of the diode can be used to
detect whether the diode is operating (≤0.3125V or
≥ 0.3125V). This mode is useful for testing small relative
changes in temperature using the approximate relation
ship of –2.1mV/°C of voltage dependence on temperature.
With an LSB weight of 38.15μV and a diode temperature
relationship of –2.1mV/°C this yields ~0.018 degree resolu
tion. For sensor applications involving heaters, the ability
to sense small changes in temperature with low noise
can yield significant power savings, allowing the heater
power to be reduced. Table 16 has some conversion result
examples for various diode voltages.
From what I understood I need to add the 5 last bit of the MSB to the 8 bit of LSB to get the 13 result bits.
Should I therefore read the LSB and MSB register with readList or readU8 or readS8
and how to add them.
e.g. result_bits = Adafruit_I2C.readList(MSB_reg, 5) & Adafruit_I2C.readList(LSB_reg, 8)
and then just divide it through 16.
as seen in the datasheet:
equation: T = D[12:0]/16

br

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit_I2C on LTC2991

Post by adafruit_support_rick »

Looks like you could do two readU8 calls:

Code: Select all

msb = Adafruit_I2C.readU8(MSB_Reg)
lsb = Adafruit_I2C.readU8(LSB_Reg)
The high bit of msb is the data-valid bit, so you can check that it's set before doing the conversion

Code: Select all

if (msb & 0x80) 
        temp = (msb * 256) + lsb
        temp = temp & 0xFFF         #temp data is low 12 bits
        if (msb & 0x10)                 #msb bit 5 is the sign bit.  
                temp = temp | 0xF000      #if the sign bit is set, then extend the sign to the left.
I'm not much of a python programmer, but this ought to be at least close.

User avatar
neslekkim
 
Posts: 61
Joined: Tue Apr 24, 2012 4:20 am

Re: Adafruit_I2C on LTC2991

Post by neslekkim »

For others who don't know proto-advantage, they also let you order a board, and enter digikey part number, and they solder everything for you, have used this many times, excellent service.
Funny that Adafruit don't know about this service?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit_I2C on LTC2991

Post by adafruit_support_mike »

Not that unusual really.. we do our own assembly, and encourage others to learn to solder as well. We design our kits with through-hole components for ease of assembly, but SOIC chips and 0805 passives aren't all that much harder to work with.

Assembly houses are good for devices where you know the design is stable, but if you're developing circuits you want to be able to tweak component values and try different solutions. Circuit guru Bob Pease used to say, "my favorite programming language is: SOLDER".

hollla
 
Posts: 5
Joined: Sat May 10, 2014 4:58 am

Re: Adafruit_I2C on LTC2991

Post by hollla »

Thanks for your reply, it helped me to understand the calulation.

This is the code I'm using now, I skipped the sign bit part because this is only used when reading voltage, according to the data sheet.

Code: Select all

#!/usr/bin/python

import time
from Adafruit_I2C import Adafruit_I2C

# LTC2991 address
address = 0x48

Adafruit_I2C = Adafruit_I2C( address )

# LTC2991 registers
MSB_Reg_V1 = 0x0a   # V1
LSB_Reg_V1 = 0x0b   # V1
MSB_Reg_V2 = 0x0c   # V2
LSB_Reg_V2 = 0x0d   # V2
MSB_Reg_V3 = 0x0e   # V3
LSB_Reg_V3 = 0x0f   # V3
MSB_Reg_V4 = 0x10   # V4
LSB_Reg_V4 = 0x11   # V4
MSB_Reg_V5 = 0x12   # V5
LSB_Reg_V5 = 0x13   # V5
MSB_Reg_V6 = 0x14   # V6
LSB_Reg_V6 = 0x15   # V6
MSB_Reg_V7 = 0x16   # V7
LSB_Reg_V7 = 0x17   # V7
MSB_Reg_V8 = 0x18   # V8
LSB_Reg_V8 = 0x19   # V8
MSB_Reg_INT = 0x1a  # internal
LSB_Reg_INT = 0x1b   # internal


Adafruit_I2C.write8( 0x01, 0xF8)    # enable all chanals
#Adafruit_I2C.write8( 0x06, 0x00)    # reset V1-V4
Adafruit_I2C.write8( 0x06, 0xAA)    # set V1-V4 to temperature
Adafruit_I2C.write8( 0x08, 0x00)    # set internal to temperature

msb = Adafruit_I2C.readU8(MSB_Reg_INT)
lsb = Adafruit_I2C.readU8(LSB_Reg_INT)


temp = (msb * 256) + lsb
temp = temp & 0xFFF         #temp data is low 12 bits
#if (msb & 0x10):  #msb bit 5 is the sign bit.
#   temp = temp | 0xF000      #if the sign bit is set, then extend the sign to the left.
temp = temp * 0.0625
print temp
I tried to read V1 as well as INTERNAL but the output is strange:

output from :

while true; do python tmp.py ; sleep 3; done

where
msb = Adafruit_I2C.readU8(MSB_Reg_V1)
lsb = Adafruit_I2C.readU8(LSB_Reg_V1)

243.9375
247.0
251.875
251.75
249.5625
246.1875
246.3125
242.5625
244.25
246.25
242.875
243.25
246.5625
242.5625
240.0625
239.375
243.75
239.75
236.25
240.0
245.1875
245.0625
246.875
244.6875
244.9375
243.875


or when
msb = Adafruit_I2C.readU8(MSB_Reg_INT)
lsb = Adafruit_I2C.readU8(LSB_Reg_INT)

220.0625
50.1875
224.125
237.625
187.0625
213.9375
175.5
55.125
50.9375
15.9375
230.4375
225.5625
249.375
19.9375
166.5

btw. my desk is not burning :)

br

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit_I2C on LTC2991

Post by adafruit_support_rick »

At a guess, I'd say you were reading Kelvin, and you need to apply a calibration factor (See pages 11,12 in the datasheet).
I have no idea why it's so unstable.
The internal temp is even more unstable. I have no guesses about that, either

hollla
 
Posts: 5
Joined: Sat May 10, 2014 4:58 am

Re: Adafruit_I2C on LTC2991

Post by hollla »

ok, thanks for your help

br

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”