Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5914
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #15 on: September 04, 2011, 01:55:25 am » |
strange. I start to suspect your code or other hardware but I know you checked thoroughly. I buy from chinaecomponents on ebay. Never a problem.
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 130
Posts: 4641
|
 |
« Reply #16 on: September 04, 2011, 09:43:21 am » |
I still thihk the problem is that the device is not ready when the begin() command send commands to the device. I suggest trying the following, one at a time: 1. Make sure you have a call to lcd.begin(...) in setup - assuming your LiquidCrystal variable is called "lcd". 2. Add a delay in setup() before the begin(...) call as per retrolefty's suggestion. 3. If that doesn't fix it, the problem may be that the lcd.begin() call in the LiquidCrystal constructor is happening too soon. Preferably, recompile the LiquidCrystal library with the begin() call at LiquidCrystal.cpp line 82 commented out. Alternatively, the following may work (it compiles but is otherwise untested): - Replace the declaration "LiquidCrystal lcd(...);" by the following:
void* operator new(unsigned int sz) { return malloc(sz); }
LiquidCrystal *pLcd; - Put the following in setup, before the lcd.begin(...) call:
delay(1000); // delay as per retrolefty's suggestion pLcd = new LiquidCrystal(...); // insert correct pin numbers here
- Replace every instance of "lcd." by "pLcd->"
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« Reply #17 on: September 05, 2011, 06:37:14 am » |
hey there. I do have a call to begin in the set-up. I have tried al sorts of delay times before the begin but does not seem to help I not sure how I recompile the library? I just tried the last suggestion, replacing some of the bits but could not get that too complie 
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 130
Posts: 4641
|
 |
« Reply #18 on: September 05, 2011, 06:40:02 am » |
I just tried the last suggestion, replacing some of the bits but could not get that too complie  What compile errors are you getting, and on what lines? If you post your sketch, I can try making the changes and see what problems there are compiling it.
|
|
|
|
« Last Edit: September 05, 2011, 06:41:41 am by dc42 »
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« Reply #19 on: September 05, 2011, 06:49:24 am » |
Hi there, here is what I have currently #include <LiquidCrystal.h> void* operator new(unsigned int sz) { return malloc(sz); }
LiquidCrystal *pLcd;
//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(1000); // delay as per retrolefty's suggestion pLcd = new LiquidCrystal(7, 8, 9, 10, 11, 12); // insert correct pin numbers here delay(100); pLcd.begin(16, 2); delay(100);
pLcd.setCursor(0, 0); pLcd.print("REAPsystems V1.1"); lcd.setCursor(0, 1); pLcd.print("iSensor tester"); delay(4000); pLcd.clear();
}
void loop(){ delay(1400);
// read the value on analog input pLcd.setCursor(0,0); pLcd.print ("Vin:"); vin = analogRead(analoginput)*5.00/1024*2; pLcd.print(vin, 3); pLcd.print ("v"); pLcd.setCursor(0,1); pLcd.print ("R:"); vin1 = analogRead(analoginput1)*5.00/1024; pLcd.print(vin1, 2); pLcd.print ("v");
pLcd.setCursor(9,1); pLcd.print ("O:"); vin2 = analogRead(analoginput2)*5.00/1024; pLcd.print(vin2, 2); pLcd.print ("v");
delay(1400);
}
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 130
Posts: 4641
|
 |
« Reply #20 on: September 05, 2011, 07:41:57 am » |
You need to replace "pLcd." by "pLcd->" everywhere, as in my original instructions.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« Reply #21 on: September 05, 2011, 12:35:03 pm » |
thanks I overlooked the symbols  I'm getting another compile error now on this line pLcd->.begin(16, 2); do i still need that in there?
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 130
Posts: 4641
|
 |
« Reply #22 on: September 05, 2011, 12:45:48 pm » |
yes but remove the . in the middle.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« Reply #23 on: September 06, 2011, 07:50:49 am » |
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 
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 130
Posts: 4641
|
 |
« Reply #24 on: September 06, 2011, 08:23:52 am » |
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.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 130
Posts: 4641
|
 |
« Reply #25 on: September 06, 2011, 08:47:26 am » |
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.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« Reply #26 on: September 06, 2011, 11:03:47 am » |
does not work mate.
I'm just going to try the hardware solution now (pull down)
Thanks for the help
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 130
Posts: 4641
|
 |
« Reply #27 on: September 06, 2011, 11:33:39 am » |
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
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« Reply #28 on: September 06, 2011, 11:51:18 am » |
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?.. http://www.ladyada.net/learn/lcd/charlcd.htmlI 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 
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 130
Posts: 4641
|
 |
« Reply #29 on: September 06, 2011, 12:14:45 pm » |
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. Yes, RW to Gnd is correct, not Vcc.
|
|
|
|
« Last Edit: September 06, 2011, 12:16:16 pm by dc42 »
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
|