Clock on pic16f628a and LED indicators. Circuit diagram of an electronic clock on pic16f628a - devices based on MK - radio-bes - electronics for the home. Diagram of the new clock on PIC16F628A

Tabletop and Wall Clock with thermometers are made in cases from analogue clocks. The clock and thermometer are manufactured as separate, independent devices.

I won’t describe the thermometer; it is posted on the same website. The circuit, printed circuit board and firmware are there, everything is unchanged.

The temperature sensor DS18B20 of the table clock is located outside the window. Insulated wires 0.35mm, approximately 10 meters long

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

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

Transistors npn any low-power ones. Buttons 6x6 H=14/10mm soldered on the conductor side . The length of the button pusher is selected based on the design requirements. Each time you press the button, a 1 is added. When held, the count speeds up to a reasonable speed.

Resistors MLT – 0.25. R3 – R6 1-3 kOhm.

Batteries: 4 pieces of GP-170, or similar. When the mains voltage is turned off, they only supply power to the microcontroller.

It is advisable to select diodes with the lowest voltage drop in the forward direction.
The boards are made of one-sided foil fiberglass.
HEX file, diagram, stamps in folder No. 1.

Option 2: on one board

This case did not fit two boards: a clock and a thermometer. I didn't want to reduce the size of the clock indicator.

I don’t like displaying time and temperature with one indicator in turn on a table 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 diagram without any changes is taken from the first section.

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

List of radioelements

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

PIC16F628A

1 To notepad
VR1 DC/DC pulse 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.1 µF2 To notepad
C4 330 µF 16 V1 To notepad
C6 Electrolytic capacitor100 µF 35 V1 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 µH1 To notepad
Tr1 Transformer 1 To notepad
F1 Fuse100 mA1 To notepad
Battery4.8 V1 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.1 µF1 To notepad
R1 Resistor

4.7 kOhm

1 To notepad
R2, R3, R5, R6 Resistor

Thermometer on the PIC16F628A and DS18B20 (DS18S20) microcontroller - an article with a detailed description of the memory thermometer circuit and, in addition, a logical continuation of the article I previously published on the Yandex site pichobbi.narod.ru. This thermometer has proven itself quite well, and it was decided to modernize it a little. In this article I will tell you what changes have been made to the scheme and work program, I will describe the new functions. The article will be useful for beginners. Later I converted the current version of the thermometer into .

The thermometer on the PIC16F628A and DS18B20 (DS18S20) microcontroller can:

  • measure and display temperature in the range:
    -55...-10 and +100...+125 with an accuracy of 1 degree (ds18b20 and ds18s20)
    -in the range -9.9...+99.9 with an accuracy of 0.1 degrees (ds18b20)
    -in the range -9.5...+99.5 with an accuracy of 0.5 degrees (ds18s20);
  • Automatically detect DS18B20 or DS18S20 sensor;
  • Automatically check the sensor for failure;
  • Remember the maximum and minimum measured temperatures.

The thermometer also provides for easy replacement of the 7-segment indicator from OK to an indicator with OA. A gentle procedure for writing to the EEPROM memory of the microcontroller has been organized. A voltmeter that has proven itself well is described in this article -.

The circuit diagram of a digital thermometer on a microcontroller was developed for reliable and long-term use. All the parts used in the circuit are not in short supply. The pattern is easy to follow and perfect for beginners.

The schematic diagram of the thermometer is shown in Figure 1

Figure 1 - Schematic diagram of a thermometer on PIC16F628A + ds18b20/ds18s20

Describe all schematic diagram I won’t use a thermometer, since it’s quite simple, I’ll just focus on the features.

Used as a microcontroller PIC16F628A from Microchip. This is an inexpensive controller and also not in short supply.

Digital sensors are used to measure temperature DS18B20 or DS18S20 from Maxim. These sensors are inexpensive, small in size, and information about the measured temperature is transmitted digitally. This solution allows you not to worry about the cross-section of the wires, their length, etc. Sensors DS18B20,DS18S20 capable of operating in the temperature range from -55… +125 °C.

The temperature is displayed on a 7-segment 3-digit LED indicator with a common cathode (OK) or with (OA).

To display the maximum and minimum measured temperatures on the indicator, you need the SB1 button. To reset the memory you also need the SB1 button

Using the SA1 button you can quickly switch sensors (street, house).

A jumper is needed to switch the common wire for the LED indicator. IMPORTANT! If the indicator is OK, then we put the jamper in the lower position according to the diagram, and solder the transistors VT1-VT3 with p-n-p conductivity. If the LED indicator is OA, then we move the jamper to the upper position according to the diagram, and solder the transistors VT1-VT3 with n-p-n conductivity.

In Table 1 you can see the entire list of parts and their possible replacement with an analogue.

Table 1 – List of parts for assembling the thermometer
Position designation Name Analogue/replacement
C1, C2 Ceramic capacitor - 0.1 μFx50V -
C3 Electrolytic capacitor - 220μFx10V
DD1 Microcontroller PIC16F628A PIC16F648A
DD2,DD3 Temperature sensor DS18B20 or DS18S20
GB1 Three 1.5V AA batteries
HG1 7-segment LED indicator KEM-5631-ASR (OK) Any other low-power for dynamic indication and suitable for connection.
R1,R3,R14,R15 Resistor 0.125W 5.1 Ohm SMD size 0805
R2,R16 Resistor 0.125W 5.1 kOhm SMD size 0805
R4,R13 Resistor 0.125W 4.7 kOhm SMD size 0805
R17-R19 Resistor 0.125W 4.3 kOhm SMD size 0805
R5-R12 Resistor 0.125W 330 Ohm SMD size 0805
SA1 Any suitable switch
SB1 Tact button
VT1-VT3 Transistor BC556B for indicator with OK/transistor BC546B for indicator with OA KT3107/KT3102
XT1 Terminal block for 3 contacts.

For initial debugging of the digital thermometer, a virtual model built in Proteus was used. In Figure 2 you can see a simplified model in Proteus

Figure 2 – Model of a thermometer on the PIC16F628A microcontroller in Proteus

Figure 3-4 shows the circuit board of the digital thermometer

Figure 3 – Printed circuit board of a thermometer on a PIC16F628A microcontroller (bottom) not to scale.

Figure 4 – Printed circuit board of a thermometer on a PIC16F628A microcontroller (top) not to scale.

The thermometer, assembled working parts, starts working immediately and does not need debugging.

The result of the work is Figures 5-7.

Figure 5 - Appearance thermometer

Figure 6 - Appearance of the thermometer

Figure 7 - Appearance of the thermometer

IMPORTANT! In the thermometer firmware not sewn in advertising can be used for your pleasure.

Amendments made to the work program:

1 automatic detection of DS18B20 or DS18S20 sensor;

2. The rewriting time in EEPROM has been reduced (if the condition for rewriting is met) from 5 minutes to 1 minute.

3. The blinking frequency of the dot has been increased;

More detailed description The operation of the thermometer can be viewed in the document, which can be downloaded at the end of this article. If you don’t want to download, then on the website www.pichobbi.narod.ru The operation of the device is also perfectly described.

The finished board fit perfectly into a Chinese alarm clock (Figures 8, 9).

Figure 8 – All the stuffing in a Chinese alarm clock

Figure 9 - All the filling in the Chinese alarm clock

Video - Thermometer operation on PIC16F628A


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

The circuit 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, an insignificant zero has been suppressed. 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 runs very accurately.

The clock is assembled on 2 printed circuit boards, docked one to the other at an angle of 90 degrees. The entire indicator is placed on one board, and everything else is on the other. The backup battery was 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 cut-off resistor leads are connected to the batteries - they hold this entire structure. Of course, the capacity of such batteries is small, but when the watch is powered from the mains, no current is consumed from the batteries. They power the circuit only if 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 tick. The control buttons are located on the board in any convenient place on the case. The design of the buttons can be any. To supply power from the network, a Chinese power supply adapter was used, to which a board with a 7805 chip (5-volt stabilizer) was added. In general, any power supply with an output voltage of 5V and a current of 150mA will do.

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



File:
Size:
Content:

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

