Designs on pic16f628a. Diagram of electronic clock on pic16f628a - devices on mk - radio-bes - electronics for home


These electronic clocks are the simplest. They were assembled in a few hours. The basis of the PIC16F628A microcontroller, in addition to it, the clock contains several simple and cheap elements, information is displayed on a 4-digit (hour) LED indicator. The circuit is powered from the mains, and also has a backup power supply. This construction can be recommended to beginners, I specially provided the source program with detailed comments to make it easier to understand what and how it works here.

The scheme is very simple, simple and the algorithm of their work (see comments in the source). Buttons kn1 and kn2 are used to correct the time - hours and minutes, respectively. The clock has a 24 hour display format. In the 1st digit of the clock, the blanking of an insignificant zero is done. The accuracy of the clock depends entirely on the frequency of the quartz resonator. But even without special selections of quartz and capacitors in the clock generator, the clock is very accurate.

The clock is assembled on 2 printed circuit boards, docked one to one at an angle of 90 degrees. The whole indicator is placed on one board, and everything else on the other. The backup battery is broken from a Chinese lighter with an LED flashlight. We remove the LED, and install the battery holder on the board. The photo shows that the trimmed resistor leads are connected to the batteries - they then hold the whole structure. Of course, the capacity of such batteries is small, but when the watch is powered by the mains, no current is consumed from the batteries. They feed the circuit only when there is no mains power. In this case, only the microcontroller is powered, the indicator is not powered by batteries, so it goes out, and the clock continues to run. The control buttons are moved from the board to any convenient place in the case. The design of the buttons can be any. For mains power, a Chinese PSU adapter was used, to which a board with a 7805 microcircuit (5-volt stabilizer) was added. Just do any power supply, with an output voltage of 5V and a current of 150mA.

The program is written in such a way that it can be used for the initial study of the PIC microcontroller, the action of almost every command is commented. If desired, you can easily add additional functions to it, such as a calendar, timer, stopwatch, etc.



File:
The size:
Content:


This version of the clock is made in such a way as to simplify the circuit as much as possible, reduce power consumption, and ultimately get a device that fits easily in your pocket. Having chosen miniature batteries to power the circuit, SMD - mounting and a miniature speaker (for example, from a non-working mobile phone), you can get a design that is slightly larger than a matchbox.
The use of a super-bright indicator allows you to reduce the current consumed by the circuit. Reducing the current consumption is also achieved in the "LoFF" mode - the indicator is off, while only the blinking dot of the least significant bit 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. The transition through the modes is carried out using the "plus" and "minus" buttons. Before displaying the indications themselves, a short hint of the mode name is displayed on the indicators. The duration of the hint output is one second. The use of short-term hints made it possible to achieve good ergonomics of the watch. When switching between display modes (which turned out to be quite a lot for such a simple device as an ordinary watch), there is no confusion, and it is always clear which readings are displayed on the indicator.


Correction of the 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 at a frequency of 2 Hz. The readings are adjusted using the plus and minus buttons. When the button is pressed for a long time, the auto-repeat mode is activated, with a given frequency. Button press auto-repeat frequencies are: for hours, months and day of the week - 4 Hz; for minutes, year and indicator brightness - 10 Hz; for the corrective value - 100 Hz.
All corrected values, except for hours, minutes and seconds, are written to EEPROM and restored after turning off - turning on the power. Seconds are reset to zero when corrected. From all modes, except hours-minutes, minutes-seconds and LoFF automatic return is organized. If none of the buttons is pressed within 10 seconds, the watch switches to the hours-minutes display mode.
By pressing the button "On / Off bud." turns on/off the alarm. The activation of the alarm is confirmed by a short two-tone sound. When the alarm clock is on, the dot in the low-order digit of the indicator lights up.
In the "Corr" mode, a correction constant is displayed on the indicator, the initial value of which is 5000 microseconds per second. When the clock lags, we increase the constant by the amount of lag, calculated in microseconds per second. If the clock is in a hurry, then we reduce the constant according to the same principle.

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

The control panel is implemented on the PIC12F629 microcontroller. The remote control is powered by a conventional battery for motherboard computers. 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 for 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 for which the alarm is set (the colon does not blink), or --:-- if the alarm is off. Pressing the CLOCK button again, or after 6 seconds, the device will again display the current time. Pressing the COR button puts the device into the clock correction mode if the clock is currently displayed; or to the alarm setting mode if the alarm is shown on the display. The first press - the hours are flashing, the hours are set with the +1 button, the second press of the COR button - the minutes are flashing - the minutes are set with the +1 button, the third press is the exit from the clock correction mode (or alarm clock). If the alarm time is corrected, it will automatically turn on.

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

