Shop OBEX P1 Docs P2 Docs Learn Events
Direct control of LCD display -an experiment — Parallax Forums

Direct control of LCD display -an experiment

doggiedocdoggiedoc Posts: 2,245
edited 2011-03-13 18:03 in Propeller 1
:cool:

So, after I managed to flub up my Parallax 2x16 Serial LCD (still not sure what happened) I decided to try to control the display directly from a Prop.

First step was to desolder the SX control board from the back of the JHD 162A - assuming that it was the damaged part (correct assumption in hind site).

Then I soldered on wires to each of the 16 pins on the LCD board.

prop_lcd2.jpg
{ --------TEST: directly control LCD #JHD 162A with Prop
3/8/2011 - Paul A. Willoughby, DVM
 }
CON
  _xinfreq = 5_000_000
  _clkmode = xtal1 + pll16x

  RsPin = 4                     'Register select (RS) on LCD -LCD pin #4
                                'RS = 0: Instruction Register
                                'RS = 1: Data Register

  EnablePin =  6                'Enable Signal on LCD -LCD pin #6
                                'toggling Enable to low and back to high again
                                'writes to register value at Data Pins -LCD
                                'pins 7 thru 14



PUB Main

  dira [4..14]~~                'set pins to output
  outa [EnablePin] := 1         'enable pin high


  waitcnt(clkfreq * 2 + cnt)    'wait 2 seconds to allow LCD to poweron (may not be needed)

''Inst_Mode                     'register select to low for instruction register
    outa [RsPin] := 0

    ''---initialize LCD
  outa [7..14] := %00001111     'show cursor, set blinking
    ToggleEnable
  outa [7..14] := %00000001     'cursor home Line 1
    ToggleEnable
  outa [7..14] := %00111000     'Enable 2 lines
    ToggleEnable

''Char_Mode                     'register select to low for instruction register
    outa [RsPin] := 1

'' Hello World
  outa [7..14] := %01001000 'H
   ToggleEnable
  outa [7..14] := %01100101 'e
   ToggleEnable
  outa [7..14] := %01101100 'l
   ToggleEnable
  outa [7..14] := %01101100 'l
   ToggleEnable
  outa [7..14] := %01101111 'o
    ToggleEnable
  outa [7..14] := %00101100 ',
    ToggleEnable
  outa [7..14] := %00100000 'space
   ToggleEnable
  outa [7..14] := %01010111 'W
   ToggleEnable
  outa [7..14] := %01101111 'o
   ToggleEnable
  outa [7..14] := %01110010 'r
    ToggleEnable
  outa [7..14] := %01101100 'l
   ToggleEnable
  outa [7..14] := %01100100 'd
   ToggleEnable
  outa [7..14] := %00100001 '!
   ToggleEnable

''Inst_Mode
    outa [RsPin] := 0
    outa [7..14] := %11000000  ' move Cursor to begining Line 2
      ToggleEnable

''Char_Mode
    outa [RsPin] := 1

''Prop
  outa [7..14] := %01010000 'P
  ToggleEnable
  outa [7..14] := %01110010 'r
  ToggleEnable
  outa [7..14] := %01101111 'o
  ToggleEnable
  outa [7..14] := %01110000 'p
  ToggleEnable
  outa [7..14] := %00100000 'space
  ToggleEnable
  outa [7..14] := %01101001 'i
  ToggleEnable
  outa [7..14] := %01110011 's
  ToggleEnable
  outa [7..14] := %00100000 'space
  ToggleEnable
  outa [7..14] := %01000001 'A
  ToggleEnable
  outa [7..14] := %01010111 'W
  ToggleEnable
  outa [7..14] := %01000101 'E
  ToggleEnable
  outa [7..14] := %01010011 'S
  ToggleEnable
  outa [7..14] := %01001111 'O
  ToggleEnable
  outa [7..14] := %01001101 'M
  ToggleEnable
  outa [7..14] := %01000101 'E
  ToggleEnable
  outa [7..14] := %00100001 '!
  ToggleEnable


