4-bit Parallel LCD drive
gregfox
Posts: 68
Hi, Im using Chris Gadd 4-bit Parallel LCD driver, and I was wondering if anyone knows of a 4-bit Parallel LCD driver (2 or 4 rows HD44780 ) written in C for the propeller? I would like to write one in C, but I need a bit more experience. I could learn a lot by just reading the code.
I know a bit of spin (enough to be dangerous), but spin is native to propeller, and I dont want to be tied to any one micro. C is mostly transportable to other chips; therefore I want to stick to C. The propeller is mostly superior to any other chip in its price range. I wish they went right to C, instead of spin.
Thanks!
I know a bit of spin (enough to be dangerous), but spin is native to propeller, and I dont want to be tied to any one micro. C is mostly transportable to other chips; therefore I want to stick to C. The propeller is mostly superior to any other chip in its price range. I wish they went right to C, instead of spin.
Thanks!
Comments
I doubt that.
If you have a free COG you could use my PASM LCD driver. Just some small wrapper C functions and it should be usable - did that for basic a while ago. ( http://obex.parallax.com/object/270 )
The main thing is that you need to insert time delays to allow the LCD time to properly respond. Most of the time delays (the longest ones are in the initialization portion of the code). The rest is rather easy.
By looking at the documentation for the LCD and an example for the BasicStamp2, I am pretty sure you can come up with good code in C.
I do have a question, I set my base pin to 12 (DB4=12/DB5=13/DB6=14/DB7=15),and BLC set to 8. the back-light comes on but no text. (not the contrast as I ran this with other drivers. What could I check?
-- http://obex.parallax.com/object/313
BLC - pin 8
E - 9
RW - 10
RS - 11
DB4 -12
DB6 - 13 etc.
I have the Anode of the lcd connected to +5V and the Cathode to the collector of a 2N3904 with a grounded emitter.
If I send dira[8] := outa[8] := 1 with nothing else in the program, pin 8 goes high, and the back-light goes on.
I know it must be me, but I'm stuck.
In the startx() method paramater blpin is copied to object variable bl.
The backlight method makes the pin output and high if a non-zero (true) value is passed in state. If you pass 0 (false) the pin driver is released. I do this so you can PWM the backlight with another cog if desired.
New version -- see attached.
I just tried it on a PPDB and the blacklight() method is working -- without any extra hacks.
As I'm working on a project with an LCD at the moment I went through and reconciled a couple method calls and the x/y addressing with another driver. The attached demo toggles the backlight on and off.
Actually, I use a 3 prop chip solution in a commercial product. I could have used other cheaper micros in all 3 places, but they would all be different micros. Now I have a common set of parts. Although more expensive, the software is simpler, and my inventory is lower. It all depends on what you are after
Thank you for your time, I really appreciate your efforts!
Thank you for your time, I really appreciate your efforts!
I'm working on a project on a PDB right this second and all is well. I like to pull-down the E pin to ground via 10K. Make sure that you haven't swapped the RS and RW lines in your setup.
Confused.
-- http://www.cameraturret.com/genesis.htm
If you can barely see the characters then you have a problem with the contrast input. Check the LCD -- you want to make sure you don't have one that requires a negative contrast voltage. You normally connect the tap of a 10K pot to the contrast input; the ends of the pot connect between 5v and ground. Adjust for best contrast.
Even using a different LCD (Reflective) the back-light doesn't come on without a hack.
It's hard to understand because looking at you code if anything above a "0" is inserted for bl it should turn on. ARGGGG.
Just for giggles, try a different pin (if the hardware allows), or connect a simple LED circuit to see if you do in fact have control.
1) It's write-only; the RW line the LCD is not controlled (tie it to ground)
2) The LCD data buss (4 pins) and 2 other pins may be used as inputs
For projects that need a four-bit LCD and up to four buttons, you only need six IO pins. In the image is an LCD on a PDB running this object (Laser-tag controller). The controller requires three buttons which means that with this object I don't have to define separate IO pins. The read_btns() method sets the buss pins to inputs, the (private) write() method restores them to outputs. There is documentation in the file that shows how to share the LCD buss pins with buttons and not have any problems (old trick from Scott Edwards).
If you want to check just one of the shared buss lines, please use code like this:
Again, you can do this because the next time you write to the LCD the buss dira bits will be restored.
Question I used you old jm_lcd4_ez_demo.spin as the top object correct?
STOP THE PRESS----I forgot to change lcd : "jm_lcd_hmi_ez" to lcd : "jm_lcd_hmi. in jm_lcd4_ez_demo
When I made the change it error-ed out with:
Project Directory: C:/GREG/Parallax/High-performance 4-bit LCD driver/JM_LCD_HMI/
openspin.exe -I C:/Program Files (x86)/SimpleIDE/bin/../propeller-gcc/spin/ jm_lcd4_ez_demo.spin
Propeller Spin/PASM Compiler 'OpenSpin' (c)2012-2013 Parallax Inc. DBA Parallax Semiconductor.
Compiled on Nov 7 2013
Compiling...
jm_lcd4_ez_demo.spin
|-jm_lcd_hmi.spin
jm_lcd4_ez_demo.spin(54:31) : error : Expected ")"
Line:
lcd.start(1, LCD_E, LCD_COLS, LCD_ROWS) ' bl on P16, 16x2 LCD
Again, thank you for your time.
Is the LCD module a 3.3 Volt friendly ? ie not a 5 Volt one.
Alan
Yes -- I tend to provide demos for my objects with a "_demo.spin" ending
The others (without _demo) are child objects. For example, in my laser tag program I have an object called hmi defined like this:
Then I instatiate it like this:
In this case you can see that I'm only using three of the six possible buttons supported by the object code.
Once you get re-connected start with a very simple demo.
Thanks.
Double-check the LCD -- note that the extended temperature range models require a different bias setup.
The LCD is not an extended temperature unit. I plugged in the 16x2 in place of the 8x2, and checked all the connections twice. As I mentioned everything works great except the BL (even on the 8x2).
On another note I’ll be out of town for 5 days, and hope to take up where we left off.
Cheers!
Gone for 5.
G.