📜 ⬆️ ⬇️

We restore the old clock "Electronics-7"

Good day, dear habrazhiteli!

This story began like this. While working at the facility, located in the building of the former factory (it seems metal) with a long name (and, of course, the name of the next great party leader), I saw one thing in a heap of rubbish destined for the release. What a thing struck me with a terrible attack of nostalgia, for it was exactly the same that hung in the hall of the SKB (with a no less long and polysyllabic name than the above-mentioned factory), where my mother once worked, and where a lot of time passed from my childhood. Meet - watch "Electronics 7-06".


')
Of course, I could not resist the temptation to restore (and perhaps even modify?) Them. Who is interested in the process, as well as the final result - I ask for the cat (carefully, a certain number of schemes and photos!).


1. A bit of theory


The clock scheme is freely available on the Internet. Element base is the 176th series of chips. Indicators - gas discharge type IV-26. Below is the original scheme.


Fig. 1. The original scheme, part 1


Fig. 2. The original scheme, part 2

2. Let's start with


The clock was removed from the pile of garbage, taken home and prepared. After cleaning the debris that has accumulated inside, this is what appeared to my eyes.











Turn on. In principle, everything works. But: indicators faded. Get the same IV-26 has nowhere. Google gives a lot of links telling us how to replace these IV-26 with LEDs, and even with ready-made seven-segment assemblies. Yes, but that's bad luck - it looks quite different ... modern and that's why it looks pop, I would say. Therefore, my task number one: to restore the indicators on the LEDs, while preserving the maximum appearance.

3. Scoreboard


When looking at the combs from the wires leading to the scoreboard, as well as on the schemes of these scoreboards with diode accumulators, I feel a little uncomfortable. Difficult to set up, you can easily confuse the wires. And the outputs of the 176th series are rather weak in order to directly control the LEDs. Plus I would like to be able to adjust the display brightness, preferably according to the scenario, too - at night, high brightness is not quite appropriate at home. The stability of the reference generator on the 25-year-old components to me, too, no one guarantees. Having estimated this way and that, I decided to modify the scheme completely.

Each indicator is a 7 x 11 LED matrix, so it goes out by the number of points on the original IV-26. It is controlled by the well-known ATtiny2313. It also stores the images of characters for display, the character generator table, in other words. Even without any optimizations of 11 bytes per character, a hundred characters exactly fit into it - this means that it is potentially possible not only to write numbers on the scoreboard. And I will have 4 such matrices. And what to display, let them get on the UART. Well, in fact, what will take time and send data for the scoreboard via this interface is later. I will think about it later (s). But only 3 wires are suitable for each matrix - GND, + 5V and Data. I considered that a unidirectional transmission line was sufficient for this task.

The display is dynamic, the node on the 74HC595 registers is used to select the rows, and the decoder 74HC238 is used to select the column. The design of the AVR + 74HC595 is well described and of no interest. Unfortunately, the tiny2313 SPI is somehow chopped up, so data loading into registers is done programmatically. Plus, when I tried to use SPI, I had problems with the PCB layout, so I abandoned this idea. The decoder is connected through a transistor assembly ULN2003 to increase power.

Initially, I planned to use an additional transistor for adjusting the brightness of the LEDs, controlled by hardware PWM on the T0 timer, but a problem arose: PWM superimposed on the dynamic indication (their frequencies, of course, did not coincide), caused an unpleasant LED flicker. Therefore, the PWM is software, and it is implemented using a column select decoder. As you can see, the indicator has 7 columns, and the outputs of the decoder are 8, and the last output is not connected. Choosing it, we extinguish the entire matrix.

The current of the LEDs is limited by resistances. Based on the documentation of the applied LED-5213-PGC-6cd, 3–3.5V at a current of 20 mA falls on them, we take an average of 3.2V. Plus another 1B drop on the ULN2003. Total (5 - 3.2 - 1) / 0.02 = 40 ohms. I took on 39 ohms.

Switches SA1 set the address of the board. This approach allows you to make all 4 boards the same.
Unfortunately, I have not yet mastered the plating of holes at home. Therefore, the single-layer board and the number of jumpers on it can be terrifying, although it has been reduced to a minimum by efforts.

The schematic diagram is shown below.


Fig. 3. Schematic diagram of the indicator


And here is a photo of the board at one of the manufacturing stages (a photoresist has just been applied and developed).

