This circuit is a PIC micro-controller based easy-to-construct gadget, which combines a clock with a temperature indicator in the same display. The display uses four 7-segment common-anode LED. It shows the clock, and in every minute for five seconds the display
alternates to show the temperature in oC. An alarm facility with buzzer is provided.
Port pins in the PIC chip have greater power capability than those in the 8051 family. So driving LED segments can be made by directly connecting the segments to the port pins, without any buffer IC. Thus, component count is reduced.
There are several analogue-to-digital converter input channels. Speed of conversion is as short as 20 microseconds. So it is easy to connect any analogue signal and digitise the same for displaying with LEDs. Here, the analogue signal is that of temperature.
Texas Instruments chip LM35 is a low-cost temperature sensor and is connected to the analogue input pin of the PIC chip. It can measure Temperatures in the range -50oC to 100oC, but in this unit it is mounted on the PCB only to show room temperature.
Circuit and working
shows the circuit diagram of the alarm clock-cum-temperature indicator. PIC16F73 IC has its reset on pin 1. A resistor and capacitor junction is tied to this pin to perform reset on applying power. The 5V power supply is obtained from a low-voltage transformer (X1), rectifier (BR1) and voltage regulator IC 7805 (IC1).
Pin 20 is Vcc and pins 19 and 8 are grounded. Pins 9 and 10 are for connecting a crystal for the oscillator. Any crystal frequency is alright, but it is better to use the highest 20MHz crystal for speed. Two capacitors, each of 15pF, are tied to the end of the crystal to ground. This frequency is called high speed, or HS. There is a configuration register inside the chip, which should be programmed for HS, among other choices, such as XT, RC and LP. The configuration byte we use is 52 hex.
Port B is programmed as output pins. Port A pins are programmed as input pins and pin 2 (AN0) is used as analogue input pin from temperature sensor LM35. Port C pins 4 through 7 are used for driving the anodes of the four LEDs.
Pin C.0 is used as input pin for connecting switch S1 to high logic in order to set the time of clock or alarm time. By continuously pressing it, time changes and the switch has to be released immediately after the required time is displayed.
Pin 20 is Vcc and pins 19 and 8 are grounded. Pins 9 and 10 are for connecting a crystal for the oscillator. Any crystal frequency is alright, but it is better to use the highest 20MHz crystal for speed. Two capacitors, each of 15pF, are tied to the end of the crystal to ground. This frequency is called high speed, or HS. There is a configuration register inside the chip, which should be programmed for HS, among other choices, such as XT, RC and LP. The configuration byte we use is 52 hex.
Port B is programmed as output pins. Port A pins are programmed as input pins and pin 2 (AN0) is used as analogue input pin from temperature sensor LM35. Port C pins 4 through 7 are used for driving the anodes of the four LEDs.
Pin C.0 is used as input pin for connecting switch S1 to high logic in order to set the time of clock or alarm time. By continuously pressing it, time changes and the switch has to be released immediately after the required time is displayed.
Pin C.3 is used as another input pin. It is used for setting the alarm time. S2, which grounds this pin, will set the alarm time to be the time currently on display. Thereafter, S1 is to be pressed to adjust to the current clock time.
Pins C.2 and C.1 are used for seconds blinking (not used here) and for clock alarm output. A piezo buzzer of a musical type is connected to it.
Since LM35 gives a linear 10mV output for each degree of temperature, it will output a value of, say, 250mV for 25oC. This will be read by the ADC as 25 because it is one-tenth of the reference voltage. For a temperature of 100oC, it will give 100 x 10 = 1000mV or 1V. This will be shown as 100 on the ADC. Value of ADC register ADRES is used to show the temperature on the display.
In order to convert the ADC value to decimal, divide the value by ten to get the high digit; balance or remainder will be low digit. First three LEDs show the 3-digit temperature value and the fourth digit is programmed to show oC. Therefore the fourth LED is turned top-down in the PCB while soldering.
It is to be understood that, according to this connection, look-up table for the segment code for each and every digit displayed is to be prepared. For example, to show number 3, segments a, b, c, d and g have to be made low to sink the current and make these glow. As per the above-mentioned order, this gives the code as 0-0-1-0-0-0-1-1. This byte is 23, which is the look-up table entry for number 3.
component list
Code for the clock as well as the temperature indicator was developed using Oshon PIC simulator _IDE software. It provides high-level BASIC for code development and has all peripherals available for simulation of a program under development on the computer screen.Complete program is in .ASM format and the program code in hEX is in a hex file. Using PICkit2 programmer it can be entered into a fresh PIC chip. Note that the configuration byte is 52 hex. You use 42 hex if you want to protect the code from being copied.
After powering on the circuit, a default value will be displayed. Press S1 to set the desired time. After setting the time, press S2 to set alarm time. Now, present time will be shown on the display. The buzzer (PZ1) will sound at the time set for the alarm.
No comments:
Post a Comment