This article goes through the design steps to get a logic circuit design in place for a basic SOCD cleaner.
What is a SOCD Cleaner Again?
For a full explanation of a SOCD cleaner in general, and some of its modes, I highly encourage you to check out Hitbox's arcade article for the details. But as a quick reminder, it's a device that takes Simultaneous Opposite Cardinal Directions and resolves into on of the directions for All Button Controllers (ABCs). For example, if the SOCD cleaner in question cleans the x-axis to neutral, that means when left and right are both pressed (opposite cardinals), the result that the game will process is neither left or right as the SOCD cleaner resolved it to neutral. You can have a different or the same SOCD cleaner mode on the y-axis as well. SOCD cleaners are required as many games can allow you to press the opposite directions at the same time causing a result that is a disadvantage to you as a player or an unfair disadvantage to another player. This is because the game developer didn't take this into account and things like charging a move while walking forward might be possible.
To Build or To Buy?
Even though there are a bunch of SOCD Cleaners on the market from places such as our store, Focus Attack, etc. I still see quite a few people rolling their own. For those who want to tinker with SOCD cleaners, I highly encourage it as you gain better insight of the hardware and sometimes its interesting to learn a bit of design. Even if someone takes an existing design and just builds it, there is always something to learn. This article is mainly targeted at those individuals interested in seeing how I would go about designing one. Whever possible, I will include a link to a video or webpage where further reading is necessary if you are not familiar with a concept.
Though it is important to note that this merely goes over just the logical circuit design using logic gates. It doesn't completely go through certain elements of an implementation of the design. For example, topics such as race conditions, voltage/logic levels, output types, sink/source current limits, output fanout, etc. will not be covered (or else this would be a long post!). However, if you feel like this article was useful and you want to know more about those concepts, feel free to comment below and request an article about the topic of interest.
Truth tables are extremely useful in logic circuit design. They describe the logical functions of the design without going into the electrical implementation. It's a visual aid to help understand what happens at every possible input. This idea of evaluating a set of current inputs is called combinational logic. When inputs are evaluated on present and past inputs that's called sequential logic. For many SOCD cleaner modes, combinational logic is sufficient.
For our example design, we are going to create a SOCD Cleaner that cleans to neutral. This cleaner can be used for either x-axis or y-axis because the cleaner has no idea what input is, left, right, down, and up. It just "sees" two inputs and then processes those inputs based on the logic design. With this in mind, let's name our inputs to be descriptive enough so we know what type of input to place.
|Min Cardinal||Max Cardinal||Resolved Min Cardinal||Resolved Max Cardinal|
The names Min Cardinal and Max Cardinal is just enough information. For Min Cardinal inputs, we intuitively know to place signals from left or down buttons. For Max Cardinals, we know to place signals from right or up. And since SOCD refers to opposite cardinals, we know to place left/right or down/up.
But what do ones and zeros represent? The answer, it depends whether you are using negative or positive logic. Typically, zero is associated with false, and one is associated with true. This describes positive logic. For negative logic, its the other way around. The table shows positive logic and will talk more about this later. For now, let's just tell ourselves zero means false (button released) and one means true (button pushed).
If you study the table a little, you can observe the respective input to output relationship is just copied over until both inputs are pressed. The result should make both outputs released which represents a cleaning to neutral result. Therefore this truth table accurately represents the function we are after in our example design.
Extracting a Boolean Equation
To make the transition to a logic circuit easier, we can take a small step and create a boolean equation. A boolean equation uses variables that rely on a two symbol system. For everyday life, we use a ten symbol system and perform things like addition, subtraction, multiplication, and division. We can even play with how an equation looks like with algebra, specifically elementary algebra. We can do the same with a boolean equation. We can play around with the equation with boolean algebra. Though an apparent difference between these two systems is that boolean math does not have addition, subtraction, multiplication, and division. It is instead has conjunction (AND), disjunction (OR), and negation (NOT).
With this, there are a whole new sets of rules that you would have to become familiar with! Luckily, if you are not interested in learning boolean algebra, there are online calculators that can do the reduction for you (not necessary for this example). But we need to at least know a method of creating some sort of boolean equation. For this we are going to use something called Sum of Products (SOP) form. It's just a specific format we can use to make ourselves a boolean expression.
First understand that when you "add" two boolean variables, that's unofficially called OR-ing. For this we use the plus symbol between each variable. When you "multiply" two boolean variables, that's unofficially called AND-ing. For this we use no symbol or a dot between each variable. For inverting a variable to it's complimentary state, that's unofficially called NOT-ing. For this we place a bar over variable (or a set of variables). Below is an example of a SOP expression.
It looks just like its name, a "Sum of Products". To get the same expression for our truth table, let's shorten our column names to makes things more manageable for notation.
Let's make the equation for the outputs. Here they are below.
How did we do it? First look at the N column, and now look all ones outputs. In our case, it's only a single case, A = 1, B = 0. That means we will only have one product to appear in our expression. Now for this case, look at the A and B inputs. Now apply a NOT operation to any input that is a zero and leave anything with a one alone. Then multiply together. That is is how we arrived at the answer. It is the same story for M. If we were to have more than a single one appear in our output, then we have to make a product term for each occurrence. For a more in-depth explanation and example, this video does a good job.
If you want to check to make sure the equations check out okay, run through the four set of inputs to convince yourself. For example, if you set A = 1, and B = 1, then N = 1 AND 0 (remember the B is NOT-ed making it a zero). If you look up the truth table the AND gate, this results in a zero, as expected. Here are tables for each type of gate to help check the equation if you are not familiar with them.
What's nice about the cleaning to neutral is that it is very simple which is why it was used as an example. Had it been more complicated, a larger boolean equation would have resulted. That would require us to perform boolean algebra to reduce the size, requiring less gates for the logic circuit. Or find an online boolean expression reduction calculator. Someone here made note of some. I haven't used them personally but they look promising.
Logic Circuit With Gates Result
Finally, here is out logic represented with logic gates!
Again you can see how simple a SOCD cleaner to neutral really easy when looking at its logic circuit. But wait! This diagram was made from positive logic, for our controllers, they use a common ground setup. This means they use negative logic, where zero means true and one means false. Guess what you homework is tonight ;) If you follow the above design pattern in the same manner, you will have a result where you get three terms in your SOP expression. This will require reduction that you can use an online converter to solve. You can also look up Products of Sums form to see if this yields an easier solution to implement ot reduce. This video can surely help with that.
There you have it, a design example from requirements all the way to the logic circuit. As mentioned before, to actually make a real circuit you need to take into consideration of things like voltage level, output type, etc but hopefully this gets those of you who want to tinker a path to follow for your next SOCD circuit build. The takeaway is that using the truth table to boolean equation to logic diagram approach is a good way when you want a predictable design technique to follow.