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

LCD AdaFruit Backpack


  • Please log in to reply
26 replies to this topic

#1 Jerfy

Jerfy

    Member

  • Members
  • PipPip
  • 14 posts

Posted 06 January 2012 - 12:55 PM

Greetings, I am trying to drive an LCD that is connected to an Adafruit i2c/SPI Backpack. http://www.adafruit.com/products/292 Does anyone know whats the correct wiring to drive the backpack? And second anyone have a code example on interfacing with the LCD through SPI? Thank you, Jeff

#2 Jerfy

Jerfy

    Member

  • Members
  • PipPip
  • 14 posts

Posted 07 January 2012 - 03:28 AM

Greetings,

I am trying to drive an LCD that is connected to an Adafruit i2c/SPI Backpack. http://www.adafruit.com/products/292

Does anyone know whats the correct wiring to drive the backpack? And second anyone have a code example on interfacing with the LCD through SPI?

Thank you,
Jeff


So here is what I was able to get working, using the http://www.adafruit.com/products/292
Here is the info on the backpack: http://www.ladyada.n...onnect_with_i2c

I am not using SPI instead its using I2C, which means there is no connection on the backpack where it says SPI.
I am using this library: http://microliquidcr...l.codeplex.com/

Code:

using System;

using FusionWare.SPOT.Hardware;

using MicroLiquidCrystal;

namespace LCDTestApplication
{
    public class Program
    {
        public static void Main()
        {
            var bus = new I2CBus();
            var lcdProvider = new MCP23008LcdTransferProvider(bus, 0x0, MCP23008LcdTransferProvider.DefaultSetup);
            var lcd = new Lcd(lcdProvider);

            lcd.Begin(20, 4);
            lcd.Clear();
            lcd.Backlight = true;

            lcd.SetCursorPosition(0, 0);
            lcd.Write("Testing 1234");
        }
    }
}

Attached Files



#3 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 21 January 2012 - 04:55 PM

Have you played with any custom Characters? I'm using the same exact setup and cannot seem to get any custom characters to display right. All I want is a simple degree symbol for temperature but it shows up garbled.

#4 Jerfy

Jerfy

    Member

  • Members
  • PipPip
  • 14 posts

Posted 22 January 2012 - 03:22 AM

Have you played with any custom Characters? I'm using the same exact setup and cannot seem to get any custom characters to display right. All I want is a simple degree symbol for temperature but it shows up garbled.


You know I haven't messed with custom characters yet. Actually I found this example much better than using the daughter board.

http://highfieldtale...e-for-netduino/

#5 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 22 January 2012 - 04:22 AM

You know I haven't messed with custom characters yet. Actually I found this example much better than using the daughter board.

http://highfieldtale...e-for-netduino/


I am definitely going to check that out. I am having some issues with the LCD glitching and I am sure its a speed issue. Thanks for the info!

#6 Ernie

Ernie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 07 March 2013 - 12:31 AM

Using Netduino Plus 2

 

I have the Adafruit 20x4 LCD http://www.adafruit.com/products/198 and the i2c backpack http://www.adafruit.com/products/292 using i2 code posted by Tim C http://forums.netdui...erface/?p=43936  I keep getting a garbled display after about 3-4 minutes.  Have seen posts about using a pullup though nothing definitive.  What is the fix for this? 



#7 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 07 March 2013 - 11:57 AM

Pull-ups are always necessary with I2C however the Backpack has them built in I believe.  Going with SPI mode on the backpack is one possible fix for it.  I2C is slower than SPI and does glitch from time to time.  There are also other possible causes at work.  With these backpacks the LCD is used in 4bit mode instead of 8bit mode.  So it sends the 8bits in two 4bit packs.  I've noticed scenarios where the display goes back into 8 bit mode which is set to 4bit during the initialization.  This could be due to power changes or simply bad connections.  Another scenario is that on of the 4bit packets is dropped causing it to begin glitching.  This could be due to lose connections.

 

Other things to check... be sure you don't exceed 400kHz for the Clock_Speed in either I2C or SPI mode.  These backpacks and displays seem to work best between 400-600kHz.

 

