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

SainSmart 16x2 (1602) LCD Keypad Shield on Netduino?


  • Please log in to reply
7 replies to this topic

#1 SteveE

SteveE

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationMidwest

Posted 11 August 2012 - 01:07 AM

Is there an existing C# class for quickly and easily outputting to this display? Or will I have to convert an Arduino lib?

Reading the buttons seems simple as they are just along outputs.

Product Found at:
  • SainSmart: SainSmart 1602 LCD Keypad Shield for Arduino Duemilanove UNO MEGA2560 MEGA1280
  • DFRobot: Arduino LCD KeyPad Shield (DFR0009)
  • Amazon: SainSmart LCD Keypad Shield for Arduino UNO MEGA Duemilanove (B006OVYI1G)
  • EBay: Everywhere
Photo Attached

Thanks for your help.

Steve

Attached Files

  • Attached File  3.png   272.43KB   78 downloads


#2 Coyttl

Coyttl

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts
  • LocationSilver Spring, MD, USA

Posted 11 August 2012 - 02:09 AM

Looks like it uses SPI to accept commands. (Documentation on the device is rather.. lacking!) However, I wasn't able to find what commands there are. (It uses the standard Arduino LiquicCrystal.h library, tho..)

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 August 2012 - 09:33 AM

Stefan -- will your LCD code work for this display? I believe I've seen it used with either your Netduino library or Fabien's library before :) Chris

#4 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 11 August 2012 - 10:51 AM

Stefan -- will your LCD code work for this display? I believe I've seen it used with either your Netduino library or Fabien's library before :)

It should, with the Hd44780Lcd class.

From the schematic I downloaded, I see:
Netduino pin D4 -> LCD pin DB4 (Data bit 4)
Netduino pin D5 -> LCD pin DB5 (Data bit 5)
Netduino pin D6 -> LCD pin DB6 (Data bit 6)
Netduino pin D7 -> LCD pin DB7 (Data bit 7)
Netduino pin D8 -> LCD pin RS (Register Select)
Netduino pin D9 -> LCD pin E (Enable)

So the constructor would be:
Hd44780Lcd Display = new Hd44780Lcd(
    Data4: Pins.GPIO_PIN_D4,
    Data5: Pins.GPIO_PIN_D5,
    Data6: Pins.GPIO_PIN_D6,
    Data7: Pins.GPIO_PIN_D7,
    RegisterSelectPin: Pins.GPIO_PIN_D8,
    ClockEnablePin: Pins.GPIO_PIN_D9
);

The keys are a bit of a problem though. They're connected to an analog pin from 5V, so I can't guarantee any working of them.
I have a DFRobot LCD Shield on my desk with the same issue. I've put it aside for that reason. If needed, I could do some testing with that one, but I'm short in time currently.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#5 SteveE

SteveE

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationMidwest

Posted 14 August 2012 - 07:01 AM

It should, with the Hd44780Lcd class.

From the schematic I downloaded, I see:
Netduino pin D4 -> LCD pin DB4 (Data bit 4)
Netduino pin D5 -> LCD pin DB5 (Data bit 5)
Netduino pin D6 -> LCD pin DB6 (Data bit 6)
Netduino pin D7 -> LCD pin DB7 (Data bit 7)
Netduino pin D8 -> LCD pin RS (Register Select)
Netduino pin D9 -> LCD pin E (Enable)

So the constructor would be:

Hd44780Lcd Display = new Hd44780Lcd(
    Data4: Pins.GPIO_PIN_D4,
    Data5: Pins.GPIO_PIN_D5,
    Data6: Pins.GPIO_PIN_D6,
    Data7: Pins.GPIO_PIN_D7,
    RegisterSelectPin: Pins.GPIO_PIN_D8,
    ClockEnablePin: Pins.GPIO_PIN_D9
);
The keys are a bit of a problem though. They're connected to an analog pin from 5V, so I can't guarantee any working of them.
I have a DFRobot LCD Shield on my desk with the same issue. I've put it aside for that reason. If needed, I could do some testing with that one, but I'm short in time currently.


The output seems to work fine.

Onto messing with the buttons and then I will look into this SPI layer that appears to be on the board as well.

My next project will be to look into this panel panel I got years ago, "Spyglass Control Panel", with 8 buttons. Seems to be I2C.
http://www.procyonen...lass/index.html

Thanks for your help.

#6 AndWHUN

AndWHUN

    New Member

  • Members
  • Pip
  • 1 posts

Posted 25 November 2012 - 07:11 AM

Hello. I am new to Netduino and C# I am currently attempting to learn how to implement what I have read in this thread on a Netduino GO with a shield base. I guess I could be having a list of issues being a noob however I have managed to map the constructor to the base shield pins. I guess I'm just wondering which parts of the Micro Toolbox I need to implement to get the constructor and the HD44780Lcd code running off the GO. I noticed that the sample code for the HD44780Lcd seemed to involve the 4.1 framework can this be switched to 4.2 and used? Or do I seem completely confused and need to read more. I have updated the firmwares of both the Go and the shield base to current versions. I have also what I think are the latest SDK's and the newest 4.2 framework. I can make a button blink a light but I may be biting off too much for the moment :). Thanks.

