Arduino Forum

Using Arduino => Project Guidance => Topic started by: adwsystems on Jul 20, 2015, 12:31 am

Title: Available LCDs and libraries
Post by: adwsystems on Jul 20, 2015, 12:31 am
Just a quick question.

I have used the 16x2 LCDs both direct I/O and via I2C. I see there are some 20x4 LCDs available with the I2C interface. Are the Arduino libraries available to drive these?
Title: Re: Available LCDs and libraries
Post by: groundFungus on Jul 20, 2015, 01:21 am
Which library did you use for the 16x2?  You might be able to use the same library for the 20x4, just change the begin to (20, 4).  You might also need to change the address and the pin mapping in the constructor depending on the specific LCD module.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 20, 2015, 02:00 am
I used wire.h and liquidcrystal_I2c.h. There is a line that sets up the LCD for an I2C address, number of rows and columns (LiquidCrystal_I2C lcd(0x27, 16, 2);). So I know hypothetically I can change the values 16 and 2; but I was wondering if anyone had and knew it would work before I spent the money on the LCD.
Title: Re: Available LCDs and libraries
Post by: groundFungus on Jul 20, 2015, 02:14 am
It has worked for me with 2 different 20x4 LCDs.  I have used the same library for 4 wire 16x2 LCDs as well

.
Title: Re: Available LCDs and libraries
Post by: florinc on Jul 20, 2015, 02:19 am
Quote
There is a line that sets up the LCD for an I2C address
That's the constructor.

