Relay Logic Clock

A digital 24 hour clock using only relays and diodes for the counting logic.

Similar projects worth following
The idea to build this all-relay-logic digital clock came last year as I was assisting in workshops teaching basic computer science workshops to 10-12 year old kids. While I was thinking about new ways to explain digital circuits I came across Simon Winders's project.

I want to give credit where credit is due. The relay flip-flops in this project are based on the design by Simon Winder used in his 'Relay Calculating Engine'. His awesome project inspired me to build this clock. The overall design and circuit board layouts are all my original work. Read about Simon's work on

This is very much an ongoing project still in development. There is so much left to do! Maybe as a little encouragement to finish it I decided to share it in it's current state.

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...

  • 313 × 1N4148 diode
  • 320 × Male connector RM 2,54, gold plated Conrad# 393491
  • 160 × Female connector RM 2,54 Conrad# 741293
  • 150 × various 5% 0.25W resistor
  • 131 × 5mm square orange LED MULTICOMP MCL293BD (Farnell# 1581163)

View all 11 components

  • Decoders continued...

    Dave Gönner05/18/2016 at 10:03 3 comments

    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:

    • Single-minutes decoder, connected to flipflop's 1A - 1E
    • Tens-minutes decoder, connected to flipflop's 2A - 2C
    • Single-hours decoder, connected to flipflops's 3A - 3E
    • Tens-hours decoder, connected to flipflop's 4A - 4B
    • Carry single-minutes to tens-minutes
    • Carry single-hours to tens-hours
    • Reset hours when '24' hours state reached

    These circuits are now combined into two decoder boards:

    Upper decoder:

    • Single-minutes
    • Tens-hours
    • Reset hours

    Lower decoder:

    • Tens-minutes
    • Single-hours
    • Carry minutes
    • Carry hours

    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.

    Decoding the digits

    The table below shows the decoding of the four displays.

    ! is NOT
    & is AND
    i.e. !A & E is (NOT A) AND E
    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
    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.

    Implementing the logic

    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...

    Read more »

  • Stuck... Unstuck ... and redoing some work

    Dave Gönner05/07/2016 at 09:16 1 comment

    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,...

    Read more »

  • 2nd digit and RTC

    Dave Gönner01/11/2016 at 12:50 0 comments

    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.

  • It's Alive!

    Dave Gönner01/05/2016 at 10:50 2 comments

    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.

  • The Decoders

    Dave Gönner12/30/2015 at 14:10 5 comments

    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.

  • D-type Flip-Flops

    Dave Gönner12/07/2015 at 13:18 9 comments

    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:

  • Overview

    Dave Gönner12/07/2015 at 11:48 0 comments

    Schematically the clock consists of four Johnson counters, cascaded together to count and display time in 24hour format. I chose Johnson counters instead of regular binary counters because the decoding to seven segment requires less logic gates than a regular binary counter. Every logic operation is done with relays, so every operation counts.

    A Johnson counter has 2n states, so a 5-stage Johnson counter can have 10 different states. Minutes count from 0 to 59. The lower digit goes from 0 to 9 and thus requires a 5-stage Johnson counter. The upper digit goes from 0 - 5 and therefore has only a 3-stage counter. The same logic applies to the hour counting.

    This is a block diagram of the different functional blocks in the clock.

    The design of the counters and the decoding circuitry closely resembles what can be found in a 4017 chip. The following was taken from a datasheet. Minus the two AND and OR gates at the top it is the same. After decoding from 5 bit to 1 in 10, it is further decoded to 7 segment via an array of diodes (not shown here).

    This is a front view of the partially completed clock and shows the layout of the different functional blocks. The four decoders and seven segment displays are not yet mounted in this picture. The MDF board is just a temporary frame to hold the parts for assembly and soldering. Once everything is finished, it will be transfered to a 6mm clear Plexiglass sheet with only the holes for the screws drilled. The large cutouts in the MDF are for easy access on the back for soldering and will not be present in the final Plexiglass sheet.

View all 7 project logs

Enjoy this project?



Sandy Ganz wrote 08/04/2017 at 21:34 point

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 - It's in need of some updating, but assembly of a board takes some time so it's slow going ;)

  Are you sure? yes | no

Andrew Starr wrote 12/09/2015 at 08:39 point

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' :)

  Are you sure? yes | no

Dave Gönner wrote 12/09/2015 at 11:51 point

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.

  Are you sure? yes | no

Dave Gönner wrote 12/09/2015 at 11:56 point

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.

  Are you sure? yes | no

Yann Guidon / YGDES wrote 12/09/2015 at 12:37 point

a synchronous motor, maybe ? (as used by disco ball rotators) such as

  Are you sure? yes | no

Andrew Starr wrote 12/09/2015 at 19:51 point

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. 

  Are you sure? yes | no

Dave Gönner wrote 12/09/2015 at 20:01 point

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:

  Are you sure? yes | no

Yann Guidon / YGDES wrote 12/09/2015 at 20:09 point

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)

  Are you sure? yes | no

Martin wrote 05/18/2016 at 12:12 point

@Dave Gönner:

"electromagnet and reed switch integrated in one package" - yes, it's normally called "reed relay".

  Are you sure? yes | no

Yann Guidon / YGDES wrote 12/08/2015 at 22:37 point

There is something missing, I think : LEDs !
Show the status of each relay so it makes a strange, puzzling light pattern around the dial...

  Are you sure? yes | no

Dave Gönner wrote 12/09/2015 at 11:37 point

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. 

  Are you sure? yes | no

Yann Guidon / YGDES wrote 12/09/2015 at 12:32 point


  Are you sure? yes | no

Dave Gönner wrote 12/08/2015 at 16:36 point

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.

  Are you sure? yes | no

danjovic wrote 12/08/2015 at 22:11 point

Oh... unleash its voice!! let it click a relay once in a second! After all a clock must tick! Lol!

  Are you sure? yes | no

Yann Guidon / YGDES wrote 12/08/2015 at 22:34 point

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...

  Are you sure? yes | no

Dave Gönner wrote 12/09/2015 at 11:34 point

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.  

  Are you sure? yes | no

danjovic wrote 12/09/2015 at 22:53 point

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 :)

  Are you sure? yes | no

Yann Guidon / YGDES wrote 12/08/2015 at 15:04 point

+1 for relay logic

+1 for Johnson counter/4017

+1 for smart diode decoding of 7 segments dispay

-something for all the operating noise ;-)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates