How to: 2x16 LCD to Mini

Oh you give in too easy :slight_smile:

I’ve just soldered a male .1" header into the connector on my LCD for breadboarding, so you could do the same.

One thing I’d recommend is buying a bag of “breadboard wires” like I have, they’re coloured in different sizes. Sparkfun have some good male-male, male-female, and female-female options that do come in handy at different times. Makes it soooo much easier. If nothing else you need a fine, solid core wire.

If you have access to an electronics store then you can get a few things worthwhile. 74LS245 for level shifting from 3v3 to 5v is worth having, grab a couple of 4094 serial-in parallel-out chips, and some BC548 transistors and a bag full of resistors.

It’s all a trade-off, ease of making it work versus cost to do something else (eg buy the pre-built serial module).

Oh, should have known this, but I didn’t - GHI have breadboard cables as well ! Support them where possible !

Brett,

I will give it a nother try whenever I dont feel sick when looking at it again :slight_smile:

Chris,

FYI, I bought the same RC you bought, (Traxxas Stampede XL-5 RTR Blue A6 ) you are now having a direct competitor :smiley: . I alway want an high performance RC to play with, so this would be my excuse.

Thanks for the research so that I didn’t have to ;D

[quote]
FYI, I bought the same RC you bought, (Traxxas Stampede XL-5 RTR Blue A6 ) you are now having a direct competitor Cheesy . I alway want an high performance RC to play with, so this would be my excuse.[/quote]

I see. Have fun with it! If you want to use it as a robot chassis, you’ll need to deal with a few things first. See my RC car thread. The waterproof box is the worst of it. After you get past that, everything is good.

Brett,
Today on the way home from work, I stopped by Frys electronics and pickup a brandnew breadsboard, wires,a tray of 20 headers. Thanks for headers I soldered it to the LCD and it is a beautifully thing I wish I knew before that they actually sell these things. I followed instruction carefully and I think i almost get it to work. LCD is powered up as it is supposed to be with background light and everything. but when I try to run the debug program downloaded from tinyclr


 public static void Main()
        {      
            FEZMini_Robot.Beep(6000, 300);
            FEZ_Components.LCD2x16 lcd = new FEZ_Components.LCD2x16(FEZ_Pin.Digital.Di5, FEZ_Pin.Digital.Di6, FEZ_Pin.Digital.Di7,FEZ_Pin.Digital.Di8, FEZ_Pin.Digital.Di3, FEZ_Pin.Digital.Di2);
            lcd.Clear();
            int i = 0;
            while (true)
            {
            lcd.CursorHome();
            lcd.Print("Counter " + i++);
            Thread.Sleep(100);
            }

        } //Main()

It keeps giving me the following exception when I try to run on debug mode


 #### Exception System.Exception - CLR_E_PIN_UNAVAILABLE (1) ####
    #### Microsoft.SPOT.Hardware.Port::.ctor [IP: 0000] ####
    #### Microsoft.SPOT.Hardware.OutputPort::.ctor [IP: 0006] ####
    #### GHIElectronics.NETMF.FEZ.FEZ_Components+LCD2x16::.ctor [IP: 0015] ####
    #### FEZ_Mini_LCDTest.Program::Main [IP: 001e] ####
A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll

It makes me feel like the FEZ component (FEZ_Components_LCD2x16.cs) driver that I am using is not designed for this LCD or something

Any thought?

-Thanks, Hai

Are you 100% sue there is only one file in your project and it has the code you posted here?

Looks like some pin is used in more than one place. I think I already pointed this out before. Remove all source files from your project and only leave the one file you copy/pasted here and the LCD driver file of course.

You shouldn’t get exceptions even if the display is not connected at all.

I just noticed this in your code

FEZMini_Robot.Beep(6000, 300);

this tell me that you still have the robot driver in your code! This driver uses a lot of IOs and most likely it is using the same IO you are using for the display.

So, remove all files from the project except for the display driver

…problem solved!..is it working now

If not working, where did you connect the contrast pin? I usually connect this to GND or to the power pin and it works but I am not sure about your display.

Why is this line appearing ? Where is this declared ?

Hey Hai

I dug out my 2x16 LCD. It is a 5v version. I will hook it up tommrow to test (late and I need to get up at 6AM tommorow).

Let me know if you are stuck and if I really need to wire up.

-Rajesh

I think Gus was right, I have an extra line on my main (copy/paste issue). I removed that line and all extra stuffs, and now I dont get that exception anymore.

though the LCD still didnt display the count. debug output shows the following


'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.0\Assemblies\mscorlib.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.0\Assemblies\Microsoft.SPOT.Native.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.0\Assemblies\Microsoft.SPOT.Hardware.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\Assemblies\FEZMini_GHIElectronics.NETMF.FEZ.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'D:\Web Sites\MyRobotics\LCDTest\LineFollower\bin\Debug\LineFollower.exe', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\Assemblies\GHIElectronics.NETMF.Hardware.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\Assemblies\GHIElectronics.NETMF.System.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.0\Assemblies\Microsoft.SPOT.Hardware.SerialPort.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.0\Assemblies\Microsoft.SPOT.IO.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\Assemblies\GHIElectronics.NETMF.IO.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\Assemblies\GHIElectronics.NETMF.Hardware.USBizi.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\Assemblies\GHIElectronics.NETMF.Hardware.EMX.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI NETMF v4.0 SDK\Assemblies\GHIElectronics.NETMF.Hardware.ChipworkX.dll'
The thread 0x2 has exited with code 0 (0x0).

