lampaloon
Newbie level 4
hey~~~i need a help..~i had write the programming code for lm35DZ,but i cnt get the expected result.when i connect the lm35dz with pic, the temperature value was changed contineusly and the result value was wrong. even though i take out the lm35DZ, the lcd display also will display the temperature value~~so weird~~
here is my code:
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
Low PORTE.1
temp var word
temperature var word
lm35 var PORTA.0
TRISA = %11111111
ADCON1= %10001110
Pause 100
Lcdout $fe, 1
main:
Lcdout " Automated H&T "
Pause 500
Lcdout $fe, $c0, "Control System"
Pause 500
Again:
ADCIN lm35, temp
pause 500
temperature=(temp*5000)*/1250
Lcdout $fe,1
Lcdout "Temp =",dec2 (temperature/100),".",dec1(temperature//100),$DF,"C"
Pause 500
Goto Again
End
here is my code:
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
Low PORTE.1
temp var word
temperature var word
lm35 var PORTA.0
TRISA = %11111111
ADCON1= %10001110
Pause 100
Lcdout $fe, 1
main:
Lcdout " Automated H&T "
Pause 500
Lcdout $fe, $c0, "Control System"
Pause 500
Again:
ADCIN lm35, temp
pause 500
temperature=(temp*5000)*/1250
Lcdout $fe,1
Lcdout "Temp =",dec2 (temperature/100),".",dec1(temperature//100),$DF,"C"
Pause 500
Goto Again
End