Geek Pocket Minecraft - Web Site Smaller Banner    The Counter Project

For this project, I wanted to create a 4-bit counter, one that can count up to 15 input pulses (0-15) and output the count in binary format using redstone lamps. The needed sub-circuits are: The first phase of this project, "Torch Only," was completed in December 2015 with Minecraft PE 0.13.1, before repeater blocks and data latches were added. The second phase was completed in February 2016 leveraging these new things.


Perfect Toggle (T) Latch, Torch-Only Version:

On my latches page, I showed how an imperfect toggle (T) latch could be constructed from an RS latch and a multiplexer. Before assembling the full counter, we need a perfect toggle latch - one that will work correctly regardless of how long or short the trigger line is ON.

I figured out how to do this by using two imperfect toggle latches put together. The wires are crossed, so instead of the RS latch output re-feeding the same side (and causing a "race" condition), it instead feeds the OPPOSITE side (the inactive side). When the trigger is turned OFF, the opposite side is triggered ON, and that RS latch feeds the original side.

This behavior is illustrated in the following four screenshots:

Torch-only perfect toggle latch, state 0 Torch-only perfect toggle latch, state 1

Torch-only perfect toggle latch, state 2 Torch-only perfect toggle latch, state 3

Here's the simplified schematic for this circuit:

Torch-only perfect toggle latch, simplified schematic

Came here from YouTube and are wondering what the Bs and Ts are? Those are inverters; click here for explanation.

It looks like I accidentally made it so the output redstone lamp toggles on an ON-to-OFF transition of the main trigger (instead of OFF-to-ON), but for the clock project it doesn't matter, and it's also easily changed (either change the output to the other latch OR change the location of the inverter at the bottom of the main trigger's "bridge").

Putting It All Together:

With the perfect toggle latch complete, the next step was to duplicate it 3 times. To keep the counter from sprawling out all over the place, I decided to place each one in a separate vertical layer. Also to simplify things each layer is identical. This screenshot shows the spacing between layers as well as an easy way to duplicate layers one or two "rows" at a time:

How to easily make copies of the redstone toggle latch circuit

Next I added staircases to propagate the output of each toggle latch to the next one above. The latch input is at the front so I pulled a signal with an identical state from the near-left of the layer. A couple of inverters were cleverly incorporated into the staircase to repeat the signal due to the long distance involved.

Torch-only 4-bit redstone counter, view of the four toggle latches

Finally, the clock (pulser) was added. I first tried a standard 5 clock. Despite the "perfect" nature of the toggle latch, apparently the propagation delays through the circuit are long enough that the clock is already sending the next pulse by the time the signals are returing from the back due to the previous pulse. As a result, Minecraft went berzerk and all my torches kept flashing on and off. I had to tear up parts of the circuit and rebuild it (not to mention exit and re-enter the game twice) before the torch freak-out finally stopped. I'm guessing this is a game bug. Anyway, the latch worked just fine with a 9 clock attached. I then had to up it to a 13 clock because of propagation delays through all the layers; otherwise, the bottom layer would change state for the next pulse before the top layer was finished updating! The 13 clock seemed to be the smallest clock that would work and still have the outputs correct for at least a half second.

View of 13 clock used to drive 4 bit redstone counter

Check out the video to see the counter in action.

Here's a sample view from the back showing the four outputs. The counter counts from 0000 to 1111 in binary (0 to 15). The screenshot is showing a value of 6. The video above all 16 states are shown and labeled.

Torch-only 4-bit redstone counter, view of outputs


I wonder if the designers of Minecraft came up with this complex redstone circuit design on purpose OR if they were merely trying to implement some simple switches and traps, and people figured out you could build larger circuits. In any case, people are always pushing the boundaries of Minecraft and cleverly coming up with new things to do way beyond what the designers ever thought of. This is what makes Minecraft such an amazing game!


Perfect Toggle (T) Latch, Data Latches Version:

In Minecraft PE 0.14.0, repeater blocks were added. As discussed on my inverter page, these help make much more compact circuits, but, aside from the ability to adjust timing, don't actually add new functionality. However, if you put two inverters together like this, with one pointed at the side of the other, you get a totally new device called a Data Latch:

Repeater-based data latch, locked state Repeater-based data latch, data load state

If the switch on the left is in the "lock" position, the data latch outputs whatever value (ON or OFF) that was previously loaded into it (in this case ON). If the switch on the left is in the "load" position, it loads the value from the data line (and outputs it also, in this case OFF).

An equivalent way to think of it is like this: The image on the right is like a normal repeater (OFF goes in, OFF goes out). If power comes in off of the side from another repeater (and only from another repeater), the first repeater is locked to whatever output it had at the time it was locked (in this case ON).

Using two data latches instead of two RS latches, it's possible to make a totally redesigned toggle latch that is amazingly smaller, faster, and simpler. But it works exactly the same as the original perfect toggle latch. Here are the four states:

Perfect toggle latch using repeater-based data latches, state 0 Perfect toggle latch using repeater-based data latches, state 1

Perfect toggle latch using repeater-based data latches, state 2 Perfect toggle latch using repeater-based data latches, state 3

The simplified schematic for this circuit is below. Note that the repeater in the lower-left gets its power, interestingly, from the anchor of the inverter, so it receives a "positive" (non-inverted) signal whereas the repeater just above it gets the usual inverted signal from the redstone torch.

Perfect toggle latch using repeater-based data latches, simplified schematic

Just as we had two RS latches loop back to each other to make the perfect toggle latch, so we are using two data latches looped back to each other here. But there's an equivalent, even easier way to interpret the above circuit. Notice in the last screenshot above the schematic, the area in the light blue box looks just like a compact 5-clock. If you think about it, a toggle latch is similar to a 5-clock in that the output goes ON, OFF, ON, OFF, ON, OFF. We merely need to control this pattern so it goes ON, OFF when WE want it to, not automatically. So the data latches in effect "pause" the clock. Each time the input line changes state, the repeater that is locked alternates. Every OTHER cycle, the new state of the clock leaks through.

With the much smaller latch, it's really easy to string four together, add a clock, and be done:

4-bit counter using data latches + 13 clock, full view

Check out the following video to see the revised 4-bit counter in action:

There's still some slight propagation delays, but it's still much faster than the previous counter. It's also small enough to be practical in a full Minecraft PE game, though you'll still need a fairly large basement or warehouse for the circuiting.

This page last updated 02/27/2016. Web site content (C) 2015,16 Kevin Jay North. Free for personal use; do not copy to other websites without permission.
The Minecraft Pocket Edition game itself is owned, sold and distributed by Mojang. Builder Buddies is owned, sold and distributed by Robledo Software, LLC. This web site is not affiliated with Mojang or Robledo.