BG1, PRELOAD BG2, PRELOAD

feloneouscat

Evolution of a Bad - VERY Bad - Idea

Rate this Entry
Most engineers do not divulge their mistakes because, quite frequently, an engineers work is not typically understood by the Big Shots. So as a result many of the horrors they create get buried.

Unfortunately, for the engineer, this can spill over into other things in real life -- to the point that either they can't admit a mistake or do their best to cover it up.

Today, however, I will admit to a big mistake. Something that was terribly, terribly stupid.

Then I will show you how I fixed it.

THAT is how most good engineering is done. Bad engineering calls it a feature and lets the customer deal with it.

The Goal

What we are attempting to do is create an RS Latch (also called an RS flipflop). Basically it works this way:

1) If you send a positive signal to the SET line, then the latch will, well, set. The output from the latch will be positive. Sending a positive signal multiple times to SET will do nothing after the first time it is set.

2) If you send a postive signal to the RESET line, it will reset the latch. The output will now be the opposite of positive (we will call it "zero").

The design criteria is that the inputs must be <-/-> and the output must be <-/->.

Sounds easy, right?

I'll Use Google!

And sure enough you will find the following for an RS Latch (for this example we will use a NOR gate):



Which looks like gibberish to those who haven't played with logic.

We haven't been introduced to NOR gates, nor do they look terribly useful. So, come on and let us get aquainted!

NOR Is OR With Inverted Output

Let us review the standard OR gate. An OR gate with a wobble bolt looks like the following:



And has the following logic:



Simple enough, eh?

Well, a NOR gate is just an OR gate with an INVERTED output. Which makes it terribly simple:



Turning that into LBP hardware then is trivial - we merely UN-INVERT the output!



Wow! This is almost to the point ANYONE can understand it!

Two NORs Equals an RS Latch

Okay, so now we have the NOR gate, let's use what we found on Google as a template to figure out how to wire this puppy up. Which doesn't take more than a couple of seconds - you only have so many possibilies!

So this is what a NOR RS Latch would look like:



