To come in
Sewerage and drainpipes portal
  • Famous types of mustache in men: all about manhood
  • "Mix, but do not stir"
  • Do you need to be an erudite to become successful
  • 100 best snipers in history
  • Daily Fat Rate Animal Products
  • Symbols of Satanism (12 photos)
  • Diy electronic clock circuit. Clock on AVR microcontroller with DS1307

    Diy electronic clock circuit. Clock on AVR microcontroller with DS1307

    With dynamic indication. There are no complaints about the work of the watch: precise movement, convenient settings. But one big drawback is that the LED indicators are hard to see in the daytime. To solve the problem, I switched to static indication and brighter LEDs. As always in the software, many thanks to Soir. In general, I would like to bring to your attention a large street clock with a static indication, the setting functions remain the same as in the previous watch.

    They have two displays - the main one (outside on the street) and the auxiliary one on the indicators - indoors, on the device case. High brightness is achieved by using ultra-bright LEDs with an operating current of 50mA and driver microcircuits.

    Diagram of an electronic clock for the street on bright LEDs

    To flash the controller with files and use the following fuse settings:

    Printed circuit boards for clock, control unit and external module, in LAY format,.


    Features of this clock scheme:

    - Time display format 24-hour.
    - Digital correction of travel accuracy.
    - Built-in control of the main power supply.
    - Non-volatile microcontroller memory.
    - There is a thermometer that measures the temperature in the range of -55 - 125 degrees.
    - It is possible to alternately display information about time and temperature on the indicator.


    Pressing the SET_TIME button turns the indicator in a circle from the main clock mode (displaying the current time). In all modes, holding down the PLUS / MINUS buttons makes an accelerated setting. Changes to settings 10 seconds after the last value change will be written to non-volatile memory (EEPROM) and will be read from there when the power is turned on again.


    Another big plus of the proposed option is that the brightness has changed, now in sunny weather the brightness is excellent. The number of wires has decreased from 14 to 5. The length of the wire to the main (outdoor) display is 20 meters. I am satisfied with the work of the electronic clock, it turned out to be a fully functional clock - both day and night. Respectfully yours, Soir – Alexandrovich.

    Not long ago there was a need in the house to get hold of a clock, but only electronic, since I do not like dials, because they tick. I have a lot of experience in soldering and etching circuits. After scouring the Internet and reading some literature, I decided to choose the most simple schemeas I don't need an alarm clock.

    I chose this scheme because it is easy make a watch with your own hands

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

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

    But there is a flaw in this scheme: the outputs of the microcontroller (hereinafter referred to as MC), which are responsible for managing the discharges, receive a pretty decent load. The total current is much exceeded from the maximum port current, but with dynamic indication, the MC does not have time to overheat. In order for the MK not to fail, we add resistors to the discharge circuits of 100 Ohm.

    In this scheme, the indicator is controlled according to the dynamic indication principle, in accordance with which the indicator segments are controlled by signals from the corresponding MC terminals. The repetition rate of these signals is more than 25 Hz, and because of this, the glow of the indicator digits seems to be continuous.

    An electronic clock made according to the above scheme, can only show time (hours and minutes), and seconds shows the dot between segmentsthat flashes. To control the operating mode of the watch, their structure provides push-button switches that control the setting of hours and minutes. This circuit is powered from a 5V power supply. When manufacturing the PCB, 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, the printed circuit was printed on an inkjet printer using glossy paper, it can be taken from modern glossy magazines. After that, the textolite of the required size was cut. My size turned out to be 36 * 26 mm. Such small size due to the fact that all parts are selected in an SMD case.

    The board was etched with ferric chloride (FeCl 3). In terms of time, the etching took about an hour, since the tray with the paid one was on the fireplace, the high temperature affects the etching time of not used copper in the board. But don't overdo it with the temperature.

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

    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 in order not to burn the MK and other parts. We carry out the soldering carefully and preferably from the first time we solder all the legs of the MK, but only separately. For those who are not in the subject, know that parts made in an SMD package have tin on their terminals for quick soldering.

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

    Even in my youth, I wanted to collect digital Watch... It seemed to me that assembling a watch was the pinnacle of skill. As a result, I put together a watch with a calendar and an alarm clock on the K176 series. Now they are already morally outdated and I wanted to collect something more modern. After a long search on the Internet (I never thought it was so hard for me to please;)) I liked this scheme. The difference from the above diagram is that a rare microcircuit is not used. TRIC6B595, and its composite and more powerful analogue on microcircuits 74HC595 and ULN2003... The fixes to the circuit are shown below.



    Diagram of electronic LED clock running line

    The author of the scheme dear OLED, the firmware is also his. The clock displays the current time, year, month and day of the week, as well as the temperature outside and inside the house with scrolling text. They have 9 independent alarms. It is possible to adjust (correct) the stroke + - a minute per day, select the speed of the line, change the brightness of the LEDs, depending on the time of day.

    In the event of a power outage, the clock is powered either by an ultracapacitor (1 Farad capacity is enough for 4 days of running), or from a battery. Anyone who likes it, the board is designed to install both. They have a very convenient and intuitive control menu (all control is done with just two buttons). The following parts are used in the watch (all parts are in SMD cases):

    Microcontroller AtMEGA 16A

    -
    Shift register 74HC595

    -
    Chip ULN2803 (eight Darlington keys)

    -
    Temperature sensors DS18B20 (installed at will)

    -
    25 resistors 75 Ohm (standard 0805)

    -
    3 resistors 4.7kOhm

    -
    2 resistors 1.5 kOhm

    -
    1 x 3.6K resistor

    -
    6 SMD capacitors with a capacity of 0.1 μF

    -
    1 capacitor 220 uF

    -
    Watch quartz for a frequency of 32768 hertz.

    -
    Matrices 3 pieces of 23088-ASR brand 60x60 mm - common cathode

    -
    Any boozer for 5 volts.



    Printed circuit board for electronic LED clock running line

    For residents of Ukraine, I will tell you, there are matrices in the store of the Lugansk radio market. The advantages of watches over other similar devices are the minimum of parts and high repeatability. The LED clock starts working immediately after the firmware, unless of course there are no jambs in the installation. The microcontroller is stitched in-circuit; for this, special pins are provided on the board. I was flashing the Ponyprog program. Fuses screens for programs ponyprog and AVR are given below, the firmware files in Ukrainian and Russian are also posted, who is more familiar with what.


    If you do not need temperature sensors, then they can be omitted. The watch automatically recognizes the connection of sensors, and if one or both sensors are missing, then the device simply stops displaying the temperature (if one sensor is missing, then the outside temperature is not displayed, if both, then the temperature is not displayed at all).

    Homemade LED watch case

    To demonstrate the work of the clock, a video is given, it is not of high quality, since it was filmed with a camera, but what it is.

    Watch video

    Four copies of these watches have already been collected, I present each one to relatives for a birthday. And everyone liked them very much. If you also wanted to collect this watch and have any questions, you are welcome to our forum. Yours faithfully, Voitovich Sergey ( Sergey-78 ).

    Discuss the article LED ELECTRONIC CLOCK

    Hello geektimes! In the first part of the article, the principles of obtaining the exact time on a homemade watch were considered. Let's go further and consider how and on what it is better to display this time.

    1. Output devices

    So, we have a certain platform (Arduino, Raspberry, PIC / AVR / STM controller, etc), and the task is to connect some indication to it. There are many options that we will consider.

    Segment display

    Everything is simple here. The segment indicator consists of ordinary LEDs, which are banally connected to the microcontroller through damping resistors.

    Watch out for traffic!

    Pros: simplicity of design, good viewing angles, low price.
    Minus: the amount of information displayed is limited.
    There are two types of indicator designs, with a common cathode and a common anode, inside it looks something like this (diagram from the manufacturer's website).

    There are 1001 articles on how to connect an LED to a microcontroller, google for help. Difficulties begin when we want to make a large clock - after all, looking at a small indicator is not particularly convenient. Then we need these indicators (photo from eBay):

    They are powered from 12V, and simply will not work directly from the microcontroller. Here the microcircuit comes to the rescue CD4511, just for this purpose. It not only converts the data from the 4-bit line into the desired digits, but also contains a built-in transistor switch to supply voltage to the indicator. Thus, in the circuit we will need to have a "power" voltage of 9-12V, and a separate buck converter (for example, L7805) to power the "logic" of the circuit.

    Matrix indicators

    In fact, these are the same LEDs, only in the form of an 8x8 matrix. Photos from eBay:

    Sold on eBay as single modules or ready-made blocks, for example, 4 pieces. Their control is very simple - a microcircuit is already soldered on the modules MAX7219, ensuring their operation and connection to the microcontroller with just 5 wires. There are many libraries for Arduino, you can look at the code.
    Pros: low price, good viewing angles and brightness.
    Cons: low resolution. But for the task of outputting the time is quite enough.

    LCD indicators

    LCD indicators are graphical and textual.

    Graphics are more expensive, but they allow you to display more diverse information (for example, a graph of atmospheric pressure). Text messages are cheaper and easier to work with, they also allow you to display pseudo-graphics - you can load custom symbols into the display.

    It is not difficult to work with the LCD indicator from the code, but there is a certain disadvantage - the indicator requires a lot of control lines (from 7 to 12) from the microcontroller, which is inconvenient. Therefore, the Chinese came up with the idea of \u200b\u200bcombining the LCD indicator with the i2c controller, it turned out in the end it is very convenient - only 4 wires are enough to connect (photo from eBay).


    LCD indicators are quite cheap (if you take it on eBay), large, easy to connect, and you can display a variety of information. The only drawback is not very large viewing angles.

    OLED indicators

    They are an improved continuation of the previous version. Ranging from small and cheap 1.1 "to large and expensive. Photo from eBay.

    Actually, they are good for everyone except the price. As for small indicators, 0.9-1.1 "in size, it is difficult to find any practical application for them (except for studying working with i2c).

    Gas discharge indicators (IN-14, IN-18)

    These indicators are now very popular, apparently because of the "warm tube sound of light" and the originality of the design.


    (photo from the site nocrotec.com)

    Their connection scheme is somewhat more complicated, since these indicators use 170V for ignition. Converter from 12V \u003d\u003e 180V can be made on a microcircuit MAX771... To supply voltage to the indicators, a Soviet microcircuit is used K155ID1, which was specially created for this. The price of the issue for self-production: about 500 rubles for each indicator and 100 rubles for the K155ID1, all other details, as they wrote in old magazines, "are not in short supply." The main difficulty here is that both IN-xx and K155ID1 have long been out of production, and you can buy them only on radio markets or in a few specialized stores.

    2. Choosing a platform

    We have more or less figured out the indication, it remains to decide which hardware platform is better to use. There are several options here (I do not consider homemade ones, since those who know how to wire the board and solder the processor, this article is not needed).

    Arduino

    The easiest option for beginners. The finished board is inexpensive (about $ 10 on eBay with free shipping), has all the necessary connectors for programming. Photos from eBay:

    There are a huge number of different libraries for Arduino (for example, for the same LCD screens, real-time modules), Arduino is hardware compatible with various additional modules.
    The main disadvantage: the complexity of debugging (only through the serial port console) and a rather weak processor by modern standards (2KB of RAM and 16MHz).
    The main plus: you can do a lot of things, practically without bothering with soldering, buying a programmer and wiring boards, just connect the modules to each other.

    32-bit STM processors

    For those who want something more powerful, there are ready-made boards with STM processors, for example, a board with an STM32F103RBT6 and a TFT screen. Photos from eBay:

    Here we already have full debugging in a full-fledged IDE (out of all the different ones I liked Coocox IDE more), however, we need a separate ST-LINK debugger-programmer with a JTAG connector (the issue price is $ 20-40 on eBay). Alternatively, you can buy an STM32F4Discovery debug board, on which this programmer is already built-in, and can be used separately.

    Raspberry PI

    And finally, for those who want full integration with the modern world, there are single-board computers with Linux, everyone probably already knows Raspberry PI. Photos from eBay:

    This is a full-fledged computer with Linux, a gigabyte of RAM and a 4-core processor on board. On the edge of the board, there is a panel of 40 pins, which allows you to connect various peripherals (pins are available from the code, for example, in Python, not to mention C / C ++), there is also a standard USB in the form of 4 connectors (you can connect WiFi). There is also standard HDMI.
    The power of the board will be enough, for example, not only to display the time, but also to run an HTTP server to configure parameters via the web interface, load a weather forecast via the Internet, and so on. In general, there is a lot of room for a flight of fantasy.

    There is only one problem with Raspberry (and STM32 processors) - its pins use 3-volt logic, and most external devices (eg LCD screens) work the old-fashioned way from 5V. You can, of course, connect and so, in principle, it will work, but this is not quite the correct method, and it’s a pity to spoil the $ 50 fee. The correct way is to use a "logic level converter", which costs only $ 1-2 on eBay.
    Photos from eBay:

    Now it is enough to connect our device through such a module, and all parameters will be coordinated.

    ESP8266

    The method is rather exotic, but rather promising due to the compactness and low cost of the solution. For very little money (about $ 4-5 on eBay), you can buy an ESP8266 module containing a processor and WiFi on board.
    Photos from eBay:

    Initially, such modules were intended as a WiFi bridge for exchange via a serial port, however, enthusiasts have written many alternative firmware that allow working with sensors, i2c devices, PWM, etc. Hypothetically, it is quite possible to receive time from an NTP server and output it via i2c on the display. For those who want to connect many different peripherals, there are special NodeMCU boards with a large number of pins, the issue price is about 500 rubles (of course on eBay):

    The only drawback is that the ESP8266 has very little RAM memory (depending on the firmware, from 1 to 32KB), but this makes the task even more interesting. The ESP8266 modules use 3V logic, so the above level converter comes in handy here as well.

    On this introductory excursion into homemade electronics can be completed, the author wishes everyone successful experiments.

    Instead of a conclusion

    In the end, I settled on using a Raspberry PI with a text indicator configured to work with pseudo-graphics (which turned out to be cheaper than a graphical screen of the same diagonal). I took a picture of the desktop clock screen while writing this article.

    The clock displays the exact time taken from the Internet, and the weather that is updated from Yandex, all this is written in Python, and has been working for several months. In parallel, an FTP server is launched on the watch, which allows (together with port forwarding on the router) to update the firmware on them not only from home, but also from anywhere where there is Internet. As a bonus, Raspberry's resources are, in principle, enough to connect a camera and / or microphone with the ability to remotely monitor an apartment, or to control various modules / relays / sensors. You can add all sorts of "goodies", such as LED indication of incoming mail, and so on.

    PS: Why eBay?
    As you can see, prices or photos from ebay were given for all devices. Why is that? Unfortunately, our stores often live according to the principle “I bought for 1 $, sold for 3, and I live on this 2 percent”. As a simple example, the Arduino Uno R3 costs (at the time of this writing) 3600r in St. Petersburg, and 350r on eBay with free shipping from China. The difference is really an order of magnitude, without any literary exaggeration. Yes, you will have to wait a month to pick up the parcel at the post office, but I think such a difference in price is worth it. But however, if someone needs it right now and urgently, then probably in local stores there is a choice, here everyone decides for himself.

    I bring to your attention electronic microcontroller clock... The clock circuit is very simple, contains a minimum of details, and is available for repetition for novice radio amateurs.

    The design is assembled on a microcontroller and a real time clock DS1307... As an indicator of the current time, a four-digit seven-segment LED indicator is used (ultra-bright, blue glow color, 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 microcircuit, the program algorithm is quite simple. Communication between the microcontroller and the real-time clock occurs via the I2C bus, and is organized by software.

    Clock scheme:

    Unfortunately, there is an error in the schema:
    - the conclusions of the MK to the bases of the transistors must be connected:
    PB0 to T4, PB1 to T3, PB2 to T2, PB3 to T1
    or change the connection of the collectors of transistors to the indicator discharges:
    T1 to DP1 ... .. T4 to DP4

    Details used in the watch diagram:

    ♦ ATTiny26 microcontroller:

    ♦ Real time clock DS1307:

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

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

    ♦ all transistors are NPN structures, you can use any (KT3102, KT315 and their foreign counterparts), 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
    ♦ DS1307 backup power - 3 volt CR2032 lithium cell

    Any unnecessary cell phone charger can be used to power the watch (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 microcircuit, you can exclude)
    The current consumption by the device is - 30 mA.
    The backup battery of the DS1307 clock may not be installed, but then, in the event of a power failure, the current time will have to be reset.
    The printed circuit board of the device is not shown, the structure was assembled in a case from a faulty mechanical clock. 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 settings of the microcontroller: clock frequency - 1 MHz, FUSE-bits do not need to be touched.

    Clock algorithm (in Algorithm Builder):

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

    When the DS307 is turned on for the first time, or when it is turned on again when there is no backup power supply, the DS307 returns to the initial setting of the current time. In this case: button S1 - to set the time, button S2 - go to the next digit. Set time - hours and minutes are recorded in DS1307 (seconds are set to zero), and the SQW / OUT pin (7th pin) is set to generate square wave pulses with a frequency of 1 Hz.
    By pressing the S2 button (S4 - in the program), interrupts are prohibited globally, the program goes to the time correction subroutine. At the same time, tens and units of minutes are set using the S1 and S2 buttons, then, from 0 seconds, pressing the S2 button records the updated time in DS1307, allows the global interrupt and returns to the main program.

    The watch showed good accuracy, time drift per month - 3 seconds.
    To improve the 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 of the assembled device and printed circuit board in .lay format from the site reader Anatoly Pilguk, for which many thanks to him!

    The device uses: Transistors - SMD VS847 and CHIP resistors

    Appendices to the article:

    (42.9 KiB, 3,227 hits)

    (6.3 KiB, 4 180 hits)

    (3.1 KiB, 2 657 hits)

    (312.1 KiB, 5 929 hits)


    The second version of the clock program in AB (for those who do not have the upper one)

    (11.4 KiB, 1,942 hits)