Character LCD with Raspberry Pi or BeagleBone Black

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
a_power
 
Posts: 13
Joined: Mon Jun 22, 2015 7:01 am

Character LCD with Raspberry Pi or BeagleBone Black

Post by a_power »

Dear all,
I am reading this interesting guide about LCD screen:
https://learn.adafruit.com/character-lc ... k/overview

Could you please correct me if I am wrong with this:
all LCD screens (16x2, 20x4, RGB positive-negative, standard etc..etc) need 5V on Vdd and LED+ pins, while the signals can be at 3.3 V

Is that right?
Thanks for your help.

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

Re: Character LCD with Raspberry Pi or BeagleBone Black

Post by adafruit_support_bill »

all LCD screens (16x2, 20x4, RGB positive-negative, standard etc..etc) need 5V on Vdd and LED+ pins, while the signals can be at 3.3 V
That is true of all the character displays we have in the store. There are other similar character displays available from other sources that are designed to operate at different voltages.

User avatar
solarblitz
 
Posts: 9
Joined: Sun Jun 14, 2015 5:48 pm

Re: Character LCD with Raspberry Pi or BeagleBone Black

Post by solarblitz »

I cannot get the 16x2 Blue LCD with the i2C backback to work with Beaglebone black.. I've had no luck with the python library and have even re-written the C++ driver. I have uploaded my cpp project here.

At one point I thought I had solder joint problems or a defective LCD or i2c backpack... so I ordered another. I can recreate the following results on either hardware combo. Th e project will boot the LCD appropriately. I can send Commands (clear, home, cursor, blink, etc) with out problem and the display performs as expected (probably not a hardware or wire length issue).

However, when I send a character, I get strange results. Usually the cursor will increment as expected or it will jump to the DDRAM memory address of the ASCII character sent (ie. sending a capital 'A' moves the cursor to second line, second column). It is almost as if the Least significant bit from the MCP23008 (which defines the 4-bit instruction as data ) is never getting set high.

the output from my C++ project is consistent with what the HD44780 data sheet calls for: example for capital 'D' (0x44 bin 0100 0100
High Nibble: sent 10100001 strobed: 10100101
Low Nibble sent 10100001 strobed: 10100101

I have a few thoughts:
the I2C library I want to use for BBB is from Derek Molloy (best BBB author out there IMHO! ). The AdaFruit cpp code uses an I2C command that does not specify the register.. but merely sends to the device. I am unable to communicate to the 23008 unless I specify register 0x09 or 0x0A.

The initial setup for the 23008 (great board that I intend to purchase more for input projects) is using default... is there some manipulation of the resistors or IO direction that may help ? The HD44780 data sheet does not provide much detail about the Enable pin in the datasheet (specifically figure 24 and table 12). could there be an i2c timing issue with the BBB (running debian ) that is different from RasPi ?

Assistance is greatly appreciated !
Attachments
BeagleBoneLCD.zip
to use: 1) ./build the c++ project (on BBB debian) which will create LCDtest 2) LCDtest boot (initializes the LCD) 3) LCD HELLOWORLD (should print HELLOWORLD on line 1 of the LCD)
(12.21 KiB) Downloaded 67 times

User avatar
zephyr
 
Posts: 13
Joined: Sun Sep 02, 2012 3:58 pm

Re: Character LCD with Raspberry Pi or BeagleBone Black

Post by zephyr »

Based on the response from adafruit support... I can use 5V to power the adafruit 20x4 LCD and backpack from the 5V supply on the BeagleBoneBlack, but I don't need a level shifter for the i2c pins? I can connect the i2c pins directly to the beagle bone? Is this correct? I was under the impression I needed a level shifter.

- Thx

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

Re: Character LCD with Raspberry Pi or BeagleBone Black

Post by adafruit_support_bill »

The OP was regarding a bare display, not the i2c/SPI backpack. If you power the backpack with 5v, you will need a level shifter to use it with a 3.3v processor.

User avatar
zephyr
 
Posts: 13
Joined: Sun Sep 02, 2012 3:58 pm

Re: Character LCD with Raspberry Pi or BeagleBone Black

Post by zephyr »

Ah... okay... so 5V to the backpack and then a level shifter for the i2c pins. I am trying to connect this to a BeagleBoneBlack. I have it connected via the adafruit i2c friendly level shifter..and I am using the python code on the adafruit site. When I run the LCD demo, I can see some garbage characters on the LCD, but the backlight does not come on. I have the backpack powered via the BBB 5v SYS pin and the level shifter uses 3.3 on the LV side and 5V on the HV side...but no luck. I can see the device in the i2c map. Please let me know if you have any advice on this. - thx.

User avatar
solarblitz
 
Posts: 9
Joined: Sun Jun 14, 2015 5:48 pm

Re: Character LCD with Raspberry Pi or BeagleBone Black

Post by solarblitz »

