16x2 Character LCD Trouble

Moderators: adafruit_support_bill, adafruit

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/
Locked
elkvis
 
Posts: 15
Joined: Fri Nov 09, 2012 3:51 pm

16x2 Character LCD Trouble

Post by elkvis »

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

#!/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?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: 16x2 Character LCD Trouble

Post by adafruit_support_bill »

Can you post a photo showing your wiring?

elkvis
 
Posts: 15
Joined: Fri Nov 09, 2012 3:51 pm

Re: 16x2 Character LCD Trouble

Post by elkvis »

this link will take you to the image. the web site wouldn't let me upload it inline :?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: 16x2 Character LCD Trouble

Post by adafruit_support_bill »

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?

elkvis
 
Posts: 15
Joined: Fri Nov 09, 2012 3:51 pm

Re: 16x2 Character LCD Trouble

Post by elkvis »

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.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: 16x2 Character LCD Trouble

Post by adafruit_support_bill »

Software could explain it partially - although nobody else has reported this symptom. The random variations ("WFW7" "GFW7" "7FW7") do suggest something intermittent.

elkvis
 
Posts: 15
Joined: Fri Nov 09, 2012 3:51 pm

Re: 16x2 Character LCD Trouble

Post by elkvis »

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

    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 3:51 pm

Re: 16x2 Character LCD Trouble

Post by elkvis »

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?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: 16x2 Character LCD Trouble

Post by adafruit_support_bill »

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.

Locked
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/

Return to “Adafruit Raspberry Pi® accessories”