Author Topic: Too much input  (Read 1384 times)

0 Members and 1 Guest are viewing this topic.

Offline Nicals

  • Contributor
  • Posts: 5
  • Country: fr
Too much input
« on: May 06, 2017, 09:04:31 am »
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.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 1783
  • Country: fi
  • Embedded SW/HW.
Re: Too much input
« Reply #1 on: May 06, 2017, 09:09:52 am »
You can have up to 8 MCP23018 in the system by connecting two resistors to the ADDR-line for each device. See the datasheet http://ww1.microchip.com/downloads/en/DeviceDoc/22103a.pdf section 1.4.
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 2361
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Too much input
« Reply #2 on: May 06, 2017, 09:16:47 am »
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 lines

Of 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.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline Nicals

  • Contributor
  • Posts: 5
  • Country: fr
Re: Too much input
« Reply #3 on: May 06, 2017, 09:19:45 am »
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...
« Last Edit: May 06, 2017, 10:14:28 am by Nicals »
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 4706
  • Country: de
  • A qualified hobbyist ;)
Re: Too much input
« Reply #4 on: May 06, 2017, 10:28:06 am »
Or you could replace the MCP23018 with two analog input pins of the MCU and two resistor ladders.
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 2361
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Too much input
« Reply #5 on: May 06, 2017, 11:37:59 am »
Yeah, I thought at this, but it seems simpler to me to be able to convert my keypad decimal output to binary.

Then 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
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf