So here you are. You've read my other tutorial on redstone. Maybe you've even gone on with the diagrams posted at the end to make some simple contraptions. So, if you already know how to do that, then why am I writing this followup?
The point of this tutorial is several-fold. It will give you practical advice on building with redstone. It will formalize a few concepts, like synchronized memory banks and the like. Finally, and most importantly, it will show how the mechanics of redstone can be built up into new, more generalized, more useful mechanics, which can in turn be built up ad infinitum.
Caveats
Hopefully you have read my past tutorial. If you haven't, please read it here. At least skim it, as I will NOT recapping anything from it. I will assume you know how to make a wire travel indefinitely upwards, or extend a wire past 15 blocks.
Philosophy
This tutorial is not meant for someone who simply wants to know how to do 'x'. I will not hand you a diagram of a double door with a lockout switch and say that you're done, because if you'd rather have the schematic handed to you than this isn't the tutorial for you. I'm certainly not averse to providing schematics (I give them out to people all the time, just throw me a PM). However, it's much more enlightening- and fun- to try and make the schematic yourself before asking someone else for it, and then after that study the schematic they gave to see how they did it.
Uses of logic gates in Minecraft, and why they will be ignored
There's quite a bit of outcry about redstone being useless. I completely disagree. You can use it to control minecarts, set off TNT, turn on lights, open doors, etc. A bit of creativity will bring you far in figuring out ways to use this. I don't particularly wish to partake in further discussion about how useful redstone is, so please keep it out of this thread. Thanks.
A Final Note
-------------------------------------------------------------------
Logic Gates What are logic gates?
Logic gates are the simplest form of redstone construction in Minecraft. A single wire is a logic gate (a non-I/O isolated OR gate). A torch on a block is a logic gate (NOT gate).
What are they used for?
Whenever you need to change a signal in any way, you need to use a logic gate. The only time you don't is when you have one direct action.
For instance, consider the simple action of pulling a lever. If you simply wanted that to open a door, then you would not need any logic gates. Pulled lever = open door. However, the minute you want to add an "extra condition" in there, you need logic gates. For instance, pulled lever1 OR pulled lever2 = open door would need an OR gate.
Logic Gate Theory
In the real world, logic gates are built out of transistors. Since transistors start to dive into physics some, I won't go into them here. However, we do need a way to build all the different gates in Minecraft. In fact, I hear someone shouting in their monitor now "Rotten, if you can only build OR's and NOT's, how do you build an 'XOR'???"
Well, again in the real world, they don't actually build everything out of transistors. It's much simpler (economy of scale-wise) to put all transistors into making what is known as the NAND gate. Why? Because NAND gates can be used to build every other type of gate. This isn't very useful to us, though, as we don't have AND gates to building out NAND gate from (NAND- NOT AND- A NOT gate and an AND gate). However, there's another gate like the NAND. What is it? The NOR gate. And we have what it takes to build NOR gates (NOTS and ORS), so we can use them to build every other type of gate (and a few other things besides).
List of Logic Gates
I will list the 7 commonly acknowledged logic gates here. The diagrams I post will, in most cases, be the version that takes the least ticks to complete its computation, as this is generally the most useful version. For other versions, visit the Minecraft Wiki's page on logic gates, which has several designs for each gate, optimized for each factor.
NOT
The simplest (input-isolated) gate to build in minecraft. It has one input, and reverses (inverts) that input.
NOR
An expansion of the NOT gate, that takes two inputs. It is only on when all the inputs are off.
OR
The OR gate is on when A OR B is on.
AND
The AND gate is on when A AND B are on.
NAND
The NAND gate is on when NOT (A AND :cool.gif: is true. That is to say, as long as A AND B are NOT both on, it is on.
XOR
The XOR gate is on when A != B.
XNOR
The XNOR gate is on if A=B.
Summary
As you hopefully now know, a logic gate takes two inputs (or more, but we'll talk about that later), and computes an output based on those inputs. Because their output is only one bit, they are limited in what they can do alone. Soon we'll be exploring what groups of logic gates stuck together can do, but for now, we have other basic components to cover.
Clocks
A clock, put simply, is a timing device. Not in a conventional sense, as in the clock on your wall. Imagine, if you will, an analog clock. Hopefully you've seen at least one or two in your life. Anyways, imagine if you make it so that whenever the hour hand was at 6 o clock or earlier, it would send a 'true' signal to a circuit. Otherwise, it would send a false. Your clock would act something like this:
That, essentially, is what a clock made from logic gates in Minecraft is, besides the fact that it is much faster. It is on for a certain number of 'ticks' (the time it takes a torch to change state, 1/16th of a second at 100 FPS), then off for (usually) an equal number of ticks. For instance, the 5 clock sends a signal of 00000111110000011111.., one 'bit' (1 or 0) each tick. So for 5 ticks the clock sends an on, then it send off for 5 ticks, then on, etc. etc.
Flip Flops
Many a time, we get posts on this forum from people asking for 'a logic gate to do this and this and this and make tea'. Sometimes a simple gate can do it. Sometimes a few gates interlinked can do it. But a lot of the time, what they need is called a flip-flop. Unlike a gate, which can only act on the time it receives input, a flip-flop can remember its inputs and output them at a later time.
Latches vs Flip flops
A latch is a flip-flop without a clock. They're generally not as useful because they don't sync with everything else. You see, with every type of complex circuit there is stabilization time. After it gets inputs, it needs however much time for those inputs to stabilize, compute, stabilize again, and get outputted. Fighting this is a futile task. instead, work with it. How? Flip flops will only take input at a certain time. How does this help?
Lets say you have a bunch of input from switches going into a circuit of flip-flops. Clock 0 is when every switch is turned on.
state[|get input|-stabilizing---|get input|-stabilizing---|get input|---etc...]
clock0123456789111111111122222222223333333333444444444455555...
position-----------012345678901234567890123456789012345678901234...
As you can see, even though there are stabilization times, they are never a problem because the flip-flops only take input after the previous components have had enough time to stabilize. Of course, this feature doesn't come with the schematics. You have to work out the amount of time it takes things to stabilize, then make the clock cycle a bit longer than that. And for large components (like the ALU in a CPU), they might have their own internal clocks that also have to be worked out manually! The benefit is certainly worth it, however. While a memory bank using latches will input and output data unevenly due to propagation times, a bank made from D-flip-flops will always seamlessly input and output.
Latches RS NOR
When the set bit goes high, the output goes high as well. Later, when the reset bit goes high, the output goes low. If both go high at the same time, it causes a 'race condition', where the output is (somewhat) indeterminate.
There are other types of latches, as well as un-clocked versions of flip-flops. However, generally the RS-NOR can fill any spot you need an un-clocked memory unit.
Flip Flops D
The 'data' flip flop, this is generally used in memory banks.
The one I've posted here is the edge-triggered D, which is more useful. Edge triggered means it will only change Q to D at the moment the clock switches from OFF to ON. The level-triggered D will change at any time the clock is OFF, and thus isn't as useful for synchronized memory, the main application of D flip-flops.
T
The T flip-flop, or Toggle, is at the core of counters, clocks, and more. in clocks, it functions as a 'period doubler', turning 2 clock cycles into one. In counters, a chain of T flip-flops will naturally assume binary numbers when the end of the chain is pulsed. Try it and you'll see.
JK
The JK flip-flop is like an improved RS NOR latch. J acts like S, and K acts like R. However, it is clocked, and setting J and K at once makes it toggle like the T flip-flop instead of racing (pseudo)randomly.
Summary
Everything from now on (with a few exceptions), everything is going to be built with gates, clocks and flip-flops. Everything. If you don't know them, you're going to have a lot of problems later on.
Building complex circuits
Introduction
I'm not going to go over how to build every type of feasible complex circuit...shift registers, multiplexers, de-multiplexers, multipliers, subtractors, dividers, etc. There's just to many to go over. Instead, I'll show you how to read the designs (schematics) and how to make your own designs.
How to Read Schematics
First, to do this you need to know the symbols for each gate and flip-flop
NOT gate
OR gate
AND gate
NAND gate
NOR gate
XOR gate
XNOR gate
RS NOR latch
D flip-flop
T flip-flop
JK flip-flop
Now that you know them/have reference to them, reading schematics is easy:
That's a connection between gates (imagine it as a line of redstone dust)
That's where two wires connect (imagine it as a redstone intersection)
That's where a wire crosses another wire but doesn't intersect it. Imagine it as a dirt bridge.
Here's a schematic to test yourself on. Try and build it in minecraft, exactly as shown. Then check below and see how it matches up.
(Forgive the texture pack, please)
Designing your Own Circuits Idea and theory
First, you need to have and idea. For instance, a circuit that will fire a TNT cannon if the correct combination is entered and two buttons 30 blocks away are pressed simultaneously.
Then, break it down into parts that you know schematics for exist. They don't have to be logic gates. For example, I can just put a big box that says 'combination lock' because thousands of schematics for them exist.
The list for this project is:
[*:3ur76xg5]Edge detector (to shorten button presses so they have to be exactly at the same time)
[*:3ur76xg5]Combination lock
[*:3ur76xg5]3-input AND
Then, make a schematic.
That wasn't to hard, was it?
Finally, use the same techniques you used when building from schematics to build from your schematic. Build it piece by piece and 'unit test' each section before moving on. This will prevent bugs later. Then...
Obviously this isn't a practical circuit. Someone could easily tear out the buttons and put in wires instead, then trigger them with a lever in the middle. However, it is good learning.
Black box design
When building any circuit, whether it is meant to be put in a larger circuit (AND gate>Adder>ALU>CPU) or stand on its own should function as what is called a 'black box': Take inputs and give outputs without regards to it's internal design. The ALU using the adder shouldn't need to know anything about the adder. Essentially, if the adder was a black box the ALU should still be able to use it just fine.
What are the advantages to this?
[*:3ur76xg5]Modularity. Designing, debugging and building can go module by module. First build an adder, test, build a multiplexer, etc.
[*:3ur76xg5]Swappability. Say two days after putting an adder in your ALU you find a smaller one that works just as well. You can swap it out with no harm to the rest of the ALU, and no other redesigning.
[*:3ur76xg5]Generalization. Imagine if your ISP needed to know everything about your computer's internals to hook you up to the internet! But they don't. They don't care if your computer runs Windows or Linux, is x86 or x86-64 or RISC or made in the 80's from scrapped C-64's, as long as it has the ability to send the right outputs and take the right inputs it can be pat of the internet (OK, maybe the Commodore 64 is a bit of a stretch).
How do I use Black Box Design?
Surprisingly, you have already. Every logic gate and flip-flop on the wiki is a 'black box', in a sense. Whats harder to do is build something that isn't one. The big thing to remember, in my opinion at last (though I don't claim to be a professional in any sense of the word) is to standardize. For instance, remember the section on flip-flops and synchronization? In case you don't, one part mentioned how very complex devices (such as a whole minecraft computer) might have multiple clocks to sync different parts together. Even if you end up going to route of one internal clock with tons of extenders to reach every single part of your construction, at some point, in SMP of course, you might be interfacing with someone elses construction, where that isn't practical. Even if they use the same clock speed as you, the clocks still won't be synced perfectly. Therefore, instead of designing the interface between the two devices to require a signal synced to a specific speed- which violates BBD because you need to know the internal clock speed- you would instead take the slightly more complex method of counting how many signals you expect to get and waiting until each signal is delivered, then giving them to your device in the timing expected.
A Final Note
I hope you've enjoyed this tutorial, I'm sure it's been a long ride! This tutorial has really been a labor of love, going back from when, months ago in the comments of my first tutorial I promised a followup, to the first draft I saved of it (October!), to slowly adding to it and revising. I'm not sure about a third, yet, but I like three a lot, so Redstone FAQ and General Tutorial - part three, secret surprise might be in the works. For now, however, I want to take a break from tutorial writing for awhile.
Please do leave a comment if this tutorial helped, it makes me happy (and keeps it bumped for others to enjoy, of course!).
If you are planning to write your own redstone tutorial more closely covering certain topics, please do. I don't want to do all the work here!
All images hosted through Dropbox, I highly recommend it. (The ref link gives you some extra space through signing up with it, as well as me, before you take it out.)
There's some good info here, although I've already done a good amount of research while working on my own stuff.
Even with clocked memory, isn't there still a little bit of desynchronizing because of data buses? I suppose you could put in unnecessary repeaters, but I'd rather not need to change anything that I'm almost done with.
Rollback Post to RevisionRollBack
Quote from evan86 »
I'm going to be a realist and say fish. If I'm wrong you can send me a pm calling me a long-legged picadilly.
Quote from MadocComadrin »
Heh, I was expecting something along the lines of this: Has anyone really been far even as decided to use even go want to do look more like?
The idea with redstone isn't so much "everything clocks at the same time" as "nothing happens until the previous 'clock' has ended." In other words, all data is already where it needs to be ready for the next clock cycle.
I think I've got it right then; I'm using read/write and memory address toggles so that it'll only do something when those are set properly.
Thanks for the help.
Rollback Post to RevisionRollBack
Quote from evan86 »
I'm going to be a realist and say fish. If I'm wrong you can send me a pm calling me a long-legged picadilly.
Quote from MadocComadrin »
Heh, I was expecting something along the lines of this: Has anyone really been far even as decided to use even go want to do look more like?
There's some good info here, although I've already done a good amount of research while working on my own stuff.
Even with clocked memory, isn't there still a little bit of desynchronizing because of data buses? I suppose you could put in unnecessary repeaters, but I'd rather not need to change anything that I'm almost done with.
Glad to know this helped, even if only a bit. There is a bit of desyncing on long data buses- I usually design my buses for minimum length, so the most I've ever had to put in was a 4-tick delay on the shortest line. It's not a bad idea to do, even if your circuit does have some tolerance.
Sorry for the double post, but I cleaned up the tutorial a bit- there were a few nagging grammar errors from typing at 1 AM. I also clarified parts that were confusing, like the clock section.
I notice that this has a lot more views than posts, so if you're reading this I'd love it if you'd bump it up a bit so other people can see it.
So any tips on how to make a thing that will change curcit 3 times every time a button is pressed?
like
Curcits 1,2 and 3
0 powered
1
2
3
Button press
0
1 powered
2
3
button press
0
1
2 powered
3
button press
0
1
2
3 powered - TNT
Rollback Post to RevisionRollBack
Mod edit: Please stay on topic. This is a thread about how to dispose a corpse
Quote from Inception Cat »
Keyofdoor and only Keyofdoor is allowed to have me on his avatar.
sorry if this is demanding but can you use the redstone sim schematics?
If you cant ill just try and use yours
Edit: Tried and it didn't work
one of the lights turn off but then nothing happened
Rollback Post to RevisionRollBack
Mod edit: Please stay on topic. This is a thread about how to dispose a corpse
Quote from Inception Cat »
Keyofdoor and only Keyofdoor is allowed to have me on his avatar.
sorry if this is demanding but can you use the redstone sim schematics?
If you cant ill just try and use yours
Sure, give me a sec and I'll transfer, no trouble.
:biggrin.gif: Ten diamonds and cookies for you
Here you go. I ended up going with a different design, because it made more sense with the way Minecraft flip-flops are built. If you want an on-off switch, you can add one in by ANDing it against the button.
Here you go. I ended up going with a different design, because it made more sense with the way Minecraft flip-flops are built. If you want an on-off switch, you can add one in by ANDing it against the button.
Lol
Schem for guy8.gif
Thanks alot! Its works perfectly :biggrin.gif:
Rollback Post to RevisionRollBack
Mod edit: Please stay on topic. This is a thread about how to dispose a corpse
Quote from Inception Cat »
Keyofdoor and only Keyofdoor is allowed to have me on his avatar.
for the flip-flops/latches,
could somebody explain
what D,S,R,Q etc.. are?
I'm getting confused trying
to replicate the base designs
in redstone sim
Ok.
In a RS NOR latch, S sets the output to 1, and R sets it to 0.
In a D flip flop, the output is set to D when the clock triggers the flip flop.
In a T flip flop, if T is 1 the output toggles (inverts itself)
In a JK flip flop, J sets the output to 1 and K sets it to 0, and if both are powered the output toggles.
For all of these, Q is the output and line-over-Q is the inverse of Q (!Q if you program).
So here you are. You've read my other tutorial on redstone. Maybe you've even gone on with the diagrams posted at the end to make some simple contraptions. So, if you already know how to do that, then why am I writing this followup?
The point of this tutorial is several-fold. It will give you practical advice on building with redstone. It will formalize a few concepts, like synchronized memory banks and the like. Finally, and most importantly, it will show how the mechanics of redstone can be built up into new, more generalized, more useful mechanics, which can in turn be built up ad infinitum.
Caveats
Hopefully you have read my past tutorial. If you haven't, please read it here. At least skim it, as I will NOT recapping anything from it. I will assume you know how to make a wire travel indefinitely upwards, or extend a wire past 15 blocks.
Philosophy
This tutorial is not meant for someone who simply wants to know how to do 'x'. I will not hand you a diagram of a double door with a lockout switch and say that you're done, because if you'd rather have the schematic handed to you than this isn't the tutorial for you. I'm certainly not averse to providing schematics (I give them out to people all the time, just throw me a PM). However, it's much more enlightening- and fun- to try and make the schematic yourself before asking someone else for it, and then after that study the schematic they gave to see how they did it.
Uses of logic gates in Minecraft, and why they will be ignored
There's quite a bit of outcry about redstone being useless. I completely disagree. You can use it to control minecarts, set off TNT, turn on lights, open doors, etc. A bit of creativity will bring you far in figuring out ways to use this. I don't particularly wish to partake in further discussion about how useful redstone is, so please keep it out of this thread. Thanks.
-------------------------------------------------------------------
Redstone logic
Logic gates:
What are Logic Gates?
What are they used for?
Logic Gate Theory
List of Logic Gates
Summary
Clocks
Flip Flops:
Latches vs Flip Flops
Latches
Flip Flops
Summary
Building Complex Circuits:
Introduction
How to Read Schematics
Designing Your Own Circuits:
Idea and Theory
Black Box Design
How Do I Use Black Box Design?
A Final Note
-------------------------------------------------------------------
Logic Gates
What are logic gates?
Logic gates are the simplest form of redstone construction in Minecraft. A single wire is a logic gate (a non-I/O isolated OR gate). A torch on a block is a logic gate (NOT gate).
What are they used for?
Whenever you need to change a signal in any way, you need to use a logic gate. The only time you don't is when you have one direct action.
For instance, consider the simple action of pulling a lever. If you simply wanted that to open a door, then you would not need any logic gates. Pulled lever = open door. However, the minute you want to add an "extra condition" in there, you need logic gates. For instance, pulled lever1 OR pulled lever2 = open door would need an OR gate.
Logic Gate Theory
In the real world, logic gates are built out of transistors. Since transistors start to dive into physics some, I won't go into them here. However, we do need a way to build all the different gates in Minecraft. In fact, I hear someone shouting in their monitor now "Rotten, if you can only build OR's and NOT's, how do you build an 'XOR'???"
Well, again in the real world, they don't actually build everything out of transistors. It's much simpler (economy of scale-wise) to put all transistors into making what is known as the NAND gate. Why? Because NAND gates can be used to build every other type of gate. This isn't very useful to us, though, as we don't have AND gates to building out NAND gate from (NAND- NOT AND- A NOT gate and an AND gate). However, there's another gate like the NAND. What is it? The NOR gate. And we have what it takes to build NOR gates (NOTS and ORS), so we can use them to build every other type of gate (and a few other things besides).
List of Logic Gates
I will list the 7 commonly acknowledged logic gates here. The diagrams I post will, in most cases, be the version that takes the least ticks to complete its computation, as this is generally the most useful version. For other versions, visit the Minecraft Wiki's page on logic gates, which has several designs for each gate, optimized for each factor.
NOT
The simplest (input-isolated) gate to build in minecraft. It has one input, and reverses (inverts) that input.
NOR
An expansion of the NOT gate, that takes two inputs. It is only on when all the inputs are off.
OR
The OR gate is on when A OR B is on.
AND
The AND gate is on when A AND B are on.
NAND
The NAND gate is on when NOT (A AND :cool.gif: is true. That is to say, as long as A AND B are NOT both on, it is on.
XOR
The XOR gate is on when A != B.
XNOR
The XNOR gate is on if A=B.
Summary
As you hopefully now know, a logic gate takes two inputs (or more, but we'll talk about that later), and computes an output based on those inputs. Because their output is only one bit, they are limited in what they can do alone. Soon we'll be exploring what groups of logic gates stuck together can do, but for now, we have other basic components to cover.
Clocks
A clock, put simply, is a timing device. Not in a conventional sense, as in the clock on your wall. Imagine, if you will, an analog clock. Hopefully you've seen at least one or two in your life. Anyways, imagine if you make it so that whenever the hour hand was at 6 o clock or earlier, it would send a 'true' signal to a circuit. Otherwise, it would send a false. Your clock would act something like this:
That, essentially, is what a clock made from logic gates in Minecraft is, besides the fact that it is much faster. It is on for a certain number of 'ticks' (the time it takes a torch to change state, 1/16th of a second at 100 FPS), then off for (usually) an equal number of ticks. For instance, the 5 clock sends a signal of 00000111110000011111.., one 'bit' (1 or 0) each tick. So for 5 ticks the clock sends an on, then it send off for 5 ticks, then on, etc. etc.
Flip Flops
Many a time, we get posts on this forum from people asking for 'a logic gate to do this and this and this and make tea'. Sometimes a simple gate can do it. Sometimes a few gates interlinked can do it. But a lot of the time, what they need is called a flip-flop. Unlike a gate, which can only act on the time it receives input, a flip-flop can remember its inputs and output them at a later time.
Latches vs Flip flops
A latch is a flip-flop without a clock. They're generally not as useful because they don't sync with everything else. You see, with every type of complex circuit there is stabilization time. After it gets inputs, it needs however much time for those inputs to stabilize, compute, stabilize again, and get outputted. Fighting this is a futile task. instead, work with it. How? Flip flops will only take input at a certain time. How does this help?
Lets say you have a bunch of input from switches going into a circuit of flip-flops. Clock 0 is when every switch is turned on.
state[|get input|-stabilizing---|get input|-stabilizing---|get input|---etc...]
clock0123456789111111111122222222223333333333444444444455555...
position-----------012345678901234567890123456789012345678901234...
As you can see, even though there are stabilization times, they are never a problem because the flip-flops only take input after the previous components have had enough time to stabilize. Of course, this feature doesn't come with the schematics. You have to work out the amount of time it takes things to stabilize, then make the clock cycle a bit longer than that. And for large components (like the ALU in a CPU), they might have their own internal clocks that also have to be worked out manually! The benefit is certainly worth it, however. While a memory bank using latches will input and output data unevenly due to propagation times, a bank made from D-flip-flops will always seamlessly input and output.
Latches
RS NOR
When the set bit goes high, the output goes high as well. Later, when the reset bit goes high, the output goes low. If both go high at the same time, it causes a 'race condition', where the output is (somewhat) indeterminate.
There are other types of latches, as well as un-clocked versions of flip-flops. However, generally the RS-NOR can fill any spot you need an un-clocked memory unit.
Flip Flops
D
The 'data' flip flop, this is generally used in memory banks.
The one I've posted here is the edge-triggered D, which is more useful. Edge triggered means it will only change Q to D at the moment the clock switches from OFF to ON. The level-triggered D will change at any time the clock is OFF, and thus isn't as useful for synchronized memory, the main application of D flip-flops.
T
The T flip-flop, or Toggle, is at the core of counters, clocks, and more. in clocks, it functions as a 'period doubler', turning 2 clock cycles into one. In counters, a chain of T flip-flops will naturally assume binary numbers when the end of the chain is pulsed. Try it and you'll see.
JK
The JK flip-flop is like an improved RS NOR latch. J acts like S, and K acts like R. However, it is clocked, and setting J and K at once makes it toggle like the T flip-flop instead of racing (pseudo)randomly.
Summary
Everything from now on (with a few exceptions), everything is going to be built with gates, clocks and flip-flops. Everything. If you don't know them, you're going to have a lot of problems later on.
Building complex circuits
Introduction
I'm not going to go over how to build every type of feasible complex circuit...shift registers, multiplexers, de-multiplexers, multipliers, subtractors, dividers, etc. There's just to many to go over. Instead, I'll show you how to read the designs (schematics) and how to make your own designs.
How to Read Schematics
First, to do this you need to know the symbols for each gate and flip-flop
NOT gate
OR gate
AND gate
NAND gate
NOR gate
XOR gate
XNOR gate
RS NOR latch
D flip-flop
T flip-flop
JK flip-flop
Now that you know them/have reference to them, reading schematics is easy:
That's a connection between gates (imagine it as a line of redstone dust)
That's where two wires connect (imagine it as a redstone intersection)
That's where a wire crosses another wire but doesn't intersect it. Imagine it as a dirt bridge.
Here's a schematic to test yourself on. Try and build it in minecraft, exactly as shown. Then check below and see how it matches up.
(Forgive the texture pack, please)
Designing your Own Circuits
Idea and theory
First, you need to have and idea. For instance, a circuit that will fire a TNT cannon if the correct combination is entered and two buttons 30 blocks away are pressed simultaneously.
Then, break it down into parts that you know schematics for exist. They don't have to be logic gates. For example, I can just put a big box that says 'combination lock' because thousands of schematics for them exist.
The list for this project is:
[*:3ur76xg5]Edge detector (to shorten button presses so they have to be exactly at the same time)
Then, make a schematic.[*:3ur76xg5]Combination lock
[*:3ur76xg5]3-input AND
That wasn't to hard, was it?
Finally, use the same techniques you used when building from schematics to build from your schematic. Build it piece by piece and 'unit test' each section before moving on. This will prevent bugs later. Then...
Obviously this isn't a practical circuit. Someone could easily tear out the buttons and put in wires instead, then trigger them with a lever in the middle. However, it is good learning.
Black box design
When building any circuit, whether it is meant to be put in a larger circuit (AND gate>Adder>ALU>CPU) or stand on its own should function as what is called a 'black box': Take inputs and give outputs without regards to it's internal design. The ALU using the adder shouldn't need to know anything about the adder. Essentially, if the adder was a black box the ALU should still be able to use it just fine.
What are the advantages to this?
[*:3ur76xg5]Modularity. Designing, debugging and building can go module by module. First build an adder, test, build a multiplexer, etc.
[*:3ur76xg5]Swappability. Say two days after putting an adder in your ALU you find a smaller one that works just as well. You can swap it out with no harm to the rest of the ALU, and no other redesigning.
[*:3ur76xg5]Generalization. Imagine if your ISP needed to know everything about your computer's internals to hook you up to the internet! But they don't. They don't care if your computer runs Windows or Linux, is x86 or x86-64 or RISC or made in the 80's from scrapped C-64's, as long as it has the ability to send the right outputs and take the right inputs it can be pat of the internet (OK, maybe the Commodore 64 is a bit of a stretch).
How do I use Black Box Design?
Surprisingly, you have already. Every logic gate and flip-flop on the wiki is a 'black box', in a sense. Whats harder to do is build something that isn't one. The big thing to remember, in my opinion at last (though I don't claim to be a professional in any sense of the word) is to standardize. For instance, remember the section on flip-flops and synchronization? In case you don't, one part mentioned how very complex devices (such as a whole minecraft computer) might have multiple clocks to sync different parts together. Even if you end up going to route of one internal clock with tons of extenders to reach every single part of your construction, at some point, in SMP of course, you might be interfacing with someone elses construction, where that isn't practical. Even if they use the same clock speed as you, the clocks still won't be synced perfectly. Therefore, instead of designing the interface between the two devices to require a signal synced to a specific speed- which violates BBD because you need to know the internal clock speed- you would instead take the slightly more complex method of counting how many signals you expect to get and waiting until each signal is delivered, then giving them to your device in the timing expected.
A Final Note
I hope you've enjoyed this tutorial, I'm sure it's been a long ride! This tutorial has really been a labor of love, going back from when, months ago in the comments of my first tutorial I promised a followup, to the first draft I saved of it (October!), to slowly adding to it and revising. I'm not sure about a third, yet, but I like three a lot, so Redstone FAQ and General Tutorial - part three, secret surprise might be in the works. For now, however, I want to take a break from tutorial writing for awhile.
Please do leave a comment if this tutorial helped, it makes me happy (and keeps it bumped for others to enjoy, of course!).
If you are planning to write your own redstone tutorial more closely covering certain topics, please do. I don't want to do all the work here!
All images hosted through Dropbox, I highly recommend it. (The ref link gives you some extra space through signing up with it, as well as me, before you take it out.)
Even with clocked memory, isn't there still a little bit of desynchronizing because of data buses? I suppose you could put in unnecessary repeaters, but I'd rather not need to change anything that I'm almost done with.
+1
I think I've got it right then; I'm using read/write and memory address toggles so that it'll only do something when those are set properly.
Thanks for the help.
Glad to know this helped, even if only a bit. There is a bit of desyncing on long data buses- I usually design my buses for minimum length, so the most I've ever had to put in was a 4-tick delay on the shortest line. It's not a bad idea to do, even if your circuit does have some tolerance.
I notice that this has a lot more views than posts, so if you're reading this I'd love it if you'd bump it up a bit so other people can see it.
i love redstone and this is epic
Good to know this was helpful!
So any tips on how to make a thing that will change curcit 3 times every time a button is pressed?
like
Curcits 1,2 and 3
0 powered
1
2
3
Button press
0
1 powered
2
3
button press
0
1
2 powered
3
button press
0
1
2
3 powered - TNT
For the TNT, instead of the lightbulbs hook the Q outputs to an AND gate, and have the AND gate's output connected to your TNT.
If you cant ill just try and use yours
Edit: Tried and it didn't work
one of the lights turn off but then nothing happened
Sure, give me a sec and I'll transfer, no trouble.
:biggrin.gif: Ten diamonds and cookies for you
Here you go. I ended up going with a different design, because it made more sense with the way Minecraft flip-flops are built. If you want an on-off switch, you can add one in by ANDing it against the button.
Here you go. I ended up going with a different design, because it made more sense with the way Minecraft flip-flops are built. If you want an on-off switch, you can add one in by ANDing it against the button.
Lol
Schem for guy8.gif
Thanks alot! Its works perfectly :biggrin.gif:
could somebody explain
what D,S,R,Q etc.. are?
I'm getting confused trying
to replicate the base designs
in redstone sim
Creating Necromancy since 2011!
Necro-ing Necromancy threads since 2014!
Repeatedly restarting mods since 2015!
Inputs and outputs 2nd output 2nd input.... but im not so sure about the rest
Ok.
In a RS NOR latch, S sets the output to 1, and R sets it to 0.
In a D flip flop, the output is set to D when the clock triggers the flip flop.
In a T flip flop, if T is 1 the output toggles (inverts itself)
In a JK flip flop, J sets the output to 1 and K sets it to 0, and if both are powered the output toggles.
For all of these, Q is the output and line-over-Q is the inverse of Q (!Q if you program).
Creating Necromancy since 2011!
Necro-ing Necromancy threads since 2014!
Repeatedly restarting mods since 2015!