Multi-program timer on the pic16f628a microcontroller. Simple timer on PIC16F628A. Scheme and description. Timer circuit - indicators with a common anode

This is another junk craft - a timer for the kitchen, although not necessarily for the kitchen. Parts that were lying around were used, in particular, old ALSki indicators, resistors soldered from old boards, etc. Microcontroller device basis PIC16F628A, one of the most common and cheapest. The timer is controlled by a knob and one button. Time delay range from 1 to 99 minutes. At the end of the timing cycle, an intermittent sound signal... And the archive contains two firmware, the first is just a timer, and the second with some bells and whistles, more on that below.

There is also an option for indicators with a common anode. Please note that the firmware for each of the schemes is different. All differences are highlighted in red on the diagram.

After turning on the power, the indicators show the specified time, the LED does not light up. By turning the encoder, the time setting can be changed from 1 to 99 minutes. When the time is set, press the button - a short beep sounds and the timer starts counting down, the LED blinks, and the time on the indicator decreases every minute. When the time has reached zero, the timer emits intermittent beeps, the LED lights up constantly. Now, by pressing the button, the sound signal is removed and the device returns to its original state - the time setting mode. This is how the first version of the firmware works.

The second version of the firmware works the same as the first, but has several additions. In time setting mode, if the knob is not touched for a few seconds, the animation starts running on the display. pressing the button or rotating the encoder will turn off the animation and re-display the time setting mode. During the countdown, if there is one minute left, the display will show seconds from 60 to 00. When the sound signal is triggered, it will sound not endlessly, but about 20 seconds. Then the display begins to indicate an animation splash screen (different from the one in the installation mode). And also, every minute it will remind you with a short sound signal. By pressing the button, as in the first firmware, the timer is reset to the time setting mode. When there are 3 seconds left until the timer expires, the timer emits a short beep for every second, i.e. 3 ... 2 ... 1 and further works as usual. Both firmwares are available and are in the archive along with the picture printed circuit board.

The audio signal is implemented using the hardware PWM built into the microcontroller. The dynamic head should have a resistance of about 50 ohms. Low-impedance dynamic heads (4 or 8 ohms) can also be used, but in this case it is better to install a small-sized output transformer, because a large current will flow through the 4 ohm head, which can overload the power supply and trigger a reset of the microcontroller.

Printed circuit board, variant of Alexey Antonov

Comments (1)

1 2

0 # 21 kaktuss 06/14/2015 16:08

Quoting AntonChip:

You can see a screenshot of setting the configuration bits during programming


I asked the author what configuration for the firmware, he replied that everything is already in the firmware. Therefore, I did not install anything, I just uploaded the firmware.
I would post screenshots, but I don't know how. Can I send you an email?

This is another junk craft - a timer for the kitchen, although not necessarily for the kitchen. Parts that were lying around were used, in particular, old ALSki indicators, resistors soldered from old boards, etc. The basis of the device is the PIC16F628A microcontroller, one of the most common and cheapest. The timer is controlled by a knob and one button. Time delay range from 1 to 99 minutes. At the end of the timing cycle, an intermittent sound signal is emitted. And the archive contains two firmware, the first is just a timer, and the second with some bells and whistles, more on that below.

There is also an option for indicators with a common anode. Please note that the firmware for each of the schemes is different. All differences are highlighted in red on the diagram.


After turning on the power, the indicators show the specified time, the LED does not light up. By turning the encoder, the time setting can be changed from 1 to 99 minutes. When the time is set, press the button - a short beep sounds and the timer starts counting down, the LED blinks, and the time on the indicator decreases every minute. When the time has reached zero, the timer emits intermittent beeps, the LED lights up constantly. Now, by pressing the button, the sound signal is removed and the device returns to its original state - the time setting mode. This is how the first version of the firmware works.

The second version of the firmware works the same as the first, but has several additions. In time setting mode, if the knob is not touched for a few seconds, the animation starts running on the display. pressing the button or rotating the encoder will turn off the animation and re-display the time setting mode. During the countdown, if there is one minute left, the display will show seconds from 60 to 00. When the sound signal is triggered, it will sound not endlessly, but about 20 seconds. Then the display begins to indicate an animation splash screen (different from the one in the installation mode). And also, every minute it will remind you with a short sound signal. By pressing the button, as in the first firmware, the timer will be reset to the time setting mode. When there are 3 seconds left until the timer expires, the timer emits a short beep for every second, i.e. 3 ... 2 ... 1 and further works as usual. Both firmwares are available and are in the archive along with the printed circuit board drawing.

The audio signal is realized using the hardware PWM built into the microcontroller. The dynamic head should have a resistance of about 50 ohms. Low-impedance dynamic heads (4 or 8 ohms) can also be used, but in this case it is better to install a small-sized output transformer, because a large current will flow through the 4 ohm head, which can overload the power supply and trigger a reset of the microcontroller.




Download add-ons

A year and a half ago on the site I told about. Comments came in asking to replace common cathode indicators with common anode indicators. Going to the meeting with a wish, I rewrote the timer program. But not significant changes were made and electrical circuit devices.

To simplify the program, it was decided to change the connection diagram of the LED indicating the start of the timer. The output to the LED was moved from pin 13 of DD1, this is the seventh bit of port B, to the fifteenth pin, the sixth bit of port A. The rest of the circuit remains the same. By the way, I think it is not advisable to use a composite three-ampere transistor KT973A in this design, and it is not always at hand at the right time. For an audio-frequency pulse amplifier, a low-power transistor KT361G may also be suitable.


