Too much input - Page 1
Forum section: electronics / beginners

author: Nicals
author_rank: Newbie
timestamp: May 06, 2017, 09:04:31 am
content: Hello,I have a project with 15 inputs button for a control panel. I want to control this using the fewest data line possible. So I decided to use a MCP23018 chip which is a 16 bits I/O extender controlled with I2C. At this point, it seems to work great.But I forgot that I also needed 4 more input, raising the total I/O to drive to 19. The MCP23018 cannot be used anymore.Since 10 of my input buttons comes from a keypad with 1 output by button, I thought I could reduce this number using a decimal to binary encoder and send the reduced number of pin to the MCP23018.I couldn't find any chip reference that can encode those 10 pins to 4 binary binary pins. What reference can I use ?And also important: is there a better way to reduce the number of inputs ?Thanks for your help.

author: Kalvin
author_rank: Super Contributor
timestamp: May 06, 2017, 09:09:52 am
content: You can have up to 8 MCP23018 in the system by connecting two resistors to the ADDR-line for each device. See the datasheethttp://ww1.microchip.com/downloads/en/DeviceDoc/22103a.pdfsection 1.4.

author: sleemanj
author_rank: Super Contributor
timestamp: May 06, 2017, 09:16:47 am
content: Well it sounds like you are not running the keypad as a matrix of keys, so you could do that - arrange keys electrically into rows and columns, you apply power (output high) to each row, and check each column (input) to see if it's gone high, therefore you know which key was pressed (intersection of row and column), rows normally being pulled down, and you send them high, and columns normally being pulled down and you watch for them going high.For 19 keys scanned as a matrix you would only need say 4 rows and 5 columns = 9 I/O linesOf course, this isn't that good if you need to press multiple keys at once.If you are already using an MCP23018, you could always just add another with a different address, that's the point of I2C, you can put multiple devices on the same bus if you give a different address, page 10 of the datasheet has the details on setting the address for the MCP23018.

author: Nicals
author_rank: Newbie
timestamp: May 06, 2017, 09:19:45 am
content: Yeah, I thought at this, but it seems simpler to me to be able to convert my keypad decimal output to binary. This will allow me to have a better data format. And adding a second MCP23018 for only 3 pins is a little too overkill for me.The matrix key seems a good option. I've thought about it but for some reason was stuck on my decimal to binary idea.But I would prefer not to have to add some key scanning operation for only a few missing pins...

author: madires
author_rank: Super Contributor
timestamp: May 06, 2017, 10:28:06 am
content: Or you could replace the MCP23018 with two analog input pins of the MCU and two resistor ladders.

author: sleemanj
author_rank: Super Contributor
timestamp: May 06, 2017, 11:37:59 am
content: Quote from: Nicals on May 06, 2017, 09:19:45 amThen what you are looking for is a BCD Encoder, like the 40147, 10 lines in, 4 lines out, in priority order (so a 9 input overrides a 1 input)http://www.ti.com/product/CD40147B