{ --not used
  outa [7..14] := %01011001  'Y
  ToggleEnable
  outa [7..14] := %01100101  'e
  ToggleEnable
  outa [7..14] := %01110011  's
  ToggleEnable
  outa [7..14] := %00100000 'space
  ToggleEnable
  outa [7..14] := %01101000 'h
  ToggleEnable
  outa [7..14] := %01100101  'e
  ToggleEnable
  outa [7..14] := %00100000 'space
  ToggleEnable
  outa [7..14] := %01101001 'i
  ToggleEnable
  outa [7..14] := %01110011 's
  ToggleEnable
  outa [7..14] := %00100001 '!
  ToggleEnable
  outa [7..14] := %00100001 '!
  ToggleEnable

}

 repeat 'keep cog active to pins don't float?  (there may be a better way to do this

PUB ToggleEnable

  outa [EnablePin] := 0
  waitcnt(clkfreq / 500 + cnt)    ' 1/500th second seems to be reliable - faster doesn't
                                  ' always work
  outa [EnablePin] := 1



Then after some research and trial and error - I came up with a hard coded output.

prop_lcd.jpg


Future experiments:
1 - use shift register to reduce number of Prop's i/o pins
2 - refine code for more "object-like" use
3 - recreate daughter board approach using Propeller instead of original SX

Paul

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-03-08 22:48
    About your future experiments:
    1- The number of I/O pins can be reduced by using the 4 bit mode of the display
    2- Pick any LCD HD44780 compatible driver from the ObjectExchange
    3- What a waste of a prop ;o) Take the smallest available AVR for little money and it can do this.

    Just want to say:
    If you do it for the fun, fine. If you have other funnier or more challenging things to do, rather use the drivers from the object exchange and do the funnier things.

    Important information outcome of this thread so far:
    1. Yes, the parallax serial LCD uses a standard HD44780 compatible display.
    2. Yes, the Prop is AWSOME ;o)
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2011-03-08 23:15
    Granted, yes, you could use objects from the OBEX to control the LCD since it is just a standard HD44780 controller LCD, but the learning that you have gained from your hardcoding is definitely worthwhile. You probably have a much better understanding now of the LCD and could probably write your own object if you wanted. Sometimes, doing things the hard way gives you a tremendous amount of knowledge. Hope it was fun! I have a 2x16 Serial LCD that is also dead and since the SX chip has a pit right on top, I am sure it's blown so I will be harvesting the LCD for use in 4 bit mode down the road as well. You should set up a bank of toggle switches for the data lines and a pushbutton for the enable. Then set the toggle switches, push the button, and watch the letters show up on the LCD. Talk about retro computing!
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-03-08 23:24
    Experiments like this are great fun. Like MagIO2 says, check out the 4 bit mode. Then you only need 6 propeller pins to drive the display. I like the 20x4 displays - same driver and almost identical code and they seem to be getting cheaper every year. I have some code to run a simple terminal - scroll at the end of a line, backspace, line feed and carriage return.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-03-09 02:47
    Once upon a time I used some pushbuttons with some debouncing logic and LEDs to read a chipcard bit by bit. With this knowledge I wrote a program to read it via parallel port. Right ... that's fun ...

    But now doggiedog knows the basics and unless he has some real new ideas about a driver I'd say it's now more like a waste of time to create another one. I also wrote a LCD driver, but only because I wanted to have one which is written in PASM and because I added some nice features ( for example 32x16 pixel graphics on the text LCD, screen buffer mode which comes handy if several COGs have to update content on the LCD ...) .
    Exploration could now be shifted to using low level drivers like the one I have put to the obex.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-03-09 03:16
    I also wrote a LCD driver, but only because I wanted to have one which is written in PASM and because I added some nice features ( for example 32x16 pixel graphics on the text LCD,

    Yes I wrote one too because one didn't exist. It uses a HC374 latch instead of driving the LCD directly. The memory part of the dracblade already existed and there was a data buss and an address buss, so the extra "cost" of adding an LCD driver was a 50c chip and no extra propeller pins. The temptation to write a driver was just too high when it didn't cost any pins at all, but the catch was that all the code had to be written from scratch, and also had to be combined with other pasm code in the same cog.

    So I have experienced the thrill of seeing "hello world" appear on an LCD after days of coding. MagIO2 and doggiedoc belong to the same exclusive club. It is fun! KyeDos boots up using a VGA display and also the serial port and the 20x4 LCD display.
    Future experiments:
    1 - use shift register to reduce number of Prop's i/o pins

    That sounds cool. How about looking at the HC595 - that ought to reduce it to 3 propeller pins.
  • doggiedocdoggiedoc Posts: 2,245
    edited 2011-03-09 03:55
    @MagIO2 - I should have mentioned that this was meant to be a leaning exercise. I felt I would get more satisfaction from the experience by figuring it out on my own in stead of using something from OBEX. I am having fun!

    @WBA Consulting - I do have a better understanding of how the LCD works. I saw the 4 bit mode in the datasheet and plan to explore that more. As for the toggle switches, that's exactly how I set it up on my PPDB (with DIP switches) at first to grasp out how to make it work. Very retro!

    @Dr_Acula - I'll have to look at the datasheet on the HC374, but I don't have any of them. I have a lot of HC595s so I suspect I'll try those first. BTW, "Hello, World!" was really second. I coded it to print my name first! :D

    Paul
  • garylakegarylake Posts: 41
    edited 2011-03-09 03:56
    Great tutorial. Yes that's what I call it. For a beginner this is what's needed. We need more of this. Good pictures and simple code. I understand LCD coding more now than if I were to use a PASM obex object.
    Good work doggiedoc. Keep experimenting, and I will stay tuned.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-09 03:58
    DoggieDoc: I like how you were able to make a part that didn't work into a working one. It is indeed a magical resurrection using only a few additional wires and some brain power to wire it. This is "green" recycling at its best. Congratulations! I also like your code because you put "vision" into it.
  • doggiedocdoggiedoc Posts: 2,245
    edited 2011-03-09 04:02
    garylake wrote: »
    Great tutorial.
    Thanks! But I never expected anybody else to gain anything from it. Happy to share!

    Here is a JAVA app that I found that really helped my understanding of it.

    Here is a link to the datasheet too. I don't understand all of it yet. :D

    Paul
  • doggiedocdoggiedoc Posts: 2,245
    edited 2011-03-09 04:05
    Humanoido wrote: »
    DoggieDoc: I like how you were able to make a part that didn't work into a working one. It is indeed a magical resurrection using only a few additional wires and some brain power to wire it. This is "green" recycling at its best. Congratulations! I also like your code because you put "vision" into it.

    Thanks for the kind remarks Humanoido! It was very satisfying to get the LCD working again. I could actually use it in a project now. I am glad I didn't just toss it out! :D:D

    Paul
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2011-03-09 05:09
    Use something like a tiny88 to do this.
    The tiny88 costs 1.80usd, add a .28 xtal and run the free VUSB software
    and add USB to it...

    Don't use a prop for this, save the prop for something
    more useful. There is 8k of flash on the tiny88 so you have lots of room to
    handle a bunch of protocols for communicating with the lcd and still there
    are enough I/O pins and mips to do several other things. You can turn a
    2.50usd ebay 2 line lcd into a powerhouse with a tiny88 and bring it all in
    for about 6 dollars including shipping...very frugal :-)

    You don't need a circuit board, epoxy the tiny88 upside down on the back of the
    lcd and do dead bug point to point wiring.
  • doggiedocdoggiedoc Posts: 2,245
    edited 2011-03-09 06:53
    @Holly - I built an Atmel programmer in the past. For the 89xx series I think. Memory fails me at the moment. Anyway, it wasn't the tiny88 and it wasn't even a flash based mcu - besides I never got it to work right. I should check into the tiny88 as you suggest - I like the minimalist approach.

    Paul

    BTW - dead bug style is awesome!
  • Heater.Heater. Posts: 21,230
    edited 2011-03-09 08:39
    Excellent.

    About the first thing I ever did with a Prop was drive an LCD like that. Just to get the hang of things. The Props first ever CP/M prompt was on that LCD as I had no spare monitor at the time.
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2011-03-09 14:16
    There is an ebay seller that has a new type of 20x4 LCD for sale.
    It is not exceptionally cheap at 15usd delivered but it is the first
    of its type that I have seen that has an OLED type of display.
    There is also a seller with a similar red colored 40x4 unit.

    It is green chars on a black background.
    http://cgi.ebay.com/OLED-Quality-looking-LCD-20x4-HD44780-Green-Black-/360332254456?pt=LH_DefaultDomain_0&hash=item53e579dcf8

    But the best buy is still this 16x2 blue unit at 3.49usd delivered.
    There used to be a seller offering this same unit at 3usd delivered.
    http://cgi.ebay.com/HD44780-1602-16x2-LCD-Display-Module-Blue-Blacklight-/180627312453?pt=LH_DefaultDomain_0&hash=item2a0e3a0f45
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-03-09 14:50
    Thanks Holly!

    Those OLED displays are stunning. I picked one up about 3 years ago on ebay and then all the ones at ebay prices disappeared for a while. Nice to see them back again. They are drop-in replacements for the LCD displays.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-03-13 17:55
    While you can use another processor, this is a prop forum! Anyway, you may have the oins available on a project. I am doing a project that uses 3 props - one is used to scan a keyboard and drive an LCD, with serial to another remote prop. I admit this could be done cheaper, but it keeps the development easy.
  • doggiedocdoggiedoc Posts: 2,245
    edited 2011-03-13 18:03
    @Cluso99 - I must admit I've yet to ever run out of I/O pins on any project. :)
Sign In or Register to comment.