Arduino I2C corrected

advertisement
Arduino I2C (MCP 23017) LCD Interface
This article outlines the construction of an I2C serial interface to a Hitachi HD 44780 LCD. This is implemented with the use of Microchip’s
MCP 23017, 16-Bit I/O Expander with Serial Interface. You could go out and buy an all-in-one commercial serial LCD but I like to build things from
“scratch”, thus hopefully gaining a more comprehensive understanding along the way. I decided to build this project because I have been promising
myself for months that I would replace the veroboard prototype of this interface, that I have been using as the display for my hot water system
Powermeter/logger. Once again I didn’t want to use SMD, my eyesight isn’t the best and I have pretty big hands! Also I like to be able to socket
ICs, as this makes repair and troubleshooting much easier. Obviously the down-side of this approach comes at the cost of valuable board real estate.
Hey, I guess the bottom-line is, I like to make my own boards and I don’t have “sophisticated” board fabrication technology at my disposal. I must
stress that to attempt this project you will need “good soldering skills”, yes I know that’s pretty relative, read the article and you be the judge but
at least you have been warned.
A single-sided PCB, using several wire links was fabricated using the Toner Transfer method and a GBC/Creative A4 laminator. The etchant used
was 12% v/v Hydrogen Peroxide, 28% v/v Hydrochloric Acid mixed in the ratio of 1:2. Please note this etchant is a powerful oxidising agent and needs
to be treated as such. A bit of basic chemistry, the ARROW rule applies here big time, always add the acid to the Hydrogen Peroxide!
The I2C approach was chosen because if a 4 or 8 bit parallel interface were used it’s too greedy with the existing Arduino IO lines. This interface
ties up just four Arduino wires, SDA, SCL, GND and 5 volts. The board has been designed to provide quite a degree of flexibility. The board in
it’s standard setup enables the MCP 23017 to control the HD 44780 with GPA0-7 data bits and GPB6-7 data bits. This leaves six free IO lines,
GPB5-0 free, to interface to anything you like. This is reduced to five if you decide to use GPB5 to control pin 5(R/W) of the HD 44780, which can
be used to access programmable characters in the HD 44780 RAM. Provision has also been made to be able to control the HD 44780 backlight by
using GPB4 to control a switching transistor. This reduces the available IO to four lines, GPB3-0, which is still pretty handy if you want to add a few
buttons/switches or the like. This flexibility is easily configured using the four jumpers, JP1 to JP4.
As far as software is concerned for this project you will need to use the wire.h library. There are many examples of using this library to get the
I2C up and running ... just a google away! Eons ago I came across an article by Lewis Loflin, “Connecting the ATMEGA168/Arduino to MCP 23016
and LCD Display”. This excellent article grabs you by the hand and walks, maybe there is a bit of dragging too, you through getting the HD 44780
display up and running with the MCP 23016 chip. The MCP 23017 is essentially just an upgrade with less passives and faster speed options!
The schematic of the project is depicted in( fig i). As you can see it is pretty simple and is built around a Hitachi HD 44780 and a Microchip
MCP 23017. I’ve seen HD 44780 16x2 backlight LCDs for around AUD $7.90 and 16x4 backlight LCDs for around AUD $12.90. The MCP 23017
can be bought for around AUD $1.20, cheap as chips!
(fig i)
Page 1 of 5
If you follow the schematic you can see pretty clearly how to set the jumpers, JP1 - JP4, for what ever configuration you decide to use. The following
diagrams and pictures are designed to be a helpful construction aid... hopefully! Fig (ii) shows the foil pattern for the pcb, which was produced using the
Toner Transfer method.
(fig ii)
Fig (iii) shows the board layout with the pads (green) and routing (blue) on the bottom side of the board and the wire links on the top side of the
board (red).
(fig iii)
Fig (iv) shows the board layout with the wire links (red) on the top of the board and the relevant connection pads (green) on the bottom side of
the board.
(fig iv)
Fig (v) shows the component layout on the top of the board and the relevant pads (green).
Page 2 of 5
( fig v)
Fig (vi) shows the etched pcb. Please note that this photo is of the original pcb foil pattern. I discovered a mistake in the routing after etching
the board. “x” marks the spot, this shorted the base of Q1 (BC327) to +5V. If you have a look at fig(ii) and fig(iii), you will find the “corrected” foil
pattern... sorry about that!.
(fig vi)
Fig (vii) shows the assembled pcb with all components and LCD attached.
(fig vii)
Page 3 of 5
Fig (viii) shows the assembled pcb and the SCL (white), SDA (blue), GND (black) and +5V (red) wires connecting the interface board to the Arduino.
(fig viii)
Fig (ix) shows the completed interface board displaying the time , courtesy of a Dallas DS1307 RTC. Also shown is the ambient temperature in Celsius
courtesy of a Dallas 1621 Thermometer/Thermostat chip. Lastly shown is the Barometric Pressure and the ambient temperature courtesy of a Bosch
BMP 085 chip. The BMP 085 chip readings are erroneous due to it being fed +5 volts instead of 3.3 volts. These three chips are all I2C devices.
(fig ix)
Page 4 of 5
I should mention a couple of rather esoteric things that you should find useful when constructing this board. I used two 8 pin female stacking headers
to implement the LCD1 connector. If you know of anyone who can supply a single 16 pin female stackable header, please let me know? You will need to
cautiously file the two joining ends of the 8 pin stackable headers to get them to fit together properly. Take the filing procedure slowly and adopt
a heuristic approach and you should be able to achieve a good fit. If I can do it, you shouldn’t have any problem! Also when it comes to soldering the
8 pin female headers to the pcb I used a 16 pin male header to align the two 8 pin female headers and then soldered them carefully to the board. When
soldering the LCD1 header I had it slightly elevated from the boards’s surface, allowing just enough room to get a soldering iron tip onto the header
pin and solder it. The reason for the elevation is that I wanted to keep the pcb and LCD as low profile as possible. Once the header is soldered into place
the excess header wire length can be cut off with side cutters. You will need to be careful with the soldering iron when soldering the header to the pcb
otherwise you will have a melted header ... not a good look! Once again, I did it so you ......I also screwed two spacers into position on the other side of
the pcb to fix the LCD and interface board together. See the brass bolts and Teflon spacers in (fig ix).
Good luck with this project, if you attempt it. Any problems .... get in touch with me by email at matthodge@iinet.net.au and I will try to help you
out!
Fig (x) is a photo of the veroboard version of this interface, without the “bells and whistles” of the pcb version. As mentioned previously this little
number has served faithfully as a LCD for my hot water powermeter/logger for many months now. The reason for the much bigger board is because
it’s a veroboard construction and I used a 16x4 LCD panel instead of a 16x2 used in this project. Got to love that Teflon spacer arrangement!!!
(fig x)
Page 5 of 5
Download