Friday, September 6, 2013

Comparator Clock in Minecraft, Explained

So with a very minimal amount of redstone it's possible to make a fast pulsing clock, just by using a comparator in subtract mode (third torch on).  We know it works, but why precisely does it work?  That's what I'm going to cover in this post.

Here is our example circuit.


Let's call the signal coming into the back of the comparator "Signal A", and the signal coming into the side of the comparator "Signal B".

When a comparator is in subtract mode, its output will be the strength of Signal A minus the strength of Signal B.

When the clock is off, Signal A, Signal B, and the comparator's output all have a strength of zero, so the result is plainly obvious: no redstone pulses.  The clock's output is stable.


When the clock is on, Signal A is the full signal strength of 15, and Signal B is zero.  The comparator subtracts zero from 15 and outputs the difference, which is 15.  Two blocks away from the output, Signal B becomes 13.


Signal B is now 13.  The comparator subtracts 13 from 15, and outputs a signal strength of 2.  Signal B once again becomes zero, so the cycle repeats.


This style of clock only works because the comparator has a built-in delay.  This delay is one redstone tick, or a tenth of a second.  The design actually uses this delay as a crucial component, because at any given step of the cycle the output of the comparator is dependent on the previous step's value of Signal B, so the previous value of Signal B needs to stay around just long enough for the comparator to notice.  If it had no delay it would pulse too fast for any other redstone component to even notice that the signal was changing.

When using one such clock, place a repeater somewhere adjacent to the redstone dust that provides Signal B, and then send the signal wherever you need it.

Edit: Notes:
  • In the creation of this post, I used the OptiFine mod and the Faithful 32x32 texture pack.
  • I'm actually flying high above my example redstone in creative mode, and holding the OptiFine Zoom button.  This combined with some cropping in Photoshop takes my obnoxiously large FOV setting out of the equation. (Quake Pro master race)
  • I did forget to turn off particles, which accounts for the bit of redstone that has zero signal having a particle above it.  The clock toggles faster than the particles disappear, the signal is indeed zero there.

No comments:

Post a Comment

I moderate comments because when Blogger originally implemented a spam filter it wouldn't work without comment moderation enabled. So if your comment doesn't show up right away, that would be why.