Go Down

Topic: LCD does not work unless Arduino is reset. (Read 6 times) previous topic - next topic

dtokez

#30
Sep 06, 2011, 08:00 pm Last Edit: Mar 04, 2013, 02:37 pm by dtokez Reason: 1
I see what you mean about calling the reset, its no different to when it first powers up because the arduino starts running exactly the same code.

I guess it must be something going wrong with the lcd on initial power up? Maybe its not ready and initializes before the arduino?

I'm really stumped lol.

Thanks for the help, much appreciated

by the way, if it helps to understand here is the code that I'm currently running
Code: [Select]
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

int analoginput = 0;
int analoginput1 = 1;
int analoginput2 = 2;
float vin = 0.0;
float vin1 = 0.0;
float vin2 = 0.0;

void setup(){
delay(100);
lcd.begin(16, 2);
delay(1000);
lcd.begin(16, 2);

   lcd.setCursor(0, 0);

      lcd.setCursor(0, 1);
  lcd.print("iSensor tester");
 
 
delay(4000);
 
 
 
 lcd.clear();

}



void loop(){
 
 
    delay(1400);


// read the value on analog input
lcd.setCursor(0,0);
lcd.print ("Vin:");
vin = analogRead(analoginput)*5.00/1024*2;
lcd.print(vin, 3);
lcd.print ("v");

lcd.setCursor(0,1);
lcd.print ("R:");
vin1 = analogRead(analoginput1)*5.00/1024;
lcd.print(vin1, 2);
lcd.print ("v");


lcd.setCursor(9,1);
lcd.print ("O:");
vin2 = analogRead(analoginput2)*5.00/1024;
lcd.print(vin2, 2);
lcd.print ("v");


delay(1400);

}

dc42

#31
Sep 06, 2011, 08:04 pm Last Edit: Sep 06, 2011, 08:06 pm by dc42 Reason: 1
Following on from my previous reply, does it work if you repeat all the code in setup() again? i.e. do the whole block twice over.

btw I see that the AdaFruit tutorial says to connect the backlight directly between Vcc and gnd, but I think on some lcds such as the one I have, you need a series resistor for the backlight.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

dtokez

Just tried with the set up doubled, still no good :(

Thanks for the heads up, I did use a resistor on the backlight.

I really think its something simple that I'm doing wrong, because I have tried 3 different types screens, and two arduino's with all the same results   :|

dc42

#33
Sep 07, 2011, 02:23 pm Last Edit: Sep 07, 2011, 02:26 pm by dc42 Reason: 1
I can only thing of 2 3 things left to do:

1. Send the initialisation sequence yourself in setup(). See page 12 of the datasheet at http://www.egochina.net.cn/eBay/Download/SPLC780D.pdf for the sequence for 4-bit interface. For each item in the sequence, you need to wait for any delay time that is indicated, set the pins to the specified values, then pulse the EN pin high and then low again. If no delay time is indicated, you still need a delay between commands, but I can't find anything in the data sheet that says how long.

2. Try with the RW pin also connected to the Arduino, using the LiquidCrystal constructor that takes 7 pin numbers. That way, the LCD library will wait for the busy flag to clear before sending new instructions to the LCD.

3. Take a copy of the LiquidCrystal .cpp file and include it in your sketch, but double all the delays.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

floresta

#34
Sep 07, 2011, 02:57 pm Last Edit: Sep 07, 2011, 03:00 pm by floresta Reason: 1
Quote
2. Try with the RW pin also connected to the Arduino, using the LiquidCrystal constructor that takes 7 pin numbers. That way, the LCD library will wait for the busy flag to clear before sending new instructions to the LCD.

If you are talking about the LiquidCrystal library that is suppiled with the Arduino IDE that won't help at all.  All the LiquidCrystal library does with the R/W pin is drive it low and keep it there.  What you would be accomplishing is just unnecessarily tying up a extra Arduino I/O pin.

On the other hand the LiquidCrystal440 library will indeed use the busy flag as described but that won't help you either since you can't use the busy flag during the early part of the initialization where the LCD controller reset is being accomplished.  The improved time delays in the library will likely take care of your problem.


Don

Go Up