The new Raspberry Pi B Model B+ is here - Pick one up in the store and check our detailed guide!
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

16x2 Character LCD Trouble

by elkvis on Thu Nov 15, 2012 12:02 am

I just received my 16x2 character LCD display and my breadboard and my Pi Cobbler, and I'm trying to follow the instructions in this tutorial, but I'm getting nothing but garbage on the screen.

using the code provided in the tutorial, I have created my own test program:
Code: Select all | TOGGLE FULL SIZE
#!/usr/bin/python

from Adafruit_CharLCD import Adafruit_CharLCD
from subprocess import *
from time import sleep, strftime
from datetime import datetime

lcd = Adafruit_CharLCD()

lcd.clear()
lcd.message("test")


when I run this program, it usually prints "WFW7" on the LCD, although sometimes it's "GFW7" or "7FW7". when I try to run the time/date/ip program, I get strange characters. I have double and triple-checked my wiring, and everything appears exactly as the tutorial says it should, but I just can't get good output to appear.

can someone please give me some idea where to start looking for the problem?
elkvis
 
Posts: 15
Joined: Fri Nov 09, 2012 2:51 pm

Re: 16x2 Character LCD Trouble

by adafruit_support_bill on Thu Nov 15, 2012 6:05 am

Can you post a photo showing your wiring?
User avatar
adafruit_support_bill
 
Posts: 28034
Joined: Sat Feb 07, 2009 9:11 am

Re: 16x2 Character LCD Trouble

by elkvis on Thu Nov 15, 2012 7:53 am

this link will take you to the image. the web site wouldn't let me upload it inline :?
elkvis
 
Posts: 15
Joined: Fri Nov 09, 2012 2:51 pm

Re: 16x2 Character LCD Trouble

by adafruit_support_bill on Fri Nov 16, 2012 6:41 am

when I run this program, it usually prints "WFW7" on the LCD, although sometimes it's "GFW7" or "7FW7"

Looking at the binary decoding of that, it appears that the high & low nybbles are swapped - with an occasional random bit thrown in. That suggests a wiring problem. Possibly something loose?
User avatar
adafruit_support_bill
 
Posts: 28034
Joined: Sat Feb 07, 2009 9:11 am

Re: 16x2 Character LCD Trouble

by elkvis on Fri Nov 16, 2012 10:07 am

as best I can tell, it is wired exactly as the tutorial says, although it's possible that something is loose. I went over all my solder connections a second time, and made sure nothing was bridged or open. the only way I can see the nybbles getting swapped is if the software is doing it, as the tutorial says the LCD is running in 4-bit mode, and I've confirmed by checking the pinout of the device and verifying that I'm only using the high nybble of the input. perhaps tonight when I get home from work I'll have a look at the code and see if reversing the order of the nybbles will resolve most of the trouble.
elkvis
 
Posts: 15
Joined: Fri Nov 09, 2012 2:51 pm

Re: 16x2 Character LCD Trouble

by adafruit_support_bill on Fri Nov 16, 2012 10:42 am

Software could explain it partially - although nobody else has reported this symptom. The random variations ("WFW7" "GFW7" "7FW7") do suggest something intermittent.
User avatar
adafruit_support_bill
 
Posts: 28034
Joined: Sat Feb 07, 2009 9:11 am

Re: 16x2 Character LCD Trouble

by elkvis on Mon Nov 19, 2012 11:27 pm

here's an update:

I slowed it way down - put in sleep(1) in a few strategic points in the pulseEnable() function of the Adafruit_CharLCD class, and it started printing the correct values. I suspect that the data was just going too fast for the LCD to pick it up. in the delayMicroseconds function, I changed it to look like this:

Code: Select all | TOGGLE FULL SIZE
    def delayMicroseconds(self, microseconds):
        seconds = microseconds / 1000000.0      # divide microseconds by 1 million for seconds
        sleep(seconds)


and then I started playing with the delay when pulseEnable called delayMicroseconds.

it appears that under all circumstances, if the divisor in delayMicroseconds is an integer (not a floating point number), it will not work correctly.
elkvis
 
Posts: 15
Joined: Fri Nov 09, 2012 2:51 pm

Re: 16x2 Character LCD Trouble

by elkvis on Mon Nov 19, 2012 11:32 pm

another update:

changing the divisor to ten million, and adjusting the delay values accordingly got back to near-instant performance. with it set to a million, it was rather slow redrawing the screen - about 2 seconds. now it's well under a second.

so the real question I'm asking now is: is there something unusual about my pi that is causing the timing to be all screwed up?
elkvis
 
Posts: 15
Joined: Fri Nov 09, 2012 2:51 pm

Re: 16x2 Character LCD Trouble

by adafruit_support_bill on Tue Nov 20, 2012 6:53 am

is there something unusual about my pi that is causing the timing to be all screwed up?

Unless you are overclocking your Pi, I would be more inclined to suspect the timing tolerances of the display.
User avatar
adafruit_support_bill
 
Posts: 28034
Joined: Sat Feb 07, 2009 9:11 am