I2C LCD help needed


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2005
    Location
    Cocoa, Florida
    Posts
    43

    Default I2C LCD help needed

    During the pandemic I had to lay out boards using the chips to hand, in this case 16F1503.
    Not enough pins for a parallel LCDout, so I used I2C LCDs intended for Arduino. How difficult could it be?
    I ended up using TTL232 displays, but would like to get the I2C working.

    Tried all the snippets on here. Can't find DT's but there is a post with his (possibly modified) library.
    Links to PBP3 forum no longer work. I understand I2C and the H27 is really H4E/4F thing.
    These are 8x2 using the Ti version of the Phillips T expander.
    Anyone with working, commented code?
    Thanks.

  2. #2

    Default Re: I2C LCD help needed

    Code is modified from Steve Earl have left his code but remmed out stuff I did not use.

    Biggest problem is getting the address correct.
    Picture is adapter used. (Ebay) LCDs with adapter attached can be ones that the address is fixed.

    As it came it was 0x27 Dec 39 but I had to double it for pbp to 0x4e dec 78.
    Tried to put the code in code tabs but not all would appear, so I zipped it as picforum.zip

    Code is for 12f683 but will/should work with any other pic, just change the ports and pic config

    Name:  BCBA100201_LCD I2C Serial Interface Adapter Board_1.JPG
Views: 4975
Size:  479.3 KB

    picforum.zip

    ^^^^^^ ZIP File
    Last edited by aerostar; - 13th July 2022 at 19:52. Reason: typo

  3. #3

    Default Re: I2C LCD help needed

    Just becareful with lcds that have backpacks already attached, some do not have the SDA SCL pullups on board, hence may not work. I hooked up a lcd with backpack fitted and it would not work until 10Ks were added.

    Picture below is the backpack to avoid, apart from the fact you cannot change the address even if you wanted.

    Name:  no resistors backpak.jpg
Views: 4753
Size:  100.6 KB

  4. #4
    Join Date
    Mar 2005
    Location
    Cocoa, Florida
    Posts
    43

    Default Re: I2C LCD help needed

    Thanks, I'll try this.

    > As it came it was 0x27 Dec 39 but I had to double it for pbp to 0x4e dec 78.
    $27 is the code not counting the R/W bit. Some people shift this one bit and add the R/W bit making $4E and $4F.
    This is clear in the Ti or NXP expander datasheets.

    There are pullups on my boards. The signals look clean.

    My hardware looks more like this:

    Name:  s-l500 (3).jpg
Views: 4391
Size:  60.9 KB

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,515

    Default Re: I2C LCD help needed

    As it came it was 0x27 Dec 39 but I had to double it for pbp to 0x4e dec 78.
    arduino uses a 7bit i2c address , so everything arduino-ish complies with that convention , pbp uses an 8bit i2c address scheme
    no big deal just 1 shift left gets there from the 7 bit address.


    add the R/W bit making $4E and $4F.
    and that is a waste of time and effort, pbp i2c commands set or clear the r/w bit automatically
    regardless.

    google "pbp ic2 lcd"

    you will find dt's version and an alternative for board with wiring variation
    there may other variations also
    you may need to trace the connections to verify code matches
    Last edited by richard; - 17th July 2022 at 06:00.
    Warning I'm not a teacher

  6. #6

    Default Re: I2C LCD help needed

    I've also wanted to use the modern widely available dime-o-dozen LCD's with I2C adapter boards. These things are like $6 all day long on Amazon etc.
    I've been searching this forum (and others) for a good 5 years or so. I am stunned that there hasn't been some solid examples posted.

    My PIC of choice over the last 10 years has been 16F690
    Evidently not that popular and it seems to be going on the verge of being obsolete. But they were nice bang-for-the-buck cheap 20 pin processors. About $2 ea
    But I do run out of I/) pins because I often use a 4 bit LCD for debugging or for the project itself.

    I wish there was some good sample code to get me started.
    I tried a few years ago but was at a dead end.

    So I will be watching this post and would like to give it a BUMP for more consideration. :-D

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,515

    Default Re: I2C LCD help needed

    I am stunned that there hasn't been some solid examples posted.
    posted 8 years ago
    https://support.melabs.com/forum/pic...f8574-20x4-lcd

    two versions covering popular variants of i2c backpack [LCD_PCF8574.pbp and LCD_PCF8574a.pbp]

    Name:  s-l1600.jpg
Views: 4520
Size:  146.4 KB

    bought one

    verified address a0 a1 a2 not grounded therefore $4e
    verified lcd data pins on PCF8574 high nibble therefore LCD_PCF8574a.pbp
    adjusted Test_LCD_PCF8574.pbp to siut

    ;----[Setup LCD using PCF8574 Port Expander]------------------------------------
    LCD_Addr CON $4e ; A0, A1, A2 tied to ground
    INCLUDE "LCD_PCF8574a.pbp" ; Include LCD module for PCF8574
    Backlight = 1 ; Turn on LCD Backlight

    worked first go



    what more could you want


    Name:  lcd.jpg
Views: 4435
Size:  83.0 KB
    Warning I'm not a teacher

Similar Threads

  1. I2C LCD
    By midali in forum General
    Replies: 46
    Last Post: - 8th January 2021, 23:52
  2. help to test a I2C LCD
    By lutherblisset in forum Code Examples
    Replies: 0
    Last Post: - 25th August 2017, 20:37
  3. Pcf8574 i2c lcd
    By cesar35 in forum General
    Replies: 2
    Last Post: - 25th August 2017, 16:22
  4. I2C CONFUSION, Help needed please
    By FromTheCockpit in forum mel PIC BASIC Pro
    Replies: 42
    Last Post: - 29th July 2013, 01:54
  5. Sample code for I2C text LCD needed
    By Alexey in forum Code Examples
    Replies: 4
    Last Post: - 15th September 2011, 02:29

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts