Rhatidbwoy
- 18th December 2005, 22:06
luciano.
thanks for the concern for everything that i have posted on this forum. I got many things to work since I started to write to this forum. xtal problem i fixed with INTRC. The first lcd problem I got to work with the contrast setting. The seond lcd is a hantronix and that is were I am having problems.
The hantronix screen that I have is the hdm-20416h. The contrast should be controlled with either a single or dual power source. I tried the single and that did not work. I am now working with a dual power source for the contrast and that works. It is not much that it needs dual power source but that it need to have more than 5volt to work. The second problem that I have with the hantronix screen is that the line address is not correct. Line 1 starts with $00 but to go any further into the line i can not do. Line 2 threw 4 is not to what the hantronix reccomend, but it is $C0, $94, $D4 . Those are the line addresses that I have figured out and what I have gotten to work so far. I am having a time trying to figure out what is happenning with line 1, but that is nothing more than the other problems that I had. Time will tell in getting it to work.
Thank you again for suggestion that I could use for figuring out timing issues.
The code that I am using is as follows:
' PicBasic program to demonstrate operation of an LCD in 4-bit mode
' PIC16F628
' LCD should be connected as follows:
' LCD PIC
' DB4 PortA.0
' DB5 PortA.1
' DB6 PortA.2
' DB7 PortA.3
' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
' E PortB.3
' RW Ground
' Vdd 5 volts
' Vss Ground
' Vo 20K potentiometer (or ground)
' DB0-3 No connect
Pause 1000 ' Wait for LCD to startup
CMCON = 7
loop: Lcdout $fe, 1 ' Clear LCD screen
lcdout $FE, $00 + 0, "LINE 1"
lcdout $FE, $C0 + 0, "LINE 2"
lcdout $FE, $94 + 0, "LINE 3"
lcdout $FE, $D4 + 0, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
lcdout $FE, $00 + 1, "LINE 1"
lcdout $FE, $C0 + 1, "LINE 2"
lcdout $FE, $94 + 1, "LINE 3"
lcdout $FE, $D4 + 1, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
lcdout $FE, $00 + 2, "LINE 1"
lcdout $FE, $C0 + 2, "LINE 2"
lcdout $FE, $94 + 2, "LINE 3"
lcdout $FE, $D4 + 2, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
lcdout $FE, $00 + 3, "LINE 1"
lcdout $FE, $C0 + 3, "LINE 2"
lcdout $FE, $94 + 3, "LINE 3"
lcdout $FE, $D4 + 3, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
lcdout $FE, $00 + 4, "LINE 1"
lcdout $FE, $C0 + 4, "LINE 2"
lcdout $FE, $94 + 4, "LINE 3"
lcdout $FE, $D4 + 4, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 5, "LINE 1"
lcdout $FE, $C0 + 5, "LINE 2"
lcdout $FE, $94 + 5, "LINE 3"
lcdout $FE, $D4 + 5, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 6, "LINE 1"
lcdout $FE, $C0 + 6, "LINE 2"
lcdout $FE, $94 + 6, "LINE 3"
lcdout $FE, $D4 + 6, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 7, "LINE 1"
lcdout $FE, $C0 + 7, "LINE 2"
lcdout $FE, $94 + 7, "LINE 3"
lcdout $FE, $D4 + 7, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 8, "LINE 1"
lcdout $FE, $C0 + 8, "LINE 2"
lcdout $FE, $94 + 8, "LINE 3"
lcdout $FE, $D4 + 8, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 9, "LINE 1"
lcdout $FE, $C0 + 9, "LINE 2"
lcdout $FE, $94 + 9, "LINE 3"
lcdout $FE, $D4 + 9, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 10, "LINE 1"
lcdout $FE, $C0 + 10, "LINE 2"
lcdout $FE, $94 + 10, "LINE 3"
lcdout $FE, $D4 + 10, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 11, "LINE 1"
lcdout $FE, $C0 + 11, "LINE 2"
lcdout $FE, $94 + 11, "LINE 3"
lcdout $FE, $D4 + 11, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 12, "LINE 1"
lcdout $FE, $C0 + 12, "LINE 2"
lcdout $FE, $94 + 12, "LINE 3"
lcdout $FE, $D4 + 12, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 13, "LINE 1"
lcdout $FE, $C0 + 13, "LINE 2"
lcdout $FE, $94 + 13, "LINE 3"
lcdout $FE, $D4 + 13, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 14, "LINE 1"
lcdout $FE, $C0 + 14, "LINE 2"
lcdout $FE, $94 + 14, "LINE 3"
lcdout $FE, $D4 + 14, "LINE 4"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 15, "LINE "
lcdout $FE, $C0 + 15, "LINE "
lcdout $FE, $94 + 15, "LINE "
lcdout $FE, $D4 + 15, "LINE "
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 16, "LINE"
lcdout $FE, $C0 + 16, "LINE"
lcdout $FE, $94 + 16, "LINE"
lcdout $FE, $D4 + 16, "LINE"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 17, "LIN"
lcdout $FE, $C0 + 17, "LIN"
lcdout $FE, $94 + 17, "LIN"
lcdout $FE, $D4 + 17, "LIN"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 18, "LI"
lcdout $FE, $C0 + 18, "LI"
lcdout $FE, $94 + 18, "LI"
lcdout $FE, $D4 + 18, "LI"
pause 2000
Lcdout $fe, 1 ' Clear LCD screen
'lcdout $FE, $00 + 19, "L"
lcdout $FE, $C0 + 19, "L"
lcdout $FE, $94 + 19, "L"
lcdout $FE, $D4 + 19, "L"
PAUSE 250
GOTO LOOP
Luciano
- 19th December 2005, 10:26
Hi
When you power-up the LCD, its cursor position is on line 1 position 1.
The LCD does that automatically. Also when you clear the LCD the
cursor will go back to line 1 position 1.
So if just after LCD power-up or after a LCD clear you write the PicBasic code ....
Lcdout "test"
... the word "test" will be displayed one line 1 and will use the first 4 locations on line 1.
* * *
To input instructions to the LCD module, such as clear screen, go to line 2, etc., you
must prefix the instruction with 254 (0xFE). The byte following prefix is seen and
treated as a instruction code. After the instruction code, the LCD automatically returns
to text mode. Every instruction code must be sent with its own 254 prefix (0xFE).
Cursor position on a four lines LCD:
To move the cursor to the beginning of the first line and display a text you will need
to send the prefix $FE, the instruction code $80 and the text to be displayed.
Example:
LCDOUT $FE,$80, "Hello on line 1"
To move the cursor to the beginning of the second line and display a text you will need
to send the prefix $FE, the instruction code $C0 and the text to be displayed.
Example:
LCDOUT $FE,$C0, "Hello on line 2"
To move the cursor to the beginning of the third line and display a text you will need
to send the prefix $FE, the instruction code $94 and the text to be displayed.
Example:
LCDOUT $FE,$94, "Hello on line 3"
To move the cursor to the beginning of the fourth line and display a text you will need
to send the prefix $FE, the instruction code $D4 and the text to be displayed.
Example:
LCDOUT $FE,$D4, "Hello on line 4"
* * *
In your program, just after LCD power-up or just after a display clear you send:
lcdout $FE, $00 + 0, "LINE 1"
With the above code you just send a NOP instruction ($0) to the LCD controller.
(NOP = Short for No OPeration). The LCD controller ignores your NOP instruction and
will stay on line 1 position 1 and the output text "LINE 1" will go
on line 1 position 1 because you don't have changed the LCD cursor position.
Try to write a text on line 2 and then, without clearing line 2, go to line 1 and write a text on line 1.
If you tray that you will understand the purpose of the PicBasic code
LCDOUT $FE,$80, "Hello on line 1".
Best regards,
Luciano
Luciano
- 20th December 2005, 09:39
Hi,
The compiler will take care for the right LCD timing, no
need to insert pauses. The compiler can do that for you only if
you specify the used oscillator. If you don't specify the oscillator
frequency, PicBasic Pro assumes that you are using a 4MHz oscillator.
If you are using a 20 MHz oscillator, DEFINE OSC 20 is mandatory.
If you don't do that, LCDOUT will not work with the right timing.
LCDOUT is not the only PicBasic command that needs correct timing.
(See PicBasic Pro manual).
DEFINE OSC xy tells the compiler the oscillator frequency and
the compiler will output an HEX file with all the delays calculated
for that oscillator frequency.
Make sure your PIC is also using the same oscillator frequency.
(Your harware is also using the same oscillator frequency).
To test that, go back to my first post in this thread, and try
to compile the flashing LED program and flash the PIC with it.
(Make sure you use DEFINE OSC xy in the code).
Examples:
DEFINE OSC 4 'Oscillator speed 4 MHz
DEFINE OSC 20 'Oscillator speed 20 MHz
See PicBasic Pro manual for all the possible values of DEFINE OSC.
There is a list of DEFINEs in the PicBasic Pro manual and some are for
the LCD configuration. Some of these DEFINEs can help in case you are
using an exotic LCD controller. (NOT the case for Hantronix).
* * *
The addresses you see in the Hantronix spec sheet are the
display RAM Map addresses. The Hantronix spec sheet is correct, no
errors in it.
Best regards,
Luciano
Rhatidbwoy
- 21st December 2005, 21:34
i got that part. luciano I get what you are saying. we are just getting crossed with the explanation.
ok get this. I am having problems with my program. I would like for the pointer that I have in my project (transmitter) to go to line four. I have the pointer start in column 2 on the LCD and go up and down. There are three screens that this pointer shows up on and the first screen it works on. The first screen it starts on the second line second column then goes down to line four. The problem that I am having is that I would like for this to happen on the second page also, go from line one to four then scroll to page three, but I can not get it to go down to line four. I have checked the program (transmitter) numerous amount of time and I can not seem to find what the problem is. Do you have any idea on that.
Where it starts:
CHANNELS:
line = linet
line = linet1
screen = screent
line = $81:val = $8E
CHANNELSA:
screen = 2
lcdout $FE, 1
pause 10
lcdout $FE, $93, CS1
lcdout $FE, $D3, CS2
lcdout $FE, $83, "Channel 1:"
lcdout $FE, $C3, "Channel 2:"
lcdout $FE, $97, "Channel 3:"
lcdout $FE, $D7, "Channel 4:"
gosub subval
gosub value
gosub pointer
pause 500
CHANNELSB:
goto channels1b
CHANNELS1B:
if PortB.7 = 1 or PortB.6 = 1 or PortB.5 = 1 or PortB.4 = 1 then pause 300
if PortB.7 = 1 or PortB.6 = 1 or PortB.5 = 1 or PortB.4 = 1 then CHANNELS1C
goto CHANNELS1B
CHANNELS1C:
if PortB.6 = 1 and PortB.7 = 1 then pause 300
if PortB.6 = 1 and PortB.7 = 1 then enter
if PortB.5 = 1 then meninc
if PortB.4 = 1 then mendec
if PortB.7 = 1 then chlinc
if PortB.6 = 1 then chldec
goto channels1b
This is where I think the problem is:
MENINC:
if line = $81 and Screen = 2 or screen = 3 then Line2
if line = $C1 and Screen = 1 or screen = 2 or screen = 3 then line3
if line = $95 and screen = 1 or screen = 2 then line4
if line = $D5 and screen = 2 then channels1 ' Scroll to page 3
goto scren
MENDEC:
if line = $D5 and screen = 1 or screen = 2 then line3
if line = $95 and screen = 1 or screen = 2 or screen = 3 then line2
if line = $C1 and screen = 2 or screen = 3 then line1
if line = $81 and screen = 3 then line4s ' Scroll to page 2
goto scren
LINE1: line = $81:val = $8E:goto scren
LINE2: line = $C1:val = $CE:goto scren
LINE3: line = $95:val = $A2:goto scren
LINE4: Line = $D5:val = $E2:goto scren
LINE4S: line = $D5:val = $E2:goto channelsa
Program continues with the loop:
SCREN:
if screen = 1 then menua
if screen = 2 then channelsa
if screen = 3 then channels1a
P.S. the program is posted earlier in the forum
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.