Digital Thermometer – FlowcodeBitahwa Bindu
Watch the Video Tutorial
In this tutorial we’re gonna apply what we’ve learnt in the Analog to Digital tutorial. Temperature sensors are very important in many projects especially in temperature logging devices and alarms. An Analog temperature sensor will be used to read the temperature. The Microcontroller will convert this analog voltage representing the temperature into Digital format and display it continuously on an LCD display.
The temperature sensor used is the LM35 which is a precision integrated-circuit temperature sensor from Texas Instruments, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature, it changes by 10 mV per °C.
The LM35 thus has an advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling.
- Calibrated directly in ° Celsius (Centigrade)
- Linear + 10.0 mV/°C scale factor
- 0.5°C accuracy guaranteed (at +25°C)
- Rated for full −55° to +150°C range
- Suitable for remote applications
- Low cost due to wafer-level trimming
- Operates from 4 to 30 volts
- Less than 60 μA current drain
- Low self-heating, 0.08°C in still air
- Non-linearity only ±1⁄4°C typical
- Low impedance output, 0.1 Ω for 1 mA load
Extract from the LM35 Datasheet
More information can be found from the LM35 datasheet
As shown on the circuit diagram above, it is very easy to interface the LM35 to a PIC, its output pin can be connected to any analog input of the PIC, the VS to +5 supply and the ground to ground. In this example, the LM35 is connected to Analog 0 (pin 2 of PIC18F2620).
VDD and VSS of the pic microcontroller is not shown in the circuit diagram. VDD should be connected to +5V and VSS to GND. The MCLR is disabled in software and an internal oscillator clock is selected so no need for external crystal.
A 16 x 2 lines LCD display is connected to PORT B. refer to the Interfacing LCD Display article to learn more.
Figure 1: Digital Thermometer Circuit Diagram
Flowcode Project Options
Let us set our PIC to use the internal oscillator so we won’t need an external crystal oscillator. Let us also disable the MCLR as we won’t need to disable our microcontroller.
—> On Build Menu, click on Project Options
Figure 2: Starting PIC options
—>On the Clock Speed combo box, enter the Clock Frequency in Hertz (Hz). In our case we’re gonna set our clock to 8MHz (8000000), then click on Configure Chip.
Figure 3: Set the Clock Frequency
—>On Oscillator section, select the Internal Oscillator (INT RC Port on RA6, port on RA7), on Select Chip, make sure to select the correct microcontroller. In our case, we’re gonna use the PIC18F2620. On Master Clear Enable, select MCLR Disabled. Leave the rest of the settings on their default values than click OK.
Figure 4: Setting Configuration Bits in Flowcode
Flowcode Full Code
Figure 5: Flowcode main Program
You can download the full project files (Flowcode Project and Proteus Schematic design) below here.
All the files are zipped, you will need to unzip them (Download a free version of the Winzip utility to unzip files).
Download Digital Thermometer Flowcode
Download Flowcode Digital Thermometer Proteus