Quote
number of rows and columns (LiquidCrystal_I2C lcd(0x27, 16, 2)
that would be something like
Code: [Select]
 lcd.begin(16, 2);
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 20, 2015, 04:16 am
That's the constructor.
that would be something like
Code: [Select]
lcd.begin(16, 2);


Don't forget we're talking about the I2C version, not the direct I/O version. I had to change lcd.begin(16, 2) to lcd.begin() and add LiquidCrystal_I2C lcd(0x27, 16, 2) to make the I2C version of the 16x2 display work. And it does work. The question before the group is: Does LiquidCrystal_I2C lcd(0x27, 20, 4) work for the 20x4 LCD with the I2C interface?
Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 20, 2015, 05:04 am
There is a line that sets up the LCD for an I2C address, number of rows and columns (LiquidCrystal_I2C lcd(0x27, 16, 2).
Well, if that works for an I2C backpack, you are very lucky as you have just by chance happened on a backpack which matches that old library.  Most backpacks currently available will not and you need to use the more detailed constructor with the fmalpartida new-liquidcrystal (https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home) library.

Other than that, of course the library should function with the 20 x 4 display.  You may need to remember that the third and fourth line are actually extensions of the first and second, though cursor positioning works correctly if you specify within the 20 x 4.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 20, 2015, 02:39 pm
I have found at least 3 different libraries called LiquidCrystal_I2C.h. None of which are on the Arduino site here. Which is the correct one? The best one?
Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 20, 2015, 03:43 pm
That would be the link I provided.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 22, 2015, 03:14 am
That would be the link I provided.

Well that library crashed and burned.  I have four 16x2 LCDs that I have purchased over the last 6 months from four different places and none of them work with this library. I am working to determine where I may have gotten the library I have been using. I know it was via a link from the Arduino site here. Anyone have a better library than either the fmalpartida or my current library?

Edit: I found the source of the library I was using. https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library as recommended to me many months ago.
Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 22, 2015, 03:01 pm
I have four 16x2 LCDs that I have purchased over the last 6 months from four different places and none of them work with this library.
I find that extremely improbable indeed.

I did explain (well, attempted to ... ) that using a given library with the abbreviated three argument descriptor will work only for the backpack which the particular library designer possessed at the time and wrote it for, which presumably explains why you have found an odd library with does work with the short descriptor.

The fmalpartida (https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home) works with all the available backpack versions, however you need to use the complete descriptor and determine what that correct descriptor is using the I2Cguesser (http://forum.arduino.cc/index.php?topic=157817.msg1235230#msg1235230) code.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 22, 2015, 05:29 pm
I used Nick Gammon's I2C scanner in addition to the fact that I already knew and had working the displays. The address is 0x27 and the only thing connected to the Arduino UNO (nothing else on the I2C or anywhere else on the Arduino).

After replacing the LiquidCrystal_I2C libraries (including an attempt that involved uninstalling the Arduino IDE, deleting the libraries, and then reinstalling the IDE and adding and adding in the new library). I used the example code straight from the website, just changing the address (from 0x38 to 0x27)

Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>


#define BACKLIGHT_PIN     13

LiquidCrystal_I2C lcd(0x27);  // Set the LCD I2C address


// Creat a set of new characters
const uint8_t charBitmap[][8] = {
   { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
   { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
   { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
   { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
   { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
   { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
   { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
   { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
   
};

void setup()
{
   int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));

  // Switch on the backlight
  pinMode ( BACKLIGHT_PIN, OUTPUT );
  digitalWrite ( BACKLIGHT_PIN, HIGH );
 
  lcd.begin(16,2);               // initialize the lcd

   for ( int i = 0; i < charBitmapSize; i++ )
   {
      lcd.createChar ( i, (uint8_t *)charBitmap[i] );
   }

  lcd.home ();                   // go home
  lcd.print("Hello, ARDUINO "); 
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print (" FORUM - fm   ");
  delay ( 1000 );
}

void loop()
{
   lcd.home ();
   // Do a little animation by writing to the same location
   for ( int i = 0; i < 2; i++ )
   {
      for ( int j = 0; j < 16; j++ )
      {
         lcd.print (char(random(7)));
      }
      lcd.setCursor ( 0, 1 );
   }
   delay (200);
}


It did not work, blank screen with lots of flickering. One of the displays I am using is http://www.dfrobot.com/index.php?route=product/product&product_id=135&search=lcd+iic&description=true#.Va-zhflViko

One conspicuous item about the fm library is the inclusion of the backlight pin. I don't have any serial enabled LCDs that have or require a output/input to drive the backlight. Many of the serial (I2C) LCDs I looked at do not have a pin for that. I would hope the library can handle that, but since I didn't write the library I don't know.

If it should work, what do I have to do to make it work? Being the link to the fm library is on the arduino site (opposed to being from a forum post), I would to prefer to use it.
Title: Re: Available LCDs and libraries
Post by: chucktodd on Jul 22, 2015, 06:37 pm
I used Nick Gammon's I2C scanner in addition to the fact that I already knew and had working the displays. The address is 0x27 and the only thing connected to the Arduino UNO (nothing else on the I2C or anywhere else on the Arduino).


If it should work, what do I have to do to make it work? Being the link to the fm library is on the arduino site (opposed to being from a forum post), I would to prefer to use it.
what is the chip connected to the LCD? a TCA9434, PCF8574? MCP23008? MCP23017?

the library need to be written for the correct I2C expander.

Chuck.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 22, 2015, 06:42 pm
If I remember correctly a PCF8574, maybe an PCF8574A (is that an option?). I would need to double check at home tonight. Along those lines, the chip pinout would also have to match the library.

Edit: It is a PCF8574T chip.
Title: Re: Available LCDs and libraries
Post by: chucktodd on Jul 22, 2015, 07:08 pm
If I remember correctly a PCF8574, maybe an PCF8574A (is that an option?). I would need to double check at home tonight. Along those lines, the chip pinout would also have to match the library.
trace out the wiring from LCD module to the IO Expander.  The fdebrabander Arduino-LiquidCrystal-I2C-library (https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library/blob/master/LiquidCrystal_I2C.h) uses these defaults for defining how the module is wired.
the LCD databus is connected in 4bit mode using P4..P7, RS = P0, Rw=P1, En=P2, backlight = P3.
This must match your module. Else change the defines in your library.

Code: [Select]


// flags for backlight control
#define LCD_BACKLIGHT 0x08
#define LCD_NOBACKLIGHT 0x00

#define En B00000100  // Enable bit
#define Rw B00000010  // Read/Write bit
#define Rs B00000001  // Register select bit


chuck.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 22, 2015, 07:24 pm
Chuck:

The fmalpartida library, that was suggested to be used (post #6), is not working for the same displays.

If you are suggesting to use the fdebrabander library, then you are linking to the library I am using and is working for me (see post #9). Is that what I am reading?
Title: Re: Available LCDs and libraries
Post by: chucktodd on Jul 22, 2015, 07:31 pm
Chuck:

The fmalpartida library, that was suggested to be used (post #6), is not working for the same displays.

If you are suggesting to use the fdebrabander library, then you are linking to the library I am using and is working for me (see post #9). Is that what I am reading?
I understood that you had not been able to use your I2C LCD.

I was trying to show you how you could modify that library to fit your hardware.

If your LCD is now working, sorry I wasted your time. I thought you had not yet found a matching library.

Chuck.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 22, 2015, 07:37 pm
The situation started as a question about a library capable of running both the 16x2 and 20x4 LCD via I2C. I have been using the fdebrabander library, which you suggested, to run the 16x2 I2C LCD quite successfully. Paul suggested using the fmalpartida library, which when implemented did not work on any of my LCDs. Do you know if the fdebrabander library is compatible and will also drive a 20x4 LCD?
Title: Re: Available LCDs and libraries
Post by: chucktodd on Jul 22, 2015, 09:13 pm
The situation started as a question about a library capable of running both the 16x2 and 20x4 LCD via I2C. I have been using the fdebrabander library, which you suggested, to run the 16x2 I2C LCD quite successfully. Paul suggested using the fmalpartida library, which when implemented did not work on any of my LCDs. Do you know if the fdebrabander library is compatible and will also drive a 20x4 LCD?
as long as the LCD module uses the HD44780 controller, and it is wired the same, it will work.

The HD44780 is used with 8x2,8x1,16x2 .. 40x2 displays. 
I have one 40x4 display that is actually 2 40x2 displays in the same case. I have to keep track of where the next character is, turn off cursor on one, turn cursor on the other when I scroll from line 2 to line 3.

I have substituted 16x2 with 20x4,  the display still works, but all of the row/column positions are different. Data shows up on the displays but not where you expect it.
(0,0) = top left, if you continously write data after the first line is filled the next position filled is the first character of the third line, then a few missing (hidden characters) then the second line is filled, then the forth line is filled.

You will have to change how you use the display; extra screen space, organization of prompts, etc..

chuck.
Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 23, 2015, 12:23 am
I used Nick Gammon's I2C scanner in addition to the fact that I already knew and had working the displays. The address is 0x27 and the only thing connected to the Arduino UNO (nothing else on the I2C or anywhere else on the Arduino).
You do not appear to be reading or understanding my explanations and clearly do not understand what a "descriptor" is. :smiley-roll:

My comments stand.  If you care to read the instructions, the fmalpartida library works beautifully.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 23, 2015, 12:30 am
Paul: I appreciated thank you (and everyone) for all of the comments and help. I read all of them and I understand them. But the comments to the fmalpartida library do not yet seem applicable as I have tried the example and it is not working.

I know the LCD I2C address is 0x27, that address corresponds with the successful operation with the fdebrabander library and Nick Gammon's I2C Scanner.

Did you read my comments back in post #11? I am not seeing anything wrong in the example code. Do you have any idea why the 'Hello World' example from the fmalpartida library isn't working? If the fmalpartida library does work "for all available backpacks", then what do I have wrong? Please provide some help or direction rather than generalized criticism.
Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 23, 2015, 03:12 pm
It is not generalised.

You have not exhibited code that includes a full descriptor - you appear not to understand what a descriptor is.  While I have not deeply studied the instructions for the fmalpartida library as I already know - from inspecting the code - how to use it, I am sure that actually reading such instructions would reveal what a descriptor is and how to use it.  I can only then conclude that you have not.

And you claim to have tried "Nick Gammon's I2C scanner", which suggests you have not read my instruction to use the I2Cguesser (http://forum.arduino.cc/index.php?topic=157817.msg1235230#msg1235230) code.

You are reading superficially (a problem my wife and I share as we have discussed - when we explain things, we mean what we say, not what people imagine we have said because they did not pay attention) - you think " I2C scanner" means "I2Cguesser" - it does not.

If you can assure me (and prove) that you have actually done what I recommended, well I will be concerned that a genuine problem exists, but I think you simply have not.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 23, 2015, 04:03 pm
It is not generalised.

You have not exhibited code that includes a full descriptor - you appear not to understand what a descriptor is.  While I have not deeply studied the instructions for the fmalpartida library as I already know - from inspecting the code - how to use it, I am sure that actually reading such instructions would reveal what a descriptor is and how to use it.  I can only then conclude that you have not.

And you claim to have tried "Nick Gammon's I2C scanner", which suggests you have not read my instruction to use the I2Cguesser (http://forum.arduino.cc/index.php?topic=157817.msg1235230#msg1235230) code.

You are reading superficially (a problem my wife and I share as we have discussed - when we explain things, we mean what we say, not what people imagine we have said because they did not pay attention) - you think " I2C scanner" means "I2Cguesser" - it does not.

If you can assure me (and prove) that you have actually done what I recommended, well I will be concerned that a genuine problem exists, but I think you simply have not.
3 out of 4 statements that tell no one anything. Most definitely general. Comments such as
you appear not to understand what a descriptor is
are quite general, unfounded, and not necessary.

 You are correct I have not run your "I2CGuesser" program. Why would I? It sounds the same as I2CScanner by Nick. After doing research on my own due to the lack of specific information the name in the post is wrong. Some explanation had been provided about what the program you were referring to did would have been specific and useful.

You have not exhibited code that includes a full descriptor.
So if I read between the lines of your comments in general on the descriptor, you are saying the example code provided (post #6) does not include a full descriptor? Based on the instructions that is the descriptor for use with the library. If there is more information on the descriptor or the descriptor given is incomplete, please provide specifics.

Per your requirements, I have run the I2CLCDGuesser (the correct name) program. It had limited success. It was able to locate the chip at 0x27 (no surprise there). But it does not flicker the backlight 3 times on any of my displays as the comments state. Are you familiar with the inner workings of the I2CLCDGuesser program? Any specific points I should be looking to modify? Any specific items to look at would be helpful.
Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 24, 2015, 02:58 pm
You are correct I have not run your "I2CGuesser" program. Why would I? It sounds the same as I2CScanner by Nick.
Which was the reason I mentioned my - and my wife's - concern for attention to detail

When dealing with computers/ microprocessors/ engineering in general, "It sounds the same" just doesn't cut it!

As she cites: "The O-ring is a millimetre out when it's cold."  "Nah, that will be fine!  What could possibly go wrong?"

After doing research on my own due to the lack of specific information the name in the post is wrong. Some explanation had been provided about what the program you were referring to did would have been specific and useful.
As I say, it's a difference in attitude.  I pointed you to it; I sincerely believed it came with instructions.

So if I read between the lines of your comments in general on the descriptor, you are saying the example code provided (post #6) does not include a full descriptor? Based on the instructions that is the descriptor for use with the library. If there is more information on the descriptor or the descriptor given is incomplete, please provide specifics.
I don't follow.  Which example code is this?  From the fmalpartida library, or something else?

Per your requirements, I have run the I2CLCDGuesser (the correct name) program. It had limited success. It was able to locate the chip at 0x27 (no surprise there). But it does not flicker the backlight 3 times on any of my displays as the comments state.
And you ran it using the - correctly installed as the only LiquidCrystal_I2C LCD library in the IDE - fmalpartida library?  (Naturally, you had the contrast control correctly set.)  And I did not realise it was supposed to "flicker the backlight 3 times", for me it simply lights the backlight when you get to the correct descriptor (and some incorrect ones as well).

Are you familiar with the inner workings of the I2CLCDGuesser program? Any specific points I should be looking to modify? Any specific items to look at would be helpful.
Actually it does not work as such for me due to a problem with the "serial" library not responding to input from the Serial Monitor when I hit Enter, so I tend to use a modified version which just cycles continuously through the options.  Clearly that does get the results I need with a little jiggery-pokery with the Reset button, but I do not know whether or why you would need to modify it in any way.

When you get the working descriptor (at least 7 arguments) from the "guesser", you cut-and paste that from the Serial Monitor into your code.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 24, 2015, 03:14 pm
OK some progress. A few logical questions, some already answered. Overall general response with no direction, no specific items to try, or rocks to look under.

I don't follow.  Which example code is this?  From the fmalpartida library, or something else?
The code is copy paste from the fmalpartida Hello_World_I2C example. The only change to the example is to the I2C address (changed from 0x38 to 0x27).

And you ran it using the - correctly installed as the only LiquidCrystal_I2C LCD library in the IDE - fmalpartida library?  (Naturally, you had the contrast control correctly set.)  And I did not realise it was supposed to "flicker the backlight 3 times", for me it simply lights the backlight when you get to the correct descriptor (and some incorrect ones as well).
As previously mentioned, I deleted the old library and replaced it. When that did not work, I uninstalled the Arduino IDE and deleted the Arduino directory from My Documents to ensure a clean install of both the IDE and the fmalpartida library.

Actually it does not work as such for me due to a problem with the "serial" library not responding to input from the Serial Monitor when I hit Enter, so I tend to use a modified version which just cycles continuously through the options.  Clearly that does get the results I need with a little jiggery-pokery with the Reset button, but I do not know whether or why you would need to modify it in any way.
Why would I need to modify it? Because it doesn't work [for me/my LCDs]. I know the LCDs work (both physically and logically with the other library that I have been using for more than 6 months) therefore there must be something wrong with the program.

When you get the working descriptor (at least 7 arguments) from the "guesser", you cut-and paste that from the Serial Monitor into your code.
Like you said, you thought those details were provided. I do not see them. What is the descriptor supposed to be? What are the 7 arguments? I get the general problem. I do not see the specific answer...yet.
Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 25, 2015, 12:38 am
As previously mentioned, I deleted the old library and replaced it. When that did not work, I uninstalled the Arduino IDE and deleted the Arduino directory from My Documents to ensure a clean install of both the IDE and the fmalpartida library.
Which of course means you have to again delete the supplied LiquidCrystal_I2C LCD library from the installed IDE when you install the fmalpartida library.

OK, so fmalpartida clearly doesn't properly describe the descriptor in the direct example given.  The presumption is extended from the original LiquidCrystal library that you are using one particular model of backpack - I guess he needs to update and correct it, wherever he now is!  The description is hidden within the branch "/LiquidCrystal/docs/html/class_liquid_crystal___i2_c.html".

Ah well.  The point is, at least the i2cLCDguesser (http://forum.arduino.cc/index.php?action=dlattach;topic=157817.0;attach=67523) sketch contains the full prototype code for using the library.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 25, 2015, 01:22 am
Which of course means you have to again delete the supplied LiquidCrystal_I2C LCD library from the installed IDE when you install the fmalpartida library.
There isn't one! There is no LiquidCrystal_I2C library as part of the native IDE install. Only a LiquidCrystal library for direct IO is included with the IDE. I figured that out 6 months ago when I had to find a I2C LCD library in the first place.

OK, so fmalpartida clearly doesn't properly describe the descriptor in the direct example given.  The presumption is extended from the original LiquidCrystal library that you are using one particular model of backpack - I guess he needs to update and correct it, wherever he now is!  The description is hidden within the branch "/LiquidCrystal/docs/html/class_liquid_crystal___i2_c.html".
Not sure where you are intending to send me with the hmtl link. Unfortunately, my HTML never came up to the same grade as my C/C++.

Ah well.  The point is, at least the i2cLCDguesser (http://forum.arduino.cc/index.php?action=dlattach;topic=157817.0;attach=67523) sketch contains the full prototype code for using the library.
I'm going to take a stab that the complete descriptor is like lcd(addr, EN, RW, RS, D4, D5, D6, D7, BL, POL). If so, would it have killed you to just post that two days ago.

So I have a full constructor now (I think), with 7 parameters just like you wanted but only know one of them (addr=0x27). Now can you provide any insight as to why the I2CLCDGuesser doesn't guess so well?

Your specifics are getting better. What exactly do you need to know to help me get the software to correlate to the hardware?

Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 25, 2015, 03:07 pm
There isn't one! There is no LiquidCrystal_I2C library as part of the native IDE install. Only a LiquidCrystal library for direct IO is included with the IDE. I figured that out 6 months ago when I had to find a I2C LCD library in the first place.
Nevertheless, you need to remove the original LiquidCrystal library to make the new one (which covers virtually all of the various interfaces) work.

Not sure where you are intending to send me with the html link. Unfortunately, my HTML never came up to the same grade as my C/C++.
That is where the information is relative to the LiquidCrystal library directory when you install it.

I'm going to take a stab that the complete descriptor is like lcd(addr, EN, RW, RS, D4, D5, D6, D7, BL, POL). If so, would it have killed you to just post that two days ago.
My apologies.  As I say, having worked from code posted in the forums here, I presumed the instructions would be with the library.

So I have a full constructor now (I think), with 7 parameters just like you wanted but only know one of them (addr=0x27). Now can you provide any insight as to why the I2CLCDGuesser doesn't guess so well?
Not removing the original LiquidCrystal library?

Sorry, it just works for me with the modules I have on hand (and as the topic comes up so often, I have deliberately attempted to collect all available versions of the I2C backpack in order to verify them and post a comprehensive HOWTO).  Had you chosen to post a picture of the board you are using (as suggested by the master instructions (http://forum.arduino.cc/index.php/topic,148850.0.html)) I probably would have simply located and posted the corresponding descriptor for you.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 25, 2015, 05:32 pm
Nevertheless, you need to remove the original LiquidCrystal library to make the new one (which covers virtually all of the various interfaces) work.
News to me. Since the header files/libraries are unique between the IDE and the downloaded libraries there is no reason to delete an irrelevent, uncalled library (standard C/C++ program methodologies at work here). In 30 years of programming C/C++ I have never had to delete header files/libraries that were not used in the project. But for you, I tried it. Huh. No effect. No change. Still doesn't work.

Not removing the original LiquidCrystal library?
Sorry. Not following you direction on this comment.

Sorry, it just works for me with the modules I have on hand (and as the topic comes up so often, I have deliberately attempted to collect all available versions of the I2C backpack in order to verify them and post a comprehensive HOWTO).  Had you chosen to post a picture of the board you are using (as suggested by the master instructions (http://forum.arduino.cc/index.php/topic,148850.0.html)) I probably would have simply located and posted the corresponding descriptor for you.
If you wanted a picture, need a picture, all you had to do was ask. I have attached photos. Please let me know how they help you.

So from your lack of details, I take it you have no idea what may be wrong or any other information on what may need to be changed to get fmalpartida library to work with the LCDs I have.

Can anyone else assist with what I may have to do to get the fmalpartida library to work with my LCDs. As it is the library listed from the Arduino website here, I would think it would be the preferred library to use. But I've not been able to get it to work.


Title: Re: Available LCDs and libraries
Post by: bperrybap on Jul 25, 2015, 06:14 pm
adwsystems,
You appear to have some knowledge gaps in how the i2c backpacks work and the use of a constructor initialize a library as you seem to be not realizing why things are working/not working and how to properly initialize the libraries.

There are also some library interaction and conflict issues that have to be dealt with as well.

First a bit on the library conflict issues.
There are several libraries with the same name "LiquidCrystal_I2C".
The Arduino IDE uses a very crappy build methodology and this gets all tangled up when there are header file collisions and there are collisions when using these libraries.
Also, fm's library will have additional collisions because it used a hybrid approach by essentially combining multiple libraries into a single library directory and is intended to replace the original IDE LiquidCrystal library.
It was done this way to be a replacement for the IDE LiquidCrystal library and to make the install easier as it was created long before all this very recent library manager stuff.
Because of these issues, when playing with fm's library you must properly install it and that means removing any/all other traces of any other LiquidCrystal_I2C library AND the system supplied LiquidCrystal library.
But when playing any of these LiquidCrystal_I2C libraries you will have to fully remove one in order to try a different one.
If they are left in place, all kinds of weird and strange things can happen which is mostly build errors, again mostly because of the crappy build methodology used by the Arduino IDE and its "libraries".


Here is some background to help fill in the missing gaps about i2c backpacks and libraries:

The i2c backpacks use a i2c i/o expander chip (PCF8574). Ignore the various versions of that chip as that is all noise and doesn't affect how it interfaces to the hd44780 lcd pins. Different versions of the chip have different base i2c addresses which is the only real difference between the different versions.

The problem you are experiencing with the libraries not "working" is due to the h/w architecture of this type of backpack.
The backpack contains an i/o expander (PCF8574) that has 8 i/o pins.
Those 8 pins can be controlled over the i2c bus using the Wire library.
6 or 7 of those pins are wired/connected to hd44780 lcd pins
1 of those pins is typically wired up to control the lcd backlight.

The issue with this type of design is that there is no standard way to connect the 8 i/o expander chip pins
to the hd44780 pins and the backlight control circuit.
So while the i2c interface and how you talk to the PCF8574 chip is all standardized, there is no standard that says which i/o pin on the i/o expander should be connected to which hd44780 pin or which i/o pin should be used to control the backlight.

As a result, different makes of the backpacks will wire the connections differently.

Because there is no standard way to wire up an i/o expander to a hd44780 LCD, there is no way to make a "plug and play" library that will work with all i2c backpacks. It simply cannot be done.

The library must "know" how the i/o pins are connected because it toggles the i/o pins to control the lcd and backlight.
If the library is toggling i/o pins incorrectly, then the lcd and backlight won't work correctly.

It is no different then when wiring up an hd44780 lcd display to use with the IDE supplied LiquidCrystal library.
The library must "know" which i/o pins are connected which hd44780 pins.
The IDE LiquidCrystal library has no default wiring and must be told by the sketch how the Arduino pins are connected to the LCD. These i2c backpacks are no different other than the i/o pins are no directly connected the microcontroller chip but rather are pins on a i/o expander that is controlled over the i2c bus.


So now back to the issue of a library constructor.
Unfortunately, there are several different "LiquidCrystal_I2C" libraries out there.
They all work differently and some of them use slightly different API calls for initialization.
All of them other than fm's library have chosen hard coded i/o expander pin mappings inside them.
So if you use one of those libraries, it will work only if the hard coded pin mappings inside the library exactly match how the i/o pins on the backpack are wired up to the lcd.
fm's library on the other hand allows the sketch to specify how the i/o expander i/o pins are wired. This is why it can work with any of the i2c backpacks.
The reason that fm's library is recommended over others is because the pin mappings can be configured in the sketch.
The way these pin mappings are configured is by using a constructor.
Unfortunately, the examples in fm's library are not good examples of how to use the library.
(I actually dislike them and think they should be ignored, particularly the i2c example as it has several issues in it)
The i2c example does not use the full constructor but rather uses a partial one which uses a default internal pin mapping.
This default pin mapping is for fm's ElectroFun LCD i/o board, so unless your board matches that board (which is VERY unlikely as I've not seen any backpack so far use this mapping) it will not work with your board.

The best thing to do is to use fm's library but then use a full constructor to tell the library exactly how the i/o expander is wired up to the LCD and backlight circuitry.
In order to do that you use the full constructor which has all 8 pins and the backlight polarity, but you must fill it with the correct parameters of how the i/o chip is wired up.
The best way to get the pin mapping information is to visually examine the board to determine how the traces on the PCB are wired up to the hd44780 pins and the type of on board transistor for the backlight. For those with h/w skills this will only take a couple of minutes.
For those that lack h/w skills, I wrote the guesser sketch which was referenced earlier in this thread.
The guesser sketch, when used properly, will go through various combinations of pin mappings to determine the correct pin mappings. The mappings will be displayed on the LCD and on the serial port and the resulting pins can be placed in the LiquidCrystal_I2C constructor in your sketch.
While there are 40,000+ permutations of how to wire up a i/o expander to an LCD and backlight, there are only about 8-10 ways that backpacks are using and most use 2 different mappings.
The guesser will go through all those combinations to help less technical users determine which pin mapping is used.


The thing to remember is that there is no way to produce a "plug and play" library for an i2c backpack that "just works".
Don't get mad at the libraries for not working.
Most libraries have been written for specific h/w to make it "plug and play" for that h/w but it won't work for other backpacks. This is what many backpack makers do. They hardcode their library for their h/w.
fm's library has a default pin mapping to make it simpler for his boards, but it won't work others.
fm's library can work for any backpack but it requires filling in the constructor to tell the library how the i/o expander is wired up.
If you are unable to look at the backpack PCB to determine the pin mappings, use the guesser sketch.

--- bill





Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 25, 2015, 07:06 pm
Thank you for the response Bill.

I take it then the full constructor is lcd(addr, EN, RW, RS, D4, D5, D6, D7, BL, POL)?

The LCD Guesser is not working? It is not finding any results that work. Any thoughts?

I will take an ohm meter to the LCD module and reverse engineer the pin out per your request. Once I have confirmation of the correct constructor, I will give it another shot. I still have not reinstalled the Arduino UNO IDE LiquidCrystal library. So it is operating as you suggest and Paul alluded to.

I am not upset with the library not "working". I'm disappointed with the lack of instructions on how to use and implement the "preferred" library in addition to the less than helpful general comments that provide no direction or directions. So no that I have a little direction, I can now attempt to make some progress.
Title: Re: Available LCDs and libraries
Post by: bperrybap on Jul 25, 2015, 07:47 pm
Thank you for the response Bill.

I take it then the full constructor is lcd(addr, EN, RW, RS, D4, D5, D6, D7, BL, POL)?
Yes.

And then the lcd.begin will turn on the backlight for you.
And you don't use the setBacklightpin calls. That is old stuf left over from very early versions of the library.

Quote
The LCD Guesser is not working? It is not finding any results that work. Any thoughts?
If the guesser sketch compiled and uploaded then fm's library is installed properly.
So far every case I've seen were the guesser was not working it was user error.
Did you follow the instructions that are in top of guesser sketch?
and went through all the guesses?

What happened?
- Did you see each guess on the serial monitor and nothring worked?
- Did the sketch hang?
other??

If there really is a issue in the sketch, I'd really like to know so I can update/fix it.



Quote
I am not upset with the library not "working". I'm disappointed with the lack of instructions on how to use and implement the "preferred" library in addition to the less than helpful general comments that provide no direction or directions. So no that I have a little direction, I can now attempt to make some progress.
I know what you mean.
I'm in the process of putting together a better hd44780 library package.
It will be better documented, with better examples, and will eliminate most of the issues that people are having and all of the installation issues.
I've improved the guesser sketch and it will be part of a diagnostic sketch that will be included with the library.
It also includes support for the MCP23008 which is on some of the backpacks like the adafruit backpack.
That one is tricky since if you put in the incorrect pin mappings you can potentially damage the backpack or lcd.
It isn't ready for distribution yet.
Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 26, 2015, 01:11 am
My only question ...

Where were you?

 :smiley-lol:
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 26, 2015, 02:00 am
There are also some library interaction and conflict issues that have to be dealt with as well.

First a bit on the library conflict issues.
There are several libraries with the same name "LiquidCrystal_I2C".
The Arduino IDE uses a very crappy build methodology and this gets all tangled up when there are header file collisions and there are collisions when using these libraries.
Also, fm's library will have additional collisions because it used a hybrid approach by essentially combining multiple libraries into a single library directory and is intended to replace the original IDE LiquidCrystal library.
It was done this way to be a replacement for the IDE LiquidCrystal library and to make the install easier as it was created long before all this very recent library manager stuff.
Because of these issues, when playing with fm's library you must properly install it and that means removing any/all other traces of any other LiquidCrystal_I2C library AND the system supplied LiquidCrystal library.
But when playing any of these LiquidCrystal_I2C libraries you will have to fully remove one in order to try a different one.
If they are left in place, all kinds of weird and strange things can happen which is mostly build errors, again mostly because of the crappy build methodology used by the Arduino IDE and its "libraries".

Looks like we are going to have to make a side trip and discuss installing the library.

https://www.arduino.cc/en/guide/libraries gives three methods:
1) Manage Libraries
2) Import a .ZIP library
3) Manual Installation

(1) Doesn't work...the fmalpartida library is not listed.
(2) Doesn't work...the .zip file is not recognized as a .zip library file by the IDE
That leaves only (3). The instructions say to install it in the sketch->library folder. That is what I have been doing. Bill mentioned it should replace the LiquidCrystal library included from the IDE install. Having no instructions, I assume the method is to shutdown the IDE, navigate to the arduino program directory, delete the old and install the new? Hope that's right because it is what I did.

Just a note on installing the fmalpartida library per the manual install instructions. I have not ever received an error. The program compiles without error.

As for the I2C LCD Guesser. It finds the PCF8574 at address 0x27. But I only see one blink of the backlight per 'send' click and garbage characters on an unlit screens. It does not appear to try all combinations. Only six combinations are attempted, the most popular ones?
Title: Re: Available LCDs and libraries
Post by: bperrybap on Jul 26, 2015, 03:42 am
Looks like we are going to have to make a side trip and discuss installing the library.

https://www.arduino.cc/en/guide/libraries gives three methods:
1) Manage Libraries
2) Import a .ZIP library
3) Manual Installation

(1) Doesn't work...the fmalpartida library is not listed.
It doesn't have support for it. but given the way the library combines multiple libraries and needs to replace the supplied LiquidCrystal library it is unlikely it could be supported by the library manager in its current form.
And even if the files could be massaged to make it work, I doubt that team Arduino would add support for it to the library manager since it replaces their library as I'm sure they would rather it be separate/different library with a different name.

Quote
(2) Doesn't work...the .zip file is not recognized as a .zip library file by the IDE
i thought it used to work. But I don't install it that way. I either do it manually or git clone it directly into my sketchbook libraries directory so that I can track all my changes with git.
(actually I'm not using it much anymore since I'm using my hd44780 i2c library)

Quote
That leaves only (3). The instructions say to install it in the sketch->library folder. That is what I have been doing. Bill mentioned it should replace the LiquidCrystal library included from the IDE install. Having no instructions, I assume the method is to shutdown the IDE, navigate to the arduino program directory, delete the old and install the new? Hope that's right because it is what I did.
You can place it either in your sketchbook/libraries directory or replace the system supplied LiquidCrystal library. Either will work. The important thing is that to avoid any IDE build issues the library directory needs to be named "LiquidCrystal" and the orignal LiquidCrystal library directory must be removed or move away to some other place.

Quote
As for the I2C LCD Guesser. It finds the PCF8574 at address 0x27. But I only see one blink of the backlight per 'send' click and garbage characters on an unlit screens. It does not appear to try all combinations. Only six combinations are attempted, the most popular ones?
Yes it only tries 6 permutations of the wiring. (All the wirings, I've seen after looking any MANY different backpacks)
Nearly all the bapacks are using 1 of 2 wirings. There are 2 other wirings that I've seen used but they are less popular and one of those I've only seen used on fm's ElectoFun board.
As it guesses, it is unpredictable what the lcd or backlight will do with incorrect guesses.
When it is correct, you will see the constructor on the LCD and the backlight will remain on.

I'm curious as to why it is not working with your backpack.
It could be that there is an issue with the sketch or you have a wiring that I've not seen before.
From looking at the blurry photo of the backpack you posted in post #28, it appears that:
PCF8574 P5 connects to hd44780 D5
PCF8574 P6 connects to hd44780 D6
PCF8574 P7 connects to hd44780 D7
PCF8574 P2 connects to hd44780 E

And it kind of looks like (but it is very hard to tell with the blurry photo)
PCF8574 P1 connects to hd44780 R/W

While I can't see the other traces well enough to see where they go, that wiring
matches with the first two guesses which are the two most common wirings for these types of backpacks.
The only difference between those two most common wirings is the backlight control polarity.

The best thing is to simply look at the board. A good visual check can verify the board wiring in just a minute or so.
If you can't see all the traces because it is soldered then use a ohm meter to resolve the wiring you can't see.
These 3 wirings are the most common and have account for all the boards I've ever seen other than fm's ElectroFun board:

Code: [Select]

// EN, RW, RS, D4, D5, D6, D7, BL, POL
  { 2,  1,  0,  4,  5,  6,  7,  3, POSITIVE }, // YwRobot/DFRobot/SainSmart
  { 2,  1,  0,  4,  5,  6,  7,  3, NEGATIVE }, // Robot Arduino LCM1602/2004
  { 4,  5,  6,  0,  1,  2,  3,  7, NEGATIVE }, // MJKDZ board


However, I really want to know why it is not working on your board.
There have only been 3 other cases where it wasn't working for people and in each of those 3 times, the person disappeared without resolving the "problem" and I never heard back from them.
So I have no idea if there is really an issue or whether they finally got it working an just didn't want to come back and report their final solution.
In a couple of cases there were serial issues on the mac which caused the guesser to lock up.
That is not to say the guesser doesn't have an issue, it is just that so far, I've not been able to confirm a case where the guesser didn't work.


--- bill
Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 26, 2015, 07:28 am
There have only been 3 other cases where it wasn't working for people and in each of those 3 times, the person disappeared without resolving the "problem" and I never heard back from them.
That says loads.

And even if the files could be massaged to make it work, I doubt that team Arduino would add support for it to the library manager since it replaces their library as I'm sure they would rather it be separate/different library with a different name.
Arrogance more to the point.  Their library should be removed and replaced with the upgraded one.  There is no reason to use the current one.

It does not appear to try all combinations.?
It cannot try all possible combinations.

Only six combinations are attempted, the most popular ones?
The only known combinations.

Working on the picture of your board.  I should have that backpack.  The question is where.

Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 26, 2015, 01:16 pm
It cannot try all possible combinations.
The only known combinations.
It could try all of the combinations. Very easily. But I would not want to sit through it.

Based on my ohm meter, the wiring corresponds to the YwRobot/DFRobot/SainSmart version. With the full descriptor in my program it is working. Still not sure about the I2CLCDGuesser.
Title: Re: Available LCDs and libraries
Post by: bperrybap on Jul 26, 2015, 05:32 pm



It could try all of the combinations. Very easily. But I would not want to sit through it.
:)

Quote
Based on my ohm meter, the wiring corresponds to the YwRobot/DFRobot/SainSmart version. With the full descriptor in my program it is working. Still not sure about the I2CLCDGuesser.
Ok. So there appears to be some sort of issue either in the guesser sketch or how it is being used.
I'd really like to resolve it.
The YwRobot/DFRobot/SainSmart wiring is the very fist guess that the guesser does so I'm not sure why it isn't working for your environment.
Can you hang around long enough to resolve the issue?

Can you provide more information as to your environment and what is happening and what you are seeing on the serial port vs the LCD as you use the IDE serial port monitor to talk to the guesser and step between each guess?

I'd also like to know:
- host operating system
- IDE version


--- bill



Paul,
In terms of replacing the IDE supplied LiquidCrystal library with fm's library, I actually wouldn't be in favor of that.
In order to replace the LiquidCrystal library with something new/better, it really needs to pretty much "just work" for all the environments.
While there are some great improvements in fm's library over the stock LiquidCrystal library, there are some actual issues with the current code and library structure that crop up in certain h/w and s/w environments.
(including build/compile/link issues)
Also, given the way the IDE works, you end up with dead code in your build.
For example, you can end up with I2C/Wire code in your sketch when you are not using i2c.
This has to do with an interaction between the IDE's dumb build methodology, the wire code, some of the low level arduino core code and AVR macros for handling interrupts, and fm's library code.

Looking forward, I'd rather see a new/different set of multiple and separate/independent arduino libraries that are layered rather than the current design implementation  in fm's library package.
A base hd44780 lcd library and then i/o interface libraries that sit on top of that that depend on that base library.
This keeps everything very clean and you will never get any unused code in your build.
While fm's library is close to that type of architecture model, that is not where it is today.

The hd44780 library package that I'm working on, will use this model so it will not have library collision issues with any other libraries and should be easier to install.

The real problem with libraries and in particular layered libraries is in the IDE itself. Very early on, the Arduino team decided to pick a build methodology that didn't use REAL libraries and didn't use a clean location structure for "library" directories.
i.e. headers should have been specified as #include <libdirectoryname/libheader.h> instead of just as <libheader.h>
so that the sketch explicitly specifies the desired library by specifying its directory rather than expecting the IDE to magically locate the library by having to scan all the directories looking for the header file.
Because of that implementation decision as well as a few others, it is impossible for the IDE to determine sub library dependencies and because of not using REAL libraries, the linker can't be used to find them. And that is what makes doing sub libraries a mess.
The truly sad part is that what they have implemented is much more complicated, bigger, slower, and more effort to maintain with lots of subtle collision and and linking issues than having done it the "normal" way of handling header files.

They are a victim of their own ignorance and inexperience.

--- bill

Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 26, 2015, 06:45 pm
Can you hang around long enough to resolve the issue?

Can you provide more information as to your environment and what is happening and what you are seeing on the serial port vs the LCD as you use the IDE serial port monitor to talk to the guesser and step between each guess?

I'd also like to know:
- host operating system
- IDE version


--- bill

Windows 7 64 bit

Arduino 1.6.0

Serial Port Output:

i2cLCDguesser v1.4.1
 - Guess constructor for i2c LCD backpack
----------------------------------------------------------------
NOTE/WARNING: Guessing the i2c constructor is not really a
good thing since it could damage the hardware. Use with caution!
Do not leave things with an incorrect guess for too long.
i.e. advance to the next guess as soon as possible
when the guess in incorrect.
If the guess is correct, the constructor will show up
on the LCD.
----------------------------------------------------------------

<Press <ENTER> or click [Send] to Continue>
Scanning i2c bus for devices..
i2c device found at address 0x27
Device found: PCF8574
<Press <ENTER> or click [Send] to start guessing>
Trying: lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE)
<Press <ENTER> or click [Send] to Continue>
Trying: lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, NEGATIVE)
<Press <ENTER> or click [Send] to Continue>
Trying: lcd(0x27, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE)
<Press <ENTER> or click [Send] to Continue>
Trying: lcd(0x27, 6, 5, 4, 0, 1, 2, 3, 7, NEGATIVE)
<Press <ENTER> or click [Send] to Continue>
Trying: lcd(0x27, 6, 5, 4, 0, 1, 2, 3, 7, POSITIVE)
<Press <ENTER> or click [Send] to Continue>
Trying: lcd(0x27, 4, 5, 6, 0, 1, 2, 3, 7, POSITIVE)
<Press <ENTER> or click [Send] to Continue>


LCD Response:

For the first two, I get a few blinks of the backlight and all the lcd dots light on the entire display. No funky text, just all dots/pixels illuminated. For the others, I get some quick blinks and some funny things written on a dark screen.

Title: Re: Available LCDs and libraries
Post by: bperrybap on Jul 26, 2015, 08:04 pm
Interesting.

And the constructor parameters:
0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE
works properly in your sketch to display text and provide back light control?

Which Arduino board are you using and what geometry LCD are you using? (16x2, 20x4 etc...)


Do you power everything off before starting the guessing?
A power cycle for the LCD is important as there is no other way to reset the lcd.
It is possible that if the LCD gets into a confused state it won't properly respond even when the signals are correct.

I am assuming you are pushing/clicking the <enter>/[send] button to advance guesses?
and pausing after each?

What do you mean by:
Quote
For the first two, I get a few blinks of the backlight and all the lcd dots light on the entire display. No funky text, just all dots/pixels illuminated
How many blinks and for how long?
(The guesser tries to do 3 blinks of 1/4 second each)

Does the backlight stay on after the first guess? which is:
0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE
(It should turn on the backlight if that constructor works in your sketch)

Are you seeing any text on the LCD after the first guess?

and what does "all the lcd dots light on the entire display" mean?
As in all dots in each 5x8 character for all the character positions on the lcd display?
That sounds like a contrast issue.
Have you ever seen any text on that display?
i.e. is the contrast pot incorrectly adjusted?


Would it be possible to take a video of fist two guesses?

--- bill
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 26, 2015, 08:24 pm
Interesting.

And the constructor parameters:
0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE
works properly in your sketch to display text and provide back light control?

Yes, but backlight control is relative, I do not toggle the backlight (the old library did not provide that functionality and I don't (think I) need it.

Which Arduino board are you using and what geometry LCD are you using? (16x2, 20x4 etc...)
16x2

Do you power everything off before starting the guessing?
A power cycle for the LCD is important as there is no other way to reset the lcd.
It is possible that if the LCD gets into a confused state it won't properly respond even when the signals are correct.

I am assuming you are pushing/clicking the <enter>/[send] button to advance guesses?
and pausing after each?
I have not been power cycling. Just download, reset, and go.

I am clicking the send button and waiting for the lcd to stop doing whatever it was doing.

What do you mean by:
How many blinks and for how long?
(The guesser tries to do 3 blinks of 1/4 second each)
Maybe three blinks, but definitely not 1/4 sec each. Blinks are so quick I can't really count.

Does the backlight stay on after the first guess? which is:
0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE
(It should turn on the backlight if that constructor works in your sketch)
Yes backlight stays on.

Are you seeing any text on the LCD after the first guess?

and what does "all the lcd dots light on the entire display" mean?
As in all dots in each 5x8 character for all the character positions on the lcd display?
That sounds like a contrast issue.
Have you ever seen any text on that display?
i.e. is the contrast pot incorrectly adjusted?
No text. All dots in all positions. I too would think it would be a contrast issue except (a) the funky text I can see without the backlight in some of the other guesses and (b) it works (worked) with the old library and does work with my sketch.

Would it be possible to take a video of first two guesses?
Sorry. I don't have anything that videos to the computer.

Any chance the library and guesser I have are corrupt? Bad sketches?
Title: Re: Available LCDs and libraries
Post by: bperrybap on Jul 27, 2015, 01:08 am
Just to verify the setup.
I just downloaded Arduino 1.6.0 and fm's v1.2.1 library from his bitbucket site
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads (https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads)
, and the guesser sketch linked to in this thread.
To make that all that work with 1.6.0 all that is necessary is to unzip the LiquidCrystal library directory (not the MACios directory turd) from fm's zip v1.2.1 zip file into your sketchbook/libraries directory.
Make sure the directory for fm's library is named LiquidCrystal - which it should be after extracting from the zip image. The IDE will allow this library to override the system supplied directory.
You can still remove the IDE supplied one, but it is not necessary in this case with more recent IDEs  like 1.6.0
BTW, you may want to look at a newer IDE since there have been some really useful updates and bug fixes to the IDE since 1.6.0

I tested the guesser sketch on 4 different backpacks including one that uses the same wiring you said was on your backpack.


Just to confirm what you are seeing:
you are saying that after the guesser fails work, you can immediately upload your own sketch using a
LiquidCrystal_I2C(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) constructor with these exact parameters and it works?
No power off?

The reason I ask is that a power cycle is the only way to reset the LCD. If the LCD module is off in NeverNeverLand then it tends to remain that way until it is power cycled.
A power cycle before doing the guesses is the most reliable method to ensure that the LCD starts in a known state.

The blinks the guesser uses should be 250ms (1/4 second) each as it uses delay(250) to pause between backlight state transitions.
The backlight control is separate from the LCD initialization and should work even if the LCD is not working.
When the backlight pin and polarity is correct in the constructor, you will see 3 very distinct blinks by the guesser sketch and then the backlight will remain on.
You may want to look at only the backlight or side of the LCD where the backlight protrudes to see the actual backlight vs look directly at the front of the LCD as seeing the backlight can sometimes be difficult on reverse pixel displays like the one you have.

The very first guess the guesser sketch does is using the wiring that you said your backpack uses, so
If the backlight blinking is not working for that very first guess then something very basic is not working correctly as the backlight h/w and control is completely separate from the LCD control so it takes very little in terms of s/w configuration and setup to maket the backlight work.

What Arduino are you using and what clock rate is it running?

--- bill



Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 27, 2015, 01:36 am
Just to verify the setup.
I just downloaded Arduino 1.6.0 and fm's v1.2.1 library from his bitbucket site
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads (https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads)
, and the guesser sketch linked to in this thread.
To make that all that work with 1.6.0 all that is necessary is to unzip the LiquidCrystal library directory (not the MACios directory turd) from fm's zip v1.2.1 zip file into your sketchbook/libraries directory.
Make sure the directory for fm's library is named LiquidCrystal - which it should be after extracting from the zip image. The IDE will allow this library to override the system supplied directory.
You can still remove the IDE supplied one, but it is not necessary in this case with more recent IDEs  like 1.6.0
That was the source for the library per my browser history. Since I was afraid of a collision in the file names, was not as knowledgeable about the issues with fm's library, and most of all was replacing the previous LCD I2C libary, the directory was called LiquidCrystal_I2C.

The guesser sketch link a few posts back is the correct one? I downloaded the sketch from the most recent post with the link in this thread.

BTW, you may want to look at a newer IDE since there have been some really useful updates and bug fixes to the IDE since 1.6.0
Will do, but let's not change too many variables at once.

I tested the guesser sketch on 4 different backpacks including one that uses the same wiring you said was on your backpack.


Just to confirm what you are seeing:
you are saying that after the guesser fails work, you can immediately upload your own sketch using a
LiquidCrystal_I2C(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) constructor with these exact parameters and it works?
No power off?

The reason I ask is that a power cycle is the only way to reset the LCD. If the LCD module is off in NeverNeverLand then it tends to remain that way until it is power cycled.
That is 100% correct.

A power cycle before doing the guesses is the most reliable method to ensure that the LCD starts in a known state.

The blinks the guesser uses should be 250ms (1/4 second) each as it uses delay(250) to pause between backlight state transitions.
The backlight control is separate from the LCD initialization and should work even if the LCD is not working.
When the backlight pin and polarity is correct in the constructor, you will see 3 very distinct blinks by the guesser sketch and then the backlight will remain on.
You may want to look at only the backlight or side of the LCD where the backlight protrudes to see the actual backlight vs look directly at the front of the LCD as seeing the backlight can sometimes be difficult on reverse pixel displays like the one you have.

The very first guess the guesser sketch does is using the wiring that you said your backpack uses, so
If the backlight blinking is not working for that very first guess then something very basic is not working correctly as the backlight h/w and control is completely separate from the LCD control so it takes very little in terms of s/w configuration and setup to maket the backlight work.

What Arduino are you using and what clock rate is it running?

--- bill
I have noticed if I plug the LCD after power on and start up, then I must reset the Arduino/program/sketch (whatever you want to call it).

The unit is an Arduino Uno and genuine as far as I can tell. (I ended up with a counterfeit one, but am not using it especially for debugging). The crystal says 16.000, I'm assuming MHz.

I'm thinking the problem is on my end. Since all my data seems to match yours, it would be the logical conclusion.

I opted to go the Arduino route because I did not have the ambition to develop all the low level drivers the Arduino appeared to have already. I have spent too much time in my life doing that, but at least I was being paid for it. I have several development partnership projects in the works. This is one. The only thing I get is experience until they hit the market.
Title: Re: Available LCDs and libraries
Post by: bperrybap on Jul 27, 2015, 03:47 am
That was the source for the library per my browser history. Since I was afraid of a collision in the file names, was not as knowledgeable about the issues with fm's library, and most of all was replacing the previous LCD I2C libary, the directory was called LiquidCrystal_I2C.

The guesser sketch link a few posts back is the correct one? I downloaded the sketch from the most recent post with the link in this thread.
That is the latest one that I've published and that is the one I used.


Quote
I have noticed if I plug the LCD after power on and start up, then I must reset the Arduino/program/sketch (whatever you want to call it).
How are you plugging in the LCD? Are you removing/attaching the 4 pin i2c cable while the Arduino is powered?
It could be creating a power glitch on the Arduino board.
I do yank/attach the 4 pin cable when using the sketch, but I reset the Arduino when I do it because not all my backpacks use the same i2c address so I just push the reset button on the board to start the sketch clean so the sketch can probe for the i2c address.

Quote
The unit is an Arduino Uno and genuine as far as I can tell. (I ended up with a counterfeit one, but am not using it especially for debugging). The crystal says 16.000, I'm assuming MHz.
good enough. I was mainly wanting to know which microcontroller it was.
AVR 328, 1284, ARM, etc...

Quote
I'm thinking the problem is on my end. Since all my data seems to match yours, it would be the logical conclusion.
Hard to say for sure. There are some other differences between what the guesser does and what the normal library does in terms of handling of the PCF8574 from powerup (guesser does some probing first).
Also, your i2c chip may be different than the ones on my backpacks.
It could be that the probing I'm doing to detect the PCF8574 is freaking out the LCD chip or getting it out of sync with how the library is initializing things.
It shouldn't matter as a proper initialization sequence should clear up everything no matter what state the LCD and PCF8574 is in but perhaps there is an issue there for some LCD modules.

At this point, I'm not sure what the issue is, but I'd sure like to track it down as it could be an issue that might eventually show up in the library.

One thing that would be nice to know is if the R/W signal on the LCD is wired up to P1 on the PCF8574 or whether it is just grounded. Some backpacks ground it, and others wire R/W to a PCF8574 i/o pin.
Did you verify where LCD R/W pin goes?

In the mean time, I'm going to have a look at the library code and take a close look at the initialization code of the 8574 output port and LCD to see if I see anything.

--- bill
Title: Re: Available LCDs and libraries
Post by: bperrybap on Jul 27, 2015, 04:03 am
So there is a piece of code that is incorrect in the LiquidCrystal_I2c code.
I fixed this long ago so I'm not sure why it is still there in the latest code.

In the module LiquidCrystal_I2C.cpp
look for this:
Code: [Select]
// setBacklightPin
void LiquidCrystal_I2C::setBacklightPin ( uint8_t value, t_backlighPol pol = POSITIVE )
{
   _backlightPinMask = ( 1 << value );
   _polarity = pol;
   setBacklight(BACKLIGHT_OFF);
}


And change it to this:
Code: [Select]
// setBacklightPin
void LiquidCrystal_I2C::setBacklightPin ( uint8_t value, t_backlighPol pol = POSITIVE )
{
   _backlightPinMask = ( 1 << value );
   _polarity = pol;
}


(remove the setBacklight() call.)

I'm not sure how the code is working with that there. In the older versions of the IDE that would hang because it was making i/o calls before other parts of the code and Wire h/w were initialized.
That call is not necessary anyway.
Not sure how that could cause the issue we are seeing but it needs to be fixed anyway.

--- bill
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 27, 2015, 04:23 am
How are you plugging in the LCD? Are you removing/attaching the 4 pin i2c cable while the Arduino is powered?
It could be creating a power glitch on the Arduino board.

I mean plugging it in, as in plugging it in for the first time. Not disconnect and then reconnect. I mean I'm an idiot and forgot to plug it in when I downloaded the sketch. Many projects, many LCDs, few Arduinos, with even fewer near the programming computer.

R/W is connected to pin5 aka P1.

I have gone ahead and done all the library related things you have listed. As I mentioned, I had replaced my sketch-LiquidCrystal_I2C directory with the contents fm's library. I have now deleted both the sketch and the IDE LiquidCrystal directories and unzipped (the non-MAC) files into an IDE directory called LiquidCrystal. It seems to be working. During detection now, the backlight is on as well as all of the LCD dots. Is it supposed to be like that?

I'm glad the instructions on installing this library are clear as mud. LOL.
Title: Re: Available LCDs and libraries
Post by: bperrybap on Jul 27, 2015, 07:07 am
R/W is connected to pin5 aka P1.
ok so R/W is hooked up to the PCF8574. Most backpacks are this way.

Quote
I have gone ahead and done all the library related things you have listed. As I mentioned, I had replaced my sketch-LiquidCrystal_I2C directory with the contents fm's library. I have now deleted both the sketch and the IDE LiquidCrystal directories and unzipped (the non-MAC) files into an IDE directory called LiquidCrystal. It seems to be working. During detection now, the backlight is on as well as all of the LCD dots. Is it supposed to be like that?
Not sure what you mean by "It seems to be working" or "During detection now, the backlight is on as well as all of the LCD dots".

When the LCD powers up before it is initialized, one row of characters on a 16x2 LCD will be "blocks" with all pixels for each character position turned on. The other row will have its pixels off.
Once the LCD is properly initialized all the pixels will be cleared.
The guesser sketch attempts to initialized the LCD and then print the constructor on the display.

Quote
I'm glad the instructions on installing this library are clear as mud. LOL.
Part of the problem is that the Arduino guys change the IDE constantly (way too often in my opinion) so it can be difficult to make one set of instructions that can work for different releases of the IDE.
There are also some things that can make things easier on newer releases that don't work on the older releases.
Title: Re: Available LCDs and libraries
Post by: Paul__B on Jul 27, 2015, 08:12 am
The unit is an Arduino Uno and genuine as far as I can tell. (I ended up with a counterfeit one, but am not using it especially for debugging). The crystal says 16.000, I'm assuming MHz.
It is, but the crystal is not connected to the ATmega328.

Nevertheless, the UNO runs at 16 MHz.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 27, 2015, 11:32 am
When the LCD powers up before it is initialized, one row of characters on a 16x2 LCD will be "blocks" with all pixels for each character position turned on. The other row will have its pixels off.
Once the LCD is properly initialized all the pixels will be cleared.
The guesser sketch attempts to initialized the LCD and then print the constructor on the display.
On power up, I see the backlight and one row of dot on, the other off. When the guesser searches and finds the LCD, the LCD is on with all dots on both rows lit. After I click send, the LCD blinks 3 times and then the constructor appears with the backlight on.
Title: Re: Available LCDs and libraries
Post by: bperrybap on Jul 27, 2015, 05:47 pm
On power up, I see the backlight and one row of dot on, the other off. When the guesser searches and finds the LCD, the LCD is on with all dots on both rows lit. After I click send, the LCD blinks 3 times and then the constructor appears with the backlight on.
It sounds like it is working now.
Although I've not ever seen a LCD turn on all the pixels after probing.

What changed or what is being done differently?
Previously, it sounded like text for the constructor never appeared on the display.
Title: Re: Available LCDs and libraries
Post by: adwsystems on Jul 27, 2015, 10:09 pm
Unfortunately I followed the instructions for adding libraries to the IDE. Based on the discussion here, that is not correct (or doesn't work, pick your poison). I made all the library related changes you listed. Initially I had just replaced the fdebrabander library in the sketch-LiquidCrystal_I2C directory with the contents fm's library. I since deleted both the sketch and the IDE LiquidCrystal directories and unzipped (the non-MAC) files into an IDE directory called LiquidCrystal.

Not sure how anyone new to fm's library would come to the conclusion this was the proper method. But if it works...
Title: Re: Available LCDs and libraries
Post by: Nasa on Jul 27, 2015, 10:34 pm
I first had problems making my program compile using the Arduino IDE until I found I had multiple LCD libraries. Some of the libraries are located in C:\Program Files (x86)\Arduino\libraries while on mine some libraries are located in C:\Users\xxx\Documents\Arduino\libraries . I deleted all LCD libraries and installed LCD_I2C Library found on http://playground.arduino.cc/Main/LCDI2C . Good explanation on the libs here also.

After that I have had no problems.