The exchange protocol is very simple:
The first byte is always FF, this is the packet header.
The second byte is the address of the board.
The third byte is the data to display, the character code according to ASCII.
Fourth - the desired brightness in the range 00 - FE.
At the end - the lower 8 bits of the sum of all bytes of the packet, integrity check. If the sum is FF, replace with FE. Sample package:

FF 01 32 80 B2 - display the character “2” on the board with the address 1, the brightness is half the maximum.

In the process of writing the code, I also got the idea to make the display board at the moment of start, before receiving the first data, display its address. It turned out to be convenient when debugging.

4. Power supply


The native unit contains a transformer with two windings: one produces 22V, which were used to power the anodes of the indicators, and 3.8V to power their filaments. Capacitors, of course, lost their capacity, besides, we will need + 5V. So the scheme will have to be revised. In addition, it provides for the ability to power the logic of 6 batteries at 1.5 V, so that the time during a power failure does not go astray. Batteries are somehow not serious, they require regular replacement, so I redid this node to work with a standard 6V, 4.5 Ah battery.
However, 22 * ​​1.41 = 31B. NDA, the usual 7805 is not enough here, except that we want to fasten here also the function of the room heater. A short googling, and LM2576-5.0 comes to the rescue - an integrated switching regulator with an output current up to 3A, which even was found in the local radio parts store.
Searching where I could steal gratuitously borrow a charger scheme in order to reduce the number of bicycles created brought me here (in general, the site is dedicated to bicycles, which in the context of the phrase smiles a little). However, shemka on linear stabilizers ... however, there is a version of the aforementioned LM2576 with tunable output voltage. In fact, it is necessary to pile a source with a restriction of the type “output voltage of about 6–14 V (with adjustment so that you can pick up the battery at 12V), the output current is not higher than 0.5A (also with adjustment).” After some thought, something happened.


Fig. 4. Power supply circuit

Switching the “charge / battery operation” mode is performed by a conventional mechanical relay with a 220V winding connected in parallel with the primary winding of the power transformer. Somewhat naive, but, paradoxically, it works.

5. The heart of the system


So it came that very “later” in which I promised myself to think about what the actual time would be to count and control the indicators. And even better, if it also synchronizes it with the world. By NTP, for example. Or DAYTIME. Fortunately, there is Wi-Fi in the house. And most importantly, yes. I almost forgot. In this watch there is still one native element of the display, which is so touching that I found it blasphemous to change it. For I can not recreate the same, and he is quite a worker. Flashing second point on the indicator IV-4! Here she still needs to blink.

I’ve been picking the forums for AVR and Wi-Fi for a long time, watching how it was done on the Arduino ... but the price depresses me. And then my eyes fell on the “raspberry” bought for the purpose of studying with the subsequent creation of the torrent of the torrent, which lies on the shelf ...

No, well, it's not even a cannon on the sparrows. This is just a blow to the main caliber of the Death Star in order to destroy the evil bacteria under the rim of the toilet bowl. And on the other hand, does it matter where this torrent player will stand? Space for USB-HDD in the watch case is more than enough. In addition, my experience with * nix-systems is not very significant yet - an excellent opportunity to broaden my horizons. Approximately these thoughts flew through my head, and the fate of Malinka was decided. Well, then let the street temperature show, if that ... if I got hold of such power. Yes, and the character generator of the board now allows you to draw pros and cons.

How to fasten a real-time clock to rPi, as well as how to turn it on in general, perform initial setup, install a torrent client there - it was said many times before me. However, a number of links that seemed useful to me, I still give below.

I take street temperature from the Rambler. The choice is due to the preferences of my second half.

So, in stages, all actions with the "raspberry":

Here we read how to make her friends with the TP-Link TL-WN725N Wi-Fi adapter.

And here - how to install a VNC server can be useful.
Here lucidly described how to raise Samba.
And here is how to work with the built-in UART.

Such a script synchronizes time with the world using NTP.
timesync.sh
#!/bin/bash sudo service ntp stop sleep 5 sudo ntpdate time.nist.gov time.windows.com sleep 5 sudo service ntp start 



