Hi everyone,

I am reading two AD7291 built-in temperature sensor but I obtain very high values that oscillates 4 Celsius.

I am reading the two AD7291 using python from a Raspberry. This is the code:

while (1==1):

Tav = 256.0*((av & 0x00FF) - 144.0) + ((av & 0xFF00) >> 8)/4.0   # Para el no average es 128 en lugar de 144

Tac = 256.0*((ac & 0x00FF) - 144.0) + ((ac & 0xFF00) >> 8)/4.0   # Para el no average es 128 en lugar de 144

Tv = 256.0*((bv & 0x00FF) - 128.0) + ((bv & 0xFF00) >> 8)/4.0   # Para el no average es 128 en lugar de 144

Tc = 256.0*((bc & 0x00FF) - 128.0) + ((bc & 0xFF00) >> 8)/4.0   # Para el no average es 128 en lugar de 144

time.sleep(1)

print 'Tav = ' + str(Tav)+' (0x'+ format(av,'02x')+')'

print 'Tac = ' + str(Tac)+' (0x'+ format(ac,'02x')+')'

print 'Tv  = ' + str(Tav)+' (0x'+ format(av,'02x')+')'

print 'Tc  = ' + str(Tac)+' (0x'+ format(ac,'02x')+')'

print

and this is the result:

Tav = 54.75 (0xdb90)

Tac = 54.0 (0xd890)

Tv  = 54.75 (0xdb90)

Tc  = 54.0 (0xd890)

Tav = 56.75 (0xe390)

Tac = 56.0 (0xe090)

Tv  = 56.75 (0xe390)

Tc  = 56.0 (0xe090)

Tav = 52.25 (0xd190)

Tac = 52.25 (0xd190)

Tv  = 52.25 (0xd190)

Tc  = 52.25 (0xd190)

Tav = 56.0 (0xe090)

Tac = 56.0 (0xe090)

Tv  = 56.0 (0xe090)

Tc  = 56.0 (0xe090)

Tav = 55.75 (0xdf90)

Tac = 57.25 (0xe590)

Tv  = 55.75 (0xdf90)

Tc  = 57.25 (0xe590)

Tav = 56.75 (0xe390)

Tac = 56.75 (0xe390)

Tv  = 56.75 (0xe390)

Tc  = 56.75 (0xe390)

Tav = 53.5 (0xd690)

Tac = 53.5 (0xd690)

Tv  = 53.5 (0xd690)

Tc  = 53.5 (0xd690)

Tav = 55.25 (0xdd90)

Tac = 55.25 (0xdd90)

Tv  = 55.25 (0xdd90)

Tc  = 55.25 (0xdd90)

I verified that I2C signals reach the AD7291 and the Raspberry correctly.

Questions:

* Am I doing the calculation correctly? --> 0xE290 means 56.5 Celsius (0xE290 --> T = 0x0E2 / 4 = 56.5 Celsius)?

* Why I have such a unstable temperature reading?

Thank you very much in advance

Regards

GuiX

• Activating "Noise-delayed" bit I have same behavior.

any hint will be really appreciated.

Best regards

GuiX

• Hi GuiX,

Can you please simplify your question so I can understand it better? I'm having confusions reading the program.

How did you get the 0XE290 be 56.5 Celsius? Also, can you share me your schematic so I can understand the problem better?

Best Regards,

May

• Hi May,

I will try to explain better my procedure to read the temperature:

1.- I have to AD7291 in the same I2C bus with addresses 0x20 and 0x2F.

2.- The I2C bus is connected to and Raspberry I2C bus and I can see the devices using "i2cdetect -y 1" in the command line.

3.- To read the temperature of both sensors I use a python program.

3.1.- I write in the configuration register to set the temperature reading and to activate "Noise-delayed" (D7 =1 and D5 = 1 --> 0xA000, table 10 in the datasheet):

3.2.- Then, I read the average temperature (address 0x03, table 9 in the datasheet)

3.3.- In hexadecimal format av is around 0xE290 (for example), I should reorganize the words to 0x90E2 and remove the "9" that indicates that the reading corresponds to the averaged temperature sensor (I keep 12 bits) --> 0x0E2 = 226 in decimal format. Now I must apply the formula "ADC Code / 4" (page 14 in the datasheet) --> 226 / 4 = 56.5 Celsius. In my python program I use (assuming av = 0xE290):

av & 0x00FF - 144 = 0x90 -144 = 0x0 --> subtracting 144 decimal I remove the "9"

av & 0xFF00 >> 8 = 0xE200 >> 8 = 0xE2--> moving 8 bits to the left I remove the "00"

The code is:

Tav = 256.0*((av & 0x00FF) - 144.0) + ((av & 0xFF00) >> 8)/4.0

4.- The results I obtain are not stable:

Tav = 54.75 (0xdb90)

Tav = 56.75 (0xe390)

Tav = 52.25 (0xd190)

Tav = 56.0 (0xe090)

Tav = 55.75 (0xdf90)

Tav = 56.75 (0xe390)

Tav = 53.5 (0xd690)

Tav = 55.25 (0xdd90)

5.- This is the schematic:

5.1.- JP10 and JP11 are closed (short circuited)

5.2.- JP12 and JP13 are open (not installed)

5.3.- R116, R117 are 0 Ohms

5.4.- Only pins 2, 3, 4, 5 and 6 are wired to the RapsBerry

5.5.- 3P3V signal came from a linear regulator and provides 3.3 V

5.6.- RaspBerry i2c signals are 3.3 V.

Any hint will be really appreciate.

Best regards

GuiX

• Hello GuiX,

the code you use for calculation of temperature value is somwhat confusing, though it may nevertheless work when reading positive temperatures from TSense average register (giving highest Nibble=9). At least I doubt, that it would give a correct sign extension in case you work with negative temperatures.

The code is:

Tav = 256.0*((av & 0x00FF) - 144.0) + ((av & 0xFF00) >> 8)/4.0

But this is not causing the strange values you observe when reading out the TSense-Register. If I'd be in your case I would check the following:

1) are supplies at the AD7291 stable? Is Vref stable and at the expected value (2,5V)?

2) are the various GND-nets on your PCB at the same potential (GND_1 and AD7291_GND)

3) does the temperature readout react at all on the chip temperature (spray on some icespray and tell us how the temperature readout behaves)

.

• Hi GuiX,

The AD7291 contains 34 internal registers that are used to store conversion results, high and low conversion limits, and information to configure and control the device. I can see that you have configured the command register to enable Tsense and Noise-delayed bit trial and sampling.

From what I can see, you are reading the Tsense average result, i.e at 0X03 register address of AD7291. This register stores the average temperature  readings from the ADC in an 11-bit twos complement format, D11 to D0, and uses Bit D15 to Bit D12 to store the channel address bits.

I would like to clarify that from your example, 0XE290 does not have valid channel address bits since D15 to D12 used is 1110. The correct address bits for Tsense average result is 1001 (Please see Table 16, page 19). The remaining 12bits is the Tsense average result data (D11 to D0) and is the ADC code you use in the formula given at the Temperature Value Format Section of the datasheet (page15) in computing for the temperature results in Celsius.