Logs:
1. Overview
2. D-type Flip-Flops
3. The Decoders
4. It's alive!
5. 2nd digit and RTC
6. Stuck... Unstuck... and redoing some work
7. Decoders continued...
8. Update June 2018
9. Timekeeping and RTC
10. Foto update (Nov 2018)
11. It's finished!
A digital 24 hour clock using only relays and diodes for the counting logic.
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
Logs:
1. Overview
2. D-type Flip-Flops
3. The Decoders
4. It's alive!
5. 2nd digit and RTC
6. Stuck... Unstuck... and redoing some work
7. Decoders continued...
8. Update June 2018
9. Timekeeping and RTC
10. Foto update (Nov 2018)
11. It's finished!
Yes, finally, the clock is finished. In fact, it has been since the summer of 2020 but I'm just getting around to writing about it. For a long time, the electronics were done, but the clock just sat in a box because I could not decide how I wanted to finish the clock from a mechanical standpoint. All the separate PCBs were screwed to a temporary MDF template that I lasercut back in 2015. I had made a lot of different designs for how to mount all the boards so you could actually hang it on the wall like a real clock, but I was not content with any of the designs. During the pandemic I finally bit the bullet and designed a minimal 3D-printable frame that all components could mount to. This is the final result:
The frame is hardly visible, as it is printed from black PLA. The frame consists of a center section with 16 spokes that slide in an screw to it. The parts have threaded brass inserts where the stainless hardware screws into. The center section was almost too large for my printer, I had to flatten the sides of the circle by a few millimeter. Here it is with the printer just finished:
After printing the spokes and mounting them, I designed an aluminium plate that screws in the middle of the center section. This has keyhole slots that are used to mount to the wall. The plate was ordered from Schaeffer AG (Frontpanel Express in USA). Here's the frame with half the spokes fitted, I could not find a picture of the completed frame.
You can see the brass inserts on the front and a few rubber feet on the back so it doesn't sit right up on the wall but a little distance from it. I think it looks good. In this last picture you see how it scales on my wall. The red and orange box on top of the cardboard boxes is the power supply. I printed it from leftover filament, that's the reason for the weird colors.
Let me know what parts of the clock you still want me to describe. The power supply is just a framed switching supply in a custom printed box with a nice yellow fabric lamp cord. I think that the only part missing from the technical description is the working of the carry circuits. This deserves a separate writeup.
The last PCB, fresh off the mill. This is the lower decoder board. It replaces the two separate decoders I made earlier, because I had to add extra circuitry for the carry logic.
Here it is after soldering.
Those diodes are a real challenge to do consistently. Here is a view from the back of the clock. I had to transfer all the PCBs to a new carrier board (the piece of MDF), without disturbing the delicate wiring. I removed the flip-flop boards to make it easier to handle. You can see I just started wiring in the new lower decoder board.
And there it is, in all it's warm glowing glory. Completely functional, although the wiring needs some work. This is a major milestone for me. The first time all the components are in place and everything seems to be working. Now I can start designing the plexiglass frame that it will be mounted in.
That's it for now. Thanks for reading! Cheers.
One part missing from my description so far is the part that does the actual timekeeping. I am a bit reluctant to publish this, as I consider it the least 'pure' part of the design. Every other part of the clock only uses old technology: Relays, diodes and resistors. But this small PCB has a microcontroller, crystal, real time clock IC, two MOSFETs, a lythium battery and a microcontroller. Those are all quite modern components. But every design has compromises and this is where I made most of them.
I wanted the clock to keep accurate time, otherwise, what good is it? What I needed was one clock pulse per minute to the minutes section. When the minutes rolled over from 59 to 00, that could be detected and a clock pulse to the hours section could be generated.
I considered multiple options to do this. From reading the 50Hz net frequency and dividing it down, to using a synchronous motor to generate a pulse once per minute. In the end I opted for using a real time clock and crystal and a microcontroller to generate the clock pulses. There is no carry circuit from the minutes to the hours. The microcontroller generates a separate clock pulse for the minute and hour circuits.
Below you see the schematic of this circuit board. In the top left is the DS1337 real time clock. This does the actual timekeeping. It has a battery to continue operating when the power to the clock is disconnected. To the left is the DS32KHZ crystal. It is a very accurate temperature compensated crystal, that is supposed to be 2PPM accurate. That is just over a minute deviation per year!
In the bottom left is the Atmel ATTiny44 microcontroller. It read the time from the RTC via the I2C bus. The microcontroller drives two MOSFETs, who supply the clock pulses to the rest of the relay clock circuits. I chose MOSFETS instead of relays to save space and because these relays would wear out quickly.
The microcontroller continually reads the time from the RTC. When a minute rollover is detected, it outputs the clock pulse to the minute and/or hour circuits. The two pushbuttons are used to set the time. One for the hours and one for the minutes. Whenever a button is pushed, the minute or hour is incremented and the seconds are zeroed. This allows for accurate timesetting.
One last gimmick I implemented is a showy power up sequence. The relay counter circuits start at 00:00 when the power is connected. The microcontroller starts with incrementing the minutes first and then the hours. It's just a nice little element to show off the mechanism to someone.
Above you see the finished circuit board. The soldering on the MOSFETs is a bit dodgy and I may redesign it later to use a different RTC. The Maxim DS3231 looks like a nice candidate. It's just as accurate, but has an integrated crystal. For now I am happy with this though.
It's been a long time since my last update. Although unfinished, the project is still alive. I got sidetracked with a different project, work and moving house two times. In the background I'm still working on this one. It is one of my dearest designs and I fully indend to finish it.
At this point, three things need to be done to finish this project.
The last time I wrote about the decoders I was short on explanations. I had just built the first one of four. Now several months and a lot of redesigns later I am ready to give a longer explanation.
Originally I intended to build four separate decoders, each one driving a single seven segment display. However I was running out of space so I had to combine the decoders together in order to fit some extra relays responsible for carry and reset of the flipflop's.
Functionally there are the following separate circuits:
These circuits are now combined into two decoder boards:
Upper decoder:
Lower decoder:
Because I was running out of space, I had to move the functional blocks around a bit so that in the end each decoder board contains exactly ten relays.
The table below shows the decoding of the four displays.
DECODING LOGIC
! is NOT
& is AND
i.e. !A & E is (NOT A) AND E
Single-minutes
1A 1B 1C 1D 1E | Num Logic
--------------------+--------------
0 0 0 0 0 | 0 !A & !E
1 0 0 0 0 | 1 A & !B
1 1 0 0 0 | 2 B & !C
1 1 1 0 0 | 3 C & !D
1 1 1 1 0 | 4 D & !E
1 1 1 1 1 | 5 A & E
0 1 1 1 1 | 6 !A & B
0 0 1 1 1 | 7 !B & C
0 0 0 1 1 | 8 !C & D
0 0 0 0 1 | 9 !D & E
Tens-minutes
2A 2B 2C | Num Logic------------+--------------
0 0 0 | 0 !A & !C
1 0 0 | 1 A & !B
1 1 0 | 2 B & !C
1 1 1 | 3 A & C
0 1 1 | 4 !A & B
0 0 1 | 5 !B & C
Single-hours
3A 3B 3C 3D 3E | Num Logic
--------------------+--------------
0 0 0 0 0 | 0 !A & !E
1 0 0 0 0 | 1 A & !B
1 1 0 0 0 | 2 B & !C
1 1 1 0 0 | 3 C & !D
1 1 1 1 0 | 4 D & !E
1 1 1 1 1 | 5 A & E
0 1 1 1 1 | 6 !A & B
0 0 1 1 1 | 7 !B & C
0 0 0 1 1 | 8 !C & D
0 0 0 0 1 | 9 !D & E
Tens-hours
4A 4B | Num Logic
--------+---------------
0 0 | 0 !A & !B
1 0 | 1 A & !B
1 1 | 2 A & B
0 1 | X -
Let's have a look at the first table, which shows the decoding of the rightmost digit, the single-minute digit. This digit is controlled by the first five flipflop's, numbered 1A through 1E. The first five colums represent the output state of these flipflop's. Notice the progression typical of a johnson counter, totally different from a binary counter. Next you see the number that this state represents and the final column shows what logic is needed to decode a number. For example, to decode the number '5' , flipflop A and flipflop E have to be both on.
The logic to decode the state of the flipflop's is all implemented, again, in relays. As you can see, every 'statement' consists of two inputs that are logically AND-ed together. To get an AND function in relays, you simply chain the outputs of two relays together. So to get A & B, you chain the normally open outputs of two relays in series. The current flows through the contacts only when both relay A and relay B are on. By using a combination of the normally open and the normally closed contacts you can implement the NOT function as well.
A very convenient property is that the combinations form pairs that are opposites of each other. For instance A & !B and !A & B are opposites. So are B & !C and !B & C. In fact, the ten combinations form five pairs. This property allows you to save relays. To implement the logic for a pair, only two relay contacts are needed, one from each relay. Because the displays are made of LED's, current can only flow through them in one direction. I am making use of this by wiring the LED's together in the opposite direction. See the little schematic below.
Two relays, K1 and K2 with their inputs A and B. The outputs are LED's D1 and D2. The outputs of the relays are wired...
Read more »It has been a while since I last posted a log entry. The reason is that I got stuck. I guess this happens to all of us from time to time. Let me tell you what happened.
When I designed the broad layout of the circuit boards I had the whole thing figured out for 90%. The other 10% I would come up during the process. Or so I thought. I did some initial tests to confirm my understanding of the mechanism and after that I got to work designing and fabricating all the individual boards. I never forgot about my little 'problem', but I was still confident that I would come up with a solution when the time was right. And then all of a sudden I was done doing all the work that could be done before solving my little issue. This is when I got stuck...
So what was the problem? It has to do with carrying the clock signals from the lower to the higher digits and resetting the counters back to zero at the right moment.
I had sort-of solved this issue with the minutes counters. They already roll over to zero after 59 on their own. This is because the lover digit can only count from 0 to 9 and the higher digit can only count from 0 to 5. The only thing I had to do was carry the clock from the lower digit to the higher one when it rolled over to zero. So every time the lover digits rolls over, it sends a clock to the higher one and increments it by one. I should have added an extra relay to buffer the carry signal, but instead I just wired the clock for the higher digits directly to the output of the last relay in the lower digit counters. This worked, but had the disadvantage that on power-up the digits would reset to "1-0" because the higher digit would get clocked immediately form the lower "0" digit. I could live with that, for now at least.
The hours counter is a little different and this trick wouldn't work. The really big problem was that I had to reset it at the right moment. These counters don't automatically roll over from 23 to zero just on their own. I had to force it somehow. Only I had no idea how to do it. This is why I stopped working on the project for several months. There were too many conflicting issues to solve all at once. I had to figure out how to do it electronically. But this surely meant extra relays and I didn't have board space for extra relays. And I did not want to compromise the look of the clock. So I was stuck. Stuck with this thought in my mind that I couldn't solve it.
But in the end I did solve it. As always, at some random time the solution came to me. And this is what it was.
I decided that I had to detect the "2-3" state and then on the next clock reset the higher and lower hours counters back to zero. The flip-flops are reset by cutting power to them, that's the only way. So the power to these flip-flops now runs through an extra relay that can be triggered to reset the hours counters. I use the outputs of the decoders that run the display to detect the "2-3" state. Both the 3 of the lower digit and the 2 of the higher digit run to separate relays. These are chained to form a logical AND operation. Then when the next clock pulse comes in, these two relays trigger the reset relay. I added a big capacitor, to keep the reset relay energised long enough to make sure all flip-flops are reset.
With the reset covered, a new problem arose. Because the hours counters had to display "0-0" on reset, I could not use the same trick as with the minutes counters to carry the clock from the lower to the higher digit. So I had to include a buffer relay. Together with the reset relays this was an extra 4 relays and I had no board space left to place them. This was a real problem as the layout of all the circuit boards could not be changed any more.
The only thing I could do was redesign the decoder boards. Originally I had designed them as 4 separate boards, because of restrictions on the size of circuit boards I could mill at the Fablab. Unfortunately, with all the mounting holes for the extra circuit boards I lost a lot of...
Read more »Today I finished the decoder for the 2nd digit. The minute display section is now complete. As you can see in the video, I finished a prototype of the battery powered real time clock as well. When the power is applied, the clock shows "10" minutes, this is because the 2nd display is clocked by the first display when it shows 0. So on power up the 2nd display immediately gets a clock and increments.
Connected to the relay clock you see an Arduino with a real time clock. I use a Maxim DS1307 to keep the time. It is connected via I2C to the processor. I have a temperature compensated crystal oscillator, a Maxim DS32KHZ, which is supposed to be accurate to +/- 2 PPM per year. This is only a prototype, in the end I will design a small rectangular board that will go in the free position at bottom of the outer circle.
After the processor powers up, it reads the time in the RTC and then sends out clock pulses tot the relays until the time on the displays corresponds to the time in the RTC. The two buttons can be used to increment the hours or the minutes. On incrementing the minutes, the seconds in the RTC are reset to zero as well.
The clock is now half done! On to the hour section. This will require some more relay trickery to get the thing to roll over from 23 to 00. I have yet to design the decoders for this, so I hope it will all fit on the available board space.
This weekend I managed to complete the single-minutes stage of the clock. After testing the flip-flop's and building the decoder I could finally connect everything together. The completed seven segment display has been sitting on my bench for months, waiting to be used. I now have one working digit. This is a milestone for me, the first time I have everything working from the counting logic to the display. As you can see in the video, the clock signal is generated externally by an Arduino. For now anyway. Enjoy the soothing clicking of the relays.
Today my latest shipment of relays got in from Hong Kong, so I can finally finish one of the decoders. I am just posting some pictures for now, but I promise to add a complete description later. The decoder shown here is the first of four. It is the single-minutes decoder. It has five inputs, from the first five flip-flops and it drives one single seven-segment display. At the bottom you see the array of diodes that decode the ten different digits. The five relays at the top are responsible for the AND operations to detect the correct state of the flip-flops.
The Johnson counters in the clock are made by stringing together individual flip-flops. This design uses D-type flip-flops. As I wrote before, the design of these flip-flops is copied from Simon Winder's design. He does an excellent job at explaining how they work in the following video.
I took Simon's schematic, modified it slightly to suit my needs and then made a circuit board layout in KiCad. All the 15 flip flops in the clock are exactly the same. Here is the schematic:
I ordered the cheapest 5 volts relays I could find off of Ebay. Their size is the main determining factor in the circuit layout of the flip-flops. After many revisions, this is the final board I settled on:
After lay out the circuit board, I milled the pcbs out of single sided FR-1 stock using a Roland Modela mdx-20. I want to thank Fablab Amsterdam for the many hours of machine time. I only have 160x100 circuit board blanks, so when laying out this board (and all the others in this project), I had to keep the size down and fit as many on a board as I could. Here's the result after milling six of them in one go:
Create an account to leave a comment. Already have an account? Log In.
I see what you mean. That's how KiCad shows them in dark mode and those pictures are just screengrabs. I need to write an update, as the project has been finished for a few years. The schematics are incomplete, as the carry circuits are missing.
Have you started your own relay logic project yet? Love to hear about it.
Great Project!
I had completed a Seven Segment Decoder with just relays (No Diodes) and am now going to try to learn enough to build the counters out of relays. Love seeing others with the crazy like I have. My stuff is huge due to the simplistic use of relays, your approach is really nice! Here is my hacked up approach - http://www.ez260.com/ It's in need of some updating, but assembly of a board takes some time so it's slow going ;)
Glad you like the project! It's been a while since I posted an update, but the project is still alive and I am making progress. Nice to see other people interested in this crazy usage of relay technology. How are you progressing in learning about the counters? I still find it's really interesting stuff. There's just something about the clicking sound that makes it feel more 'alive' than modern electronics.
Have been slow, found a few others with relay counter and they look pretty easy to build but need to prototype one of them and see how it works. Their are few guys that did clocks with them. A couple had used a unique way of eliminating relays to form the flip flop with less parts. Have to get a bit more time on this now that you mention it :)
Progress on things like this tend to be slow, but good that you are still working on it. There are a few ways to reduce the number of relays. One is that I used a johnson counter instead of a binary counter. The binary is more difficult to decode to seven segment, as you may have found out with your BCD to 7 segment decoder. The other trick is to use relays with more contacts. I used DPDT because I could find cheap ones, but had I used 4PDT relays, I could have used only half as much as I did now. You can do a flip-flop and decoding with only two 4PDT relays instead of the four DPDT that I did it with.
I found some very slick implementations of a FF with more common relays (not 4PDT) They rely on a small cap and resistor to cheat a bit. I'll have to dig up the counter circuit. It was, as I recall for a project that the guy made a Relay based single board computer. Was really cool.
That's some seriously nice looking hardware. And the router has made a beautiful job of the PCBs. And I'm pleased to see you're using KiCAD.
Now, for the clock source, how about a reed switch triggered by a solenoid powered by the mains, clocking a divide-by-120 (or 100) relay counter? That keeps the design 'pure' :)
Thank you, I like how the boards turned out. Also, these pcb's have a more 'antique' look than the green ones from the board house. In a next version I would have the boards fabricated because it takes a seriously long time to mill them all.
Ah yes, the clock source. You got me there. I really wanted to keep the design 'pure' but couldn't because of practical reasons. To divide the 50Hz mains down to a 1/60Hz clock in a discrete way would take too much space. In the end I chose a ATtiny microcontroller, a DS1307 real time clock and a DS32KHz temperature compensated crystal to keep time. The only thing it does is generate a 1/60 Hz clock signal for the relay counters. But because of the battery backed RTC, it will set the time for you when the power is plugged back in. I do consider this cheating but I thought this was the best solution. Also, the crystal has a drift of only 2 ppm so the clock should be pretty accurate.
Do you think the reed switch could reliably handle a 50Hz signal? I dismissed this idea because I thought the frequency would be too high for a mechanical circuit, but perhaps it is possible to do it.
a synchronous motor, maybe ? (as used by disco ball rotators) such as http://www.ebay.com/itm/Motor-for-disco/361278555366
A reed switch generally has sub-millisecond response times, and good for billions of operations. You problem will be further upstream. According to the datasheet and my calculations, the LSB of your divide-by-100 relay counter will burn out in about an hour :)
Yann's synchronous motor idea deserves serious consideration though.
A further thought: if you can gear it down 50:1, and attach a magnet to the output cog, then there's your 1s trigger for the reed switch.
I agree, the life expectancy of the parts is a real limiting factor here. Did not know that reed switches where that fast though. Are there any devices out there that have an electromagnet and reed switch integrated in one package? These would not be that much different from a regular relay, except that the switch is operated by magnetism directly and not via an arm that is operated by magnetism.
I will look further into the synchronous motor. Isn't that the exact same way that the old 'flipover' nightstand alarm clocks from the 50s keep time? With a synchronous motor fed off the mains and a gear reduction to drive the display.
Another avenue to pursue would be neon bulbs. I have seen clock designs that use small neon bulbs for the active element instead of transistors. You can make awesome counters this way, but they do take up more space than I have available in this project. see this page for some excellent examples: http://www.dos4ever.com/ring/ring.html
My opinion is that the MTBF is given at full switching load. Dave will use low level signals so it should be easier on the contacts.
I have never found reports of broken relays, only old vacuum triodes. That would be an interesting research to do.
Could Dave setup a little stress system for some relays ? feed 20Hz to a coild and cascade other coils, because the release of the contact probably has as much effect as the physical shock of the contacts together, because of the inductance... (a 100nF in parallel with the coil will also ease the electrical spikes, before the diode conducts)
There is something missing, I think : LEDs !
Show the status of each relay so it makes a strange, puzzling light pattern around the dial...
Great idea, and they're already there! Each flip flop has a single orange LED to indicate it's state. I have no photos of it yet, but you could read the time just from the state of the Johnson counters in the outer ring alone.
Actually it only clicks once a minute, so there's no constant operating noise. And the whole thing will be sandwiched between two 6 mm plexiglass sheets and mounted in an aluminium extrusion frame. My hope is that will dampen the sound a little.
Oh... unleash its voice!! let it click a relay once in a second! After all a clock must tick! Lol!
and from the sound of it, hear when it skips to the next minute or the next hours :-D
But the relay contacts might wear out much faster...
That was one of the considerations not to count seconds. The relay contacts are specified at 1.000.000 operations, that would give the busiest ones in the clock a life of 2.5 years. I made the flip flop modules removable so they can be replaced.
Yeah, the lifespan of the contacts for the seconds relay would be less than two weeks, but if you don't use the relay contacts that wouldn't matter, I mean, the only use for the seconds relay would be to produce a cool ticking sound.
Of course, your clock is cool enough as it is now :)
+1 for relay logic
+1 for Johnson counter/4017
+1 for smart diode decoding of 7 segments dispay
-something for all the operating noise ;-)
Become a member to follow this project and never miss any updates
Someof your schematics are dark blue and dark red on a black background. This makes them very difficult to read.
Great project, I have always wanted to see someone actually use relay logic, but my eyes are killing me trying to read those schematics.