Showing posts with label latches. Show all posts
Showing posts with label latches. Show all posts

Thursday, October 13, 2011

Demo 2: The Idiot Trap

If you're wondering what you could use latches for, here's an example...
The set-up I'll show will do this: if someone goes into the left room and presses the S input button, the iron door closes and the redstone torch in the right room comes on. Someone pressing the R input will then shut the alert torch off and open the door again, releasing the person in the left room.

As with the previous demo, clay blocks are where full walls or floors would go, and white wool is mainly there so the redstone shows up nicely. In this demo, the blue wool represents where another wall would go, so I could show the boundary of the rooms without obscuring the wiring.

I labeled the images this time, so they should hopefully be fairly self-explanatory.
(No errors here, nope...)
A better view of some of the wiring.
There's a mistake here: The vertical "steps" that bring the R input line to ground level will cause a loop if you add in the blocks for the floor, rendering the input nonfunctional. The second step should be one to the right instead of one in front. I might fix the image eventually but not tonight.

And here's the back of the wiring that transfers the signal from the S input.
(If you're wondering why I went with the relatively complicated two-torches set-up here, the answer is that I was working on this way too late at night. It would work just as well with a set-up similar to the wiring from the R input, but with the second wool block one to the left instead of to the right.)
And this is just another alternative view of the wiring. The redstone torch placed along the middle of the inverse output line is placed pretty arbitrarily - it just needs to be somewhere along the line there in order to balance out the torch that's powering the iron door.

The title for this one is pretty much all in how you present it, of course...


For extra credit: add some pistons in the ceiling of the sucker room that are also connected to the inverse output, acting as floodgates and holding back flowing lava until someone presses the button.

Wednesday, October 12, 2011

RS NOR Latch: An Intro to Latches

I'll just be covering one latch in this post, and the next post should be a demonstration of one possible use for a RS NOR latch.

A latch or a flip-flop is a redstone circuit that effectively carries a single bit of memory - that is, it can hold an "on" or "off" state and hold it, instead of relying only on input at the moment it's given.
Latches typically have two inputs, one "reset" input and one "set" input - that is, one R and one S input.
Flip-flops add more complicated logic to a latch in order to change the way it behaves. I'll go into them at a later time.

All of these circuits are, at their core, built around the RS NOR Latch:
In this image, the top left lever is the "set" or S input, and the bottom right lever is the "reset" or R input. The top output - on the blue block - is the inverse output, and the green output is the uninverted output.
(Just for the record, you may not want to use levers - because they can both be set to "on" at the same time, they can cause some issues. Something like a button will work with less chance of error.)
In the state pictured, you can sit there pulling the R lever as much as you like and nothing will happen, the inverse output will stay on, and the uninverted output will stay off.
Flick the S lever on and then off, though, and the opposite is true - the uninverted output will remain on, and the inverted input will be off, no matter how many times you pull the S lever (or push the S button, walk over the pressure pad, whatever input you use...)
(This is why I really should've used buttons, by the way - if you pull the S lever and leave it on, then pull the R lever, it will mess the whole thing up. I used them mostly so that they're visible, but keep this in mind if you use this circuit!)

So there you go - this is the simplest latch. There's a variety of designs for it, as there are with most of the circuits we've covered so far, but for the moment I'll be sticking with this for the sake of consistency.
You can also have an RS NAND Latch, which would just be an RS NOR latch with inverters applied to the inputs and outputs.