Animated clock on pic16f628a. Clock - alarm clock on the microcontroller PIC16F628A

This device will allow you to count time, measure temperature, use a stopwatch. Additionally, this device keeps simple temperature statistics - minimum / maximum, but otherwise it differs little from a lot of similar devices. For indication, LED 7-segment indicators with a decimal point, green glow are used. The indication is dynamic.

The device has the following functions:

  • Indication of the current time in the HH.MM format for 3 seconds, then the readings switch to temperature, displaying with an accuracy of 0.1 degrees. Clock correction is only possible in this display mode.
  • Indication of the extremely low temperature for the current day, the indicator displays a small L in the first familiarity and then the temperature.
  • Indication of the maximum high temperature for the current day, the indicator displays a small h in the first familiarity.
  • The average temperature for the current day, the indicator displays a small c.
  • Indication of the extremely low temperature for the entire history of the thermometer, in the first familiarity a large letter L.
  • Indication of extremely high temperature for the entire history of operation, in the first familiarity a large H.
  • The average temperature for the entire history, in the first familiarity is a large C.
  • Time indication in MM.SS format (i.e. minutes and seconds). In this mode, correction is not possible.
  • Indication of the number of days elapsed since the device was turned on.
  • Stopwatch - having several indication limits (M.SS.D - MM.SS - H.MM.S - HH.MM). The stopwatch count limit is 100 hours. Then the stopwatch stops and the display shows BUSY.
  • Temperature records (not daily, but total for the entire history) are stored in non-volatile EEPROM memory
  • To measure the temperature, the DS18B20 sensor is used, this sensor is remote, installed “outside the window” to measure the street temperature. The remaining functions of the device are implemented purely in software. Data output to the indicator is carried out sequentially via 2 wires DATA and SYNCHRONIZATION. After all 8 bits are sequentially unloaded into the shift register K1533IR24, one of the transistors opens and lights up the desired familiarity. Then all the familiarity is turned off and a new value for the next digit is loaded into the register and after that the next transistor opens, thereby igniting the next familiarity. This happens very quickly, so visually it seems that the entire indicator is lit, all its familiarity.

    Only 2 buttons are used to control this device. Button S1 sequentially switches all display modes. And the S2 button is used to turn on the clock correction mode or to start / stop the stopwatch. In the clock correction mode, the hour digits flash first, the S2 button changes their value to 1, if you press S1 again, the minutes digits will flash, the S2 button will already affect them. Clock correction is only possible in the clock/temperature display mode. In other modes (except for the stopwatch), the S1 button does nothing. In stopwatch mode, the S1 button starts the count, and pressing it again stops it. The stopwatch will be reset to 0 by pressing the S2 button. If the stopwatch has already been reset, pressing S2 will switch the device to the next mode. In addition, when no buttons are pressed for 10 seconds, the indicators switch to a “muted” mode (this mode turned out to be a little clumsy, there is almost no noticeable decrease in brightness) in order to reduce power consumption and heating of the 7805 stabilizer. But as soon as any button is pressed, regardless of the current display mode - the indicators will return to full brightness again and the 10-second cycle will repeat.

    Some indication examples:
    - Temperature.

    — Time (HH.MM — dividing dot flashes).

    — The maximum temperature for the current day.

    — Minimum temperature for the current day.

    - The maximum temperature in the entire history of operation

    — The minimum temperature for the entire history of operation.

    - Number of days worked.

    - Stopwatch.

    — minutes-seconds (MM.SS — separating dot does not blink).

    Many device events have an audible signal.

  • Turn on / off / reset the stopwatch - 1 short.
  • The temperature dropped below zero, and earlier in the day it was not below zero (and so on, with a further decrease) - 1 short.
  • The temperature rose above 30 and was not above 30 before (and so on with a further increase) - 2 short.
  • A new record minimum or maximum temperature was obtained - 3 short ones.
  • Stopwatch overflow - 1 long and 2 short.
  • Turning on the device - 1 short.

    The device is assembled on a printed circuit board and housed in a suitable plastic case. Control buttons are displayed on the front panel, and holes with a diameter of 1.2 mm are drilled in the area of ​​\u200b\u200bthe sound emitter. There was already a window for the indicator in the case that came across to me. The sensor is mounted on a plastic tube at a distance of about 30 cm from the window; a box with holes is made of tin around the sensor to reduce the heating of the sensor by direct sunlight. To power the device from the network, an external power supply is used - an adapter with an output voltage of 9 volts, it does not have a stabilizer. Only a transformer, a diode bridge and a 470uF capacitor. Of course, it is better to use a backup power supply to power this device so that the clock does not reset when the mains voltage fails. The 7805 stabilizer chip must be equipped with a small heat sink and ensure its ventilation (several holes in the case). The microcontroller can be used in absolutely any temperature version.

    DOWNLOAD - Archive files(56 kb)
    contains a project for Proteus 7.5 SP3, a ready-made microcontroller firmware and a diagram in GIF format. In the firmware, record temperatures are immediately entered into EEPROM: the minimum is +20, and the maximum is +30 degrees, these values ​​\u200b\u200bare easy to correct right in the window of the programmer control program, they must be made equal to the current temperature of +100 so that the thermometer keeps correct statistics. Those. if you need to enter a start temperature equal to 10 degrees, then in fact you need to enter 110. In hexadecimal form, this will be 0x6E.

  • On MK. Its heart is the PIC16F628A microcontroller. The thermometer circuit uses a 4-digit or 2 + 2 LED indicator with a common anode. The temperature sensor is of the DS18B20 type, and in my case the sensor readings are displayed with an accuracy of 0.5*C. The thermometer has temperature measurement limits from -55 to + 125 * C, which is enough for all occasions. To power the thermometer, a conventional charging from a mobile phone on a power supply with a transistor 13001 was used.

    Schematic diagram of the thermometer on the PIC16F628A microcontroller:

    To flash the PIC16F628A, I used the ProgCode program, installing it on a computer and assembling the ProgCode programmer according to the well-known scheme:

    The designation of the pins of the used microcontroller and the pinout of some other similar MK:

    The ProgCode program and instructions with photos of the step-by-step firmware are in the archive on the forum. In the same place and all files necessary for this scheme. In the program, open and click on the "record everything" button. In my manufactured device, as can be seen from the photographs, 2 thermometers are assembled at once in one case, the upper indicator shows the temperature at home, the lower one - on the street. It is placed anywhere in the room and is connected to sensor flexible wire in the screen.Material provided by ansel73.Firmware edited: [)eNiS

    Clock on PIC16F628A and temperature sensor DS18B20.

    4-segment LED indicator.

    Animated display change.

    A variant of a simple clock on the popular and affordable PIC16F628A microcontroller. In fact, the project on AVR began with them.

    Description of the clock.


    1. Functions.

    – hours, time display format 24-hour, hours:minutes.

    – digital accuracy correction. Daily correction ±25 sec. is possible. The set value of 1 hour 0 minutes 30 seconds will be added/subtracted from the current time.

    - thermometer.

    - indication. Alternate.

    - Customizable animation of changing readings.

    – use of the non-volatile memory of the microcontroller to save the settings when the power is turned off.

    – if you press the button in the main modePLUS , then the time is displayed on the indicators, if you click onMINUS - temperature. When the buttons are released, automatic change of readings resumes.

    2. Setting.

    2.1. When the power is turned on, the clock is in the main mode.

    2.2. Push buttonSET enters the settings mode and selects the parameter to be set. In turn, available for installation:

    - minutes;

    - clock;

    – seconds (reset to zero when you press the buttonsPLUS orMINUS );

    – amount of correction. In the most significant digit, the symbol "with ";

    – time of indication of the current time. In high-order digits, the symbols "tc ". Setting range 0÷99 sec. If set to 0, the time will not be displayed;

    – temperature indication time. In high-order digits, the symbols "tt ". Setting range 0÷99 sec. If set to 0, the temperature will not be displayed;

    – selection of animation effect. In high-order digits, the symbols "EF ". If set to 0, the change of information will be carried out without effects, if automatic mode is selected (symbolBUT ), the effects will change in sequence. If the mode is selectedr , then the effects will change randomly.

    – selection of animation speed. In the most significant digit, the symbol "P ". The setting range is 0÷99. One unit corresponds to about 2 ms, the higher the value, the slower the animation.

    2.3. The parameter to be set flashes.

    2.4. Holding buttonsPLUS / MINUS the parameter is quickly set.

    3. Notes.

    It is necessary to measure the speed of animation and the time of displaying information. If a slow animation and a short display time are selected, then it may turn out that the information does not have time to fully update before the next shift.

    When the main power is turned off (+12V) the indication turns off, the clock continues to run. The MC is powered from a backup source.

    In the firmware archive for indicators with a common cathode and anode, a project in Proteus and a description.

    Questions, wishes in the forum.

    11.03.2015

    Added updated firmware for common cathode indicator. The new firmware has more animation effects and small changes in the algorithm. Detailed description in the archive.


    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:

    Table and wall clocks with thermometers are made in cases from analog clocks. The clock and the thermometer are made as separate, independent devices.

    I will not describe the thermometer, it is posted on the same site. The circuit, printed circuit board and firmware are there, everything is unchanged.

    The temperature sensor DS18B20 of the desktop clock is placed outside the window to the street. Insulated wires 0.35mm, length approximately 10 meters

    The clock is assembled on a single 7-segment green LED indicators. The size of the figure is 14x25.4mm - it is clearly visible from any corner of the room. Please note that the indicator is connected without quenching resistors. This is due to the fact that each segment consists of two LEDs connected in series and a nominal voltage of 3.8 volts. With dynamic indication, the currents do not exceed the permissible ones.

    The voltage stabilizer is located in the plug - adapter. It is assembled on a 3 watt transformer and a high-frequency converter - the LM2575T-5.0 stabilizer according to the standard scheme. The microcircuit without a radiator, practically does not heat up. Connector for the power supply 3.5mm. Quartz 4 MHz.

    Transistors n-p-n any low-power. Buttons 6x6 H=14/10mm soldered on the side of the conductors . The length of the button pusher is selected based on the requirements of the design. Each time the button is pressed, one is added. When held, the score accelerates to a reasonable speed.

    MLT resistors - 0.25. 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.

    It is desirable to select diodes with the smallest voltage drop in the forward direction.
    The boards are made of one-sided foil fiberglass.
    HEX file, scheme, seals in folder No. 1.

    Option 2: on one board

    Two boards did not fit into this case: a clock and a thermometer. I did not want to reduce the size of the clock indicator.

    I don’t like to display time and temperature with one indicator in turn in a desktop clock.
    I had to take another smaller indicator for the thermometer and draw a new printed circuit board. Therefore, the circuit and firmware for the thermometer are different.

    HEX file and thermometer diagram in folder No. 2. Printed circuit board in the same place.
    The clock scheme without any changes is taken from the first section.

    Below you can download firmware and printed circuit boards in HEX format

    List of radio elements

    Designation Type Denomination Quantity NoteScoreMy notepad
    Option 1
    MK PIC 8-bit

    PIC16F628A

    1 To notepad
    VR1 DC/DC switching converter

    LM2575

    1 5V To notepad
    VT1-VT4 bipolar transistor

    KT3102

    4 To notepad
    VD1, VD2, VD4 Diode

    D310

    3 To notepad
    VD3 Schottky diode

    1N5819

    1 To notepad
    VS1 Diode bridge

    DB157

    1 To notepad
    C1, C2 Capacitor20 pF2 To notepad
    C3, C5 Capacitor0.1uF2 To notepad
    C4 330uF 16V1 To notepad
    C6 electrolytic capacitor100uF 35V1 To notepad
    R1, R2 Resistor

    10 kOhm

    2 To notepad
    R3-R6 Resistor

    1 kOhm

    4 To notepad
    R7, R10 Resistor

    100 ohm

    2 To notepad
    L1 Inductor330 uH1 To notepad
    Tr1 Transformer 1 To notepad
    F1 Fuse100 mA1 To notepad
    Battery4.8V1 To notepad
    HL1, HL2 Light-emitting diode 2 To notepad
    S1, S2 Button 2 To notepad
    Z1 Quartz4 MHz1 To notepad
    IndicatorFYS10012BG211 To notepad
    Option 2
    MK PIC 8-bit

    PIC16F628A

    1 To notepad
    VT1-VT4 bipolar transistor

    KT3102

    1 To notepad
    C1, C2 Capacitor20 pF2 To notepad
    C3 Capacitor0.1uF1 To notepad
    R1 Resistor

    4.7 kOhm

    1 To notepad
    R2, R3, R5, R6 Resistor