I2C LCD


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 47

Thread: I2C LCD

  1. #1
    Join Date
    Jan 2014
    Posts
    84

    Default I2C LCD

    Merry XMAS to all!
    I'm back with another problem. Its first time when I work with I2C .
    I have a 1x LCD with 8 pins, I suppose that have a controller ST7036i or ST7032i (pin2, pin3 = NC) and also I have a LCD with 7 pins , TM202SIFSUGWA with ST7036i controller(pin2 = NC) . I tried to display a text but I have nothing on LCD.

    I used this schematic:

    Name:  schema.JPG
Views: 6363
Size:  67.3 KB

    Code :
    #CONFIG
    __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
    __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG

    OSCCON = %01101010 'sets the internal oscillator to 4Mhz

    TRISA = %00000000
    TRISC = %00000000
    ANSELA = %00000000
    ANSELC = %00000000

    OPTION_REG.7 = 0
    WPUA = %00000000
    WPUC = %00000011

    PORTA = 0
    PORTC = 0

    SCL VAR PORTC.0
    SDA var PORTC.1
    RESET var PORTC.2 ; IT'S REQUIRED?

    cbyte var byte 'CONTROL BYTE FOR DATA
    I2C var byte 'CONTROL BYTE FOR CONTROL CODES

    cbyte = 0 'USE TO send a command
    I2C = $7C 'ADDRESS FROM MANUAL ??

    main:

    I2CWRITE SDA,SCL,I2C,cbyte,[$25] 'contrast
    PAUSE 1
    I2CWRITE SDA,SCL,I2C,cbyte,["HELLO"] 'print on the first line
    pause 3000

    goto main
    end
    Pls, can somebody help me ?

    1000 x thx !

  2. #2
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: 16LF1824 strange problem

    Code:
    #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
          
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    WPUA = %00000000
    WPUC = %00000011
    
    PORTA = 0  
    PORTC = 0
      
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    RESET var PORTC.2 ; IT'S REQUIRED?
    
    cbyte var byte 'CONTROL BYTE FOR DATA
    I2C   var byte 'CONTROL BYTE FOR CONTROL CODES
    
    cbyte = 0 'USE TO send a command
    I2C   = $7C 'ADDRESS FROM MANUAL ??
    
    main:
    
    I2CWRITE SDA,SCL,I2C,cbyte,[$25] 'contrast
    PAUSE 1
    I2CWRITE SDA,SCL,I2C,cbyte,["HELLO"] 'print on the first line
    pause 3000
    
    goto main
    end

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: 16LF1824 strange problem

    It might be working but the lcd might not have high enough contrast.

    Usually, V0 is not VDD.

    Try a 20K variable resistor, V0 to center pin, VDD to one side, GND to other side.

    Now turn resistor and look at LCD for changes.

    Edit: also increase pause between writes to lcd in case it needs more time. Try PAUSE500 to test.

    Robert
    Last edited by Demon; - 26th December 2014 at 22:36.

  4. #4
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Thx Robert for suggestion ..I tried like schematic, but nothing...
    A question : on this LCD type I must see a dots when I play cu variable resistor ? Or first time ,lcd must be initialized ?

    Name:  schema.JPG
