Unbranded 20x4 LCD via i2c ?

Hi All

I've recently bought an unbranded 20x4 LCD display and an unbranded i2c converter, for use with a 28x2 PICAXE project. I already have an AXE033 clock and display, and wanted to add a second display.

However it's proving impossible to get any response from the new display. The only thing I know about it is that the i2c address should be $3F.

I note that there are a lot of previous conversations about displays on here, but I couldn't find anything discussing this combination of parts, and suitable addressing/code.
The parts seem very common on market sites, so I'm guessing someone else has tried this?

All ideas appreciated
 
The i2c converter is based on a PFC8574AT chip (hence the $3F address), and I assume (but don't know), that the display will be based on the HD44780 standard.
 

Jeff Haas

Senior Member
There's a lot of info on those displays in this thread, including sample code:
 

AllyCat

Senior Member
Hi,

The problem is that these displays don't have an intelligent "ASCII" character interface, but each I2C byte contains 4 "control" bits and a 4 bit data nibble, so 2 bytes are required to send each character or control code. All this can be buried somewhere in an Arduino Library file, but must be done explicitly by a PICaxe programme (subroutine). However, there are several PICaxe forum threads with sample program code, such as that linked above.

Another hint is that these 4 row displays are organised with Row 3 as an "continuation" of Row 1 and Row 4 continues after Row 2. Thus the cursor addresses for the first characters in Rows 1 - 4 are typically: $80 (i.e. 128) , $C0 , $94 (i.e 128 + 20 = 148) and $D4 .

Cheers, Alan.
 
Hi Alan

Thanks for that info. I was at a brick wall for quite some time, not knowing if it was a hardware or software problem, but I'm gradually peeling the layers now, with the hints from you and Jeff Haas. I'd worked out the PICAXE version of the i2c address ($7c with address pin A0 held low), and confirmed it by noticing that the right address made the LCD panel flicker slightly. Now, putting that address into the code written by struggles I get an "effect" on the LCD, though not characters yet. I'm sure I'll understand the 4-bit code samples in due course. I did know the weird addressing of the display lines, but appreciate all help/ideas.
Thanks again to all of you on the forum.
Alan (!)
 

Flenser

Senior Member
Latelifecrisis,

When I tackle some new hardware for the first time I like to start with someone else's working code.

To get something displayed on a LCD using one of these PFC8574AT backpacks I can personally recommend Hippy's I2C-LCD.txt code posted here.
- It very conveniently happens to be written for the same 4 line LCD
- If you checkout the next post #29 in the thread you can see that Pekari reported Hippy's code worked straight away for him
 
Hi Flenser
Thanks for your comments.
I've tried using Hippy's code, with the only change being to set my i2c address to $7c. It doesn't appear to work "out of the box". Probably the mapping of the interface chip to the LCD module. But the complication of the 4-bit interface seems to be a lot more than I'd expected. Buying cheap parts through eBay "seemed like a good idea at the time"...

Now I'm re-thinking the whole approach.

I have a PICAXE based controller for a thermal solar panel and hot water tank. It controls various pumps and valves for the whole hot water system, and has been running perfectly for the last 11 years. However, there's now a need to look again at optimising the algorithms to squeeze more energy out of the solar, and less out of the gas boiler(!).

It was based on a PICAXE 28X1 chip, and I had run out of code space. So I've recently transferred the code across to a 28X2 instead, and started expanding into the 4 program slots. The controller uses a 20x4 display, through an AXE033 interface, which includes a real-time clock.

I want to add an extra display for some of the extra functions, but also replace the existing LCD panel, so that I have 2 matching displays. I bought a couple of bare LCD panels, and a couple of cheap i2c adaptor modules. I was planning to replace the existing display at the parallel wire level, and assumed the new units would be compatible with the old (I still hope that's true). But I thought the easiest way to add the second display would be to connect into the i2c "bus".

But seeing how complicated that is, I wonder what others would suggest as the "best" way ?

I wonder if there's any possibility of adding the second display onto the AXE033 board at the parallel interface (with reprogramming of the interface PIC), or finding a pre-owned AXE033 board, or using a serial instead of i2c for the second LCD? If it were possible to buy the serial interface board used in the AXE034Y kit, that might be ideal (again assuming the parallel interface to the OLED display is the same as that for LCD units).

I'd obviously thought of buying two AXE034Y kits, but I really can't justify the cost...
 

AllyCat

Senior Member
Hi,

It really shouldn't be too difficult to get one of those displays running in 4-bit/I2C mode, so IMHO it's worth persevering. The I2C bus is also about the fastest way to get data into or out of a PICaxe (and needs only 2 pins). ;)

Not specifically using the I2C bus, but inglewoodpete described a very useful Code Snippet some years ago.

Cheers, Alan.
 

Flenser

Senior Member
Latelifecrisis,

You said in post #1 "I've recently bought an unbranded 20x4 LCD display and an unbranded i2c converter", in post #5 you've wired the address pin A0 low and then in post #7 you are talking about using two displays. I'm not sure that I've understood your three posts and I suggest your first get these two new unbranded modules working by themselves.

Once you get the new unbranded LCD working with the new unbranded backpack you can move on to driving two LCDs knowing that anything that doesn't work then has to be something other than these two pieces of hardware and the software to drive them.

If your unbranded LCD & PFC8574AT based I2C backpack are both the most common variety the you should be able to simply plug the backpack onto the LCD and connect the power, gnd, SDA and SCL lines between your 28X2 to the PFC8574AT backpack.
Is this what you are trying and are you connecting just the one LCD?

Then on to Hippy's code. Note the comment "So the PCF8547T chip default address of $27 becomes $4E for the PICAXE H2ICSETUP command."
If your I2C backpack chip is marked PFC8574AT then, as you are already aware, it has a different range of I2C addresses from that for the PCF8547T in Hippy's code.
My calculation of the PFC8574AT address with A0 pulled low $3E (00111110) shifted left 1 bit becomes the same 01111100 ($7C) value as you have for the PICAXE H2ICSETUP command.

So if you change the H2ICSETUP command in Hippy's code to use $7C for the address then it should work to drive just this one display.

Full disclosure. I've only have backpacks with the PCF8547T chip so I have not tested what I've described using a PFC8574AT backpack. I'm just working from the PCF8547/PCF8547A datasheet and the PICAXE manual.
 

hippy

Ex-Staff (retired)
I wonder if there's any possibility of adding the second display onto the AXE033 board at the parallel interface
Not at all easily IMO. You would probably be better off using an AXE133 but even then paralleling two displays can sometimes be problematic, may require separate buffering.

Two separate displays with their own drivers would be the way I would go for an easy life.

It may be worth putting what you have under a magnifying glass, seeing what the control chip actually is, trying to figure out how the display is wired to that. Things can sometimes be annoyingly difficult because it's often a case of nothing works until you have got it right.

If it's something which is going to be a useful thing, have a long life - which it sounds like this will - it may be better to spend money up-front to have something which is well documented and/or works out of the box, suck the pain of that up as a small amount when spread over its lifetime. Saving money can sometimes prove to be a false economy in the grand scheme of things.
 
Hi Again guys.

To Flenser - to clarify, I have two PICXAXE28 development boards - one continues to use the 28X1 chip and it's established code, display etc controlling my solar. I've set up connectors so that I can change the new board, with the 28X2, into the operating solar system.

But since I got the new LCD displays the 28X2 board is connected only to one of the new LCD displays with an i2c piggyback "on the bench". As I was trying to understand the i2c addressing, I bridged the A0 address bit on the new i2c board. Now that I've understood the addressing I could undo that, but there's not really any need, and as I said, I'm sure the $7c address is right, as I've seen the display flash in response (as opposed to other addresses I'd tried before). I've used a couple of ribbon cables to connect the i2c to the development board - just the 4 lines soldered between the open ends of the ribbon cables. I've buzzed them through from the pins on the 28X2 to the connector on the i2c board. I'm pretty sure they're right, the display responds etc.

To Hippy - so I got quite optimistic about your very simple demo code as referenced. I changed just the i2c address, and ran it. The effect has been to turn off the backlight, but nothing else.

To check out the differences between your original system and mine, I've buzzed the key pins from the 16 pin display header, back to the pins on the PCF8547AT. As follows:

Code:
Hippy definitions       my display header   PCF8574AT pin      PCF8574AT logic

Symbol bitRS = bit8        ;   pin 4            pin 4              bit 0
Symbol bitWR = bit9        ;   pin 5            pin 5              bit 1
Symbol bitE  = bit10       ;   pin 6            pin 6              bit 2
Symbol bitD4 = bit12       ;   pin 11           pin 9              bit 4
Symbol bitD5 = bit13       ;   pin 12           pin 10             bit 5
Symbol bitD6 = bit14       ;   pin 13           pin 11             bit 6
Symbol bitD7 = bit15       ;   pin 14           pin 12             bit 7
I tried swapping the symbol definitions from "yours" to "mine", ie bitRS=bit0 etc, but no luck.

Thanks so much for your help. Any more ideas?

Alan
 
Last edited by a moderator:

hippy

Ex-Staff (retired)
I took the liberty of putting your table within a code block to make it more readable; hope you don't mind.

I haven't studied it all but, if your 'logic' is correct, then it would seem the SYMBOL definitions are correct. Because, I'm guessing, the code uses 'b1' to hold the bits then 'bit8-bit15' in the PICAXE are the 'bit0-bit7' when they arrive at the chip.

One thing which is worth doing is a power-cycle reset with a few seconds of 'off' when changing bit allocations, to ensure the display does reset properly.
 

Flenser

Senior Member
Latelifecrisis,

You description helps a lot. I'll echo it back to you in my words, so pls correct me if I've missunderstood.
- The unbranded 20x4 LCD display and an unbranded i2c converter are connected to the 28X2 board by 4 ribbon cable wires for power, gnd, SDA & SCL.
- This is the only thing currently connected to the 28X2 board.

I gave you some bad advice because the first thing to do when setting LCD displays is not, as I said, to "simply plug the backpack onto the LCD and connect the power, gnd, SDA and SCL lines between your 28X2 to the PFC8574AT backpack."

The first thing to do is to plug the backpack onto the LCD, connect just the power and gnd to the backpack and adjust the contract pot until you see one line of black rectangles.
See the section "Contract Circuit" on this tutorial page from adafruit.com: https://learn.adafruit.com/character-lcds/wiring-a-character-lcd for a screen shot of the LCD adjusted to show the black rectangles.
- All you have to do is connect power and ground. You don't have to wire up the contrast pot as this has already been done for you on the backpack.

In your case you've already wired up power, gnd, SDA & SCL and loaded code into the 28X2 so you may not get to see the line of rectangles unless you choose to disconnnect one of the I2C lines.
On the other hand you may not have to disconnect anything. All you may have to do is adjust the contrast pot.
If you've seen the display flash using the $7c address then there is something happening and the LCD won't do _anything_ unless it is correctly receiving command codes to initialize it in 4-bit mode, which is what these backpacks use.
if the contract has not been adjusted and the backlight is off then it could be working using the $7c address but the characters are just invisible to you.

FYI, some of these I2C backpacks do control the backlight and in the link I gave you to Hippy's code:
- in post #29 Pekari first reports that Hippy's code worked for him (with his PFC8574 backpack)
- in post #30 Pekari the report that the backlight was turned off. In this case the contrast was adjusted and the LCD characters are clearly visible if the LCD is well lit.

As I suggested, lets get the LCD working with the backlight off first because the only code changes that should need is to set the address to $7C in Hippy's code.
Turning the backlight on is something that I can test using Hippy's code with my PFC8574 backpack which I'll look at after work tomorrow or over the weekend.

I wonder if there's any possibility of adding the second display onto the AXE033 board at the parallel interface
As I understand these LCD display's, Hippy's comment about this is correct. The parallel interface is not described as being able to run more than one display in the LCD datasheet and I've never seen any code that does this.
 

hippy

Ex-Staff (retired)
The i2c converter is based on a PFC8574AT chip (hence the $3F address),
Presumably a typo for PFC8754AT - My datasheet shows the 7-bit Device ID as '0111xxx', which would be 8-bit '0111xxx0', which is '$7x' in hex.. Using $7C would seem correct if A2 and A1 is high, A0 is low.

Looking at your table earlier, everything would seem to be correct to me.

What do you have Pin 3, the contrast pin, on your LCD connected to - Could it be that everything is working but the contrast is too low to see it working ?

When you only connect only the I2C backpack 5V and 0V what do you see on the display ? My expectation would be solid blocks on lines 1 and 3 of the display, at least on line 1 - Cross-posted with Flenser

And, does the backpack have pull-ups on the I2C bus lines ?

I'm remembering why we recommend using the display products we sell to avoid the nightmare of getting arbitrary displays to work :)
 

Flenser

Senior Member
I wonder if there's any possibility of adding the second display onto the AXE033 board at the parallel interface (with reprogramming of the interface PIC), or finding a pre-owned AXE033 board, or using a serial instead of i2c for the second LCD?
You can run as many AXE033/AXE034 boards as you like because it is up to your program to send the commands and text to the correct serout or hserout pins for each LCD.

The I2C protocol allows more than one chip on the I2C bus, so you should be able run more than one I2C backpack LCD by setting different addresses as you've already done. The axe110_i2c.pdf I2C tutorial on the PICAXE website has code for reading the temp from the DS1820 I2C chip and writing it to an I2C EEPROM chip. Note that this pdf uses the readi2c & writei2c commands which are deprecated and have been replaced with the hi2in & hi2cout commands.

I've never done it but I can't think of any reason why you couldn't run one or more AXE033/AXE034 LCDs together with one or more I2C backpack LCDs to make use of what you already have.
 
Hi Again guys.
I'm pleased to say I've got the display working.
I spent quite a while understanding WHY the interface has to be 4-bit, and checking all of the pins on the HD44780 and the PCF8574A. Using that knowledge, and hints from other places, I found that the "missing" bit 3 from the PCF8574A is not connected to any of the 16 pins of the LCD board, but instead to a transistor on the interface board. I guessed that this controls the backlight, so added it into Hippy's program, and voila! Then adjusted the contrast to reveal the text.
So many thanks to Hippy for the elegantly simple demo code, and Flenser for the contrast suggestion (I had tried it before, but it needed to be adjusted when the backlight & text were there to be seen).
What a wonderful thing is a forum...
In case it may be helpful, I attach my very slightly modified version of Hippy's code.
 

Attachments

Top