Alarm clock with remote control on PIC16F628A - Devices on microcontrollers - Schemes of devices on microcontrollers. Clock - alarm clock on the microcontroller PIC16F628A Pic16f628a device diagrams


This version of the watch is made in such a way as to simplify the circuit as much as possible, reduce power consumption, and, as a result, get a device that fits easily in your pocket. By choosing miniature batteries for powering the circuit, SMD - mounting and a miniature speaker (for example, from a non-working mobile phone), you can get a structure slightly larger than a matchbox.
The use of a super-bright indicator allows you to reduce the current consumed by the circuit. A decrease in the current consumption is also achieved in the "LoFF" mode - the indicator is off, while only the blinking point of the least significant digit of the clock is on.

Indication
Adjustable brightness of the indicators allows you to choose the most comfortable display of readings (and again, reduce power consumption).
The watch has 9 display modes. Switching between modes is carried out using the "plus" and "minus" buttons. Before displaying the readings themselves, a short hint of the mode name is displayed on the indicators. Duration of displaying a hint is one second. The use of short-term prompts made it possible to achieve good ergonomics of the watch. When going through the display modes (which turned out to be quite a lot, for such a simple device as a regular watch), there is no confusion, and it is always clear which readings are displayed on the indicator.


Correction of readings displayed on the indicator is activated by pressing the "Correction" button. In this case, a short prompt is displayed for 1/4 second, after which the corrected value starts flashing with a frequency of 2 Hz. The readings are corrected with the "plus" and "minus" buttons. When you press the button for a long time, the autorepeat mode is activated, with a specified frequency. The autorepeat frequencies for pressing the button are: for hours, months and days of the week - 4 Hz; for minutes, year and indicator brightness - 10 Hz; for the correction value - 100 Hz.
All corrected values, except for hours, minutes and seconds, are written to the EEPROM and restored after power off / on. Seconds are reset to zero during correction. Of all modes, except for hours-minutes, minutes-seconds and LoFF, an automatic return is organized. If within 10 seconds none of the buttons is pressed, the watch switches to the display mode of hours - minutes.
By pressing the "On / Off bud." the alarm clock turns on / off. The activation of the alarm is confirmed by a short two-tone sound. When the alarm clock is on, a dot in the lowest digit of the indicator glows.
In the "Corr" mode, the indicator displays a correction constant, the initial value of which is 5000 microseconds per second. When the clock lags, the constant is increased by the amount of lag calculated in microseconds per second. If the clock is in a hurry, then the constant is reduced by the same principle.

Frequency meter schematic diagram

The PIC16F628A microcontroller serves to do all the work without any additional microcircuits. The 16F628A has 16 I / O pins, two of which are used for the crystal oscillator, one is for signal input and the other can be used for input only, which gives us only 12 useful I / O pins. The solution is to put a transistor that opens when all other digits are turned off.

7 segment LED display used here with common cathode type BC56-12SRWA. When all signals are high, Q1 turns on and switches on the first digit. The current for each segment is about 7 mA.

The entire frequency counter circuit consumes a current of about 30 mA on average. The microcontroller uses its internal 4 MHz oscillator to clock the CPU. And an external crystal oscillator with a frequency of 32768 Hz is needed to set 1 second time interval. Tmr0 is used to count the input signal at pin RA4.

You will need 5 volts of a rectangular shape as an input signal. The frequency counter itself can measure up to 1 megahertz, which is more than enough for amateur projects. This is for convenience, since the counter can go up to 999999 Hz - and you don't need to switch anything. We measure at least 11 hertz, at least 139.622 kilohertz.

In general, if anyone has a desire to repeat this project themselves, here are the files. The board in the archive is slightly different from the one in the photo, some optimizations were made later. And the program code is open - you can optimize it if you know how to optimize it.

Here is another example of laboratory equipment - LC meter. This measurement mode, especially the L measurement, is almost impossible to find in cheap factory multimeters.

Scheme of this LC meter on microcontroller was taken from www.sites.google.com/site/vk3bhr/home/index2-html. The device is built on a 16F628A PIC microcontroller, and since I recently purchased a PIC programmer, I decided to try it out with this project.

I removed the 7805 regulator as I decided to use a 5 volt cell phone charger.

The circuit has a 5 kΩ trimmer resistor, but in fact I put 10 kΩ, according to the datasheet, on the purchased LCD module.
All three 10uF tantalum capacitors. It should be noted that capacitor C7 - 100uF is actually 1000uF.
Two 1000pF capacitors styroflex capacitors with 1% tolerance, 82μH inductive coil.

The total current consumption with the backlight is about 30mA.
Resistor R11 limits the backlight current and must be sized according to the actual LCD module used.

I used the original PCB drawing as a starting point and modified it to match the components I have.
Here's the result:




The last two photos show the LC meter in action. On the first of them, measuring the capacitance of a 1nF capacitor with a deviation of 1%, and on the second, an inductance of 22μH with a deviation of 10%. The device is very sensitive - that is, with an unconnected capacitor, it shows a capacitance of the order of 3-5 pF, but this is eliminated by calibration.

Watch with a small 4-digit indicator. The dot between hours and minutes flashes at a rate of 0.5 seconds. Can be built into any object: a desk calendar, a radio, a car. The calculated error is 0.00002%. In practice, for half a year there was never a need for correction.

Power supply 4.5 - 5 volts, current up to 70mA. The voltage regulator is located in the adapter plug. It is assembled on a 3-watt transformer and a high-frequency converter - stabilizer according to the standard circuit. For a car, of course, a transformer is not needed. The microcircuit without a radiator, practically does not heat up. Connector for power supply 3.5mm. Quartz 4 MHz. Any low-power n-p-n transistors.

Any buttons . The length of the button pusher is selected based on the design requirements. You can also solder the buttons from the side of the conductors. Each time you press the button, a one is added. When held, the count is accelerated to a reasonable rate.

Resistors MLT - 0.25. R7 - R14 300 - 360 Ohm. R3 - R6 1-3 kOhm.
Batteries: 4 pieces of GP-170, or similar. When the mains voltage is disconnected, they only supply the microcontroller. 8 days are kept exactly, checked.
Diodes with the lowest forward voltage drop.

The boards are made of one-sided foil-coated fiberglass.

Before installing the microcontroller in the panel of the manufactured board, turn on the power and measure the voltage on the 14th leg of the socket. Should be 4.5 - 4.8 volts. The 5th leg has 0 volts. If you are not sure about the quality of the manufactured board or the serviceability of the parts, check the device without a microcontroller. This is done very simply:

  • Insert the bare wire jumper into the socket, terminals 1 and 14. This means that +4.5 volts from the first leg through the resistor will open the transistor VT 2 and the cathode of the hour units indicator will be connected to zero.
  • Connect any wire with one end to +, and the other end alternately touch the terminals 6,7,8,9,10,11,12,13 of the socket.
  • At the same time, observe the lighted segments and their correspondence to the scheme: + on the 6th leg - the "g" segment is on and so on.
  • Move the jumper to terminals 2 and 14 of the socket. Check all segments of the minutes indicator.
  • Jumper 18 and 14 - tens of hours are checked, 17 and 14 - tens of minutes.

If something is wrong, fix it. If everything is correct, program the microcontroller and insert, with the power off, into the socket.
HEX file is attached.
Turn on the power and have a ready clock.

If you buy all the parts, including resistors, then, in accordance with my diagram, the device will cost about 400 rubles:

  • PIC16F628A - 22.8 UAH
  • LM2575T-5.0 - 10 UAH
  • FYQ 3641AS21 - 9.3 UAH
  • Socket - 3 UAH
  • Quartz - 1.5 UAH

Literature:

  • Pic microcontrollers. Everything you need to know. Sid Katzen. 2008.
  • PIC microcontrollers. Architecture and programming. Michael Predko. 2010
  • Pic microcontrollers. Application practice. Christian Tavernier. 2004.
  • Development of embedded systems using PIC microcontrollers. Tim Wilmshurst. 2008
  • Data sheet: PIC16F628A, FYQ 3641, LM2575.
  • A tutorial on programming PIC controllers for beginners. Evgeny Korabelnikov. 2008

Below you can download the firmware and PCB in LAY format

List of radioelements

Designation A type Denomination

Score

MK PIC 8-bit

PIC16F628A

1
Search in store
VR2 DC / DC pulse converter

LM2575

1 5BSearch in store
VT1-VT4 Bipolar transistor

KT315A

4
Search in store
VD1, VD3, VD4 Diode

D310

3
Search in store
VD2 Schottky diode

1N5819

1
Search in store
VD5 Diode bridge

DB157

1
Search in store
C1, C2 Capacitor20 pF2
Search in store
C3 Capacitor0.1 uF1
Search in store
C4 330 uF 16 V1
Search in store
C5 Electrolytic capacitor100 uF 35 V1
Search in store
R1, R2 Resistor

10 kΩ

2
Search in store
R3-R6 Resistor

1.5 k Ohm

4
Search in store
R7-R9, R11-R14 Resistor

300 Ohm

7
Search in store
R10 Resistor

360 Ohm

1

This device is an ordinary electronic clock with an alarm clock, but they are controlled by a remote control using IR rays. The clock is implemented in software, the indication is dynamic. The circuit provides backup power in case of power outage. The alarm clock is implemented on a simple "buzzer" with a built-in generator - buzzer.

The control panel is implemented on the PIC12F629 microcontroller. The remote control is powered by a regular battery for the computer motherboard. If none of the buttons is pressed, the microcontroller is in SLEEP mode and practically does not consume current. As soon as the button is pressed, the microcontroller "wakes up" and generates a code message to the IR LED.


When the power is turned on, the display shows the current time, the colon flashes. If you press the CLOCK button, the display will show the time at which the alarm is set (the colon does not flash), or -: - if the alarm is off. Pressing the CLOCK button again, or after 6 seconds, the device will display the current time again. Pressing the COR button switches the device to the clock correction mode if the clock is currently displayed; or to the alarm setting mode if the alarm clock is displayed. The first press - the hours blink, the +1 button sets the hours, the second press of the COR button - the minutes flash - the +1 button sets the minutes, the third press - exits the clock correction mode (or alarm clock). If the alarm time is adjusted, it will automatically turn on.

When the display indicates the time for setting the alarm (turned on by the CLOCK button) - pressing the +1 button turns on, and pressing the button again turns off the alarm, the display, accordingly, shows the time for setting the alarm, or -: - (the colon does not flash). If the alarm is turned off, its setting time is not reset.

In the clock display mode (the colon is blinking) - pressing the +1 button - switches the clock to the "night" mode - in this mode the indicator completely goes out and only the colon blinks, which reduces power consumption and does not create unnecessary night illumination. In this case, pressing any button on the remote control, as well as triggering, removes the clock from the night mode.

If the alarm is triggered, a sound signal sounds for one minute, all the digits on the display are blinking. Pressing any button on the remote control turns off the alarm (without resetting its setting time).

To back up the clock, as well as in the control panel, a battery from the computer motherboard is used. Its voltage is 3V, so the microcontroller in the clock needs to be applied low-voltage - PIC16LF628A. If you use a battery with a voltage of more than 3.6V, then the usual PIC16F628A will do. Well, an absolutely ideal option is to use a microcontroller with the NANOWATT technology - PIC16F819 (Attention! This microcontroller uses a different firmware).