Views: 5329
Size:  16.0 KB
    Attached Images Attached Images  
    Last edited by midali; - 27th December 2014 at 11:02.

  5. #5
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    You can start by seeing the "squares" where the characters will appear darken. Once you get something going - adjust to taste.

  6. #6
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    I do not see RESET set to any value. Portc is 0. Most LCDs I have work with the reset line needs to be high. (except if you are resetting) I could not find a data sheet so not sure about your display.

    Dave

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Yeah, couldn't find anything either.

    Try adding a PAUSE 250 before writes to give time to lcd to initialize.

    Robert

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: 16LF1824 strange problem

    Quote Originally Posted by Demon View Post
    ...
    Try a 20K variable resistor, V0 to center pin, VDD to one side, GND to other side.
    ...
    You still need VDD to pin 4.

    Robert

  9. #9
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    2C = $7C 'ADDRESS FROM MANUAL ??
    What manual? Do you have a link?

    Robert

  10. #10
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    So , I found a working factory motherboard with LCD ( 7 pins) , TM202SIFSUGWA ,with ST7036i controller .
    I measured the voltage on pin V0 =3.87 V , then I desoldered the lcd and I tried to set contrast with a variable resistor...nothing on LCD!
    My conclusion is that contrast must set from software. I'm wrong ?

  11. #11
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Really I have more different LCD display's, with 7 and 8 pins.
    I tried with:
    - 8 pins LCD (TM202TCCWUGWA) ...I suppose that have ST7032i controller
    - 7 pins LCD (TM202SGFSGWA-B-1A ) ...I'm sure that have ST7036i controller

    I not found datasheets for them, but I suppose that important is the controller.
    Recently I found some information about ST7032, see atach. ST7032i_10.zip
    Here is a link with the same LCD ( I guess) http://www.farnell.com/datasheets/1669635.pdf

    New code (not working)
    Code:
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    RESET var PORTC.2 ; IT'S REQUIRED?
    
    cbyte var byte 'CONTROL BYTE FOR DATA
    I2C   var byte 'CONTROL BYTE FOR CONTROL CODES
    
    cbyte = 4 'USE TO send a command
    I2C   = $7C 'ADDRESS FROM MANUAL ??
    high reset
    
    main:
    
    I2CWRITE SDA,SCL,I2C,cbyte,["HELLO"] 'print on the first line
    pause 250
    
    goto main
    end

  12. #12
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Add PAUSE 250 before Main, LCD must stabilize.

    (Will look at datasheet)

    Robert

  13. #13
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Look at I2C commands in PBP manual. You are missing DEFINEs.

    Robert

  14. #14
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD


  15. #15
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    For me is too hard because I write in basic code only few lines in my life. Your start point is welocome for me.
    I appreciate your help Robert! Thank you very much!

  16. #16
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    To inilalize this display wyou need to write something like this
    Code:
    high RESET
    pause 10
    low RESET
    pause 10
    high RESET
    
    I2CWRITE datapin, clockpin,$7C[$80,$57,$80,$6C,$80,$01,$80,$02]
    before you can write to the display
    Code:
    I2CWRITE datapin, clockpin,$7C[$80,$80,$40,$48,$45,$$4C,$4c,$4F]  'HELLO
    I do not have a display to test so not sure if this will work, but this is what I would start with, I took the code from the data sheet.

    Dave

  17. #17
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    You might want to put a resistor on RESET pin, at least 1K.

    Robert

  18. #18
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    I measured on working original board with ST7036i controller , 5V Vdd :
    V0 pin = 3,82V (voltage from a divider with 2 resistors)
    SDA = 150 ohm resistor between PIC pin and SDA LCD pin
    SCL = to PIC pin
    SDA and SCL = 1k to 5V
    RESET = to PIC pin and 1nF capacitor to GND
    RESET pin is all time to HIGH

    A question : SDA and SCL pins from LCD must connect with SDA and SCL pins from PIC or I can connect to any pins pic ?

  19. #19
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Quote Originally Posted by DaveC3 View Post
    To inilalize this display wyou need to write something like this
    Code:
    high RESET
    pause 10
    low RESET
    pause 10
    high RESET
    
    I2CWRITE datapin, clockpin,$7C[$80,$57,$80,$6C,$80,$01,$80,$02]
    before you can write to the display
    Code:
    I2CWRITE datapin, clockpin,$7C[$80,$80,$40,$48,$45,$$4C,$4c,$4F]  'HELLO
    I do not have a display to test so not sure if this will work, but this is what I would start with, I took the code from the data sheet.

    Dave
    Thx Dave, I tried but nothing!
    I tried a code for 7036i controller, with V0 connected to Vdd , but I feel that somewhere I'm wrong in DEFINE LCD .
    I know that your help eat a lot of time, but if somebody have a free time to read in datasheet and help me, I'll appreciate!
    Datasheet 7036i : http://www.datasheetarchive.com/dlma...DSA-621251.pdf

    Code :

    Code:
    'PIC 16F1824
    
    #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
          
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    WPUA = %00000000
    WPUC = %00000011
    
    PORTA = 0  
    PORTC = 0
      
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    RS    var PORTC.2 
    symbol mode = $7C
    
    pause 100
    RS = 0
    'OPF1 = 0 ; OPF2 = 0 . => BON=0, FON=1. => Vout=Vin (pag50 datasheet)
    
    '=============Initializing by Instruction==========pag 39 datasheet
    
    'CLEAR LCD --------------pag 28 datasheet
    I2CWRITE sda, scl,mode,[$01]
    pause 10
     
    'ENTRY MODE SET----------
     I2CWRITE sda, scl,mode,[$07] 'cursor/blink moves to right and DDRAM address is increased by 1.
     pause 10
     
    'FUNCTION SET------------pag 30 datasheet
    I2CWRITE sda, scl,mode,[$38] ' 8 bit, 2 lines, font normal, instruction table 0
    pause 10
    
    'CURSOR DISPLAY------------pag 29 datasheet
    I2CWRITE sda, scl,mode,[$14]
    pause 10
    
    'INTERNAL OSC------------pag 35 datasheet
    I2CWRITE sda, scl,mode,[$14] ' 1/5 BIAS , 130Hz/5v
    pause 10
    
    'CONTRAST SET------------pag 37 datasheet
    I2CWRITE sda, scl,mode,[$7F]
    pause 10
    
    'POWER/ICON/CONTRAST------pag 36 datasheet
    I2CWRITE sda, scl,mode,[$5B] 'ICON=ON, BON = OFF , contrast $03
    pause 10
    
    'FOLLOWER CONTROL-------pag 37 datasheet
    I2CWRITE sda, scl,mode,[$6F] 'FON=1 ..set is correct ??
    pause 10
    
    'DISPLAY ON------------- pag 29 datasheet
    I2CWRITE sda, scl,mode,[$0E] 'display ON, cursor ON, blink OFF
    pause 10
    
    RS = 1
    pause 500
    
    I2CWRITE SDA,SCL,mode,["HELLO"] 'print on the first line

  20. #20
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Try this, initalization based on an arduino sketch
    Code:
    'PIC 16F1824
    
    #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
          
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    WPUA = %00000000
    WPUC = %00000011
    
    PORTA = 0  
    PORTC = 0
      
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    RS    var PORTC.2 
    symbol mode = $7C
    
    pause 100
    RS = 0
    'OPF1 = 0 ; OPF2 = 0 . => BON=0, FON=1. => Vout=Vin (pag50 datasheet)
    
    '=============Initializing by Instruction==========pag 39 datasheet
    
     
    I2CWRITE PORTC.1, PORTC.0,$7C,[$00] 'send command to display
     
    'FUNCTION SET 0 and 1 ------------pag 30 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$38] ' Function set - 8 bit, 2 line display 5x8, inst table 0
    pause 10
    
    I2CWRITE PORTC.1, PORTC.0,$7C,[$39] ' Function set - 8 bit, 2 line display 5x8, inst table 1
    pause 10
    
    
    
    'INTERNAL OSC------------pag 35 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$14] ' 1/5 BIAS , 130Hz/5v
    
    
    'CONTRAST SET------------pag 37 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$73]
    
    
    'POWER/ICON/CONTRAST------pag 36 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$5E] 'ICON=ON, BON = OFF , contrast $03
    
    
    'FOLLOWER CONTROL-------pag 37 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$6D] 'FON=1 ..set is correct ??
    pause 10
    
    'DISPLAY ON------------- pag 29 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$0C] 'display ON, cursor ON, blink OFF
    
    
    
    'CLEAR LCD --------------pag 28 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$01]
    
    
    'ENTRY MODE SET----------
     I2CWRITE PORTC.1, PORTC.0,$7C,[$06] 'cursor/blink moves to right and DDRAM address is increased by 1.
    
    
    RS = 1
    pause 500
    
    I2CWRITE PORTC.1,PORTC.0,$7C,["HELLO"] 'print on the first line [ I am not sure this line will work]
    Can you include a high res picture of your display?

  21. #21
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    try this
    Code:
    'PIC 16F1824
    
    #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
          
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    WPUA = %00000000
    WPUC = %00000011
    
    PORTA = 0  
    PORTC = 0
      
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    RS    var PORTC.2 
    symbol mode = $7C
    
    pause 100
    RS = 0
    'OPF1 = 0 ; OPF2 = 0 . => BON=0, FON=1. => Vout=Vin (pag50 datasheet)
    
    '=============Initializing by Instruction==========pag 39 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$78] 'slave
     
    I2CWRITE PORTC.1, PORTC.0,$7C,[$00] 'send command to display
     
    'FUNCTION SET 0 and 1 ------------pag 30 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$38] ' Function set - 8 bit, 2 line display 5x8, inst table 0
    pause 10
    
    I2CWRITE PORTC.1, PORTC.0,$7C,[$39] ' Function set - 8 bit, 2 line display 5x8, inst table 1
    pause 10
    
    
    
    'INTERNAL OSC------------pag 35 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$14] ' 1/5 BIAS , 130Hz/5v
    
    
    'CONTRAST SET------------pag 37 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$73]
    
    
    'POWER/ICON/CONTRAST------pag 36 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$5E] 'ICON=ON, BON = OFF , contrast $03
    
    
    'FOLLOWER CONTROL-------pag 37 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$6D] 'FON=1 ..set is correct ??
    pause 10
    
    'DISPLAY ON------------- pag 29 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$0C] 'display ON, cursor ON, blink OFF
    
    
    
    'CLEAR LCD --------------pag 28 datasheet
    I2CWRITE PORTC.1, PORTC.0,$7C,[$01]
    
    
    'ENTRY MODE SET----------
     I2CWRITE PORTC.1, PORTC.0,$7C,[$06] 'cursor/blink moves to right and DDRAM address is increased by 1.
    
    
    RS = 1
    pause 500
    I2CWRITE PORTC.1, PORTC.0,$7C,[$78] 'slave
     
    I2CWRITE PORTC.1, PORTC.0,$7C,[$40] 'Write to display RAM
    I2CWRITE PORTC.1,PORTC.0,$7C,["HELLO"] 'print on the first line [ I am not sure this line will work]
    end

  22. #22
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    or try this,
    Code:
     #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
          
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    Reset    var PORTC.2     'could tie reset pin to   vdd through 10K resistor
    
    
    pause 100
    HIGH Reset
    'OPF1 = 0 
    goto StartProgram
    '********************************************************************************
    '=============Initializing LCD==========
    ST7036Init:
    
    
     
    'FUNCTION SET 0 and 1 ------------pag 30 datasheet
    
    I2CWRITE PORTC.1, PORTC.0,$78,[$00,$38] ' Function set - 8 bit, 2 line display 5x8, inst table 0
    pause 10
    
    I2CWRITE PORTC.1, PORTC.0,$78,[$00,$39] ' Function set - 8 bit, 2 line display 5x8, inst table 1
    pause 10
    
    I2CWRITE PORTC.1, PORTC.0,$78,[$00,$14,$73,$5E,$6D,$0C,$01,$06] ' 
    
    
    
    Return
    '********************************************************************************
    
    
    
    startProgram:
    gosub  ST7036Init
    I2CWRITE PORTC.1, PORTC.0,$78,[$40,$48,$65,$6c,$6c,$6f] ' Hello
    
    IdleLoop:
          ' could blink an led here
    goto Idleloop

  23. #23
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    1000 x thx Dave for your help!
    I tried all your suggestions, but nothing on display. Also I changed 3 lcds for test ,I tried another ways to initialise, but no succes.
    I can make a photo at high resolution with LCD, but is only light, nothing else.
    Its possible that LCD init is well, but problems come from contrast?
    How I can make a loop with set contrast with values from $00 to $FF ?
    Note: the LCD Bias must set to 1/5

  24. #24
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    On my lcd, I adjust contrast with the potentiometer on pin V0.

    Robert

  25. #25
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Without the LCD data sheet I don't think I can help ay more. Looking at the controller data sheet does not tell the whole story. There are different interfaces and component combinations for different VDD voltages and LCD manufactures. Where did you buy this LCD?

    Dave

  26. #26
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Quote Originally Posted by DaveC3 View Post
    Without the LCD data sheet I don't think I can help ay more. Looking at the controller data sheet does not tell the whole story. There are different interfaces and component combinations for different VDD voltages and LCD manufactures. Where did you buy this LCD?

    Dave
    You are right Dave !

    All LCD's was a gift for me from a friend. He gave me a printed paper with sumary of LCD(7pins):
    - Display Type : TM202SIFSUGWA
    - LCD OPERATING VOLTAGE : 4.8V
    - VDD : 5V
    - DRIVE METHOD : 1/16 DUTY ; 1/5 BIAS
    - CONTROLLER : ST7036i
    - pinouts, tolerance, etc

    Really on boards I found 3 LCDs with different serials, but the boards are same, with the same functions. Actually I work on TM202SGFSGWA-B-1A . On internet I dont find a datasheet for them. I suppose that all LCDs with ST7036 controllers have the same init. The serials depending from manufacturers.

    The LCD's are mounted on a working factory boards. I desolder the LCD from motherboard for test...also I make a test on a LCD directly on board ( of course that I cuted the tracks from sda, scl and reset pins for separate of rest components board) because I want to be sure that LCD was not destroied from desoldering. Any code I wrote in pic, I tested with potentiometer divider , with V0 short with Vdd.

    I see in datasheet that contrast can be configured from registry(case V0 short with Vdd) or from external resistors divider.

    Also I have LCDs with 8 pins but I have not any information about them....I have a information only from a serial printed on back LCD side(TM202TCCWUGWA)...here I suppose that have a 7032 controller, but is no important at this time.

    Again thx for your help !

  27. #27
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    I think the LCDs that googled up for TM202 were Tienma. None of them were TM202T or S. It looks like these are custom made, specs could be anything.

    I suggest contacting Tienma and asking for a datasheet.

    Robert

  28. #28
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    As an outside chance change your pullup resistors to 4.7K, I have never used 1k. The contrast is set in the initialization of the display. I do not think you can change it on the fly.
    And lastly give this a try
    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : Dave Cutliff                                      *
    '*  Notice  : Copyright (c) 2014 Use at your own risk           *
    '*          : All Rights Reserved                               *
    '*  Date    : 12/29/2014                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
     #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
          
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    Reset    var PORTC.2     'could tie reset pin to   vdd through 10K resistor
    
    
    pause 100
    HIGH Reset
    'OPF1 = 0 
    goto StartProgram
    '********************************************************************************
    '=============Initializing LCD==========
    ST7036Init:
    
    
     
    
    
    I2CWRITE PORTC.1, PORTC.0,$78,[$00,$38, $39,$14,$79,$50,$6C,$0C,$01,$06] ' 
    
    
    
    Return
    '********************************************************************************
    
    
    
    startProgram:
    gosub  ST7036Init
    I2CWRITE PORTC.1, PORTC.0,$78,[$40,$48,$65,$6c,$6c,$6f] ' Hello
    
    IdleLoop:
          ' could blink an led here
    goto Idleloop
    Last edited by DaveC3; - 31st December 2014 at 00:52.

  29. #29
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Quote Originally Posted by DaveC3 View Post
    As an outside chance change your pullup resistors to 4.7K, I have never used 1k. ...
    Yup, from the manual:
    The I2C clock and data lines should be pulled up to Vcc with a 4.7K
    Could this be an issue?
    Transfer on the I2C bus can be paused by the receiving device by its holding the clock line low (not supported on 12-bit core PIC MCUs). To enable this the following DEFINE should be added to the program:

    DEFINE I2C_HOLD 1
    Robert


    EDIT: I would try one last thing with Dave's code, add PAUSE 250 before every write to the LCD, just to eliminate that possibility.
    Last edited by Demon; - 31st December 2014 at 02:45.

  30. #30
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Dave, with your last example code nothing help. I insert pause 250 between instructions and appear something like this : "ell o Hello " on LCD, but a very low contrast.i have not enough free time to change resistors from 1k to 4k7 . So, Its a good way! Thx Dave and Robert!

    Very strange, I tried quickly some variants to display a text without succes. I wrote again working code and again nothing on LCD
    So,now I must go with my family to party and "next year" I'm back to try.

    Again 1000x thx and Happy New Year to all forum members !

  31. #31
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    If you saw something on the display we are getting close. When you get a chance post the code where you saw "ell o Hello "

    Here is an initialization for a 5v display data sheet simular to yours.

    Code:
    INITIALIZE: (5V)
    MOV I2C_CONTROL,#00H ;WRITE COMMAND
    MOV I2C_DATA,#38H ;Function Set
    LCALL WRITE_CODE
    MOV I2C_CONTROL,#00H ;WRITE COMMAND
    MOV I2C_DATA,#39H ;Function Set
    LCALL WRITE_CODE
    MOV I2C_DATA,#14H ;Internal OSC frequency
    LCALL WRITE_CODE
    MOV I2C_DATA,#79H ;Contrast set
    LCALL WRITE_CODE
    MOV I2C_DATA,#50H ;Power/ICON control/Contrast set
    LCALL WRITE_CODE
    MOV I2C_DATA,#6CH ;Follower control
    LCALL WRITE_CODE
    MOV I2C_DATA,#0CH ;Display ON/OFF
    LCALL WRITE_CODE
    MOV I2C_DATA,#01H ;Clear Display
    LCALL WRITE_CODE
    Based on this information try to change your code to
    Code:
    ST7036Init:
    
    
     
    
    
    I2CWRITE PORTC.1, PORTC.0,$78,[$00,$38]
    PAUSE 10 
    I2CWRITE PORTC.1, PORTC.0,$78,[$00, $39,$14,$79,$50,$6C,$0C,$01,$06] ' 
    
    
    
    Return

  32. #32
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Working first code :
    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : Dave Cutliff                                      *
    '*  Notice  : Copyright (c) 2014 Use at your own risk           *
    '*          : All Rights Reserved                               *
    '*  Date    : 12/29/2014                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
     #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
    DEFINE I2C_HOLD 1       
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    SCL      VAR PORTC.0
    SDA      var PORTC.1
    Reset    var PORTC.2     'could tie reset pin to   vdd through 10K resistor
    
    pause 1000
    HIGH Reset
    goto StartProgram
    '********************************************************************************
    '=============Initializing LCD==========
    ST7036Init:
    I2CWRITE PORTC.1, PORTC.0,$78,[$00]
    pause 250
    I2CWRITE PORTC.1, PORTC.0,$78,[$38]
    pause 250
    I2CWRITE PORTC.1, PORTC.0,$78,[$39]
    pause 250
    I2CWRITE PORTC.1, PORTC.0,$78,[$14]
    pause 250
    I2CWRITE PORTC.1, PORTC.0,$78,[$79]
    pause 250
    I2CWRITE PORTC.1, PORTC.0,$78,[$50]
    pause 250
    I2CWRITE PORTC.1, PORTC.0,$78,[$6C]
    pause 250
    I2CWRITE PORTC.1, PORTC.0,$78,[$0C]
    pause 250
    I2CWRITE PORTC.1, PORTC.0,$78,[$01]
    pause 250
    I2CWRITE PORTC.1, PORTC.0,$78,[$06]
    pause 250
    Return
    '********************************************************************************
    startProgram:
    gosub  ST7036Init
    I2CWRITE PORTC.1, PORTC.0,$78,[$40,$48,$65,$6c,$6c,$6f] ' Hello
    
    IdleLoop:
          ' could blink an led here
    goto Idleloop
    Very strange whats happened: I wrote hex file , on LCD apppeared something like this :"ell o Hello ". I writed the file again, with the same hex file , on the same test board, without any changes ....and nothing on LCD! I tried many times...I discharged a capacitors from Vcc, I disconected the power supply 30 min, I turn ON again ...nothing!
    So, today I have free time to study . I'll try next Dave's suggestion.

    Thx for your patience ,Dave!!

  33. #33
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Quote Originally Posted by DaveC3 View Post
    If you saw something on the display we are getting close. When you get a chance post the code where you saw "ell o Hello "

    Here is an initialization for a 5v display data sheet simular to yours.

    Code:
    INITIALIZE: (5V)
    MOV I2C_CONTROL,#00H ;WRITE COMMAND
    MOV I2C_DATA,#38H ;Function Set
    LCALL WRITE_CODE
    MOV I2C_CONTROL,#00H ;WRITE COMMAND
    MOV I2C_DATA,#39H ;Function Set
    LCALL WRITE_CODE
    MOV I2C_DATA,#14H ;Internal OSC frequency
    LCALL WRITE_CODE
    MOV I2C_DATA,#79H ;Contrast set
    LCALL WRITE_CODE
    MOV I2C_DATA,#50H ;Power/ICON control/Contrast set
    LCALL WRITE_CODE
    MOV I2C_DATA,#6CH ;Follower control
    LCALL WRITE_CODE
    MOV I2C_DATA,#0CH ;Display ON/OFF
    LCALL WRITE_CODE
    MOV I2C_DATA,#01H ;Clear Display
    LCALL WRITE_CODE
    Based on this information try to change your code to
    Code:
    ST7036Init:
    
    
     
    
    
    I2CWRITE PORTC.1, PORTC.0,$78,[$00,$38]
    PAUSE 10 
    I2CWRITE PORTC.1, PORTC.0,$78,[$00, $39,$14,$79,$50,$6C,$0C,$01,$06] ' 
    
    
    
    Return
    I tried ...
    if I write the PIC and turn ON the board with Vcc = 3,6V I see on LCD this:
    Name:  3v6.JPG
