2 Zones weekly digital timer

5.00 avg. rating (89% score) - 1 vote

 timer boardFigure 1

This document describes the design and implementation of a digital weekly timer based on AVR microcontroller.

PRODUCT OVERVIEW

This digital / microcontroller based indoor digital timer will turn the electrical devises of maximum two zones ON/OFF automatically. Simple programming controls two  devices (on/off) on specific days, 7 days a week or any day only. Includes Battery – backup maintains settings during power failures. It will help save money and energy. It runs off a 5 volts power supply and draws about 100 mA.

  • Turns electrical devices ON/OFF automatically
  • Simple programming – 7 days a week or any week days only
  • Includes battery backup which maintains settings during power failures

Components used to design this timer:

1- A 2 × 16 characters LCD display to show time and date and the output port setting statuses.

2- 5 simple pushbuttons to set the time and date activate and de-activate any of the output port.

3- 2 × TRIAC ICs (MOS3020) (AC power line switching devices) that are while isolating the microcontroller from the power line, they are used to switch any load to control water flow.

How to set the timer to function?

In the time setting mode, we can have access to up to 15 LCD screens to complete the settings such as setting a weekly schedule to control each zone’s on/off time.

When any of Left or Right pushbutton is depressed, system shows any of the screen shown in figure 2 in backward or forward related to any of week days respectively.

As an example, when Right pushbutton is depressed, screen1 is displayed which shows the day of the week also it says that Zone #1 output device is off. Readdressing the same button, will cause screen2 to be displayed which says the same thing but this time it is related to Zone #2. See figure 3

 screens

Figure 2

To set on/off time related any time of the day, we can first depress ‘OK‘ key and then use + / – keys to increase or decrease data related to hour or minute in which we want the output load to be turned on or off. See next figure.

on-offFigure 3

After the time is set, by pressing the + key, off status changes to on or by pressing – key, on status changes to off. Hence, two pushbuttons + or – are used to change the status of the output port.

buttons1

Figure 4

In any screen being displayed currently, by pressing ‘Reset this SCR’ causes the set time related to that particular day to be cleared to 0. By pressing ‘Reset All’ button, all the data related to all days are cleared to 0.

buttons2

Figure 5

The screen background light is turned off if none of the key is depressed for more than 10 seconds.

Each output port has an indicator (LED) which is turned on when that particular port is activated. See figure6.

triac

Figure 6

To connect any device as a load to any of the output port, do as shown in figure 6. L1 must be connected to the timer’s output terminal and N wire to the supply terminal.

connectionsFigure 7

Project hardware

In the schematic diagram of the timer as shown in figure 8,7, 5 buttons are used for setting the time and date parameters 2 other buttons are tied to the external microcontroller’s interrupts. A DS1307 IC is used as a real time clock which is basically just like a watch – it runs on a battery and keeps time for you even when there is a power outage! I also used two optical TRIAC MOS3020 ICs to drive two 240V coils AC relay directly. As you see from figure 6, the output of the two TRIAC ICs are directly tied to two solenoid valves which I took them out from an old washing machine.

schFigure 8

AVR microcontroller Atmega16

The ATmega16 is a low-power Complementary metal–oxide–semiconductor

(CMOS) 8-bit microcontroller based on the AVR enhanced RISC architecture which

is used as the main part of this project. By executing powerful instructions in a single

clock cycle, the ATmega16 achieves throughputs approaching 1 MIPS per MHz

allowing the system designer to optimize power consumption versus processing

speed, operating Voltage range for this microcontroller is – 4.5V – 5.5V [20].

Important Features of ATmega16:

– Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes

– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture

Mode

– Real Time Counter with Separate Oscillator

– 8-channel, 10-bit ADC

– Byte-oriented Two-wire Serial Interface

                                                                                  – Master/Slave SPI Serial Interface

pcbFigure 8

Main software of the system:

weekly timer.c

block-diagram     Figure 1 shows the graphical view of the system

When reset key is depressed, the main screen shown in the next figure.

lcd-1

To set the date and current time, depress the OK key you will have the next screen

lcd-2

To change the day of the week on the display, press ‘UP/+’ or ‘Down/-‘ keys to set the current day of the week.

button3

To set time of the day, press OK key to move to the next row and then use ‘+’ or ‘-‘ keys to increase or decrease hour, minuet or second values and then press OK key to go to the next field to set the next item of the current time (hour > minute > second).In the next figure, software is showing previous hour time, user can increase or decrease the hour value by depressing ‘+’ or ‘-‘ keys respectively.

lcd-4

To set the time of the day for the system to turn load connected to any of two outputs, we can simply press ‘à’ key to change the screen to the related day of the week and set the time to turn on/off the interested output port.

Let’s say we wish to turn zone # 1 on, on Wednesday from 4:00PM to 4:15 PM and Zone 2 to be turned on Friday from 8:00 AM to 8:25AM.

1- Depress the Reset key, to get the system to turn on the background light and show the current time and date of the day. See next figure.

lcd-5

To set the zone #1on from 4:00 PM to 4:15PM on Wednesday we need to take the following steps:

:(Depress the ‘–>’ key few times to have the next screen (next figure

lcd-6

Notice that previous setting shows that on Wednesday zone # 1 is off and time is from 05:58 to 20:5.

                   . We need to change the setting as mentioned earlier to 4:00 PM to 4:15 PM

Just by depressing OK key, we can start setting the time of the day.

In the next figure notice that zone is shown ‘off’ from previous setting and also time is shown as 17:– to  –:– . Pressing OK key takes us to the time field to set (e.g. 17 should be changed to 16). Press ‘-‘ key deducts one unit from 17-1 = 16 and press OK key to go to the next field and type 00.

lcd-7

After fixing 16:00 (press OK key when you are done with the current field) and typing 16:15, now we need to change ‘off’ status to ‘on’ as well.

lcd-8

To change the status, press the ‘+’ key one more time and you will have the next screen as shown below.

lcd-9

Pressing ‘–>’ key causes the system to show data relate to zone # 2 for the same day (Wednesday) but since we do not want to have anything to do with it, just press ‘–>’ key to move to the next day’s data which is Tuesday. Pressing ‘–>’ key again, takes us to Thursday and finally to Friday.

Now we need to set zone # 2 to be turned on Friday from 8:00 AM to 8:25AM.

lcd-10

Pressing ‘–>’ key again, will take us to the screen related to zone # 2 of the same day which is Friday.

lcd-11

We can take the same steps as it was mentioned earlier to set the time for zone # 2.

In the next figure, notice that the screen is related to zone # 2 and the hour field is set to the required time by pressing ‘+’ key.

lcd-12

After typing ’08’ again by pressing OK key we can move to the next field which is related to the minute field and type our value there. In the same way, we may fill out data related to the next off time values. See next figure.

lcd-13

After typing the last value (08:25), to change the status of the output from ‘off’ to ‘on’, we can again press ‘+’ key one more time which causes the mode to change to ‘on’ status. See next figure.

lcd-14

:Remark

Pressing Reset All key, clears content of all time setting related to 7 days of a week and two zones. Meaning by pressing the Reset All key, one has to enter all the zone data again.

Pressing Reset Screen key, clears data related to current screen that you are editing it.

Download ZIPVideo of this project

youtu.be/xbIEKI3qqNM

One thought on “2 Zones weekly digital timer

  1. Excellent blog! Do you have any tips for aspiring writers?
    I’m hoping to start my own website soon but I’m a little lost on everything.
    Would you propose starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally confused ..
    Any suggestions? Appreciate it!

Leave a Reply

Your email address will not be published. Required fields are marked *