@zephyr, if you get it working, please let me know. I'm going to order a couple i2c safe level converters if this solves your problem. Did you have to modify your driver to get it working with the slower performance caused by the 10k resistors. In the previous post, I provided a cpp foundation that I was testing with. I'd be interested to see if that C++ project that I posted works or if it also provides the garbage characters you mention.

User avatar
zephyr
 
Posts: 13
Joined: Sun Sep 02, 2012 3:58 pm

Re: Character LCD with Raspberry Pi or BeagleBone Black

Post by zephyr »

Hey @solarblitz... I did have it working last year with C++ code that I derived from Derek Molloy. In that case, I was using a BeagleBone (not the black) on Ubuntu and the Adafruit level-shifters worked great. Unfortunately, I don't have the old BB anymore. I tried this same thing again with the BB black and was using the python code on debian. That's when I saw the garbage characters...but no backlight. I am going to try the C++ code the weekend and maybe another LCD and backpack. I have a RTC module (also from adafruit) on the same i2c bus, which may be causing some problems. I am also suspecting the connection wire jumpers that I am using...they may be to fine. I will try and rule out these variables and let you know how it goes.

User avatar
zephyr
 
Posts: 13
Joined: Sun Sep 02, 2012 3:58 pm

Re: Character LCD with Raspberry Pi or BeagleBone Black

Post by zephyr »

Hi @solarblitz, so I got it working with the Adafruit level shifters (https://www.adafruit.com/products/757). They work great. The LCD that I have is the Adafruit 20x4 Blue display (https://www.adafruit.com/products/198) with i2c backpack (https://www.adafruit.com/products/292). The i2c backpack has an MCP23008 on it and the address pins (A4-A7, RS, E) are wired to the 16 pins of the LCD. My problem with the backlight and garbage characters was due to the pin mappings in the python example code. I downloaded the Adafruit BBIO library and character LCD example code. What I realized is that I needed to set the MCP23008 pins to match the LCD pins. There does not appear to be a resource that tells which pins on the MCP23008 are wired to which holes on the backpack, so I had to use this x-ray view (https://learn.adafruit.com/assets/2871) to figure that out. For my BBB, I wired the LV side of the level shifter to pins 19 (SDA) and 20 (SCL). I used A1 and A2. On the HV side, I used B1 and B2 and connected those to the associated backpack pins. You can then connect the LV VCC to 3.3V and the HV VCC to 5V...both are coming from the BBB pins (P2-3, P2-5). GND on both the LV and HV sides comes from the BBB (P9-1) as well.

From your post, it appears you are using C/C++ so this part may not help you out. I had to modify the example Python code to use the following LCD to MCP pin mappings: lcd_rs=1, lcd_en=2, lcd_d4=3, lcd_d5=4, lcd_d6=5, lcd_d7=6, backlight=7. You then set the cols and lines to 20 and 4. For gpio, you should use MCP.MCP23008() and then I had to set the address (0x20) and bus number (1). Then, when you call the LCD.Adafruit_CharLCD() method, you pass in those pin mappings but also set the invert_polarity=False. The pin mappings fixed the garbage data issue, and the invert_polarity parameter fixed the backlight issue. So now it is working.

Hopefully there is something similar you can do with the C/C++ code you are using. If you don't have the same LCD, there should be a pin mapping silk-screen on the back of the LCD...you then just have to match the MCP to backpack pins and you should be set to go. Let me know if you need any additional information. Good luck.

P.S. since there is no BBB tutorial for the i2c extender and 20x4 LCD, I wonder if it would be worth putting my notes together with yours and maybe we can create a C/C++ and Python tutorial for the Adafruit site?

User avatar
solarblitz
 
Posts: 9
Joined: Sun Jun 14, 2015 5:48 pm

Re: Character LCD with Raspberry Pi or BeagleBone Black

Post by solarblitz »

Thanks @zephyr! The additional information about the pinouts got me unstuck ! I had the data and the read/write pins reversed... Eventually I started getting characters today. I'll update my C++ code and post it. I like your idea of posting a tutorial to Adafruit.

User avatar
solarblitz
 
Posts: 9
Joined: Sun Jun 14, 2015 5:48 pm

Re: Character LCD with Raspberry Pi or BeagleBone Black

Post by solarblitz »

I finally have it working reliably ! The attached cpp (including a build script to compile it on BBB - I am using a debian release) will drive the LCD display with the i2c backpack. I plan to continue to use cpp code for other projects... but I can also manipulate the LCD directly from a shell command line. The level shifter was required and is working at the default bus clock speed of the BBB.

I'm not a great C++ coder.. .there are a few things I wanted to incorporate .. but this gets me past this hurdle. Hope it does for others as well.
The major hangups I encountered were: the pinouts for the other code samples confused me; Second, the BBB wants to know what device address (in the case of the MCP23008 it is using 0x0A (or 0x09)). The timing, order, and strobe sequence of the 'boot' function is critical... and MUST be the FIRST command sent after the LCD/backpack module is powered up.

Thanks, Adafruit for the great source of gadgets and information !
Attachments
BeagleBoneLCD.zip
(9.64 KiB) Downloaded 57 times

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”