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


  • Please log in to reply
11 replies to this topic

#1 Peter Forstmeier

Peter Forstmeier

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 03 November 2013 - 07:02 PM

Hi List,

i get this LCD:

 

http://club.dx.com/reviews/text/118059

 

and wirte them with these layout:

 

http://netmftoolbox....ailable classes

 

I connect the NetDuino  directly to the LCD, omiting the breadboard,

 

So:

GND    -> Pin1(LCD)

3V   -> Pin 2 (LCD)

empty ->PIN3

Pin8   -> Pin4

empty  -> Pin 5

empty  -> Pin 16

 

the rest is done as on the drawing.

 

I use the classes here and the code runs just fine, but LCD is dark.

 

Any idea whot wrong with the wiring?

 

Thanks in advance

Peter

 



#2 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 03 November 2013 - 09:43 PM

Pin 15 and 16 are needed for the back light and might need 5v's depending on the display type.

 

Grant



#3 Peter Forstmeier

Peter Forstmeier

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 04 November 2013 - 06:38 PM

Hi Grant,

thanks for the answer. I will try it during the week (very very busy). Will be back to you.

 

Thanks once more

Peter



#4 Peter Forstmeier

Peter Forstmeier

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 07 November 2013 - 07:26 PM

Hi,

i think i'm definitly to stupid.

I connect Pin's 15 and 16.

Try 3 + 5 V

There is no Display of Text at all.

 

If i stack the Display  directly on top of my N2+ there is backlight and some Blocks in row 2.

 

Peter



#5 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 08 November 2013 - 12:00 AM

I used that framework on the original Netduino with great success but have not been able to get it to work with the Netduino 2's. Try following this example from Embedded Lab. I recommend following the instructions there, or at least reading them and downloading the code. 

I've made some minor modifications to this code and now use it for all of my projects. I believe it is probably an inferior way of doing it compared to Stefan's but it is extremely easy to get going and very reliable.

 

Grant.



#6 Peter Forstmeier

Peter Forstmeier

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 08 November 2013 - 07:00 AM

Hi and good morning (from Germany),

I will try this link.

 

By the way, is it ok to have

2 times 3 V at Pin 2 and 15

3 times Ground Pin 1 - 5  -16

Pin 3 is Empty

i didn't use the Restistor at the breadboard because my breadboard

 

Peter



#7 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 10 November 2013 - 05:59 AM

I might be able to help more if you provide the data sheet for the display that you've got. Some require 3 or 5v logic. Some can do both. I'm working on a graphics lcd at the moment that I need to step up from 3.3 to 5v. Adds another dimension to it.

Please post some sort of data sheet and as much other info as possible.

 

From what i can see there you definitely need pin 3 connected though. If you don't have a trim pot just experiment with different resistors. start with about 5k i rekon.

 

Grant



#8 Peter Forstmeier

Peter Forstmeier

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 10 November 2013 - 09:32 PM

Hi,

i would like to use these Display:

 

http://www.exp-tech....pad-Shield.html

 

 

on the Product page you can find links to the datasheet and schematics

 

I have another other one in stock:

 

http://www.exp-tech....-Backlight.html

but have not  tried it yet.

 

Peter



#9 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 12 November 2013 - 07:24 AM

<iframe src="https://skydrive.liv...ADIaSTd8kXfcHMU" width="274" height="319" frameborder="0" scrolling="no"></iframe>

 

copy this where vdd is 5v.

 

then run this code.

 

LCD.cs

