Shop OBEX P1 Docs P2 Docs Learn Events
Setting up 16x2 LCD on Propeller Activity board — Parallax Forums

Setting up 16x2 LCD on Propeller Activity board

STiGMaSTiGMa Posts: 7
edited 2015-07-21 05:39 in Propeller 1
I got an old basic 16x2 LCD I would like to use it with my Propeller Activity board. Unfortunately, I am pretty new into this and I do not know how and where I should connect its pins with the activity board.  I spent a good number of hours searching the web, but I didn't manage to do it. I connected Pin#1 to the board's ground and Pin#2 to its 5V point; it seems that the LCD switches on. I do not know how to connect the other pins.
Could you please give me some advice/hints or references.
Thanks,STiGMa

Comments

  • It depends on what the communication interface is for your particular LCD.  Odds are that someone has already written a driver for it.  Take a look through the Propeller Object Exchange.  Once you download a driver, look inside the code.  Most often, the developer has indicated which pins the driver is expecting the hardware to be connected to (you can usually change the values, if the defaults don't suit your needs).  Sometimes, you will also find a working demo/example that you can use/modify to test that you have it connected correctly.
  • Please also specify whether you are looking for C/C++ or Spin. Objects have been written for both.
    I've seen three basic types of 16x2 LCD (also known as Hitachi HD44780):
    • Parallel connection - using either 7 or 11 pins for communication - like this one
    • Serial, like Parallax's product
    • I2C, like PropWare.If you have a serial connection, no special driver is needed - just connect a TX pin to the RX line of the LCD and use normal serial commands from the Propeller (as if you were writing to the terminal on your computer)
      If it's I2C, I'm actually not sure of a driver. I'm sure there are ready-made drivers for LCDs over I2C, I just haven't looked for one.
  • You can tie pin 3 low for testing as this is just the contrast control but normally needs around 0.5V or so.
    Pin 4   RS or address select
    Pin 5   R/W which can be tied low as it is only used to read the busy flag but this is redundant.
    Pin 6   E  which is taken high to select the display for data transfer
    Pin 7..14   DB0..DB7 data lines.

    Originally these displays were meant to be driven from a data bus of a microprocessor such as the old Z80s etc but many small micros these days do not have an external data bus and end up driving these from I/O pins to emulate the bus.

    If you are short of I/O pins you can drive the LCD in 4-bit data mode using DB7..DB4 so you only need 2 other I/O for RS and E.

    I would avoid using drivers that try to use the R/W to read back the redundant busy flag as that also means you now have to provide for reading 5V signals.
    Anyway I always write my own drivers and they simply insert a short 2ms delay when using the clear display and return home commands.
    All other commands have a maximum execution time of 37us so there is no need to read a busy flag because Spin and others will take longer than that bit banging the I/O etc.

    Also I like to use an RC filter from one of the I/O so that software adjusts the contrast using the Prop's duty cycle mode rather than a potentiometer.

    You haven't mentioned what language you are using but if you are working with Spin and want the easy way out then just grab the object of your choice and wire up the display accordingly.

  • I got an old basic 16x2 LCD I would like to use it with my Propeller Activity board. Unfortunately, I am pretty new into this and I do not know how and where I should connect its pins with the activity board.  I spent a good number of hours searching the web, but I didn't manage to do it. I connected Pin#1 to the board's ground and Pin#2 to its 5V point; it seems that the LCD switches on. I do not know how to connect the other pins.
    Could you please give me some advice/hints or references.
    Thanks,STiGMa

    Do you have the part number for the display? 
    That would keep us from guessing if it is serial or parallel interface.

  • Thanks for replying guys.

    The LCD is like the one below. 
    HD44780_breadboard_02_lrg.jpg


    I followed an instructable and mounted the lcd on a breadboard for better use. 

    I also pinned the +ve and the ground to the propeller and the lcd now switches on.

    I am still missing how to send data to the LCD. Is there a minimal code, in C preferable, which I can use as a starting point?
  • PublisonPublison Posts: 12,366
    edited 2015-07-22 16:49
    There is Spin code at:
    http://obex.parallax.com/object/73

    Have not tried it yet.
    You may want to try some 4 Bit code:
    http://forums.parallax.com/discussion/153326/4-bit-parallel-lcd-drive




  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-07-22 20:51
    There is existing code in C++ via PropWare. Simply download this zip: http://david.zemon.name/downloads/PropWare_includes.zipAnd extract the contents into your project. You should end up with a folder called "PropWare" in your project and a few .h files inside that.

    Using the API is as easy as pasting the following code into your main source file and renaming the source file as whatever.cpp instead of whatever.c.
    #include "PropWare/PropWare.h"
    #include "PropWare/printer/printer.h"
    #include "PropWare/hd44780.h"
    
    using namespace PropWare;
    
    // Control pins
    const Port::Mask RS = Port::P16;   // Pin connected to `Register Select` on your LCD
    const Port::Mask RW = Port::P17;   // Pin connected to `Read/Write` on your LCD
    const Port::Mask EN = Port::P18;   // Pin connected to `Enable` on your LCD
    
    // Data pins
    const Port::Mask          FIRST_DATA_PIN = Port::P19;          // This would be whatever pin is connected to `Data 0` on your LCD
    const HD44780::Bitmode    BITMODE        = HD44780::BM_8;      // If you're only using 4 of the `Data x` pins, change this to BM_4, otherwise don't touch it
    const HD44780::Dimensions DIMENSIONS     = HD44780::DIM_16x2;  // HD44780 works with more than just 16x2 character LCDs - but since 16x2 is what you have, don't touch this line
    
    // Main function
    int main () {
        // Create and initialize our LCD object
        HD44780 lcd;
        lcd.start(FIRST_DATA_PIN, RS, RW, EN, BITMODE, DIMENSIONS);
    
        // Create a printer for easy, formatted writing to the LCD
        Printer lcdPrinter(&lcd);
    
        // Print to the LCD
        lcdPrinter.printf("Hello, world!");
    
        return 0;
    }
    
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-07-22 20:52
    Btw, the code shown above is taken straight from my example project here.
  • Hey Stigma - closest thing I can find from my array of items is the following:
    http://tymkrs.tumblr.com/post/87994050098/parallel-lcd-propeller-and-in-spin

    It looks like it might be a parallel LCD.  I found reading the object for it very helpful in terms of knowing where the pins go to.  This isn't in C, but in spin as well.  Hope it helps!
Sign In or Register to comment.