Menu English Ukrainian russian Home

Free technical library for hobbyists and professionals Free technical library


ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING
Free library / Schemes of radio-electronic and electrical devices

Timer on the microcontroller. Encyclopedia of radio electronics and electrical engineering

Free technical library

Encyclopedia of radio electronics and electrical engineering / Clocks, timers, relays, load switches

Comments on the article Comments on the article

The timer in question has two countdown modes for time intervals ranging from 1 to 999 minutes or the same number of seconds.

Timer on the microcontroller

The diagram of the device is shown in the figure. It has a switch SA1, with which you can choose in which units, minutes or seconds the count will be kept, control buttons SB1-SB3, a three-digit LED indicator HG1 (hundreds digit) - HG3 (unit digit). After the timer is powered on, the RC circuit R2C3 generates a pulse that sets the DD1 microcontroller (AT90S2313-10PI) to its initial state.

When setting the duration of the generated shutter speed, each press of the SB1 (L) button increases the indicator readings by one. If you keep this button pressed for more than 3 seconds, the value on the indicator will increase by 5 units (minutes or seconds) every second. The SB2 (V) button acts similarly to the SB1 button, but the value on the indicator does not increase, but decreases. Upon reaching the values ​​of 999 or 0, further change in the readings in the corresponding direction is automatically blocked.

Selecting the SA1 switch, the time will be counted in minutes or seconds and setting the required exposure time with the SB1 and SB2 buttons, you should press the SB3 (C) button. From this moment, the timer starts - the high level at the PD6 output of the microcontroller is replaced by a low one, voltage is applied to the actuator connected to connector X2, which is signaled by the neon lamp HL1 (with a built-in ballast resistor), and the countdown of the set time begins. The number displayed on the indicator decreases by one every minute or second. The decimal point in the units digit flashes with a period of 1 s.

As soon as the indicator reaches zero, the low level at the PD6 output will again become high, which will turn off the actuator. In addition, in the minutes counting mode, at this moment, a pulse sequence with a duration of 4 s will be generated at the PD60 output - an audible signal will sound. The device will then return to its original state.

To end the shutter speed ahead of time, press the SB3 button again - the actuator will be turned off. To generate a new shutter speed, you must set its duration again.

The actuator control unit is assembled on a solid-state relay U1, the emitting diode of which is connected to the output PD6 of the microcontroller. Thanks to this, the relay circuits connected to the 220 V network are isolated from the rest of the timer circuits. Piezoelectric emitter HA1, which gives a sound signal for the end of exposure, is connected to the output PD4.

At the outputs of port B, the DD1 microcontroller generates signals that come through the current-limiting resistors R4-R11 to the cathodes of the elements of the LED indicators HG1-HG3, and the signals used to determine the state of the buttons SB1-SB3. The second pins of all buttons are connected together and connected to the PD3 input of the microcontroller. Diodes VD1-VD3 prevent short circuits between the lines of port B when several buttons are pressed at the same time. Transistors VT1-VT3, controlled by signals from the PDO-PD2 outputs, alternately connect the common anodes of the HG1-HG3 indicators to the power source, which is required for organizing dynamic indication.

The clock frequency of the microcontroller DD1 is set by a quartz resonator ZQ1 equal to 10 MHz.

The program loaded into the timer microcontroller, the source code of which is available in the appendix to the article, consists of three main parts: the initialization module (INIT label), the main infinite loop (SE1 label) and the T/C1 timer interrupt handler (TIM0 label).

It starts its work by initializing registers, counters, stack, T/C1 timer, watchdog timer, I/O ports. Upon completion of the initialization, the number 001 is displayed on the indicator, all decimal points are off, the PD6 output is set to a high level, so the circuit of the actuator is open. The countdown has been stopped.

The task of forming accurate time intervals with a duration of 1 s is solved using interrupts from the timer T / C1, requests for which follow every 3,9 ms (1/256 s). They are counted by a counter in register r25. Using the counter organized in the register r21, an interval of 1 minute is formed.

In the process of processing interrupts, the bit displayed on the indicator is also changed and the binary value of the digit output in this bit is converted into a "seven-segment" code. In addition, the state of the buttons is polled, control signals are generated for the optoelectronic relay and the audible signaling device.

In the data memory of the microcontroller from address $060 to $062, a buffer is organized that stores the value of the time interval remaining until the end of the exposure. It is from it that the interrupt handler takes the numbers for dynamic output to the indicator. When you press the SB1 button, the value stored in the buffer is increased by one. At the same time, the seconds counter in register r1 is started. If the button is held down for more than 3 seconds, the value in the buffer starts to increase by one five times every second. The count of the time interval during which this increase occurs is organized in the rg register. After releasing the SB1 button, the counters in the registers r1 and rO are reset to zero.

The processing of pressing the SB2 button, which reduces the number in the buffer, is organized in a completely similar way. The time counters for this button are in the registers r2 and rXNUMX.

In the process of counting the specified shutter speed, the number in the buffer is decremented (decreased by one) every minute or second, depending on the position of the SA1 switch. Please note that if you move it to another position before the end of the specified delay, the decrementing period will change accordingly.

Register r22 stores a binary code with a unit in the bit corresponding to the currently enabled bit of the indicator. During initialization, 00000001 is written to it (the HG3 indicator is on), and the starting address of the buffer ($060) is written to the Y register. Each time the interrupt routine is called, the contents of register r22 are shifted one bit to the left, and register Y is incremented. It is clear that as soon as the unit in the r22 register is shifted to the third digit (all indicators are passed), the r22 and Y registers should be reloaded, restoring their original values.

