Remove Text Formatting
Loading...

+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 41 to 48 of 48
  1. #41
    Join Date
    Mar 2008
    Posts
    42

    Default Re: Interfacing with Arduino I2C LCD

    Quote Originally Posted by richard View Post
    interpreted as [( 7bit_addr, EN, RW, RS, D4, D5, D6, D7, Backlight, POLARITY) ]

    the PCF8574 datasheet indicates the 7bit addr range is 0x20--0x27

    0x3f is not valid afaik.


    default with a0:2 open = 7bit_addr of 0x27 , pbp addr would be $4e
    I see on the data sheet for the PCF8574 you are right I used the Arduino i2c address finder to get the address. I have tried it using the 4E address and get nothing however with the 7E I do get some response from the display. I am still trying to understand the Initialization string and how to use it if you can offer guidance it would be appreciated. This is a little beyond my current ability but I will continue to try to learn and get this project going.

    Thank You!

  2. #42
    Join Date
    May 2013
    Location
    australia
    Posts
    1,191

    Default Re: Interfacing with Arduino I2C LCD

    did it work with the Arduino sketch ?
    if so what was the init command [I assume a0:2 are open]
    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) or LiquidCrystal_I2C lcd(0x27, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE);
    afaik there is at least two types there may be others.
    if the addr is not between 0x20 and 0x27 then its a going to be different animal and the include files may need modification

    would not hurt to trace out the cct and see what bits are wired to rs,e,rd/wr etc
    This is more entertaining than Free to Air TV

  3. #43
    Join Date
    Mar 2008
    Posts
    42

    Default Re: Interfacing with Arduino I2C LCD

    Quote Originally Posted by richard View Post
    did it work with the Arduino sketch ?
    if so what was the init command [I assume a0:2 are open]
    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) or LiquidCrystal_I2C lcd(0x27, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE);
    afaik there is at least two types there may be others.
    if the addr is not between 0x20 and 0x27 then its a going to be different animal and the include files may need modification

    would not hurt to trace out the cct and see what bits are wired to rs,e,rd/wr etc

    This is the init command from my working Arduino sketch "LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE)" all three jumpers are open A0:2.

    Thanks!

  4. #44
    Join Date
    May 2013
    Location
    australia
    Posts
    1,191

    Default Re: Interfacing with Arduino I2C LCD

    This is the init command from my working Arduino sketch "LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE)" all three jumpers are open A0:2.
    ok must be PCF8574A [addr range 0x38-0x3f]

    so $7e is sounding good for an address , one of those includes should work .

    another thought
    you did not specify osc speed you may need
    DEFINE I2C_SLOW 1
    Last edited by richard; - 27th February 2017 at 05:42.
    This is more entertaining than Free to Air TV

  5. #45
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,014

    Default Re: Interfacing with Arduino I2C LCD

    Make sure of the IC Type. A PCF8574 (non A) has an upper nibble of 4 for the address and the PCF5874A version has an upper nibble of 7 for the address. NXP did this to allow upto 16 devices on the I2C bus.
    Dave Purola,
    N8NTA
    EN82fn

  6. #46
    Join Date
    Mar 2008
    Posts
    42

    Default Re: Interfacing with Arduino I2C LCD

    PCF8574AT is the number on my IC.

  7. #47
    Join Date
    Oct 2012
    Posts
    9

    Default Re: Interfacing with Arduino I2C LCD

    Wow... I must apologize for being a butt head. I've got no excuse... I'm a butt head. That being said, here's some of the code I originally did not want to share. It's highly commented, so I hope it's more helpful than the first post. It's not the same "Hello RCG" example, but a speed test I did. It's easy to follow (at least I think it is).

    Code:
    'I2C LCD SPEED TEST.BAS
    'BY NoRoHS
    'BASIC INTERFACING WITH AN ARDUINO I2C LCD GY-LCD-V1 20x4 LCD MODULE
    'TARGET PIC 12F629
    'PRINTS THE NUMBERS (0 THROUGH 65535) ON THE LCD AS FAST AS IT CAN
    'RESULT IS ABOUT 800CPS COM SPEED AND DISPLAY VALUE UPDATE IS 120 TIMES A SECOND
    'SET PROGRAMMER FOR POWER-UP TIMER ENABLE AND HS CLOCKING (20MHZ) AND NO WDT
    '352 WORDS USED
    'TESTED AND CONFIRMED ON LAST SAVE/COMPILE 11/11/12
    '
    '             
    '           |<============ NO NEED FOR 4.7k PULLUP RESISTORS -
    '           |   |<======== 10K'S ARE ON ARDUINO I2C LCD MODULE'S BACKBOARD 
    '           |   |                               
    '      GND SDA SCL N/C
    '     __|___|___|___|__
    '    |  8   7   6   5  |
    '    >   PIC12F629     |
    '    |__1___2___3___4__|
    '       |   |   |   |
    '      +5V  X-TAL  N/C
    '
    '   METHOD OF OPERATION:
    '   USES BYTE VARIABLE (NUM_GEN) TO STEP THROUGH ALL 65536 VALUES AND PRINT
    '   THIS NUMBER ON THE FIRST LINE. EACH NUMBER IS CONVERTED TO A 
    '   DIGIT VALUE AND PADDED BY ADDING 48 THE RESULTS TO CONVERT IT TO ASCII.
    '   SINCE THIS IS AN I2C COM, THE LCD IS IN THE 4-BIT MODE AND DATA IS MOVED
    '   USING THE 4-BIT FORMAT, REQUIRING THE SHIFTING AND MASKING OF DATA FOR 
    '   EACH COMMAND/VALUE SENT.
    '
    '   THIS IS A 'CHOPPED' PROGRAM FROM ANOTHER ONE AND MOST OF THE UN-NEEDED
    '   PROGRAM INFORMATION HAS BEEN REMOVED, BUT SOME MAY STILL REMAIN.
    '
    '   THE FOLLOWING HELPS EXPLAIN THE 12C TO 4-BIT MODE DATA CONVERSION PROCESS:
    '
    '
    '   vvvvvvv (FROM FIRST DEMO PROGRAM - RELEVENT - FOR REFERENCE ONLY)  vvvvvvvv
    '   ***************************************************************************
    '   *                                                                         *
    '   *  WRITING TO LCD MODULE WITH I2C FORMAT: (I2CWRITE D,C,ADDR,[LCD_DAT])   *
    '   *                                                                         *
    '   ***************************************************************************
    '   *                                                                         *
    '   *  *REMEMBER, EVEN THOUGH THE LCD IS SET FOR 4-BIT MODE, IN I2C WE ARE    *
    '   *   ALWAYS SENDING 8 BITS OF DATA WITH EVERY I2CWRITE COMMAND             *
    '   *                                                                         *
    '   *  *HIGH NIBBLE MEANS THE HIGHEST 4 BITS OF A BYTE                        *
    '   *  *LOW NIBBLE MEANS THE LOWEST 4 BITS OF A BYTE                          *
    '   *                                                                         *
    '   *  *LCD_DAT Variable IS A BYTE - VALUE MAYBE CODED IN HEX ($xy)           *
    '   *    FOR EASY READING                                                     *
    '   *                                                                         *
    '   *  *HIGH NIBBLE OR THE x IN $xy IS THE LCD MODULE FUNCTION PINS (4 BITS)  *
    '   *  *LOW NIBBLE OR THE y IN $xy IS THE LCD DATA PINS (4 BITS)              *
    '   *                                                                         *
    '   *  *HIGH NIBBLE (FUNCTION NIBBLE)(x IN $xy) EX:($4y OR %0100yyyy) CONTAINS*
    '   *    LCD_DAT.Bit7 = BACKLIGHT LED ON/OFF (1 = OFF, 0 = ON)(NOT A MISPRINT)*
    '   *    LCD_DAT.Bit6 = RS (1 = DATA, 0 = INSTRUCTION)                        *
    '   *    LCD_DAT.Bit5 = R/W (1 = READ, 0 = WRITE)                             *
    '   *    LCD_DAT.Bit4 = E (1 = ENABLE, 0 = INHIBIT)                           *
    '   *                                                                         *
    '   *    **NOTE THAT EVERY TRANSMISSION OF DATA WILL INCLUE INFORMATION ABOUT *
    '   *      THESE FUNCTIONS. IN THIS EXAMPLE, SETTING THESE PINS (IF NEEDED)   *
    '   *      MUST BE DONE AFTER CONSTRUCTING THE DATA TO BE SENT. MASKING AND   *
    '   *      SHIFTING NEEDED TO CONSTRUCT THE LOWER NIBBLE MEANS THESE BITS ARE *
    '   *      ALWAYS SET TO "0" AFTER THE DATA IS CONSTRUCTED.                   *
    '   *                                                                         *
    '   *  *LOW NIBBLE (DATA NIBBLE) (THE y IN $xy) EX:($x8 OR %xxxx1000) CONTAINS*
    '   *    LCD_DAT.Bit3 = DATA BIT 3 (MSB)                                      *
    '   *    LCD_DAT.Bit2 = DATA BIT 2                                            *
    '   *    LCD_DAT.Bit1 = DATA BIT 1                                            *
    '   *    LCD_DAT.Bit0 = DATA BIT 0 (LSB)                                      *
    '   *                                                                         *
    '   *  *LCD_DAT IS SENT OUT IN TWO WRITES USING I2CWRITE(**)                  *
    '   *    SEND OUT THE HIGH NIBBLE OF THE DATA FIRST:                          *
    '   *    LCD_DAT = FUNCTION + DATA(HIGH NIBBLE) > I2CWRITE                    *
    '   *    LATCH DATA TO LCD MODULE (ENABLE BIT SET/RELEASE) > RETURN           *
    '   *    SEND OUT THE LOW NIBBLE OF THE DATA SECOND:                          *
    '   *    LCD_DAT = FUNCTION + DATA (LOW NIBBLE) >  I2CWRITE                   *
    '   *    LATCH DATA TO LCD MODULE (ENABLE BIT SET/RELEASED) > RETURN          *
    '   *                                                                         *
    '   *    **NOTE:                                                              *
    '   *       THE FIRST TIME THE MODULE IS ADDRESSED IT IS IN THE 8-BIT MODE.   *
    '   *       THESE COMMANDS MUST BE THE FIRST SENT TO THE LCD MODULE TO PUT    *
    '   *       IT IN THE 4-BIT MODE:                                             *
    '   *                                                                         *
    '   *       LCD_DAT = $02                                                     *
    '   *       GOSUB LCDWRITE                                                    *
    '   *       GOSUB LCDWRITE                                                    *
    '   *       LCD_DAT = $08                                                     *
    '   *       GOSUB LCDWRITE                                                    *
    '   *                                                                         *
    '   *  *EXAMPLE: (SENDING THE CHARACTER "H")                                  *
    '   *    * THE CHARACTER "H" IN HEX IS $48                                    *
    '   *    * SEND THE HEX '4' FIRST, THEN THE HEX '8' SECOND                    *
    '   *    * EACH TIME THEY ARE SENT, THEY ARE COMBINED WITH THE FUNCTION       *
    '   *       HIGH NIBBLE (REPRESENTED AS x IN $xy)                             *
    '   *    * FOR THIS EXAMPLE: FUNCTION = $4y OR %0100yyyy OR $40 (MASKED)      *
    '   *       WHICH IS LED = ON, RS = DATA, R/W = WRITE, E = INHIBIT            * 
    '   *    * SO, SENDING THE HEX DATA IN THIS EXAMPLE OF "H" IS:                *
    '   *       LCD_DAT = $44, LCDWRITE, FOLLOWED BY LCD_DAT = $48, LCDWRITE      *
    '   *    * THE SUB LCDWRITE WILL SEND LCD_DAT VIA I2C TO THE ARDUINO MODULE   *
    '   *       AND THEN TOGGLE THE 'E'(ENABLE) BIT ON AND OFF TO 'LATCH' THE DATA*
    '   *       INTO THE LCD MODULE. THIS IS WHY LCDWRITE HAS 3 I2CWRITE'S IN IT. *
    '   *                                                                         *
    '   ***************************************************************************
    '
    '
        
    Define OSC 20             'USE EXTERNAL 20MHZ CRYSTAL (PINS 2 AND 3)
    'DEFINE I2C_SLOW 1        'SEEMS TO WORK FASTER AND WELL IN THE FASTER MODE
    
    CMCON = $7                'SET COMPARITOR PORTS TO DIGITAL
    
    MASK    CON $0F            'SET MASK TO %00001111 TO CLEAR TOP NIBBLE
    
    C       VAR GPIO.1        'IC PIN 6 IS SCL
    D       VAR GPIO.0        'IC PIN 7 IS SDA
    
    ADDR    VAR BYTE          'HOLDER FOR I2C ADDRESS
    LCD_DAT VAR BYTE          'HOLDER FOR I2C LCD MODULE DATA ***SEE ABOVE ^
    FCHAR   VAR BYTE          'CHARICTOR OR COMMAND TO BE SENT
    FTEMP   VAR BYTE          'NEEDED TO MANIPULATE FCHAR AND PRESERVE FCHAR VALUE
    E       VAR LCD_DAT.BIT4  'HOLDER FOR ENABLE BIT (xxxE xxxx)
    RS      VAR LCD_DAT.BIT6  'HOLDER FOR REGISTER SELECT BIT (xRSxx xxxx)
    
    NUM_GEN VAR WORD          'LOOP COUNTER HOLDER FOR THE VALUE TO BE DISPLAYED 
    NUM_GEN = 0               'MAKE SURE VALUE STARTS AT 0 (REDUNDENT)
    
    ADDR = $40                'SET I2C 7 BIT ADDRESS $20 + A '0' FOR PBP BYTE VALUE
    LCD_DAT = $00             'PRESET LCD_DAT VALUE TO 0 TO BE SURE
    E = 0                     'PRESET ENABLE AND REGISTER SELECT BITS TO O
    RS = 0                    '  (ALSO TO BE SURE)
    
    PAUSE 1000                 'WAIT 1 SECOND FOR THE LCD MODULE TO RESET 
    
    '***************       'LCD MODULE SETUP STARTS HERE  **************************
                           
    LCD_DAT = $02             'SETUP LCD MODULE FOR 4-BIT MODE
    GOSUB LCDWRITE         
    GOSUB LCDWRITE            'NOTE: MUST SEND $02 TWICE
    LCD_DAT = $08          
    GOSUB LCDWRITE         
    
    LCD_DAT = $00             'DISP ON, CURS ON, NO BLINK UPPER NIBBLE 
    GOSUB LCDWRITE            '...SEND
    LCD_DAT = $0E             'DISP ON, CURS ON, NO BLINK LOWER NIBBLE
    GOSUB LCDWRITE            '...SEND
    LCD_DAT = $00             'SETUP ENTRY MODE UPPER NIBLE
    GOSUB LCDWRITE            '...SEND
    LCD_DAT = $06             'SETUP ENTRY MODE LOWER NIBLE
    GOSUB LCDWRITE            '...SEND
    LCD_DAT = $00             'RETURN TO HOME UPPER NIBLE
    GOSUB LCDWRITE            '...SEND
    LCD_DAT = $02             'RETURN TO HOME LOWER NIBLE
    GOSUB LCDWRITE            '...SEND
    
    '****************      LCD MAIN DISPLAY LOOP STARTS HERE  *********************
    
    MAIN:
    
    fOR NUM_GEN = 0 TO 65535  'MAIN LOOP COUNTER AND NUMBER TO BE DISPLAYED
    
        FCHAR = NUM_GEN DIG 4 'THE NEXT 17 LINES ARE USED TO CALCULATE THE
        FCHAR = FCHAR + 48    'ASCII VALUE TO BE SENT TO THE LCD DISPLAY...
        GOSUB CONSTRUCT_CHAR
    
        FCHAR = NUM_GEN DIG 3
        FCHAR = FCHAR + 48
        GOSUB CONSTRUCT_CHAR
    
        FCHAR = ","           'NO ASCII CONVERSION NEEDED FOR " , " 
        GOSUB CONSTRUCT_CHAR
    
        FCHAR = NUM_GEN DIG 2
        FCHAR = FCHAR + 48
        GOSUB CONSTRUCT_CHAR
    
        FCHAR = NUM_GEN DIG 1
        FCHAR = FCHAR + 48
        GOSUB CONSTRUCT_CHAR
    
        FCHAR = NUM_GEN DIG 0
        FCHAR = FCHAR + 48
        GOSUB CONSTRUCT_CHAR
        
        LCD_DAT = $00         'SEND UPPER NIBBLE 'RETURN TO HOME' COMMAND
        GOSUB LCDWRITE
        LCD_DAT = $02         'SEND LOWER NIBBLE 'RETURN TO HOME' COMMAND
        GOSUB LCDWRITE
        
        nEXT NUM_GEN          'NEXT NUMBER TO BE DISPLAYED... UNTIL 65535
    
    PAUSE 2000                'PAUSE 2 SECONDS WHEN NUM_GEN ROLLS OVER
    
    GOTO MAIN                 'LOOP FOREVER
    
    '************ CONSTRUCT_CHAR SUB- CONSTRUCT CHARICTERS AND SEND OUT ************
    
    CONSTRUCT_CHAR:
    
        FTEMP = FCHAR         'MOVE THE UPPER NIBBLE TO THE LOWER NIBBLE
        FTEMP = FTEMP >> 4    ' (UPPER NIBBLE IS SENT FIRST IN 4-BIT MODE)
        LCD_DAT = FTEMP       'NOTE: UPPER NIBBLE IS GOING TO BE ALL "0" ...
        RS = 1                '  SO, SET THE RS TO 'DATA'
    
        GOSUB LCDWRITE        'SEND UPPER NIBBLE TO LCD
    
        FTEMP = FCHAR         'MASK THE UPPER NIBBLE WITH '0'
        FTEMP = FTEMP & MASK  ' (LOWER NIBBLE IS SENT SECOND IN 4-BIT MODE)
        LCD_DAT = FTEMP       'NOTE: UPPER NIBBLE IS GOING TO BE ALL "0" ...
        RS = 1                '  SO, SET THE RS TO 'DATA'
    
        GOSUB LCDWRITE        'SEND LOWER NIBBLE TO LCD
    
    RETURN
    
    '************* LCDWRITE SUB - SENDING AND LATCHING DATA TO LCD *****************
    
    LCDWRITE:
    
    I2CWRITE D,C,ADDR,[LCD_DAT] 'LOAD DATA ONTO LCD PORT (NOT LATCHED YET)
    E = 1                       'SET ENABLE BIT
    I2CWRITE D,C,ADDR,[LCD_DAT] 'LATCH DATA BY SETTING ENABLE PIN ON LCD MODULE
    E = 0                       'CLEAR ENABLE BIT
    I2CWRITE D,C,ADDR,[LCD_DAT] 'CLEAR ENABLE PIN ON LCD MODULE
                                    
    RETURN
    
    '****************          'END    ********************************************
    
    END
    
    Attached Files Attached Files

  8. #48
    Join Date
    Mar 2008
    Posts
    42

    Default Re: Interfacing with Arduino I2C LCD

    Thank You, I will try your code. I went another direction but I will order another display just to try this. Thanks again!

Similar Threads

  1. Another Arduino clone that uses a PIC
    By dhouston in forum PBP & Amicus18
    Replies: 0
    Last Post: - 7th March 2012, 19:14
  2. Arduino ?
    By Michael in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 13th September 2011, 19:50
  3. How do I operate an Arduino I2C LCD
    By menta in forum General
    Replies: 8
    Last Post: - 13th July 2011, 02:28
  4. Arduino
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 1st July 2011, 19:11
  5. ARDUINO? -- what is it?
    By Michael in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th August 2009, 00:19

Members who have read this thread : 26

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