Timer on atmega8 with clock module. Programming microcontrollers AVR

This timer is designed to set shutter speeds from 5 seconds to 100 minutes. At its output there is a sufficiently powerful electromagnetic relay that allows switching current up to 30A at a voltage of 12V and current up to 10A at a voltage of 220V. Thanks to the use of an electromagnetic relay, the timer can control not only heating or lighting devices, but also electronic devices that are critical to the form of the AC supply voltage. Transformer supply, in combination with a relay, provides complete galvanic isolation electronic circuit network timer.

To communicate with the operator, the timer has a four-digit LED indicator, it has very old 7-segment matrices AL304 in the amount of four pieces, connected into a matrix by connecting segment outputs of the same name together. Of course, you can use more modern LED indicators, and even ready-made matrices of four digits for dynamic indication.

Control the timer with buttons S1, S2, S3, S4. When the S1 button is pressed, the load is turned on and the timer starts. To set the time during which the load is to be operated, press S4. The display will flash the two most significant digits (minutes). Now you can set the minutes with buttons S2 and S3. Then you need to press S4 again. Now the lower digits will flash and you can set the seconds with the S2 and S3 buttons. To save the settings, press S4 again. Now the indicator will show the set shutter speed. Press S1 to start the timer. The load is turned on, and the indicator readings begin to decrease. As soon as given time dries up, “OFF” appears on the indicator, and the load is turned off by an electromagnetic relay. To repeat, press the S1 button twice. The first time you press "OFF" it will change to the indication of the set time, and the second time the timer will start. Relay control on output 23 D1. Inclusion is a logical unit. The key on VT5 and VT6 controls the electromagnetic relay K1. Such relays are used in car alarm circuits. They can switch like D.C.(12V) and variable (220V), because they have good insulation.

The power supply is made on a low-power transformer. Since the secondary winding of the transformer has a tap from the middle (12-0-12), the rectifier is made not according to the bridge, but according to the full-wave circuit on two diodes VD2 and VD3. If the transformer is with a 12V winding without a tap, then a rectifier bridge is needed. The relay is powered directly from the output of the rectifier, and the rest of the circuit through the voltage regulator A1 5V.

When flashing, you need to set it to work with an internal 8 MHz generator.

The circuit is assembled on a purchased breadboard printed circuit board, on its one side there is a microcircuit and other parts, and buttons and indicators on the other side. Power transformer outside the board.

Transistors KT315 can be replaced by KT3102 or any analogues. The KT815 transistor can be replaced with KT817, KT604. Diode KD521 - almost any analogue. Diodes in the KD209 rectifier - any rectifier diodes for direct current not lower than 150 mA. The integral stabilizer 7805 can be replaced with any 5-volt one, for example, KR142EN5A. Or make a stabilizer according to a parametric circuit on two transistors and a 5V zener diode. The indicators are discussed above. It can be any seven-segment indicators with a common anode (cathode).

Archive for the article "Timer on Atmega8 and LED indicators"
Description: Firmware files
File size: 5.58KB Number of downloads: 4 319

This timer is designed to set shutter speeds from 5 seconds to 100 minutes. At its output there is a sufficiently powerful electromagnetic relay that allows switching current up to 30A at a voltage of 12V and current up to 10A at a voltage of 220V. Thanks to the use of an electromagnetic relay, the timer can control not only heating or lighting devices, but also electronic devices that are critical to the form of the AC supply voltage. Transformer power, in combination with a relay, provides complete galvanic isolation of the timer electronic circuit from the mains.

To communicate with the operator, the timer has a four-digit LED indicator, it has very old 7-segment matrices AL304 in the amount of four pieces, connected into a matrix by connecting segment outputs of the same name together. Of course, you can use more modern LED indicators, and even ready-made matrices of four digits for dynamic indication.

Control the timer with buttons S1, S2, S3, S4. When the S1 button is pressed, the load is turned on and the timer starts. To set the time during which the load is to be operated, press S4. The display will flash the two most significant digits (minutes). Now you can set the minutes with buttons S2 and S3. Then you need to press S4 again. Now the lower digits will flash and you can set the seconds with the S2 and S3 buttons. To save the settings, press S4 again. Now the indicator will show the set shutter speed. Press S1 to start the timer. The load is turned on, and the indicator readings begin to decrease. As soon as the set time runs out, the indicator shows the inscription “OFF”, and the load is turned off by an electromagnetic relay. To repeat, press the S1 button twice. The first time you press "OFF" it will change to the indication of the set time, and the second time the timer will start. Relay control on output 23 D1. Inclusion is a logical unit. The key on VT5 and VT6 controls the electromagnetic relay K1. Such relays are used in car alarm circuits. They can switch both direct current (12V) and alternating current (220V), as they have good insulation.

The power supply is made on a low-power transformer. Since the secondary winding of the transformer has a tap from the middle (12-0-12), the rectifier is made not according to the bridge, but according to the full-wave circuit on two diodes VD2 and VD3. If the transformer is with a 12V winding without a tap, then a rectifier bridge is needed. The relay is powered directly from the output of the rectifier, and the rest of the circuit through the voltage regulator A1 5V.

When flashing, you need to set it to work with an internal 8 MHz generator.

The circuit is assembled on a purchased breadboard printed circuit board, on its one side there is a microcircuit and other parts, and buttons and indicators on the other side. Power transformer outside the board.

Transistors KT315 can be replaced by KT3102 or any analogues. The KT815 transistor can be replaced with KT817, KT604. Diode KD521 - almost any analogue. Diodes in the KD209 rectifier - any rectifier diodes for direct current not lower than 150 mA. The integral stabilizer 7805 can be replaced with any 5-volt one, for example, KR142EN5A. Or make a stabilizer according to a parametric circuit on two transistors and a 5V zener diode. The indicators are discussed above. It can be any seven-segment indicators with a common anode (cathode).

Archive for the article "Timer on Atmega8 and LED indicators"
Description: Firmware files
File size: 5.58KB Number of downloads: 4 319


The countdown timer will help you accurately measure the time interval in the range from 1 second to 24 hours.

Today you will not surprise anyone with the design of the timer, because. on sale and on the Internet of similar devices, as many as you like. And all the timers seem to be similar to each other. And when you begin to consider the functions of the circuit in more detail, you find some inconvenience in it for yourself.

From these considerations, I made a timer program that meets the following parameters:

– compact design and simple circuitry;

– operational push-button control;

– when controlled by buttons, duplication of actions on the LCD;

- setting the time with an accuracy of up to a second;

– countdown range from 1 second to 24 hours;

– function start, pause;

- the function of resetting the countdown and the set time values;

– when the value 00.00.00 is reached, the actuator is switched on;

All tasks set were implemented in this project.

Description of the timer modes

After turning on the timer, you can set the time that we need. The purpose of the buttons can be seen in the diagram. After setting, press the START button - pause the countdown begins. The maximum set time is 23.59.59.

The countdown time correction can be made at any moment of the timer operation, after power supply to the circuit.

As soon as the time reaches 00.00.00, the LED turns on (at the moment it is an imitation of turning on the actuator, or you can simply squeak with a generator).

If the start-pause button is pressed while the timer is running, the timer will stop the countdown, pressing the START-pause button twice will resume the stopped countdown.

To turn off the load after turning it on, you need to press RESET, the timer data will be set to 00.00.01 - the load will turn off. Or set a new countdown period and double-click the START-pause button.

Display of characters on the LCD< ! > means that the load is disconnected (PD3) and pressing the START button once will start the countdown of the set time.

Quartz external 8 MHz, for counting accuracy.

For the programmer in PonyProg and CodeVisionAVR, you need to uncheck the clock generator settings.

After the programmer flashes the fuses from an external quartz, the controller will be read by the programmer only with a quartz.

Attention! As for the FUSE bits. This is the main source of errors leading to controller lockup.

– CKSEL3…0 must be NOT programmed.

In PonyProg and CodeVisionAVR they cost like this:

LCD must be based on HD4480 controller

16x1, for it in the archive there is firmware V-1

or 8x2, firmware V-2 in the archive.

The operation of the circuit can be tested in proteus.

If, when simulating a project in proteus, Cyrillic characters are displayed incorrectly on the LCD, then to correctly display the Cyrillic alphabet on the LCD, unpack the library LCDrus.zip (attached in the project archive) to a folder models proteus.

This device will be useful to anyone who has to constantly cook, and will reliably protect your kitchen from excessive amounts of smoke. This appliance, as the name suggests, is a kitchen timer. It is designed to count the intervals in the preparation of various dishes. The timer has several keys, with which you can easily set the time from 1 minute to 99 hours. The countdown starts automatically, 3 seconds after the time is set. Thanks to the loud squeaker, you will definitely hear when the dish is ready. The device is assembled on the basis of the ATMega8 microcontroller.

