sensor DS1621

Pessoal tudo bem!
Tinha aqui na bancada um sensor de temperatura DS1621 jah a muito,agora querendo fazer alguma coisa com o bichi pesquisando por tudo lado nao achei nada de jeito para me ajudar !
Fiz o seguinte codigo ,mas não funca soh mostra no LCd o numero 235.0 e nao mexe nem que vc o coloca na geladera! qual serà o erro algem tem ideia??
Pessoal dar uma olhda neste codigo pra ver o que esta mal e se possivel correguir por favor!!
desde jah agradeço qualquer ajuda
O codigo..
#include <16f877A.h>
#use delay(clock=4000000)
#fuses XT,NOWDT,NOPROTECT,PUT,NOLVP,NOBROWNOUT
#include <lcd.c>
#include <DS1621.C>//biblioteca DS1621
#use standard_io (b)
//#use standard_io (a)
//#use standard_io(c)
#use standard_io(D)
void main() {
float value;
lcd_init();
delay_ms(50);
init_temp();
while(1) {
value = read_temp();
delay_ms(20);
printf(lcd_Putc,"\f%03.1f",value);
delay_ms(100);
}
}
//A biblioteca pra DS1621
///////////////////////////////////////////////////////////////////////////
//// ////
//// Library for a Dallas 1621 Temperature chip ////
//// ////
//// init_temp(); Call before the other functions are used ////
//// ////
//// d = read_temp(); Read the temerature in degrees (0-255) ////
//// ////
//// ////
//// (C) Copyright 1996,1997 Custom Computer Services ////
//// ////
///////////////////////////////////////////////////////////////////////////
#use i2c(master,sda=PIN_D0, scl=PIN_D1)
void temp_config(byte data) {
i2c_start();
i2c_write(0x90);
i2c_write(0xac);
i2c_write(data);
i2c_stop();
delay_ms(11);
}
void init_temp() {
output_high(PIN_B7);
output_high(PIN_B6);
i2c_start();
i2c_write(0x90);
i2c_write(0xee);
i2c_stop();
temp_config(8);
}
byte read_temp() { ////// Returns degrees F (0-255)
byte datah,datal;
long data;
i2c_start();
i2c_write(0x90);
i2c_write(0xaa);
i2c_start();
i2c_write(0x91);
datah=i2c_read();
datal=i2c_read(0);
i2c_stop();
data=datah;
data=data*9;
if((datal&0x80)!=0)
data=data+4;
data=(data/5)+32;
datal=data;
return(datal);
}
Tinha aqui na bancada um sensor de temperatura DS1621 jah a muito,agora querendo fazer alguma coisa com o bichi pesquisando por tudo lado nao achei nada de jeito para me ajudar !
Fiz o seguinte codigo ,mas não funca soh mostra no LCd o numero 235.0 e nao mexe nem que vc o coloca na geladera! qual serà o erro algem tem ideia??
Pessoal dar uma olhda neste codigo pra ver o que esta mal e se possivel correguir por favor!!
desde jah agradeço qualquer ajuda
O codigo..
#include <16f877A.h>
#use delay(clock=4000000)
#fuses XT,NOWDT,NOPROTECT,PUT,NOLVP,NOBROWNOUT
#include <lcd.c>
#include <DS1621.C>//biblioteca DS1621
#use standard_io (b)
//#use standard_io (a)
//#use standard_io(c)
#use standard_io(D)
void main() {
float value;
lcd_init();
delay_ms(50);
init_temp();
while(1) {
value = read_temp();
delay_ms(20);
printf(lcd_Putc,"\f%03.1f",value);
delay_ms(100);
}
}
//A biblioteca pra DS1621
///////////////////////////////////////////////////////////////////////////
//// ////
//// Library for a Dallas 1621 Temperature chip ////
//// ////
//// init_temp(); Call before the other functions are used ////
//// ////
//// d = read_temp(); Read the temerature in degrees (0-255) ////
//// ////
//// ////
//// (C) Copyright 1996,1997 Custom Computer Services ////
//// ////
///////////////////////////////////////////////////////////////////////////
#use i2c(master,sda=PIN_D0, scl=PIN_D1)
void temp_config(byte data) {
i2c_start();
i2c_write(0x90);
i2c_write(0xac);
i2c_write(data);
i2c_stop();
delay_ms(11);
}
void init_temp() {
output_high(PIN_B7);
output_high(PIN_B6);
i2c_start();
i2c_write(0x90);
i2c_write(0xee);
i2c_stop();
temp_config(8);
}
byte read_temp() { ////// Returns degrees F (0-255)
byte datah,datal;
long data;
i2c_start();
i2c_write(0x90);
i2c_write(0xaa);
i2c_start();
i2c_write(0x91);
datah=i2c_read();
datal=i2c_read(0);
i2c_stop();
data=datah;
data=data*9;
if((datal&0x80)!=0)
data=data+4;
data=(data/5)+32;
datal=data;
return(datal);
}