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

Simple alarm clock on PIC16F84. 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

Not so long ago, electronic watches were built on the so-called clock chips of the K176 series and specialized chips of the K145 (K145IK1901) and KR1016 (KR1016VI1) series. Their main drawback is the limited possibilities for improvement (any change required hardware refinement). Watches assembled on the basis of a microcontroller stand out favorably. The circuit is greatly simplified, and the "upgrade" can be carried out without any changes in the hardware. Even setting the clock rate can be purely software. It is these watches that are described in the article published below.

The proposed alarm clock with a four-digit LED indicator is made on the basis of a microcontroller (MC) and shows the time in a 24-hour format with an insignificant zero blanking in the tens of hours discharge. There is a display mode for minutes and seconds, a short (lasting 1 s) beep at the beginning of each hour (if necessary, this function can be turned off), two alarms that can be turned off, and a software setting of the time correction factor, on which the accuracy of the watch depends. The value of the coefficient and alarm settings are recorded in the non-volatile memory (EEPROM) of the MK. The status of the alarm clocks and the signal "Every hour" is indicated by LEDs.

The schematic diagram of the device is shown in fig. 1. Its basis is the PIC16F84 (DD1) microcontroller, the operating frequency of which is set by an oscillator with an external resonator ZQ1 at 4 MHz. The MC reset input (MCLR) is directly connected to the +5V power rail.

Simple alarm clock on PIC16F84

Five-bit port A, all lines of which are configured for output, controls the HL1 LED and switches the digits of the HG1 indicator. The four most significant bits of port B (RB4-RB7) are configured for input and receive control signals from the SB1-SB4 buttons, which are connected to pins without "pull-up" resistors, because there are such in the MK. Bits RB0 and RB1 of port B are used to load the seven-element code corresponding to the displayed digit into register DD2. The RB2 discharge is the output of a 3H signal or an alarm (depending on the version of the program), which can be connected directly to a piezo emitter (ZP-1, ZP-3 and the like), to the input of a 3H amplifier or to an actuator, for example, a relay that at the time of the alarm will turn on the radio, TV or other device.

LEDs HL1 and HL2 indicate the status of the "Every hour" signal and alarm clocks, respectively: HL1 lights up if the "Every hour" signal is turned on, and HL2 - if at least one of the alarm clocks is turned on or if both are turned on.

The device uses a specialized clock LED indicator by Kingbright, containing four seven-element digits with a common anode and two dots indicating seconds between middle digits. Since the conclusions of the ag elements are common to all digits, the indicator can only be controlled in dynamic mode. For this design, the indicator fit perfectly: the number of general-purpose I / O lines in the P1C16F84 MK does not allow for a static indication, and with a dynamic one, with another indicator, it would be necessary to combine the outputs of the same elements of different digits on the board.

Resistors R3-R10 limit the current through the indicator LEDs. The shift register DD2 was introduced to save MK outputs - it converts the serial code into parallel during dynamic indication.

Capacitor C4 filters the ripple in the MK power circuit. There is no place for it on the board; it is soldered directly to the terminals of the MK socket from the side of the printed conductors.

The control program for the MK is written in the standard MPASM assembler from Microchip and compiled in the MPLAB environment of the same company. Of the 1024 MK program memories, about eight hundred have been used, so there are resources for improvement.

Immediately after the power is turned on, the control program is initialized: the port bits are configured for input and output, the timer operation mode is set to 0, alarm settings and the time correction factor are read from the non-volatile memory.

The main task of the program - the formation of accurate time intervals with a duration of 1 s - is solved using interrupts from timer 0. Its pre-healer is connected to the MK crystal oscillator and adjusted to a division factor of 16. A number from 0h to OFh is written to the timer 00 register during each interrupt processing (this and there is a time correction factor, in the source code of the program it is called TIME_SET), so the timer overflows not for 256, but for example, for 250 clock cycles (with TIME_SET=5).

In this case, when using a 4 MHz crystal, timer 0 interrupts occur at a frequency of 1 Hz / 000/000 = 250 Hz. After initialization, the program goes into a loop waiting for these interrupts and counts them. When the number of interrupts reaches 16, the current time is increased by one second.

Timer 0 interrupts also provide dynamic indication. During their processing, the MK sets the zero level at the pins RA0-RA3 and thereby extinguishes the indicator. Further, a seven-element code corresponding to the character to be displayed is loaded into the DD2 register through the MK pins RB0 and RB1. Then, a high logic level is set on one of the RAO-RA3 pins, due to which one of the familiar spaces is lit. All this happens 250 times per second, and due to the inertia of vision, the user sees all the discharges turned on at once.

