The RCX Input Mux 

The way you switch between inputs is by toggling sensor type temporarily between Light, Touch and back to Light. Going to Touch type drops the 8V supply. This is picked up by the D7, D8, C2 & R2 circuit which clocks the 4017 counter. To figure out where the counter is on startup, the input for count 0 is a special case. (Special thanks to Paul Haas for this idea.) By using a 2.2k resistor and the input tied to ground the RCX will read 100 for this channel. The other channels use a 3.9k resistor. This means their readings will never exceed about 91 even with 0v. Remember 0v = large readings and 5v = 0. Once the RCX knows where the counter is, it can just toggle the type and read values. Four more channels can be easily added by adding another 4066 quad analog switch hooked up to O4 through O7 of U1 and move RESET to O8.

You can hook up Touch type sensors between the inputs and ground and get 0 for an open sensor and about 88 for one that is pushed. You cannot hook up Light or Rotation sensors to these inputs because they actually require power to operate and this has been stripped off to run the circuit. There isn't enough power available at an input to power more than one Light sensor anyway. Finally a Temperature sensor can be hooked up, but the values won't be in C or F.

Here is a driver task for the above circuit. It loops until it sees the special 100 value input and then it knows it is locked on. It loops forever toggling the channels and putting the values into variables 20, 21 and 22. Other tasks would use these variables where you would normally use a sensor value. The short waits are there to allow the sensor reading to settle down before reading and going on. It looks like they are necessary for the scheme to work.

Spirit1.BeginOfTask 3
   Spirit1.SetSensorType 0, 3
   Spirit1.While 9, 0, 3, 2, 100
     Spirit1.SetSensorType 0, 1
     Spirit1.SetSensorType 0, 3
     Spirit1.Wait 2, 10
   Spirit1.EndWhile
   Spirit1.Loop 2, 0
     Spirit1.SetSensorType 0, 1
     Spirit1.SetSensorType 0, 3
     Spirit1.Wait 2, 10
     Spirit1.SetVar 20, 9, 0
     Spirit1.SetSensorType 0, 1
     Spirit1.SetSensorType 0, 3
     Spirit1.Wait 2, 10
     Spirit1.SetVar 21, 9, 0
     Spirit1.SetSensorType 0, 1
     Spirit1.SetSensorType 0, 3
     Spirit1.Wait 2, 10
     Spirit1.SetVar 22, 9, 0
     Spirit1.SetSensorType 0, 1
     Spirit1.SetSensorType 0, 3
     Spirit1.Wait 2, 10
   Spirit1.EndLoop
 Spirit1.EndOfTask

 

Click Here to Return to the Main Page