HD44780 module on FEZ Mini

Hi,

To get a better understanding of communication between systems, i want to create a simple testdevice out of the Fez Mini ( i have 2 of these).

  1. I need to connect HD44780 displays to each Fez Mini. (i have some GHI HD44780 modules incl displays that work on my gadgeteer boards)
    (a) Can i connect these to the Fez Mini (if yes, Is it wise to use the HD44780 modules 10 pin plug , od connect directly to the LCD pins ? )
    (b) Is there a pinout available that i can use
    © Which drivers \ code can i use. ? ( I only want to output some text messages)

  2. Has anybody got (ready to go ) code for serial communication.
    ( i want to set the FezMini in ReceiveMode on a certain baudrate, and when data gets sent to the Rx pin, it shows the dat on the display)
    ( When i press th LDR button (or other input device) I want to go to SEND mode, Send a test string “Hello World” on the Tx pin, then go back to ReceiveMode

Thanks for any advice.
I have been googling for ages, and got some information, but need to get some simple (working) example to get me going.

Hi

http://www.tinyclr.com/forum/topic?id=1307 and GHI Electronics – Where Hardware Meets Software are good references to see info on other HD44780 options. In particular, the pinout is the important thing. You can normally get the gadgeteer scematic info from http://gadgeteer.codeplex.com/ but the hardware files don’t seem to have been uploaded yet. Best bet is to reverse engineer the pin mappting from http://gadgeteer.codeplex.com/SourceControl/changeset/view/19754#256230 (to give you a hand, here’s the relevant section)


            LCD_RS = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Four, false, null);
            LCD_E = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Three, false, null);
            LCD_D4 = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Five, false, null);
            LCD_D5 = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Seven, false, null);
            LCD_D6 = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Nine, false, null);
            LCD_D7 = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Six, false, null);

            BackLight = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Eight, true, null);

You can also use the Fez shield info (code in particular) from the original LCD+Keypad shield, http://www.ghielectronics.com/downloads/FEZ/Shield/ (you will need to ignore/remove the keypad portion).

Serial comms are easy (to a degree). Wire up a DataRecieved event and add it to a string that you push out the LCD. Here’s a sample code GHI Electronics – Where Hardware Meets Software that might be useful for serial comms.

I think you should take it a step at a time. Write code to read LDR presses. Write code to display stuff on the LCD. Then join the two. Then add that to the LDR+LCD code.

good luck !

@ Brett - Thanks Brett,

I shall follow your advice (taking it one step at a time) and links.
ik i get stuck , Ill post what i’ve tried incl. results, maybe for your
further advice.

Thankx until thusfar

Bert

@ Brett -

Success… after some “figgering” …

Hi… First i modified the standard HD44780 code (.cs) to use the configuration commands for the Fez-Mini.
( This meand taking out all reference to socket and using the NETMF.FEZ library in stead of the Gadgeteer library.

LCD_RS = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Four, false, null);

became

 LCD_RS = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di4, false);

(The working code is attached at the end of this reply !)

I connected the HD44780 module (GHI) to an extentionboard wich fits snugly in my breadboard… NO GO
(i could only get the backlight to work)…