Its collector capacity is 150 milliwatts. We look at the table. But it can be significantly increased if the transistor is supplemented with a heat sink, which can be made from a copper strip. The width of the strip is equal to the width of the transistor body, the length is arbitrary. The strip is bent in accordance with the photo.


A clip is made from a thinner strip, but you can also make it from the same strip as the heat sink itself. The heat sink is put on the body of the transistor through a heat-conducting paste. A well-made heat sink "sits" on the transistor body quite firmly and the collector power of the transistor can reach 500 ... 700 milliwatts.


And the sound volume with such a transistor power is quite enough even for large rooms. Moreover, the transistor in this circuit operates in a pulsed mode, and the efficiency is very high. If you make a hole in one of the bent sides of the strip, then such a heat sink can be attached to the board using a screw with a diameter of 2 ... 3 mm. Everything about everything takes me five minutes. The picture of the printed circuit board can be downloaded from the previous article "

This is a simple timer circuit based on a PIC16F628A microcontroller and an LCD 1602 indicator. The idea of ​​a timer is borrowed from a Portuguese electronics site.

The PIC16F628A microcontroller in this circuit is clocked by an internal oscillator, which is accurate enough for this case, but since pins 15 and 16 are left unoccupied, an external crystal resonator could be used for greater accuracy.

Timer on PIC16F628A. Work description

As mentioned earlier, this project was created on the basis of an existing project, but in fact, both schemes are different from each other, and therefore the code was almost completely rewritten. The timer has three buttons for control: "START / STOP", "MIN" and "SEC"

  1. "START / STOP" - to start and pause the timer.
  2. "MIN" - to set the minutes. The number of minutes is set from 0 to 99, and then everything starts over from 0.
  3. "SEC" - to set the seconds. The second is also set from 0 to 59 and then again from 0.

Pressing "MIN" and "SEC" at the same time will reset the timer during operation.

When the timer reaches 00:00, a beep sounds (3 short and 1 long beeps) and the HL1 LED lights up. An electromagnetic buzzer is used as a sound emitter. After that, when one of the buttons is pressed, the timer is reset and the HL1 LED turns off.

When the timer counts down on pin 13 (RB7) is high level, and when the timer stops, a low logic level appears. This conclusion can be used to control external executive devices. the timer is powered from a stabilized source on.

Jumper J1 is used to calibrate the timer. When it is closed, the timer enters the setting mode. Using the "MIN" and "SEC" buttons, you can increase / decrease the value of the internal parameter, which allows you to slow down or speed up the timer. This value is stored in the EEPROM. Pressing the START / STOP button while in this mode will reset this parameter to its default value.

The code is written and compiled with mikroC PRO for PIC.

Project parameters:

  • Generator: INTOSC
  • Oscillator frequency: 4 MHz
  • Watchdog Timer: Disabled
  • Power-up timer: included
  • RA5 / MCLR / VPP: Disabled
  • Brown-out: enabled

Photo of the finished timer.

This is another junk craft - a timer for the kitchen, although not necessarily for the kitchen. Parts that were lying around were used, in particular, old ALSki indicators, resistors soldered from old boards, etc. Microcontroller device basis PIC16F628A, one of the most common and cheapest. The timer is controlled by a knob and one button. Time delay range from 1 to 99 minutes. At the end of the timing cycle, an intermittent sound signal is emitted. And the archive contains two firmware, the first is just a timer, and the second with some bells and whistles, more on that below.

There is also an option for indicators with a common anode. Please note that the firmware for each of the schemes is different. All differences are highlighted in red on the diagram.

After turning on the power, the indicators show the specified time, the LED does not light up. By turning the encoder, the time setting can be changed from 1 to 99 minutes. When the time is set, press the button - a short beep sounds and the timer starts counting down, the LED blinks, and the time on the indicator decreases every minute. When the time has reached zero, the timer emits intermittent beeps, the LED lights up constantly. Now, by pressing the button, the sound signal is removed and the device returns to its original state - the time setting mode. This is how the first version of the firmware works.

The second version of the firmware works the same as the first, but has several additions. In time setting mode, if the knob is not touched for a few seconds, the animation starts running on the display. pressing the button or rotating the encoder will turn off the animation and re-display the time setting mode. During the countdown, if there is one minute left, the display will show seconds from 60 to 00. When the sound signal is triggered, it will sound not endlessly, but about 20 seconds. Then the display begins to indicate an animation splash screen (different from the one in the installation mode). And also, every minute it will remind you with a short sound signal. By pressing the button, as in the first firmware, the timer is reset to the time setting mode. When there are 3 seconds left until the timer expires, the timer emits a short beep for every second, i.e. 3 ... 2 ... 1 and further works as usual. Both firmwares are available and are in the archive along with the printed circuit board drawing.

The audio signal is implemented using the hardware PWM built into the microcontroller. The dynamic head should have a resistance of about 50 ohms. Low-impedance dynamic heads (4 or 8 ohms) can also be used, but in this case it is better to install a small-sized output transformer, because a large current will flow through the 4 ohm head, which can overload the power supply and trigger a reset of the microcontroller.

Printed circuit board, variant of Alexey Antonov

Comments (1)

1 2

0 # 21 kaktuss 06/14/2015 16:08

Quoting AntonChip:

You can see a screenshot of setting the configuration bits during programming


I asked the author what configuration for the firmware, he replied that everything is already in the firmware. Therefore, I did not install anything, I just uploaded the firmware.
I would post screenshots, but I don't know how. Can I send you an email?