Using the LM75 with an 8-bit microcontroller I2C interface:
The LM75 was created by National Semiconductor Corporation to fill a crying need in the PC industry for detecting over temperature conditions in a personal computer. This device has a built-in 9 bit ADC that will convert the analog thermal reference to a digital value usable by the PC. But for this document we are going to explore how to access this device using a Atmel 89C51 flash microcontroller. I2C interface (created by the Phillips Communication with the LM75 is through the Corporation).
This is a 2-wire communications protocol used to communicate serially with various types of devices similarly configured. The LM75, designed as a ‘slave’ device, can be configured through the I2C interface to alert, through various methods, the PC system that an over temperature condition has happened. The LM75 Datasheet will, at all times, be the sole authority. If there is a conflict of information, the LM75 Datasheet will be considered the correct source.
The Lm75 has four registers that you can read and write to, depending upon what you want the device to do. Mostly though, you will be reading the temperature. Upon power up the device is set to the default mode:
TOS = 80°C
THYS = 75°C
O.S. Active Low
Pointer = “00”
the waveforms clearly delineate, as two 8-bit words, in high byte, low byte, order. So most people make the I2C function when communicating with the mistake of using the read word or write word LM75. Although the registers are 16-bit, the access method is 8-bit.
The temperature register is 16 bits wide. Only bits D7 through D15 mean anything. The High Byte of the temperature word contains the Sign bit (D15) and the whole value temperature, and the Low Byte contains the fractional temperature (D7). The rest of the bits in the Low Byte have no meaning (D0 to D6).
To read the LM75 temperature will require sending the address and read command to the LM75 and then reading the High Byte and then the Low Byte. In addition, the temperature data is in two’s compliment form. This means that when the temperature goes below 0°C the sign bit is set and the data is now a two’s compliment of the actual temperature value.
Two’s compliment simply means that the information is negated. As an example, zero is the compliment of one, and one is the compliment of zero. The compliment of falling down is falling up. The math for it though is a little tricky. In doing the math we loose 1 LSB, so it must be replaced when converting back.
The compliment to 00011001 (Hex 19) is 11100111 (Hex E7). But if we negate 11100111 we get 00011000 (Hex 18). But we know that we lost 1LSB when the conversion was performed, so we just add it back. So 00011000 (Hex 18) +1 gives us 00011001 (Hex19), the original number.
other useful projects are:-
LM75 Temperature Sensor with 7 segment display output
PIC MICROCONTROLLER 16F877A SCHEMATIC including the interfacing of LM35
adc/dac interfacing with pic microcontroller
practicle implementation of temperature sensor LM35
PIC wireless (RF) monitoring