The history of the creation of the clock synchronizer DCF77

    Once I decided to please myself and bought a citizen watch. Among other things, this watch declares the ability to synchronize the clock over the air. At the time of the order, I did not have much idea what it was, I thought that it somehow would do everything as it should. But it turned out that radio synchronization in Russia practically does not work. I decided to rectify the situation. The first thing I found was an articlededicated to signal amplification. It was proposed to wind a large coil with a capacitor, put it on a window facing west and wait. Also in this article, the dcf77 protocol was mentioned, according to which the clock synchronizes time, and I realized that it is not very complicated. Although at that moment in electronics I was a complete zero, but it seemed to me that I could handle the digital part, and somehow I would deal with the rest. And I decided to start a project to develop a clock synchronization device using the dcf77 protocol.

    Here I will describe how I worked on this project, what problems I encountered as a beginner in electronics, interesting solutions that I came across when working on a project, and try to justify them. This text may be of interest to programmers who decide to do electronics. Therefore, on the programming side, many things will be omitted.

    image

    Device concept


    The first thing I started with was gathering information about the protocol, possible finished devices, and thought out the requirements for the device. I started thinking through the basic concept.

    1. Synchronization should be carried out within the room
    2. The synchronizer itself may have an error of 2s
    3. The synchronizer should also be a clock.
    4. Must have a self-diagnosis system.
    5. Must be battery powered. (I'm not sure that I can make a device that can work on the network safely for others)
    6. The device should work for about a month on battery power.
    7. Everything should be beautiful. Body. Screen. Buttons. Etc.

    First steps


    Next, I began to collect material about the protocol and similar devices. Somewhere on German resources there were some ready-made devices . Found a protocol description on wikipedia .
    Since this all started.

    What is dcf77? This is a protocol in which date and time are transmitted by zeros and ones by an amplitude-modulated signal. At the beginning of each second, the amplitude is reduced to 15% by 0.1 or 0.2 s. If the length of the shortened signal is 0.1 s, then 0 if 0.2 s then 1. What is quite clearly visible if you blink the LED. More details here and here .

    The first thing I did was implement the dcf77 protocol on a large computer in c ++. I did it quickly. It is clear that I already tried to make flashers on arduino, so making a flasher with the dcf77 protocol on the LED was not difficult. Unfortunately, I didn’t have any photos or schemes of the very first versions. But the scheme was approximately the same as in the figure. Only without generator and on Arduino Uno.

    image

    On the way to such a scheme, I encountered some difficulties.

    The first thing I came across is that in Arduino ide classes cannot be implemented in ino files. I had to rewrite everything to C. I did not immediately realize that you could just connect it from a separate file. This problem was resolved quickly.

    Due to the fact that I started by visualizing the signal with an LED, I put the resistor in series with the LED in the region of 200 ohms (in the figure it’s not so already). To make it shine brighter. This all led to the fact that the transistor was constantly ajar and the circuit did not work normally. I guessed by the method of putting two diodes in series.

    The transistor seems to be closing. But it somehow looked wild, even for me, and I realized that it was necessary to study the theory. Knowing the basics is very important. At least how the transistor works in key mode. And here I came across the following problem: few details and few tools. For example, to make an antenna, you need a wire and ferrite. From China they wait a long time. Fortunately, the hex invertor was in an Arduino starter. But I did not find quartz 77500 in Russia at all, and even in China, on ali, it was only in one place, a batch of 50 pieces. By this time, I already realized that even if I assemble the generator, I can’t even understand if it works or not. And I realized that we need tools: we need a frequency meter and / or an oscilloscope. This gave me a break in working on the device. And I began to study electronics. I listened to a number of YouTube videos on electronics, for example,that . Articles on the topic . Articles on antennas. I was very worried that the antennas for this frequency should be about 700 meters long. But still I decided to try to make a magnetic antenna as in receivers .

    For the antenna, you need a circuit from a magnetic coil and a capacitor in resonance. Resonance must somehow be sought. This led to the transistor tester project. I wanted to implement it in between cases. Maybe there was an inductance meter, and I had several Arduino mini (plz Arduino haters did not immediately respond. I later corrected a little). But I realized that I wasn’t ready to do it myself, ordered DYI, looked at its circuit and found its source .

    I also learned about some useful programs for the phone, such as EveryCircuit and ElectroDroid. I used ElectroDroid at this moment to calculate the resonance of the antenna. EveryCircuit allows you to simulate small schemes on the phone. I decided to document the scheme. Somewhere on the Internet I saw a beautiful picture on a breadboard. I realized that Fritzing does this, in addition, he can design a circuit diagram and design a board. Started using fritzing.

    Then the time had already come when the first packages from China began to arrive. Something had to be urgently ordered in the “chip and dip”. Here the first idea appeared how to synchronize time. It was decided to make synchronization on the wifi module esp8266.

    Stumbled upon a similar project. I decided to take the main ideas from it. The radio part was completely borrowed from it. It was impossible to use it without alteration, because:

    1. It is designed for 12 volts.
    2. Based on pic microcontroller.

    First successes


    As the details arrived, I began to improve the device. After the quartz arrived and the transistor tester, it became possible to finally assemble the first version, capable of transmitting time. I wound a coil on a ferrite rod - this is an antenna. Looked at her inductance. Picked up capacitors at 100 pf. Everything seems to be collected. Should work. But it doesn’t work. And, of course, it’s impossible to diagnose the problem. The oscilloscope has not arrived yet. Even the multimer is the easiest. From it, little can be understood. It’s good that my father-in-law had instruments and an oscilloscope and a frequency meter. I went to him with my device. We looked at the frequency meter, like there is a frequency. We looked at the oscilloscope, too, like nothing. The sine is not pure, but still similar. I went home to understand further. The problem is that how to understand it is not clear. By the clock you can only understand if they saw a signal or not. It’s impossible to understand what the error is. But nevertheless, it is clear that the problem is not in the radio part, but in the modulator. I tried to vary the parameters. Without going far from the description from Wikipedia. In the end, he decided to lengthen the pulses in the frequency modulator. And at that moment the watch finally hooked on the signal. And, after several attempts, DAY managed to complete the first synchronization. Then it was decided to do time synchronization on the device itself. DAY managed to complete the first synchronization. Then it was decided to do time synchronization on the device itself. DAY managed to complete the first synchronization. Then it was decided to do time synchronization on the device itself.

    In the process of finding problems, I also found that digitalwrite is not working efficiently.

    I remade everything so that it would not be used. Then I met this in other sources. But for the first time I saw here . This was the first retreat from Arduino.

    I really like oled screens, so it was decided to use the ssd1306 screen. But the library from adafruit is terrible. She is very slow. Uses a lot of RAM. Found an alternative to u8glib . I really liked it.

    The first solution I tried was based on the esp8266 module and involved time synchronization via the Internet. But I didn’t like the fact that it’s rather difficult to connect through this module. And at that moment he was not very stable. Therefore, it occurred to me to try time synchronization via GPS. The module for ardino was like that. The firmware for synchronizing via GPS was simpler, but there were problems that I encountered in the future.

    Finally managed to assemble a fully functional device on the breadboard.

    image

    Failure from Arduinio


    I found some links to interesting dyi in cases. It was important for me that the device had a neat appearance. I saw some videos where they are flashing atmega328 in Arduino. Firmware by this time was already difficult. I did not want to transfer it to something else. Arduino IDE seemed to me a good tool in such situations. Flashed Arduino using usbasp, which also ordered in China.

    I did not want to get involved in self-etching boards. Therefore, I decided that I would solder the device on a special breadboard for soldering. Therefore, I preferred chips in a dip package. In those cases when there are no good alternatives in the dip case, I used adapters.

    Transmission Improvement


    Success in the transmission finally allowed us to start experimenting with the transmitter and receiver. I set up the transmitter and wore the watch all over the room in search of a better signal. I found out that we will take it best when the Antenna is directed with its axis to the clock. And the watch is at a distance of no more than a meter and a half. In addition, the oscilloscope finally arrived. He also allowed us to gain an understanding of the ongoing processes. He conducted experiments with a coil, which he attached to the probes. You could see that the signal amplitude is changing, confirming the observations with the clock. The maximum amplitude on the coil if it is near and along the axis of the antenna. One and a half meters is not enough. It was decided to increase the transmitter power. The question is how? In the circuit that I took as a basis, 1 kOhm resistors were installed. I decided to reduce this resistance. Moreover, measured the resistance of the antenna. There was something around 300 ohms. Looking ahead, I’ll say that here I didn’t think about reactance. But first things first. Reduced the resistance of the transmitting antenna through the use of a wire with a cross section of 0.3.

    image

    In order for it to work, I probably decided to install a step-up module for the transmitting part. And to be able to turn it off to save energy. In this configuration, everything became noticeably better. Within 2-3 meters, there were many successful synchronizations on the axis of the transmitter. Off-axis successful synchronization was a meter away.

    image

    To increase the voltage used lt1302. In addition, I found an interesting charge on the ltc4054-4.2, which fit well into the concept of the device.

    At this stage, I realized why datasheets are needed. They help a lot when using microchips, especially when it comes to specialized devices. I already took lt1302 and ltc4054-4.2 connection schemes from a datasheet. And I made a habit of putting in git, in addition to schemes, source codes and datasheets of all used devices.

    First attempt to assemble a device


    So, I got to the soldering of the project. At this point, I had a device diagram. And a fritzing project that repeated the breadboard.

    image

    Separate hemorrhoids - create your own components for fritzing. As it turned out, this is an unpleasant part in general in any CAD system.

    image

    Another task that lasts long enough is to breed the board. This can last several days. But in principle, it is quite feasible. The main point: we place elements, then we connect them. If something uncomfortably connected, try a little rearrange the components.
    Noticed Fritzing's flaw. If you rearrange something on the breadboard or on the circuit, then this affects the breadboard. And there may be extra connections. Therefore, with small changes in one place they need to be done in another. In general, try, but it tires a lot. Although fritzing is not bad for simple schemes.

    Here's what happened.

    image

    Used a 15x9 breadboard. Sawed it in half. By the way, another necessary device for radio crafts - Dremel.

    Soldered a couple of days. It seems to work. But there was a lot of wall mounting. It looked ugly.
    They write that the boards need to be washed after soldering. I decided that I would try to launder. Used for this flux-off. But somehow it went wrong. Washed on Saturday at work, when almost no one was. But his head was spinning, although he used it a little and carefully. Shorter laundered and threw it. At the same time, everything was laundered badly. So far I decided to score.

    Here's what happened.

    image

    Here is another GPS module. I wanted the device to run on battery power for a long time. The GPS module consumes quite a lot, I decided to find a GPS device with an enable line so that it can be turned off. Enable did not work for me. But the GPS on mtk3339 turned out to consume 2 times less than neo-6m. 30ma vs 60ma. And the mtk3339 GPS module can be immersed in sleep.

    Rethinking the project



    He assembled the device, hoping that after soldering everything would work much better. But that did not happen. Old problems surfaced - unstable synchronization. There was also a problem when turning on the device without a battery. It did not work. It was possible to find out that the problem arose because the step-up charged a large capacitor at startup, and at the start the device consumed a large current, more than the current for which the power supply, which went into protection, was designed. Everything was fine with the battery, so for now I decided not to pay attention to the problem. I just picked up the capacitor so that there was no interference and the trip happened less. I did not want to install a resistor, so as not to increase the already large consumption of the device. The device worked on the strength - day. Which did not meet the requirements.Wikipedia and here . In the German version, everything was fine. I fixed the error on Wikipedia. It turned out that the amplitude should not fall by 15%, but to 15%. I noticed this while conducting experiments, but then I found confirmation, for example, in the German wiki. So, with synchronization, everything was decided, but the radius was still small. On the display at the edge was a strip of debris that I could not overcome.

    I did not like the switch that turns off the power. It turned out to be very bulky. In addition, in the transistor tester, I spied the idea that you can turn on the power by pressing a button, which can be used for other purposes. At the same time, the Transistor tester does not consume energy in standby mode.

    The waveform left much to be desired. The spectrum analyzer showed many unnecessary harmonics.

    I began to think how to improve the device. Googled another version of the synchronizer .

    What is interesting in it is that behind the logic element there is a filter on the lvm824 differential amplifier, and behind it is an amplifier on the transistor. Disassembled the device. Fortunately, it consisted of two parts. Used the logical part for control, and began to assemble the transmitting part on the breadboard and experiment.

    As is, I did not want to take the scheme. Because the voltage drop across the bipolar transistor is 0.6 volts, and the supply voltage is already about 4v. I began to think what to do.

    Considering options with sound amplifiers. But, firstly, they are designed for a frequency of up to 40khz, and secondly they have a voltage drop of 2 volts. I did not find anything suitable.
    I have already met the rail-to-rail characteristic which means that the amplifier works in the entire power range, so I began to look for similar ones. I realized that you need to understand how filters are made and calculated. Found resources where you can count filters .

    I had to suffer with filters. I began to experiment with them, using step-up to strengthen. Step-up was adjustable, which allowed to set a balance between power and battery saving. But there was no way to select the filter parameters so that it operates for a wide range of input voltages.

    Q1 transistor in circuituses as an amplifier. In order not to lose 0.6 volts, at first I decided to do the same on a field-effect transistor, but reading further about amplifiers, I found an interesting amplifier circuit - a bridge, which better amplifies the signal in antiphase. I tried such a circuit on lvm822 with an output transistor. The advantage of such a circuit is that with the same power, the signal amplitude doubles. And this means that ideally the power is quadrupled. I also noticed that there is an ad8532 microcircuit that is sufficient in output power for my purposes and thus does not need to be set up with an output transistor. Such a connection greatly reduced interference and allowed to abandon step up.

    I also stumbled upon the second improvement of the transmitter by accident. I saw that the reactance of my oscillating circuit is 1.5 kOm. This limits the power of the transmitter.

    When I experimented with the level of transfer to the coil, I thought that you can make a step-up transformer after the amplifier. Then, from the output of the amplifier, a larger voltage will be supplied to the input of the antenna. This was done by winding several turns on the transmitting Antenna. On the antenna itself there are about 200 turns, and on the other winding about 10 turns. The exact number was selected by an oscilloscope and a tester. By this time I already had a tester with a frequency counter.

    Such changes gave a big increase to the transmission power. Theoretically, the increase in power compared to the old circuit will be approximately 400 times. In addition, the signal became an almost pure sine wave. But I had to add blocking capacitors to the antenna, because of the constant component that was creeping into the signal.

    The range has increased greatly. It was even possible to synchronize the clock in another room, not paying attention to the location of the antenna.

    But at work, the device did not work. I think when a lot of computers are turned on - a lot of interference.

    Another problem - the transmitter sometimes did not start due to the fact that the generator did not start. This was solved due to the fact that I ground the quartz case and due to a more stable power supply.

    Another problem was that I went too far in the pursuit of gain in the communication coil. I understood what the problem was, slightly increased the number of turns, losing in gain, but the work of the transmitting part became more stable. It is now 100% synchronized for almost a year, every night.

    Final option


    In addition to the improvements in the transmitting part, I wanted to make a turn-off key as in a transistor tester, but there it is made on a bipolar transistor. To reduce losses, I decided to do it in the field with low resistance. Here I modeled it . Also tested on a breadboard. Everything was excellent: the voltage drop was approximately 0.05v, which suited me.

    I wanted to monitor energy efficiency. Therefore, I decided to build an ina139 ammeter. I tested it on a breadboard. But I had to look for resistance 0.05Om.

    The transmitter made everything disconnectable through the same AO3401 field device (Rds = 60mOm). In total, the voltage drop is 0.1V at the transmitter.

    He began to redo the scheme in fritzing. And then fritzing began to show for the worse. The scheme began to fall apart. Already completed connections remained, but the contacts were considered disconnected. Failed to fix the problem. The more you correct, the more the scheme fell apart. At work, by this time we had a club of like-minded people. I became interested in friends who use what for designing circuits. I was advised by kiCad and ToporLite. I redid the circuit on kiCad. Made new components that were not there. It all took a very long time. Used autorouting from topor. In principle, I liked it. A bit later I came across deeptrace. But I did not dare to switch to it. Although I suspect that deeptrace is still better.

    I immediately decided that I would not be sharpening on dip. I will do everything on smd, but in order not to bother with etching, I will order a fee in Ali or in Zelenograd.

    The case I had already been prepared for a long time. Therefore, the board was bred under the case.

    Bred a fee for several days. And he decided to still order in Zelenograd. They did it quickly. It turned out beautifully. He began to unsolder and found several errors. Confused rx and tx gps. Confused + and 0 current sensors. I made a mistake with the dimensions of a couple of millimeters on each side. Holes for mounting the display did less than necessary. In some places there was no mask on the components. Incorrectly parted the linear stabilizer for power from 9V - well, I took into account its cooling. It was necessary to make a large training ground for him. And he incorrectly spread the 9v connector itself. If the wiring of the connector could be fixed, then it was difficult to get rid of overheating. Therefore, I removed the 9v connector.

    And there were a number of minor problems. The most unpleasant of the first two. I suffered with them for a very long time.

    Another wiring problem is that I inattentively read the datasheet. I did not pay attention to how to breed the GPS module. There it was necessary to make a hole. All such corrections were made after Dremel. Some corrections had to be done by surface mounting. The worst thing was with the current sensor.

    In general, soldering was difficult. The hardest thing was to unsolder the GPS module. Even without errors, adjacent tracks are very easy to close.

    I missed with the loop of the screen. Not very accurate connector turned out. And bulky.
    But the device is assembled. Again I tried to wash the flux. This time washed with isopropyl alcohol. So laundered much better and without consequences.
    Here's what happened.

    image

    image

    The marker on the image above shows the errors found.

    image

    The final touches. Software development


    The final touch was to reduce power consumption by managing power, controlling power consumption and using the solar panel to recharge the device.

    Modified fonts so that the firmware fit into memory. Fixed a problem with a strip on the screen. It turned out that the Chinese sold me a screen on sh1106 instead of ssd1306 as was written in the order. Well, God bless them.

    To control the load, a round robin database is used for the current value. By the way, this experience was interesting even from the point of view of the programmer. There is little memory, but I wanted to store data for the year.

    Another subtle point is determining when gps synchronized time to turn it off. To do this, I had to modify the gpstiny library.

    Now, with all the modifications, the device works for about a month without charging.

    image

    the screen shows that the consumption is 12 mA, but this is due to the maximum brightness of the screen.

    Retrospective


    I started the project in January 2015. I got the first results in April. Soldered on a breadboard in July. After that, there was a break until March 2016. I collected the iron version on the ordered board in June 2016. On July 31, 2016 there was the last commit to improve software. So I spent a year and a half on this device. Could the project be approached differently? Maybe yes. But the knowledge was very lacking at the beginning of the project. Now it’s clear that such work requires tools and some details. And clearly what. Need knowledge. They appeared.

    Of course, I still confuse the emitter and collector in the circuit, and I will not be able to tell from memory how the transistor works in each of the connection modes. But I know where to look quickly. A lot of money was spent on the project. It would probably be cheaper to buy a clock with GPS synchronization. Could cost be reduced? Yes it is possible, but not fundamentally. Can I sell a device? Yes you can. But the labor costs for its production are too large. It’s more profitable to just work where I work now. I saw the sale of the device easier for 150 euros, but I need to collect it 2-3 days. And I think it's hard to sell. So, I don’t see commercial success with the device. Moreover, a clock with gps synchronization has begun to appear. They will soon become cheaper. Did I enjoy the process? Yes, I received. It was very interesting to learn new things. As a programmer, it was useful for me to increase my horizons. Will I post his sources? May be. If someone needs it.

    Possible improvements


    I launched a new board revision but didn’t order it.

    It is necessary to improve the power supply system of the controller. You need to turn off the power of gps completely, since in standby mode gps still eats 1 mA.

    Need to make the watch more accurate. There is an idea how to do this, but only on stm32. There you can use the function of adjusting the travel signal from GPS. Also, stm32 will allow you to abandon the extra chip. Although ds3231 is more accurate, you can make fine tuning for stm32.

    Try using an e-ink screen to save energy. Now basically the screen eats up the whole battery. It consumes somewhere 4 ma out of 6 ma in standby mode, when only the current time is displayed. The transmitter consumes 60 ma when turned on. This is 20 minutes a day. GPS consumes 30 ma, but it synchronizes time per minute.


    Also popular now: