PDA

View Full Version : LCD's with Shift Registers, and LCDOUT



Darrel Taylor
- 21st September 2007, 06:13
Notice: LCDOUT HighJack routines MUST be installed in the PBPPIC??.LIB file before using these interfaces.
For more information on how to install the HighJack routines, see this thread...

LCD_AnyPin.pbp
http://www.picbasic.co.uk/forum/showthread.php?t=7038

PC064PYL I bought a bunch of these displays via eBay a couple years ago. They just looked so cute I couldn't resist.

2x8 HD44780 based LCD's with backlight. P/N PC064PYL
http://www.darreltaylor.com/files/PC064PYL/PC064PYL_Front.JPGhttp://www.darreltaylor.com/files/PC064PYL/PC064PYL_Back.JPG
Running the Sample program shown below.

I should have looked closer at the auction, because it had a 5 pin interface using 74HC164's (shift registers) as a 9-bit input to a normal HD44780 display. ... I was able to get one working using SHIFTOUT, but it was really a pain since you couldn't use LCDOUT, or DEC, or HEX, or ... _____. So they sat in a box on the shelf for a couple years, with me thinking it was a stupid buy. (@ 75 cents apiece, maybe not all that stupid).

But now that there's "HighJack". (previously shown in the LCD_AnyPin.pbp (http://www.picbasic.co.uk/forum/showthread.php?t=7038) thread)
You can do pretty much whatever you want with LCD's.

In this case, the "Little Cutie" is rejuvenated by being able to use normal LCDOUT statements, even though it's a Synchronous Serial interface.

I redrew the schematic for the input circuit.
The only datasheet I could find looks like it was copied a dozen times before being scanned.
Here's (http://www.darreltaylor.com/files/PC064PYL/pc-064pyl.pdf) a copy of part of the datasheet.

And this is the re-draw ...

http://www.darreltaylor.com/files/PC064PYL/PC064PYL_Input.GIF


The display uses an 8 bit interface, so it makes things pretty easy.
Shift in the RS bit, followed by the data byte LSB first.
Once all nine bits are shifted in, pulse the Enable line for at least 1uS.

But then, you don't need to worry about that stuff because it's handled in the Include file.
All you have to do is use LCDOUT.

Assuming that you've properly installed the HighJack routines as mentioned above.
This sample program should give an idea of how simple it is to use PC064PYL.pbp.
; Initialize your Hardware first, set CONFIGs, OSC, Turn off A/D etc
;----[ Change these to match your LCD ]---------------------------------------
LCD2x8_CLK VAR PORTB.0 ; Clock - Pin 1
LCD2x8_DAT VAR PORTB.1 ; Data - Pin 2
LCD2x8_E VAR PORTB.2 ; Enable - Pin 5
INCLUDE "PC064PYL.pbp" ; *** Include MUST be AFTER LCD Pin assignments ****

;----[ Your Main program starts here ]----------------------------------------
LoopCount VAR WORD
Main:
LCDOUT $FE,$80,"Hello,",$FE,$C0,"From DT!"
PAUSE 3000
LCDOUT $FE,1 ; clear screen
FOR LoopCount = 0 TO 65535
LCDOUT $FE,$80, IDEC LoopCount
LCDOUT $FE,$C0, IHEX4 LoopCount
; pause 100 ; Slow it down, if you want
NEXT LoopCount
GOTO Main

Just assign the pins used for the LCD.
Include the PC064PYL.pbp file.

And away you go, ... using LCDOUT just like you always have.
Except it's an itty bitty display.

While this is an easy way to use a PC064PYL, it's also a way that you can hook up ANY HD44780 Display.
It just happens that the "Little Guy" has them built in.

However, it seems like a waste to have 2 - 74HC164's, when the second one is only using 1 out of 8 bits. You could use a 4-bit interface and save the extra chip, but it still takes 5 wires going to the LCD. So I wouldn't recommend using this EXACT same way of doing things, unless it's already built-in, like the PC064PYL.
There's something very close that only requires 1 chip and 4 wires, and that's what I'll tackle in the next post in this thread.

There are 2 files required to use the PC064PYL driver with PicBasic Pro. They are ...


PC064PYL.pbp
VirtualPort.bas   (included from the PC064PYL.pbp file)
Both files are included in the .ZIP file below. VirtualPort.bas is the same as the file from the LCD_AnyPin thread and doesn't need to be overwritten, but it doesn't matter if you do since they're the same.
Extract the files to your PBP folder.

naginar
- 25th October 2010, 10:09
Using the Darrel Taylor LCD_AnyPin.pbp as a template i adapted the 2 wires idea of M. Predko to be used in PICBASIC. (LCDOUT)
The new .pbp patch is not so professional as the original (maybe Mr Darrel Taylor can fix it), but is working.
Only two pins (any) of the uC are neded to drive the LCD display (44780 type).
The example is for 16F628A uC.
Some time is very useful to have more pins available.

Guido

Hope the attachment PBP_2WSLCD.zip is inserted correctly!

picone
- 29th July 2012, 21:44
I too bought some of these little guys from ebay a number of years ago.....have been collecting dust ever since.

Just curious if this will work with a 12F683?
I followed all of the above instructions and then just replaced the pin definitions with gpio.0, gpio.1, gpio.2 but I'm not getting any output to the lcd.

Darrel Taylor
- 30th July 2012, 00:44
Yes, it should work on a 12F683.

Did you add ... ANSEL = 0 ... to your program?

picone
- 30th July 2012, 03:48
I did have ANSEL=0 in the code which is shown below...compiled with PBP 2.60c. Is it possible my lcd is just defective?



define osc 4
intcon=0
ansel=0

;----[ Change these to match your LCD ]---------------------------------------
LCD2x8_CLK VAR gpio.0 ; Clock - Pin 1
LCD2x8_DAT VAR gpio.1 ; Data - Pin 2
LCD2x8_E VAR gpio.2 ; Enable - Pin 5
INCLUDE "PC064PYL.pbp" ; *** Include MUST be AFTER LCD Pin assignments ****
;----[ Your Main program starts here ]----------------------------------------
LoopCount VAR WORD
Main:
LCDOUT $FE,$80,"Hello,",$FE,$C0,"From DT!"
PAUSE 3000
LCDOUT $FE,1 ; clear screen
FOR LoopCount = 0 TO 65535
LCDOUT $FE,$80, IDEC LoopCount
LCDOUT $FE,$C0, IHEX4 LoopCount
PAUSE 100 ; Slow it down, if you want
NEXT LoopCount
GOTO Main

Darrel Taylor
- 30th July 2012, 06:19
Is it possible my lcd is just defective?
I suppose it's possible, but I'd look for other problems first, like ...

Do you have a pull-up resistor on the MCLR pin? Or have you disabled MCLR in the configs.

picone
- 30th July 2012, 14:36
I suppose it's possible, but I'd look for other problems first, like ...

Do you have a pull-up resistor on the MCLR pin? Or have you disabled MCLR in the configs.

I set MCLR off and am using INTOSC_NOCLKOUT. I double and triple checked my wiring, and I did have a generic led blinking program running on this board to ensure I had a functioning setup. The lcd backlight comes on when I apply power....but no text.

Is there anything else in the CONFIG that could prevent this from working besides MCLR and oscillator?

HenrikOlsson
- 30th July 2012, 16:53
Hi,
I must admit I'm not sure how or if the comparator interfere with the pins when the pins are configured as outputs. However I can't see the comparator pins being set to digital so it might be worth a try to add CMCOM0 = 7.

I also don't see you setting the pins used to outputs but Darrels original code doesn't do it either so it's probably handles by the LCDOUT statement as normal ir the hijack routine. But again, might be worth a try configuring TRISIO properly.

/Henrik.

picone
- 31st July 2012, 12:24
Hi,
I must admit I'm not sure how or if the comparator interfere with the pins when the pins are configured as outputs. However I can't see the comparator pins being set to digital so it might be worth a try to add CMCOM0 = 7.

I also don't see you setting the pins used to outputs but Darrels original code doesn't do it either so it's probably handles by the LCDOUT statement as normal ir the hijack routine. But again, might be worth a try configuring TRISIO properly.

/Henrik.

CMCON0=7 did the trick! Thank you Henrik and Darrell for your help.

On a separate and unrelated note..........how come Darrell's routines (i.e. Instant Interrupts, Slow PWM, LCDanypin, etc) haven't been incorporated into PBP yet? They must add about 50% more functionality to PBP but I'm surprised they aren't part of the software package.

gr1ph0n
- 5th September 2012, 16:48
Is it possible to make naginar's patch to work? I tried the schematic in proteus and I get an error telling me that the "HD44780 controller received command whilst busy".

gr1ph0n
- 5th September 2012, 19:14
I've managed to make it work with minor modifications and connecting E separately. Thank you.

ajoyna1
- 3rd April 2015, 15:34
I also don't see you setting the pins used to outputs but Darrels original code doesn't do it either so it's probably handles by the LCDOUT statement as normal ir the hijack routine. But again, might be worth a try configuring TRISIO properly.