meanpc

i2c LCD

22 posts in this topic

Couple of questions:

 

1: Have you confirmed if I2C is talking to the LCD? You can probably read some registers to see if it gives anything back.

2: What chip do you have in the LaunchPad?

3: To what pins have you connected I2C SDA and SCL?

4: What is the I2C address?

5: Can you post your sketch so that we can have a look at it?

 

Robert

Share this post


Link to post
Share on other sites

1. I have not confirmed this with the Launchpad. The display works fine with Arduino boards, though

2. 2553

3. 14 and 15, or P1.6,P1.7

4. 0x27

5. I am using the library found here (at the bottom of the page): http://www.dfrobot.com/index.php?route= ... GYpGk3A9TI

 

I am just trying to upload the 'Hello World' sketch from that library which is:

 

//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include 
#include 

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
 lcd.init();                      // initialize the lcd 

 // Print a message to the LCD.
 lcd.backlight();
 lcd.print("Hello, world!");
}

void loop()
{
}

Share this post


Link to post
Share on other sites

I have to ask so please don't be offended. Is P1.6 connected to SCL of the display?

The Wiki says it's a 5 Volt device.. How do you have it hooked up to I2C of the LaunchPad? And what voltage are you supplying VCC on the LCD with?

Share this post


Link to post
Share on other sites
I have to ask so please don't be offended. Is P1.6 connected to SCL of the display?

The Wiki says it's a 5 Volt device.. How do you have it hooked up to I2C of the LaunchPad? And what voltage are you supplying VCC on the LCD with?

 

Not offended at all - I do stupid stuff all the time, so your questions are relevant.

 

I tried SDA and SCL connected to both 1.6 and 1.7. I have the display powered from the 5V test points near the USB connector on the launchpad. I was thinking of the display's logic being passive and not having to worry about 5V coming back to the Launchpad...but I didn't check. I just measured the voltage on SDA and SCL pins of the display while it's powered up and I'm measuring 150mV, but I don't know if that measurement is valid or not.

Share this post


Link to post
Share on other sites

First of all you will need to take care of the 3.3<->5 Volt incompatibility. Here is a good guide: http://www.savagecircuits.com/forums/co ... 3V-Devices

 

The 150mV is definitly not right and indicates that there are no pull resistors. I2C requires a pull up resistor on both SCL and SDA. You can enable the internal pull up in the msp430 on the I2C lines by doing:

 

pinMode(P1_6, INPUT_PULLUP);
pinMode(P1_7, INPUT_PULLUP);

 

Or you you can put external pull up resistors on both lines.

 

Be carefull with the 5Volt stuff though. This could fry your msp430.

Share this post


Link to post
Share on other sites

Sorry to resurrect this but I'm looking at a similar situation and think I may have a partial solution.

 

I have VCC and GND connected to the pins next to the USB port: the first and third line of the display show signs of being "on" if I turn the contrast all the way up. SCL connected to P1.6, SDA to P1.7.

 

The datasheet for the I2C chip here indicates Vcc of 2.5-6V. Obviously that's the chip, not the display. It also specs the SCL and SDA chips as "high" when not busy, requiring pull-up resistors. Logic level voltages on those two lines are: "LOW"= -0.5 to +0.3Vdd (presumably that means "0.3 * Vdd", so with 5v would be 1.5v); and "HIGH" as 0.7Vdd ( = 3.5v with 5v Vdd) to Vdd + 0.5.

 

I think we have confirmation that some level shifting needs done on SCL & SDA.

 

 

 

But I have another issue as well. I have tried the library for the dfrobot display, and a few different revisions of Sainsmart / YwRobot boards' libraries (one of which is the linked to in a bit and doesn't compile). The ones that do compile do not show any affect on the display, likely due to the level mismatch. The recommended library for the IIC circuit board I have (reads "Arduino-IIC-LCD GY-LCD-V1" along the bottom) is here. But will not compile a sketch. It fails with an error about missing file "pins_arduino.h".

 

One other comment- if that is the IIC board on the display, the address is 0x20, not 0x27 as the vendor states.

Share this post


Link to post
Share on other sites

Made some progress using this library: http://www.xs4all.nl/~hmario/arduino/LiquidCrystal_I2C/V1.0/LiquidCrystal_I2C_V1.0.zip

 

Used +5V and ground from near the USB port to an adjustable voltage regulator. I had 4.84V on the input to the regulator and 3.74V out.

As for IIC/I2C connections, SCL to P1.6, SDA to P1.7.

 

Sketch:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x20,20,4);  // set the LCD address to 0x20 for a 20 chars and 4 line display

void setup()
{
  lcd.init();                      // initialize the lcd 
 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("43oh.com rocks!     ");
  lcd.print("Now for some RFID...");
}

void loop()
{
}
 

 

Result:

8309990726_fbac5e04ce_z.jpg

Share this post


Link to post
Share on other sites

Okay, that gave me the cajones to try something else... same sketch as above, didn't even re-load it, just unplugged the MSP from USB, removed the cables and breadboard and plugged everything back together:

 

8310001456_a9c7d60d29_z.jpg

Share this post


Link to post
Share on other sites

Something I thought worth mentioning: on the 20x4 display, it's more like a 40x2.

Line 1 overflows to line 3. When line 3 overflows, it wraps to line 2. When line 2 overflows, it wraps to line 4.

When line 4 overflows, it's back to line 1.

 

I'm sure there's something in the library to deal with that but I haven't gone there yet: I'm just happy it's working.

roadrunner84 likes this

Share this post


Link to post
Share on other sites

why i can't just compile the code you post on top?

i'm really need to connect my IIC interface LCD1602 module to my launchpad G2553

what you guys were talking about seems just like the cure for me

but i had tried, and it didn't work.

i'm a little bit depressed right now,

could you give me some advice?

 

thanks a lot

 

the error imformation that Energia showed when i compile the "hello word" example

------

In file included from HelloWorld.cpp:2:0:
C:\energia-0101E0009\hardware\msp430\libraries\LiquidCrystal_I2C_V1/LiquidCrystal_I2C.h:80:16: error: conflicting return type specified for 'virtual void LiquidCrystal_I2C::write(uint8_t)'
C:\energia-0101E0009\hardware\msp430\cores\msp430/Print.h:55:20: error:   overriding 'virtual size_t Print::write(uint8_t)'
------

 

if you can figure it out what happened, please tell me.

Share this post


Link to post
Share on other sites

G'day,

Well it's been over a year since the last unanswered post on this  topic.

I am trying to use  a IIC module ( that's soldered to  the back of an LCD) so that it can be controlled by I2C.

The libraries mention in the posts are two Arduino's plus an IAR. Have started to rewrite the Arduino where the last post error was fixed etc

But am before I spend more time, has anyone  successfully used Energia to drive a I2C LCD.

Grant

Share this post


Link to post
Share on other sites

Yosh,

Am using a I2C to LCD port convertor (uses a PCF8574 chip) that is soldered to the 16 pins on a 1602 LCD. 

Am sure others have used this setup as one can buy the two components.

http://www.aliexpress.com/item/5pcs-lot-1602-2004-LCD-Adapter-Plate-IIC-I2C-Interface-Free-Shipping-Dropshipping/1122976396.html

and

http://www.aliexpress.com/item/IIC-I2C-1602-Serial-Blue-Backlight-LCD-Display-For-Arduino-2560-UNO-AVR-A004-Free-Shipping/690912591.html

 

All I need is a Energia library to drive this system.

Grant

Share this post


Link to post
Share on other sites

Have an arduino lib that I have started converting for Launchpad, but thought I maybe expending effort as it had been done already.

Seems not, so will spend a bit more time and do the conversion.

Share this post


Link to post
Share on other sites

Have an arduino lib that I have started converting for Launchpad, but thought I maybe expending effort as it had been done already.

Seems not, so will spend a bit more time and do the conversion.

 Have you had any luck? I am a new to MPS430 and micro controllers in general. I am trying to get a YwRobot 16X2 to work with my launch pad. I get the same error mentioned in a earlier post "conflicting return type specified for 'virtual void LiquidCrystal_I2C::write(uint8_t)'" I understand this because the libary is for and older Arduino IDE.  any help would be nice Thanks

Share this post


Link to post
Share on other sites

Yosh,

Am using a I2C to LCD port convertor (uses a PCF8574 chip) that is soldered to the 16 pins on a 1602 LCD. 

Am sure others have used this setup as one can buy the two components.

http://www.aliexpress.com/item/5pcs-lot-1602-2004-LCD-Adapter-Plate-IIC-I2C-Interface-Free-Shipping-Dropshipping/1122976396.html

and

http://www.aliexpress.com/item/IIC-I2C-1602-Serial-Blue-Backlight-LCD-Display-For-Arduino-2560-UNO-AVR-A004-Free-Shipping/690912591.html

 

All I need is a Energia library to drive this system.

Grant

 

Most of those screens and attached controllers are designed for Arduino, with 5V.

 

The LaunchPads operate at 3.3V. 

 

You need to insert a logic level converter to ensure signals are high enough for the screen and low enough for the MCU

Share this post


Link to post
Share on other sites

Roger,
Fixed my problem by adding a Wire,write() 
 
e.g. 
 .......
   Wire.beginTransmission(address);
   Wire.write(1);  ///////////////////////////////////// sketch works ok when this line added
   error = Wire.endTransmission();

.........

 

Have a look at my other post for details

http://forum.43oh.com/topic/5473-i2c-scanner-for-2553-5529/

 

And as Rio suggested I used two 2N7000 fets and a few resistor for the 3v3 to 5V interface.

Grant

Share this post


Link to post
Share on other sites

Hi abecedarian,

 

can you upload your source code of library??

 

I have the same error:

 

C:\Users\...\Energia\libraries\LiquidCrystal_I2C_Prueba/LiquidCrystal_I2C.h:80:16: error: conflicting return type specified for 'virtual void LiquidCrystal_I2C::write(uint8_t)'
C:\energia-0101E0012\hardware\msp430\cores\msp430/Print.h:55:20: error:   overriding 'virtual size_t Print::write(uint8_t)'

 

Thanks!!

Share this post


Link to post
Share on other sites

I recently bought a 20x4 LCD with I2C backpack and got it working. I've posted a working library (taken from DFRobot.com) and an example. While I've only used it with the 20x4 LCD it should also work with a 16x2. It has been tested on the MSP430F5529, MSP432P401R, and CC3200. These LCDs need 5V to work and you will need bi-directional logic level conversion. I've posted two circuits that work - one using two BS170 MOSFETs and another with a converter module I bought from Addicore. You can find it here on github.

 

EDIT: I recently tried this library with a 16 x 2 LCD and it works with that also. You will need to change the variables that hold screen size where indicated in the example.

Share this post


Link to post
Share on other sites

I succeed  interfacing a 16x2 LCD with a 430G2553 trough a PCF8574A port expansor as I2C/parallel  converter using the DFRobot.com library posted by Fmilburn, after solving the Energia 18 known issue with the 2553 I2C pin association described here

To do this, it iwas necessary to copy the files twi.c and twi_sw.c  in the folder hardware/msp430/cores/msp430 in the Energia installation and, in addition to that, to edit the .cpp file in the library to add the line "Wire.setModule(0);" just before "Wire.begin(0);".

Two additional comments that could be usefull for those that could want to use the same configuration:

1) Pay attention to the chip used in the I2C backpack: Most of the code examples use the address 0x20, that is the default for the to PCF8574 (unless you had been playing with the A0, A1 and A2 pins) but today it is pretty usual to find the version PCF8574A where the default address is 0x38.

2) Most LCDs work with 5V, but the PCF8574 works fine with any voltage in the range 2.5 - 6 V. So, you have two alternatives to wire the LCD to the 2553 without using the space-consuming level converters:

- Connect the backpack to 3.3 V using an additional wire to feed the LCD with 5V, or

- Connect the LCD and the backpack to 5V, but removing the pull up resistors from the SCA and SCL lines on the backpack board and placing them on the pins 14 and 15 of the G2553 (to 3.3V, obviously).

BTW, you should also consider this last solution if you plan to connect more than one display (or other devices) to the I2C bus, to avoid the parallel of the individual pull up resistors.

JLV

Fmilburn, dubnet and chicken like this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now