LED clock circuits. Electronic LED clock

LED simple clock can be done on a cheap PIC16F628A controller. Of course, the stores are full of various electronic watches, but their functions may either lack a thermometer or an alarm clock, or they may not glow in the dark. And in general, sometimes you just want to solder something yourself, rather than buy ready-made ones. Click to enlarge the diagram.

The offered watches have a calendar. It has two options for displaying the date - the month as a number or a syllable, all this is configured after entering the date by switching further with the button S1 during display required parameter, thermometer. There are firmwares for different sensors. See the device inside the case:


Everyone knows that quartz resonators are not ideal in accuracy, and within a few weeks the error accumulates. To combat this issue, the watch has a rate correction, which is set by parameters SH And SL. More details:

SH=42 and SL=40 are forward by 5 minutes per day;
SH=46 and SL=40 are backward by 3 minutes per day;
SH=40 and SL=40 are forward by 2 minutes per day;
SH=45 and SL=40 are backward by 1 minute per day;
SH=44 and SL=С0 - this is forward by 1 minute per day;
SH=45 and SL=00 - this correction is disabled.

This way you can achieve perfect accuracy. Although you will have to adjust the correction several times until it is set perfectly. And now the operation of an electronic clock is clearly shown:

temperature 29 degrees Celsius

As indicators, you can use either LED dial assemblies, which are indicated in the diagram itself, or replace them with ordinary round super-bright LEDs - then these clocks will be visible from afar and can be hung even on the street.

Not long ago there became a need to have a clock in the house, but only an electronic one, since I don’t like clocks, because they tick. I have quite a bit of experience in soldering and etching circuits. After scouring the Internet and reading some literature, I decided to choose the most simple diagram, since I don't need an alarm clock.

I chose this scheme because it’s easy make your own watch

Let's get started, so what do we need in order to make a watch with our own hands? Well, of course, hands, skill (not even great) in reading circuit diagrams, soldering iron and parts. Here's a complete list of what I used:

10 MHz quartz – 1 pc., ATtiny 2313 microcontroller, 100 Ohm resistors – 8 pcs., 3 pcs. 10 kOhm, 2 capacitors of 22 pF, 4 transistors, 2 buttons, LED indicator 4-bit KEM-5641-ASR (RL-F5610SBAW/D15). I performed the installation on a one-sided PCB.

But there is a flaw in this scheme: the pins of the microcontroller (hereinafter referred to as MK), which are responsible for controlling the discharges, receive quite a decent load. Current in total amount far exceeded from maximum current port, but with dynamic display the MK does not have time to overheat. To prevent the MK from malfunctioning, we add 100 Ohm resistors to the discharge circuits.

In this scheme, the indicator is controlled according to the principle of dynamic indication, according to which the indicator segments are controlled by signals from the corresponding outputs of the MK. The repetition rate of these signals is more than 25 Hz and because of this, the glow of the indicator numbers seems continuous.

Electronic watches made according to the above scheme can only show time (hours and minutes), and seconds are shown by a dot between the segments, which is flashing. To control the operating mode of the watch, push-button switches are provided in its structure, which control the setting of hours and minutes. This circuit is powered from a 5V power supply. During the manufacture of the printed circuit board, a 5V zener diode was included in the circuit.

Since I have a 5V power supply, I excluded the zener diode from the circuit.

To make the board, the circuit was applied using an iron. That is printed circuit printed on inkjet printer using glossy paper, it can be taken from modern glossy magazines. Afterwards the textolite was cut out required sizes. My size turned out to be 36*26 mm. Such small size due to the fact that all parts are selected in an SMD package.

The board was etched using ferric chloride (FeCl 3 ). The etching took about an hour, since the bath with the toll was on the fireplace, high temperature affects the etching time of unused copper in the board. But don't overdo it with the temperature.

While the erasing process was going on, so as not to rack my brains and write firmware for the watch, I went to the Internet and found a this diagram firmware How to flash MK can also be found on the Internet. I used a programmer that flashes only ATMEGA MKs.