Views: 4732
Size:  46.3 KB
    ...then I move the Vcc to 5V, on LCD appear :
    Name:  5v.JPG
Views: 4785
Size:  50.3 KB
    In this case I can set a contrast from 5k potentiometer on V0 LCD pin, but I see only full dots.

    If I write the PIC and turn ON the board with Vcc = 5v, I see nothing on LCD. No effect if I down the voltage to 3,6V !

  34. #34
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    '************************************************* *******************************
    IdleLoop:
    I2CWRITE PORTC.1, PORTC.0,$78,[$00, $39,$14,$79]
    pause 250
    goto Idleloop
    end[/CODE]

    With this line is nothing on display. One time appeared undefinited characters, who move to right one by one.

    Identically, in this case I run initially Vcc at 3,6V and after few seconds I changed to 5v.

  35. #35
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    In the above loop you are writing commands over and over again. I would not expect anything to display. I have to assume the supply to this display needs to be 5v (according to the paper you received from your friend). The connections should look like this with 5vName:  lcd5v.png
Views: 4784
Size:  19.1 KB

    Also change the address to $7C again according to the data sheet i found.

    Code:
    I2C interface
    It just only could write Data or Instruction to ST7032 by the IIC Interface.
    It could not read Data or Instruction from ST7032 (except Acknowledge signal).
    SCL: serial clock input
    SDA: serial data input
    Slaver address could only set to 0111110, no other slaver address could be set
    I found this data sheet at http://www.farnell.com/datasheets/1669635.pdf

    The pinouts are the same as your display

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : Dave Cutliff                                      *
    '*  Notice  : Copyright (c) 2014 Use at your own risk           *
    '*          : All Rights Reserved                               *
    '*  Date    : 12/29/2014                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
     #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
    #ENDCONFIG
    OSCCON = %01101010   'sets the internal oscillator to 4Mhz
          
    TRISA  = %00000000  
    TRISC  = %00000000  
    ANSELA = %00000000  
    ANSELC = %00000000  
    
    OPTION_REG.7 = 0
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    Reset    var PORTC.2     'could tie reset pin to   vdd through 10K resistor
    
    
    pause 100
    HIGH Reset
    'OPF1 = 0 
    goto StartProgram
    '********************************************************************************
    '=============Initializing LCD==========
    ST7036Init:
    
    
     
    
    
    
    I2CWRITE PORTC.1, PORTC.0,$7C,[$00,$38]
    PAUSE 10 
    I2CWRITE PORTC.1, PORTC.0,$7C,[$00, $39,$14,$79,$50,$6C,$0C,$01,$06] ' 
    
    
    
    Return
    '********************************************************************************
    
    
    
    startProgram:
    gosub  ST7036Init
    I2CWRITE PORTC.1, PORTC.0,$7C,[$40,$48,$65,$6c,$6c,$6f] ' Hello
    
    IdleLoop:
          ' could blink an led here
    goto Idleloop
    give the above a try, that a look at the data sheet.

    Good luck

    Dave

  36. #36
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Incredible but real !
    Don't work!
    I tried initializing by internal reset circuit, also I tried initialising by instructions...nothing on LCD!
    One time appeared "@ello" ...i disconected the Vcc, reconect and again blank lcd.
    Its spent free time for all, so I decided that I'll buy a LCD's with 7036i and 7032i controller and I'll test . After its works, I'll back to my LCD.I want to be sure that is 7036 or 7032 controller on my LCD's!
    I'll be back after I'll buy the LCD's .

    Thank you very much Dave for patience and for your help!!

  37. #37
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    No problem, sorry it does not wok for you. Did you try 4.7K pullups?

    Take care
    Dave

  38. #38
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    Each time I verified with 4k7 and 1k. I made 2 different boards for tests.
    I found on market LCD with 7036i controller with own datasheet. I hope that in 2 weeks I'll receive it.

  39. #39
    Join Date
    Jan 2014
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    I'm back after exactly 1 year.
    I changed the 16LF1824 with 16F1503 and now LCD is working !
    Many thx to Dave and Robert !

    Now I need again a your help. How i can display a variable ? (for example, x from my code )

    Working code:

    Code:
    DEFINE I2C_HOLD 1 
    TRISA  = 000000  
    TRISC  = 000000  
    ANSELA = 000000  
    ANSELC = 000000  
    OPTION_REG.7 = 0
    
    SCL   VAR PORTC.0
    SDA   var PORTC.1
    Reset var PORTC.2    
    x     var byte   :x=12
    com   con $78
    
    pause 100
    HIGH Reset
    
    goto StartProgram
    '********************************************************************************
    '=============Initializing LCD==========
    ST7036Init:
    I2CWRITE SDA,SCL,com,[$00,$38]'function set
    pause 1
    I2CWRITE SDA,SCL,com,[$00,$39]'function set
    pause 1
    I2CWRITE SDA,SCL,com,[$00,$14]'internal OSC
    pause 1
    I2CWRITE SDA,SCL,com,[$00,$6A]'follower control
    pause 1
    I2CWRITE SDA,SCL,com,[$00,$0C]'display on/off
    pause 1
    I2CWRITE SDA,SCL,com,[$00,$01]'clear display
    pause 1
    I2CWRITE SDA,SCL,com,[$00,$06]'entry mode set
    pause 1
    Return
    '********************************************************************************
    startProgram:
    gosub  ST7036Init
    I2CWRITE SDA, SCL,com,$40,"hello" 
     
    Main:
    'program
    goto Main
    Last edited by midali; - 28th December 2015 at 16:45.

  40. #40
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: I2C LCD

    midali,

    Now I need again a your help. How i can display a variable ? (for example, x from my code )
    that should be EASY!!

    in your example above just replace the "hello" with X (no quotes this time)
    you might need to choose how you want X to display... in the manual you should find where you can use modifiers like DEC for a decimal value or HEX for the hex value, etc.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

Similar Threads

  1. I2C lcd ( arduino ) with PICBASIC, help
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 92
    Last Post: - 10th September 2014, 19:00
  2. I2C variable to LCD
    By pointjohn in forum Serial
    Replies: 7
    Last Post: - 19th October 2011, 09:53
  3. I2C to LCD display
    By Ron Marcus in forum Serial
    Replies: 3
    Last Post: - 29th December 2007, 15:53
  4. Need cheap i2c LCD for 16F877a
    By CodeShredder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th December 2006, 02:25

Members who have read this thread : 7

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