After checking all connections, i figured that , as i was using the extentionboard the wrong way (it probably didnt pass my signals to either of the 2 10pin connectors. It is probably protected by diodes…??

Well I opted for a direct approach before giving up totally…
So i connectede a 10pin-ribboncable to 10 headerpins that fit in the breadboard
wired up the pins (all exept the 3.3v pin(1)) to the pins on the Fez Mini.
rebooted the mini (didnt even have to connect to the PC, as the code was working after all)
and Voila!!!

see the results.

Now I am in for step 2 : getting some serial communication to display on the LCD…
regards
Bert


using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;

namespace FezMiniWithLCD
{
    public class Program
    {

        static OutputPort LCD_RS;
        static OutputPort LCD_E;
        static OutputPort LCD_D4;
        static OutputPort LCD_D5;
        static OutputPort LCD_D6;
        static OutputPort LCD_D7;
        static OutputPort BackLight;

        const byte DISP_ON = 0xC;    //Turn visible LCD on
        const byte CLR_DISP = 1;      //Clear display
        const byte CUR_HOME = 2;      //Move cursor home and clear screen memory
        const byte SET_CURSOR = 0x80;   //SET_CURSOR + X : Sets cursor position to X



        static void Main()
        {
            LCD_RS = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di4, false);
            LCD_E = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di3, false);
            LCD_D4 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di5, false);
            LCD_D5 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di7, false);
            LCD_D6 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di9, false);
            LCD_D7 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di6, false);
            BackLight = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di8, false);
            Initialize();
            TurnBacklightOn();
              Thread.Sleep(2000);
           
             PrintString("Hello World");
           
          }

        static void Initialize()
        {
            LCD_RS.Write(false);

            // 4 bit data communication
            Thread.Sleep(50);

            LCD_D7.Write(false);
            LCD_D6.Write(false);
            LCD_D5.Write(true);
            LCD_D4.Write(true);

            LCD_E.Write(true);
            LCD_E.Write(false);

            Thread.Sleep(50);

            LCD_D7.Write(false);
            LCD_D6.Write(false);
            LCD_D5.Write(true);
            LCD_D4.Write(true);

            LCD_E.Write(true);
            LCD_E.Write(false);

            Thread.Sleep(50);

            LCD_D7.Write(false);
            LCD_D6.Write(false);
            LCD_D5.Write(true);
            LCD_D4.Write(true);

            LCD_E.Write(true);
            LCD_E.Write(false);

            Thread.Sleep(50);

            LCD_D7.Write(false);
            LCD_D6.Write(false);
            LCD_D5.Write(true);
            LCD_D4.Write(false);

            LCD_E.Write(true);
            LCD_E.Write(false);

            SendCmd(DISP_ON);
            SendCmd(CLR_DISP);
        }

        ///<summary>
        /// Sends an LCD command.
        /// </summary>
        static void SendCmd(byte c)
        {
            LCD_RS.Write(false); //set LCD to data mode

            LCD_D7.Write((c & 0x80) != 0);
            LCD_D6.Write((c & 0x40) != 0);
            LCD_D5.Write((c & 0x20) != 0);
            LCD_D4.Write((c & 0x10) != 0);
            LCD_E.Write(true); LCD_E.Write(false); //Toggle the Enable Pin

            LCD_D7.Write((c & 0x08) != 0);
            LCD_D6.Write((c & 0x04) != 0);
            LCD_D5.Write((c & 0x02) != 0);
            LCD_D4.Write((c & 0x01) != 0);
            LCD_E.Write(true); LCD_E.Write(false); //Toggle the Enable Pin

            Thread.Sleep(1);

            LCD_RS.Write(true); //set LCD to data mode
        }

        /// <summary>
        /// Prints the passed in string to the screen at the current cursor position. Note: This function will move the cursor position after.
        /// </summary>
        /// <param name="str">The string to print.</param>
        static void PrintString(string str)
        {
            for (int i = 0; i < str.Length; i++)
                Putc((byte)str[i]);
        }

        /// <summary>
        /// Sends an ASCII character to the LCD at the current cursor position. Note: This function will move the cursor position after.
        /// </summary>
        /// <param name="c">The character to display.</param>
        static void Putc(byte c)
        {
            LCD_D7.Write((c & 0x80) != 0);
            LCD_D6.Write((c & 0x40) != 0);
            LCD_D5.Write((c & 0x20) != 0);
            LCD_D4.Write((c & 0x10) != 0);
            LCD_E.Write(true); LCD_E.Write(false); //Toggle the Enable Pin

            LCD_D7.Write((c & 0x08) != 0);
            LCD_D6.Write((c & 0x04) != 0);
            LCD_D5.Write((c & 0x02) != 0);
            LCD_D4.Write((c & 0x01) != 0);
            LCD_E.Write(true); LCD_E.Write(false); //Toggle the Enable Pin
            //Thread.Sleep(1);
        }

        /// <summary>
        /// Clears the screen.
        /// </summary>
        static void Clear()
        {
            SendCmd(CLR_DISP);
        }

        /// <summary>
        /// Places the cursor at the top left of the screen.
        /// </summary>
        static void CursorHome()
        {
            SendCmd(CUR_HOME);
        }

        /// <summary>
        /// Set the cursor to the passed in position.
        /// </summary>
        /// <param name="row">Row of the desired cursor position.</param>
        /// <param name="col">Column of the desired cursor position.</param>
        static void SetCursor(byte row, byte col)
        {
            byte[] row_offsets = new byte[4] { 0x00, 0x40, 0x14, 0x54 };
            SendCmd((byte)(SET_CURSOR | row_offsets[row] | col));
        }

        /// <summary>
        /// Turns the backlight on.
        /// </summary>
        static void TurnBacklightOn()
        {
            BackLight.Write(true);
        }

        /// <summary>
        /// Turns the backlight off.
        /// </summary>
        static void ShutBacklightOff()
        {
            BackLight.Write(false);
        }


    }
}

Congrats on the progress !

My thought about the Extender module is that it shouldn’t have caused any such issue - as far as I know there are no diodes involved in any of the modules that would affect this. Personally, I suspect that the issue was more likely to be contrast related (or maybe some of the pin mappings weren’t right?); now you know it works, you could try re-doing the same with the extender and see if you can get it to work.

Onto the UART ! One tip, don’t assume that DataRecieved events are the answer to every problem you have :slight_smile: