Mechanical T flip flop counter in Minecraft

My son and I began playing Minecraft together, me on my Windows laptop and him on his iPad. In my opinion, Minecraft is probably the only game in which a parent and child can play together in the same virtual world and both of them enjoy it. Quality time with your child in a video game? Who would have thought?

The game is easy enough for a child to understand and complex enough for an adult to appreciate. In "creative" mode, it's like a giant Lego virtual 3D world in which you can build fantastic structures more easily than with Lego. Then there's "survival" mode, in which you're plunked down in a world with nothing, and you must gather resources, make your own tools, feed yourself, and so on — pulling yourself up by your bootstraps in a world full of both friendly and hostile creatures.

One of the more intriguing features of Minecraft is the redstone circuit capability. You can build moving machines, logic circuits, devices that get triggered from a footfall or tripwire or day-night cycles, and even programmable blocks. A few enterprising souls with way too much time on their hands have actually constructed 8-bit processors in Minecraft, complete with CPU, address and data registers, arithmetic logic unit, memory, and an instruction set. Check out this computer made without command blocks; it seems to sprawl forever in all directions, it's huge.

So I got to thinking about constructing a simple counting contraption, not made with silent non-moving parts, but with noisy moving pistons. A piston in Minecraft is a redstone-powered component that can push (and pull, in the case of sticky pistons) other blocks by one block in displacement.

For a 3-bit counter that counts from 0 to 7 in binary, we need three T flip-flops cascaded together. A T flip-flop (T for "toggle") is a memory circuit that toggles between two output states every time you give it a toggle signal. A simple mechanical example is a push-on, push-off pushbutton switch, each time you push the button the output changes state, and has a "memory" of its most recent state, not changing until you toggle it again. How do I build a flip-flop in Minecraft? And even then, how do I build one out of pistons?

The official Minecraft Wiki has extensive information on redstone circuit components with many examples, including a page on memory circuits that describe flip-flops. Unfortunately, the piston-based ones don't work in the Bedrock edition of Minecraft, because the Bedrock edition lacks a feature called "quasi-connectivity" that exists in the Java edition. So, I had to develop my own.

Consider a relay having an armature with no return spring. Instead, the armature moves by activating one or the other solenoid on either side of it. I haven't ever seen a relay like this, but you can imagine it. Here's a circuit using such a relay in a semi-mechanical T flip-flop design:

Notional T flip-flop

A notional T flip-flop using a relay armature pulled by two different solenoids.

The input pulse is intended to have sufficient power for the relay armature to travel from one contact to the other. The pulse powers the solenoid, pulling the armature to the opposite contact. Of course, the instant this happens, the armature breaks the circuit that's pulling it, so I put a capacitor across the solenoid coil with the idea of keeping the solenoid powered long enough. When the armature makes contact with the opposite side, the whole circuit is set up for toggling back on the next pulse. I have no idea if such a circuit would actually work. This is just a concept that I would implement in Minecraft.

A pulse is needed because a continuous input would result in the whole device oscillating between states. Here's how a pulse might be realized from a continuous input using a relay:

A pulse generator using a relay.

This is also called an "edge detector". The input signal is seen briefly on the output before the contact is broken, thereby converting the input to a pulse. Imagine that circuit plugged into the "pulse" space in the first figure.

So let's see how we'do that using redstone circuits in Minecraft. The pulse circuit is easy:

A pulse generator, creating a short pulse (right) from a longer input signal (left).

I'm using the Minecraft Wiki's convention of showing movable blocks as diamond (blue), and stationary blocks as gold. That device is 6 blocks wide, but only three of them (the second, third, and fourth blocks) make up the pulse generator. The first block is the signal switch (ON or OFF), and the 5th and 6th blocks show an output line going to a redstone lamp, to visualize the pulse. As for the actual pulse generator:

  • The second block uses a line of redstone dust to conduct the signal into the third block.
  • The third block consists of a diamond block sitting atop a sticky piston with the piston pointed upward. A block can conduct a signal — very weakly — across it, enough to power a repeater but not much else.
  • The fourth block is a redstone repeater, which restores the weak signal to full strength. When the piston moves, the diamond block moves, breaking the circuit, resulting in a short pulse at the output of the repeater.

That dual-pulling relay in the first figure is basically an S-R (set-reset) latch, in which you can store a memory bit by putting a "set" signal on one solenoid, and clear it by putting a "reset" signal on the other solenoid. In Minecraft, the analogous circuit would be a dual-pushing pair of non-sticky pistons, pushing a redstone block (a power source) back and forth as you apply a "set" or "reset" signal:

Flipping the "set" switch on the left moves the redstone block to the right, while flipping the "reset" switch on the right moves the redstone block back to the left.

Given these components, I can put together a T flip-flop based on pistons. Here's a schematic I made on the Minecraft Wiki. Because the whole thing is two blocks high (due to the pulse generator and a couple of redstone dust conductors I had to add) it is shown as two levels:

Piston T flip-flop

Level 0 (underground, left) and level 1 (ground level) layers of a piston-based T flip-flop.

Here it is working:

A working piston-based T flip-flop.

To keep me from having to toggle it manually, I'll make a clock circuit out of a sticky piston, a redstone block to create the clock signal, and four repeaters set to maximum delay that loop back around from the redstone block to the piston....

A piston+repeater clock circuit.

...and then, using the clock circuit as the input to the T flip-flop, and adding a redstone torch at the output (it displays the negation of its input signal), we get a device that flashes on and off at half the rate of the clock signal:

The clocked T flip-flop with output signal (torch at the right).

And finally, to get a counting circuit, I just have to string the T flip-flops together, connecting the output of one to the input of the next. Here is a 3-bit counter, which counts in binary from 0 to 7 (look at the torches, with the least significant bit on the right).

Minecraft redstone circuit 3-bit counter, shown at night, the better to see the output torches.

Voila!

Comments

  1. Looks cool! Add some AND's and NOT's and you will have a traffic light!

    ReplyDelete

Post a Comment

Popular posts from this blog

Syncing Office 365 Outlook to Google calendar using Power Automate

New approach to screw threads in OpenSCAD

The water rocket: Thrust from water