Accurate Temperature Thermometer using LM35
Posted: Thu Jul 31, 2014 3:34 pm
Equipment used and files required:
EB006 Programmer with 16F1824 fitted.
Note: Only designed to work with the following microcontrollers:
12F1822, 16F1823, 16F1824,16F1825, 16F1828 & 16F1829
Also External Vref will no be available unless original PIC_CAL_ADC.c is restored.
EB005 LCD.
LM35 Temperature sensor (10mv per deg C) connnected to An0 (pin 13)
Connections: If readings fluctuate, then a basic RC filter (see Datasheet)
Attached Thermometer LM35 V1.fcfx
Description:
The 16F1824 (and all shown devices above) have many new features including 3 different internal stabled Fixed Voltage References (FVR)
These are:
1.024V which changes 10 Bit ADC resolution to 1.024/1024 = 1mV
2.048V which changes 10 Bit ADC resolution to 2.048/1024 = 2mV
& 4.096V which changes 10 Bit ADC resolution to 4.096/1024 = 4mV
Now you can see the reasoning behind this since without FVR and supply =5V
10 Bit ADC resolution = 5/1024 = 4.88mV
The down side is since each ADC variable increment of 1 = 1mV then maximum i/p voltage for ADC = 1023 = 1.023V = 102.3 deg C
PIC_CAL_ADC.c has been modified to enable internal Fixed Voltage reference of 1.024V as this makes the thermometer much more sensitive!
But only when Vref+ has been selected from Vref options (ADC component properties)
If not, then the default resolution will be 4.88mV: This means when FVR is enabled the resolution of 10bit ADC is 1.024/1024 = 1mV
Since output voltage from LM35 is 10mV per deg C that means that the resolution of temperature Thermometer is 0.1 deg C
Floats are not required to display temperature to an accuracy of 0.1 deg C
How the flowchart works is:
10Bit ADC is read.
Since voltage out from LM35 is 10mV per C and resolution of ADC is 1mV then ADC = temperature x 10
So if ADC= 151 then actual temperature is 15.1 deg C.
The 151 is converted to a string.
All numbers except from the last number on the right is printed so in this case 15
Then decimal point is printed. Finally the last digit on the right is printed.
The result printed will be 15.1
At the time of writing this, being in a warm room, calibrated Ktype thermometer displayed 27.0 deg C and LCD connected to EB006 programmer with LM35 connected displayed 26.9 deg C
Hope you find this useful.
Martin
EB006 Programmer with 16F1824 fitted.
Note: Only designed to work with the following microcontrollers:
12F1822, 16F1823, 16F1824,16F1825, 16F1828 & 16F1829
Also External Vref will no be available unless original PIC_CAL_ADC.c is restored.
EB005 LCD.
LM35 Temperature sensor (10mv per deg C) connnected to An0 (pin 13)
Connections: If readings fluctuate, then a basic RC filter (see Datasheet)
Attached Thermometer LM35 V1.fcfx
Description:
The 16F1824 (and all shown devices above) have many new features including 3 different internal stabled Fixed Voltage References (FVR)
These are:
1.024V which changes 10 Bit ADC resolution to 1.024/1024 = 1mV
2.048V which changes 10 Bit ADC resolution to 2.048/1024 = 2mV
& 4.096V which changes 10 Bit ADC resolution to 4.096/1024 = 4mV
Now you can see the reasoning behind this since without FVR and supply =5V
10 Bit ADC resolution = 5/1024 = 4.88mV
The down side is since each ADC variable increment of 1 = 1mV then maximum i/p voltage for ADC = 1023 = 1.023V = 102.3 deg C
PIC_CAL_ADC.c has been modified to enable internal Fixed Voltage reference of 1.024V as this makes the thermometer much more sensitive!
But only when Vref+ has been selected from Vref options (ADC component properties)
If not, then the default resolution will be 4.88mV: This means when FVR is enabled the resolution of 10bit ADC is 1.024/1024 = 1mV
Since output voltage from LM35 is 10mV per deg C that means that the resolution of temperature Thermometer is 0.1 deg C
Floats are not required to display temperature to an accuracy of 0.1 deg C
How the flowchart works is:
10Bit ADC is read.
Since voltage out from LM35 is 10mV per C and resolution of ADC is 1mV then ADC = temperature x 10
So if ADC= 151 then actual temperature is 15.1 deg C.
The 151 is converted to a string.
All numbers except from the last number on the right is printed so in this case 15
Then decimal point is printed. Finally the last digit on the right is printed.
The result printed will be 15.1
At the time of writing this, being in a warm room, calibrated Ktype thermometer displayed 27.0 deg C and LCD connected to EB006 programmer with LM35 connected displayed 26.9 deg C
Hope you find this useful.
Martin