The MicroLiquidCrystal library is the same library I am using however I've had to make some changes both on the I2C and SPI code to get it to work correctly.  I don't believe the creator has done much work enhancing the library or fixing any possible issues.  If you are still having issues feel free to post up the repro code and we can take a look.  Members like myself, Tim, Stefan, Mario and Guiliano have been playing quite a bit with the LCDs and backpacks and can certainly help.



#8 Ernie

Ernie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 08 March 2013 - 01:20 AM

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]"be sure you don't exceed 400kHz for the Clock_Speed in either I2C or SPI mode.  These backpacks and displays seem to work best between 400-600kHz"  What?  [/color]Don't exceed 400kHz but they work best between 400-600kHz!!  Also what resistance on the pull-ups and what voltage?



#9 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 08 March 2013 - 01:31 AM

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]"be sure you don't exceed 400kHz for the Clock_Speed in either I2C or SPI mode.  These backpacks and displays seem to work best between 400-600kHz"  What?  [/color]Don't exceed 400kHz but they work best between 400-600kHz!!  Also what resistance on the pull-ups and what voltage?

 

In otherwords don't exceed 400khz if you want it to work.  600khz will work but will likely glitch after some time.

 

Pulls up depend on the other circuitry involved.  There is no set standard.  You would need to calculate it out, but as I said, the Adafruit backpack has them built in so you don't need them.



#10 Ernie

Ernie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 08 March 2013 - 03:15 AM

So it was defaulting to 100kHz.  I tried 400kHz worked longer!  Tried 350kHz and 200kHz.  In the end the result is the same. After varying minutes, based on different clock rates, the garbled display return.  Based on the products I references does ANYBODY know how to make these displays work reliably???



#11 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 08 March 2013 - 03:41 AM

I have several ND+2 with the same backpack (set for I2C) and the same LCD screen using the microliquidcrystal library that run without glitching.  In fact I just powered one off to take with me tomorrow.  It's been running a week or more without any glitches and the screen updates twice every second.  They work very well and I cannot remember the last time any one of them glitched.  As I said, it may be something with your code or your wiring.  Loose or bad connections can certainly cause this to occur.  Also sending too many commands to the LCD too fast can also cause this.

 

EDIT:

 

Last night before I went to sleep I setup a Netduino Plus 2 with the Adafruit LCD Backpack and a 4x20 LCD.  I reset the clock on the Netduino so it would start from zero and show the amount of time the unit ran.  You can see it has been running for 8 hours 31 minutes without a glitch.  This is set for 400kHz clock.

 

Posted Image


Edited by Dave VanderWekke, 08 March 2013 - 12:22 PM.


#12 Ernie

Ernie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 08 March 2013 - 11:09 PM

Out of ideas! Wiring is correct.  Code is code posted by Tim C.  How about posting your code Dave???



#13 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 09 March 2013 - 12:08 PM

I won't be back home near my PC until Sunday. Will post up a repro project then.

#14 tim c

tim c

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 09 March 2013 - 04:25 PM

I am running the code I posted using my N2+ (upgraded to MF 4.3) and it is working without display corruption  for 10 minutes with 4 tests  - 2 at 100Mhz and then the same 2 at 400Mhz:

 

 

1)

 

        public static void Main()        {            _bus = new I2CBus();            initializeLCD(_bus);            NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];            TimeSpan ts;            DateTime startedDate = DateTime.Now;            short i = 1;            while (true)            {                ts = DateTime.Now.Subtract(startedDate);                String s = "Days: " + ts.ToString();                Debug.Print(s);                LCD.Print(Lcd.Position.ROW_1, Lcd.Position.COLUMN_1, Lcd.FillRow("abcdefghijklmnopqrst"));                LCD.Print(Lcd.Position.ROW_2, Lcd.Position.COLUMN_1, Lcd.FillRow("01234567890123456789"));                LCD.Print(Lcd.Position.ROW_3, Lcd.Position.COLUMN_1, Lcd.FillRow("ABCDEFGHIJKLMNOPQRST"));                LCD.Print(Lcd.Position.ROW_4, Lcd.Position.COLUMN_1, Lcd.FillRow("01234567890123456789"));                switch (i)                {                    case 1:                        LCD.Print(Lcd.Position.ROW_1, Lcd.Position.COLUMN_1, Lcd.FillRow(s));                        i++;                        break;                    case 2:                        LCD.Print(Lcd.Position.ROW_2, Lcd.Position.COLUMN_1, Lcd.FillRow(s));                        i++;                        break;                    case 3:                        LCD.Print(Lcd.Position.ROW_3, Lcd.Position.COLUMN_1, Lcd.FillRow(s));                        i++;                        break;                    case 4:                        LCD.Print(Lcd.Position.ROW_4, Lcd.Position.COLUMN_1, Lcd.FillRow(s));                        i = 1;                        break;                }                Thread.Sleep(5000);            }        }

 

2)

 

 

        public static void Main()        {            _bus = new I2CBus();            initializeLCD(_bus);            NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];            TimeSpan ts;            DateTime startedDate = DateTime.Now;            LCD.Print(Lcd.Position.ROW_1, Lcd.Position.COLUMN_1, Lcd.FillRow("abcdefghijklmnopqrst"));            LCD.Print(Lcd.Position.ROW_2, Lcd.Position.COLUMN_1, Lcd.FillRow("01234567890123456789"));            LCD.Print(Lcd.Position.ROW_3, Lcd.Position.COLUMN_1, Lcd.FillRow("ABCDEFGHIJKLMNOPQRST"));            LCD.Print(Lcd.Position.ROW_4, Lcd.Position.COLUMN_1, Lcd.FillRow("01234567890123456789"));            while (true)            {                ts = DateTime.Now.Subtract(startedDate);                String s = "Days: " + ts.ToString();                Debug.Print(s);                LCD.Print(Lcd.Position.ROW_4, Lcd.Position.COLUMN_1, Lcd.FillRow(s));                Thread.Sleep(1000);            }        }

 

 

If you are sure the wiring and soldering is correct and good then maybe check the power? Do you have a Logic Analyzer to see what is on the I2C lines before and after the corruption? What firmware and .NETMF version are you using? There were some bugs with I2C in some firmware releases.

 

Can you post a code sample/project and the exact device and SDK/Firmware versions you are using?



#15 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 10 March 2013 - 12:36 PM

I just got back home from my trip. This morning walked into my office. LCD display is still running glitch free since March 7th at 11:41pm. It is now March 10th at 8:30am.

#16 Ernie

Ernie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 10 March 2013 - 06:25 PM

NP2 on firmware 4.2.2 SDK 4.2.2. Tim are you implying after 10 minutes you get corruption? No I do not have a logic analyzer.

#17 tim c

tim c

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 10 March 2013 - 07:44 PM

No, I only ran the tests for 10 minutes each and saw no corruption. I did leave the last test running and 11 hours later it was still working great.

 

Tim

 

NP2 on firmware 4.2.2 SDK 4.2.2. Tim are you implying after 10 minutes you get corruption? No I do not have a logic analyzer.



#18 Ernie

Ernie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 10 March 2013 - 10:54 PM

Are you using SC AND SD on NP2?  Is there any other way to connect?



#19 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 10 March 2013 - 11:27 PM

Are you using SC AND SD on NP2?  Is there any other way to connect?

 

If you are using ND+2 you can only use SC and SD for I2C.  It is no longer A4/A5. They are working on Firmware that will allow either for Shield Compatibility but for now only SC and SD work.



#20 Ernie

Ernie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 10 March 2013 - 11:46 PM

I noticed Dave has practically no text. Check out page 15 of this document http://www.picaxe.com/docs/axe033.pdf it implies text is the problem, which I had data descriptions preceeding all of my measurements.  My display was specifying data like this:

 

[font="arial, helvetica, sans-serif;"]Air Temp: 66.89[/font]

[font="arial, helvetica, sans-serif;"]Water Temp: 72.38[/font]

[font="arial, helvetica, sans-serif;"]PH: 7.00[/font]

[font="arial, helvetica, sans-serif;"]Flow Rate: 0.62LPM[/font]

 

[font="arial, helvetica, sans-serif;"]I took out the text and I am testing right now to see if that makes a difference.[/font]






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.