Evolution of a Bad - VERY Bad - Idea
by, 05-04-2009 at 03:39 PM (1296 Views)
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.
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.
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"