Home network hardware Weekly timer on a microcontroller. Competition for the best microcontroller design

Weekly timer on a microcontroller. Competition for the best microcontroller design

Picture from Novelty Kitchen Timers


In amateur radio practice, a timer is often needed: exposing the photoresist, holding time after knurling, after exposure, cooking dumplings, eggs (I often have all the water boil away). The options from Google didn't work for me. I wanted to make a timer that would have 12 buttons and a 4-digit LED indicator - I used red so as not to expose the photoresist. For this design, I used the ATMEL AT89C2051 microcontroller, which had been in storage for a long time. Powered by one battery.

And now the design is ready. Meet: a brutal amateur radio timer with a dwell time from 1 second to 100 minutes in 1 second increments or from 1 minute to 100 hours in 1 minute increments.

About 10 years ago I developed a timer on an LCD and a cheap PIC12C508 microcontroller (Radio magazine No. 5, 2004). It is good for everyone, since then I have never even changed the batteries. Unless there is no backlight and the buttons in that design were clocked, they jam. And I decided not to upgrade the old development, but to make a new one.

The program uses an interrupt from TIMER0, which is turned on in mode “2”, i.e. into 8-bit timer mode with autoloading. In a timer interrupt, the cathodes of the indicator are turned off and data is sent to the serial port to output the next digit of the indicator.
After the transfer is completed, a serial port interrupt is called, in which the corresponding indicator cathode is turned on and the keyboard is polled.

The program takes up a little more than one kilobyte and is written in the KEIL environment. The source text and firmware file are attached.

If you keep the “1” button pressed when turning on the timer, the timer will blink with two extreme dots and enter the time counting mode in hours and minutes. Those. setting the time to 01.00 will already mean 1 hour. You just need to take into account that when powered by one battery, its charge will last for a maximum of 10 hours, it follows that for long exposures the timer must be powered either from more powerful batteries or from the mains.

Since my design was assembled on buttons with Hall sensors, I did not check the connection diagram of mechanical buttons and an indicator with a common anode. If you have any problems during implementation, write, I will help.

Photo of the assembled timer.


Rear view with a cutout for the battery; this case does not have a battery compartment.

Video

A small video in which the indicator blinks in every possible way - this is the beating of the camera scan and dynamic display, it is not visible to the eye, the indicator update time is 20 ms.
Video with this resolution because the house is in the countryside and there is 3G Internet.

Files

Source text in the KEIL environment and firmware file for indicators with a common cathode and a common anode.
🕗 05/04/14 ⚖️ 7.15 Kb ⇣ 27 Hello, reader! My name is Igor, I'm 45, I'm a Siberian and an avid amateur electronics engineer. I came up with, created and have been maintaining this wonderful site since 2006.
For more than 10 years, our magazine has existed only at my expense.

Good! The freebie is over. If you want files and useful articles, help me!

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 timer on ATmega8 is simple, small circuit, based on a clock quartz

Description of control.

If there are less than ten hours left in work, the leading zero is removed; if there is less than an hour left, MM:SS is displayed on the indicator; when setting the timer, the time format is HH:MM.
When less than 20 seconds remain, pulses with a period of 0.5 s are sent to the signal pin (PC4).
pressing the SW4 button while the timer is running stops counting completely, subsequent presses in turn restore the previous setting or reset the timer

If jumper Jmp1 is closed, then when power appears, the timer continues counting. If it is open, then the countdown does not proceed while there is no power (pause). With backup power, there is no indication. The dot near the hour unit blinks.
When you press the RESET button, the timer turns off the load, stops and resets to zero, and pressing it again restores the previous setting. The dot flashes only when counting is in progress.

indicator points:

Do not blink: timer has stopped
- the middle one is flashing - the timer has started

Indicators OA.

Author of the project VasylYE you can find it herehttp://elektron.ucoz.ru/forum/

TIMER ON MICROCONTROLLER

Many descriptions have been published on the Internet, the magazine "Radio", as well as other technical radio publications.devices designed to count time intervals, otherwise called timers. The complexity of their circuits varies from simple, with timingR.C.- chains, up to complex onesdigital integrated circuits with a quartz oscillator. Recently, the development of timer designs on microcontrollers has appeared. Continuing this topic, I propose another design, author S. RYCHIKHIN, from Pervouralsk, made on a microcontroller, in which there is no quartz resonator

The timer is intended for use in everyday life, for example in the kitchen. The interval for changing time delays is from 1 to 100 minutes with a discreteness of 1 minute. The device diagram is shown in rice. 1.


It does not have a quartz resonator, and is used to generate a clock signal.R.C.-generator included in the microcontroller. The frequency stability of this generator is quite sufficient for such a timer. In addition, to improve the accuracy of the count, the possibility of speed correction has been implemented. timer counts. At the end of a preset time interval, the timer will sound a sound signal and after a certain time will go into sleep mode.( Power Down), in which power consumption is low (current consumption is about 1 μA), so there is no power switch in the device An encoder (valcoder) is used as an information input device into the microcontroller.S1 . A four-digit LED indicator is used to display information HG1, operating in dynamic display mode. Its elements (LED cathodes) are connected to the lines of the RVO-RV7 port of the microcontroller, and the transistorsVT1 - VT4 controlled by signals from linesPDO, P.D.1 , P.D.4, P.D.6 and supply power to the indicator digits. The end of the time interval signal comes from the port lineP.D.5 to transistorVT5, which supplies power to the acoustic signaling device HA1 with a built-in generator. ElementsR1, VD1, C1 generates a microcontroller reset signal.

