Milestone : 1 Bit ALU prototype

2014-12-15 15.57.41It’s been a really long time since I did any work on my Relay Computer (older posts here). In fact, it’s been almost 2 years. For whatever reason I finally got inspired again and I got back to work. The next step was to start laying out the actual schematic for the ALU. So I chose a PCB manufacturer pretty much at random and downloaded their toolkit and started building out the schematic.

My vision is to have 4 identical boards each filled with an identical copy of the 1 Bit ALU. Once they are all wired together I will then have the 4bit ALU module which will be the heart of my Relay Computer. So I needed to come up with a design for the PCB. Step one in the PCB creation process is to have an actual schematic mapped out with all the connections between all the components that will be on the board. In my case the only component is the relay I chose so setting up the software was pretty easy. I just had to draw out one relay component and then start wiring them all up and placing them in an organized layout. 2014-12-13 14.16.43The schematic took up 5 pages. Here they are if you’re curious : ALU-a ALU-b ALU-c ALU-d ALU-e  .

Next up, I needed to make sure my schematic was good so I had to whip out the breadboard and start building the circuit. It was surprisingly easy work and there were only a couple of bugs in the schematic (very minor ones and they aren’t reflected in the PDFs above).2014-12-13 14.43.44 Here are a few pics of the building as it was progressing along. 2014-12-13 14.49.292014-12-13 17.32.092014-12-13 18.16.23-1
2014-12-15 15.57.36
2014-12-15 18.31.47-2


Next I needed to wire up some simple switches and an LED array for the output and then I needed to test it all out. Once I was done I made a little video for you all to see. Until next time!

Coding and Relays

So if you’ve been following along you know I completed a prototype for the 4×1 multiplexer. This was done on a breadboard and there was no thought put into compactness. I just wanted to see if it worked.

But compactness is a requirement of the actual design. I want to make sure that for each bit of the ALU (one bit per board) the overall connection distance between all the relays is minimized.  If you saw any of the prototype videos you’d notice that there are a lot of wires connecting things and the wires go everywhere. I want to minimize that mess.

The final location of the multiplexer was arbitrarily decided by me to be on the right side of the board and fit in 2 columns of 10 relays each. On the left side of the board would be the adder and the gates (another 2 columns of 10). But that’s it. That’s all I came up with. I figured the placement of the relays would simply show itself as I played around. So it was time to start playing with the actual location of the multiplexer relays.

I spent about 2 hours drawing up ideas and started to get really frustrated. Sometimes I’d come up with something but there would be one wire that had to jump over a bunch or relays to make a connection. If I moved that one, then another long connection crept up. Moving again, same problem. There’s 20 interconnecting parts here that could be swapped around and rotated. It was also a factor that for some pins of the relay I was using I could connect to one side or another. How to optimize that?

Finally I thought of something : “hey! I’m a software engineer, this could be done with a computer!”. So I decided to start writing a program to help solve my problem. But then I started to think that with 20 relays and rotation and pins on either side that the number of possible combinations was in the billions (or more). So I needed some algorithmic solution of some kind.

Should I do research? Well, I did ask a friend for his ideas but it’s a really hard problem once you really start getting down into the details and he was too busy to get into it too deeply.  I looked in a few books and checked the web but finally I gave up and started plugging away. After about 30-40 hours of coding I came up with something that works pretty good. It could be a lot better but for now I’m happy with it.

How does it work? I’ll explain maybe later but a simple overview is :

I came up with a metric to keep track of progress. I called it totalDistance and it was simply the sum of the distances of all the connections in the circuit. A connection distance is calculated by the following : Each relay can have connections on its right or its left side. The connection distances based on the 4 possible horizontal connections between 2 relays (call the left one 1 and the right one 2) there are 4 connections : 1L->2L (distance 1), 1R->2L (distance 0), 1L->2R (distance 2),1R->2R (distance 1) . From there I would also add 1 for each vertical space apart they were and 1 for each horizontal space they were apart.

Once I had the metric in place I could try different things. I first tried randomly placing and rotating relays, keeping track of the best ones. Then I came up with a way to swap relays around, then I came up with a way to rotate them, etc. All the while keeping track of my totalDistance.

To give you an idea, I started with a tD of about 85. After having my current code running for a day or so I got it down to 15.

Here is the output of the 15 version.

Note that there is a small bug in the program that I need to fix where the graphical output of connections on the left side of the relays have their arrows backwards but the locations and rotations (the ones with I are inverted/rotated) are correct.

This is a java program and if you want to play with it yourself I hosted it on github here.  (note you will need another project of mine as well).

Maybe if you really are curious I can build an executable but for now you non techies will have to be happy just browsing the code..


Next Phase in my relay project

I built another prototype component of my Relay Computer. It’s a 4 input multiplexor and it will be used to determine what function our ALU will complete (AND, OR, XOR, Adder). Made a video in 2 parts for you to enjoy. Next part is a software project where I will try to write some code to determine the optimum placement of the relays in the final build.

part 1

part 2

Fail Fail Fail

Duh. I’m such an idiot. I should not be allowed be called an engineer at all. So In my haste to find the cheapest relay I forgot that I needed one with all 5 pins. See, a relay works by using a magnet to pull a switch. The magnet is powered by 2 of the pins, the input to the switch by one pin and the switch points are the other 2 pins. The relays I bought only have a pin for the ‘on’ contact of the switch.

To make an XOR gate and an inverter my design calls for relays that have connections of the ‘off’ contact of the switch as well. Luckily most of the gates in our design are not XORs or inverters so all is not totally lost but I will still need to use 2 different kinds of relays which will not look cool at all. I’m going to have to try to find 5 pin relays that look and act exactly the same.

Small Problem?

So the old adage is this “Measure twice, cut once”. In my haste to choose the relay we will use for the project I somehow didn’t test it enough before I jumped in and bought $100 worth of them. There’s this small problem in that one of the pins of the relay is not placed correctly to fit into a standard PC Board or Breadboard.

Also, I really should have tested soldering and connecting them up to each other before ordering a whole bunch. That part I haven’t done yet.

To know that this will work I’ll need to solder a few of them into a PC Board and find some suitable wire to connect them and see if I can attach that to my solder points as well. The final board will be etched so there won’t be any wired connections, but still, I should have tested that!

A Brick of Relays

What you see here is what I’m calling a ‘brick’ of relays. I was so excited when this arrived. My nice heavy, dense, bad ass box of relays. This is just a small number of the total we’ll need to do the whole computer but it is enough for the first part which is the prototype of one of the bits of the ALU.

I bought 100 since that got me the best discount but even at $0.85 each, that’s still some money! But now things feel more real and less theoretical. This is certainly a motivator to get moving forward on actually building something.

I plan to put a bunch of them together to build a one bit adder next. This will show me that this is possible and also we can measure the current drops (if any) as we move along the circuit.