Pages: [1] 2 3 4   Go Down
Author Topic: 4x20 LCD I2C Adapter - 1st 4 char of line4 repeated over last 4 char of line2  (Read 1817 times)
0 Members and 1 Guest are viewing this topic.
Lebanon, Indiana, USA
Offline Offline
Full Member
***
Karma: 3
Posts: 132
Old fart playing around with itty bitty control computers.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

********   P R O B L E M    S O L V E D  *******  T H A N K S   F O R   Y O U R    H E L P   ************
     It just so happens that the very first 4x20 LCD I bought in my life was bad.  Odds?

The first 4 characters of line 4 overlays the last 4 characters of line 2 on my 4x20 LCD display with I2C adapter.
Arduino Uno R3 2012.  Using fm's New LiquidCrystal library.

Simple test program:
Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup()
{
  lcd.begin(20,4);               // initialize the lcd
}

void loop()
{
   lcd.home();
   lcd.clear();
   lcd.print("Line2GoofedUpExample");
   lcd.setCursor ( 0,1);
   lcd.print("ThisIsTheSecondLine2");
   lcd.setCursor (0,2);
   lcd.print("ThisIsTheThirdLine33");
   lcd.setCursor(0,3);
   lcd.print("LastLineFirst4Repeat");  
  
   delay (2000);
}

This displays:
Code:
Line2GoofedUpExample
ThisIsTheSecondLLast
ThisTheThirdLine33
LastLineFirst4Repeat

No matter what I print in the 4th line, the 1st 4 characters overlay the contents of the last 4 characters of the 2nd line.

I tried this with 3 different I2C adapters from 2 different sources.  I only have the one 4x20 LCD.

Anyone heard of this before?  
Got any ideas for something I can try?

John
« Last Edit: March 14, 2014, 11:15:39 am by OldSalt1945 » Logged

Always keep the shower curtain INSIDE the tub.

Offline Offline
Faraday Member
**
Karma: 95
Posts: 5665
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

20-4=16. Is there any chance it is really a 16x4 ?  Apparently they do exist:
http://www.amazon.com/JAMECO-VALUEPRO-16X4-PARALLEL-DISPLAY/dp/B00B88C0VK


Admittedly that is just a shot in the dark...
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Lebanon, Indiana, USA
Offline Offline
Full Member
***
Karma: 3
Posts: 132
Old fart playing around with itty bitty control computers.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Naaah.   I thought about the 16 chars deal, but  it prints all 20 characters on each of the 4 lines.

It might be a hardware problem, I just don't know.  I'm sure that if it were fm's LiquidCrystal library, someone would have run across this and fixed it before now.  4x20's are not uncommon.

I'm hoping to find a RSG (army speak for real smart guy) that will know the answer.

John
Logged

Always keep the shower curtain INSIDE the tub.

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4331
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


A 16x4 would definitely give you addressing problems with any library derived from the regular LiquidCrystal library but I think this is an unrelated problem.

To find out what is going on you should start by having the code run once and then stop.  This means that your 'test' code should be in setup() and loop() should be blank (nothing between the brackets).  Try that and let us know what happens.


Don




Logged

Lebanon, Indiana, USA
Offline Offline
Full Member
***
Karma: 3
Posts: 132
Old fart playing around with itty bitty control computers.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Put all the code in the setup section.  Nothing in the Loop Section.  Arduino doing nothing very fast. smiley

Same results...........................Rats.....!!!!!

John
Logged

Always keep the shower curtain INSIDE the tub.

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4331
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now you have to put a pause between each line to see when the problem occurs.  You may even want to rewrite things to put a pause between each character.

Don
Logged

Offline Offline
Faraday Member
**
Karma: 95
Posts: 5665
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void loop()
{
   lcd.home();
   lcd.clear();
   lcd.print("Line2GoofedUpExample");
   lcd.setCursor ( 0,1);
   lcd.print("ThisIsTheSecondLine2");
   lcd.setCursor (0,2);
   lcd.print("ThisIsTheThirdLine33");
   lcd.setCursor(0,3);
   lcd.print("LastLineFirst4Repeat");   
   
   delay (2000);

Do you see a "lcd.setCursor(0,4);" statement ?
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Lebanon, Indiana, USA
Offline Offline
Full Member
***
Karma: 3
Posts: 132
Old fart playing around with itty bitty control computers.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Very wierd!

All characters are blanked out.

The first line prints correctly.

The 2nd line prints correctly, but the last 4 characters of line 2 are duplicated on the 1st 4 characters of line 4.

The 3rd line prints correctly.

The 4th line prints correctly, but the first 4 characters of line 4 replace the last 4 characters of line 2.

They are obviously sharing the same memory space for those 4 characters.

I changed the sketch and put the code back in the Loop section with the pause between lines, but not clearing the screen between loops.
When line 2 is written, it changes back to the original content, but goofs up line 4, proving that they share memory space.

Now all we need to know is hardware or software?

Hints?????????????

John
Logged

Always keep the shower curtain INSIDE the tub.

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4331
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Very wierd!

All characters are blanked out.

The first line prints correctly.
etc
To which post are you responding?

Don
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4331
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do you see a "lcd.setCursor(0,4);" statement ?
No.  Do you?

Don
Logged

Lebanon, Indiana, USA
Offline Offline
Full Member
***
Karma: 3
Posts: 132
Old fart playing around with itty bitty control computers.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I was answering Don's suggestion for a test with pause, but you posted between.

Now I'm trying to figure out what I did wrong, missing the 0,4

John
Logged

Always keep the shower curtain INSIDE the tub.

Offline Offline
Faraday Member
**
Karma: 95
Posts: 5665
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's a 4 line display. Shouldn't there be one ?



« Last Edit: March 12, 2014, 09:39:33 pm by raschemmel » Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4331
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Now I'm trying to figure out what I did wrong, missing the 0,4
Stop figuring.  If you found one it would be wrong.

Don
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4331
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It's a 4 line display. Shouldn't there be one ?
No.  You start your counting with 1 but most programmers start with 0.

Don
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4331
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Then it's missing the lcd.setCursor(0,0);"

You really need to look into the Instruction Set in the HD44780U datasheet.   The 'Clear display' instruction would be a good place to start.

Don

Edit: In case anyone is wondering there is a post that has been deleted.
« Last Edit: March 12, 2014, 09:43:04 pm by floresta » Logged

Pages: [1] 2 3 4   Go Up
Jump to: