My RS Latch Can Beat Up Your P-Switch!

Rate this Entry
Since the beginning of time, or at least what qualifies as time for the LittleBigPlanet omniverse, people have used little devices called P-Switches. P-Switches stands for Permanent Switches.

So just in case you happen to be one of these new people, and a hearty congratulations you will never leave LittleBigPlanet (which we in the know call LBP - handy, eh?) let us look at two COMMON P-Switches.

The first P-Switch is the Media Molecule (also abbreviated as Mm or MM) approved P-Switch. It consists of a magnet key, on a dab of dissolve. Close to it is a magnetic switch that is set to invert. While the key exists, the magnetic switch will output a zero or a <- or a nothing. It looks like the following:

Connect a pushbutton to the dissolve. When someone pushes the pushbutton, poof, the dissolve will, well, dissolve, taking the key with it in a puff of smoke. The key switch will go “oh, dear, look what has happened, I better alert the neighbors” and output a 1, or a -> or one of the other signals you can set it to output.

The other type of P-Switch looks like the following:

The brown square is a piece of metal or other heavy material. When the dissolve dissolves, it drops down and voila, you have an output!

What is useful about a P-Switch is that it guarantees that once a input has happened, that the output will always be 1, or -> or whatever you have the output set as.


Unless you want to reset something in the game.

Wouldn’t it be nice if there were some way to RESET a P-Switch?

But First a Word About Signals

For this series all of our devices will use directional inputs and directional outputs (that’s the <-/-> in the switches). The <- will be assumed to be a zero and the -> will be assumed to mean a one. It’s like binary!

The goal of this series is NOT how to design efficient logic, but logic that will work. Once you have it working then you can hack away. Just make sure you save it first!

The RS Latch - Sounds Like Crazy Talk

The RS Latch is actually a very simple device - it has two inputs and one output. The output of the RS Latch is EXACTLY like a P-Switch. One of the inputs is EXACTLY like connecting to that dab of dissolve. The second input is new: it actually RESETS the output.

And just in case you want to correct me, yes, it is also called the SR Latch, RS Flipflop, and “that thing”. The last is VERY technical talk.

The input that sets the RS Latch is called, not surprisingly, the SET input. The input that resets it is called, also not surprisingly, the RESET. The only surprising thing about this is that the output is called Q. Why? Engineers are a funny lot. Maybe someone thought the Q looked a lot like an O or perhaps they wanted to remember it using “QRS” - who knows?

My secret theory is that it was a typo - engineers are notorious for bad handwriting. Like doctors.

A Simple RS Latch that even I can Understand

Okay, remember how we had a little logic diagram for all the AND, OR, and XOR gates? Well, the RS Latch also has a logic diagram and it is pretty easy to understand:

S is SET and R is RESET. Q is, well, Q.

The thing to remember is that JUST LIKE the P-Switch, once that pushbutton for the SET is pressed the output, called Q (remember that Q looks like an O for output) will be a permanent 1 - until someone presses the button connected to the RESET then it will go back to 0.

So the first three lines make sense: no inputs, nothing changes - Q is whatever it was last time we looked at it (either a 1 or a zero). S sets the output. R resets the output. The last, however, shows both S and R having a one and the output is ... “undefined”!?!

What the heck does that mean?

Well, think about it - how can you have something SET and RESET at the same time? This is called an “indeterminate state” or “oops, look what I did!” If you go to wikipeida you will find a nice long, complex explanation of the RS Latch.

It also has a very cool bit of animation. And it can make your head hurt.

We will, for the sake of this series, use a box. My article “Evolution of a Bad - VERY BAD - Idea” will show you how to make one for real out of LBP hardware. But for now, we will use a little box. I like boxes. They are easy to draw. ANYONE can draw a box.

See? Just an S for SET, an R for RESET and a Q for the output. Easy peasy.

Just in case you DID go to wikipedia, please note that they also show a Q with a line over it. That means it is the INVERSE of whatever Q is. So if Q is a 1 then Q-bar will be a zero and vice versa.

Got it?

Okay, Got it. Why is it Better than a P-Switch?

Lets create a scenario:

We have a checkpoint to the left and a door to the right. The door is closed when the piston is retracted and open when it is extended. to the left of the door is a button that the player presses to open the door. We then have two proximity switches (those switches that can detect a sackperson). One proximity switch is connected to a piston which in turn is connected to a chunk of metal. This is what squishes the sackperson. The other proximity switch is connected to our logic.

When the sackperson enters the room, the proximity switch connected to the metal block piston, starts to extend. Sack person must push the button to open the door or get squished!


Wow! How do We Create Logic For That?!?!

Lets back up a bit. Imagine I wanted something very “Raiders of the Lost Arc”-ish. A room that something started lowering until it squished the sackperson. And I wanted something that kept them there until they pushed the button (a door is easy).

Here are the steps I would take:

1. I needed something that opens the door. A button seems obvious.

2. I needed something that made sure that once the button was released, that the sack person could get THROUGH the door (otherwise it would close as soon as he got off the button). Since I needed what looked like a resettable P-Switch, it is only natural that I use a RS Latch.

3. I needed a way to start lowering the metal block. A proximity switch seems natural.

