[SOLVED] Arduino to LCD via PCF8574A

Hi All,

I am trying get a schematic drawn but the trim in the picture attached is rather confusing. Could somebody please advise how the attached 'Arduino LCD' relates to the actual trim pot in the ' IB schematic' attached


IB schematic

Arduino LCD

Thanks in advance

Hi,
In IB
pin1 of JP2 is gnd,
pin2 of JP2 is +5V.

S of the trimpot goes to pin3 of JP2
A of the trimpot goes to pin 1 of JP2
E of the trimpot goes to pin2 of JP2.

trimpot forms a potential divider across +5V and gnd, the S terminal, which is the pot wiper, then provides a voltage of between 0 and 5V to the CONTRAST pin3 of the LCD.

Your R1 should be 470R not 470K, and it goes from pin2 of JP2 to pin15 of JP2.

Note; you have S connected to 5V.

Tom... :slight_smile:

Thank you Tom.

Appreciated.

This could be similar to your circuit: I2C LCD Backpack - PCF8574 [4585] : Sunrom Electronics.

Thank you 6v6gt.

Do these work on on 20x4 LCD as well ?

So it claims:

Convert any standard 16 pin LCDs like 8x1, 8x2, 16x2, 16x4 and 20x4 LCDs with this I2C backpack. Easy to use and occupies just 2 MCU I/O.

However, the pin mapping for ports P0 to P7 of the pcf8574 may differ depending on the module. This means that the following or similar statements in the sketch may have to be adapted:

#include <LiquidCrystal_I2C.h> 
. . .
#define BACKLIGHT_PIN  7
#define En_pin  4
#define Rw_pin  5
#define Rs_pin  6
#define D4_pin  0
#define D5_pin  1
#define D6_pin  2
#define D7_pin  3
. . .
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

Hi,

Here's the schematic I use:

I think that makes it clearer how the pot is connected.

The usual LCD Backpack modules are also useable as general-purpose digital I/O. I started selling them as separate parts HERE

DISCLAIMER: Mentioned stuff from my own shop...

I use a 20x4 with a backpack which i had bought from ebay and to add a UI i was thinking of customizing it by adding two switches and a rotary encoder for a project of mine.

Thank you everyone for the replies.

6v6gt:
However, the pin mapping for ports P0 to P7 of the pcf8574 may differ depending on the module. This means that the following or similar statements in the sketch may have to be adapted:

Or....
If you use my hd44780 package with the hd44780_I2Cexp class (which is available in the library manager), you don't have to mess with manual configuration as it figures out the i2c address, pin mappings, and backlight control at run time to auto configure itself.
See here for more information: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library

There is also some information on the wiki.

--- bill

Bill,

Getting time to try out your library has been On My List for too long... Sigh..

After this next MakerFaire...

Hi,
@terryking228, thankyou thankyou thankyou

Now that above is better than this below;

You don't have to play search a word, and you can SEE signal flow.

Tom... :slight_smile:

I tend to agree that terryking228's version is generally nicer and that the one I found was extremely sparse.

However, I believe it is sometimes better to get the user to play "search a word" than to present him with a diagram where every possible path is represented by an explicit line connection. For example, I find this very difficult to follow (although I use it myself because I have not found - or created - a sparser version) Arduino Nano (CH340G) based USB-TTL adapter - Exhibition / Gallery - Arduino Forum.

Hi,
Yes, some diagrams have layout problems that are hard or impossible to fix a rats-nest of wires on paper, some searchaword may be needed.
That one you cited is a good example, but not the whole diagram as searchaword.

I find searchaword does not tell you that a pin labelled say AUX may be connected to more than one other component in the schematic.

Tom... :slight_smile:

terryking228:
Hi,

Here's the schematic I use:

I think that makes it clearer how the pot is connected.

The usual LCD Backpack modules are also useable as general-purpose digital I/O. I started selling them as separate parts HERE

DISCLAIMER: Mentioned stuff from my own shop...

Hey terry thanks for sharing. I will use this in my project as well rather the one i had posted.

I know this was marked as solved, but I guess I'm a bit confused as to what the issue with the original schematic was from a visual perspective.
If you look at the image in its full size, the schematic seemed pretty clear on how to wire things up.

In the larger picture, how the PCF8574 is wired up to the LCD and the backlight circuit design affects the library software in a very big way.

The original circuit, the circuit that 6v6gt posted, the circuit that TerryKing provided are all different.

