PDA

View Full Version : LCD Showes Some Wrong Letters



sbobowski
- 7th September 2008, 15:22
hello,
Never posted here before. But I do read a lot.
Any way maybe this will help some one starting out with LCD's
I use Pic Basic Pro Version 2.50a
Micro Code Studio Version 3.0.0.5
I have A Microchip PIC 12F628A
and a Hantronix HDM20216L-1 20x2 LCD

I started off with the "Hello World" LCD Toturial.
plugged in a chip, set the right chip in PBP, programed it up, soldered a few test leads to my lcd. and this is what i got

Code: -------------------------------------------------------------------
Pause 500 ' Wait for LCD to startup

loop: Lcdout $fe, 1 ' Clear LCD screen
Lcdout "Hello" ' Display Hello
Pause 500 ' Wait .5 second

Lcdout $fe, 1 ' Clear LCD screen
Lcdout "World"
Pause 500 ' Wait .5 second

Goto loop ' Do it forever

-------------------------------------------------------------------
Screen 1: Hello

Screen2: HelloWo ld

(well this is wrong! Hello was suppose to disappear and last i checked "Wo ld" had an r in the middle)

ok lets modify the code and try something new

new code: -------------------------------------------------------------------

Pause 1000 ' Wait for LCD to startup

loop: Lcdout $fe, 1 ' Clear LCD screen
lcdout $fe, $80
pause 1000
Lcdout "abcdefghijklmnopqrst" ' Display Hello
lcdout $fe, $c0
Lcdout "uvwxyz0123456789ABCD"
pause 1000

Lcdout $fe, 1 ' Clear LCD screen
lcdout $fe, $80
pause 1000
Lcdout "EFGHIJKLMNOPQRSTUVWX" ' Display Hello
lcdout $fe, $c0
Lcdout "VZ~!@#$%^&*()_+-=,.?"
pause 1000

Goto loop ' Do it forever
END

-------------------------------------------------------------------
Screen 1:
abcdefghijklmno7qrst
uvwxyz0123456789ABCD

Screen 2:
EFGHIJKLMNO QRSTUVWX
YZ>!@#$%^&*()_2-= .?

ok still not even close since when is "p" = "7" and "~" = a right arrow, "+" = "2", and a comma = nothing.

new thought maybe i have a bad wire, maybe i have a non compatible LCD, maybe I'm a rock

well the answer is number three, after reading lots and finding nothing, i found a post about an LCD with a gridded out screen. several posts in the thread someone suggested that he had spelled CMCON = 7 wrong
then i thought i don't have a turn off analog statement in my code.
guess what,
that's it works like a champ

my only question is what if i need a analog input? say i want a battery meter on my project.
now what i have no analog ports, can anyone suggest something for me

Melanie
- 7th September 2008, 17:09
Hi and welcome to the forum.

You do not have to use the pins in the schematic in the manual for your LCD. You can assign other PIC pins for LCD usage by using the various DEFINE LCD statements. So, in that case, you can reassign the LCD to use other Ports/Pins leaving your Analog pins free.

Here is an example where all the Data and Register connections for an LCD have been assigned to PortC... (PIC16F876)...


Define LCD_DREG PORTC ' Port for LCD Data
Define LCD_DBIT 4 ' Use upper 4 bits of Port
Define LCD_RSREG PORTC ' Port for RegisterSelect (RS) bit
Define LCD_RSBIT 3 ' Port Pin for RS bit
Define LCD_EREG PORTC ' Port for Enable (E) bit
Define LCD_EBIT 0 ' Port Pin for E bit
Define LCB_BITS 4 ' Using 4-bit bus
Define LCD_LINES 2 ' Using 2 line Display
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)

sbobowski
- 23rd September 2008, 19:15
Works GREAT thank you!!
i did it on a pic16f628A and moved them to Port.B