Darrel Taylor
- 21st September 2007, 06:13
<br>
<table border=1 CELLPADDING=12 bordercolor=red><tr><td>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</td></tr></table>
I hope to show a few examples of using LCD's with Shift registers in this thread, but I'll start off with one that's been haunting me for awhile, then work on using Shift Registers to drive ANY HD44780 LCD a bit later.
<hr><a name="PC064PYL"></a><h2>PC064PYL</h2>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
<table border=1 ><tr><td>http://www.darreltaylor.com/files/PC064PYL/PC064PYL_Front.JPG<br><center>Running the Sample program shown below.</center></td><td>http://www.darreltaylor.com/files/PC064PYL/PC064PYL_Back.JPG</td></tr></table>
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.<font color="#0000FF"><b><i>; Initialize your Hardware first, set CONFIGs, OSC, Turn off A/D etc
;----[ Change these to match your LCD ]---------------------------------------
</i></b></font><b>LCD2x8_CLK </b><font color="#008000"><b>VAR </b></font><b>PORTB</b>.<font color="#800000"><b>0 </b></font><font color="#0000FF"><b><i>; Clock - Pin 1
</i></b></font><b>LCD2x8_DAT </b><font color="#008000"><b>VAR </b></font><b>PORTB</b>.<font color="#800000"><b>1 </b></font><font color="#0000FF"><b><i>; Data - Pin 2
</i></b></font><b>LCD2x8_E </b><font color="#008000"><b>VAR </b></font><b>PORTB</b>.<font color="#800000"><b>2 </b></font><font color="#0000FF"><b><i>; Enable - Pin 5
</i></b></font>
<font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">"PC064PYL.pbp" </font><font color="#0000FF"><b><i>; *** Include MUST be AFTER LCD Pin assignments ****
;----[ Your Main program starts here ]----------------------------------------
</i></b></font><b>LoopCount </b><font color="#008000"><b>VAR WORD
</b></font><b>Main</b>:
<font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$80</b></font>,<font color="#FF0000">"Hello,"</font>,<font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$C0</b></font>,<font color="#FF0000">"From DT!"
</font><font color="#008000"><b>PAUSE </b></font><font color="#800000"><b>3000
</b></font><font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>1 </b></font><font color="#0000FF"><b><i>; clear screen
</i></b></font><font color="#008000"><b>FOR </b></font><b>LoopCount </b>= <font color="#800000"><b>0 </b></font><font color="#008000"><b>TO </b></font><font color="#800000"><b>65535
</b></font><font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$80</b></font>, <font color="#008000"><b>IDEC </b></font><b>LoopCount
</b><font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$C0</b></font>, <font color="#008000"><b>IHEX4 </b></font><b>LoopCount
</b><font color="#0000FF"><b><i>; pause 100 ; Slow it down, if you want
</i></b></font><font color="#008000"><b>NEXT </b></font><b>LoopCount
</b><font color="#008000"><b>GOTO </b></font><b>Main</b>
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.<hr>
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.<hr>
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.
<br>
<table border=1 CELLPADDING=12 bordercolor=red><tr><td>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</td></tr></table>
I hope to show a few examples of using LCD's with Shift registers in this thread, but I'll start off with one that's been haunting me for awhile, then work on using Shift Registers to drive ANY HD44780 LCD a bit later.
<hr><a name="PC064PYL"></a><h2>PC064PYL</h2>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
<table border=1 ><tr><td>http://www.darreltaylor.com/files/PC064PYL/PC064PYL_Front.JPG<br><center>Running the Sample program shown below.</center></td><td>http://www.darreltaylor.com/files/PC064PYL/PC064PYL_Back.JPG</td></tr></table>
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.<font color="#0000FF"><b><i>; Initialize your Hardware first, set CONFIGs, OSC, Turn off A/D etc
;----[ Change these to match your LCD ]---------------------------------------
</i></b></font><b>LCD2x8_CLK </b><font color="#008000"><b>VAR </b></font><b>PORTB</b>.<font color="#800000"><b>0 </b></font><font color="#0000FF"><b><i>; Clock - Pin 1
</i></b></font><b>LCD2x8_DAT </b><font color="#008000"><b>VAR </b></font><b>PORTB</b>.<font color="#800000"><b>1 </b></font><font color="#0000FF"><b><i>; Data - Pin 2
</i></b></font><b>LCD2x8_E </b><font color="#008000"><b>VAR </b></font><b>PORTB</b>.<font color="#800000"><b>2 </b></font><font color="#0000FF"><b><i>; Enable - Pin 5
</i></b></font>
<font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">"PC064PYL.pbp" </font><font color="#0000FF"><b><i>; *** Include MUST be AFTER LCD Pin assignments ****
;----[ Your Main program starts here ]----------------------------------------
</i></b></font><b>LoopCount </b><font color="#008000"><b>VAR WORD
</b></font><b>Main</b>:
<font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$80</b></font>,<font color="#FF0000">"Hello,"</font>,<font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$C0</b></font>,<font color="#FF0000">"From DT!"
</font><font color="#008000"><b>PAUSE </b></font><font color="#800000"><b>3000
</b></font><font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>1 </b></font><font color="#0000FF"><b><i>; clear screen
</i></b></font><font color="#008000"><b>FOR </b></font><b>LoopCount </b>= <font color="#800000"><b>0 </b></font><font color="#008000"><b>TO </b></font><font color="#800000"><b>65535
</b></font><font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$80</b></font>, <font color="#008000"><b>IDEC </b></font><b>LoopCount
</b><font color="#008000"><b>LCDOUT </b></font><font color="#800000"><b>$FE</b></font>,<font color="#800000"><b>$C0</b></font>, <font color="#008000"><b>IHEX4 </b></font><b>LoopCount
</b><font color="#0000FF"><b><i>; pause 100 ; Slow it down, if you want
</i></b></font><font color="#008000"><b>NEXT </b></font><b>LoopCount
</b><font color="#008000"><b>GOTO </b></font><b>Main</b>
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.<hr>
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.<hr>
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.
<br>