Intrigued by the simplicity of setting up an MCP23017 I2C chip and easily getting 16 General Purpose input/output pins, my mind turned to using the chip to make an I2C connected HD44780 character LCD device. The breakout board has proved useful for other purposes as well.
In 8 bit mode an HD44780 based LCD needs 8 data connections, and 3 control connections (Enable, R/W, and RS) leaving 5 GPIO lines for other purposes. I used one of the lines for controlling the LED back light on the LCD - the MCP23017 can provide upto 25mA output current which was more than enough for an adequate backlight.
In 4 bit mode only 4 data and 3 control lines are needed leaving 9 lines for other uses. However, the I2C bus running as the usual 100KHz is not the fastest bus, and driving the LCD in 4 bit mode needs twice as many I2C write transactions for each byte written to the display. I believe some commercially available I2C adapters for LCDs use the MCP23017 connected to the LCD for 4 bit mode.
The circuit is pretty simple. Each 8 bit port of the chip is brought out to the edge of the board - to header pins for GPIOA, and to a header socket for GPIOB. The 16 pin header socket is provided to be able to connect an LCD display with a standard 14 pin straight connector, along with the LCD backlight anode/kathode bought out to pins 15/16. The Anode is fed from the output of GPIOA line 4. GPIOA lines 5, 6 and 7 are patched to LCD RS, R/W, Enable lines respectively. The LCD lines 1 and 2, 0v and 5v, are patched to the I2C bus connector pins which provide ground, 5v SDA and SCL lines.
GPIOA lines 0, 1, 2 and 3 are free for any other use, e.g. connecting a sounder to provide an alarm function, or to use as inputs for connecting a few switches.
The address lines are pulled high by default, giving an I2C address of hex 27. 3 pairs of header pins are provided between the address pins and ground so that any combination of address pins can be selected to give any address between hex 20 and hex 27 ...
A2 A1 A0 Hex address J J J 20 all jumpers fitted J J - 21 J - J 22 J - - 23 - J J 24 - J - 25 - - J 26 - - - 27 no jumpers
If you want to set a fixed address simply wire the Address pins as necessary to 0v and V+ and omit the jumper setup.
INTA and INTB are simply brought out to header pins and are available.
Of course the board does not have to be used for driving an LCD module, it can be used for other purposes. I made up a simple R2R DAC ladder on stripboard with right angled headerpins to connect to the GPIOB header socket and the ground on socket pin 16. This made a very simple 8 bit DAC.
I used a piece of 0.1 inch stripboard 25 by 16 holes. Apologies for the low contrast images, they are scans of pencil drawings.
I've written software for Linux to drive the MCP23017, which uses standard I2C Linux kernel devices to read and write to the MCP23017 registers. This was developed and tested on a RaspberryPI device, but should be Linux generic.
Please email - see below - about the software.
WARNING: For this design the RaspberryPI I2C lines were connected through bi-directional 3.3v to 5v converters, and power was taken from the 5v line. This provides the 5v needed for the LCD module.
If the board is not used with an LCD module, then the MCP23017 will work from 3.3v and connect direct to the RaspberryPI lines. In this case, DON'T connect voltages higher than 3.3V to the pins of the MCP23017 chip, or you could damage it.
Jim Jackson <firstname.lastname@example.org> Tue Mar 26 22:55:54 GMT 2013
This document was generated using AFT v5.095