The high bit of the code loaded into the DD2 register is used to control the second points of the indicator, which flash at a frequency of 1 Hz. Thus, with the help of interrupts from timer 0, two tasks are solved at once. In addition, in the interrupt handling routine, the MK checks if the output digit is a non-significant zero in the left digit, and if so, instead of the seven-element code of the O digit, the MK loads the binary number 11111111 into the register (an indicator with a common anode, so one corresponds to a blanked segment ).

The keyboard is polled about 10 times per second, but after the first pressing of some buttons and their combinations, the program does not respond to repeated pressings for 1 s (for example, if the buttons are held down). This is necessary for the convenience of managing the clock.

Simple alarm clock on PIC16F84

When the alarm goes off, an intermittent 2H signal appears on the RB1 output for 3 minute or, depending on the version of the program, a high level (more precisely, pulses with a repetition rate of 1 Hz). LEDs HL1 and HL2 blink. After a minute, a special subroutine is called, which restores the correct glow of the LEDs.

The device is controlled by buttons SB1-SB4, each of which combines several functions (see the mnemonic diagram shown in Fig. 2). The clock operates in three modes: basic (indication of the current time), with a time correction factor and the mode of setting alarms.

In the main mode, the HG1 indicator displays hours and minutes, while the second points flash at a frequency of 1 Hz. The current time is set with the buttons SB1 (hours) and SB2 (minutes): each press of them increases the readings by one, and if this is done while pressing SB4, it decreases. When the minutes digits reach zero values, the transfer to the hour digit does not occur.

If you hold down the SB4 button for three seconds, the indicator displays minutes and seconds of the current time instead of hours and minutes.

The signal "Every hour" is turned on and off with the SB3 button while holding SB4 (the HL1 LED lights up or goes out, respectively).

To switch to the alarm setting mode, press the SB3 button. The indications of the first alarm appear on the indicator, the second dots glow continuously. Hours and minutes are set by the same buttons SB1 and SB2 (in this case, only an increase in readings). Pressing the SB4 button turns off the alarm, and only dashes remain on the indicator (G elements are lit). The next time the alarm is turned on, the same button appears on the indicator, and zeros (and not the previous values) are written to the alarm registers. If you press the SB3 button again, the indications of the second alarm will appear on the indicator, but the second dots will go out. Both alarms are set up the same way.

The third press of the SB3 button puts the clock into operation mode with a time correction coefficient: the symbols "EE X" are displayed on the indicator, where EE means EEPROM, and X is the current value of the coefficient in hexadecimal form; the second dots continue to flash. With the SB1 button you can increase, and with the SB2 button you can decrease the value of the coefficient in the range from Oh to Fh. The set number will be written to timer 0 in the timer overflow routine.

When the SB3 button is pressed for the fourth time, the alarm settings and the coefficient value are written to EEPROM: the first alarm clock - at addresses 02h-05h (minutes, tens of minutes, hours and tens of hours, respectively), the second - at addresses 06h-09h (in the same order), coefficient - at 01 h.

The device is mounted on a printed circuit board made according to the drawing shown in fig. 3 (dashed lines show jumper wires connecting printed conductors on the opposite side of the board).

Simple alarm clock on PIC16F84

Without any changes in the circuit and the MK program, you can use PIC16C84 - a one-time programmable analogue of PIC16F84. The indicator indicated in the diagram can be replaced by any other four-digit one with a common anode (it is desirable that the conclusions of the same-name elements of the discharges be connected inside the indicator). It is permissible to use four single-digit indicators, in this case, two separate LEDs can be used as second points, connected by cathodes to the right (according to the diagram) output of the resistor R10 (if necessary, through a key on the transistor). Resistors, capacitors, LEDs, buttons - any small-sized ones.

Three versions of the control program have been developed for the watch. Version 1.10 is the main one (its HEX file is given in the table). When alarms go off, a signal (meander) with a frequency of 2 Hz appears at the RB1 output. It can be used to control various actuators and 3H signal generators: from the simplest on two or three logic elements to complex digital sound synthesis systems [1, 2]. Dynamic indication in this version works all the time.

Simple alarm clock on PIC16F84
(click to enlarge)