And finally, our board is ready and we can start soldering our watches. For soldering, you need a 25 W soldering iron with a thin tip so as not to burn the MK and other parts. We carry out soldering carefully and preferably solder all the legs of the MK the first time, but only separately. For those who are not in the know, know that parts made in an SMD package have tin on their terminals for quick soldering.

And this is what the board looks like with soldered parts.

I remember... Thirty years ago, six indicators were a small treasure. Anyone who could then make a clock using TTL logic with such indicators was considered a sophisticated expert in his field.

The glow of the gas-discharge indicators seemed warmer. After a few minutes I was wondering if these old lamps would work and wanted to do something with them. Now it’s very easy to make such a watch. All you need is a microcontroller...

Since at that time I was interested in programming microcontrollers in languages high level, I decided to play a little. I tried to construct a simple clock using digital gas discharge indicators.

Purpose of design

I decided that the clock should have six digits, and the time should be set with a minimum number of buttons. Additionally, I wanted to try to use a few of the most common microcontroller families different manufacturers. I intended to write the program in C.

Gas discharge indicators require high voltage to operate. But dealing with dangerous mains voltage I didn't want to. The watch was supposed to be powered by a harmless 12 V voltage.

Since my main goal was the game, you will not find any description of the mechanical design or body drawings here. If you wish, you can change the watch yourself in accordance with your tastes and experience.

Here's what I got:

  • Time display: HH MM SS
  • Alarm indication: HH MM --
  • Time display mode: 24 hours
  • Accuracy ±1 second per day (depending on quartz crystal)
  • Supply voltage: 12 V
  • Current consumption: 100 mA

Clock diagram

For a device with six-bit digital display The natural solution was multiplex mode.

