Menu

Using LCD on 12lf1840 using I2C

Help
2016-08-21
2016-08-30
  • Jim giordano

    Jim giordano - 2016-08-21

    Which 4x20 LCD is a good match for using on a 12lf1840 using I2C?
    Is the "SainSmart IIC/I2C/TWI Serial 2004 20x4 LCD Module Shield For Arduino UNO MEGA R3" compatible?
    If so, what would the address be?

    p.s. I would prefer to operate on 3.3V if possible.

     

    Last edit: Jim giordano 2016-08-21
  • Anobium

    Anobium - 2016-08-22

    I will take the address question. :-)

    Attach the LCD - run I2C discovery and you chip will show you the address. Where is I2C discovery? In the demo folders of your installation. Typically, these devices are address 0x4e - which I think is the Great Cow BASIC default value.

     
  • Jim giordano

    Jim giordano - 2016-08-22

    Anobium-
    I tried this about a year ago with no luck. After a week of screwing around, I gave up. I'll order the sainsmart and try again.

     
    • Anobium

      Anobium - 2016-08-22

      I know of no reason why these devices will not work. I got one operating last month - no issues.

      Let us know what happens.

       
  • David Stephenson

    I mainly use the Midas Display MCCOG21605C6W it's 16x2 (or 16x1 software selectable). They are fairly cheap (see Rapid electronics (57-2338). Their great advantage is that they will run on 3 or 5V and the current is as low as 130 uA.
    As for the read and write addresses this is always in the the data sheet ( and on some devices can be altered with an external connection).
    Note getting I2C devices to work first time is fiddly I make sure that all caps are dischraged on each try as this can sometimes cause a lockup. Also don't forget the WPU (you can use the intenal ones on the 12F1840).

     
    • Anobium

      Anobium - 2016-08-23

      Always start as follows:
      - May sure pullups are fitted to data and clock
      - Check votlages
      - Check connnections
      - then,using I2C Discovery validate the i2c device.
      - then, move on to using any device driver.

      Yesterday, I received an I2C display - documentation stated one address... I2C discovery proved that the device was not setup as expected.

      A few hours later - new i2c display driver.

       

      Last edit: Anobium 2016-08-30
  • Jim giordano

    Jim giordano - 2016-08-28

    Thanks guys. I finally got it to work. Somewhere I read it had internal pullup resistors on scl and sda, but it didn't. Running the discovery program was a pain because I didn't have a terminal setup to run (that's why I was trying the lcd in the first place, no terminal) but finally got it using leds. Both address 78 and 79 worked (0x4e,0x4f).

     
  • David Stephenson

    On the 12F1840 there are weak pullups, but they are off as a default. If you want to avoid external resistors they can be activated as shown below

    #chip 12F1840,4
    #config OSC=INTOSC, MCLRE=Off, WDTE=off, boren=off
    #define hi2c_BAUD_RATE 400
    #define hi2c_DATA PORTA.2
    #define hi2c_CLOCK PORTA.1
    Dir hi2c_DATA in
    Dir hi2c_CLOCK in
    hi2cMode Master
    
    option_reg.7=0 'activate wpu
    wpua=b'00000110' 'wpu on a.1 and a.2
    

    Of those addreses one will probably be for read and the other for write.

     
  • Jim giordano

    Jim giordano - 2016-08-29

    Thanks for that. It almost worked. The weak pullups only brought the line up to 4.8V. Not quite enough to make the display happy. But it was interesting.
    Upon further testing, that 4.8 was just what the voltmeter read. Using a 220k resistor worked, and only read 4v, so the weak pullup just wasn't strong enough to hold the voltage when the display needed it, I guess.

     

    Last edit: Jim giordano 2016-08-29
    • Anobium

      Anobium - 2016-08-30

      Pullups rule! :-)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.