PC In-depth guide for how to make sequential logic circuits with faulty logic gates

JereTheJuggler

Spazmatism
Introduction
Ok, this is a guide to help with figuring out how to achieve many possible desired outcomes that can be achieved through counting in some way. This is something I figured out while messing around making a wire-intensive-contraption filled adventure map (which is still in the works). This circuit is easy to modify to achieve different results from using it, and it can have many applications, such as...
  • Creating a counter that can be both incremented and decremented
  • Reducing any number of activations into the circuit to a single pulse coming out of the circuit
  • Converting base 10 to any other base
  • Making an N-second timer that can be interrupted and reset with a single pulse
The Basic Principle
This circuit is constructed by following a pattern of faulty logic lamps that create a chain of any length and connecting all of their inputs to a single input source for the entire circuit. At any given time in this circuit, there is one faulty gate that is on and the rest of them are off, and with each activation of the circuit the on gate moves down the line one step.

Building the most basic circuit
Step 1:
First thing you have to do is decide how many inputs you want required for a single output, and then you must decide whether you want activation to go from left to right or vice versa.
Throughout this tutorial we will be making a circuit going from left to right that makes it so you flip a switch 7 times in order to turn a torch on/off as an example.

Step 2:
However many activations you want your circuit to require, you make that number of faulty logic gates at the same height with a gap between them. If you want activation to go from left to right, then the leftmost gate is the only one on, otherwise the rightmost gate is the only one on.
cWt2wds.png

Step 3:
Make a wire connecting the inputs for all of the gates that goes to the input source for your circuit (switch, timer, pressure plate, etc.)
drVnGal.png

Step 4:
For each gate except the one on the opposite side of your starting gate, connect them using two colors that aren't the same as in step 3 in an alternating pattern so that you go from the gate's output, through its lamp, and into the next gate's lamp.
6In5TQq.png

Step 5:
Using the last color of wire you haven't used yet, make a wire that goes from the last gate's output, through its lamp, and over the top of the circuit to loop around and connect to the first gate's lamp.
I3RW3B7.png

Step 6:
Make a wire branching off the one you made in the last step going to your output (trap, torch, teleporter, conveyor belt, etc.)
mEMeNFU.png

And then you're done!
Completed basic circuit
ANoHMtz.png
As you can see in the gif, every 5 times the switch is flipped, the torch is turned on/off.

But what about all the different uses I listed for it? Well, a lot of the uses require some modifications to this circuit. Before I start telling you how to modify it exactly, I'd like to establish some basic terminology to describe these circuits.

Terminology
Period
The number of gates that the circuit cycles through.
Multiple Output vs. Single Output

If a circuit just has one output that happens once every cycle, then it is single output. If a circuit has a different output for each input, then it is multiple output.
Looping vs. Terminating

If the circuit doesn't reset itself after it's final output allowing for it to be gone through again, then it is terminating. If the circuit works like the one in the gif above where you can repeat the process any number of times, then it is looping.
Step Reset vs. Instant Reset

In the more advanced modifications to the circuit, there will be a second input that can be used to reverse progress in the circuit. If that input causes all progress to be lost at once resulting in the circuit going back to it's starting state, it is instant reset. If the second input causes just one activation to be undone, then it is step reset.

Modifying the Circuit

A multiple-output circuit
The most simplistic variation is to make the circuit so that instead of having one output every certain amount of inputs you have a different output that occurs with each input. This can be helpful if you want to make a gauge using torches that "fills up" with every input to the circuit.

This can be achieved by making wires come off of the ones that are the outputs for the faulty gates. If you don't want to have any output on say the 4th input then just don't make a wire coming out of the 4th gate!

iU46Jyb.png
And just for fun, I decided to make a version with a rapid input from a hoiking target dummy
A terminating circuit
Another extremely simple variation is to make it so once the circuit completes one cycle it doesn't get reset back to it's starting state. This can be achieved by just removing the wire that comes out of your final gate connecting to the first gate's lamp.
Hkgk0q3.png
As you can see in the gif, after one cycle through the circuit is completed no more input will have an effect on it.
A terminating circuit with an instant reset input
Ok, now for the fun stuff, circuits with two inputs. The most basic circuit with two inputs can be made by altering a terminating simple circuit. This can be useful if (yet again) you are trying to make a gauge with torches lighting up to show progress. With this setup, once the gauge is filled, it can't continue filling (which would actually be wrapping around and turning off all the torches again), but it can also be reset at any time.

You start by adding a second line of faulty logic gates. All of them off and there is one for each member of the first set of gates. Like the first set, you connect the inputs for all the gates to whatever you want to trigger a reset (red switch in this case). Next step is to make a wire coming from each of the first set of gates' outputs that goes through their corresponding reset gate's lamp and into the output.
PpEv569.png
In the gif, you can see that as I flip the green input switch, the circuit advances until it has completed a full cycle and then never again until the reset switch is flipped. I didn't show it, but the reset switch could be flipped at any time to revert the circuit back to it's starting state.
A terminating circuit with a step reset input
This version is almost the same as the last one with one tiny adjustment so that instead of completely resetting the circuit with the reset switch, it only undoes the actions of the previous input. This would be useful if you want to make a counter that you can increment and decrement.

