## Building a Computer 101: Wandel’s Toggle

I’ve been wondering how I am going to move my kids from thinking about how this marble adder works to thinking about how a computer’s CPU works.  Most of that I think I’m going to have to play by ear, but we took at least a small step in the right direction when my nine-year-old spontaneously asked how we will make a subtractor, a multiplier and a divider after we have our adder made.  I told him that he should think about that, which he has been doing–more on his ideas in some future post.  I also gave him a couple of ideas.  One of those was that maybe we should consider how we might represent negative numbers in our machine–more on that in a future post also.  The second idea was that we needed a way to draw simplified representations of the components of the adder.  It does get cumbersome to draw all of the little details each time.  This is perhaps an idea that I should have let him come up with himself.  I’m still not sure whether he sees the real value of it.  In any case I got him drawing the Wandel’s toggle mechanism as  a little box and he has been working with combining the little boxes in different ways to try to come up with a subtractor.

As I mentioned above, I’ll talk about his designs at a later date.  In this post I want to talk about the logic of Wandel’s toggle.  It’s very simple but effective.  I think there are a couple key ideas that it incorporates that will be key parts of any marble computer that is eventually made.  Here is what it looks like (and this is Wandel’s photo. I don’t have anything nearly this nice yet.)

And here is my schematic drawing of itThere is one input, labeled i.  There are two outputs 01 and 02.  The input i is where a marble can come in.  The outputs are the two places a marble can come out.  The toggle also has an internal state.  It can either be rocked to the left, or it can be rocked to the right and have a marble caught in its little semi-circular trap (as shown in the photo above).  In normal operation of the adder, whenever it is rocked to the right it will have a marble caught in the trap.  What about that r coming in on the side?  Well, that’s not a place for a marble to come in.  I’ll get to the r in a second.

We can represent the operation of the toggle with the following table

```i|s1|s2|o1|o2
-+--+--+--+--
0|0 |0 |0 |0
0|1 |1 |0 |0
1|0 |1 |0 |0
1|1 |0 |1 |1
```

Line one of the table says that if you input no marble (i=0) and the machine is in state zero (that is, it is not storing a marble, or s1=0) then the machine remains in state zero (still no marble stored, or s2=0) and you get nothing from either output (o1=o2=0). Line two of the table covers the case when no marble is input, but there is already a marble stored. OK, so these first two lines of the table are pretty boring. If you don’t put a marble in then nothing changes is what they say. Lines three and four cover the cases where a marble *is* input. In both cases the internal state of the machine changes. Either it goes from storing no marble (s1=0) to storing a marble (s2=1) or from storing a marble (s1=1) to not storing one (s2=0). Only in the case where you put a marble in and it was already storing one do you get any marbles of output (and in that case you get one marble from each output).

Now we come to that mysterious r. You see, there is something else that can happen. At the end of the computation there is a little slide you can hit at the bottom of the machine. When you do this all of the marbles are cleared from their trapped positions and they fall to the bottom. So that’s what my r is. It’s the reset condition. Here is my table to represent it

```     |s1|s2|o1|o2
-----+--+--+--+--
RESET|0 |0 |0 |0
RESET|1 |0 |0 |1
```

The table just says that the reset condition always puts the machine back to the zero state, and sends any internally stored marble through output two.

This reset condition seems innocuous enough, but I think that it is one of the major achievements of the Wandel toggle. Here is one reason why: some have claimed that it is impossible to get an inverter gate in a marble logic circuit (see one of the comments near the bottom of the replies to this video) what you need to get logic gates to work reliably is a clock. This is true for electronic computers also, everything runs on a clock. The reset input could be used as a clock in a marble computer. More on this in a future post.