Rajesh,

Thanks!

For me, I found that while I could power the display from the 5v on Fez, the inputs on my LCD would not be driven with the 3v3 signals. Each LCD will likely be different here, and even though the datasheet might imply they possibly can be driven by a 3v3 signal, I couldn’t get mine to do so - so that’s when the 74LS245 level shifter became necessary for me. Your mileage (and LCD) may vary :slight_smile:

Brett,

My LCD explicitly said it needs 5v. I couldn’t get the LCD power up with 3.3v, however FEZ-Mini does have a 5v out. so I used that pin to power LCD.

Below is the link to the datasheet for my LCD, I suspect that there is a layout different between yours LCD and mine, take a look at page 11 and see if can see anything abnormal about it.

http://www.junun.org/MarkIII/datasheets/162A0LED.pdf

Thanks, Hai

On page 7, Vih says 2v2 minimum, therefore theoretically a 3v3 Hi should register as a Hi on this device.

On page 11 the connections seem to be standard HD44780 connections, GND/Vin/Cont/RS/RW/E/data/BL+/BLgnd

So looks to me that everything is in place for you to do and achieve what you want, and if your code is doing what you would expect then it should work, if the device would handle 5v input signals. It seems that it doesn’t work, it may be a different problem (wiring for example) or it may be the level shifting (my guess).

For that you should grab an 74LS245 or equivalent level shifter (there are many that would do I am sure). If you do, you connect 5V to the LS245, then the data input lines from Fez and the data output lines to the LCD.

I actually went to great lengths to prove that I needed the level shifting. I initially set up a LED array connected to the Fez outputs and made sure when I called the LCD code that they blinked as expected. I then also connected in the LCD at the same time, and proved that it didn’t get any data - the LEDs didn’t come on at all, no matter what size current limiting resistor I was using, so I assume (technical bit may well be wrong here) that the LCD inputs needed a higher current than I could drive with Fez to accurately register the input. Whacking the level shifter in place meant it was fine.

I may have solved the mystery :slight_smile:

I use a 5V LCD and no level shifting logic or passive.

The 2x16 LCD brochure needs a small change

GND - ground
VDD - connect t0 5V
Vo - contrast voltage, connect to ground [or a contast adjust pot or fixed resistor]
RS - connect to any digital pin on FEZ
RW - not needed, connect to ground
**********************************This is missing on the brochure
E - connect to any digital pin on FEZ


D0 - leave unconnected
D1 - leave unconnected
D2 - leave unconnected
D3 - leave unconnected
D4 - connect to any digital pin on FEZ
D4 - connect to any digital pin on FEZ
D4 - connect to any digital pin on FEZ
D4 - connect to any digital pin on FEZ
D4 - connect to any digital pin on FEZ
BL_A - backlight, connect to 5V
BL_K - backlight, connect to ground

Also look at the module init code :: don’t mix E and RS



         FEZ_Components.LCD2x16(
         FEZ_Pin.Digital D4,          //D4
         FEZ_Pin.Digital D5,          //D5
         FEZ_Pin.Digital D6,          //D6
         FEZ_Pin.Digital D7,          //D7
         FEZ_Pin.Digital E,            //E
         FEZ_Pin.Digital RS          //RS
);


To Confirm, if you see an exception as follows

Exception System.Exception - CLR_E_PIN_UNAVAILABLE (1)

Microsoft.SPOT.Hardware.Port::.ctor [IP: 0000]

Microsoft.SPOT.Hardware.OutputPort::.ctor [IP: 0006]

GHIElectronics.NETMF.FEZ.FEZ_Components+LCD2x16::.ctor [IP: 0015]

FEZ_Mini_LCDTest.Program::Main [IP: 001e]

This 100% means that you passed the same pin more than once to the module init call

HTH

-Rajesh

Rajesh,
Actually the exception was caused by I have some previous code for other robot, Gus identified it and I have removed that code, now it is not running into exception anymore. I did have
LCD6 (E) - FEZ Di3.

I dnnt see any other issue when run the following code on debug mode, but it doesn’t do anthing either which is strange.

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using System.Threading;
using GHIElectronics.NETMF.FEZ; 

namespace FEZ_Mini_LCDTest
{
    public class Program
    { 
        public static void Main()
        {       
            FEZ_Components.LCD2x16 lcd = new FEZ_Components.LCD2x16(FEZ_Pin.Digital.Di5, FEZ_Pin.Digital.Di6, FEZ_Pin.Digital.Di7,FEZ_Pin.Digital.Di8, FEZ_Pin.Digital.Di3, FEZ_Pin.Digital.Di2);
            lcd.Clear();
            int i = 0;
            while (true)
            {
                lcd.CursorHome();
                lcd.Print("Counter " + i++);
                Thread.Sleep(100);
            }

        } //Main()
    } //class
}//namespace

Strange, problem solved after I moved LCD6 (E) from FEZ Di4 to Di3… why is that?
it is counting now. This LCD drove me banana…should have listened to support monkey, get the serial LCD instead. :smiley:

Thanks Everyone!!!

but what a bunch of bananas you uncovered by doing it “the more challenging way” ;D

Agreed that often the easier path is what you should do, but there can be other reasons for approaching it a different way - cost, availability of bits, etc…

Congrats in perservering !

:dance:

So You had E connected to Di4 and you were passing Di3 to the init call. So it was a wiring problem.