This script reads weather from the Rambler, adding the received data to a file.
getweather.sh
 ##!/bin/bash URL="http://api.rambler.ru/weather/informer?content_type=xml" FILENAME=/home/pi/clock/weather.dat WEATHER=$(curl ${URL} | grep -o -E "(<now><temp>)[\+\-]?[0-9]{1,2}(<\/temp>)" | grep -o -E "[\+\-]?[0-9]{1,2}") if [ -z ${WEATHER} ] then echo "Get weather failed!" else echo -ne " " > ${FILENAME} echo -ne $(printf "%+03d" ${WEATHER}) >> ${FILENAME} fi 



The main script transmits data through the UART to display:
send.sh
 #!/bin/bash DATAPATH=/home/pi/clock/weather.dat declare -i LOW_BRIGHT=5 declare -i HIGH_BRIGHT=100 send_data () { DATA=$1 LEN=${#DATA} stty -F /dev/ttyAMA0 cs8 -cstopb raw speed 19200 > /dev/null for((i=0; i<$LEN; i++)); do ADDRESS=$(printf "%d" $(($i+1))) CHAR=$(printf "%d" ${DATA:$i:1}) if [ "$CHAR" = "0" ] then CHAR=32 fi HOUR=$(date | cut -c 12-13) if (("$HOUR" > "20")) || (("$HOUR" < "7")) then BRIGHTNESS=$(printf "%d" $LOW_BRIGHT) else BRIGHTNESS=$(printf "%d" $HIGH_BRIGHT) fi CHECKSUM=$((($ADDRESS+$CHAR+$BRIGHTNESS-1)%256)) if [ "$CHECKSUM" = "255" ] then CHECKSUM=254 fi ADDRESS=$(printf "%o" $ADDRESS) CHAR=$(printf "%o" $CHAR) BRIGHTNESS=$(printf "%o" $BRIGHTNESS) CHECKSUM=$(printf "%o" $CHECKSUM) MESSAGE="\0377\0$ADDRESS\0$CHAR\0$BRIGHTNESS\0$CHECKSUM" echo -ne "$MESSAGE$MESSAGE" > /dev/ttyAMA0 done } if [ "$1" = "time" ] then HOUR=$(date | cut -c 12-13) MINUTE=$(date | cut -c 15-16) TIME="${HOUR}${MINUTE}" send_data $TIME exit 0 fi if [ "$1" = "weather" ] then WEATHER=$(cat ${DATAPATH}) if [ -z ${WEATHER} ] then echo "No weather info found" exit 0 fi send_data "$WEATHER" exit 0 fi if [ "$1" = "startup" ] then send_data "HELO" sleep 5 send_data "HABR" sleep 5 send_data " " exit 0 fi echo "Usage: send.sh time | weather | startup" exit 0 



And yes. A blink of a second.
blink.sh
 #!/bin/bash sudo echo "25" > /sys/class/gpio/export sudo echo "out" > /sys/class/gpio/gpio25/direction while true do echo "1" > /sys/class/gpio/gpio25/value sleep 0.5 echo "0" > /sys/class/gpio/gpio25/value sleep 0.5 done 



Now add all this stuff to cron:
 # mh dom mon dow command 0/15 * * * * /home/pi/clock/timesync.sh 0/15 * * * * /home/pi/clock/getweather.sh * * * * * sleep 00; /home/pi/clock/send.sh time * * * * * sleep 10; /home/pi/clock/send.sh weather * * * * * sleep 15; /home/pi/clock/send.sh time * * * * * sleep 25; /home/pi/clock/send.sh weather * * * * * sleep 30; /home/pi/clock/send.sh time * * * * * sleep 40; /home/pi/clock/send.sh weather * * * * * sleep 45; /home/pi/clock/send.sh time * * * * * sleep 55; /home/pi/clock/send.sh weather 

And ... and everything. We hang on the wall, enjoy, nostalgic. Photos of the process (clickable), as well as the traditional greeting to the residents of Habr can be seen below.

Attention! To the author of the article at birth, an artistic feeling was cut out, as a future engineer was not needed. Connoisseurs of the undeveloped horizons, composition of the frame and any other white balance, please stop reading at this place and go directly to the comments, in order to avoid serious emotional trauma.


Mounting display boards on the chassis. Next is the power supply board.


We paint the rusted back covers.


The first inclusion is assembled. Boards display their addresses.


All elements are mounted on the chassis.


Larger, same stage.


We pack in the case.

And - a logical conclusion!



Time.


Temperature overboard.




All schemes, printed circuit boards and firmware can be found here .

Source: https://habr.com/ru/post/242263/


All Articles