After applying the supply voltage or briefly pressing the buttonS.B.2 “Installation” (“Set.”) the visual effect “running fire” is displayed on the indicator for 1.5 s. After which the timer goes into the time delay setting mode. Rotate the encoder knob to set the desired number of minutes and press the buttonS.B.1 "Start" - the countdown has begun. The indicator displays the remaining time in minutes and seconds. At the end of the exposure time, flashing symbols “- 0 -” are displayed on the indicator and an intermittent sound signal sounds. After about a minute, the timer will turn itself off - the microcontroller will go into sleep mode. You can pause the timer by pressing the buttonS.B.2 "Set" and it will enter time setting mode. If you do not press the buttons or rotate the encoder, the timer will also turn off after a minute. The device uses resistors MLT, C2-23 or imported, oxide capacitors - K50-35 or imported C2 - K10-17. Replacing the KD522A diode with any of the KD509, KD510, KD522, KD521 series. Transistors KT361B can be replaced by any series KT361, KT3107, and KT315B - series KT315, KT3102. Sound alarm -EMX-7 T.A.6 SP, EMX-703 SP, HPMX14AX. ButtonS.B.1 (AndS.B.2) - PKn159,S.W.T.-6 with a long pusher. Depending on the type of encoder used, the buttonS.B.2 "Ust." can be either built into it or separate (similar toS.B.1), in the latter case, it is placed on the board next to the encoder. You can use the encoder without an additional button RES11-4115 F- N001 8 or with button RES11-4115 F- S0018 (a printed circuit board is designed for itrice. 3 .

All elements, except the power battery, are placed on two printed circuit boards, the drawings of which are shown in rice. 2 And rice. 3. Please note that a jumper is connected in series with the acoustic emitter HA1; it replaces a resistor that can be installed to reduce the volume of the sound signal. The boards, together with the battery cell holder, are installed in a plastic case measuring 40x80x110 mm and connected to each other by insulated wires. The top cover has holes for the indicator, encoder axis and button pusher. The timer is powered by a battery of three AAA-sized galvanic cells connected in series. In indication mode, the current consumption is 25...50 mA.

On rice. 4 the device boards are shown assembled.

In Fig. 5 - configuration of the microcontroller during its programming.


The fully assembled timer is shown in rice. 6.


Once assembly is complete, the device starts working immediately after power is applied. But since the frequency of the built-in RC oscillator differs in different instances of microcontrollers, it is necessary to adjust the accuracy of the timer. For this purpose, the device provides a correction mode. In order to enter this mode, you need to set the number 22 on the indicator and press the SB2 “Set” button. The indicator will display the current value of the correction constant, which will be written in the OCR1A register of the T1 timer-counter of the microcontroller. By default, the value of the constant is 2500. Use the encoder to change this value up or down.
The exact figure is selected experimentally. To do this, when turning on for the first time, without changing the constant, set the shutter speed to 10 minutes. Press the SB1 “Start” button and note the exact exposure time. Having determined the difference in stroke in seconds, divide it by 600 and get the deviation in 1 second. By dividing the result by 0.000064, find the number by which the value of the correction constant should be changed. If the timer is “in a hurry”, the value of the constant is increased, if it is “lagging behind” - it is decreased. In the original version of the timer, the value of the correction constant is set to 2917. To exit the correction mode, press the SB1 “Start” button, the value of the constant will be entered into the EEPROM of the microcontroller. In correction mode, the auto power off function is disabled. If the constant has been adjusted, this will be indicated by a short beep that sounds after the supply voltage is applied. The visual effect can be turned off if, in the time setting mode, set the number 23 on the indicator, press the SB2 “Set” button. and then, setting 0 instead of 1, press the SB1 “Start” button

Well, as always, files for downloading this device can be downloaded from the links below. Good luck!!!

When LUT ceases to satisfy you with its quality, you start looking for an alternative and come to photoresist. Gives a much better and repeatable result without much difficulty and at home. When manufacturing printed circuit boards using photoresist, there is a need to accurately count time intervals, and this timer was made for these purposes. Although I think it can find other uses.

The timer counts second intervals of time; it is made on a PIC 16F 886 microcontroller from Microchip. The maximum time is 999 seconds. Control is carried out by three buttons. The timer has the ability to save 7 time intervals in non-volatile memory.

A seven-segment indicator with a common cathode and a symbol height of 14 mm is used for display. The switching element is a relay.

Use the S1 and S3 buttons to set the required time interval. The S2 button is used to start/stop the timer and select the operating mode. At the end of the countdown, the timer beeps every 10 seconds. before pressing button S2. Buttons S1 and S3 have an auto-repeat mode.

Structurally, the timer is made on two boards. On one of them there is a power supply and a relay that switches the load, and on the second there is a digital part with control elements.

The boards are attached to each other using metal stands 30 mm high.

The Bresenham algorithm is used to count second time intervals.

Timer connection:

The procedure for connecting the 220 V network and load is shown in the photo.

Working with the timer:

When turned on, the timer is in the last operating mode that was selected before turning off.

A short press of the S2 button starts the time countdown, pressing it again stops the countdown. A long press (more than 2 sec.) on the S2 button allows you to select time intervals stored in the memory “P1…P7”. To edit time intervals, select one of the cells “P1…P7” and long press the S2 button to enter the editing mode. “RU” mode - allows you to directly set time intervals when the timer is running.

You cannot download files from our server firmware, MPLAB source, Eagle signet

New on the site

>

Most popular