In version 1.11, the indication also works continuously, but when the alarms go off and at the moment the "Every hour" signal is generated, bursts of pulses with a repetition rate of 2 Hz appear on the RB1 output (the frequency of oscillations filling the bursts corresponds to the interrupt frequency from the timer 0 - 250 Hz). This signal can be applied directly to the emitter or to the input of the 3H amplifier.

Version 1.20 differs from 1.11 only in that the dynamic indication is turned off by default (while all other clock functions work in normal mode). It starts working if you press the SB4 button, and automatically turns off after 10 seconds. When you press the buttons and the alarm goes off, the countdown of this interval starts again. If the alarm went off when the indication is off, it does not turn on: you need to press the SB4 button twice to turn off the alarm and turn on the indication. It is advisable to use this program if the watch is powered by a battery composed of galvanic cells or accumulators: turning off the display saves battery power.

When programming the MK, the configuration word indicates the type of generator - XT, Power-up timer - on, watchdog timer and code protection - off. In addition, a number from Oh to Fh (time correction factor) must be entered in cell 01 h of the non-volatile data memory, and alarm settings at addresses 02h-09h.

If the software setting of the clock accuracy turns out to be rough (which is quite likely), you should install the tuning capacitor C3 shown in the diagram in dashed lines (there is a place for it on the printed circuit board).

HEX files of the program versions 1.11 and 1.20, as well as the source texts of all versions

Literature

  1. Long A. How to write audio data from a wav-file into ROM and "play" them. - Radio, 2001, No. 4, p. 25-27; No. 5, p. 23, 24.
  2. Parts A. Single-chip sound module. - Radio, 2002, No. 11, p. 40, 41.
  3. Prozhirko Yu. Electronic alarm clock with a radio receiver. - Radio, 2001, No. 7, p. 16, 17; No. 8, p. 17, 18.

Author: A. Vakulenko, Tyumen

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

Ceramic motor tested 15.10.2017

The American company GE Aviation, together with specialists from the US Army, has completed testing of the first prototype of a new gas turbine engine, in the design of which ceramic matrix composites are widely used.

In 2011, the US military announced that they needed new gas turbine engines that were economical to operate and relatively inexpensive to manufacture. Power plants are planned to be installed on different types of helicopters. According to GE Aviation, the use of ceramics in the design of advanced engines will reduce the cost of their production by simplifying the production cycle and reduce the cost of operation due to the longer resource of ceramic composites compared to traditional materials.

Ceramic matrix composites have a wide operating temperature range, and parts made from such materials can normally operate at much higher temperatures than conventional metal alloy elements. This allows you to expand the operating range of the propulsion system as a whole. Ceramic parts will be produced using XNUMXD printing technology.

According to the requirement of the military, the new engines must have 80% more power density than modern power plants. In addition, the specific fuel consumption of new engines should be 35% less, and the estimated resource - 20% more. Finally, the cost of production and maintenance of the project's power plants should be reduced by 45%. GE Aviation believes these requirements are quite feasible.

Testing of the first engine prototype in autumn 2016. The engine went through many start and stop cycles, it was tested for the possibility of long-term operation. During the test, the developers monitored the reliability of the compressor, combustion chamber and turbine, and these elements were tested both as part of the power plant and separately on a special stand. Other details about the inspections carried out were not disclosed.

Power plants will be produced in several versions. They will differ from each other in size and power. Depending on the version, the engines will be able to develop power from five to ten thousand horsepower (3,7-7,4 thousand kilowatts). First of all, the power plants are considered as a replacement for the T700 engines of the AH-64 Apache and UH-60 Black Hawk helicopters. T700 engines in several dozen versions have been produced since 1973 and have a power of 6,1 to 7,4 kilowatts.

Other interesting news:

▪ MAX17558 Dual Channel 60V DC-DC Buck Controller

▪ ultrasonic microphone

▪ Indoor positioning technology

▪ Mobile phone tracked by a special signal

▪ Agricultural GMO crops under threat

News feed of science and technology, new electronics

 

Interesting materials of the Free Technical Library:

▪ section of the site Stories from the life of radio amateurs. Selection of articles

▪ telephone article. History of invention and production

▪ article What is a pineapple? Detailed answer

▪ article American winter cress. Legends, cultivation, methods of application

▪ article Introduction to digital electronics. Encyclopedia of radio electronics and electrical engineering

▪ article Inexhaustible glass. Focus secret

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