A digital 24 hour clock using only relays and diodes for the counting logic.
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...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,...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.