Shop OBEX P1 Docs P2 Docs Learn Events
2004A LCD Display For Text — Parallax Forums

2004A LCD Display For Text

seekerofthetreeseekerofthetree Posts: 12
edited 2015-01-24 15:12 in Robotics
Hey guys,

Need some help I am coming along designing my US transducer guided car. I wanted to add a display using the propellor board of education and a LCD display. I went for the cheaper option and bought a generic 2004A board. My question is do I have to reinvent ASCII in order to display on this thing? I wanted to display distance measured for example. So if I want to display 3.4 inches do I have to send 051 046 052 032 105 110 099 104 101 115 to each port? Seems like a pain in the rear. Anybody used one of these cheap displays before?

Thanks
Seeker

Comments

  • kwinnkwinn Posts: 8,697
    edited 2015-01-20 20:12
    Based on the data sheet that display has an 8 bit parallel interface so you send out the 8 bit ascii code for the alphanumeric characters you want to display. Pretty standard stuff for an 8 bit parallel interface. The numbers you listed are the decimal equivalent of the 8 bit code. For example 051 is the decimal representation of "3", "33" is the hexadecimal representation, and "00110011 the binary representation.
  • seekerofthetreeseekerofthetree Posts: 12
    edited 2015-01-20 20:41
    Thanks. So I would have to create a separate library in which I would send a text string or a char array and then it would take those and convert those to the binary equivalent and display for each char. Did I capture it right? Seems like it would be a alot of work. What do you think?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-20 21:16
    I'm not sure why this is "reinventing" ASCII. It sounds like the display is using ASCII like many displays. Even with a serial display or debug terminal window you send your variables as ASCII characters. The "Dec" methods of the various serial drivers should show how to convert numeric values to ASCII characters.

    For a single digit "value", you could use:
    character := value + "0"
    

    There's a method "DecPoint" floating around a couple of places on the forum which makes it easier to display scaled integers using a decimal point. It would need to be slightly modified to send the characters to your display rather than a serial driver.
    The same thing can be done with the method "fdec" in the object "strfmt". The object "Numbers" in the Propeller Tool's library also has this sort of method (IIRC).
  • kwinnkwinn Posts: 8,697
    edited 2015-01-20 21:34
    Not exactly. Usually the numeric data you are measuring or calculating is stored as binary integers or floating point numbers. They will need to be converted to the equivalent ascii characters to be displayed. Text is usually stored in memory as part of the program or read from some external storage and is already in ascii. The exact details vary depending on the processor and language you are using so it's best if you post that information.
  • seekerofthetreeseekerofthetree Posts: 12
    edited 2015-01-20 21:41
    So I am using C and the Propellor BOE. I have the 8 inputs wired. So if I wanted to display "Hello" I would have to convert hello into a bit string correct and the for each letter transmit then advance the cursor correct? I am using the simpleIDE to program my C in so I will probably have to add libraries if I want to get fancy but I don't see anyway to convert a string to a binary array. That would be the easiest and then I could display a binary string by going through a loop and picking up 8 bits at a time. Thanks for your help guys.
  • kwinnkwinn Posts: 8,697
    edited 2015-01-21 08:29
    Not exactly. In the hello world program below the compiler stores the bytes that make up the word "Hello!" in memory. When the "print" function is called it sends each of those bytes to the display in sequence starting with the "H" and ending with the "!" (exclamation mark).

    Most of this is part of the hardware and software standards. On an alphanumeric keyboard when you press the "h" key the keyboard hardware sends out the ascii code for the letter "h". If you hold the shift key and press the "h" key it sends out the ascii code for the capital letter "H".

    If a display terminal or printer receives the ascii code for "H" the hardware of the display or printer will display or print "H", no conversions needed.

    In almost all cases now the hardware for keyboards, displays, and printers are microcontrollers and software that perform these functions. For numbers it is different. Virtually all calculations are done with binary numbers internally in the micro, so the decimal digits we are familiar with need to be converted to binary numbers when they are entered, and the binary numbers need to be converted back to decimal digits when we want to display or print them. That conversion is usually done by the library functions of the C compiler.
    #include "simpletools.h"                      // Include simple tools
    
    int main()                                    // Main function
    {
      print("Hello!");                            // Display test message
    }
    
  • seekerofthetreeseekerofthetree Posts: 12
    edited 2015-01-21 13:57
    Thanks for the reply. I understand what you are saying. My question is if I have a LCD 20x4 display with 8 bit inputs and each is either 0 or 1 and connected to my Board; I will have to go ahead and tell each input to be on or off correct to display the correct letter. The only way I could see that occurring is if I am converting each letter to bits and then turning each pin input either on or off myself. Am I over complicating this?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-21 15:36
    Am I over complicating this?

    I think so.

    In Spin you could do this:
      outa[7..0] := character
    

    You do something similar with any 8 sequential pins. There's got to be an easy way to do the same in C.
  • kwinnkwinn Posts: 8,697
    edited 2015-01-21 20:02
    As Duane posted, it's not as complicated as you think. Based on the data sheet (I have never used this display) it looks like a matter of sending out 3 control signals (RS, R/W, E) and reading or writing 8 data bits. All of that is explained in the data sheet, and driver code should be fairly simple to write if there is none already written.

    The sequence for each character or command would be something like:

    output function bits to RS and R/W pins
    output 8 data bits to data pins
    output high to E pin
    output low to E pin

    This is for the lowest level.

    There are a lot of other functions that are performed by writing commands to the display control register. They are explained in the data sheet.

    PS - Take a look at the Multi Propeller - 8bit Parallel IO object to see how a parallel port is done in spin.
  • seekerofthetreeseekerofthetree Posts: 12
    edited 2015-01-21 20:06
    Thanks guys I appreciate the help. I am gonna try it out this weekend and let you know the results.
  • seekerofthetreeseekerofthetree Posts: 12
    edited 2015-01-21 20:07
    I have also seen the arduino liquidcrystal library. Not sure how I would incorporate that into the program I am using.
  • Hal AlbachHal Albach Posts: 747
    edited 2015-01-22 04:14
    http://moderndevice.com/product/lcd117-serial-lcd-kit/
    I use this device to connect my propeller projects to an LCD display. It takes all the tedium out of getting the display operational, which can be very frustrating, particularly initializing the display. Added benefit is that it uses 1 propeller I/O pin instead of 9 or ten. Setting it up in C with Simpletools is as easy as 1-2-3.
    serial *lcd;      // use this declaration before MAIN, allows global LCD access
    int main(void)
    {
    
      lcd = serial_open(-1, 26, 0, 9600);   // open the device in MAIN, now you can use dprint in any function
                                                         // Parm -1  serial-in pin  (-1 = none)
                                                         // Parm 26  serial-out pin from propeller to interface
                                                         // Parm 0   unused mode field
                                                         // Parm 9600  Baud rate used by the interface
      .
      .
      .
    }
    void show_time()
      .
      .
      .
      dprint(lcd, "?y3?x04%02d:%02d:%02d", hour, min, sec);        // %02d prints a 0-padded 2 digit number
      .
      .
    }
    
    The dprint statement...
    ?y3 = line 4 of a 4x20 display
    ?x04 = 5th position from left
    The rest is standard C format for printing to the device. There are quite a few ?commands available to let you do just about anything with your display. The onboard PIC takes care of nearly all timing except for when you write config info to the Pic eeprom, which is clearly spelled out in the documentation. If your propeller board has an unused servo port, you can use that to drive the display using the provided cable in the kit.
  • kwinnkwinn Posts: 8,697
    edited 2015-01-22 10:44
    Hal Albach wrote: »
    http://moderndevice.com/product/lcd117-serial-lcd-kit/
    I use this device to connect my propeller projects to an LCD display. It takes all the tedium out of getting the display operational, which can be very frustrating, particularly initializing the display. Added benefit is that it uses 1 propeller I/O pin instead of 9 or ten. Setting it up in C with Simpletools is as easy as 1-2-3.
    ...................................................

    Nice module Hal, unfortunately his LCD is not HD44780-based so it will not work with his display. It uses a parallel 8 bit or 4 bit data bus and 3 control lines and the commands are different.
  • Hal AlbachHal Albach Posts: 747
    edited 2015-01-22 11:56
    kwinn wrote: »
    Nice module Hal, unfortunately his LCD is not HD44780-based so it will not work with his display. It uses a parallel 8 bit or 4 bit data bus and 3 control lines and the commands are different.
    Hello, kwinn;
    Just looked up the 2004A LCD module and the datasheet shows it uses the SPLC780D controller chip. According to postings on AVR Freaks they state that the two controllers are compatible. They both have the same instruction set, and module pinouts are similar to those that use the Hitachi controller. As I understand it, the LCD117 is a serial to parallel interface specifically for driving LCD modules with just one I/O pin. The 117 offers two ways of connecting to the LCD module, with 1x16 or a 2x8 connectors, and actually communicates with the LCD module using the 4-bit data bus plus control lines.

    Hal
  • kwinnkwinn Posts: 8,697
    edited 2015-01-22 15:40
    Didn't seem like it would work based on the initial web page I looked at, but when I dug a little bit deeper it looks like you're absolutely right. Sorry I ever doubted you.
  • Hal AlbachHal Albach Posts: 747
    edited 2015-01-22 16:04
    kwinn wrote: »
    Didn't seem like it would work based on the initial web page I looked at, but when I dug a little bit deeper it looks like you're absolutely right. Sorry I ever doubted you.
    I am very grateful that you did because it reminded me that if I am going to offer suggestions or possible solutions, I would be more credible if I actually looked up the facts (which I didn't) and not just merely speak from half-knowledge and conjecture (which I did). We both learned a little more here, and isn't that a good thing?
    I hope the OP at least takes a look at the module, I know it has made my life a lot easier. When I tried bit banging LCD modules it seemed like it took forever to get the blasted thing properly initialized.

    Thank you, Kwinn;

    Hal
  • kwinnkwinn Posts: 8,697
    edited 2015-01-23 06:42
    Hal Albach wrote: »
    I am very grateful that you did because it reminded me that if I am going to offer suggestions or possible solutions, I would be more credible if I actually looked up the facts (which I didn't) and not just merely speak from half-knowledge and conjecture (which I did). We both learned a little more here, and isn't that a good thing?
    I hope the OP at least takes a look at the module, I know it has made my life a lot easier. When I tried bit banging LCD modules it seemed like it took forever to get the blasted thing properly initialized.

    Thank you, Kwinn;

    Hal

    It's a reminder I need as well. I have a bad habit of taking a quick look and and getting involved in projects that are a lot more work and of greater complexity than that first look indicated. Bad from a time and income perspective at times but a very good learning experience. I have learned a lot and attracted some new customers from those mistakes, so in the grand scheme of things they have been a benefit.
  • seekerofthetreeseekerofthetree Posts: 12
    edited 2015-01-24 12:30
    You guys are awesome. Thanks guys. I think this module will save me tons of time and effort. I am going to get it assembled and tested.
  • Hal AlbachHal Albach Posts: 747
    edited 2015-01-24 15:12
    I think you will like it. Just be careful the first time and make sure you connect the LCD module to the board pin 1 to pin 1, etc. In the online guide Paul Badger goes over all the precautions. Just be aware that there are some LCD modules with non-standard pinouts, in fact I have one where all the pins are standard except the +5 and Ground are reversed.

    Hal
Sign In or Register to comment.