To make this modification, you just need to add one wire to all the reset gates so that they trigger the lamp of the gate in the opposite direction of the circuit's flow.
U5VPLlR.png
This gif shows that the input still progresses the circuit one step each time until the cycle is completed, but when the reset switch is flipped, it only undoes one activation instead of completely returning the circuit to its starting state.
A looping single-output circuit with an instant reset input
This circuit can be useful if you want to make an N-Second timer (where N is the period of the circuit multiplied by the timer's original duration) that can be interrupted and reset.
The trick with this is that whatever period you want the circuit to be, you start off with a terminating single-output circuit with an instant reset input with a period of one less than that. You then make another faulty gate for the top row, but do not make it a partner for the second row. Extend the circuit's input wire to include the new gate. Remove the wiring for the gate that was last in the base circuit and replace it with the appropriate color to continue the pattern, but don't have it lead to your circuit's output. Instead, it should lead to the lamp in the new gate. Now with that last color back to being unused again, make a wire coming from the new gate's output that goes into all the inputs for the reset gates. Make a wire branching off of the wire you just made to your circuit's output.
vvkCuHD.png
The gif shows that the circuit loops as you would expect, but the reset switch doesn't ever undo the completion of a loop, which would result in changing the final output. Instead, it cancels the current cycle the circuit is going through, resetting it back to its original state.

A word of warning if you try to make this a multiple output circuit. The way it works is that the output of the base circuit is basically another reset switch for it. If you just branch off the gate outputs then it will always be as if you complete one cycle and then immediately hit the reset on the base circuit.
Applications With Multiple Circuits
An N-second timer that uses multiple looping single-output circuits with an instant reset switch
Ok, so with a single one of ^those^ circuits, the period would be multiplied by the timer's original duration to get how long it would take for the whole circuit to fire. But what if that circuit fired into another one of those circuits? Long story short, you can achieve longer duration timers while saving space and resources if you have more than one circuit. For example, let's say you have a 1 second timer. you feed that through one of those circuits with a period of 4 to make the equivalent of a 4 second timer. You take your "4 second timer" and have that input to a copy of the same circuit and you now have a 16 second timer. To accomplish this feat with one circuit, you'd have to use 31 gates (16 for the period with a reset gate for all but the last one), while the two 4 period circuits only use 7 gates each.

So enough with all these words, let's see how to set it up and see it in action. As you can see below, setting it up is exactly as simple as it sounds. You just make more of the same type of circuit (same period isn't necessary) and use the output from the previous circuits as the input for the next circuits. All you have to do after that is connect all the circuits' reset wires together so that they're all reset from the same input.

I went a little further than in my example above and made 3 circuits each with a period of 3 with a 1 second timer as the input. the first circuit's duration is 1x3, so 3 seconds. That feeds into the second circuit so it's duration is 3x3, so 9 seconds. That again feeds into the final circuit, so the total duration is 9x3, so 27 seconds.

These 3 circuits use only 5 gates each, bringing the total to 15 gates for a 27 second timer, whereas the same feat with one circuit would use 53 gates.
a1unNtx.png
In this gif you can see that it takes 27 seconds for it to get back to it's starting state the first time because I did not interfere with it, and chat was off-screen, but the announcement box said "27 seconds passed without a reset!". The second time it starts going, I hit the reset switch midway through, resetting the timer back to 0.
Converting from base 10 to any other base
Some of you might have noticed something interesting going on with my timer in the previous application, and that's that I basically made a converter to base 3, although it would've made more sense if everything was flipped though so lower place values are to the right.

In the starting state, the three circuits can be imagined as displaying 000, and then after the first second they would read 001, and then 002, and then the second circuit is finally triggered and the first is reset, making it display 010. You can continue this trend until all three circuits are 1 activation away from being reset, and at that point they would read 222, which is the highest number you can represent with 3 ternary digits.

You can do this with any base, because the period of all the timers (they have to be the same) is the base you're converting to.

Conclusion
If anyone is still reading at this point, I'd like to say thanks, and I hope you're leaving with some useful information! These circuits have been extremely helpful for achieving desired effects in the adventure map I'm working on!
 
Last edited:
This is a really nicely made guide, with a glossy feel to it, even. Thank you for contributing it.:)

That title though... I'm not sure it could be more vague, heh.:p But seriously, I think you should probably rename this, for clarity and search purposes. Including some key words would be useful, even if they don't encompass the scope of your work fully: "Faulty logic gates"? "Base-N counters", which is the main gist of what you have here - resetting, declinating and chaining them.

I've also tended to call them linear/sequential counters (as opposed to binary), since they are awkward, being properly named depending upon the number of states they have (10 being a decade counter, 3 a tertiary counter, or whatever). N x period timers. Or frequency division by N (and so related to these gate designs). They are also essentially "shift registers", in terms of the on-lamp being shuffled up (or backwards), if not it's output pattern (e.g. the torches, which come on in sequence, not shifting).

