The one that came with the LCD I bought is very buggy. Was about to start fixing it but guessed is probably been done before (and probably better!).
Thanks.
The one that came with the LCD I bought is very buggy. Was about to start fixing it but guessed is probably been done before (and probably better!).
Thanks.
I am using LCD library from F.Malpartida for the years without any changes. There is also support for I2C.
I was involved with and wrote some parts of the code in fm's library package so I'm very familiar with it, but I would recommend my new hd44780 library instead. It is faster, and easier to install and use.
It can be quickly and easily be installed using the IDE library manger.
It will also automatically locate the backpack i2c address and auto self configure all the pin mappings so there is nothing that has to be filled into the constructor.
You can read more about it here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
The io class for PCF8574 based backpacks is hd44780_I2Cexp.
It should "just work" out of the box.
The hd44780_I2Cexp class includes a diagnostic sketch (I2CexpDIag) as one of its examples.
The diag sketch will test the i2c pins for pullup resistors and then do a diagnostic ram test on the internal ram of the LCD module.
You didn't state which Arduino board/processor you are using but hd44780 should work on pretty anything.
I've tested on AVR, pic32, and ARM based processors. It also mostly works on ESP8266 based modules as well.
There are some updates for ESP8266 that will be committed soon (next day or so) to fix some watchdog timeout issues in some of the sketches, but it should work ok for normal sketch code.
--- bill
Thanks folks.
Bill, am using the UNO at this stage, but I might end up on the mega for the extra pins yet. I'll check out your library today. Quick question about your library and autodetect, I am using a adafruit sev seg I2C display also, will this interfere with your library? (i'll probably have an answer before you read this!).
Pearo:
Thanks folks.Bill, am using the UNO at this stage, but I might end up on the mega for the extra pins yet. I'll check out your library today. Quick question about your library and autodetect, I am using a adafruit sev seg I2C display also, will this interfere with your library? (i'll probably have an answer before you read this!).
What i2c chip does it use? I'm assuming it uses a HT16K33 chip.
The HT16K33 chip uses a different i2c address range than the PCF8574 or MCP23008 i/o expander chips which is what hd44780_I2Cexp is looking for.
So the hd44780_I2Cexp class should not interfere with the LED backpack or Adafruit library for it.
Let me know if you have any issues.
--- bill
Hi Pberrybap,
This is Terry King; I write http://ArduinoInfo.Info and the page there about I2C based LCD display is unusually active: 314000 hits this month of December so far...
If you can , please look at that page and think about how your work could be incorporated to make it easier for newbies and others to use LCD displays with PCF8574 backpack interfaces of various versions.
If you think it's worthwhile, (and when you think things are stable) I would like to modify that page to use your auto-configuration approach. I get constant pleas of "My LCD doesn't work" which almost always is "wrong configuration"..
The page is HERE...
Let me know what you think, and thanks for your good work on all this!
bperrybap:
What i2c chip does it use? I'm assuming it uses a HT16K33 chip.
The HT16K33 chip uses a different i2c address range than the PCF8574 or MCP23008 i/o expander chips which is what hd44780_I2Cexp is looking for.
So the hd44780_I2Cexp class should not interfere with the LED backpack or Adafruit library for it.
Let me know if you have any issues.--- bill
Well that was easy! All works fine (bar the backlight). Declaration and initialization aside, all my existing code also works and there is no more buffer overruns! No issue with the 7 seg display either.
Re backlight, I can see where its auto sensing it, however its got the high/low part backwards, that is i can turn the back light on by calling noBacklight(). I'll have a bit of a poke around later (probably wont be till after christmas now though). My debugger is not working properly either, so need to figure that out first.
Anyways, its an awesome bit of work on your part. Some pretty neat tricks in there for detecting stuff!
terryking228:
Hi Pberrybap,This is Terry King; I write http://ArduinoInfo.Info and the page there about I2C based LCD display is unusually active: 314000 hits this month of December so far...
If you can , please look at that page and think about how your work could be incorporated to make it easier for newbies and others to use LCD displays with PCF8574 backpack interfaces of various versions.
If you think it's worthwhile, (and when you think things are stable) I would like to modify that page to use your auto-configuration approach. I get constant pleas of "My LCD doesn't work" which almost always is "wrong configuration"..
The page is HERE...
Let me know what you think, and thanks for your good work on all this!
Geezuz, good website but man, that font!!
Who makes your backpack? Is it a SYDZ board? Can you post some photos of it?
I'd really like to understand why the auto detect for the backlight active level failed on that backpack.
I have run into one backpack design that has a bad/incorrect backlight transistor design and because of that, it breaks the auto detection. If you looked at the library code you may have seen the comments about the SYDZ backpacks.
I haven't yet created and posted the documentation for the library yet but there is a way to force the library to use a hard coded configuration rather than have it auto detect everything.
If you look at the diagnostic output on the serial monitor it will post the auto detect parameters.
If it is correct other than that backlight active level, you can use that information to create a non auto detect constructor that will force the configuration parameters.
You will see a string of numbers/characters like P0124567L
The P means PCF8574 and the L means active low.
That means the constructor would be:
lcd(i2c_addr, I2Cexp_PCF8574,0,1,2,4,5,6,7,LOW)
If backlight control is backwards then change the active level to HIGH.
You can also use I2Cexp_ADDR_UNKNOWN for the i2c address and the code will still look for and locate the expander chip.
There are also some canned entries in the header file.
If you open it you will see them they have names like:
I2Cexp_BOARD_XXX where there are various "XXX" boards.
I2Cexp_BOARD_SYDZ, I2C_BOARD_MJKDZ, etc...
Unfortunately, manual configuration is an area that is subject to change - hence why the code is still alpha state.
These names might change if the defines move into the class as const variables.
On the list of updates is to get to a single token for configuration so that there is just a single number that configure everything.
i.e. for above it might be 101245670
This is the stuff I'm trying to finalize before the code becomes a 1.0 release.
Anyway, there is a way to manually configure the library object for these cases but I really want to understand why the auto configuration failed to detect the backlight active level on your backpack.
--- bill
Hi Bill,
I saw all the info on boards. This is just some cheap ebay POS that I picked up cheap whilst waiting for some stuff to arrive from adafruit. I can see how to force the library to use my own config, so not really an issue. I was more happy that I didn't have to go chasing buffer overrun issues that I had with the previous library!
Here is a potato photo of the board: http://imgur.com/a/f43eq My eyesight has deteriorated over the last 6-12 months, so its a struggle to read the part number on the transistor. It looks like the markings are A2 SHB. Until I can confirm that part number its impossible to understand how the board is wired. I can confirm from reading the other library that the board uses P3 on the PCF8574 and it sets the bit to turn the backlight on ( I think, its writes 0x08 to the PCF8574 for so I am assuming that sets P3 high, but to be honest I have only briefly read the datasheet).
The library is great, I can make it work regardless of the board design. Just posted the detail here so you can make it easier for others.! For users who have very little experience with coding and hardware this library is fantastic. I remember back in the 80's spending weeks writing ASM libraries like this, now I can just pull something of the internet and have it working in 10 minutes! Thanks for all your hard work and effort.
Please let me know if you want more info. I would be happy to reverse engineer and draw a schematic of the board, but I wont have time now until the new year. I should be able to sneak a few hours here and there to do software analysis though.
Thanks,
Andy.
Could you clarify a few things.
Buffer overrun?
Was that something in the library or was it something happening in the sketch because the other library was a bit slower?
What configuration did I2CexpDiag report?
I'm assuming that it got the backlight active backwards?
What constructor are you using to make it work?
Thanks for the information.
BTW, if you are getting one of the Adafruit #292 LCD backpacks (i2c/shift register) it will be slower when using i2c. (about 20% slower at 100Khz)
That is because of the way the MCP23008 works. It requires additional bytes to be transferred to set bits in the GPIO register. There is nothing that can be done to make it as fast as a PCF8574 for the same i2c clock rate.
note: you can bump the i2c clock rate up to 400khz and it will make a big difference.
You can run the LCDispeed sketch to check the byte transfer timing.
hd44780 is about 6x faster than the adafruit library. and about 19x faster if you bump the i2c clock to 400khz.
Most i2c devices run this fast, one big exception being the older DS1307 chips.
--- bill
On the backlight transistor, A2SHB is a mosfet. So I'm guessing that is correct.
Since mosfets use voltage instead of current, there is no way to detect it's presence since there is no load through the gate.
R3 might be pullup on the gate. Either way, since there is no load on the PCF8574 pin that drives the gate of the mosfet, the library cannot properly detect this type of backlight circuit design and will get active level wrong.
Originally I thought that the SYDZ board used a mosfet but on that board it turns out that they wired the transistor in a non standard and less efficient way which breaks the auto detection.
Unfortunately, there is no way to auto detect the backlight active level when mosfets are used.
With respect to vision, I feel you . My vision has really started to get bad as well.
I bought a USB microscope that I use quite often to look at small things like PCB components.
It is like a Pen with a small ring of leds and a camera on the end. I can point it whatever I like and see it nice and large on the computer screen.
--- bill
Terry,
We briefly had an email conversation about the hd44780 library back in August when I reached out to you. I'll revive that email thread and we can continue the discussion about the library and the "LCD blue" web page out of this unrelated thread.
--- bill
Hi Bill,
Firstly, let me say that the buffer overrun is not a problem with your library. It was the supplied library and this is why I went chasing a better library. Let me know if you want a copy. I started chasing down the problem but to create this thread first!
Output from diag as requested:
********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 0.8.1
--------------------------------------------------------------------
Reported Arduino Revision: 1.6.12
F_CPU: 16000000
--------------------------------------------------------------------
A4: digital pin: 18
A5: digital pin: 19
SDA: digital pin: 18
SCL: digital pin: 19
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - YES
--------------------------------------------------------------------
Scanning i2c bus for devices..
i2c device found at address 0x27
i2c device found at address 0x70
Total I2C devices found: 2
--------------------------------------------------------------------
Scanning i2c bus for all lcd displays
LCD at address: 0x27 | config: P01245673L | R/W control: Yes
Total LCD devices found: 1
--------------------------------------------------------------------
LCD Display Memory Test
Display: 0
Walking 1s data test: PASSED
Address line test: PASSED
--------------------------------------------------------------------
Each display should be displaying its #, address, and config information
If display is blank, but backlight is on, try adjusting contrast pot
If backlight is off, wait for next test
--------------------------------------------------------------------
Blinking backlight test: to verify BL level autodetection
If backlight is mostly off but
you briefly see "BL Off" on display with backlight on,
then the library autodetected incorrect BL level
and the library cannot autoconfigure the device
--------------------------------------------------------------------
Displaying 'uptime' on all displays
--------------------------------------------------------------------
Took me a while to figure out why this would not run form the arduino library, forgot I was using a dev board with Atmel ICE and the cap on the reset line disconnected!
I am just running the default constructor with no params.
I might order one of those USB microscopes, I think it would be handy! I currently have a large lit magnifying glass that helps, but its not powerful enough! I need one of the Mantis scopes that I used to use when I was doing hardware development!
Pearo:
I am just running the default constructor with no params.
With the FET backlight circuit on that board, I'm assuming that the library got backlight active level wrong so backlight control is backwards?
You can fix it by using a different constructor that doesn't auto configure everything.
That display looks like it will work with the SYDZ canned board type entry.
--- bill
bperrybap:
With the FET backlight circuit on that board, I'm assuming that the library got backlight active level wrong so backlight control is backwards?
You can fix it by using a different constructor that doesn't auto configure everything.
That display looks like it will work with the SYDZ canned board type entry.--- bill
Yup, indeed it got the back light level wrong.
As I said before, I am not to fussed about as I can make it work regardless (and was planning to use one of the other constructors). You have already saved me a good chunk of work that I would have spent trying to fix the broken library that was supplied with the display. Thanks for your efforts, its well appreciated.
hd44780 has been updated (rev 0.8.2) to allow a canned backpack board while still locating the i2c address.
So you can how use a constructor like:
hd44780_I2Cexp lcd(I2Cexp_BOARD_SYDZ);
And it will auto locate the expander but use the specified canned parameters.
--- bill