#7 Strut

Strut

    Member

  • Members
  • PipPip
  • 18 posts

Posted 06 January 2013 - 03:21 PM

Hi all,

 

I just wanted to note that I was able to get this LCD working with both the toolbox code suggested above and with the ?LiquidCrystal library http://microliquidcr...l.codeplex.com/. The former has support for shift registers, scrolling text, and special characters.

 

I had to rebuild the ?LiquidCrystal source for the 4.2 framework to get working. I still have intermittent problems with the screen initializing both lines of the LCD and sometimes it appears to want to go into 8bit mode corrupting the text, but it generally works after a reset or two.

 

PS - Although the LCD is capable of 8bit addressing the shield isn't wired up for it. Hope this saves someone the time that I wasted troubleshooting the library. 

 

Edit for some code

 

var LcdProvidor = new GpioLcdTransferProvider(                Pins.GPIO_PIN_D8,                Pins.GPIO_PIN_D9,                Pins.GPIO_PIN_D4,                Pins.GPIO_PIN_D5,                Pins.GPIO_PIN_D6,                Pins.GPIO_PIN_D7            );            //Debug.Print(LcdProvidor.FourBitMode.ToString());            var lcd = new Lcd(LcdProvidor);            lcd.Begin(16, 2);            //Creating custom characters (Smiley face and gimp)            byte[] buffer = new byte[] {    0x07, 0x08, 0x10, 0x10, 0x13, 0x13, 0x10, 0x10,                                            0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04,                                            0x1C, 0x02, 0x01, 0x01, 0x19, 0x19, 0x01, 0x01,                                            0x10, 0x10, 0x12, 0x11, 0x10, 0x10, 0x08, 0x07,                                            0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x1F,                                            0x01, 0x01, 0x09, 0x11, 0x01, 0x01, 0x02, 0x1C,                                            0x15, 0x15, 0x0E, 0x04, 0x04, 0x0A, 0x11, 0x11,                                            0x04, 0x04, 0x0E, 0x15, 0x04, 0x0A, 0x11, 0x11                                       };            // Load custom characters to display CGRAM            for (int i = 0; i < 8; i++)            {                lcd.CreateChar(i, buffer, i * 8);            }            while (true)            {                lcd.Clear();                // Print the special characters with the face                lcd.Write(new byte[] { 0x00, 0x01, 0x02 }, 0, 3);                lcd.Write(" .NET Micro");                // Move to second line                lcd.SetCursorPosition(0, 1);                // Print the special characters with the face                lcd.Write(new byte[] { 0x03, 0x04, 0x05 }, 0, 3);                lcd.Write("  Framework");                Thread.Sleep(5000);                lcd.Clear();                const string message = "Netduino Plus 2!";                // Let gimp write the message                for (int i = 0; i < message.Length; i++)                {                    lcd.SetCursorPosition(i, 1);                    lcd.WriteByte((byte)(((i % 2) == 0) ? 0x06 : 0x07));                    lcd.SetCursorPosition(i, 0);                    lcd.Write(message[i].ToString());                    Thread.Sleep(200);                    lcd.SetCursorPosition(i, 1);                    lcd.Write(" ");                }                Thread.Sleep(5000);                lcd.Clear();                lcd.SetCursorPosition(16, 0);                lcd.Write("www.netduino.com");                lcd.SetCursorPosition(16, 1);                lcd.Write("www.netduino.com");                for (int i = 0; i < 40; i++)                {                    lcd.ScrollDisplayLeft();                    Thread.Sleep(400);                }                            }


#8 ByteMaster

ByteMaster

    Advanced Member

  • Members
  • PipPipPip
  • 76 posts

Posted 12 March 2013 - 01:04 PM

It should, with the Hd44780Lcd class.

 

Since the Netduino Plus 2 is so blazingly fast, if you attempt to use this class as-is it will won't work.

 

What you will need to do is hold the clock enable pin high just a little longer rather than just toggling it as was done in the original driver.

 

This happens around line 366 in the _Write4Bits method of Hd44780Lcd.cs.

 

private void _Write4Bits(byte Byte){  	.......	// Enables the pin for a moment        this._CePin.Write(true);        for (var idx = 0; idx < 1000; ++idx) ;                    this._CePin.Write(false);

?

?

?

?

?

?

I haven't experimented too much with the exact number of iterations necessary but 1000 seemed to do the trick.

 

To deploy this you can either update the source code in the tool box and recompile, or just include the file Hd4470Lcd.cs into your project and make the change there.  Either way you'll need to include references for "Toolbox.NETMF.Core" and "Toolbox.NETMF.Hardware.Core" to your project.

 

-twb


Kevin D. Wolf
Windows Phone Development MVP
President Software Logistics, LLC
Tampa, FL




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.