4. I needed a way to detect if the sackperson died. Another proximity switch seemed natural.

5. Since an RS Latch takes a 1 for set and a 1 for reset, I need to make sure the proximity switch connected to RESET is inverted.

All of this then creates the following “circuit” or wiring diagram:

I have tried to put the appropriate step number in a bubble to try to give you some understanding of how these steps relate to the “circuit” or wiring diagram.

I Could Have Done This With a P-Switch

Only up till the part where the sackperson dies. Then you are stuck.

This is where the RS Latch saves the day. Not only can you set it (like a P-Switch) but should sack person die you can reset it. This means you can start the ... er... puzzle all over again until they get it right. And with infinite checkpoint, they could be ... er... stuck all day!


No need to have puzzles that if the person messes up they have to restart the level. That means you get more people who actually finish your level (instead of posting ugly comments at the end that “THIZ LVL ZUCKS”).

We want, as designers, people to play our levels and finish them. Nothing is more disappointing to a designer than someone not finishing it. Was it too hard? Badly designed? It is hard to know. But with RS Latches, we can help avoid some of the problems.

How do I Break Stuff Up into Logic?

Notice the steps (1-5)? That’s usually what you have to do. Actually, it is really easy most of the time. Anytime you write “this and this” happens you probably need an AND gate. When you write “this or this” happens, probably means an OR gate. When you write “this happens, unless that is a one/zero, then something else happens” that is indicative of an XOR. If you need a P-Switch that you can reset, then it is an RS Latch.

In a later article I will go into more detail on how to go step by step into creating a logic diagram from “I want to do this”. Until then, this will have to suffice.

Extra Credit

I’ve published this scenario as “Logic Blog … RS Latches” and you can find it if you search @feloneouscat. Look for the badge that has a “0/1”.

For those who are reading this series, PM me if you can solve the following (don’t put it in the comments - not everyone lives in the same place on Earth and I want to give everyone a chance):

Extra Credit: If the sackperson gets through the door the first time (without getting squished) I want to give him extra score bubbles. If he doesn’t do it in one go, then he gets no extra score bubbles (awww!)

Again, PM me if you think you know the logic. A simple verbal description will do. Don’t feel intimidated if this is your first time designing logic. We all have to start somewhere. If you feel particularly proud of your solution, publish it and let me know!

Final Words

As you can see the RS Latch is very powerful. It is the fundamental basis of all digital logic (and the LBP Universe!). One could even go so far to say that if it did not exist, sackpeople wouldn’t either!

Until next time!

Updated 05-10-2009 at 11:31 PM by feloneouscat



  1. AJnKnox's Avatar
    Informative and confusing all at the same time! I love these lessons and really appreciate your taking the time to do them! I will chew on your 'extra credit' question and see if I can come up with an answer
  2. Burnvictim42's Avatar
    I hope you post the answer somewhere later! (perhaps in your next blog :P) I can think of billions of ways to do it otherwise... but you're looking for the logical solution, which i'm not entirely sure i have :P Keep up the great work with the blogs... even if they occationally make my head hurt ;p
  3. rtm223's Avatar
    Burnvictim, if you can think of a billion ways that work, then this is good. It means you can pick and choose. The normal scenario is that there are many ways to realise the same logic system. "Right" and "Wrong" solutions are just a case of whether it works.
  4. feloneouscat's Avatar
    Rtm223 is correct. There is no "right" solution. There is your solution and there are other solutions. I would be silly to say "this is the answer" - sure I HAVE an answer, but it doesn't mean it is the best or even the ONLY way of doing it.

    This is a challenge for you folks to get creative and show me what you got. Mistakes are okay. Even wrong answers are okay. This is not a pass/fail class - if you get even a LITTLE bit then you pass.

    Oh, and if you like my jokes you DOUBLE pass!
  5. mindphaser74's Avatar
    Thanks this was great! Maybe the answer involves an extra perm switch/splitter combo?
  6. feloneouscat's Avatar
    Maybe... maybe not. This is why it is for extra credit. If you think you know the answer PM me.

    This is to make you think (use those noggins!)! Get creative! Show me some logic.

    BTW, ONLY TWO has PM'ed me with even a hint to a solution! Come on, guys and gals, I know you are reading this! (I can see the view count!

    Figure something out. You have a copyable level. You have the basics. Anyone who PM's me with even PART of an answer gets partial credit (how about that?).

    And if you are close, I'll point you to one of the BILLION possible answers.
    Updated 05-29-2009 at 05:52 PM by feloneouscat
  7. Fjonan's Avatar
    Intriguing as always. At first the length scared me but now after reading it ... it's ingenious. I do not know how i would have realized the "sqish chamber" if i had to do it on my own. maybe some weird switch combos which ultimately would have come down to "that thing".
  8. feloneouscat's Avatar
    Actually, it was LONGER! But the system wouldn't allow me to post more than 10000 characters

    I try to write these to be easy. Don't be scared of the length, most of it is pictures anyway!
  9. Gravel's Avatar
    Well, the diagrams are all blue boxed question marks for me... so I'm up a paddle with a creek!
  10. feloneouscat's Avatar
    All are hosted by

    You might see if that site is blocked.