Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

I2C LCD with Netduino 3


  • Please log in to reply
7 replies to this topic

#1 blindahl

blindahl

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationSedro-Woolley, WA

Posted 20 May 2015 - 08:52 PM

Has anyone had any luck using the Adafruit 16x2 I2C shields? I'm using one of these:

 

http://www.adafruit.com/products/772

 

along with the code from this post. I get the default "boxes" displayed on the lcd, so at least something is happening... but I don't get any backlight or other response from the display.

 

my code is something like:

lcd = new LiquidCrystal_I2C(0x20, 16, 2);
lcd.backlight();
write(bytes);

Any thoughts on what to try?

 

brian



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 21 May 2015 - 12:43 AM

Hi brian,

Does the shield have SDA/SCL pins to connect into your Netduino 3?

The older-style Arduino shields used pins A4/A5 for I2C whereas the newer-style Arduino shields (with the extra pins) use pins SDA/SCL for I2C.

Also: are the drivers you're using meant for this shield/LCD controller? Any configuration issues (such as I2C address or pull-up resistor strength) that could be different on the shield?

Chris

#3 blindahl

blindahl

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationSedro-Woolley, WA

Posted 21 May 2015 - 06:58 PM

Chris - thanks for the reply. Note that I'm a complete noob to the Netduino, although I do have 10+ years in c#.

 

it looks like the shield might handle both. per adafruit page: "It uses the I2C pins at Analog 4 and Analog 5. It will also work perfectly with Arduino Mega R3's which have the extra SDA/SCL I2C pins broken out." hrm - looking at the pcb layout, it's got 4/5 tied to sda/scl, so it should be working with either pins.

 

As for the driver, I compared the code I linked to (which is using the mf toolbox's MCP23017 driver, which is the same i2c chip as my shield) with what I had previously manually ported from the Adafruit arduino code, and it looked the same.

 

pull-up resistors are built into the shield. they're different than the values that were mentioned in AxelG's post (4.7K where he ended up with 1.8K). as they're mounted under the LCD backplane, they'll be loads of fun to change... maybe i can put another resistor in parallel, which IIRC from electronics class 30+ years ago will end up with the pullup ohms being the average of the two?

 

brian



#4 dhensel

dhensel

    New Member

  • Members
  • Pip
  • 7 posts
  • LocationBoston, MA

Posted 22 May 2015 - 07:50 PM

I get the default "boxes" displayed on the lcd, so at least something is happening... but I don't get any backlight or other response from the display.

 

 

Not to sound disrespectful, but have you tried adjusting the contrast pot?  Mine was all the way down originally and I saw the same "boxes".  On my N2 I've had good a good, straightforward experience using that LCD shield (actually the RGB version) from Adafruit, and I've been using the NETMF Toolbox "Hd44780Lcd" class



#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 23 May 2015 - 02:00 AM

Hi brian,

One more thing:
If pins A4/A5 and SDA/SCL are tied together on the shield... Make sure that you're not using pins A4/A5 anywhere in your code. Otherwise you could potentially create a conflict (sending or pulling power/signal on/from pins A4/A5...would conflict with pins SDA/SCL in this case since they're physically wired together).

One safe way to know that the pins aren't being used is to do Port.ReservePin at the top of your code (which would throw an exception if your code then tried to open the pin again) or to open them up as InputPorts with the PullResistor value set to Disabled (which would put the A4/A5 pins in a safe read state in this instance). If you do this, just be sure to do it in a way that your Port doesn't go out of scope...or NETMF will GC it and this will have only temporary effect.

Chris

#6 blindahl

blindahl

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationSedro-Woolley, WA

Posted 25 May 2015 - 01:51 AM

@chris - thanks for the reminder. i'll make sure to do that in my actual app.

 

@dhensel - yes, I tried that. I can't get any response out of the LCD at all aside from the boxes when it's all the way turned one direction. My code is:

 

            Mcp23017 i2c = new Mcp23017(0x20);
            IParallelOut i2cParallel = i2c.CreateParallelOut(0, 4);
            Hd44780Lcd( lcd = new Hd44780Lcd(i2cParallel, (Cpu.Pin)13, (Cpu.Pin)15, (Cpu.Pin)14);
            i2c.Pins[8].Write(true);
            i2c.Pins[7].Write(true);
            i2c.Pins[6].Write(true);
            lcd.Write("Hello");
 

the only things that seem to be adjustable are the i2c address (adafruit docs say 0x20) and the CPU pins... I got the pin values from the adafruit library:

 

  _rs_pin = 15;
  _rw_pin = 14;
  _enable_pin = 13;
 

also, the pin.writes _should_ turn on the backlight, if I'm reading the adafruit code correctly (and understanding the arduino/netduino differences):

 

// Allows to set the backlight, if the LCD backpack is used
void Adafruit_RGBLCDShield::setBacklight(uint8_t status) {
  // check if i2c or SPI
  _i2c.digitalWrite(8, ~(status >> 2) & 0x1);
  _i2c.digitalWrite(7, ~(status >> 1) & 0x1);
  _i2c.digitalWrite(6, ~status & 0x1);
}
 

and just to be sure, I went through and re-soldered everything on the shield - it's been a long time since I soldered anything that complex. Had my father's instructions about cold solder joints and solder bridges running through my head for the first time in 35 years... :)

 

Any suggestions?

 

brian



#7 dhensel

dhensel

    New Member

  • Members
  • Pip
  • 7 posts
  • LocationBoston, MA

Posted 26 May 2015 - 03:04 PM

This is the snippet from the NETMF sample that I used in my program.  It's for the RGB, but I think the Adafruit hardware implementation is the same for both?  There are a bunch of examples in "Documents\NETMF Toolbox Samples" and should run standalone which I've used to test out my components when I first got them, and later when things went awry.  Have you tried running any of the samples?

// The Adafruit LCD Shield uses a MCP23017 IC as multiplex chip
Mcp23017 Mux = new Mcp23017();

// Pins 0 to 4 on the Mux-chip are connected to the buttons
IGPIPort ButtonSelect = Mux.Pins[0];
IGPIPort ButtonRight = Mux.Pins[1];
IGPIPort ButtonDown = Mux.Pins[2];
IGPIPort ButtonUp = Mux.Pins[3];
IGPIPort ButtonLeft = Mux.Pins[4];
// Enables pull-ups for all the buttons
for (int i = 0; i < 5; ++i)
{
    Mux.EnablePullup(i, true);
    Mux.Pins[i].InvertReadings = true;
}

// Pins 6 to 8 on the Mux-chip are for the backlight
IGPOPort Red = Mux.Pins[6];    // Red backlight
IGPOPort Green = Mux.Pins[7];  // Green backlight
IGPOPort Blue = Mux.Pins[8];   // Blue backlight

// Pins 9 to 15 are connected to the HD44780 LCD
Hd44780Lcd Display = new Hd44780Lcd(
    Data: Mux.CreateParallelOut(9, 4),
    ClockEnablePin: Mux.Pins[13],
    ReadWritePin: Mux.Pins[14],
    RegisterSelectPin: Mux.Pins[15]
);


#8 blindahl

blindahl

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationSedro-Woolley, WA

Posted 27 May 2015 - 02:04 PM

yes, i tried the sample as well. i can see button state, so it looks like the shield is functional, but I get no response whatsoever from the LCD itself. I've only seen the backlight on once, and it was when i'd just switched assemblies to test something else. I'm thinking that I probably have a defective board. Thanks to everyone for the help.

 

brian






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.