Go Down

Topic: 16x2 Works fine then Garbled (Read 1 time) previous topic - next topic

nnimcmj

Hello All,

Been working on my project and have run into a snag. My LCD display will get all garbled randomly while the code is measuring a Analog Input. If I go to a section of the code that is not using the AD the display is fine. I can't seem to fine the issue. Sometimes the LCD print out is fine through the measuring section, Other times it gets all garbled.
The only way to get things working again is to hit the reset. I've try different LCD with the same results. Every thing is powered from the Adruino VCC.
I'm using the 4 Bit mode on the LCD, and the library is LiquidCrystal.h.

I'm new to this so I'm sure its my code it'c just the randomness of the issue that has me stumped. I have include my setup and a section that measure the analog. If more is need to figure it out let me know.

THANKS
Code: [Select]

// include the library code for the LCD:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(3, 4, 5, 6, 7, 8);



Code: [Select]

void setup() { // LCD
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  analogReference(DEFAULT); // Set Analog reference to 5 Volts
  pinMode(2, INPUT); // RPM Interupt
  pinMode(9,INPUT);// Sets di 9 as input ZeroPB & RMS Mode select
  pinMode(10,INPUT);// Sets di 10 as input MMS Mode Select
  pinMode(11,INPUT);// Sets di 11 as input Current Mode Select
  pinMode(12,INPUT);// Sets di 12 as input RPM Mode Select
  pinMode(13,INPUT);// Sets di 13 as input

  // Print a start up message to the LCD.
  lcd.print("MMS Complete!");
  lcd.setCursor(0, 1);
  lcd.print("Select a mode");
}



Here is where I get the random Garbled LCD on both line

Code: [Select]

lcd.setCursor(0, 0);
  lcd.print("RMS Mode");
  delay(100);
  // set the cursor to column 0, line 2
  lcd.setCursor(0, 1);
  lcd.print("                ");
  lcd.setCursor(0, 1);
  // Measurement section
  A1_Value = analogRead(A1)-Zero; // read A1 value - the senors zero state
  F1 = A1_Value*4.8875;  // convert the AD to Volts 4.8875 per steps (5 / 1023)
  if (F1<-100.0) {
    F1=  (F1-RMS_trim);
  }
  else if  (F1>100.0) {
    F1= RMS_trim + F1;
  }

  lcd.print(F1,0);  // Print to LCD with out decimal

  delay(500);





liudr

Why do you do lcd.print(XXX,0)?

Is there a base zero option? I don't know about that though. Did you mean DEC?

nnimcmj

that print the float with out a decimal

Why do you do lcd.print(XXX,0)?

Is there a base zero option? I don't know about that though. Did you mean DEC?

that printed the float with out a decimal. it worked maybe wrong.


As a test I connected a Serial enabled LCD and added the code to print to the serial enabled LCD. The LCD connected to the Adruino directly gets garble but the serial LCD doesn't. Attached is a pic of the garbled LCD if that helps.

liudr

So the parallel display, when displaying information unrelated to analog read, is just fine, right?

Can you show the wiring of the display and details of what you're sensing with analog input?

nnimcmj


So the parallel display, when displaying information unrelated to analog read, is just fine, right?

Can you show the wiring of the display and details of what you're sensing with analog input?


Yes the second LCD(which the Arduino is talking with serially) that I added doesn't get garbled. But the one the Adrunio is directly connected does get garbled.
The Garbling, on closer inspection happens anywhere I print to the display in a loop.... Could I be overrunning the display. It strange the the serial LCD in the same loop is fine. And remember the garbling seems random. I'll try increasing the loop delay from 500msec to 1sec...

liudr

Is the RW pin on the LCD (pin 5) tied to the ground? It should.

nnimcmj

Eureka!!!   :smiley-mr-green:
Schematic was right but the wiring wrong. I had LCD pin 1 to 5 shorted and ground on 16 but forgot the jumper form 1-5. Thanks for making me look.

liudr


Eureka!!!   :smiley-mr-green:
Schematic was right but the wiring wrong. I had LCD pin 1 to 5 shorted and ground on 16 but forgot the jumper form 1-5. Thanks for making me look.



Don't understand what you meant by 1 to 5 shorted. Just for the sake of another reader, could you explain?

nnimcmj

Pins 1, 5, and 16 all go to ground. I had a jumper between 1and 5(the short) and the ground form the Arduino on 16 but never connected 16 to 5

floresta

Quote
... I had a jumper between 1and 5(the short) ...

'Jumper' is the better term.  A 'short' is usually perceived as something that is unintentional and undesirable.

Don

liudr

I see it now. Your pins 1 and 5 on the LCD were floating instead of tied to the ground. Thanks for making it clear.

Go Up