Tutorials:Controlling devices with multiple switches

Consider the situation where you have two doors into a room, each with a light switch next to it, or a switch at the top and bottom of a flight of stairs. Either switch needs to be able to control one or more common lights (say you want to be able to turn the lights on at one side of the room, walk to the door on the far side and turn the lights off with the switch next to that door). In real life, this trick is done using some clever wiring - I wanted to try doing it in dromed using nothing but fnords. What I ended up with is this (borrowing some symbols from digital electronics):

Tutorial-MultiSwitch.png


(Note: this is actually an implementation of an exclusive-OR gate..)

The "Any" object is a RequireAnyTrap (an OR gate), the two "all" objects are RequireAllTraps (AND gates) and Inv is an Inverter. S1 and S2 are the input switches, O is the output (which may be one or more objects). To set this up in Dromed: Place your two switches, call them S1 and S2. Add the objects you want to control - lights, doors, whatever. Add one RequireAnyTrap fnord and rename it Any. Add two RequireAllTrap fnords and call them All1 and All2. Add one Inverter fnord, call it Inv. Add a ControlDevice link from S1 to Any. Add a ControlDevice link from S1 to All1. Add a ControlDevice link from S2 to Any. Add a ControlDevice link from S2 to All1. Add a ControlDevice link from Any to All2 (line a on the diagram). Add a ControlDevice link from All1 to Inv (line b on the diagram). Add a ControlDevice link from Inv to All2 (line c on the diagram). Add ControlDevice links from All2 to all the controlled objects.

To see how this works, have a look at this truth table:

  S1 S2 a b c out
1:OffOffOffOffOnOff
2:On OffOn OffOnOn
3:OffOn On OffOnOn
4:On On On On OffOff

For example, say that initially both switchs are off (line 1). You enter the room and frob S1. Now S1 is on and S2 is off - the output of the RequireAnyTrap is On, the output of All1 is off, but the Inverter changes this to On. So now All2 is seeing On at both of its inputs, so it send out On to the controlled devices. Now say that you walk across the room and leave, frobbing S2 on the way out. Now we move to line 4: S1 and S2 are on. The RequireAnyTrap outputs On, All1 outputs On, but now the Inverter changes that to Off, so All2 is now seeing one On and one Off - so it sends an Off to the controlled objects. Some time later you come back into the room via the door next to S1. Remember that S1 and S2 are still both On. You frob S1, moving from Line 3 to Line 4. This creates the same state as on line 2, All2 sends On to the controlled objects.

The only fly in the ointment with this method is that the Inverter needs to be "primed" with an Off before the system works properly. This only needs to be done once at the start of the level.

Authors

  • gravatar The Watcher [userbureaucratsysopPHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+]

Looking for something?

Use the form below to search the wiki:

 

Still not finding what you are looking for? Contact us so we can take care of it!