Library attached for using the MCP23018 16 bit I2C I/O expander chip. It's similar to the MCP23017, but the pinout is different and it has open drain outputs (not push-pull).
The I2C bus address is set by cahnging the voltage on the address pin. The default address in the library is 0 (address pin connected to Vss) but this can be overriden by defining MCP23018_Addr in the program code. At present, only 1 device on the bus is supported.
I built this chip onto a board to use with a keypad so there are functions included for reading the value of a 4x4 keypad. The schematic is below - if you have something different then you will need to alter the library to suit, and also the keypad map.
I am waiting for some similar I/O expanders which I will add into the library in due course.
Interesting Peter. I just remembered I got five mcp23017 chips that I haven't used and I'll ckeck your code as first post I've seen for similar. I thought of many uses including driving a glcd with lots of pins.
Thanks for sharing. Nice one.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
True Chris. I hadn't noticed. I forgot I had the chips to until I saw Peter's post. Thanks for the update.
They look fast-
• High-Speed I2C Interface (MCP23017):
- 100 kHz
- 400 kHz
- 1.7 MHz
• High-Speed SPI Interface (MCP23S17):
- 10 MHz (maximum)
•
from uchip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Excuse me, if that comes across as a schoolmaster.
The new homepage has a search function, which spits out the following when searching for 23017:
HARDWARE ACCESSORIES
mcp23017 i2c to serial a library that supports the i2c to serial functions.
mcp4xxxdigitalpot digital pot a library that supports the mcpxxxx
range of digital potentiometers. mcp7940n clock
The description of all Libraries are available online, one have to find only ;-)
Last edit: bed 2017-12-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry if I'm intruding, I have a pair of MCP23S17 expander but I do not know how to use them. On the pinout I see that it uses an SPI interface with commands on CS, SCK, SO, RESET.
Is there a simple demo where to learn?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I do not see a demo for these chips - but, I am sure one of the guys in this thread will create some demos - I can then pick up and put in the GitHub library.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You could try changing the mcp23017 includes..there a new one in projects, i2c to spi. See demos/spi. Are they the same operation ie setting address tieing pins?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The MCP23S17 has the same pinout except the NC/I2C pins are swapped for a CS and the SPI connections.
Registers are the same, but obviously it sends SPI packets instead of I2C. Figure 3-3 of the datasheet is great for explaining how the I2C interface works but I can't see a corresponding one for SPI.
I've only tried SPI devices a few times and failed to get them to work on every occasion so stick to I2C.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'll have a go at converting existing code from the forum to spi. 5 minute job :)
The spi stuff I use with gcb works fine if I wire it correct. Any problems have been 3.3V or 5V logic levels.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Library attached for using the MCP23018 16 bit I2C I/O expander chip. It's similar to the MCP23017, but the pinout is different and it has open drain outputs (not push-pull).
The I2C bus address is set by cahnging the voltage on the address pin. The default address in the library is 0 (address pin connected to Vss) but this can be overriden by defining
MCP23018_Addr
in the program code. At present, only 1 device on the bus is supported.I built this chip onto a board to use with a keypad so there are functions included for reading the value of a 4x4 keypad. The schematic is below - if you have something different then you will need to alter the library to suit, and also the keypad map.
I am waiting for some similar I/O expanders which I will add into the library in due course.
Last edit: Peter 2017-11-19
Keypad demo video here:
And an image of the BodgeBoard™ used to add in the pullup resistors which were omitted from the PCB design!

And here's a simple LED chaser demonstration, showing how to use the port as an output.
Last edit: Peter 2017-11-19
@Peter. May I lift the library (from here? or, do you have a later version?) and demos etc and include in the next distribution?
Let me know please.
Interesting Peter. I just remembered I got five mcp23017 chips that I haven't used and I'll ckeck your code as first post I've seen for similar. I thought of many uses including driving a glcd with lots of pins.
Thanks for sharing. Nice one.
Strange that it is the first you have seen Stan.
The .../GreatCowBasic/Include folder has:
MCP23008.h
MCP23017.h
and
PCF8574.h
So the three most common port expanders have built in support alraedy.
The MCP23018 will be a nice addition.
True Chris. I hadn't noticed. I forgot I had the chips to until I saw Peter's post. Thanks for the update.
They look fast-
• High-Speed I2C Interface (MCP23017):
- 100 kHz
- 400 kHz
- 1.7 MHz
• High-Speed SPI Interface (MCP23S17):
- 10 MHz (maximum)
•
from uchip
Excuse me, if that comes across as a schoolmaster.
The new homepage has a search function, which spits out the following when searching for 23017:
The description of all Libraries are available online, one have to find only ;-)
Last edit: bed 2017-12-02
I could not find a mcp23017 demo. I can find how the mcp23017 works but not how to use the include without examining it.
We must have missed this device.
@Stan. Are you up to writing a simple example that we can publish?
I have mcp23017 chips if they are similar enough. I thought about using the 23017 to drive 2 stepper motors
Sorry if I'm intruding, I have a pair of MCP23S17 expander but I do not know how to use them. On the pinout I see that it uses an SPI interface with commands on CS, SCK, SO, RESET.
Is there a simple demo where to learn?
I do not see a demo for these chips - but, I am sure one of the guys in this thread will create some demos - I can then pick up and put in the GitHub library.
thank you so much. I will follow the topics.
You could try changing the mcp23017 includes..there a new one in projects, i2c to spi. See demos/spi. Are they the same operation ie setting address tieing pins?
The MCP23S17 has the same pinout except the NC/I2C pins are swapped for a CS and the SPI connections.
Registers are the same, but obviously it sends SPI packets instead of I2C. Figure 3-3 of the datasheet is great for explaining how the I2C interface works but I can't see a corresponding one for SPI.
I've only tried SPI devices a few times and failed to get them to work on every occasion so stick to I2C.
I'll have a go at converting existing code from the forum to spi. 5 minute job :)
The spi stuff I use with gcb works fine if I wire it correct. Any problems have been 3.3V or 5V logic levels.