So I recently bought 2 16x2 lcd screens (1 as a spare), and hooked one up to the arduino. It worked fine with every sketch I loaded up on it so I started building my project. Long story short, everything worked as planned until today, when I was just finishing up the software.
For some reason, whenever I try to print the letter 'o', or a sentence with the letter 'o' in it, the lcd goes blank, the top row goes white, and anything I try to print after that will turn into garbage. Not even the hello world example works anymore. Originally, I thought the lcd controller was toast. However, it can't be an lcd problem because I get the exact same result on the backup lcd I bought. Then I thought that I had pooched the atmega328, and it was sending something else when I sent an 'o'. It can't be that either because the lcd will print the 'o' fine if I take it and the atmega328 out of my project and stick it on a breadboard. So naturally I then thought that I had a bad connection on a data pin, but there's no way I can achieve the same problem by unplugging data pins when the lcd is on a breadboard, I just get garbage no matter what I print, whether or not there's an 'o' in the sentence. So it's not an microcontroller problem (works on breadboard), it's not an lcd problem (works on backup lcd), and it's not a connection problem (unplugging data pins doesn't give the same problem). I'm now truly stumped as to what's causing this problem. Any ideas?
Sounds like a pin problem, by this i mean it could be wiring but also a typo in your sketch.
Did you try to put the LCD with original pin config on arduino running example sketch?
That always helps me to tell that i did something stupid :~
I've seen before that is one thing messes up slightly with an lcd it keeps on messing up
It obviously has something to do with your project - but you have given us no information about that aspect.
Don
Get a web domain, create a directory, upload the code, the original datasheet + photos.
These character LCDs should be compatible but sometimes they aren't, libraries are not always designed to work 100% with a specific display. From the information you give in the post, people can't really track down the reason. Unless they are using exactly the same type of display, and are having exactly the same kind of problem.
Alright it seems like I might be getting somewhere. After some more expirementing, it seems that I cant print the following characters: /, ?, O, _, o, and backspace. After looking at the character chart for an HD44780, http://inst.eecs.berkeley.edu/~ee40/calbot/webpage/lcd-ch1a.gif
every single one of those characters is in the bottom row, with the last four bits being 1111. Not sure how this would relate to a connection problem though
@kenny the lcd works with my pin configuration on a breadboard, but not in my project.
@floresta I suppose so, but the thing is that the lcd worked for a week or two until yesterday.
@takao21106 as I've already mentioned, the lcd worked before, even in my project. The code isn't a problem either, as all example code fails to run if there is a character with 1111 as the last four bits
It would seem like a connection problem is the only thing left, but I can't figure out what would have to be disconnected for a character with 1111 as the last 4 bits not to print. I'm running in 4 bit mode btw, and I can print any other character, which would require all four data lines to have connection
EDIT: turns out I can't print any characters with the FISRT 4 bits as 1111 either. It still works fine on a breadboard though.
if you rule out connection problem then it is maybe due to a timing problem. Hard to say if you use a library and did not write the LCD code yourself. Is the library available as source?
Maybe something else is connected to one of the data pins and does not allow for fast enough level recovery. If you have some spare Atmel chips, solder it on a small piece of PCB + row headers, then try connecting pins directly instead through the Arduino PCB so you can isolate the problem.
I don't know if these ideas relate to your problem that is what I would try to do.
I thought it might be a timing problem. I'm using the defualt LiquidCrystal library, http://www.arduino.cc/en/Tutorial/LiquidCrystal . Nothing is connected to the data pins other than the lcd, and the traces are all less than 2 inches long. Unfortunately, I don't have any other (working) atmel micro's that I can test. I'll look through some HD44780 datasheets to see where I could add a delay between writes in the code. I might even go as far as cutting tracks/desoldering other components on my projects PCB to track down the problem.
What's driving me insane though is that it all works fine on a breadboard, and that it worked for two weeks until yesterday on my PCB.
and backspace
Which character is this?
Alright it seems like I might be getting somewhere. After some more expirementing, it seems that I cant print the following characters: /, ?, O, _, o, and backspace. After looking at the character chart for an HD44780, http://inst.eecs.berkeley.edu/~ee40/calbot/webpage/lcd-ch1a.gif
every single one of those characters is in the bottom row, with the last four bits being 1111.
That is a good start. Now we need to know exactly what character is displayed for each of the characters that is not displayed correctly. With this information we may be able to determine exactly what is wrong.
Not sure how this would relate to a connection problem though
One of the data lines could be grounded which would mean that you can't make it a '1'. My guess is DB7. This would give you ., >, N, ^, n, and ~ as the substitute characters.
Don
Well people always seem to have problems with these character LCDs.
I did not succeed with 4bits about 2 years ago...
I have now put my code (with some edits) to a webpage:
http://pic.hitechworld.org/data/hitachi_lcd.html
I use very generous delays, always one milisecond, via interrupt, it does not matter too much,
since LCD is not updated often, and the interrupts are still enabled.
If you write, it worked, then stopped working after some weeks, this certainly relates to wrong timing/wrong tristate. Microcontrollers have complex internal circuits, not just one transistor for port I/O, this can result in correct function for a while, but then slowly some gate charges up where it should not.
I had problems like that, and often it related to a missing MCLR resistor (PIC), a wrong tristate timing, or indeed powering LCD directly (I guess the circuit "burns in", so to say, after a month or so, sometimes I would get a few garbled character at startup, note this was a circuit from 3 years ago, deconstructed recently).
Currently I do a burn-in test for a PCB having a small 8x2 display, powered at 3 volts, charge pump IC for the LCD glass, so far, everything works fine, always starts up correctly, no fail even after days, no garbled characters, etc.
Well people always seem to have problems with these character LCDs.
Not if they use program code that follows the recommendations in the Hitachi datasheet.
I have now put my code (with some edits) to a webpage:
http://pic.hitechworld.org/data/hitachi_lcd.html
It's nice to see that you have corrected the initialization sequence.
I use very generous delays, always one milisecond, via interrupt, it does not matter too much,
since LCD is not updated often, and the interrupts are still enabled.If you write, it worked, then stopped working after some weeks, this certainly relates to wrong timing/wrong tristate. Microcontrollers have complex internal circuits, not just one transistor for port I/O, this can result in correct function for a while, but then slowly some gate charges up where it should not.
I had problems like that, and often it related to a missing MCLR resistor (PIC), a wrong tristate timing, or indeed powering LCD directly (I guess the circuit "burns in", so to say, after a month or so, sometimes I would get a few garbled character at startup, note this was a circuit from 3 years ago, deconstructed recently).
Currently I do a burn-in test for a PCB having a small 8x2 display, powered at 3 volts, charge pump IC for the LCD glass, so far, everything works fine, always starts up correctly, no fail even after days, no garbled characters, etc.
Some of this is technical doubletalk and none of it is necessary. As I said before, all you really have to do is follow the recommendations in the Hitachi datasheet.
Don
-
backspace looks like a left arrow key, right next to 'o' in the link i posted
-
That's where things get confusing. Instead of printing a different character, the whole lcd goes blank and whatever I try to write after that becomes garbled, sometimes it prints a whole line of random characters, sometimes it prints 1 or 2 random characters. I'll if I can post a video to illustrate it more clearly.
-
Just tested with a multimeter, none of the pins are shorted to ground, Vcc, or each other. However, it seems that neither Vss nor RW have continuity to ground now... yet the lcd still works (other that my main problem of course). I'll go re-solder those and see what happens.
- backspace looks like a left arrow key, ...
You've got that backwards! It is a left arrow, it just looks like a backspace (to you).
I'll if I can post a video to illustrate it more clearly.
That will certainly help. Without looking at your code and a picture of your setup we are just guessing.
However, it seems that neither Vss nor RW have continuity to ground now...
That would certainly cause a problem.
yet the lcd still works (other that my main problem of course).
It functions, it doesn't really work. There's a difference.
Don
Well what do you know, as usual the problem was caused by what I least expected. I had a bad connection from Vss and RW to ground. Re-soldered it and it works like a charm now. I'm still befuddled as to why the previously mentioned characters wouldn't print though and all others would. Generally, disconnecting RW and Vss would cause the display to be completely unresponsive, not half functioning in a predictable manner. If I follow my traces from Vss and RW it seems that there WAS actually a connection to ground, but it was through a 2k2 resistor... could that lead to a half functioning lcd? Either way, the problem is now solved. Thanks to every one for helping me solve it in under a day.
I have had the same problem and it was a high resistance in the lead from the Aruino to the breadboard for the ground connection. Swapped leads and worked fine.
Perhaps if you just popped into your TARDIS you could go and tell Bob.
He may be able to rent a DeLorean if he isn't in the UK.
Don