Now, if you build this EXACTLY as I have it shown, and did it on PAUSE, as soon as you UNPAUSE it, it will begin to oscillate back and forth REALLY fast (if you have the motors at .1 seconds). This is because as it was set up, we have put the RS Latch into an UNDEFINED state (no, really, it is UNDEFINED because, well, it isn't defined!). You can get it into a defined state easily by flipping one or the other switch.

However, the fact that you can get it to oscillate so easily makes me fear that it could happen in game (remember, this is all SIMULATED hardware). Good engineering is about taking as many possibilities into account and eliminating those that cause problems. Oscillation is something we DON'T want. It is a problem.

We need a solution.

That got me to thinking about the "Bad Idea".

Origin of a Bad Idea

Actually, the idea was that like the piston RS Latch, we needed something that was simple, easy, and best of all, DIDN'T oscillate.

My first stab at it was interesting, but you might see why it is problematic.



The idea was the the SET input would rotate so that the latch (the wobble with the magnetic sensor) would see it. That would cause the latch to rotate so that when you removed the input from SET, the latch would remain set.

RESET was connected to the SET wobble bolt by a string. When you RESET, the RESET wobble bolt would pull the string that would pull the magnetic key out of range of the magnetic sensor.

I even managed to get it to work. But it didn't take much fiddling to realize that this was a horrible, horrible, next to impossible way of creating a RS Latch.

Worse of all, it would be nigh impossible to write up "How To Do This" in a way that didn't make your skin crawl.

I know my skin was crawling.

Sometimes Giving Up on an Idea gives way to Inspiration

Once I had realized that this bad idea (very bad!) wasn't feasible, I started afresh. I realized that three wobble bolts was exactly what I needed, I just didn't have them in the right arrangement. Ten minutes later, it hit me like a ton of bricks.

And I just kept calling myself "stupid, stupid, stupid" out loud.

Here is the easy solution:



All three wobble bolts are set to 180 degrees. In the off state the two magnetic keys and magnetic sensors are on the left side. Motors are set for .1 second.

The idea is that the SET will flip the key into view of the magnetic key sensor. This will spin the latch (the center wobble) so that it is in range of the RESET magnetic key. That is a successful latch.

To RESET you merely signal the RESET line which spins the magnetic key out of view of the magnetic sensor switch. This then causes the center to spin 180 degrees where it waits for another SET.

Bingo!

We solved the problem and it uses the same number of parts as our RS Latch using pistions. What's more, it is a clean and elegant design as opposed to the one with a piece of string.

Lessons to Take Away with this Project

Our goal was a clean, small, RS Latch that we could use in further projects. Now we have both piston versions of the logic and wobble bolt versions.

To make a lot of this easier for beginners I will dispense with the OR, NOR, AND, NAND symbols - yes, it is easy for us veterans, but sometimes just a box with OR labeled on it is enough. After all, I'm not trying to teach anyone the fundamentals of how to read a schematic - I'm trying to show how to use logic to solve problems.

So expect to see the following:



For the purists who would rather see standard symbols, go right ahead and start your own blog.

Previews of Coming Attractions

Just before we go and do something useful, we're going to build a monostable multivibrator (ooooooo.... uh, what?). Also known to the hardware otaku's as a one-shot.

(UPDATE) But JUST BEFORE THAT we will have a little refresher course on OR gates, AND gates, and XOR gates - tentatively titled "OR Gates - What's all this, then?"... Unless I change my mind or forget.

Should be a lot of fun!

You can find the RS Latch for Wobble Bolts by searching @feloneouscat and selecting the level "Logic Blog"

Updated 05-08-2009 at 04:55 PM by feloneouscat

Categories
Uncategorized

Comments

  1. feloneouscat's Avatar
    BTW, I changed my mind on the title
  2. Fjonan's Avatar
    Mh ... shouldn't SET and RESET be buttons instead of 2-way-switches? Shouldn't the angle on the 3-wobble-bolt-latch be just as big that it alsmost has both keys in range, so that when the middle one is spinning, there is no moment where the switch is not triggered by one of the keys?

    Oh and the NOR latch made my head explode.
  3. feloneouscat's Avatar
    Due to the way an RS Latch works, it can either be a button or a switch - it doesn't matter. Once it is set, it will stay set. Once it is reset, it will stay reset. The only issue with an RS Latch (where buttons are preferable) is if R and S are BOTH turned on - this is considered an undefined state and I believe a black hole erupts and swallows you.

    My initial design of the 3 wobble bolt latch indeed had the angle set to about 180 degrees - however, due to time constraints, I didn't modify my drawing to fit the actual hardware. HOWEVER, I suspect that the "inertia" built into the wobble bolt will allow even a very narrow range - just as long as you have it set to .1 seconds. BUT, I haven't tested it. HOWEVER, even in my example that I posted on @feloneouscat in "Logic Blog" you will find that there IS a time when the key is not seen - yet it still works correctly.

    So, the question is, should I DEPEND on inertia to assure that it works correctly? Or should I make sure a key is seen every time? Good point and I will bring it up in my next article on RS Latches and why they can be better than P-Switches.

    Yes, the NOR latch is non-intuitive. It is one of those "don't try to understand it, just accept it" things. I believe the simple three wobble bolt RS Latch is far more understandable (and does the same thing).

    (UPDATE) Ran out of room to point out why it is a GOOD idea to make sure the key switch is seen and not depend on inertia in RS Latches. Apparently I talk too much!
    Updated 05-11-2009 at 03:57 PM by feloneouscat
  4. feloneouscat's Avatar
    Fixed the RS Latch to be closer to what was tested and works. With some fiddling you should be able to remove the undefined state. I left it in because this is closer to the definition of an RS Latch.