A digital 24 hour clock using only relays and diodes for the counting logic.
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:
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 in series to produce the AND function....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:
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.