Portal about bathroom renovation. Useful tips

Competition for the best design on microcontrollers. Timer circuit for controlling a low-voltage load (CD4040) Homemade daily timer on a microcontroller

This microcontroller timer circuit PIC16F684 allows independent selection of the moment to turn off and turn on the load. A distinctive quality of this timer is the use of a SoG LCD indicator with a built-in serial interface.

Description of the operation of the timer on the microcontroller

The indicator has 8 seven-segment digits. The time display starts with four digits in the middle. Hours and minutes are separated by a decimal point. Indication of whether the timer load is on or off is displayed on the right side of the indicator (0 – off, 1 – on)

All timer control is carried out using 4 buttons. If you press and hold the “Install” button for 2 seconds, the installation mode is activated. First, the real time (hours and minutes) is set. After setting the time, you must click on “set” once

To set the on and off time of the microcontroller timer, you must press the corresponding button. Also, after selecting the required value, you must click “install” once.

The microcontroller operates from a built-in RC oscillator with a frequency of 8 MHz. The internal clock circuit operates from a 32768 Hz quartz oscillator. The microcontroller is in sleep mode most of the time, so the average current consumption is approximately 5...7 µA.

IRLML2502 (BSS138) is used as a key. Tactile buttons are arbitrary. Other SMD radioelements. Plug for programming the PLS5 microcontroller with pin numbering as in PICKit2.

This is a timer circuit on a PIC16F628A microcontroller, borrowed from a good Portuguese site on radio electronics. The microcontroller is clocked from an internal oscillator, which can be considered quite accurate for this moment, since pins 15 and 16 remain free, you can use an external quartz resonator for even greater accuracy in operation.


The timer has three buttons to control the device: “START/STOP”, “MIN” and “SEC”

"START/STOP"- to start and pause the timer.
"MIN"- to set the time interval in minutes. Can be set from 0 to 99.
SEC- the same, but to set seconds. The second can also be set from 0 to 59.
Pressing the "MIN" and "SEC" buttons simultaneously will reset the timer circuit during operation.

When the set time on the timer is used up, a beep will sound and the LED will light up. An electromagnetic type buzzer is used as a sound emitter. After this, when you press the button, the timer will be reset and the LED will go out.

While the timer is counting down, pin 13 is high, and when the timer completes its countdown, the logic level will be low. This output can be used to control any actuator. The circuit is powered through a stabilized current source.


Jumper J1 is used to calibrate the timer. When it is closed, it enters programming mode. Using the “MIN” and “SEC” buttons you can change the value of the internal parameter that slows down or speeds up the timer. This value is stored in the EEPROM of the microcontroller. If you press the “START/STOP” button while in programming mode, this parameter will be reset to the default settings.

Simple timer on pic16f630

The timer can be set to a time interval from one minute to 21 hours in discrete steps per minute. The design has 12 control switches, each of which has its own holding time. Since the microcontroller operates from its own generator, the time counting error is quite small, no more than 30 seconds per hour.

When flashing MK firmware, Jp1 must be disabled. If you don’t plan to change the time settings often, you can use jumpers instead of switches. The firmware, source and project in Proteus can be downloaded from the link above

The timer is designed for single or periodic switching on of a DC load with a voltage of 8 to 12V, a current of no more than 1A. The timer is powered from the same power supply as the load. The time is set by setting the jumper, and can be 5 minutes, 10 minutes, 20 minutes or 40 minutes.

You can select, by installing another jumper, one of the modes - one-time activation or periodic activation. In the first case, the load is turned on after a specified time. And it stays on as long as there is power. In the second mode, the load is turned on and off periodically - it turns on after a specified time, then turns off after the same time. And this repeats itself cyclically.

The timer is started using a button. The countdown begins from the moment this button is released. The source of clock pulses is a flashing LED. The frequency of its blinking determines the time intervals. The author's LED blinked at a frequency of about 1.7 Hz.

At the same time, time intervals of 40, 20, 10 and 5 minutes are indicated approximately; in fact, they are several seconds shorter. Therefore, it makes no sense to use this timer where strict and precise adherence to time intervals is required. It is only suitable where too much accuracy is not required, for example, in various military sports games.

Schematic diagram

The circuit is based on the CD4040 microcircuit (analogous to K561IE20), a 12-bit binary counter. The source of clock pulses is the blinking LED HL1. Jumper L is used to select a time interval (shown in the “40 minutes” position in the diagram). Jumper J2 is used to select the mode (shown in the diagram in the position of one-time load switching).

Rice. 1. Schematic diagram of a timer (time relay) for controlling a low-voltage load with a current of up to 1A.

After counter D1 is reset, all its outputs are logical zeros. And zero voltage through jumper L is supplied to the gate of field-effect transistor VT1, which switches the load. Therefore, it is closed and no current flows to the load.

In the position indicated in the diagram, current is supplied through jumper J2 and resistor R2 to the flashing LED from the output of microcircuit D1. The HL1 LED blinks, creating current and voltage pulses along its power supply circuit. Voltage pulses through the R3-C1 chain are supplied to the meter input. After releasing the S1 button, the counter begins to count these pulses.

After a given time, a logical one appears at the counter output to which jumper L is connected. At the same time, voltage is applied to the gate of field-effect transistor VT1 and it opens. And through J2, the high logic level voltage is supplied to the blinking LED HL1, and the current through it stops - it no longer blinks or generates pulses.

The circuit stops here. But, if jumper J2 is in the lower position, according to the diagram, then resistor R2 will be connected not to the output of the counter, but to the common minus of the power supply. Therefore, the counter will continue to work. And after the same time, a logical zero will appear at the counter output connected to jumper J1. And transistor VT1 will close, turning off the load. And this will be repeated cyclically.

Parts and PCB

Instead of the LED indicated in the diagram, you can use any single-color flashing LED, but you need to take into account that its flashing frequency may be different, and, accordingly, the time intervals will also be different. A socket for a 14-pin microcircuit is used as the basis for the jumpers. Two contacts have been removed from it.

Rice. 2. Printed circuit board for the timer circuit.

Four pins work for jumper J2, and eight pins work for jumper J1. The installation is carried out on a printed circuit board, shown schematically in the figure. Power supply can be from 5 to 15V.

Gordeev I. RK-2017-05.

The electronic timer is designed for programmatic control of household appliances, lighting and other devices. The timer can be used for aquarium and other equipment. Using a timer will save energy without reducing the level of comfort.

Option 1

This device includes three timers. Timer 1.1 and timer 1.2 each allow you to set the time to turn on and off the load that is connected to the KV1 relay. Timer 2.1 and timer 2.2 also allow you to set the time to turn on and off the load, which is connected to the common relay KV2. Timer 3 is a reverse timer that controls the load via KV3.

This device uses a PIC16F628A microcontroller. Elements C1, C2, ZQ1 are external frequency-setting elements of the internal clock generator. To display information, the HG1 indicator with the KS0066 controller is used. The indicator can display two lines of sixteen characters each. Adjustment resistor R4 can be used to adjust the image contrast. Using SB1-SB5, you can control operating and display modes, as well as set the timer. Through pins 1,17,18 of the microcontroller, transistors VT1-VT3 and then relays KV1-KV3 are controlled, which turn on or off the load. When using a relay with a coil current of more than 100 mA, the KT315V transistors should be replaced with transistors with a maximum permissible collector current, which are greater than the relay coil current.

Current time display mode.




Timer display mode 1.1.

If the on time is set equal to the off time, it is considered not used.

The purpose of the keys and their controls are the same as in the current time mode.

Timers 1.2, 2.1 and 2.2 are similar in indication and control to timer 1.1.

Timer 3 display mode

Timer 3 is a countdown timer.

To enter the timer 3 setting mode, you must press and hold the SB5 button until a flashing cursor appears. In the setting mode, the cursor is moved using the SB3 and SB4 buttons, and the values ​​are changed using the SB1 and SB2 buttons. When counting down time, you can stop timer 3 by pressing SB5. After pressing SB5 again, the timer will continue counting and when its value is zero, the load will turn off.

Switching between display modes is carried out using the SB1 and SB2 buttons.

Microcontroller configuration bits.

Option 2

Current time display mode

Purpose of control keys in this mode:
SB5 - enter/exit current time setting mode.
SB3, SB4 – move the cursor left or right during setup.
SB1, SB2 – decrease or increase time values ​​when setting.

Timer display mode


List of radioelements

Designation Type Denomination Quantity NoteShopMy notepad
DD1 MK PIC 8-bit

PIC16F628A

1 To notepad
HG1 LCD 16x2BC1602B21 To notepad
ZQ1 Quartz resonator4 MHz1 To notepad
VD1-VD3 Diode

KD105B

3 To notepad
VT1-VT3 Bipolar transistor

KT315V

3 To notepad
C1, C2 Capacitor15...30 pF2 To notepad
R1, R3, R5 Resistor

1 kOhm

3 To notepad
R2, R6 Resistor

For consideration and possible repetition, a very simple circuit, a very good timer. With convenient navigation through the menu, with a liquid crystal LCD display, with a real-time clock, with the minimum possible number of details, and with all this, you can program as many as one hundred time periods during the day.

Compact dimensions

Timer test video

The heart of this timer is the very popular and no longer expensive Atmega8 microcontroller. You can say that to flash the firmware we will need a programmer that we don’t have, but this is not so; to flash the Atmega firmware, just five short 10-15 cm wires connected through 150-200 Ohm resistors are enough. directly to the LPT port using this scheme.


It is for this reason that these microcontrollers have become the most popular among radio amateurs.

In this picture you see: Pinout diagram of MK legs for connection and firmware.

Step 1. Prepare everything you need to make a timer.

The most necessary radio components of the circuit, the rest can usually be picked up at home, the smallest microcircuit is the DS1307 clock.

We will need the following radioelements:

Integral clock DS1307
LCD liquid crystal indicator
Stabilizer 7805
500-1000 Mf - 16 volts.
Relay or electronic key (depending on the load that is planned to be connected).
resistance 5.1 kohm - 3 pcs., variable resistor (according to the LCD display manual).
Quartz clock 32768 Hz.
Momentary buttons - 4 pcs.
The battery is a 3 volt tablet.
Textolite for the board.
Small transformer ~220V. -> ~6-12c.
Junction box for the case.
+ For the programmer: resistors 150-200 Ohm. - 4 pcs., LPT port connector (for convenience, not required).

Mandatory tools for every radio amateur:
Soldering iron for soldering microcircuits, soldering iron for soldering passive radio components and wires.
Tester for testing tracks and checking radio components.
Tin, rosin.
+ Laser printer (for making a circuit board or another method).

Point 2. Let's start manufacturing.

We will make the timer according to this main scheme.


As you can see, there is no diagram of the power supply and output actuator on it, this is because you may decide to use an external stabilized power supply, and you also don’t know what load you plan to connect, therefore, everyone must choose the actuator themselves to suit their technical requirements.

Personally, I used this power supply circuit and an actuator on a transistor and a relay for my timer.


But you may want to use triacs, thyristors and triacs as an actuator; options for such circuits are shown below.



They are more compact (no heatsink), but less powerful than a simple relay.

In accordance with the main circuit diagram + PSU + IU and analysis of the mounting dimensions of your box for the case, as well as the dimensions of the selected radio elements, we design the shape, size and pattern of the tracks on the board. To do this, it is convenient to use the Sprint Layout program.

For my device I got this simple board.


We transfer the resulting drawing using a special marker or using LUT technology (using a laser printer and iron) onto a copper layer of PCB. If you have a Brother laser printer (like me), then it’s better to immediately abandon the idea of ​​LUT, due to the refractory toner used in it ~400C instead of the usual ~200C; by the way, I once foolishly bought this printer specifically for LUT :(. , so as a result my board is drawn with a marker.
The pattern applied to the copper is etched in a bath of ferric chloride or any other special solution.


We solder the parts onto the finished board according to the diagram, paying special attention when installing and soldering the clock chip and quartz element. The length of the tracks between them should be minimal, but it is better to use micro quartz from a wristwatch and solder it directly to the MC legs of the watch. We fill all the free space next to the clock and quartz MC with housing pads (GND). The battery is needed to keep the watch running while unplugged. If for some reason you did not install this battery, then connect the positive wire to the case, otherwise the clock simply will not work.

We flash the microcontroller with a programmer or using 5 wires.

*Firmware* (downloads: 1394)

The author of the firmware was created specifically for convenience (for which we thank him) and did not change the factory fuses, which makes it very easy, without any problems, to install the firmware for a novice radio amateur. If the MK has not yet been used, it’s new from the store, then just upload the firmware and that’s it, but if there are already changes in the fuses, then you need to set them like CKSEL=0001. Everything else is simple and needs no explanation.

Point 3. Assembly.

It is very convenient to use plastic junction boxes for the case; they come in different sizes and shapes.




Using hot glue from a gun, we fix the LCD screen into the cover cut with a knife, cut holes for the control buttons and the power button.



Trim the protruding glue.