The purpose of most elements of the block diagram (Figure 1) is clear without comment. To a certain extent, a non-standard task was to create a TTL level converter into high-voltage indicator control signals. Anode drivers are made on high voltage NPN and PNP transistors. The diagram is borrowed from Stefan Kneller (http://www.stefankneller.de).

The 74141 TTL chip contains a BCD decoder and a high-voltage driver for each digit. It may be difficult to order one chip. (Although I don't know if anyone makes them anymore). But if you found gas discharge indicators, 74141 may be somewhere nearby :-). At the time of TTL logic, there was practically no alternative to the 74141 chip. So try to find one somewhere.

The indicators require a voltage of about 170 V. It makes no sense to develop a special circuit for a voltage converter, since there are a huge number of boost converter chips. I chose the inexpensive and widely available IC34063. The converter circuit is almost completely copied from technical description MC34063. A T13 power switch has just been added to it. Internal key for this high voltage doesn't fit. I used a choke as inductance for the converter. It is shown in Figure 2; its diameter is 8 mm and its length is 10 mm.

The efficiency of the converter is quite good, and output voltage relatively safe. With a load current of 5 mA, the output voltage drops to 60 V. R32 acts as a current-sensing resistor.

To power the logic, linear regulator U4 is used. There is space on the diagram and on the board for backup battery. (3.6 V - NiMH or NiCd). D7 and D8 are Schottky diodes, and resistor R37 is designed to limit the charging current according to the characteristics of the battery. If you are building watches just for fun, you won't need the battery, D7, D8 and R37.

The final circuit is shown in Figure 3.

Figure 3.

The time setting buttons are connected via diodes. The state of the buttons is checked by setting a logical “1” at the corresponding output. As a bonus feature, a piezo emitter is connected to the output of the microcontroller. To shut up that nasty squeak, use a small switch. A hammer would be quite suitable for this, but this is a last resort :-).

A list of circuit components, a printed circuit board drawing, and a layout diagram can be found in the “Downloads” section.

CPU

Almost any microcontroller with a sufficient number of pins, the minimum required number of which is indicated in Table 1, can control this simple device.

Table 1.
Function Conclusions
Nutrition 2
Quartz resonator 2
Anode management 6
Driver 74141 4
Button input 1
Piezo emitter 1
Total 16

Each manufacturer develops its own families and types of microcontrollers. The location of the pins is individual for each type. I tried to design a universal board for several types of microcontrollers. The board has a 20-pin socket. With a few jumper wires you can adapt it to different microcontrollers.

The microcontrollers tested in this circuit are listed below. You can experiment with other types. The advantage of the scheme is the ability to use different processors. Radio amateurs, as a rule, use one family of microcontrollers and have the appropriate programmer and software tools. There may be problems with microcontrollers from other manufacturers, so I gave you the opportunity to choose a processor from your favorite family.

All the specifics of inclusion various microcontrollers reflected in Tables 2...5 and Figures 4...7.

Table 2.
Freescale
Type MC68HC908QY1
Quartz resonator 12 MHz
Capacitors C1, C2 22 pF
Program freescale.zip
(see "Downloads" section)
Settings

Note: In parallel quartz resonator 10 MΩ resistor included.

Table 3.
Microchip
Type PIC16F628A
Quartz resonator 32.768 kHz
Capacitors C1, C2 22 pF
Program pic628.zip
(see "Downloads" section)
Settings Int. 4 MHz generator - I/O RA6,
MCLR OFF, WDT OFF, LVP OFF,
BROUT OFF, CP OFF, PWRUP OFF

Note: The microcircuit must be rotated 180° in the socket.

Table 4.
Atmel
Type ATtiny2313
Quartz resonator 12 MHz
Capacitors C1, C2 15 pF
Program attiny.zip
(see "Downloads" section)
Settings Sq. 8 MHz oscillator, RESET ON

Note: Add SMD components R and C to the RESET pin (10 kΩ and 100 nF).

Table 5.
Atmel
Type AT89C2051
Quartz resonator 12 MHz
Capacitors C1, C2 22 pF
Program at2051.zip
(see "Downloads" section)
Settings --

Note: Add SMD components R and C to the RESET pin (10 kΩ and 100 nF); connect the pins marked with asterisks to the +Ub power bus via 3.3 kOhm SMD resistors.

When you compare the codes for different microcontrollers, you will see that they are very similar. There are differences in access to ports and definition of interrupt functions, as well as in what depends on the hardware components.

The source code consists of two sections. Function main() configures ports and starts a timer that generates interrupt signals. After this, the program scans the pressed buttons and sets the appropriate time and alarm values. Right there in the main loop current time is compared with the alarm clock and the piezo emitter is turned on.

The second part is a subroutine for handling timer interrupts. A subroutine that is called every millisecond (depending on the timer's capabilities) increments the time variables and controls the display digits. In addition, the status of the buttons is checked.

Running the circuit

When installing components and setting up, start with the power source. Solder the U4 regulator and surrounding components. Check for 5 V voltage for U2 and 4.6 V for U1. The next step is to collect high voltage converter. Use trimmer resistor R36 to set the voltage to 170 V. If the trim range is not enough, slightly change the resistance of resistor R33. Now install the U2 chip, transistors and resistors of the anode and digital driver circuit. Connect the U2 inputs to the GND bus and connect one of the resistors R25 - R30 in series to the +Ub power bus. The indicator numbers should light up in the corresponding positions. On last stage To check the circuit, connect pin 19 of the U1 microcircuit to ground - the piezo emitter should beep.

Source codes and compiled programs can be found in the corresponding ZIP file in the "Downloads" section. After flashing the program into the microcontroller, carefully check each pin in position U1 and install the necessary wire and solder jumpers. Refer to the microcontroller images above. If the microcontroller is programmed and connected correctly, its generator should start working. You can set the time and alarm. Attention! There is space on the board for one more button - this is a spare button for future expansions :-).

Check generator frequency accuracy. If it is not within the expected range, slightly change the values ​​of capacitors C1 and C2. (Solder small capacitors in parallel or replace them with others). The accuracy of the watch should improve.

Conclusion

Small 8-bit processors are quite suitable for high-level languages. C was not originally intended for small microcontrollers, but simple applications you can use it perfectly. Assembler would be better suited For complex tasks, requiring compliance with critical times or maximum processor load. For most radio amateurs, both free and shareware limited versions of the C compiler are suitable.

C programming is the same for all microcontrollers. You must know the hardware functions (registers and peripherals) of the selected type of microcontroller. Be careful with bit operations - the C language is not suitable for manipulating individual bits, as can be seen in the example of the original when for ATtiny.

Are you done? Then tune in to contemplate the vacuum tubes and watch...

...the old days are back... :-)

Editor's note

A complete analogue of the SN74141 is the K155ID1 microcircuit, produced by the Minsk Integral software.
The microcircuit can be easily found on the Internet.

The photo shows a prototype that I assembled to debug the program that will manage this entire facility. Second arduino nano in the upper right corner of the layout does not relate to the project and sticks out there just like that, you don’t have to pay attention to it.

A little about the principle of operation: Arduino takes data from the DS323 timer, processes it, determines the light level using a photoresistor, then sends everything to the MAX7219, and it, in turn, lights up the required segments with the required brightness. Also, using three buttons, you can set the year, month, day, and time as desired. In the photo, the indicators display time and temperature, which is taken from a digital temperature sensor

The main difficulty in my case is that the 2.7-inch indicators have a common anode, and they had to, firstly, somehow make friends with the max7219, which is designed for indicators with a common cathode, and secondly, solve the problem with their power supply, since they need 7.2 volts for glow, which max7219 alone cannot provide. Having asked for help on one forum, I received an answer.

Solution in the screenshot:


A microcircuit that inverts the signal is attached to the outputs of the segments from max7219, and a circuit of three transistors is attached to each pin that should be connected to the common cathode of the display, which also invert its signal and increase the voltage. Thus, we get the opportunity to connect displays with a common anode and a supply voltage of more than 5 volts to the max7219

I connected one indicator for the test, everything works, nothing smokes

Let's start collecting.

I decided to divide the circuit into 2 parts because huge amount jumpers in a version separated by my crooked paws, where everything was on one board. The clock will consist of a display unit and a power and control unit. It was decided to collect the latter first. I ask aesthetes and experienced radio amateurs not to faint because of the cruel treatment of parts. I have no desire to buy a printer for the sake of LUT, so I do it the old fashioned way - I practice on a piece of paper, drill holes according to a template, draw paths with a marker, then etch.

The principle of attaching indicators remained the same as on.

We mark the position of the indicators and components using a plexiglass template made for convenience.

Markup process







Then using a template we drill holes in in the right places and try on all the components. Everything fit perfectly.

We draw paths and etch.




bathing in ferric chloride

Ready!
control board:


indication board:


The control board turned out great, the track on the display board was not critically eaten up, it can be fixed, it’s time to solder. This time I lost my SMD virginity and included 0805 components in the circuit. At the very least, the first resistors and capacitors were soldered into place. I think I'll get better at it, it will be easier.
For soldering I used flux that I bought. Soldering with it is a pleasure; now I use alcohol rosin only for tinning.

Here are the finished boards. The control board has a seat for an Arduino nano, a clock, as well as outputs for connecting to the display board and sensors (photoresistor for auto brightness and digital thermometer ds18s20) and a power supply with adjustable output voltage (for large seven-segment devices) and for powering the clock and Arduino, on the display board there are mounting sockets for displays, sockets for max2719 and uln2003a, a solution for powering four large seven-segment devices and a bunch of jumpers.




rear control board

Rear display board:

Terrible smd installation:


Launch

After soldering all the cables, buttons and sensors, it's time to turn it all on. The first launch revealed several problems. The last large indicator did not light up, and the rest glowed dimly. I dealt with the first problem by soldering the leg of the SMD transistor, with the second by adjusting the voltage produced by lm317.
IT'S ALIVE!

I present to your attention electronic microcontroller clock. The clock circuit is very simple, contains a minimum of parts, and can be repeated by beginning radio amateurs.