At the time of polling the state of the buttons SB1-SB3, all indicators turn off, and a "running zero" code is generated at the outputs PB0-РВ2 of the microcontroller. Having detected a low level at the input PD3 and knowing which of the outputs PB0-PB2 is currently low, the interrupt routine decides which button is pressed.

The entire program occupies about 670 bytes of microcontroller program memory.

The timer is assembled on a breadboard placed in a plastic case, on the front panel of which indicators HG1-HG3, buttons SB1-SB3, switch SA1 and neon lamp HL1 are displayed. The current consumed from a voltage source of 5 V does not exceed 100 mA.
Piezoelectric emitter HPM14AX can be replaced by HPA17AX or HPA14AX. Instead of HDSP-F501 indicators, other LED seven-element indicators with common anodes will also work. The N-702R indicator lamp with a built-in resistor can be replaced with an ordinary neon lamp by connecting a resistor with a nominal value of 200 ... 560 kOhm and a power of at least 0,25 W in series with it.

The microcontroller program can be downloaded hence.

Author: S. Shishkin, Sarov, Nizhny Novgorod Region; Publication: radioradar.net

See other articles Section Clocks, timers, relays, load switches.

Read and write useful comments on this article.

<< Back

Latest news of science and technology, new electronics:

Machine for thinning flowers in gardens 02.05.2024

In modern agriculture, technological progress is developing aimed at increasing the efficiency of plant care processes. The innovative Florix flower thinning machine was presented in Italy, designed to optimize the harvesting stage. This tool is equipped with mobile arms, allowing it to be easily adapted to the needs of the garden. The operator can adjust the speed of the thin wires by controlling them from the tractor cab using a joystick. This approach significantly increases the efficiency of the flower thinning process, providing the possibility of individual adjustment to the specific conditions of the garden, as well as the variety and type of fruit grown in it. After testing the Florix machine for two years on various types of fruit, the results were very encouraging. Farmers such as Filiberto Montanari, who has used a Florix machine for several years, have reported a significant reduction in the time and labor required to thin flowers. ... >>

Advanced Infrared Microscope 02.05.2024

Microscopes play an important role in scientific research, allowing scientists to delve into structures and processes invisible to the eye. However, various microscopy methods have their limitations, and among them was the limitation of resolution when using the infrared range. But the latest achievements of Japanese researchers from the University of Tokyo open up new prospects for studying the microworld. Scientists from the University of Tokyo have unveiled a new microscope that will revolutionize the capabilities of infrared microscopy. This advanced instrument allows you to see the internal structures of living bacteria with amazing clarity on the nanometer scale. Typically, mid-infrared microscopes are limited by low resolution, but the latest development from Japanese researchers overcomes these limitations. According to scientists, the developed microscope allows creating images with a resolution of up to 120 nanometers, which is 30 times higher than the resolution of traditional microscopes. ... >>

Air trap for insects 01.05.2024

Agriculture is one of the key sectors of the economy, and pest control is an integral part of this process. A team of scientists from the Indian Council of Agricultural Research-Central Potato Research Institute (ICAR-CPRI), Shimla, has come up with an innovative solution to this problem - a wind-powered insect air trap. This device addresses the shortcomings of traditional pest control methods by providing real-time insect population data. The trap is powered entirely by wind energy, making it an environmentally friendly solution that requires no power. Its unique design allows monitoring of both harmful and beneficial insects, providing a complete overview of the population in any agricultural area. “By assessing target pests at the right time, we can take necessary measures to control both pests and diseases,” says Kapil ... >>

Random news from the Archive

mosquito tracking radar 31.03.2018

Chinese defense technology scientists are developing a device to track mosquitoes within two kilometers, which will "save millions of lives" from being bitten by the planet's "deadliest insects".

The new device will pick up the sound of mosquito wings flapping at a distance of about two kilometers.

Modern military radars are capable of picking up the echoes of small objects over long distances. For example, the American anti-missile system "X-band radar" can recognize an object the size of a baseball at a distance of 4 thousand kilometers.

China has similar devices in the defense sector, but some scientists believe that these military technologies can also be used in the fight against mosquitoes. So, at the end of last year, the central government of China allocated about 12,9 million dollars to create a full-fledged radar to track dangerous insects.

Mosquitoes are carriers of numerous dangerous diseases, including the Zika virus, and more people have died from their bites than from all wars combined. More than one million people die each year from mosquito bites, according to the World Health Organization.

Other interesting news:

▪ Electric explosion of aluminum foil will effectively bond the metal

▪ Gluten for split ends

▪ Low Dropout Voltage Regulators (0,4V)

▪ Tesla will clatter its hooves

▪ American robot walked 23 km 335 m

News feed of science and technology, new electronics

 

Interesting materials of the Free Technical Library:

▪ section of the site Home workshop. Article selection

▪ article by Natalie Clifford Barney. Famous aphorisms

▪ article What direction of the mental number line is innate? Detailed answer

▪ article Self-tightening knot with a half bayonet. Tourist tips

▪ article Sound indicator of ultrasound. Encyclopedia of radio electronics and electrical engineering

▪ article Thermal distortion in HiFi amplifiers. Encyclopedia of radio electronics and electrical engineering

Leave your comment on this article:

Name:


Email (optional):


A comment:





All languages ​​of this page

Home page | Library | Articles | Website map | Site Reviews

www.diagram.com.ua

www.diagram.com.ua
2000-2024