112 logic inputs encode?

Discussion in 'The Projects Forum' started by themotorman, Nov 17, 2012.

  1. themotorman

    Thread Starter Member

    Jun 13, 2009
    13
    0
    I have 112 switches that can be either 0 OR 5 VOLTS. I need a way to change this so I have one or two lines as serial feed to an Arduino. The Arduino can then process the info and give me an output as the which of the 112 switches are hi or Lo. Normally all switches are hi and I only need to know 1. That any are now lo and it would be great if I knew which switches had changed state. Ideas please.
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,145
    1,791
    PISO (Parallel IN Serial OUT) shift registers. You need a data line, a shift clock, and a shift/load line. The Arduino will:
    1. Set shift/load to "LOAD" which loads all 112 bits
    2. Set shift/load to "SHIFT"
    3. REPEAT 112 times
      • Set clock to "1"
      • Read the data
      • Set clock to "0"
    4. END REPEAT
    The shift registers are connected together in a chain with the output of one going to the input of the next. The last one goes to a digital input on the Arduino
     
  3. crutschow

    Expert

    Mar 14, 2008
    13,018
    3,235
    You could also use multiplexers to select the switch outputs sequentially, but the shift register approach, (such as the 4014 or 4021) as suggested by Papabravo is likely simpler since it requires no address lines. It would require 112/8 = 14 8-bit shift registers.
     
  4. WBahn

    Moderator

    Mar 31, 2012
    17,750
    4,797
    There are a host of alternatives, depending on what is important and where you are willing to put complexity. Which is "best" depends on what is important. That you always be able to determine what the state of a particular switch is, that you know about a change in state of a given switch within a very short amount of time of the change occurring, that you minimize the amount of data that your Arduino has to process, that you keep the cost/size/power to a minimum, etc., etc.. You could use a simple circuit, implemented with something like an 8-pin PIC, at each switch, that monitors the state of the switch and reports its state to the central node using something like I2C or CAN whenever the state changes (and perhaps whenever it hasn't made a report in more than so long an interval). You could then also only poll the switches that you were interested in. Now, with 112 switches, using an 8-pin PIC introduces the problem of how to enumerate the switches. There are a few ways to do this, but it definitely adds complexity.
     
Loading...