LCD does not work unless Arduino is reset.

Thanks, I should have checked my code properly!

Just complied, and downloaded to my arduino but I'm sad to say the problem is still the same :frowning:

OK, here is one more suggestion. Change the start of setup() to this:

pinMode(8, OUTPUT);
digitalWrite(8, LOW);
delay(5000);
pLcd = new LiquidCrystal(7, 8, 9, 10, 11, 12);   // insert correct pin numbers here
delay(100);
pLcd->begin(16, 2);
....

i.e. set the enable pin to be an output and drive it low early on.

PS - an alternative that might work even better would be to add a pulldown resistor between the EN input to the LCD and ground. What I'm trying to do is to make sure the LCD doesn't think it's receiving any commands while it powers up.

does not work mate.

I'm just going to try the hardware solution now (pull down)

Thanks for the help

  1. Can you confirm that the LCD doesn't work after power up, but always works if you then press the reset button?

  2. Confirm you have the LCD RW pin connected to Vcc?

  3. If the answer to both the above is yes and the pulldown on EN doesn't work, it might be worth trying:

  • a pulldown on the RS pin as well
  • sending 2 begin() calls in setup() instead of just one, with a large delay between them

1- Indeed, that is the behaviour that I'm currently dealing with.

2- Pin 5 (r/w) is tied to gnd, as per this tutorial that I followed?.. Arduino Tutorial - connecting a parallel LCD

I tried a 100k to gnd on the E pin but still the same, also just tried two begin calls with a 1 sec delay in between, also no good :frowning:

dtokez:
1- Indeed, that is the behaviour that I'm currently dealing with.

Very strange. The Arduino reset line does not go to the LCD, therefore what's resetting the LCD after you press reset must be the begin() call in the LCD constructor and/or the begin() call in setup(). So the question is, what else are you doing in your sketch that is making those calls work?

I'm running out of ideas, but maybe it is some other command you sent the LCD before you pressed reset, like printing characters or setting the cursor location. So all I can suggest now is that in between making those 2 begin calls in setup, you try try doing those things.

dtokez:
2- Pin 5 (r/w) is tied to gnd, as per this tutorial that I followed?.. Arduino Tutorial - connecting a parallel LCD

Yes, RW to Gnd is correct, not Vcc.

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

#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);

}

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.

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

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 :expressionless:

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.

  1. 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

It sounds like he should try the LiquidCrystal440 library then. How can he get it?

It sounds like he should try the LiquidCrystal440 library then. How can he get it?

He could try the link in reply #7.

Don

Hi all, I have tried the liquidcrystal440 lib to no avail sadly :frowning:

JRaines is currently looking at two of the screens for me too see if he can work out anything I'm missing

I did look at the 2 LCDs Dan sent. They actually work well with the recent version
of LiquidCrystal. I think it is slightly slower than the usual HD44780 type display.
The benchmark that I use to determine how fast the display will process text using
the busy flag to handshake with the Arduino shows it running about 9% slower than
one i got from Adafruit (and THAT display was a little too slow for the LiquidCrystal
routine that is packaged with Arduino 17- 1.0). It does not, however, run slower than
the display I bought at Axman; that one is about 30% slower yet)

This is a good place to review the timing changes I made in the recent LiquidCrystal440
versions. There are several delays involved in initialization:

delay to allow power to rise to 5 volts and chip to initialize itself: 135000 usec was 50000usec in 17-1.0
delay after pulling RS high 1st time: 5000usec was 4500 usec in 17-1.0
delay for next 3 writes of init: 150usec no change (note that 17-1.0 also has an 8bit mode with an extra 4500usec delay)

and there are two delay timings in the code not associated with initialization:
delay after home command: 2900 usec was 2000 usec
delay for each character: 320 usec was 100 usec

Remarkably when one uses the LiquidCrystal440 interfaces that check the busy flag
even on my slowest (axman) display the throughput is about 3 timss as fast as it is
with these timed delays. I suspect that there must be some specific situations
that take much longer in the HD44780 than others so that only occasionally is the
full 320usec needed on the axman display, but that display won't run reliably with
a 300usec delay between characters when not testing the busy flag.

Thanks for looking into it! Did you see any start up issues at all similar to the ones that I am regularly seeing?

I did not see any problems, here.

so if if you power up the arduino and the screens at the same time the screen always initialized fine? Really wish I could work out what I'm doing wrong :frowning:

I just did that a bunch of times in a row. The one way I saw a problem was if it was powered up, I removed power briefly from the Arduino and then quickly plugged it back in--power off for just a second. Don (floresta) probably can say more precisely what is likely going on in that specific situation. If the power is off for 3 seconds or more it always seems to work fine.