math mondays

Last week, we created this marble machine binary counter:

 

Each digit of the counter is represented by one of the four traps along the left-hand side of the machine. The reason that the machine counts in binary is that each trap may hold zero balls or one ball, but when a second ball enters a trap, it dumps both of its balls (and one of them carries into the next trap down and to the left). But as you may recall when we introduced the trap a couple of weeks ago, each trap has an adjustment weight that can set how many balls are required for it to dump. So what would happen if we just dialed all of these traps up so that they won’t dump until the third ball?

Well, then, the machine should count in base three, or “ternary.” Each trap could hold 0, 1, or 2 balls, corresponding to the three digits in ternary notation, and then a third ball would cause the trap to dump, making a ball in the next trap count as three balls in the previous trap. There’s just one mechanical issue: now that the trap dumps three balls and we only want one to carry to the next trap, we need a track from the dump of one trap to the entry of the next trap which will pass one out of three balls and send the other two to a receptacle of no-longer-necessary balls.

So can we make such a track out of some of our flip-flops? It turns out we can’t. The essential obstacle is that flip-flops have just two states, so they operate with period two (i.e. they have two actions that cycle over and over again). We want a track that will have period three. And that turns out to be an insurmountable divide; there is no way to connect a collection of period-two devices without feedback so that the resulting overall mechanism operates with period three. (On the other hand, as my colleague Jim Propp points out, it is possible to create a period-three mechanism out of period-two devices as long as the output of some devices can be connected to the input of other devices in series to create a loop of devices. With marble machines, because gravity only goes one way, that kind of loop is only possible with a marble elevator, which would introduce even more complexity than the other options we’re going to consider below.)

So we are going to have to rig up our own component to overcome this obstacle. Now it is possible to create a mechanical marble-powered device that operates with period three, such as the one below created by Jelle Bakker of knikkerbaan.nl. Note the three different openings from the green block; the wire mechanism correspondingly can sit in three different positions, which it cycles among as successive balls arrive.

 

On the other hand, I wanted to find a solution that would require a less ambitious, wholesale fabrication of a novel component; in particular, I was worried about compatibility with the rest of the Chaos Toy system. That desire led to an alternate approach. Rather than using one out of three of the dumped marbles as the carry to the next trap, the idea was to have the dumping of the trap trigger a parallel mechanism which would allow exactly one (new) marble to proceed to the next trap, from some repository of “carry” marbles.

And what is this component which will allow exactly one marble at a time to proceed? It’s something called an escapement, and here’s a Chaos Toy bell component modded to be an escapement. (I did mention this was a project with all the bells and whistles!)

Here’s briefly how it works (since this week’s column is getting long, I will include the gory details of constructing an escapement next week). Although you can’t see it in the above image, in the picture on the left below, showing the view directly into the entry of the escapement, you can see there is a little white stop in the track that only allows one marble at a time to fit inside. When the escapement is triggered and the arm holding that one marble lowers, the yellow tab blocks the incoming track so that no additional marbles can enter the escapement until it resets. And how will we trigger the escapement? By linking it to one of the traps we are using for the place values of the ternary counter, as shown in the left-hand image below.

That way, whenever a third marble reaches the trap, it will dump, causing a single marble to fall from the escapement to the mechanism below (where it will be routed to the trap representing the next greater place value in the counter).

So, to complete the conversion of the binary counter to a ternary counter, all we have to do is adjust each trap to dump when it receives three marbles, not two, and link each one to an escapement that will release one ball to a track that routes it down to the next trap. To see how that goes, here’s a picture of just the lowest level, showing one trap with its escapement for carrying, and a track leading from that escapement, via a ball-drop and catch assembly, down to the highest place-value trap (which doesn’t need an escapement, since when it fills, the machine simply overflows).

Note how both of the traps have their weights dialed farther out, to require three balls to initiate a dump rather than two.

Here’s a brief video showing the trap-escapement combination in action to yield a single carry from the “ones place” to the “threes place”.

And here’s the completed machine counting from one to 27 in ternary. Note that after nine balls and after 18 balls have been deposited, the supply of carry marbles for the ones place needs to be replenished. (Those balls are not “counted” by the machine, they’re just used later as it needs to carry.)

Just to underscore how the ternary counting works, here’s what the machine looks like after 22 marbles have been deposited (with some red labels for clarity).

Correspondingly, the ternary representation of 22 is 211, because 2×9+1×3+1×1 = 22. Note that the ternary counter has a lot more capacity than is used in this video — it can count up to 80 before overflowing. Next time, we’ll see how to make this machine more useful.