Design Description

The heart of the device is the U1 microcontroller (ATMega8) with quartz resonator X1 (16 MHz) and a strapping of two capacitors C1 (22 pF) and C2 (22 pF). Stabilizer U2 (7805) with a strapping of capacitors C3 (100 uF) and C4 (47 uF) stabilizes the 5V supply voltage necessary for the correct operation of the microcontroller and related components. The Zas connector is supplied with a voltage of 7-12V. If you have a power supply with a voltage of 5-6V, you can exclude the voltage regulator from the circuit. Buzzer B1 and display anodes W1 are controlled by transistors T1 - T5 (BC556), with resistors R1 - R8 (3.3 kOhm), R17 (3.3 kOhm) and R18 (3.3 kOhm). Resistors R9 - R16 (330 ohms) limit the current through the display segments. The Prog connector and one R pin are used to connect the programmer. The timer keypad is connected to the Sw connector.

Manufacturing

Picture printed circuit board for the device is in the archive at the end of the article. Installation of parts begins with soldering two jumpers. Then all the resistors and other elements are installed in order from smallest to largest. Quartz X1 must be "low" - it is installed under the display - otherwise it simply will not fit there. The buzzer B1 can be soldered on the board as shown in the photos, but later it turned out that after closing the case, the sound is too quiet (despite the holes drilled in the case). It is better to glue the buzzer on one of the sides of the case (as shown in the last photo), and connect it with wires to the board. The keyboard consists of 5 buttons without fixing 12x12mm directly on the front of the case, so that their pushers are slightly above the surface of the case. For this device, it is good to use as a power supply Charger for the phone, because of its small weight and size.

List of radio elements

Designation Type Denomination Quantity NoteShopMy notepad
U1 MK AVR 8-bit

ATmega8A-AU

1 To notepad
U2 Linear Regulator

LM7805CT

1 To notepad
T1-T5 bipolar transistor

BC556

5 To notepad
C1, C2 Capacitor22 pF1 To notepad
C3 100uF1 To notepad
C4 electrolytic capacitor47uF1 To notepad
R1-R8, R17, R18 Resistor3.3 kOhm10 To notepad
R9-R16 Resistor330 ohm8 To notepad
W1 7 segment indicatorAF-05643FG-B1 Or with a similar pinout To notepad
B1 Piezo speaker with generator 1

On our website, dedicated to various electronic homemade products, schemes have been repeatedly published. Of course, they are inferior to modern industrial counterparts, where there is a display, programming and other service functions. And now it's time to place such a scheme that will compete on equal terms with the best branded samples. A digital timer is used to control the operation of electrical devices according to a programmed schedule. This programmable timer is based on a microcontroller. PIC16F628A, which can be programmed to schedule the on and off of an electrical appliance connected to it that is controlled via a relay. The timer allows you to manually set the on and off times. The maximum time interval that can be set to turn on and off is 99 hours 59 minutes. The project is designed to use a 16x2 LCD display and 4 buttons.

Here, the 5 volt relay is controlled by a PN2222 transistor, which in turn is controlled by a RB3 PIC16F628A. Digital inputs of the 4 buttons are read using the I/O port RA2, RA3, RA4, and RB0. A standard 16×2 character LCD is used to display device status, program, menu and time. The LCD operates in 4-bit mode, so only 6 I/O pins of the PIC16F628A are needed for operation. Piezo buzzer gives sound signal when the timer starts and stops. It also beeps when the device is turned on or off. The supply voltage of the circuit comes from the LM7805 stabilizer. 9 V is supplied to its input from network adapter. LED backlight enhances readability LCD display in low light condition.

Timer operation and button functions

The timer receives commands from 4 buttons. Their functions are as follows:

Time: Allows you to set the turn on and turn off time. When the timer is initially enabled, the device is in the off state and the time is 0. By pressing this button, you can switch between on and off on the display.

Choice: allows you to select between on and off parameters, as well as hour and minute digits. The selected digit is increased by pressing the ON/OFF button.

Input: When the corresponding time is selected, pressing this button will complete the settings.

start/stop: to start or stop the timer. If it is already enabled, you can stop it at any time by clicking on this button.