Strange characters on display

Hi,

I'm newbie with arduino and I have strange problem with display. I use Arduino Ethernet with 1602display (Hitachi HD44780 controller) with serial controller. Every 2sec I send new strings on display. And sometimes (2-3 times within a minute) I got strange chars on display. This is my code

  Serial.print(12, BYTE);  //clear LCD
  Serial.print(1,BYTE); //move to the Home
  Serial.print("Voltage: ");
  Serial.println(voltage);
  Serial.print(13, BYTE);
  Serial.print("Temp.: ");  
  Serial.println(temperature);
  Serial.print(4, BYTE);
  delay(2000);

and on this video you can see what's happening.

http://youtu.be/oAwxDx91HDQ

What I'm doing wrong and how can I fix this?

thanks

try a 250mS delay after clear screen ensures the hardware (and software) has time to catch up

You really should avoid 'clearing' the screen if you can. You should consider displaying the non-changing information once, in setup(), and displaying only the changing information in loop(). This will involve some cursor positioning and some printing of 'spaces' to cover up old data but it will remove the need for an extended delay.

Don

floresta:
You really should avoid ‘clearing’ the screen if you can. You should consider displaying the non-changing information once, in setup(), and displaying only the changing information in loop(). This will involve some cursor positioning and some printing of ‘spaces’ to cover up old data but it will remove the need for an extended delay.

Don

why’s that Don?
is it just to avoid the delay, or is there something more sinister??

mmcp42: try a 250mS delay after clear screen ensures the hardware (and software) has time to catch up

I've tried but it doesn't help. I increase the time also to the 500ms but same thing happens.

I've also tried printing " " (whitespaces) but without success.

wonder if it's noise what else is in the circuit?

There have been lots of reports of garbled characters on LCDs recently. Some suggestions:

  1. Add a decoupling capacitor between the Vdd and Vss pins of the lcd, either soldered on the lcd connector or as close to it as possible. There is probably one on the lcd board already, but one user reported said that adding another eliminated the problem. Try 10uF.

  2. Keep the wires from the lcd to the Arduino (especially the ground wire) short, and keep them away from sources of interference.

why's that Don? is it just to avoid the delay, or is there something more sinister??

Avoiding the delay is part of it since the Clear Display and Home the Cursor instructions take much more time than the others. Incidentally, the Hitachi instruction that clears the display also homes the cursor so you probably don't need both of those commands. If you do use both commands then the extra delay, if that is the answer, would be required after each of them.

Good programming practice is another part. This sledgehammer approach is OK when you are starting out (like now) but your final program will be more elegant if you don't redisplay stuff that doesn't have to be redisplayed. That's part of how a teacher of programming distinguishes between the A, B and C versions of a working program.

wonder if it's noise what else is in the circuit?

You haven't answered this question.

It would also be interesting to know what all the magic numbers are supposed to do. That's the purpose of comments in a program. A link to the datasheet for the serial controller would be appropriate as well.

Don

I was trying to fix this last 2 days but without success.

floresta: Avoiding the delay is part of it since the Clear Display and Home the Cursor instructions take much more time than the others. Incidentally, the Hitachi instruction that clears the display also homes the cursor so you probably don't need both of those commands. If you do use both commands then the extra delay, if that is the answer, would be required after each of them. [/quote]

Ok, I've done this but it still prints strange characters. I've tried this :

void writeSecondLine(char msg[]){
  Serial.write( byte(2) );
  Serial.write( byte(17) ); // position cursor on the beging of the second line
  delay(100);
  Serial.print("             ");
  delay(100);
  Serial.write( byte(2) );
  Serial.write( byte(17) ); // position cursor on the beging of the second line
  delay(100);
  Serial.print( msg ); 
};

If I call this function 2ice with 1000ms delay it works fine, 5-6 times and then it starts to overwrites first line which is printed only once in setup();

I have this display.

Good programming practice is another part. This sledgehammer approach is OK when you are starting out (like now) but your final program will be more elegant if you don't redisplay stuff that doesn't have to be redisplayed. That's part of how a teacher of programming distinguishes between the A, B and C versions of a working program.

I need to use second line for different type of messages so I need to rewrite whole line (initial case was only example how I'm started).

wonder if it's noise what else is in the circuit?

I have arduino Ethernet, TMP36 temp sensor and this display connected.

It would also be interesting to know what all the magic numbers are supposed to do.

I need to mesaure temperature every 1-2 sec and to show it on display.

thank you.

I haven't tried with capacitor because I don't have it right now.

I haven't tried with capacitor because I don't have it right now.

I'd go for the capacitor first noise will not just go away

I have this display.

So you expect me to look up the magic numbers??? What if I am not around a year or ten from now when you want to figure out how your program is supposed to work?

Example: Serial.write( byte(2) );

Don