Looking for a chip to reduce number of inputs to controller - Page 1
Forum section: electronics / beginners

author: huangwm
author_rank: Newbie
timestamp: October 24, 2018, 05:33:07 pm
content: Sorry if I'm posting in the wrong section.I'm working on a small hobby project where I need to detect a large number of inputs that are assembled in a grid-like fashion. The controller that I am using (arduino/pi) doesn't have that many inputs, so I guess I will need a converter chip to reduce the number of inputs into the controller.I was hoping that the community would give some ideas on what chips I could use, or if there's an alternative idea.Thanks alot!

author: Benta
author_rank: Super Contributor
timestamp: October 24, 2018, 05:43:27 pm
content: The easiest and cheapest solution is normally the 74HC165, especially if your MCU has an SPI interface.

author: mariush
author_rank: Super Contributor
timestamp: October 24, 2018, 05:50:08 pm
content: An option would be I/O expanders:https://www.digikey.com/products/en/integrated-circuits-ics/interface-i-o-expanders/74960 i/o : CY8C9560A-24AXIhttps://www.digikey.com/product-detail/en/cypress-semiconductor-corp/CY8C9560A-24AXI/428-2017-ND/164024848 :Diodes Incorporated PI4IOE5V96248ZLEXhttps://www.digikey.com/product-detail/en/diodes-incorporated/PI4IOE5V96248ZLEX/PI4IOE5V96248ZLEXDICT-ND/8548731PCA9506DGG,518https://www.digikey.com/product-detail/en/nxp-usa-inc/PCA9506DGG518/568-11940-6-ND/5221875loads more with 28, 24, 16 etcThese are mostly i2c , super easy to usesome (for example the diodes inc one above) have an interrupt pin , so you can get an interrupt when one input changes instead of having to constantly read the state of all input pins. but you can do that also, whatever you like more.

author: HB9EVI
author_rank: Frequent Contributor
timestamp: October 24, 2018, 06:08:11 pm
content: +1 for the I/O expanders if I2C doesn't turn out to be too slow

author: dferyance
author_rank: Regular Contributor
timestamp: October 24, 2018, 06:24:20 pm
content: It totally depends on your scenario but there are tricks to have multiple inputs go to the same pins. I've used different resistor values attached to switches and doing analog/digital conversion to know which ones are enabled. Keyboards often multiplex by enabling individual rows or columns in a scan loop. You might even be able to use common IC circuits like multiplexers or logic gates depending on your inputs.

author: mariush
author_rank: Super Contributor
timestamp: October 24, 2018, 08:17:18 pm
content: Indeed, in fact there's an application note / booklet from Microchip called Tips & Tricks where they show how to use ADC and resistors to detect one button press of out many.Here's the link to the PDF document, it's ~ 6 MB:http://ww1.microchip.com/downloads/en/devicedoc/01146b.pdfYou'll just have to keep in mind that the ADC isn't instant, and you may want to take 2-3 adc measurements and average or something like that. Should still be able to measure once every few ms or so. It can also be a pain in the ass to use so many resistors (and you should use 1% tolerance )Another idea would be to have a small micro with a bunch of pins, and use 8 as inputs and 4 or more pins as output to send power to buttons through some resistors (to limit current) .... only send power to one row of buttons at a time and you detect if buttons on that row are pressed or not by reading the input pinsYour micro outputs on RA0, waits a few microseconds and reads PORTB and gets the state of all 8 buttons on first row. Store this in memory. Turn output off on RA0 , turn on output on RA1 .. wait a bit, read port , store second row of buttons in another variable... go through all 4 rows, and you have the 32 button states with just 12 io pinsYou'll need a couple of other pins for I2C or SPI ... so a 16 pin microcontroller in theory would be enough.

author: MudAndSnow
author_rank: Contributor
timestamp: October 26, 2018, 04:10:45 am
content: +1 for multiplexed keypad and adc inputs.If you have enough inputs available you could use limited range of resistors such that the range of voltages is within the threshold to trigger an interrupt so you don't have to run adc and poll all the time. Just wait for interrupt then poll adc.

author: Mechatrommer
author_rank: Super Contributor
timestamp: October 26, 2018, 10:25:47 am
content: if more than one button are pressed, the voltage is not unique anymore. unless the resistors are choosen really carefully to avoid non uniqueness if more than one button are pressed.