Some libraries hard code the pin mappings and backlight control (LiquidCrystal_I2C in the library manager),
some allow full manual configuration (fm's newLiquidCrystal and hd44780)
and hd44780 can auto detect the pin mappings and back light control active level.

There are some things to consider:
While any circuit design can be made to work with fm's newLiquidCrystal and hd44780,
Depending on the circuit, it may not work with the LiquidCrystal_I2C library.
Depending on the circuit, hd44780 may not be able to auto detect the backlight control active level.

There are 3 different circuits shown in this thread:
#1 is what is the orignal post
#2 is what is in the 6g6vt schematic
#3 is what is in the TerryKing schematic
Here is the wiring for each:

LCD      1   2   3 
RS      P6  P0  P4  
EN      P5  P1  P5  
RW      P4  P2  P6  
D4      P0  P4  P0  
D5      P1  P5  P1  
D6      P2  P6  P2  
D7      P3  P7  P3
BL      P7  P3  P7
BLlevel HI  HI  LO

My recommendation would be use a circuit that matches what the LiquidCrystal_I2C library expects as it offers the most flexibility in terms of s/w libraries.
That way:

  • LiquidCrystal_I2C library from the IDE manager will work
  • hd44780 hd44780_I2Cexp i/o class can auto self configure everything
  • fms' newLiquidCrystal library LiquidCrystal_I2C i/o class can be manually configured to work
  • hd44780 library hd44780_I2Cexp i/o class can be manually configure to work.

Of those 3 circuits posted in this thread, only the 6g6vt board is wired that way, but the backlight circuit will confuse hd44780 auto detection.
The original circuit was wired in a way that I've never seen any other backpack use
(And I've seen pretty much every backpack design).

While the wiring in the TerryKing schematic should allow hd44780 to auto self configure,
I would recommend wiring up the LCD to use what LiquidCrystal_I2C library expects as it is a very common pin wiring used on backpacks and will allow the LiquidCrystal_I2C library to work.

That library expects:

LCD      
RS      P0  
EN      P1  
RW      P2  
D4      P4  
D5      P5  
D6      P6  
D7      P7  
BL      P3  
BLlevel HI

But don't use the backlight circuit from the 6g6vt schematic as that won't allow hd44780 to auto detect the backlight level.
Don't put a pullup on the base of the NPN transistor.

Also when using a NPN transistor there is no need to use a series resistor to the base to limit the current flowing through the transistor to the emitter.
This is because the PCF8574 doesn't really drive the output pin for HI signals. It enables a pullup on the pin. The PCF8574 has no true drive capability. Sink yes, but drive no.
(This is part of their "quasi-static" i/o pin logic)
Because of this, the output current for high signals is already limited to a very small amount.

But when you can get a pre-made LCD backpack delivered to your door for less than $1 USD,
why not just buy a pre-made backpack off Ebay?

--- bill

bperrybap:
. . .
But when you can get a pre-made LCD backpack delivered to your door for less than $1 USD,
why not just buy a pre-made backpack off Ebay?
. . .

In general I agree, but the backpack makes the whole LCD assembly very clumsy, a problem especially if space is at a premium or you want to mount the display directly on a circuit board, then access to the external connectors and the contrast potentiometer is poor.

On one occasion where space was at a minimum I built the I2C interface using a Sparkfun schematic (but mcp16008, not PCF8574 based although very similar in concept) and used the corresponding Sparkfun library. On another, I sandwiched the project's circuit board (actually a prototype board) between the backpack and the lcd and cut back the pins (power/serial) and moved the contrast pot to the board with the rest of the circuit. Fortunately the header pins already soldered to the backpack were just long enough to allow this.

Where I have used the backpack in the standard position, I have often controlled the backlight intensity via the jumper connection which bridges the LED and Vcc using a pnp transitor and pulse width modulation.

bperrybap:
But when you can get a pre-made LCD backpack delivered to your door for less than $1 USD,
why not just buy a pre-made backpack off Ebay?

Generally that is the best option and like 6v6gt said the back just increases the overall width of the lcd and i have an interface board so incorporating the backpack into my UI makes it easier to mount the lcd in a housing. I wish these the LCDs came with the SDA SCL interface built in.

Here is the link to the EAGLE library for the LCD.I found it as i was in need so though i'd share it here just in case some body would find it useful.

If you have height issue with a soldered backpack, you could also use a ribbon cable instead of soldering it directly to the back of the LCD.

But regardless of how the PCF8574 interface circuitry is implemented, I'd still recommend using the pin mappings and backlight active level that works with the LiquidCrystal_I2C library.
As that mapping offers the ability to use the most libraries including hd44780, which can auto self configure the pin mappings.

--- bill