Question about muxing button & switch inputs

This forum is for posts that might be considered off-topic but that may be useful or interesting to members. Examples include posts about electronics or programming in general, other microcontrollers or interesting devices, useful websites, etc.
Post Reply
cerickson
Posts: 45
Joined: 20 May 2008, 15:50 PM
Location: Waikoloa Village, HI, USA
Contact:

Question about muxing button & switch inputs

Post by cerickson »

I have a need to mux together up to 16 digital inputs, made up of pushbutton switches and some toggle switches. I also want to add debounce and the ability to trigger an interrupt pin when one of the switches changes state.

So far I have been looking at the HP4067 A/D mux, the Max6816 debouncer and maybe a couple of octal input gates. However I have the feeling I am going about this all wrong and that there is an elegant solution out there that will do everything I want and not need more than I/O 6 pins.

Anyone have any ideas they would be willing to share?

Thanks in advance!
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Question about muxing button & switch inputs

Post by dkinzer »

cerickson wrote:So far I have been looking at the HP4067 A/D mux, the Max6816 debouncer and maybe a couple of octal input gates.
You might want to consider using an I2C I/O expander like the PCF8574 instead of the analog multiplexor. With that arrangement, you'd need the two I2C signals and one (or two) inputs for the state change interrupt.

You may be able to do the debouncing in software - you can find software debouncing code using and I/O expander on the Internet.
- Don Kinzer
rosariote
Posts: 39
Joined: 22 July 2007, 10:12 AM

Post by rosariote »

Hi,
Also you can use the PCA8575. It is a 16 bit digital input and an interrupt if one of the input signal changed. I never used it but it was in my list in case ran of inputs in one of my projects.
cerickson
Posts: 45
Joined: 20 May 2008, 15:50 PM
Location: Waikoloa Village, HI, USA
Contact:

Post by cerickson »

Thanks guys. I'll research both suggestions.

I am trying to save the I2C connection for a mess of sensors so I am not sure I want to put mission-critical control switches there as well.

You can tell that I am treading in new territory here!
cerickson
Posts: 45
Joined: 20 May 2008, 15:50 PM
Location: Waikoloa Village, HI, USA
Contact:

Post by cerickson »

Hmmm...

On first glance it looks like a bouncing contact isn't very compatible with how the interrupts work with either of these chips.

Or am I misinterpreting the spec sheets?
rosariote
Posts: 39
Joined: 22 July 2007, 10:12 AM

Post by rosariote »

Hi,
You can use a resistor and capacitor to clean the contact closure bouncing or you can do software wise like as dkinzer already suggested. Also you can share the I2C signals for all the chips as long they have an enable chip signal. Just enable the one you want to address.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

cerickson wrote:On first glance it looks like a bouncing contact isn't very compatible with how the interrupts work with either of these chips.
It is possible that you'll have to use the debouncing chips and feed the de-bounced signals to the I/O expanders.

Also, you could have two I2C subsystems - one using the hardware I2C controller and one doing software I2C on any two pins.
- Don Kinzer
Post Reply