Standard LCD 16x2 displays random characters
Moderators: adafruit_support_bill, adafruit

Standard LCD 16x2 displays random characters

by berko on Wed Nov 28, 2012 3:41 pm

i purchased a Standard LCD 16x2 + extras - white on blue and followed the tutorial examples to get it going and all worked fine: http://learn.adafruit.com/character-lcds/using-a-character-lcd

Now i have moved on to the next step that i wanted to do which is add a second pot that i can use to scroll through messages.
I connected the pot's center pin to anolog pin A0 and Left to gound, right to 5V both directly on the Arduino Uno.

i have tried powering both from the usb port and a 9V battery.

this works most of the time but sometimes the screen will display random characters (mostly looking like junk but sometimes repeating part of the string to be displayed or the whole string.

is this noise from somewhere? a loose connection? bad code?

let me know if you want pictures. i am doubting it is a solder issue since i had no issues with any of the example scripts.

Code: Select all | TOGGLE FULL SIZE
// include the library code:
#include <LiquidCrystal.h>

LiquidCrystal lcd(7,8,9,10,11,12);  //to hold the pins of the display
int sensorPin = A0; //pin to read the selection pot
int sensorValue; //to hold the value selected
int currentMessage = 0; //to see if the message has changes since last loop through
String messages[] = {"hello","how are you?","good","me too, thanks!"}; //array of messages

void setup() {
  lcd.begin(16,2);   // set up the LCD's number of columns and rows
  pinMode(sensorPin, INPUT); //set up the pin to read the pot
}

void loop() {
  lcd.setCursor(0,0);
 
  sensorValue = analogRead(sensorPin); //read the pot
  sensorValue = map(sensorValue, 0, 1000, 0, 3); //divide the pot reading into the number of values to match the number of messages
 
 //if statement used to check to see if value changed since last time through.  if true clear old message and set currentMessage value to new message value
  if (currentMessage != sensorValue) {
    currentMessage = sensorValue;
    lcd.clear();
  }
 
  lcd.print(messages[sensorValue]);  //print the message to the display
}
User avatar
berko
 
Posts: 53
Joined: Sat Aug 04, 2012 5:44 pm

Re: Standard LCD 16x2 displays random characters

by berko on Wed Nov 28, 2012 3:48 pm

two more things.
i just added a Serial.println to print the message that should be displayed and when the random characters appear the code is still printing the correct message to the serial monitor.
so i think this may rule out a code issue.
added the following two lines of code. first line as the first line in setup() and the second line as the last line in loop().

Code: Select all | TOGGLE FULL SIZE

Serial.begin(9600); //first line of setup()

Serial.println(messages[sensorValue]);  //last line of loop()


and the second thing:
if i hit the arduino reset button the message on the LCD goes back to the correct message and the random characters are gone.
User avatar
berko
 
Posts: 53
Joined: Sat Aug 04, 2012 5:44 pm

Re: Standard LCD 16x2 displays random characters

by berko on Wed Nov 28, 2012 4:06 pm

Image

Image

Image
User avatar
berko
 
Posts: 53
Joined: Sat Aug 04, 2012 5:44 pm

Re: Standard LCD 16x2 displays random characters

by adafruit_support_bill on Thu Nov 29, 2012 5:59 am

Could be a loose connection or noise. Considering that it is on a breadboard, the first case is the most likely.

Once the display gets out-of-sync, anything you send to it will be garbled until it it re-initialized when you restart the sketch.
User avatar
adafruit_support_bill
 
Posts: 29162
Joined: Sat Feb 07, 2009 9:11 am

Re: Standard LCD 16x2 displays random characters

by RJF on Sun Feb 03, 2013 3:52 pm

Exactly same as berko.

Detail:
I recently purchased from you (adafruit conf# 218042) a
Standard LCD 16x2 + extras - white on blue ID: 181

In this regard, seeing same as berko (above) .....apparently.

The LCD is wired and configured per:
http://learn.adafruit.com/character-lcds
Wiring is currently all properly soldered.
All wiring is ~6inch length, 20gauage solid conductors.

All works well ~95% of the time; Arduino Re-Set required to correct.
Suspect strange characters maybe caused by EMI; However,
present setup is at tried & true lab setup.
The system is built on Arduino Mega 2560 R3 and all is being powered by high quality
regulated lab ps (+5V from ps for the LCD).
Simultaneous monitoring of same display data, via pc from RS232 thru 2560, indicates that all data is ok (ie, not corrupt)....
same as previous per berko.

I suggest that the subject LCD is not properly engineered, else
there must be suggested cap power filter, EMI shielding, etc ?
Thank you in advance for any assistance!
RJF
 
Posts: 5
Joined: Mon Jan 07, 2013 3:01 pm

Re: Standard LCD 16x2 displays random characters

by adafruit_support_bill on Mon Feb 04, 2013 6:16 am

In my experience, they are somewhat susceptible to noise. I have one (all soldered connections & a regulated supply) that used to have this problem. The source turned out to be a compressor motor on the same lab circuit. Since moving the device to a different circuit I have not had a problem.
User avatar
adafruit_support_bill
 
Posts: 29162
Joined: Sat Feb 07, 2009 9:11 am

Re: Standard LCD 16x2 displays random characters

by RJF on Mon Feb 04, 2013 9:34 am

Any suggested filter circuitry ?
Any code which might be employed to sense if noise characters are being presented on the LCD ?
thx.
RJF
 
Posts: 5
Joined: Mon Jan 07, 2013 3:01 pm

Re: Standard LCD 16x2 displays random characters

by adafruit_support_bill on Mon Feb 04, 2013 10:28 am

Filtering noise can be a tricky business. The best solution depends on the nature of the noise and how it is coupling into the system. If you can identify the source and suppress it there that would be ideal. But that is often not possible or practical.

Things you can try are:
    Bypass caps on power as close to the component as possible.
    Ferrite beads on incoming power & signal lines.
    Shielded cables for signal lines.
    Re-route wires to minimize inductive coupling (keep wires separated and try to cross only at right angles)
    Shielding of the device.
    Move the device to a different circuit.
    Move the device away from the source of noise.
User avatar
adafruit_support_bill
 
Posts: 29162
Joined: Sat Feb 07, 2009 9:11 am

Re: Standard LCD 16x2 displays random characters

by RJF on Mon Feb 04, 2013 10:38 am

Thx.
RJF
 
Posts: 5
Joined: Mon Jan 07, 2013 3:01 pm

Re: Standard LCD 16x2 displays random characters

by RJF on Mon Feb 18, 2013 2:13 am

Is there a spec on the maximum wired distance the "Standard LCD 16x2" may be located from the uP (Mega) ?
I've a need for it to be ~12 to 14inches from the uP.
Thx in advance for reply!
RJF
 
Posts: 5
Joined: Mon Jan 07, 2013 3:01 pm

Re: Standard LCD 16x2 displays random characters

by adafruit_support_rick on Mon Feb 18, 2013 10:22 am

No spec. But 12-14" shouldn't be a problem, unless you're in a particularly noisy environment.
User avatar
adafruit_support_rick
 
Posts: 11638
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Standard LCD 16x2 displays random characters

by RJF on Mon Feb 18, 2013 11:09 am

thx db.
RJF
 
Posts: 5
Joined: Mon Jan 07, 2013 3:01 pm