These circuits have been extremely helpful for achieving desired effects in the adventure map I'm working on!
I think that grounded examples are always good to include in guides, where possible, for inspiration but also understanding, to help the meaning of the mechanisms sink in.

In @Baih and Noel's (@Kieda) adventure map, your faulty lamp incrementers were used in multiple places. For example, keeping score in the shooting game, so as to output to the appropriate announcement box number. That uses a dart based reset to chase the count state (fairly) rapidly off the end.
It is slightly more reliable to use logic gates in a counter:
img

img

Every time the yellow wire at the top is activated, it sends a signal to all the logic gates, which are faulty. Faulty logic gates send a signal if the lamps are on and not if they are off. So if they are all sent a signal, only the logic gate with a lamp on will then send a signal. It will turn itself off and turn the lamp on for the next logic gate, so it increases by one every time a signal is sent.
Also, for cycling the actuation states of the spikes in the "scientist's lair", to make them into a deadly, moving obstruction to negotiate:
Rotating Spikes
Spikes actuate in rotation, so the player must go through the path of the spikes while they are inactive:
index.php

There's a lot of wiring here, there are 2 sections of rotating spikes. Each one is on a timer, the timer goes through a counter, the counter connected to different segments of the spikes. That's all the logic it to it really, counters are mentioned at the start of the thread on how they work. Otherwise all the wiring is connecting each part of the counters to parts of the spikes.

Finally, for tracking the health of the mechanical boss (as you chunk it down with head shots). Also capable of resetting, same as above.
The green wire also sends a signal to a counter, a series of faulty logic gates:
img

There is one activate faulty logic gate indicating the position of the counter, every time a signal is sent the active faulty logic lamp will turn the next one on and itself off. At 25% intervals the counter will send a message indicating the boss is at 25/50/75 % health. Once the counter reaches the end, it activates an explosive inside the boss, destroying it, turns of the timer stopping the attacks, and opens up a path to the ending of the map.
And one of your 2-way (or "step reset") mechanisms could have been used in place of Baih's spear engine, in the power meter.

Any different applications that I've not mentioned (adventure map, or otherwise)?
 
Last edited:
I think that grounded examples are always good to include in guides, where possible, for inspiration but also understanding, to help the meaning of the mechanisms sink in.
My map is very much a work in progress at this point. I'm still working towards making my creations actually presentable, because believe me, once they are I will be showing them off in posts here.
I have refrained from playing Baih's map and looking at their posts as to not have them influence my own work. I already have to fear people just immediately writing my map off as a copy of their map purely because they had early access and released it before it was even possible for me to really start conceptualizing about mine, and the less I let them influence me the more original I can be.
Any different applications that I've not mentioned (adventure map, or otherwise)?
Well, one other use that I've made in my map is a sort of password lock. If you have a looping circuit that only goes one way, you can loop through all the states and shortcut it so that all the circuits in your password (one for each character) feed into an AND gate and once the correct number input is reached then it turns on a lamp, and the input immediately after that turns it off.

If you have a circuit with a period of 10 then you essentially have one fourth of a typical 4 digit passcode lock.
 
I agree the title should be more descriptive. I would go with "Guide to sequential logic circuits"

Sequential circuits also have a near limitless number of applications @ZeroGravitas . Some more use cases I can think of would be: the program counter in a CPU could be created with just a transistor based sequential circuit. We also used this setup when building the data serialization module in the other thread. Any time your output needs to be dependent on not only the input, but the past outputs, then this is useful. Aka when your circuit needs memory.
 
My map is very much a work in progress at this point. [...] I will be showing them off in posts here.
Yay! More awesome maps to come, with more great, inventive mechanism uses tucked inside, for us to look at. :D
I have refrained from playing Baih's map and looking at their posts as to not have them influence my own work.
WoooOps! Sorry. I hope I've not 'spoiled' you too much there then :( I hope that connecting the examples to the concept might still be helpful for some (although, a bit late to the party). I can imagine that it's pretty stressful having such a large amount of work all riding on the chance of being marred by incidental similarities. There's all kinds of examples of such things, from parallel discoveries in science and inventions, to movies that were accidentally very similar. When I've made videos, I've tried to look around to avoid covering information that's been shown (a lot) before, but with a more creative process. I guess it would be harder to be sure of not being distracted or influenced unwittingly (like, I can't imagine how musicians ever manage to create totally new tunes, if I tried I'd just come out with some big tune or other, at best). Still, all you map builders are pure enthusiasts, in it for the 'right' reasons, with no money at stake (as yet). Only priceless pride.:naughty: Heh.

the data serialization module in the other thread
Looks really exciting (been meaning to reply to that): http://forums.terraria.org/index.php?threads/serializing-data-save-wire-space-and-nerves.43886/
So this sequential circuit is used in both the encoder and decoder circuits?

So, yeah, circuit is also used for all manner of computing type applications. A great little concept. :)
 
Back
Top Bottom