Amaal
Newbie level 3

lm35dz
Hi All,
I'm having trouble stablizing the temperature.
It's fluctuating between 21 and 48 Deg C
I used the same code in http://www.rentron.com/PicBasic/LM34.htm
But with a help of a friend here. He told me to change it to this code.
I'm still having trouble. VREF is not becoming +5V on my pin 5 (AN3)
Can Anyone help me please.
I'm using Picbasic
DEFINE loader_used 1 ' Boot loader is being used
DEFINE debug_mode 0 ' Debug sending True serial data
DEFINE debug_reg portc ' Debug Port = PortC
DEFINE debug_bit 6 ' Debug.bit = PortC.6
DEFINE debug_baud 9600 ' Default baud rate = 9600
DEFINE osc 4 ' We're using a 4 MHz oscillator
DEFINE ADC_BITS 10 ' Set A/D for 10-bit operation
DEFINE ADC_CLOCK 1 ' Set A/D clock Fosc/8
DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS
samples VAR WORD ' Multiple A/D sample accumulator
sample VAR word ' Holds number of samples to take
temp VAR word ' Temperature storage
samples = 0 ' Clear samples accumulator on power-up
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000000
PAUSE 500 ' Wait .5 second
loop:
FOR sample = 1 TO 20 ' Take 20 samples
ADCIN 0, temp ' Read channel 0 into temp variable
samples = samples + temp ' Accumulate 20 samples
PAUSE 250 ' Wait approximately 1/4 seconds per loop
NEXT sample
temp = samples/40
DEBUG "Temperature is: ",DEC temp," Deg C",10,13
samples = 0 ' Clear old sample accumulator
GOTO loop ' Do it forever
END
Thanks
Hi All,
I'm having trouble stablizing the temperature.
It's fluctuating between 21 and 48 Deg C
I used the same code in http://www.rentron.com/PicBasic/LM34.htm
But with a help of a friend here. He told me to change it to this code.
I'm still having trouble. VREF is not becoming +5V on my pin 5 (AN3)
Can Anyone help me please.
I'm using Picbasic
DEFINE loader_used 1 ' Boot loader is being used
DEFINE debug_mode 0 ' Debug sending True serial data
DEFINE debug_reg portc ' Debug Port = PortC
DEFINE debug_bit 6 ' Debug.bit = PortC.6
DEFINE debug_baud 9600 ' Default baud rate = 9600
DEFINE osc 4 ' We're using a 4 MHz oscillator
DEFINE ADC_BITS 10 ' Set A/D for 10-bit operation
DEFINE ADC_CLOCK 1 ' Set A/D clock Fosc/8
DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS
samples VAR WORD ' Multiple A/D sample accumulator
sample VAR word ' Holds number of samples to take
temp VAR word ' Temperature storage
samples = 0 ' Clear samples accumulator on power-up
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000000
PAUSE 500 ' Wait .5 second
loop:
FOR sample = 1 TO 20 ' Take 20 samples
ADCIN 0, temp ' Read channel 0 into temp variable
samples = samples + temp ' Accumulate 20 samples
PAUSE 250 ' Wait approximately 1/4 seconds per loop
NEXT sample
temp = samples/40
DEBUG "Temperature is: ",DEC temp," Deg C",10,13
samples = 0 ' Clear old sample accumulator
GOTO loop ' Do it forever
END
Thanks