Pages: [1]   Go Down
Author Topic: HD44780 LCD being sent incorrect data  (Read 94 times)
0 Members and 3 Guests are viewing this topic.
Tearing my hair out, Melbourne, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good Morning all,

I have had a HD44780  LCD wired up to my Arduino for around 2 weeks now. I have been testing different code on it and everything worked perfectly. The wiring was standard, with the only exception being the contrast pin going directly to GND. Everything was peachy.

//Problem 1
I had run the Arduino and LCD off battery and USB before, so the first problem was unexpected. One day, I decided to run the board off battery because I didn't have my laptop. I plugged in a 9V battery into GND and Vin as I had done countless times before. Nek minnit black squares with the correct text showing very faintly beneath the squares. The backlight also shone brighter than usual.
I dug up a 10k pot and add that to the contrast pin to see what would happen, but as expected, the black squares with faint text became grey squares with fainter text. Nothing had changed since the last time that I ran the board from battery. The board was sourcing power from the 5V pin, so I was surprised that the backlight brightness would be different when using battery power instead of USB.

//Problem 2
I decided to rewire the whole thing just in case a wire was wobbly. It got worse. As of now, connecting the LCD like this (Pin1 to 5V, Pin2 to GND, Pin3 to GND) does not display the test display row of black squares that is expected.
When I upload the example sketch "Blink", it takes around 10 uploads before something other than black squares is displayed. When it does work, I get the "hello, world!" message followed by the blinking cursor for around 10-20 seconds. After that, the screen can start outputting rubbish, go blank, or clear itself and place the blinking cursor at 0,0

I then decided to try running my original code on it just to see what happened.

Code:
#include <LiquidCrystal.h>

LiquidCrystal lcd(4, 6, 8, 9, 10, 11);

const int buttpin = 12;
int buttonstate = 0;
int textpos = 11;
int originaltextpos = 11;
int time = 0;

void setup() {
  lcd.begin(16, 2);

  lcd.setCursor(16,0);
  lcd.autoscroll();
  char bootMsg[] = "Waiting for EDI ";
  for(int i =0; i<16; i++){
    lcd.print(bootMsg[i]);
    delay(200);
  }
  lcd.noAutoscroll();
  //button pin 13
  pinMode(buttpin, INPUT);
  lcd.clear(); //why is this needed?
}

void loop() {
  lcd.setCursor(0,0);
  lcd.print("Waiting for EDI ");
  lcd.setCursor(13,1);
  lcd.print("sec");
  time = millis()/1000+3547;
 
  if(time>9999){
    textpos = originaltextpos-4;
  }else if(time>999){
    textpos = originaltextpos-3;
  }else if(time>99){
    textpos = originaltextpos-2;
  }else if(time>9){
    textpos = originaltextpos-1;
  }
  lcd.setCursor(textpos,1);
  lcd.print(time);
  //read button
  buttonstate = digitalRead(buttpin);
 
  if(buttonstate == HIGH) {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Monkeys Tamed   ");
    lcd.setCursor(0,1);
    lcd.print(random(0,100));
    delay(3000);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Idle Employees  ");
    lcd.setCursor(0,1);
    lcd.print(random(8,50));
    delay(3000);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Money Saved     ");
    lcd.setCursor(0,1);
    lcd.print("$");
    lcd.setCursor(1,1);
    lcd.print(random(100,10000000));
    delay(3000);
    lcd.clear();
  }
}

Complete rubbish.

I pared down the code until it was pretty much the same as the example sketch "HelloWorld", and it still only showed something meaningful every 10-20 uploads. Even then, the leftmost 8x2 characters were fainter than the rest, and seemed to be flickering.

I have found that the lcd.setCursor and lcd.clear() commands confuse the display and make it go blank or start spewing random chars.

//My expression -> O_o
Can anyone tell me what is going on or hazard a guess as to what the heck is wrong with my LCD/Arduino?

I have not:
☺shorted the LCD
☺swapped the 5V and GND on the LCD

P.S. Does it matter that I am running the display in 4 bit mode and leaving the other 4 bits' date lines disconnected? I don't think it is a problem as they were never connected to anything back when the display was working fine.

;_;
Logged

Electronics?      O_o

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

Quote
As of now, connecting the LCD like this (Pin1 to 5V, Pin2 to GND, Pin3 to GND) does not display the test display row of black squares that is expected.

Quote
I have not:
☺shorted the LCD
☺swapped the 5V and GND on the LCD

I have seen at least one datasheet for a device with +5V on pin 1 and GND on pin 2 but the vast majority are the other way around.  You haven't identified your device so we can't check this part out.

Quote
Does it matter that I am running the display in 4 bit mode and leaving the other 4 bits' date lines disconnected?
No.

It's time to start over.
Here is my generic step by step approach that should work:

(1) If the module has a backlight then get it working properly.  This involves only pins 15 and 16 on most LCD modules.  Make sure to use a current limiting resistor if there is none on the LCD module.

(2) Get the power and contrast working properly.  This involves only pins 1, 2, and 3 on most LCD modules.  You should be able to just barely see blocks on one row of a two row display and on two rows of a four row display. 

NOTE:  The Arduino has not been used yet, except as a possible source for the power needed for the first two steps.  Do not try to go any further until this is working.  If you don't see the blocks then no amount of program code will help.

(3) Connect the LCD R/W pin (pin 5) to GND.

(4) Connect the six control and data wires between your LCD module and your Arduino.

(5) Upload your sketch and it should work.


Troubleshooting:

If you have a 16x1 display and there are blocks only on the left half of the row in step 2 then use lcd.begin(8, 2); in your sketch.

If you still don't get a display then make sure that your wiring matches the numbers in the descriptor (or vice versa).


Code:
//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here

If you get a display but it is garbled or has some other problems then try again with a 'static' sketch, one that displays a simple message on the top row of the display and then stops.  All of your code should be in setup() and loop() should be empty between the brackets.

Code:
#include <LiquidCrystal.h>

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here

void setup()
  {
  lcd.begin(16, 2);                          // put your LCD parameters here
  lcd.print("hello, world!");
  lcd.setCursor(0,1);
  lcd.print("it works!");
  }

void loop()
  {
  }

If you are still having problems then we need to see a photograph of your setup that clearly and unambiguously shows all of the connections between your Arduino and your LCD module.  We also need a copy/paste version of the code that you are actually using, not a link to the code that you think you are using.

Don


Logged

Tearing my hair out, Melbourne, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I haven't yet had time to play with the Arduino, but I had just enough time to poke at some things with a multimeter.

Results:
The 5V pin on the Arduino sits at 8V when the board is running off a 9V battery.
THAT probably explains why the backlight is brighter.
I don't know if that would mess with the data that the LCD receives though.

Could it be that the board was just faulty to begin with and the regulator just decided to die on me?
Logged

Electronics?      O_o

Pages: [1]   Go Up
Jump to: