Protecting I/O pins of I/O expander

Discussion in 'Embedded Systems and Microcontrollers' started by Juul, Dec 26, 2014.

  1. Juul

    Thread Starter New Member

    May 7, 2014
    4
    0
    Hi,

    I'm planning to use many MCP23017 I/O expanders in a home automation system to
    • observe switches (pressed or not) (Niko switches)
    • control LED's which are built into the Niko switches
    • switch relays (Omron) and impulse switches (Eltako)
    Hence, the need for many MCP23017 I/O expanders.

    Obviously, I want to protect the pins of the MCP23017, especially the pins used as input. Therefore, I came up with the following scheme:

    io_expander_with_switch_input.png

    The switch is put into the wall in different rooms, all cables from the switches are coming to the PCB's in a star form. Hence, some cables can be up to 15 meters of length.

    In the above drawing, I've put Schottky Barrier diodes of type 1N5818 to protect against over- or under voltage. Is this a good approach or should I better take zener diodes with a zener voltage of 5.1V (MCP23017 is powered with +5V)?

    The 3k3 resistor is used as pull-up resistor, to give a stable voltage to the input pin of the MCP23017, in case the switch (button) is not pressed.

    The R1/C2 network is used to filter spikes and also to avoid contact bouncing (RC constant is about 50 ms).

    Is this, in general, a good approach to protect as much as possible the pins used as input for the MCP23017?

    Any suggestions, remarks, corrections, improvements are highly appreciated.

    Best rgds,
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,436
    3,360
    Interesting problem. Obviously you have given this some serious thoughts.
    Have you considered using opto-isolators?
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    OK, so you have 30 meters of wire between a switch and a 5V power source.

    Just what dangers are you looking to protect against? Shorts to the AC line? Lighting? Al Qaeda?
     
  4. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,675
    2,724
  5. Juul

    Thread Starter New Member

    May 7, 2014
    4
    0
    Just want to avoid that my IO expanders will be destroyed by:
    • spikes on the net; e.g. switching on/off a water pump, a vacuum cleaner,... All devices that can generate noise in a household electrical circuit
    • ESD, caused one way or another by touching the switches
    • noise picked up by the cables (I've used UTP cable to connect my switches to my PCB's)
    • in case I would go for an interrupt driven mechanism: avoid having false interrupts caused by spikes
    • indirect uplift of the power due to lightning strokes (not lighting...)
    In short, I just want to be on the safe side, since that will be the base control of my house.

    Best rgds,
     
  6. Juul

    Thread Starter New Member

    May 7, 2014
    4
    0
    No, not really... If one such component could replace all the components I'm planning to use and solve all the issues I'm "worried" about, it would be worth investigating it. Any examples for this?

    Best rgds,
     
  7. Juul

    Thread Starter New Member

    May 7, 2014
    4
    0
    Do you also cover contact bouncing with this circuit?

    Best rgds,
     
  8. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Jull: Just about any way of protecting an input is fine for this use. There are several benefits with joeyd999's circuit though it does not block contact bounce. But unless your software is pushing 100% of available cycles to perform it's tasks then "contact bouncing" is best handled by code then by hardware. Consider dumping those tasks under "input validation" rather than a simple debounce and ask yourself what a valid press looks like?

    How long can it be before something else happens (like an auto repeat)?

    How short can it be until it seems unlikely a human knowingly pressed the button that fast?

    If you use a simple interrupt to detect a keypress you are limited in ways of validation.

    I would not be surprised if your final program spends 99% plus of it's time in a tight loop just waiting for something to happen it needs to respond to.
     
  9. John P

    AAC Fanatic!

    Oct 14, 2008
    1,632
    224
    If you're really worried about destructive voltages on the inputs, use an entirely separate system with its own power supply, and then have optical isolators on each line.

    Contact bounce is a trivial problem that people allow to become important. Just avoid reading the inputs too frequently, and the job is basically done.
     
Loading...