Back to Top

LCD BACKPACK MODULE


Introduction


Image not found...
(Fig1) An LCD backpack module
I recently uploaded a tutorial of how you can use lcd character modules Here . So in this tutorial i will show you how you can
control them through the I2C communication protocol ( also known as Inter Intergrated Circuit or IIC )
with 4 wires instead of 16 in 8-bit mode or 12 in 4-bit mode !!!. ( Power lines are also included to the counting. )
I am really excited about the particular module...
When i first saw it i couldn't understand how valuable the particular module is...
But while i was analyzing and experimenting with it, it was obviously what this module can do....
The heart of this module is the PCF8574 Datasheet here which is an 8-Bit I/O Expander for the I2C bus.
As you will notice furthermore, since this module uses communication through the I2C bus, it requires only two wires for communication, which makes it a PERFECT solution when you want to use it with microcontrollers where don't have much
I/O pins available. ( Such as 8 pins mcu's for example ).
Also when using I2C communication protocol it is possible to cascade more than of those modules!!!.
So by default you can connect 8 boards of this module (since it's internal addressing...) which means that from 2 control wires
you are able to control up to 64 I/Os !!!! or in our case 8 lcd displays!!!! But i realized afterwards ( i found it by the hard way ) ,
that there is one more version of this chip the PCF8574A which is exactly the same as the one above, but with a significant
difference which is the internal addressing of the chip. This difference allows you to use 8 more additional boards through the
I2C bus and control at last up to 128 I/Os !!!! or in our case 16 lcd displays!!!!.
And all that by the 2 wire I2C bus.... Just AMAZING !!!!

PCB Schematic


After these boards were delivered to my address, i searched online to find a schematic or even better a datasheet of this board....
That wasn't easy at all...The only proper datasheet was from adafruit, which refers to a completely different pcb layout..
So after only one schematic i found online, i decided to do my reverse engeeniring, and i ended up to the following schematic...

Image not found...
(Fig2) The schematic of the lcd backpack module.


This module is intented to be soldered on the back of the lcd. The only adjustments that you can do is the contrast of the lcd display, and the addressing of the PCF8574.
But to be honest... the particular version of the pcb has a drawback ( at least to my taste... ) which is that the addressing of the chip, is selected,
by soldering or desoldering the pads from A0 to A3. Instead of that they could have used jumpers so you could easily change the module address.
( But you can also tell me in reverse.. how often do you change the address...?. )

Materials

Resistors
R1 10KOhm Smd (0805)
R2 10KOhm Smd (0805)
R3 10KOhm Smd (0805)
R4 4,7KOhm Smd (0805)
R5 4,7KOhm Smd (0805)
R6 1KOhm Smd (0805)
R7 4,7KOhm Smd (0805)
R8 10KOhm Smd Trimmer
Capacitors
C1 X7R 0.1uf
IC
IC1 PCF8574 Remote 8-bit I/O expander for I2C-bus with interrupt
MISC
LED Smd (0805) Red Led

PCF8574 I2C Communication


This project was my first time that i was dealing with the I2C communication protocol. So the necessity of using my logic analyzer was inevitable...
I have used SPI in the past without any problems. I2C on the other hand is similar but yet another protocol, with different speeds, less wires, etc so
precautions should be taken in account.
At the beggining i got frustrated when i attempted to communicate with the PCF8574.
I was trying to get a response but with no success. The reason as it was proven afterwards for failing to get a response from the PCF8574,
was because i was setting a wrong address (Fig6).
Having seen some videos before about this module, most of them mention that the default address without any jumper from A0 to A3 is the 0x27.
But what it is not said, is that this address results when you don't take in account the R/W bit. This bit defines the operation of the PCF8574,
whether to read from it or write to it. ( That means that the library they use somehow deal with this bit. )
So when this bit is set to logic 1 a read is selected, while a logic 0 selects a write operation. So you must always study in detail the datasheet !!!.
Below are the addresses, taken by the chip's datasheet, with all the combinations for both chips.

Image not found...
(Fig3) These are the addresses for both chips. (Click to enlarge)


Since i usually write to lcd's instead of reading them, i have only attached the writing operation mode (output). Now let's see what's happening here....
The master (the microcontroller in our case) initiates a START condition through the I2C hardware module, after that sends a byte (always MSB first) which consists
of the slave address of the module that wants to talk to, with the last bit of this byte to logic 0, where corresponds to write operation as we mention earlier.
After that, the PCF8574/74A acknowledges, and the master then sends a byte with the data from P7 to P0 to the port register.
As the clock line goes HIGH, the 8-bit data is presented on the port lines after it has been acknowledged by the PCF8574/74A.
If a LOW is written, the strong pull-down turns on and stays on. If a HIGH is written, the strong pull-up turns on for 1⁄2 of the clock cycle, then the line is held HIGH
by the weak current source. The master can then send a STOP or ReSTART condition or continue sending data.
The number of data bytes that can be sent successively is not limited, and the previous data are overwritten every time a data byte has been sent and acknowledged.
Below i have attached screenshots when i was experimenting with my logic amalyzer, and the packets i sent and acknoledge.
A brief "chart" or the steps of how to communicate in IIC, is as it follows....

1. Initiate a start condition.
2. Send slave address with operation(Read, Write), and wait for acknowledge.
3. Send byte1 and wait for acknowledge.
4. Do for as many bytes as you want....
5. Initiate a stop condition, or initiate a start condition again, to command another slave and start over from step 2



Image not found...
(Fig3) The writing mode procedure for PCF8574/74A (Click to enlarge)



Image not found...
(Fig4) This is the packet i captured of the initialazation command, followed by the word hello. (Click to enlarge)



Image not found...
(Fig5) This is a byte that i zoomed in, to be more visible to you the I2C format. (Click to enlarge)



Image not found...
(Fig6) This screenshot was taken when i wasn't able to get a response from the PCF8574 due to the wrong address. (Click to enlarge)



Image not found...
(Fig7) This packet consists of two texts, on two lcd displays, including initialization. You can also see the start condition on the second lcd address.
(Click to enlarge)



Since we are talking for 4-bit mode transmittion, each transmitted byte that it is sent to the lcd, it is broken in two...

On the first transmittion the byte carries in it's upper nibble, the upper nibble of the command or the data that it will be sent to the lcd, and in the lower nibble,
it has always the read-write operation of the LCD, which are the enable control of the lcd, the control of the lcd backlight, and the command or data operation.

In the second and the final transmition, it has in its upper nibble , the lower nibble of the command or the data , and in it's lower nibble it carries once again,
the read-write operation of the LCD, the enable control of the lcd, the control of the lcd backlight, and the command or data operation.

More info it will be provided in the library that i will upload below. I will also not analyze more the I2C bus in this topic, but i will probably make a theory page of how
the I2C protocol works.


Pinout Description


Image not found...
(Fig8) The pinout
of the module.
(Click to enlarge)

Although there is no need for pinout description since this module fits at the back of the lcd,
it won't matter to make a brief analysis that came out from my reverse engeenering.

From below there are:
Gnd Power Supply -
Vcc Power Supply +
Vo goes to contrast pin of the lcd.
P0 goes to RS pin of the lcd.
P1 goes to R/W pin of the lcd.
P2 goes to Enable pin of the lcd.
P3 goes to the base of the transistor that controls the backlight of the lcd. (By software.. the ground pin(NPN))
P4 goes to DB4 pin of the lcd.
P5 goes to DB5 pin of the lcd.
P6 goes to DB6 pin of the lcd.
P7 goes to DB7 pin of the lcd.
Led+ goes to lcd's backlight. (This pin has in series the jumper that deactivates by hardware the lcd's backlight)
Led- goes to lcd's backlight.
X pins are not connected anywhere. (Since this is dictated from the lcd's datasheet.)



Desigh Requirements


This section is just for reference.... This section must be taken in account when you are designing a pcb with the PCF8574/74A or using multiple devices
on the I2C bus, since there is a capacitance limitation on it.
Taken from TI datasheet:

The pull-up resistors, RP, for the SCL and SDA lines need to be selected appropriately and take into consideration the total capacitance of all slaves on the I2C bus.
The minimum pull-up resistance is a function of VCC, VOL,(max), and IOL:

Image not found...
The maximum pull-up resistance is a function of the maximum rise time, tr300 ns for fast-mode operation, fSCL = 400 kHz) and bus capacitance, Cb:
Image not found...
The maximum bus capacitance for an I2C bus must not exceed 400 pF for standard-mode or fast-mode operation. The bus capacitance can be approximated by adding
the capacitance of the PCF8574 device, Ci for SCL or Cio for SDA, the capacitance of wires-connections-traces, and the capacitance of additional slaves on the bus.

Image not found...



Video


And here's the video with the module in action.....

COMING SOON.....

Follow me on tweeter and stay tuned with Electronicsgate.com