In the clock indication mode (the colon blinks) - pressing the +1 button - switches the clock to the "night" mode - in this mode, the indicator goes out completely and only the colon blinks, which reduces power consumption and does not create unnecessary night illumination. At the same time, pressing any button on the remote control, as well as triggering, takes the clock out of night mode.

If the alarm goes off, an audible signal sounds for one minute, all the numbers on the display flash. Pressing any button on the remote control turns off the alarm (without resetting its setting time).

For backup power of the watch, 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 used low-voltage - PIC16LF628A. If you use a battery with a voltage of more than 3.6V, then the usual PIC16F628A will do. Well, a completely ideal option is to use a microcontroller with NANOWATT technology - PIC16F819 (Attention! a different firmware is used for this microcontroller).

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

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

I removed the 7805 regulator because 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 for the purchased LCD module.
All three capacitors are 10uF tantalum. It should be noted that the capacitor C7 - 100uF is actually 1000uF.
Two 1000pF styroflex capacitors with 1% tolerance, 82uH inductive coil.

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

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




The last two photos show the LC meter in action. On the first of them, the measurement of the capacitance of a 1nF capacitor with a deviation of 1%, and on the second, the 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.

Clock with a small 4-digit indicator. The dot between hours and minutes flashes at a frequency of 0.5 seconds. It can be built into any object: a desk calendar, a radio, a car. Estimated error - 0.00002%. In practice, for six months there has never been a need for correction.

Power supply 4.5 - 5 volts, current up to 70mA. The voltage stabilizer is located in the plug - adapter. It is assembled on a 3 watt transformer and a high-frequency converter - stabilizer according to the standard scheme. 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. Transistors n-p-n any low-power.

Any buttons . The length of the button pusher is selected based on the requirements of the design. You can solder the buttons on the side of the conductors. Each time the button is pressed, one is added. When held, the score accelerates to a reasonable speed.

MLT resistors - 0.25. R7 - R14 300 - 360 ohms. R3 - R6 1-3 kOhm.
Batteries: 4 pieces from GP-170 or similar. When the mains voltage is turned off, they feed only the microcontroller. 8 days stand exactly, checked.
Diodes with the lowest forward voltage drop.

The boards are made of one-sided foil fiberglass.

Before installing the microcontroller into the panel of the manufactured board, turn on the power and measure the voltage on the 14th leg of the panel. Should be 4.5 - 4.8 volts. Pin 5 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 a 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 clock unit indicator will be connected to zero.
  • Connect any wire with one end to +, and with the other end alternately touch terminals 6,7,8,9,10,11,12,13 of the panel.
  • At the same time, observe the igniting segments and their correspondence to the scheme: + on the 6th leg - segment "g" is lit, and so on.
  • Move the jumper to terminals 2 and 14 of the panel. Check all segments of the minute units indicator.
  • Jumper 18 and 14 - tens of hours are checked, 17 and 14 - tens of minutes.

If something doesn't work, 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 get your watch ready.

If you buy all the details, including resistors, then, in accordance with my scheme, 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.
  • Tutorial on programming PIC controllers for beginners. Evgeny Korabelnikov. 2008

Below you can download firmware and PCB in LAY format

List of radio elements

Designation Type of Denomination

Score

MK PIC 8-bit

PIC16F628A

1
Store search
VR2 DC/DC switching converter

LM2575

1 5VStore search
VT1-VT4 bipolar transistor

KT315A

4
Store search
VD1, VD3, VD4 Diode

D310

3
Store search
VD2 Schottky diode

1N5819

1
Store search
VD5 Diode bridge

DB157

1
Store search
C1, C2 Capacitor20 pF2
Store search
C3 Capacitor0.1uF1
Store search
C4 330uF 16V1
Store search
C5 electrolytic capacitor100uF 35V1
Store search
R1, R2 Resistor

10 kOhm

2
Store search
R3-R6 Resistor

1.5 kOhm

4
Store search
R7-R9, R11-R14 Resistor

300 ohm

7
Store search
R10 Resistor

360 ohm

1
2022 x360ce.ru
Photography - Information portal