Question say it all.
How do I fix this? I need an updated .pyc with corrects made for the new pin outs. Where can I find an updated copy for rev2 board?
Question say it all.
How do I fix this? I need an updated .pyc with corrects made for the new pin outs. Where can I find an updated copy for rev2 board?
Hi - is this the Python code from Adafruit that you are using?
https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/master/Adafruit_CharLCD
I see it referenced on the character LCD tutorial:
http://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/overview
I've not tried it out myself yet so don't have any particular insight. However, I think a good way to get help would be to raise a issue in that GitHub repo:
https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/issues
Sure, I can raise an issue, but I think I need to get some more info first. Do you mean that you believe Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCD/Adafruit_CharLCD.py is out of date and does not work?
My understanding of and experience with the 512MB Rev 2.0 Pi is that the P1 GPIO header (which the Pi Cobbler uses) is unchanged. I've not noticed any differences switching between old and new Pi's in my own projects. I'm going to try to wire up a 16x2 LCD on a breadboard with the Pi Cobbler like in the tutorial. I've got Rev 1.0, Rev 1.0 + ECN0001, and 512MB Rev 2.0 Pi's so I can check if I experience any difference.
Sounds good. I an am pritty sure that I have wired it correctly because I got "???????????????" Accross the display. I think it has something to do with the change involving GPIO21 and GPIO27. That would be the only change that could affect it.
Problem found. It is exactly what I thought...
I think it has something to do with the change involving GPIO21 and GPIO27. That would be the only change that could affect it.
Before I tested with 512mb RPi, I did a test with my old rev1 board. = PASS
Anyway, I found this out by connecting the 4th pin from the right to the pin 11 on the camera connector and...WOOH! It worked.
Now all we need to do is work out how to fix this issue by rewriting the .pyc file that adafruit has kindly provided for us.
Attached is the .pyc file along with some other files that they provide.
**ALERT**
Fixed the problem...
Change Line:
def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 17, 21, 22], GPIO = None):
to:
def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 17, 27, 22], GPIO = None):
Hope this helps someone and I hope that adafruit add in a checker for rev in updates of this software.
EDIT:
MUST ALSO DELETE .pyc FILE. The program will recompile itself.
Thanks for the advise and sharing the solution. I see I overlooked the pin change which you point out (under "JTAG Debug Support" on this page: http://www.raspberrypi.org/archives/1929).
I didn't get a chance to wire up a LCD last night, but I'm looking forward to doing that tonight and taking advantage of your fix.
Thanks for the advise and sharing the solution. I see I overlooked the pin change which you point out (under "JTAG Debug Support" on this page: http://www.raspberrypi.org/archives/1929).
I didn't get a chance to wire up a LCD last night, but I'm looking forward to doing that tonight and taking advantage of your fix.
I was looking at the RPi.GPIO module and it actually does auto detect the Raspberry Pi revision. By switching to BOARD pin addressing instead of BCM, the code works ok on both the Rev 1 and Rev 2 Pi's.
diff --git a/Adafruit_CharLCD/Adafruit_CharLCD.py b/Adafruit_CharLCD/Adafruit_CharLCD.py
index bbb8955..aef9556 100755
--- a/Adafruit_CharLCD/Adafruit_CharLCD.py
+++ b/Adafruit_CharLCD/Adafruit_CharLCD.py
@@ -54,17 +54,21 @@ class Adafruit_CharLCD:
- def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 17, 21, 22], GPIO = None):
+ #def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 17, 27, 22], GPIO = None):
+ def __init__(self, pin_rs=22, pin_e=18, pins_db=[16, 11, 13, 15], GPIO = None):
+
# Emulate the old behavior of using RPi.GPIO if we haven't been given
# an explicit GPIO interface to use
if not GPIO:
import RPi.GPIO as GPIO
self.GPIO = GPIO
+ self.GPIO.setwarnings(False)
self.pin_rs = pin_rs
self.pin_e = pin_e
self.pins_db = pins_db
- self.GPIO.setmode(GPIO.BCM)
+ self.GPIO.setmode(GPIO.BOARD)
+ #self.GPIO.setmode(GPIO.BCM)
self.GPIO.setup(self.pin_e, GPIO.OUT)
self.GPIO.setup(self.pin_rs, GPIO.OUT)
fyi: I've forked the Adafruit repo, committed the pin numbering scheme fix and issued a pull request to resolve:
https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/issues/9
my commit: