Go Down

Topic: Arduino plus LCD crashing when printing on LCD (Read 978 times) previous topic - next topic

Kiis

Hey Guys

We are a couple of dudes who have a big problem. We are creating an interface of several menus using the LCD Library but we have now reached a limit for how many different printlines we can have in the source code. We are not printing these lines in the on the same time, but if we create too many different printlines the program simply chrashes, even though the added printlines arent even the one being loaded. We still have a lot of space left on the Arduino. So any ideas to what can be wrong or a solution to the probelm?

Thanks!   

robtillaart


remove the String class from your code and/or google for the F() macro.

posting your code might give you a more elaborated answer
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Kiis

Our code is plus a 1000 lines long so it won´t make much sense posting it when the problem is not a specific code but adding any more code of lcd.print(" ......"); which causes the chrash.

arduinodlb

Sounds like a general program size issue more than a specific LCD.print("...."); issue.

When you say the program crashes, does the Arduino crash? Or the download crashes? Or the compile crashes?
Do not IM me. I will not respond. Ask questions in the forum.

Kiis

The display either shows random things or just shuts down. 

arduinodlb

Which display? The LCD display?

So, the download works fine and the Arduino starts up? Random things on the display doesn't sound like a crash necessarily.

Have you tried replacing all the lcd.print() with Serial.print()? That should let you know if it's a size issue, and if the "random" characters are the same out the serial port.
Do not IM me. I will not respond. Ask questions in the forum.

Kiis

We are printing on a simple 20x4 LCD display, we are not printing in the serial port. So yeah it is the LCD display that prints, some times different prints on the same time mingled into each other (when it fails), or it prints nothing but squares (when it fails).

Kiis

The same thing happens if we try using the Serial.print("").

More specific nothing happens in the serial port.

arduinodlb

Yes, but if you replace all calls to lcd.print() with Serial.print() and you still have the problem, then it's a probably a general size issue. Plus, you get to see what order the prints are coming out in, and where it might be going wrong.

What size is the sketch download saying the total filesize is?
Do not IM me. I will not respond. Ask questions in the forum.

Kiis

When i tried changing all the lcd to serial prints nothing happened if there  were "too many" prints but if i commented 2 prints out again it worked just fine.

THe sketch size is around 16.000 bytes right now. The maximum size for the arduino should be around 32.000 bytes, so the general size shouldn´t really not be a problem 

arduinodlb

#10
Oct 07, 2013, 10:23 pm Last Edit: Oct 07, 2013, 10:27 pm by arduinodlb Reason: 1
OK, I think this is your problem:

http://arduino.cc/en/Tutorial/Memory

There's only 2k of static ram on an arduino uno. Each use of "..." in a print takes up static ram. You need to either combine then into a function call, or put the strings in PROGMEM and use the variable in the print instead.
Do not IM me. I will not respond. Ask questions in the forum.

Kiis

It is the last two blocks in the code in the bottom (which is commented out because they causes the error).

arduinodlb

Yep it definitely looks like the static memory problem.

I would put all your strings in a table in PROGMEM. That'll free up static memory, but it will also make your code a lot simpler as you won't be duplicating all your LCD setup commands.
Do not IM me. I will not respond. Ask questions in the forum.


TheCoolest

The simplest solution would be to use PROGMEM as suggested above.
If you are using Arduino IDE 1.0, you can replace lcd.print("your text"); with lcd.print(F("your text"));
F() is a macro to ease the use of PROGMEM and give it a more natural feel.

Go Up