|
|
View previous topic :: View next topic |
Author |
Message |
rrb011270
Joined: 07 Sep 2003 Posts: 51
|
Anybody has a driver for LM75 Temp Sensor |
Posted: Thu Oct 02, 2003 5:00 am |
|
|
Mabuhay!
Anybody in the community has done a drvier/libraries for LM75 temperature sensor?
Thnx |
|
|
TSchultz
Joined: 08 Sep 2003 Posts: 66 Location: Toronto, Canada
|
|
Posted: Thu Oct 02, 2003 5:52 am |
|
|
This should give you a good start, this is the routine I use for the LM74, the SPI version. There is some extra code in there since this project had all the addressing handled by an external CPLD, there were 16 total devices on the SPI port, some of which did not tri-state when not enabled.
The LM75 is an I2C device, so you will have to address and read the data from the sensor differently.
<pre>
/****************************************************************************
Routine to read LM74 temperature sensor.
Temperature sensor output is read as 16bit value, actual temp = value/128. Temperature is a global variable.
*****************************************************************************/
void ReadTemperature( void ){
PORTD_WRITE; //data port direction
PORTD = 0b00001010; //set data and address bits for CS_TEMP
STROBE = 1; //set STROBE
setup_spi( SPI_MASTER|SPI_CLK_DIV_16|SPI_L_TO_H|SPI_SAMPLE_AT_END|SPI_XMIT_L_TO_H );
Temperature = make16( spi_read( 0x00 ), spi_read( 0x00 ) );
STROBE = 0;
PORTD_READ; //data port direction
}
</pre> |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Thu Oct 02, 2003 7:18 am |
|
|
I never though about dynamicaly changing the SPI configuration. Thats something to remember. |
|
|
claude Guest
|
i have made a program witch succesfully uses an lm75. |
Posted: Sun Nov 19, 2006 11:44 am |
|
|
i like to modify the following program to use more than 24 sensors, if someone has an idea, i'l be glad to listen to. Code: | #include <16F870.h>
#use delay(clock=4000000)
#fuses XT,NOWDT,PUT,NOPROTECT,BROWNOUT,NOLVP,NOCPD,NOWRT,NODEBUG
#define SDA_PIN PIN_C2 // i2c serial data in/out
#define SCL_PIN PIN_C3 // i2c serial clock
// Variabile pentru citire LM75
int8 dataH,dataL,current_temp, max_temp, min_temp;
int1 flgSign;
char txt;
#define p1 PIN_A3 //push button for temperature reset
#define p4 PIN_A0
#define buz PIN_A4 //buzzer
#define fan PIN_A5
#use i2c(master,sda=SDA_PIN, scl=SCL_PIN)
void i2c_init(void)
{
output_high( SCL_PIN );
output_high( SDA_PIN );
}
void lm75_start(void)
{
i2c_start();
i2c_write(0x90);
i2c_write(0x01); // Pointer Byte
i2c_write(0x00); // Configuration Byte (operating)
i2c_stop();
}
void lm75_setandread(void)
{
i2c_start();
i2c_write(0x90);
i2c_write(0x00); // Pointer Byte
i2c_start();
i2c_write(0x91);
dataH = i2c_read(); // with ACK
dataL = i2c_read(0); // with NOACK
// dataL &= 0x80; // // D6-D0 sunt undefined
i2c_stop();
}
#include <lcdme.c>
void sounds() {
output_low(buz);delay_ms(20);
output_high(buz);delay_ms(20);
output_low(buz);delay_ms(30);
output_high(buz);delay_ms(30);
output_low(buz);delay_ms(40);
output_high(buz);delay_ms(40);
output_low(buz);delay_ms(50);
output_high(buz);delay_ms(50);
output_low(fan);
}
void reset_temp() {
current_temp = dataH;
min_temp=current_temp;
max_temp=current_temp;
}
main() {
i2c_init();
delay_ms( 10 );
lcd_init();
reset_temp();
txt=223;
while(1)
{
lm75_start();
delay_ms( 30 );
// lm75_read();
lm75_setandread();
// lm75_shutdown();
delay_ms( 100 );
// Stabileste valoarea/semnul temperaturii (in 0,5 grade Celsius)
flgSign = 0;
if( bit_test( dataH, 7 ) ){ // semn negativ (bit-ul 7 setat)
flgSign = 1;
dataH = ( 0xFF - dataH + 1 );
}
dataH = ( dataH <<1>max_temp) max_temp=current_temp;
else if(current_temp<min_temp>=27) sounds();
else {output_high(buz);output_high(fan);}
lcd_gotoxy(1,1);
printf(lcd_putc,"%u %cC" ,min_temp,txt);
lcd_gotoxy(6,1);
printf(lcd_putc,">%u" ,dataH);
lcd_gotoxy(1,2);
printf(lcd_putc,"< %u %cC" ,max_temp,txt);
if (!input(p4)) {lcd_gotoxy(1,1);printf(lcd_putc, "Claudiu ");
lcd_gotoxy(1,2);printf(lcd_putc, "Godinel ");
output_high(buz);}
delay_ms(250);
}}
|
|
|
|
Guest
|
|
Posted: Tue Sep 15, 2009 4:15 pm |
|
|
i used this driver code ... but my LM75 seems to heat it self (first temp. data is correct... (same as bimetalic thermometer) then every another is larger (for example in room there is 20 C . first reading gives 20.06 next, 20.13, 20.22 ... till 29... then it stops and only oscilating around 29).
... anybody knows why? |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Tue Sep 15, 2009 11:56 pm |
|
|
Self-heating of LM75 in normal operation can be estimated from the datasheet 0.35 mA * 5 V * 200 °C/W = 0.35 °C, reducable to effectively nothing if the device is kept in shutdown most of the time.
So, if you didn't manage to cause excessive power dissipation of the LM75 somehow, it should be expected, that the observed 9°C overtemperature is caused by other part's power dissipation, e.g. voltage regulator, µP, whatever. Not a LM75 problem, actually. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1938 Location: Norman, OK
|
|
Posted: Wed Sep 16, 2009 2:11 pm |
|
|
For the Maxim version the datasheet predicts very low self heating (0.2 degrees C) in normal operation and I have never encountered this problem when using the Maxim LM75. Is it possible your power supply is too high or something else is heating it? _________________ Google and Forum Search are some of your best tools!!!! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|