The design is assembled on a microcontroller and a DS1307 real-time clock. A four-digit, seven-segment LED indicator is used as an indicator of the current time (ultra-bright, blue-colored, which looks good in the dark, and, at the same time, the clock plays the role of a night light). The clock is controlled by two buttons. Thanks to the use of the DS1307 real-time clock chip, the program algorithm turned out to be quite simple. The microcontroller communicates with the real-time clock via the I2C bus, and is organized by software.

Clock diagram:

Unfortunately, there is an error in the diagram:
— the MK terminals need to be connected to the transistor bases:
РВ0 to Т4, РВ1 to Т3, РВ2 to Т2, РВ3 to Т1
or change the connection of the transistor collectors to the indicator digits:
T1 to DP1…..T4 to DP4

Parts used in the clock circuit:

♦ ATTiny26 microcontroller:

♦ real time clock DS1307:

♦ 4-digit seven-segment LED indicator – FYQ-5641UB-21 with a common cathode (ultra-bright, blue):

♦ quartz 32.768 kHz, with an input capacitance of 12.5 pF (can be taken from motherboard computer), the accuracy of the clock depends on this quartz:

♦ all transistors are NPN structures, you can use any (KT3102, KT315 and their foreign analogues), I used BC547S
♦ microcircuit voltage stabilizer type 7805
♦ all resistors with a power of 0.125 watts
♦ polar capacitors on operating voltage not lower than supply voltage
♦ backup power supply DS1307 – 3 volt lithium cell CR2032

You can use any unnecessary charger to power your watch. cell phone(in this case, if the output voltage charger within 5 volts ± 0.5 volts, part of the circuit is a voltage stabilizer on a 7805 type microcircuit, can be excluded)
The current consumption of the device is 30 mA.
You don’t have to install the backup battery for the DS1307 clock, but then, if the mains power goes out, the current time will have to be set again.
The printed circuit board of the device is not shown; the design was assembled in a housing from faulty mechanical watch. The LED (with a blinking frequency of 1 Hz, from the SQW DS1307 pin) serves to separate the hours and minutes on the indicator.

Factory microcontroller settings: clock frequency— 1 MHz, FUSE bits do not need to be touched.

Clock operation algorithm(in Algorithm Builder):

1. Setting the stack pointer
2. Setting timer T0:
— frequency SK/8
- overflow interrupts (at this preset frequency, the interrupt is called every 2 milliseconds)
3. Initialization of ports (pins PA0-6 and PB0-3 are configured as output, PA7 and PB6 as input)
4. Initialization of the I2C bus (pins PB4 and PB5)
5. Checking the 7th bit (CH) of the DS1307 register zero
6. Global interrupt enable
7. Entering a loop and checking if a button is pressed

When turned on for the first time, or turned on again in the absence of backup power, the DS307 goes into initial installation current time. In this case: button S1 – to set the time, button S2 – transition to the next digit. Set time– hours and minutes are written to the DS1307 (seconds are set to zero), and the SQW/OUT pin (7th pin) is configured to generate rectangular pulses with a frequency of 1 Hz.
When you press the S2 button (S4 - in the program), a global interruption is disabled, the program goes into the time correction subroutine. In this case, using the S1 and S2 buttons, tens and units of minutes are set, then, from 0 seconds, pressing the S2 button records the updated time in the DS1307, resolves the global interrupt and returns to the main program.

The watch showed good accuracy, the time loss per month was 3 seconds.
To improve accuracy, it is recommended to connect quartz to DS1307, as indicated in the datasheet:

The program is written in the Algorithm Builder environment.
Using the clock program as an example, you can familiarize yourself with the algorithm for communicating between the microcontroller and other devices via the I2C bus (each line is commented in detail in the algorithm).

Photo assembled device And PCB in .lay format from site reader Anatoly Pilguk, for which many thanks to him!

The device uses: Transistors - SMD BC847 and CHIP resistors

Attachments to the article:

(42.9 KiB, 3,038 hits)

(6.3 KiB, 4,058 hits)

(3.1 KiB, 2,500 hits)

(312.1 KiB, 5,833 hits)


The second version of the clock program in AB (for those who cannot download the upper one)

(11.4 KiB, 1,842 hits)