/*-------------------------------------------------------------------------------+|| Copyright (c) 2012, Embedded-Lab. All Rights Reserved.|| Limited permission is hereby granted to reproduce and modify this | copyrighted material provided that this notice is retained | in its entirety in any such reproduction or modification.|| Author: ANir| First Version Date: 2012/12/27+-------------------------------------------------------------------------------*/using System;using System.Threading;using Microsoft.SPOT.Hardware;using System.Text;namespace EmbeddedLab.NetduinoPlus.Day2.Display{    public class LCD    {        #region Constructor        public LCD(Cpu.Pin rs, Cpu.Pin enable,            Cpu.Pin d4, Cpu.Pin d5, Cpu.Pin d6, Cpu.Pin d7,            byte columns, Operational lineSize, int numberOfRows, Operational dotSize)        {            RS = new OutputPort(rs, false);            Enable = new OutputPort(enable, false);            D4 = new OutputPort(d4, false);            D5 = new OutputPort(d5, false);            D6 = new OutputPort(d6, false);            D7 = new OutputPort(d7, false);            Columns = columns;            DotSize = (byte)dotSize;            NumberOfLines = (byte)lineSize;            NumberOfRows = numberOfRows;            Initialize();        }        #endregion        #region Public Methods        public void Show(string text, int delay, bool newLine)        {            if (newLine) dirtyColumns = 0;            foreach (char textChar in text.ToCharArray())            {                ResetLines();                Show(Encoding.UTF8.GetBytes(textChar.ToString()));                dirtyColumns += 1;                Thread.Sleep(delay);            }        }        public void Show(string text)        {            string[] splitedText = SplitText(text);            Show(splitedText);        }        public void ClearDisplay()        {            SendCommand((byte)Command.Clear);            currentRow = 0;            dirtyColumns = 0;        }        public void GoHome()        {            SendCommand((byte)Command.Home);            currentRow = 0;            dirtyColumns = 0;        }        public void JumpAt(byte column, byte row)        {            if (NumberOfLines == (byte)Operational.DoubleLIne) row = (byte)(row % 4);            else row = (byte)(row % 2);            SendCommand((byte)((byte)Command.SetDdRam | (byte)(column + rowAddress[row]))); //0 based index        }        public void PushContentToLeft()        {            SendCommand(0x18 | 0x00);        }        public void PushContentToRight()        {            SendCommand(0x18 | 0x04);        }        #endregion        #region Private Methods        private void Initialize()        {            //initialize fields            isVisible = true;            showCursor = false;            isBlinking = false;            rowAddress = new byte[] { 0x00, 0x40, 0x14, 0x54 };            firstHalfAddress = new byte[] { 0x10, 0x20, 0x40, 0x80 };            secondHalfAddress = new byte[] { 0x01, 0x02, 0x04, 0x08 };            currentRow = 0;            dirtyColumns = 0;            Thread.Sleep(50); // must wait for a few milliseconds            // RS to high = data transfer            // RS to low = command/instruction transfer            RS.Write(false);            // Enable provides a clock function to synchronize data transfer            Enable.Write(false);            // Set for 4 bit model            Write(0x03, secondHalfAddress);            Thread.Sleep(4);            Write(0x03, secondHalfAddress);            Thread.Sleep(4);            Write(0x03, secondHalfAddress);            Thread.Sleep(150);            Write(0x02, secondHalfAddress);            // Set the LCD properties             byte operationalValue = (byte)((byte)Operational.FourBit | (byte)NumberOfLines | (byte)DotSize);            SendCommand((byte)((byte)Command.Operational | operationalValue));            UpdateDisplayOptions();            ClearDisplay();            byte entranceValue = (byte)Entrance.FromLeft | (byte)Entrance.ShiftDecrement;            SendCommand((byte)((byte)Command.Entrance | entranceValue));        }        private string[] SplitText(string str)        {            if (str.Length > Columns * NumberOfRows) str = str.Substring(0, Columns * NumberOfRows);            int stringArrayCounter = 0;            dirtyColumns = 0;            char[] charArray = str.ToCharArray();            int arraySize = (int)System.Math.Ceiling((double)(str.Length + dirtyColumns) / Columns);            string[] stringArray = new string[arraySize];            for (int i = 0; i < charArray.Length; i++)            {                if (dirtyColumns < Columns)                {                    stringArray[stringArrayCounter] = stringArray[stringArrayCounter] + charArray[i];                    dirtyColumns += 1;                }                else                {                    dirtyColumns = 1;                    stringArrayCounter += 1;                    stringArray[stringArrayCounter] = stringArray[stringArrayCounter] + charArray[i];                }            }            return stringArray;        }        private void ResetLines()        {            if (dirtyColumns == 0) return;            if (dirtyColumns % Columns == 0)            {                currentRow += 1;                JumpAt((byte)0, (byte)(currentRow));            }        }        private void Write(byte[] data)        {            foreach (byte value in data)            {                Write(value, firstHalfAddress); // First half                Write(value, secondHalfAddress); // Second half            }        }        private void Write(byte value, byte[] halfAddress)        {            D4.Write((value & halfAddress[0]) > 0);            D5.Write((value & halfAddress[1]) > 0);            D6.Write((value & halfAddress[2]) > 0);            D7.Write((value & halfAddress[3]) > 0);            Enable.Write(true);            Enable.Write(false);            //Debug.Print("Wrote " + value.ToString());        }        private void SendCommand(byte value)        {            RS.Write(false); // command/instruction transfer            Write(new byte[] { value });            Thread.Sleep(5);        }        private void UpdateDisplayOptions()        {            byte command = (byte)Command.DisplayControl;            command |= isVisible ? (byte)DisplayControl.ScreenOn : (byte)DisplayControl.ScreenOff;            command |= showCursor ? (byte)DisplayControl.CursorOn : (byte)DisplayControl.CursorOff;            command |= isBlinking ? (byte)DisplayControl.BlinkBoxOn : (byte)DisplayControl.BlinkBoxOff;            SendCommand(command);        }        private void Show(string[] splitedText)        {            foreach (string text in splitedText)            {                JumpAt((byte)0, (byte)(currentRow));                currentRow += 1;                Show(Encoding.UTF8.GetBytes(text));            }        }        private void Show(byte[] bytes)        {            RS.Write(true);            Write(bytes);        }        #endregion        #region Public Properties        public bool IsVisible        {            get { return isVisible; }            set { isVisible = value; UpdateDisplayOptions(); }        }        public bool IsBlinking        {            get { return isBlinking; }            set { isBlinking = value; UpdateDisplayOptions(); }        }        public bool ShowCursor        {            get { return showCursor; }            set { showCursor = value; UpdateDisplayOptions(); }        }        #endregion        #region Fields        private OutputPort RS;        private OutputPort Enable;        private OutputPort D4;        private OutputPort D5;        private OutputPort D6;        private OutputPort D7;        private byte Columns;        private byte DotSize;        private byte NumberOfLines;        private byte[] rowAddress;        private byte[] firstHalfAddress;        private byte[] secondHalfAddress;        private byte visibilityValue;        private int currentRow;        private int dirtyColumns;        private int NumberOfRows;        private bool isVisible;        private bool showCursor;        private bool isBlinking;        #endregion        #region Enums        public enum Command : byte        {            Clear = 0x01,            Home = 0x02,            Entrance = 0x04,            DisplayControl = 0x08,            Move = 0x10,            Operational = 0x20,            SetCgRam = 0x40,            SetDdRam = 0x80        }        public enum Entrance : byte        {            FromRight = 0x00,            FromLeft = 0x02,            ShiftIncrement = 0x01,            ShiftDecrement = 0x00        }        public enum DisplayControl : byte        {            ScreenOn = 0x04,            ScreenOff = 0x00,            CursorOn = 0x02,            CursorOff = 0x00,            BlinkBoxOn = 0x01,            BlinkBoxOff = 0x00        }        public enum Operational : byte        {            Dot5x10 = 0x04,            Dot5x8 = 0x00,            SingleLine = 0x00,            DoubleLIne = 0x08,            FourBit = 0x00        }        #endregion    }}

Program.cs

/*-------------------------------------------------------------------------------+|| Copyright (c) 2012, Embedded-Lab. All Rights Reserved.|| Limited permission is hereby granted to reproduce and modify this | copyrighted material provided that this notice is retained | in its entirety in any such reproduction or modification.|| Author: ANir| First Version Date: 2012/12/27+-------------------------------------------------------------------------------*/using System;using System.Threading;using SecretLabs.NETMF.Hardware.NetduinoPlus;using EmbeddedLab.NetduinoPlus.Day2.Display;namespace EmbeddedLab.NetduinoPlus.Day2{    public class Program    {        public static void Main()        {            LCD lcd = new LCD(                Pins.GPIO_PIN_D8, // RS                Pins.GPIO_PIN_D9,  // Enable                Pins.GPIO_PIN_D4,  // D4                Pins.GPIO_PIN_D5,  // D5                Pins.GPIO_PIN_D6,  // D6                Pins.GPIO_PIN_D7,  // D7                20,                // Number of Columns                 LCD.Operational.DoubleLIne, // LCD Row Format                4,                 // Number of Rows in LCD                LCD.Operational.Dot5x8);    // Dot Size of LCD            while (true)            {                lcd.ShowCursor = true;                lcd.Show("www.Embedded-Lab.comWelcome's you to Netduino Tutorial site.  Happy Learning! :)", 200, true);                Thread.Sleep(5000); // reading time for the viewer                lcd.ClearDisplay();                lcd.ClearDisplay();                lcd.Show("That was cool! Let's clear the display and show all text at once", 200, true);                Thread.Sleep(1000); // reading time for the viewer                lcd.ClearDisplay();                lcd.ShowCursor = false;                lcd.Show("ABCDEFGHILKLMnopqrstuvwxyz0123456789                              -Thanks!");            }        }    }}

Works for me.

 

Courtesy of embedded lab.

 

If this doesn't work I'm thinking the display needs 5v logic signals not 3.3v. Get back to me but you'll need to use a shift register though?

 

Grant



#10 Peter Forstmeier

Peter Forstmeier

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 12 November 2013 - 06:01 PM

Hi,

what did you mean with this Phrase:

......

<iframe src="https://skydrive.liv...ADIaSTd8kXfcHMU" width="274" height="319" frameborder="0" scrolling="no"></iframe>

 

copy this where vdd is 5v.

------

as you can see  here

http://forums.netdui...erase-netduino/

my N+2 is dead at the Moment. As soon he will work again,i will be back

 

Thanks

 

Peter



#11 stotech

stotech

    Advanced Member

  • Members
  • PipPipPip
  • 143 posts
  • LocationAustralia

Posted 13 November 2013 - 07:55 AM

No worries. Here is the wiring diagram you can copy at this link.

https://skydrive.liv...ADIaSTd8kXfcHMU

Except that you can connect pin16 directly to GND instead of using transistor. 

 

Where you see Vdd on the diagram. Connect to 5v.

 

Does that clear it up?



#12 Peter Forstmeier

Peter Forstmeier

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 14 November 2013 - 07:29 AM

Hi,

as you can see in this thread:

http://forums.netdui...eflash-bricked/

i habve to wait until my N+2 is working again.

 

thanks

Peter






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.