The device has the following functions:

  • Indication of the current time in HH.MM format for 3 seconds, then the readings switch to temperature, display 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 lights up a small L in the first familiar place and then the temperature.
  • Indication of the maximum temperature for the current day; the indicator lights up a small h in the first familiar place.
  • Average temperature for the current day, the indicator displays a small c.
  • Indication of the lowest possible temperature in the entire history of the thermometer, with a large letter L in the first acquaintance.
  • Indication of the highest temperature in the entire history of operation, in the first familiar place there is a large H.
  • The average temperature for the entire history, in the first acquaintance is high C.
  • Time display in MM.SS format (i.e. minutes and seconds). In this mode, correction is not possible.
  • Indication of the number of days passed since the device was turned on.
  • Stopwatch - having several indication limits (M.SS.D - MM.SS - H.MM.S - HH.MM). The stopwatch counting limit is 100 hours. Then the stopwatch stops and BUSY appears on the display.
  • Temperature records (not daily, but total for the entire history) are stored in non-volatile EEPROM memory
  • To measure temperature, a DS18B20 sensor is used; this sensor is remote and 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 loaded into the shift register K1533IR24, one of the transistors opens and lights up the desired familiarity. Next, all familiarizations are turned off and a new value for next digit and after that the next transistor opens, thereby igniting the next familiarity. This happens very quickly, so visually it seems that the entire indicator, all its familiar places, are lit.

    To control this device, only 2 buttons are used. 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 minute digits will flash, the S2 button will influence them. Clock correction is only possible in the clock/temperature display mode. In other modes (except for the stopwatch), the S1 button does not perform any action. In stopwatch mode, the S1 button starts counting, and pressing it again stops it. The stopwatch is reset to 0 by pressing button S2. If the stopwatch has already been reset, pressing S2 will switch the device to the next mode. In addition, when the buttons are not pressed for 10 seconds, the indicators switch to a “muted” mode (this mode turned out to be a little clumsy, the decrease in brightness is almost not noticeable) in order to reduce power consumption and heating of the 7805 stabilizer. But as soon as any button is pressed, regardless of current display mode - the indicators will return to full brightness and the 10-second cycle will repeat.

    Some indication examples:
    - Temperature.

    — Time (HH.MM - the dividing dot blinks).

    — Maximum temperature for the current day.

    — Minimum temperature for the current day.

    — Maximum temperature in the entire operating history

    — Minimum temperature for the entire history of operation.

    — Number of days worked.

    - Stopwatch.

    - minutes-seconds (MM.SS - the dividing dot does not blink).

    Many device events have an audible alarm.

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

    The device is assembled on printed circuit board, and housed in a suitable plastic housing. On front panel control buttons were removed, and holes with a diameter of 1.2 mm were drilled in the area of ​​the sound emitter. The case I came across already had a window for the indicator. The sensor is mounted on a plastic tube at a distance of approximately 30 cm from the window; a box with holes is made of tin around the sensor to reduce heating of the sensor by direct lines sun rays. 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. Transformer only diode bridge and a 470uF capacitor. Of course, it is better to use a power supply with backup power to power this device, so that the clock does not reset when the power goes out. The 7805 stabilizer chip must be equipped with a small heat sink and its ventilation must be provided (several holes in the case). The microcontroller can be used in absolutely any temperature version.

    DOWNLOAD – File Archive(56 kb)
    contains a project for Proteus 7.5 SP3, ready-made microcontroller firmware and a diagram in GIF format. In the firmware, record temperatures are immediately entered into the EEPROM: the minimum is +20, and the maximum is +30 degrees, these values ​​can be easily adjusted directly in the programmer control program window, they need to be made equal to the current temperature +100 so that the thermometer keeps correct statistics. Those. if you need to enter a starting temperature of 10 degrees, then you actually need to enter 110. In hexadecimal it will be 0x6E.

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

    Power supply 4.5 - 5 volts, current up to 70mA. The voltage stabilizer is located in the adapter plug. It is assembled on a 3-watt transformer and a high-frequency converter - stabilizer according to a standard circuit. For a car, of course, a transformer is not needed. The microcircuit does not heat up without a heatsink. Connector for 3.5mm power supply. 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 buttons on the conductor side. Each time you press the button, a 1 is added. When held, the counting speeds up to a reasonable speed.

    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 turned off, they only supply power to the microcontroller. They hold up for 8 days exactly, I checked. Diodes with the lowest voltage drop in the forward direction. 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 socket. It should be 4.5 - 4.8 volts. On the 5th leg 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 jumper from the bare wire into the socket, terminals 1 and 14. This means that +4.5 volts from the first leg will open transistor VT 2 through a resistor 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 socket.
    • At the same time, observe the lighting segments and their correspondence to the diagram: + on the 6th leg - segment “g” is lit and so on.
    • Move the jumper to terminals 2 and 14 of the socket. Check all segments of the minutes unit indicator.
    • Jumper 18 and 14 - tens of hours are checked, 17 and 14 - tens of minutes.

    If something doesn't work correctly, fix it. If everything is correct, program the microcontroller and insert it into the socket with the power off. HEX file is attached. Turn on the power and get a ready-made watch.

    If you buy all the parts, including resistors, then according to my diagram the device will cost about 400 rubles:

    • - 22.8 UAH
    • - 10 UAH
    • FYQ 3641AS21 - 9.3 UAH
    • Panel - 3 UAH
    • Quartz - 1.5 UAH

    Source: www.cxem.net


    This diagram is also often viewed: