i2c LCD display adapter and PIC microprocessor

Discussion in 'Programmer's Corner' started by portreathbeach, May 15, 2014.

  1. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    After my recently dabbling with the o2c protocol and successfully reading and writing to a DS3231 real time clock module I discovered the i2c to LCD module driver board on eBay for as little as 99p from China.

    http://www.ebay.co.uk/itm/IIC-I2C-T...al_Components_Supplies_ET&hash=item3388ecb48f

    These boards connect the parallel pins of the LCD to a small daughter board which allows you to control the display using the i2c bus, rather than using up loads of pins on a PIC microprocessor as I have had to do in the past.

    A few years back I wrote some code that controls an LCD and worked fine, but I would my next project that uses an LCD I would like to try and use the small daughter board interface so as not to use up loads of pins on my PIC.

    I haven't been able to find out much information on the net about the interface boards in regards to what data is needed to be sent to it to get it to make the display actually display something. These boards are mostly used by the Auduino guys and there are libraries written for them.

    When I programmed for LCDs before, you clock the parallel data onto the LCD and can also read data back, but I can't seem to find any information as to what registers I would need to write too over i2c if I was using one of those i2c adaptors.

    Anyone used one?
  2. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    When programming for the LCD before, to clear the display for example you stick '00000001' onto the parallel pins and clock it in.

    For display on, you stick '00000110'on the lines for Entry mode, increment address to be written after each character is sent.

    When wanting to write a character to the display I think that the RS pin has a high level applied to it and the parallel data is clocked once more.

    How would this be sent over i2c to the LCD adapter?

    Thanks again for any help :)
  3. ErnieM

    ErnieM AAC Fanatic!

    Joined:
    Apr 24, 2011
    Messages:
    5,487
    Location:
    Lon Guyland, Noo Yawk
    That device on EBay uses it's own internal protocol to convert something you send over the I2C to the parallel lines of the LCD.

    The correct place to ask for this protocol is from the guy selling it.
  4. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    Hi ErnieM. I'm aware that these modules look as though they use a PIC or something to act as the i2c slave to control the LCD, and I have messaged a couple of sellers. The sellers don't really have any info they can give me as they seem to be generic Chinese boards that a lot of people are selling.

    Maybe I'll get some of the auduino code that people use with these devices and see how they interface with them.
  5. ErnieM

    ErnieM AAC Fanatic!

    Joined:
    Apr 24, 2011
    Messages:
    5,487
    Location:
    Lon Guyland, Noo Yawk
    I was afraid no one offered any support for a cheap part. I saw a ton of these on EBay last night, no one offered any support info except for the guy who posted a corrupted zip file.

    Now this listing seems to be the same part, and I can just make out the chip number: PCF8574, which is an I/O expander from T.I. and NXP.

    That makes things simpler: just pretend it's a regular parallel port and send the same info, except use I2C and not a Latch setting.

    Since this is an 8 bit I/O device you'll probably need to kick the LCD into 4 bit mode, not enough lines to run it in 8 bit mode.

    Knowing what device is sitting there, which is simple once it sits in your hand, you can buzz out all the connections and completely nail down pin outs, data words, and everything.

    I'd get a few of these myself but I like to reuse the LCD data lines for input buttons.
    Last edited: May 16, 2014
  6. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    Ah I see. They must run the LCD in 4 bit mode, therefore the remaining 4 bits are used for the other pins, read/write etc.

    I suppose all that would then be needed to send data to the LCD would be to send the device address on the i2c bus, then the data that would usually be set on the parallel pins. So after working out which pins on the output of the converter chip were connected to which pins on the LCD, the data and read/write bits etc. would be sent as 1 byte to the device.
  7. ErnieM

    ErnieM AAC Fanatic!

    Joined:
    Apr 24, 2011
    Messages:
    5,487
    Location:
    Lon Guyland, Noo Yawk
    Yeah that's how I see it too. The "complication" comes in when you wish to toggle a line, you have to write out the port values several times. A write sequence may go as "set RS & RW" "set E hi" "set E lo" then repeat that for the lower 4 bits.

    Oisch... wish there was a micro there so you send simple data and it does all the heavy lifting for you, but a few well planned functions will also do the job.
  8. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    Yeah, I was thinking too about the toggling. In normal 8 bit mode, you make the enable line low, put the data on the parallel pins and then put enable high, wait and then put enable low.

    In 4 bit mode it says to apply the high nibble of the command or character you want to display onto pins 7-4, enable high, wait, enable low, put the low nibble on the pins and then toggle the enable again.

    I guess when using the i2c adaptor, you would have to send the high nibble of the data you want to send along with the relevant bit set to make the enable pin low, then resend it again with the relevant bit for enable set to high and then again with the relevant it to set enable low again. This same sequence would then be repeated again with the low nibble of data.

    As you said ErnieM, quite a lot to do, but after you have coded the sub routines to carry out the task, should be fine. I haven't got any specific project lined up that will need an LCD but I've done a few in the past where I would have used one but was limited by pins, this would be a good answer to the problem in the future.
  9. t06afre

    t06afre AAC Fanatic!

    Joined:
    May 11, 2009
    Messages:
    5,939
  10. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    Cheers for the link. Shouldn't be too hard to implement using the i2c adaptor.

    I was having a quick look at the LCD datasheet and it said that the data is 'clocked' in on the falling edge of the enable pin, so that means to send a byte to the LCD you could simply:

    -Send the address of the the i2c adaptor over i2c
    -Send high nibble of the data to send with the enable pin high
    -Send the high nibble again with the enable pin low
    -Send the low nibble with the enable pin high
    -Send the low nibble again with the enable pin low
  11. ErnieM

    ErnieM AAC Fanatic!

    Joined:
    Apr 24, 2011
    Messages:
    5,487
    Location:
    Lon Guyland, Noo Yawk
    More like this:

    -Send START, I2C address, Send high nibble of data + enable pin high, STOP
    -Send START, I2C address, Send high nibble of data + enable pin low, STOP
    -Send START, I2C address, Send high nibble of data + enable pin high, STOP

    -Send START, I2C address, Send low nibble of data + enable pin high, STOP
    -Send START, I2C address, Send low nibble of data + enable pin low, STOP
    -Send START, I2C address, Send low nibble of data + enable pin high, STOP
  12. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    Hi again Ernie. Could you not send the START once, then the I2C address, then multiple data followed by the STOP?
  13. ErnieM

    ErnieM AAC Fanatic!

    Joined:
    Apr 24, 2011
    Messages:
    5,487
    Location:
    Lon Guyland, Noo Yawk
    I *think* you can but I'm not getting something in those specs (both TI and NXP).
  14. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    I've ordered a couple, so I guess it's a case of trying out what works and what doesn't. They are coming from china, so could be a few weeks. I'll post back with the results and which pins on the adaptor board connect to which pins on the LCD.
  15. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    I've done a little more research and from a few different sites found the pinout for the i2c adaptor board.....

    PCF8574 -- LCD
    -----------------
    P0 -------- Data pin 4
    P1 -------- Data pin 5
    P2 -------- Data pin 6
    P3 -------- Data pin 7
    P4 -------- RS
    P5 -------- R/W
    P6 -------- En
  16. ErnieM

    ErnieM AAC Fanatic!

    Joined:
    Apr 24, 2011
    Messages:
    5,487
    Location:
    Lon Guyland, Noo Yawk
    I betcha P7 runs the back light.
  17. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    That would be good :)
  18. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    Just found a picture of one of the boards good enough to see what P7 is connected too. You were right ErnieM, P7 looks as though it is connected via a resistor to a tiny transistor which appears to feed the +LED pin on the display.

    With the price of an LCD and an i2c adaptor from China, there are endless projects that can benefit an LCD. I don't usually use that many LCDs as of the amount of pins normally required. But if you have a project thta is already using i2c, this can be added for 'free', no extra pins needed.
  19. THE_RB

    THE_RB AAC Fanatic!

    Joined:
    Feb 11, 2008
    Messages:
    5,435
  20. portreathbeach

    portreathbeach Thread Starter Member

    Joined:
    Mar 7, 2010
    Messages:
    103
    Cheers. I've had a look at the code but I've already written my assembly code for it. Just waiting for it to turn up now to experiment with.
Similar Threads
Forum Title Date
Programmer's Corner 8086 ALP String Display Jul 19, 2014
Programmer's Corner How to shift decimal point on seven segment displays. Jul 3, 2014
Programmer's Corner LCD Increment and Decrement For Display Feb 25, 2014
Programmer's Corner Led display multiplexing - MicroC Aug 16, 2013
Programmer's Corner C programming of sms based device control and lcd display May 6, 2013

Share This Page