Problema con codigo para traer datos de temperatura

Hola tengo un codigo en Mikropascal que estoy tratando que ande el codigo y circuito se trata de un termometro el problema es que al simularlo solo me trae el valor 0 me gustaria poder traer valores reales de temperatura pero creo que no estoy al nivel de este codigo por mas que es pequeño! si me dan una mano para saber que tengo que hacer estare muy agradecido!

adjunto simulacion y codigo amigos del foro!

Código:
program termometro877;

var i, j1, j2, por1, por2: byte;
var text : array[20] of char;

// LCD module connections
var LCD_RS : sbit at RB4_bit;
var LCD_EN : sbit at RB5_bit;
var LCD_D4 : sbit at RB0_bit;
var LCD_D5 : sbit at RB1_bit;
var LCD_D6 : sbit at RB2_bit;
var LCD_D7 : sbit at RB3_bit;

var LCD_RS_Direction : sbit at TRISB4_bit;
var LCD_EN_Direction : sbit at TRISB5_bit;
var LCD_D4_Direction : sbit at TRISB0_bit;
var LCD_D5_Direction : sbit at TRISB1_bit;
var LCD_D6_Direction : sbit at TRISB2_bit;
var LCD_D7_Direction : sbit at TRISB3_bit;
// End LCD module connections


begin
text := 'Temperature:';
PORTB := 0; // initialize PORTB to 0
PORTA := 255; // initialize PORTA to 255
TRISB := 0; // PORTB is output
TRISA := 255; // PORTA is input
LCD_Init();                   // init LCD on PORTB (for EasyPIC3 or lower)
LCD_Cmd(_LCD_CURSOR_OFF);     // turns of LCD cursor
LCD_Out(1, 1, text);
repeat
begin
OW_Reset(PORTA,5); // 1-wire reset signal
OW_Write(PORTA,5,$CC); // issue command to DS1820
OW_Write(PORTA,5,$44); // issue command to DS1820
Delay_us(120);
i := OW_Reset(PORTA,5);
OW_Write(PORTA,5,$CC); // issue command to DS1820
OW_Write(PORTA,5,$BE); // issue command to DS1820
Delay_ms(1000);
j1 := OW_Read(PORTA,5); // get result
j2 := OW_Read(PORTA,5); // get result
j1 := j1 shr 1; // assuming the temp. >= 0C
ByteToStr(j1, text); // convert j1 to text
LCD_Out(2, 8, text); // print text
//LCD_Chr(2, 10, 223); // 'degree' character
//LCD_Chr(2, 11,'C');
Delay_ms(500);
end;
until false; // endless loop
end.
ver
 

Adjuntos

  • Sin título.gif
    Sin título.gif
    268.1 KB · Visitas: 8
Atrás
Arriba