The circuit described here is the digital and display section of a thermometer; the analogue circuitry and signal conditioning required to use an LM35 temperature sensor are described elsewhere in this issue (‘LM35 to ADC’). The analogue-to-digital converter used here is hidden inside a PIC16F873 microcontroller behind the RA5 port pin. It has a resolution of 10 bits (1024 steps), allowing a temperature range of 128 °C to be divided into steps of exactly 128 °C / 1024 = 0.125 °C. Displaying a range of 1024 steps of one eighth of a degree, or even just 128 steps of one degree, on a row of LEDs is hardly practical. A better plan is to specify a desired temperature value and allow the microcontroller to indicate deviations from that temperature over a small range; effectively moving a magnifying glass over the temperature scale. The BCD-encoded switches are used to set the desired centre temperature. When the measured temperature is equal to this value the centre two-colour LED D6 will light green. If the temperature deviates from this value, the LED will light yellow.
LEDs D1 to D5 indicate positive deviations and LEDs D7 to D11 indicate negative deviations in steps of one degree. If the overall measurement range is from –24 °C to +84 °C we can therefore set the centre point between –19 °C and +79 °C. Half-degree steps are indicated by two neighbouring LEDs lighting simultaneously. For example, between 19.75 °C and 20.25 °C just one LED will light; between 20.25 °C and 20.75 °C the next LED will also light; and between 20.75 °C and 21.25 °C just the second LED will light. If just the top or bottom LED is lit, it means that the temperature is outside the displayable range. The BCDencoded switches (S1 for the tens digit and S2 for the units) used to set the centre value have the advantage that there is no need for mental acrobatics converting between decimal and hexadecimal when setting or checking the value.Since negative numbers cannot be set using the switches, the value is expressed as the offset from the bottom of the temperature range. The software updates the displayed value every second if JP2 is fitted; if, however, port RA4 is high (jumper not fitted) a 900 ms delay loop in the software is bypassed and the display is updated at full speed.
A printed circuit board layout is available for the digital section of the thermometer (see Figure 2). The two BCD switches are in 6-pin DIL packages and can easily be fitted in sockets so that they can protrude through the lid of an enclosure. If the microcontroller is also be fitted in a socket it may become necessary to stack two or more sockets for the switches. The LEDs are situated at the edge of the board so that their leads can be bent through 90 ° if desired. When the board is populated (not forgetting the wire links near the resonator!) and the soldering has been checked on both boards, JP2 can be fitted and the circuit can be tested. During initialisation the microcontroller will run a power-on self test: the row of LEDs is lit in sequence from bottom to top. Each of the 23 possible display patters is shown for 100 ms. Finally the two-colour LED flashes yellow twice, and the unit starts to display the temperature. Now switch off the power supply, remove JP1 on the digital board and set the BCD switches to the zero position. On the analogue board connect the LM35’s ground to the amplifier input (JP1 in position 0). Apply power and adjust P1 until LED D11 lights; this corresponds to the lower limit of the temperature measurement range.