The circuit discussed here represents the digital and display segment of a thermometer. The analog components and signal conditioning necessary for utilizing an LM35 temperature sensor are explained in another section of this issue (‘LM35 to ADC’). Within this setup, the analog-to-digital converter is integrated into a PIC16F873 microcontroller, concealed behind the RA5 port pin. It boasts a resolution of 10 bits (1024 steps), enabling the division of a temperature range of 128 °C into precise increments of 0.125 °C (128 °C / 1024 = 0.125 °C).
Attempting to display 1024 steps of one-eighth of a degree, or even just 128 steps of one degree, on a row of LEDs is impractical. A more effective approach is to specify a target temperature value and enable the microcontroller to indicate deviations from that temperature within a narrow range, akin to moving a magnifying glass over the temperature scale. BCD-encoded switches are employed to set the desired central temperature. When the measured temperature matches this value, the central two-color LED D6 illuminates in green. If the temperature diverges from this value, the LED changes to yellow.
Temperature Deviation Indicators
LEDs D1 to D5 serve as positive deviation indicators, while LEDs D7 to D11 indicate negative deviations in one-degree increments. Given a measurement range spanning from -24°C to +84°C, the center point is established between -19°C and +79°C. Half-degree intervals are denoted by two adjacent LEDs illuminating simultaneously. For instance, between 19.75°C and 20.25°C, a single LED lights up; between 20.25°C and 20.75°C, the next LED in sequence also illuminates. When only the top or bottom LED is lit, it signifies that the temperature falls outside the displayable range.
Simplified Value Setting with BCD-Encoded Switches
BCD-encoded switches (S1 for tens digit and S2 for units) simplify the process of configuring the center value. There’s no need for complex conversions between decimal and hexadecimal when setting or verifying values. As negative numbers cannot be set using these switches, the value is expressed as an offset from the lower limit of the temperature range. The software updates the displayed value every second when JP2 is connected. If port RA4 is set high (jumper not installed), a 900 ms delay loop in the software is bypassed, resulting in a faster display update.
Printed Circuit Board Layout and Assembly
A printed circuit board layout for the digital section of the thermometer is available (refer to Figure 2). The two BCD switches come in 6-pin DIL packages and can be easily socketed to protrude through the enclosure lid. In some cases, stacking multiple sockets may be necessary when fitting the microcontroller in a socket. LEDs are positioned along the board’s edge, allowing their leads to be bent at a 90° angle if desired. After populating the board (with attention to wire links near the resonator) and verifying soldering on both boards, JP2 can be installed, and the circuit can be tested.
Initialization and Calibration
During initialization, the microcontroller performs a power-on self-test. Sequentially lighting up the row of LEDs from bottom to top. Each of the 23 possible display patterns is shown for 100 ms. Finally, the two-color LED flashes yellow twice, and the unit begins displaying the temperature. To calibrate the device, switch off the power supply, remove JP1 from the digital board, and set the BCD switches to zero position. On the analog board, connect the LM35’s ground to the amplifier input (JP1 in position 0). Apply power and adjust P1 until LED D11 lights up, indicating the lower limit of the temperature measurement range.