Go Down

Topic: Problem with LCD code (Read 2476 times) previous topic - next topic

pluggy



What is imitation the sincerest form of ?  ;)
http://pluggy.is-a-geek.com/index.html

mem

Strange, the LCD display is functioning correctly for me using the code I posted. I have been running an enhanced version (uses the Ethernet shield to sync the time from an NTP time server) and its been working correctly for over an hour.

Are you sure you have replaced LiquidCrystal.cpp with the posted version?

Slugsie

Yup, as a quick test I added some completely random characters to the new LiquidCrystal.cpp and it failed to complile, removed them and it compiles fine. Just doesn't work. Weird yes, annoying yes, damned if I know how to fix it. :S

Slugsie

@pluggy

Not quite, you're in Lancs UK, I'm in the one in England. :D

Plus if this is my imitation of you, it's probably not very flattering. :-[

mem

#19
Dec 03, 2009, 08:09 pm Last Edit: Dec 03, 2009, 08:10 pm by mem Reason: 1
did you try the sketch posted in reply #11 (using LiquidCrystal lcd(12, 11, 5, 4, 3, 2) or whatever you need for  your lcd wiring)


Slugsie

Yup, same result, it doesn't work.

mem

#21
Dec 03, 2009, 11:00 pm Last Edit: Dec 03, 2009, 11:00 pm by mem Reason: 1
If you put an lcd.print("hello world") in setup followed by a long delay, can you see the output on the LCD?

fwiw, the code I am running here is still working perfectly, so would be interested to find out what is different in your tests.

Slugsie

OK, this is just mad.

First change, added:

Code: [Select]
lcd.print("hello world");
delay(10000);


to setup(). That was displayed just fine.

Next I removed the Serial.println("");, but now the "hello world" message gets displayed but the first two characters are corrupted, but the time gets displayed OK.

Almost seems like there is a buffer that is being created but not initialised correctly.

Here is the current state of my code:

Code: [Select]
#include <LiquidCrystal.h>
#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h>

int rtc[7];

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
// Uncomment these lines if you want to set the time on startup
/*
 RTC.stop();
 RTC.set(DS1307_SEC,0);
 RTC.set(DS1307_MIN,26);
 RTC.set(DS1307_HR,15);
 RTC.set(DS1307_DOW,6);
 RTC.set(DS1307_DATE,29);
 RTC.set(DS1307_MTH,11);
 RTC.set(DS1307_YR,9);
 RTC.start();
*/
 // set up the LCD's number of rows and columns:
 lcd.begin(16, 2);
 lcd.print("hello world");
 delay(10000);
}

char* dayOfWeek[] = {"xxx", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};

void loop()
{
 RTC.get(rtc,true);

 lcd.setCursor(0,0);
 //lcd.print(millis());
 printDigits(rtc[2],':');
 printDigits(rtc[1],':');
 printDigits(rtc[0],' ');
 
 lcd.print(dayOfWeek[rtc[3]]);
 
 lcd.setCursor(0,1);
 printDigits(rtc[4],'/');
 printDigits(rtc[5],'/');
 printDigits(rtc[6],' ');

 //Serial.println("");
 delay(100);
}

void printDigits(int digits, char delimiter)
{
 if(digits < 10) {
   lcd.print('0');
 }
 lcd.print(digits,DEC);
 lcd.print(delimiter);
}


If I change "hello world" to ".", it displays a double bar symbol for 10 seconds, then the dayOfWeek is corrupted and becomes a double bar. If I change it to ".,", then I get two corrupt characters for 10 seconds then the main loop displays mostly garbage which bears a slight resemblance to the time and date. ".,/" goes back to a basically blank screen. "hello" performs the same as "hello world".

This is insane!

I think I'm going to try using a different computer, I'm wondering if there is an incompatibility with W7x64 RC1 somewhere. I'll give it a go on my XP based netbook tomorrow sometime. The fact that adding or removing code from loop() is affecting code running in setup() just strikes me as ridiculous unless there is a compiler problem/incompatibility somewhere.

PaulS

Since the code is being executed on an Arduino, and displayed on an LCD, I fail to see how compiling the code on a different computer will make any difference.

However, I will be interested in hearing whether that makes any difference.

The Serial.println should not do anything, because you don't have a Serial.begin statement. Serial.println should (but maybe doesn't) know whether or not Serial.begin was called, and do absolutely nothing if it wasn't.

Slugsie

If there was a bug or incompatibility in the compiler/IDE/USB drivers then that could quite easily affect the way the code was compiled and uploaded to the Arduino. If the code is compiled wrong, then anything could happen.

Sediek

#25
Dec 06, 2009, 10:28 am Last Edit: Dec 06, 2009, 10:44 am by sediek Reason: 1
I am new to this forum, i am building some stuff for home use.
One of the things i had troubles, was the LCD.
As i watch this topic, there is a similar problem i had too.

Quote
If I change "hello world" to ".", it displays a double bar symbol for 10 seconds, then the dayOfWeek is corrupted and becomes a double bar. If I change it to ".,", then I get two corrupt characters for 10 seconds then the main loop displays mostly garbage which bears a slight resemblance to the time and date. ".,/" goes back to a basically blank screen. "hello" performs the same as "hello world".


My LCD did not show anything, i also have the DS1307. My problem was simple the power of the LCD, if you get 00:00:00 time and date or garbage caracters, then it meant in my case that the needed power to the DS1307 is too short, because the LCD used too much.
I solved this with a second 7805 i added for the lcd and the trouble was gone. I had the same troubles, first a few seconds time and date and after some seconds garbage.
That is maybe, i think for 100% the trouble in this case.

I use this forum to get solutions.
I hope this will solve your LCD troubles.

Go Up