• DIY large LED clock. How to make your own digital watch in retro style

    August 20, 2015 at 12:34 pm

    Homemade electronic watch, element base- part 1, measurement of time

    • DIY or Do It Yourself

    Probably every geek who is into homemade electronics sooner or later comes up with the idea of ​​making his own unique watch. The idea is quite good, let’s figure out how and what is best to make them. As a starting point, we will assume that a person knows how to program microcontrollers, understands how to send 2 bytes over an i2c or serial port, and can solder several wires together. In principle, this is enough.

    It is clear that key function clock - measuring time (who would have thought, right?). And it is advisable to do this as accurately as possible; there are several options and pitfalls.

    So, what methods of measuring time are available in hardware that we can use?

    Built-in CPU RC oscillator

    The simplest idea that can come to mind is to simply set up a software timer and use it to count down the seconds. So, this idea is no good. The clock will work, of course, but the accuracy of the built-in generator is not regulated in any way, and can “float” within 10% of the nominal value. It’s unlikely that anyone needs a watch that takes 15 minutes a month.

    Real time module DS1307

    A more correct option, which is also used in most “folk” products, is a real-time clock. The microcircuit communicates with the microcontroller via I2C and requires a minimum of wiring (quartz and a pair of resistors). The price is about 100 rubles per chip, or about $1 on eBay for a ready-made board with a chip, a memory module and a battery connector.

    Scheme from the datasheet:

    What is equally important, the microcircuit is produced in a DIP package, which means that any novice radio amateur can solder it. The built-in battery keeps the clock running even if the power is turned off.

    It would seem that everything is fine, if not for one problem - low accuracy. The approximate accuracy of watch quartz is 20-30ppm. The designation ppm - parts per million, shows the number of parts per million. It would seem that 20 millionths is super, but for a frequency of 32768Hz it turns out 20*32768/1000000 = ±0.65536Hz, i.e. already half a hertz. By simple calculations, it can be seen that with such a difference, a generator “clicks” an extra (or missing) 56 thousand cycles per day, which corresponds to 2 seconds per day. There are different types of quartz, some users also wrote about an error of 5 seconds per day. Somehow it’s not very accurate - in a month such a watch will take at least a minute. This is already a significant difference, noticeable to the naked eye (when grandma’s favorite TV series starts at 11.00, and the clock shows 11.05, the developer of such a watch will be embarrassed in front of relatives).

    However, since the temperature in the room is more or less stable, and the quartz frequency will not change much, you can add software correction. Another advice given on the forums is to use clock quartz from old motherboards; according to reviews, they are quite accurate.

    DS3231 Real Time Module

    We are not the first to ask the question of accuracy, and the Dallas company, following the wishes, released a more advanced module - DS3231. It's called "Extremely Accurate Real Time Clock" and has a built-in temperature-corrected generator. The accuracy is 10 times higher, and is 2ppm. The price is a little higher, but the chip body is designed for SMD mounting, soldering is not so convenient, but you can buy a ready-made board on eBay.


    (photo from the seller's website)

    An accuracy of 6 seconds per month is already a good result. But we will go further - ideally, clocks in the 21st century do not need to be adjusted at all.

    Radio module DCF-77

    The method is rather exotic, but for the sake of completeness it cannot be ignored. Few people know, but precise time signals have been transmitted over the radio since the 70s. The DCF-77 transmitter is located in Germany near Frankfurt, and on the VHF frequency 77.5 KHz, precise time stamps are transmitted (yes, they already had wall and table clock, which do not need to be adjusted).

    The good thing about this method is that the circuit has low power consumption, so they are now even producing wrist watch with this technology. A ready-made DCF-77 receiving board can be purchased on ebay, the asking price is $20.

    Many watches and weather stations have the ability to receive DCF-77, the only problem is that the signal practically does not reach Russia. Coverage map from Wikipedia:

    As you can see, only Moscow and St. Petersburg are on the border of the reception zone. According to reviews from owners, only sometimes the signal can be received, which is why practical application Of course it won't do.

    GPS module

    If the clock is placed close to the window, then it is quite real method obtaining exact time - GPS module. These modules can be purchased inexpensively on ebay (issue price is $10-15). For example, Ublox NEO-6M connects directly to the processor's serial pins and outputs NMEA strings at 9600 speed.

    The data comes in approximately the following format: “$GPRMC,040302.663,A,3939.7,N,10506.6,W,0.27,358.86,200804,*1A”, and parsing them is not difficult even for a weak Arduino. By the way, patriots can purchase the more expensive Ublox NEO-7N module, which supports (according to reviews) both GPS and Glonass.

    Obviously, the GPS module knows nothing about different time zones, so the developer will have to think about their calculation and the change of summer/winter time himself. Another minus using GPS- relatively high power consumption (however, some modules can be switched to “sleep mode” using separate commands).

    WiFi

    And finally, the last (and most obvious at the moment) way to get the exact time is to take it from the Internet. There are two approaches here. The first, and simplest, is to use something like a Raspberry PI with Linux as a clock board, then you don’t need to do anything, everything will work out of the box. If you want “exotic” - then interesting option is the esp8266 module.

    This is an inexpensive (issue price is about 200 rubles on ebay) WiFi module can communicate with the server via the serial port of the processor, if desired, it can also be reflashed (there are quite a lot of third-party firmware), and part of the logic (for example, polling the time server) can be done in the module itself. Third-party firmware supports a lot of everything, from Lua to C++, so there are quite enough options to “flex your brain.”

    At this point, the topic of measuring time can probably be closed. In the next part we will take a closer look at processors and time output methods.

    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 indicator is used as the current time indicator. LED indicator(ultra bright, blue color glow, 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 for operating voltage not lower than supply voltage
    ♦ backup power 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.
    Battery backup power You don’t have to set the DS1307 clock, but then, if the 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 you turn it on for the first time, or restart in the absence of backup power DS307, a transition occurs 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 the 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 of the assembled device and printed circuit board 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)

    The photo shows a prototype that I assembled to debug the program that will manage this entire facility. The second arduino nano in the upper right corner of the breadboard does not belong 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 due to the huge number of jumpers in the version that was 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 the 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 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 ready-made 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 (a photoresistor for auto-brightness and a 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!

    Clock with audible alarm timer for controlling household appliances.

    A timer is a device that set time turns the equipment on or off with its switching contacts. Real-time timers allow you to set the trigger time at a set time of day. The most simple example such a timer will be an alarm clock.

    The scope of application of the timer is extensive:
    - lighting control;
    - watering management of home and garden plants;
    - ventilation control;
    - aquarium management;
    - control of electric heaters and so on.

    The proposed timer can be made quickly and inexpensively even by a novice radio amateur.
    I made it based on the clock designer. ()

    I needed to use a timer to control the watering of plants at the dacha.

    Watch the entire manufacturing process in the video:


    List of tools and materials
    - any electronic watch with an alarm sound;
    -screwdriver;
    - scissors;
    - soldering iron;
    -cambric;
    - two 12V relays;
    -12V power supply from the adapter;
    - connecting wires;
    - foil textolite for printed circuit board or breadboard;
    -industrial or homemade time relay;
    -resistor;
    - transistors KT815 (or analogues);
    -diode.

    Step one. Timer board wiring.
    Timer circuit
    All that is needed is to solder the components according to the circuit diagram breadboard and solder two wires from the piezo emitter of the clock. We collect the simplest scheme with intermediate relay and transistor switch. When the first pulse of the sound signal is sent from the clock, relay P1 is turned on, the normally open contact closes and turns on the load, and at the same time, through the second normally open contact of relay P1 and the normally closed contact of the time relay, relay P1 self-locks. Together with the load, the time relay PB is turned on - the countdown of the specified load operating time begins. At the end of this time, RV opens the contact and relay P1 is de-energized, the load is turned off. The circuit is ready for the next cycle. The diode serves to prevent a reverse pulse into the clock circuit (any low-power diode can be used). LED to indicate load activation. In this circuit, you need an intermediate relay with two normally open contacts, but I didn’t have it - I used two Chinese relays (the coils are connected in parallel). If the load is more powerful, then accordingly you need to use a relay with more powerful contacts. I had a 12V adapter and installed its circuit directly on the breadboard. In principle, any low-power 12V power source can be used.


    In short, the clock turns on the load and the time relay is turned off after the delay has expired.
    If you do not have an industrial time relay, you can make it yourself using a simple scheme. As the capacitance of capacitor C1 increases, the operating time of the relay increases.


    Step two. Checking the timer operation.
    My circuit worked the first time I turned it on.
    All that remains is to set the alarm time. My watch has two alarm time settings. For my case, it’s enough to turn on watering, for example, in the morning at 7 o’clock for one hour, and in the evening at 20 o’clock, water again. When the watch buttons are pressed, the sound signals, therefore, when setting up the timer circuit, it is necessary to de-energize it in order to exclude false positives. My watch has a “chime” function - every hour from 8 to 20 o’clock, that is, in addition to the alarm clock, you can use these signals if necessary. If not necessary, then the “chimes” function is disabled.

    This is how the weekend design turned out. It was interesting to test new scheme so everything was done quickly. In the future, it will be necessary to make a case and place a board and a time relay there. A beginner can make such a timer on his own without spending a lot of time and money. And where to use them is up to you to decide.

    All the work took a couple of weekend evenings and 75 rubles (

    You can find many on sale various models and electronic options digital clock, but most of them are designed for indoor use, since the numbers are small. However, sometimes it is necessary to place a clock on the street - for example, on the wall of a house, or in a stadium, square, that is, where it will be visible from a great distance by many people. For this purpose it was developed and successfully assembled this scheme large LED clock, to which you can connect (via internal transistor switches) LED indicators as desired large size. Increase schematic diagram you can click on it:

    Description of the clock

    1. Watch. IN this mode There is a standard type of time display. There is a digital correction of the clock accuracy.
    2. Thermometer. In this case, the device measures the temperature of the room or air outside from one sensor. Range from -55 to +125 degrees.
    3. Power supply control is provided.
    4. Displays information on the indicator alternately - a clock and a thermometer.
    5. To save settings and settings when 220V is lost, non-volatile memory is used.


    The basis of the device is the ATMega8 MK, which is flashed by setting fuses according to the table:

    Operation and clock management

    When you turn on the watch for the first time, an advertising splash screen will appear on the screen, after which it will switch to displaying the time. Pressing a button SET_TIME the indicator will go in a circle from the main mode:

    • minutes and seconds display mode. In this mode, if you simultaneously press the button PLUS And MINUS, then the seconds will be reset;
    • setting the minutes of the current time;
    • setting the current time clock;
    • symbol t. Setting the duration of the clock display;
    • symbol o. Display time of external temperature indication symbols (out);
    • the amount of daily correction of the clock accuracy. Symbol c and correction value. Setting limits from -25 to 25 sec. The selected value will be added or subtracted from the current time every day at 0 hours 0 minutes and 30 seconds. For more details, read the instructions that are in the archive with the firmware and printed circuit board files.

    Setting the clock

    While holding down the buttons PLUS/MINUS We do accelerated setting of values. After changing any settings, after 10 seconds the new values ​​will be written to non-volatile memory and will be read from there when the power is turned on again. New settings take effect during installation. The microcontroller monitors the presence of main power. When it is turned off, the device is powered from internal source. The redundant power module diagram is shown below:


    To reduce current consumption, the indicator, sensors and buttons are turned off, but the clock itself continues to count time. As soon as the 220V mains voltage appears, all indication functions are restored.


    Since the device was conceived as large led clock, they have two displays: a large LED - for the street, and a small LCD - for easy setup of the main display. The large display is located several meters from the control unit and is connected by two cables of 8 wires. To control the anodes of the external indicator indicator, transistor switches are used according to the diagram given in the archive. Project authors: Alexandrovich & SOIR.