Shop OBEX P1 Docs P2 Docs Learn Events
i2c LCD - What am I missing? — Parallax Forums

i2c LCD - What am I missing?

I've got an LCD display with an i2c backpack. It's the one named "I2C LCD DISPLAY VERSION 3" on this page, although this isn't where I bought it: http://arduino-info.wikispaces.com/LCD-Blue-I2C

There's a pretty long thread here on these displays, I've gone over it in detail and it includes code:
http://forums.parallax.com/discussion/146904/propeller-1-and-i2c-lcd-please-help/p1

I used the i2c scanner in that thread; on the Quickstart it will find the address of the LCD (0x27) if it's connected to 28 and 29 but not other pins, even if using the pull-ups recommended in the thread. And I've got JonnyMac's code as well, both for talking to the display and for running a demo. But when I run it, no letters show on the display - but it looks like it's being talked to, because when you get to the end where the backlight blinks, that works.

There is something different about this i2c display, but I can't figure it out. Any ideas what I should look at?

Comments

  • Sounds like you haven't adjusted the contrast pot.
    NOTE: The Blue Potentiometer (Photo) adjusts Contrast. If you don't see any characters, adjust it. Start clockwise and back down to where the characters are bright and the background does not have boxes behind the characters.
  • JonnyMacJonnyMac Posts: 9,161
    edited 2016-01-07 17:30
    I think Peter is correct: check you contrast pot. The attached image is a $9 LCD with that backpack that I got from Amazon (connected to EFX-TEK HC-8+). I had to adjust the pot on this display when I first ran it.

    I have made recent updates to my object for that backpack; I've attached for your convenience.

  • And it's working!

    Thanks to both Peter and JonnyMac.

    Notes:
    - I connected to VDD and GND, and the SDA and SCL pins on the Quickstart board.
    - The Quickstart board will work without the pull-ups but the LCD performs better with 10K pull-ups.
    - I updated JonnyMac's jm_twi_lcd_demo to work with the updated pcf8574 object, that file is attached. It's set up for an LCD at the 0x27 address, 16x2.
  • I would suggest this:
      lcd.start(LCD_SCL, LCD_SDA, %111)
    
    ...because the PCF8574 device type ($20) is fixed -- you can only change the address (%000..%111). The comment you have in the code suggests you can change the device ID.
  • Thanks for the note. I'm still learning Spin, it's a big transition from PBasic. I actually have an HC-8+ but I thought it would be easier to get going with the Quickstart, and just learn to hook up various switches and modules to it.

    Just for completion, I've attached an updated version of the demo code with the change.
  • I did a big code clean-up and posted in ObEx: http://obex.parallax.com/object/833
  • This is great, thanks for the effort.
  • Jon - Just found a limitation in the code, relating to another variation of hardware.

    The constant for the I2C address is limited to three numbers:

    LCD_ADDR = %111

    However, I just got a new I2C LCD, 20 columns wide by four lines, and it's set to an address which is longer in binary. These are the results from the I2C scanner:

    2-line LCD - 4e27
    01001110 00100111

    New 4-line LCD - 4e3F
    01111110 00111111

    So the object can't address it correctly. I've gone through all the files in the code but this is over my head.

    Jeff

  • JonnyMacJonnyMac Posts: 9,161
    edited 2016-01-11 20:51
    I cannot write code for a device I don't have docs for. What chip is in the new LCD?

    Please provide a link to the problematic display. I have run that code through two different PCF8574 backpacks and both work just fine.

    And what I2C scanner are you using? I wrote my own but it only cares about 7-bit devices.

    I don't mind fixing broken code, but don't like being blamed for problems I didn't create. This is why I had stopped posting in ObEx and am now beginning to think that posting again is a bad idea.
  • I'll do what I can to help.

    The chip is an PCF8574AT. After some digging, I found that there are two versions of the chip out in the wild - PCF8574T and the PCF8574AT. The difference is the I2C addresses have a different range, so multiple devices can be on the same buss.

    I ordered a device with what I thought was the same backpack, and I thought it would be an easy swap for my other LCD, but the one with the other version of the chip showed up.

    Here's a link to the data sheet for both versions of the chip:
    http://www.nxp.com/products/interface-and-connectivity/interface-and-system-management/i2c/i2c-general-purpose-i-o/remote-8-bit-i-o-expander-for-icbus-with-interrupt:PCF8574_74A

    The first version of the chip has addresses that go from hex 20 - 27; the "A" version has addresses that go from 38 to 3F. See Table 4 and Table 5 of the datasheet.

    This backpack actually has spots to change the I2C address via solder bridges. Picture attached.

    I'm using Tim Moore's i2cScan object, linked in kuroneko's post in the thread previously discussed:
    http://forums.parallax.com/discussion/146904/propeller-1-and-i2c-lcd-please-help/p1

    As a test, I temporarily bridged A0 closed and ran the scan, and got the correct addresses (3E).

    Sorry to come off as annoying, I just try to cut the problem down to the smallest parts. Please let me know if there is anything more I can help with, including testing code before it is posted.

    1152 x 648 - 103K
  • JonnyMacJonnyMac Posts: 9,161
    edited 2016-01-11 23:09
    The chip is an PCF8574AT
    As you've identified the problem, what is stopping you from changing the device ID code inside the PCF8574 object and then saving it to a PCF8574A object? You could have done that in less time than it took me to type that last question.
  • JonnyMacJonnyMac Posts: 9,161
    edited 2016-01-11 23:35
    Jon - Just found a limitation in the code, relating to another variation of hardware.
    The constant for the I2C address is limited to three numbers:

    LCD_ADDR = %111

    This is a point of confusion/contention. In my world view, a given I2C device can have up to eight addresses %000-%111; though not all device types support all possible addresses. This means for a 7-bit device code (plus RW bit) the possible range is %0001_000_0 through %1110_111_0. Note that group (upper four bits) %0000 is not valid for a single device, and group %1111 is used for special addressing (e.g., 10-bit).

    I've attached my own scanner. I used to output all address while scanning, after seeing the program you referenced I changed it just to the devices actually found on the buss. You may find, as I do, that the formatted output is easier to deal with.
  • Ok, I got it.

    The LCD I2C address needs to be changed like this in the top object, for a backpack using the second version of the chip (with the "A"):

    From this format, in the current object, set to (0x27):
    LCD_ADDR = %111

    To this one, (0x3f)
    LCD_ADDR = %0111111
  • I posted my previous reply before returning and seeing your post about the I2C standard and your scanner. Thanks for that, it's easier to use, especially the feature where the serial terminal waits for a keypress before starting the scan.

    I've also discovered that the USB port on my desktop computer is starting to go wonky, and depending on how the USB plug is put in, doesn't give a good connection, even though the Quickstart gets power. So sometimes the LCD didn't work right even though it powered up, thus leading to a lot of incorrect results.
  • JonnyMacJonnyMac Posts: 9,161
    edited 2016-01-12 05:46
    You are confusing the 7-bit device code with the 3-bit address within the device.

    Your new LCD uses the PCF8574A which has a type code of %0111. The possible addresses for that device are %000..%111. Combining these and shifting left by one for the RW bit you can have

    %0111_000_0 to %0111_111_0 as valid base device codes (7-bit buss address) for the PCF8574A.

    The address parameter in the LCD driver is the 3-bit portion to select a specific PCF8574A, NOT THE ENTIRE 7-BIT DEVICE CODE.

    I added two new methods to my PCF8574 object -- the "a" methods to use that device. Likewise I added an "a" method to the the LCD object. The updated LCD driver works with the normal start method with my LCD, you'll have to try it with yours using the new "a" method.

    Since every detail seems to have to be spelled out in the forums, what I'm saying is that for your new display you'll start the LCD driver object like this:
      lcd.starta(SCL, SDA, LCD_ADDR)                                ' start LCD
    

    Set LCD_ADDR to the 3-bit address revealed by my scanner -- that's the three bits between the two underscore characters in the output.

  • Got time to test it - your update works, as I would expect. Thanks again.
  • JonnyMac, Thanks for posting the LCD bits. They work perfectly with a SainSmart IIC/I2C/TWI Serial 2004 20x4 LCD which has a PCF8574T chip on the backpack.
    Very cool!
  • JonM wrote: »
    JonnyMac, Thanks for posting the LCD bits. They work perfectly with a SainSmart IIC/I2C/TWI Serial 2004 20x4 LCD which has a PCF8574T chip on the backpack.
    Very cool!

    I rule! :)

Sign In or Register to comment.