Sequential 4 Input Trigger
Obviously, no deviously constructed level would be complete without a challenge or some obscure puzzle that blocks your progress, so enter some logic that can make a nice challenge… the 4 input sequential trigger (ST for short). I will admit, thats a bit of a mouthful, but it (and devices like it) can be used to give your players a challenge.
The ST is designed to trigger when the player operates 4 switches in the correct order. Operate them out of sequence and it will reset meaning they have to start over. Up to now, I’ve talked about devices that simply change state under some stimuli. A directional push button for example… jump on, and it’s output is TRUE (expanded), jump off, and it’s output returns to FALSE (contracted). For the ST to work, we need to store the fact that the player has activated a button once they jump off. Thankfully, this is relatively straight forward.
Enter what I’m calling the ‘Single Bit Store’.
This device accepts two inputs… ‘SET’ and ‘RESET’. These will activate the switch (set) and deactivate the switch (reset) accordingly. This allows us to have a switch that is activated by a temporary input (a push button or grab switch for example) that will remain set until we say otherwise and deactivate it with the reset input.
The other element we need is a means of detecting that all four trigger inputs have been activated. Again, this is relatively straight forward. We can apply some logic that we have already seen… the AND gate. Admittedly we have only mentioned 2 input AND gates, but the logic is the same.
4 Input AND Gate Truth Table
This is a shortened truth table. We are only explicitly showing a single state. The one with all four inputs set to TRUE. This is the only state that results in the output being TRUE. For all other cases the output is false. Thus, we indicate that we don’t care about the state of the input using another state. I used an X to indicate that I didn’t care. The full table for a 4 input AND gate runs to 16 states.
To implement this in LBP we would use something like this:-
A B C D ]<->[ ]<->[ ]<->[ ]<->[*] [ /D\
So, combining this with the single bit store (1 for each input, we get):-
IN1 ]<->[ ][*] [ ]<->[ /D\-Input 1 Triggered-Connect to A IN2 ]<->[ ][*] [ ]<->[ /D\-Input 2 Triggered-Connect to B IN3 ]<->[ ][*] [ ]<->[ /D\-Input 3 Triggered-Connect to C IN4 ]<->[ ][*] [ ]<->[ /D\-Input 4 Triggered-Connect to D A B C D ]<->[ ]<->[ ]<->[ ]<->[*] [ /D\-Final Output
The observant amongst you will of course have spotted that the reset pistons of the single bit stores aren’t actually connected, so naturally, they will instantly reset the bit. If we simply wanted our players to activate four switches, we could have them activate four two way switches and connect them straight to the 4 input AND… but where’s the fun in that… we want our challenge to be a little harder… they have to get the order right. This is where the reset pistons come in.
However, the first thing we have to do, is to detect whether we have activated a switch out of turn (e.g. input 2 before input 1).
OUTOFORDER=INPUT 2 AND (NOT INPUT 1) or O = I2 . ( ! I1 )
It’s our old friend the 2 input AND gate, but with a twist. One of the inputs is inverted. So, instead of this:-
]<->[ ]<->[*] [ /D\
We reverse or invert (another name for NOT) one of the pistons. Then, when the input is TRUE (expanded), the piston does the opposite and contracts. This gives us a mechanism like this:-
]>-<[ ]<->[*] [ /D\
Combining these two elements for a single channel, we get the following mechanism:-
IN2 RI T1 T2 ]<->[ ][*] [ ]<->[ ]>-<[ ]<->[*] [ /D\T2 /D\RO
Where ‘IN2′ is the second stage trigger input, T1 is the output from the 1st stage single bit store, T2 is the output from the 2nd stage single bit store, RI is the reset input and RO is the reset output that signals we have activated stage 2 before stage 1. In reality, if this had occured (and the reset input RI was not yet triggered), the mechanism would look something like this:-
IN2 R2 T1 T2 ]<---->[ ][*][ ]<->[ ]>----<[ ]<---->[*][ /D\T2 /D\RO
Expanding this to the four inputs we get:-
IN1 RI ]<->[ ][*] [ ]<->[ /D\T1 IN2 RI T1 T2 ]<->[ ][*] [ ]<->[ ]>----<[ ]<->[*] [ /D\T2 /D\RO IN3 RI T2 T3 ]<->[ ][*] [ ]<->[ ]>----<[ ]<->[*] [ /D\T3 /D\RO IN4 RI T3 T4 ]<->[ ][*] [ ]<->[ ]>----<[ ]<->[*] [ /D\T4 /D\RO
Notice that there is no out of order mechanism for input 1. It can’t be out of order as it is the first, and if you activate any of the others before it, their out of order mechanism will detect it and reset the whole thing. The only problem we now have is that we need to activate 4 pistons from 3 different switches. This isn’t possible using just wires. One switch can activate many pistons, but each piston can only be activated by a single switch.
We need a little more logic. We need to activate the reset inputs (RI) when the stage 2 RO is activated OR the stage 3 RO is activated OR the stage 4 RO is activated. And if that didn’t give it away… this is what we need:-
3 Input OR Gate Truth Table
To build one, we expand our 2 input version like this:-
IN1 IN2 ]<->[*] [*]<->[ ---------/D\-------- ]<->[*] [*]<->[ IN3 IN4
The switch (/D\) will now be triggered when any of the four inputs (IN1, IN2, IN3 and IN4) are activated. But why do we have four inputs? Having a 4th input is handy. It allows us to trigger a reset by other means. It will come into play in the next section, but for now, we can just connect it to a directional switch that will never be activated (the easiest way to achieve this is a magnetic switch with a minute detection radius that is a different colour t all those around it).
To complete the wiring, we simply connect the out of order detected output (RO) from each stage to one of the pistons in the 4 input OR gate and then connect the output switch to each of the reset pistons (RI) in the main mechanism.
And that as they say is that. A sequential four input trigger circuit, but perhaps more importantly, I hope to have illustrated the logical steps involved in developing something a little more complicated.
The Finished Design
The image below (click the thumbnail to view it) is the final design (actually version 2) of my 4 input sequential trigger. This is included in my LittleBigPlanet logic work book which is available to download in the sidebar. The colours of switches and pistons indicate the interconnects. The colours around the -C-s indicate the colours of the magnets and switches used in that area.
My plan (in my logic workbook):-
And, a Google SketchUp model of the finished article (this obviously does not show the wiring or the pistons):-
The colours of the blocks indicate their purpose. Green are the input state stores, yellow are the out of sequence detectors, brown are the final output AND gate and blue are the reset OR gate. The switches are coloured to ensure there is no cross over from different channels, so pick them as you see fit.
And that concludes this section on a more complex logic control device. The next section covers the use of emitters to create timing devices, and adds to this by providing the design for an automatic reset timer for the ST (i.e. you have X seconds to activate the switches before it automagically resets).