Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

scroll message on LCD assembly code ?

Status
Not open for further replies.

vead

Full Member level 5
Full Member level 5
Joined
Nov 27, 2011
Messages
285
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
india
Visit site
Activity points
3,815
Hello ,
I am making small project on software
Microcontroller 8051
language assembly
assembler- 8051 IDE
upload_2015-3-1_23-39-57.png

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
ORG 0H
MOV A,#38H       ; command
ACALL COMNWRT    ;call command
ACALL DELAY       ;give LCD some time
MOV A,#0EH        ;display on, cursor on
ACALL COMNWRT     ;call command
MOV A,#01          ;clear LCD
ACALL COMNWRT       ;call command
ACALL DELAY       ;give LCD some time
MOV A,#06H        ;shift cursor right
ACALL COMNWRT    ;call command subroutine
ACALL DELAY       ;give LCD some time
MOV A,#84H        
ACALL COMNWRT ;call command
ACALL DELAY ;give LCD some time
MOV A,#'V' ;display letter J
ACALL DATAWRT ;call display
ACALL DELAY ;give LCD some time
MOV A,#'E' ;display letter J
ACALL DATAWRT ;call display
ACALL DELAY ;give LCD some time
MOV A,#'A' ;display letter J
ACALL DATAWRT ;call display
ACALL DELAY ;give LCD some time
MOV A,#'D' ;display letter D
ACALL DATAWRT ;call display
AGAIN: SJMP AGAIN ;stay here
COMNWRT: ;send command to LCD
MOV P1,A ;copy reg A to port 1
CLR P2.0 ;RS=0 for command
CLR P2.1 ;R/W=0 for write
SETB P2.2 ;E=1 for high pulse
ACALL DELAY ;give LCD some time
CLR P2.2 ;E=0 for H-to-L pulse
RET
DATAWRT: ;write data to LCD
MOV P1,A ;copy reg A to port 1
SETB P2.0 ;RS=1 for data
CLR P2.1 ;R/W=0 for write
SETB P2.2 ;E=1 for high pulse
ACALL DELAY ;give LCD some time
CLR P2.2
RET
DELAY: MOV R3,#50
HERE2: MOV R4,#255
HERE: DJNZ R4,HERE
DJNZ R3,HERE2
RET
END



can someone tell me why message are not scrolling continuously on LCD. whats wrong with code ?
 

Hi.
I couldn't spot any subroutine dedicated to scroll the displayed message. Would you tell me where you are sending command for scrolling?
Maybe you have to write command 18H after your message is displayed.
 

hello


do you want to scroll letter by letter or pixel by pixel ?
if think 0x18h LCD Cde is for letter shift .. (not sure, to confirm by other ?)


for pixel by pixel you must use the Char Police definition (5x7 or 6x8) and use a LCD with grafic access
like a Nokia 5110 or other to be able to change only a pixel not a complete char at each time.

i did a moving message of 32 cars ,pixel by pixel ,on a POV(HAPR) clock.
in asm MPLAB 16F876..
you can have a look on it to understand How To do it.

- Define what is your maximum length of message to display
- at what speed ? any second ?
- what is the resolution of one char (5x7 or 6x8 or ?) ?
-so you can define a elementary pixel clock wich is the base of the application
the main difficulty is the frontiere (limite) between 2 caracteres .. on pixel belong to the previous char, the following pixel belong to the next char

it is a very good subject to learn about algorytm and software.
 

Hi.
I couldn't spot any subroutine dedicated to scroll the displayed message. Would you tell me where you are sending command for scrolling?
Maybe you have to write command 18H after your message is displayed.
Hello Genovator,
I wrote that command but my message ''vead" is not scrolling on lcd

- - - Updated - - -

hello


do you want to scroll letter by letter or pixel by pixel ?
if think 0x18h LCD Cde is for letter shift .. (not sure, to confirm by other ?)


for pixel by pixel you must use the Char Police definition (5x7 or 6x8) and use a LCD with grafic access
like a Nokia 5110 or other to be able to change only a pixel not a complete char at each time.

i did a moving message of 32 cars ,pixel by pixel ,on a POV(HAPR) clock.
in asm MPLAB 16F876..
you can have a look on it to understand How To do it.

- Define what is your maximum length of message to display
- at what speed ? any second ?
- what is the resolution of one char (5x7 or 6x8 or ?) ?
-so you can define a elementary pixel clock wich is the base of the application
the main difficulty is the frontiere (limite) between 2 caracteres .. on pixel belong to the previous char, the following pixel belong to the next char

it is a very good subject to learn about algorytm and software.
I want scroll message ''VEAD'' continuously on LCD
 

I don't know 8051 MCU ( PIC only).

Are you able to acces a pixel of a char ?
Traditional LCD are mainly used char by char.
maybe trougth CGRAM of LCD, but CGRAM is limited in size
and used to redefine any char , not all of them..

I prefere to use Nokia LCD 3310 ,ie 8 lines of 16 cars (or Nokia 5110 6 lines of 14cars)
all char are defined inside the program memory area.
So the programm can acces at each collum witch buid one char = pixel position
and possible to shift from one pixel position to the next one.
 

Hello Genovator,
I wrote that command but my message ''vead" is not scrolling on lcd

Can you locate for me in your code where you written that command? I am not sure if pixel shift is available in a 16x2 LCD controller. Couldn't found it in datasheets though. But for char shift, try adding the following after line 26 in the code of post #1:

MOV A,#018H
ACALL COMNWRT
*Call for a delay and repeat the command.


Didn't tested, but it should work.
 

Can you locate for me in your code where you written that command? I am not sure if pixel shift is available in a 16x2 LCD controller. Couldn't found it in datasheets though. But for char shift, try adding the following after line 26 in the code of post #1:

MOV A,#018H
ACALL COMNWRT
*Call for a delay and repeat the command.


Didn't tested, but it should work.
I did what you said
Code:
ORG 0H
MOV A,#38H       ; command
ACALL COMNWRT    ;call command
ACALL DELAY       ;give LCD some time
MOV A,#0EH        ;display on, cursor on
ACALL COMNWRT     ;call command
MOV A,#01          ;clear LCD
ACALL COMNWRT       ;call command
ACALL DELAY       ;give LCD some time
MOV A,#06H        ;shift cursor right
ACALL COMNWRT    ;call command subroutine
ACALL DELAY       ;give LCD some time
MOV A,#84H        
ACALL COMNWRT ;call command
ACALL DELAY ;give LCD some time
MOV A,#'V' ;display letter J
ACALL DATAWRT ;call display
ACALL DELAY ;give LCD some time
MOV A,#'E' ;display letter J
ACALL DATAWRT ;call display
ACALL DELAY ;give LCD some time
MOV A,#'A' ;display letter J
ACALL DATAWRT ;call display
ACALL DELAY ;give LCD some time
MOV A,#'D' ;display letter D
ACALL DATAWRT ;call display

MOV A,#018H
ACALL COMNWRT
AGAIN: SJMP AGAIN ;stay here
COMNWRT: ;send command to LCD
MOV P1,A ;copy reg A to port 1
CLR P2.0 ;RS=0 for command
CLR P2.1 ;R/W=0 for write
SETB P2.2 ;E=1 for high pulse
ACALL DELAY ;give LCD some time
CLR P2.2 ;E=0 for H-to-L pulse
RET
DATAWRT: ;write data to LCD
MOV P1,A ;copy reg A to port 1
SETB P2.0 ;RS=1 for data
CLR P2.1 ;R/W=0 for write
SETB P2.2 ;E=1 for high pulse
ACALL DELAY ;give LCD some time
CLR P2.2
RET
DELAY: MOV R3,#50
HERE2: MOV R4,#255
HERE: DJNZ R4,HERE
DJNZ R3,HERE2
RET
END
but still message not scrolling
 

Try the codes here...

Code:
	ORG 	0H
RS	EQU	P2.0
RW	EQU	P2.1
EN	EQU	P2.2
PDATA	EQU	P1

MAIN:
	ACALL	INIT	;INITIALIZE LCD
DISPLAY:		;DISPLAY 'VEAD VEAD VEAD'
	MOV	DPTR,#MESSAGE	;POINT DPTR TO BRGINNING OF MESSAGE
DLOOP:	CLR	A	;CLEAR ACC
	MOVC	A,@A+DPTR
	JNZ	DISP1
	ACALL	SCROLL	
HERE:	AJMP	HERE	;STOP HERE

;------------------------------------------------------
DISP1:	ACALL	DATAWRT	;DISPLAY TEXT IN ACC
	ACALL	DELAY
	INC	DPTR
	AJMP	DLOOP

MESSAGE: DB	'VEAD VEAD VEAD  '  ;TEXT TO PRINT ON LCD
	 DB	00	;END OF TEXT	

;-------------------------------------------------------
SCROLL:
	MOV	R5,#18
SLOOP:	ACALL	ROTATE_RIGHT
	DJNZ	R5,SLOOP
	RET

ROTATE_LEFT:		;FOR SCROLLING LEFT TO RIGHT
        CLR 	RS
        MOV 	PDATA,#18h
        SETB 	EN
        CLR 	EN
        ACALL 	DELAY
        ACALL 	DELAY
        ACALL 	DELAY
	RET

ROTATE_RIGHT:		;FOR SCROLLING RIGHT TO LEFT
        CLR 	RS
        MOV 	PDATA,#1Eh
        SETB 	EN
        CLR 	EN
        ACALL 	DELAY
        ACALL 	DELAY
        ACALL 	DELAY
	RET

;----------------------------------------------
INIT:	MOV A,#38H       ; initialize LCD
	ACALL COMNWRT
	ACALL DELAY 
	MOV A,#0EH        ;display on, cursor on
	ACALL COMNWRT 
	MOV A,#01          ;clear LCD
	ACALL COMNWRT 
	ACALL DELAY  
	MOV A,#06         ;shift cursor right
	ACALL COMNWRT    
	ACALL DELAY
	MOV A,#80H 
	ACALL COMNWRT
	ACALL DELAY
	RET

COMNWRT: 		;send command to LCD
	MOV PDATA,A 	;copy reg A to port 1
	CLR RS 		;RS=0 for command
	CLR RW 		;R/W=0 for write
	SETB EN 	;E=1 for high pulse
	ACALL DELAY 	
	CLR EN 		;E=0 for H-to-L pulse
	RET

DATAWRT: 		;write data to LCD
	MOV PDATA,A 	;copy reg A to port 1
	SETB RS 	;RS=1 for data
	CLR RW	 	;R/W=0 for write
	SETB EN 	;E=1 for high pulse
	ACALL DELAY 	
	CLR EN
	RET

;-----------delay subroutine--------------------	
DELAY: 	MOV R3,#50
DEL2: 	MOV R4,#255
DEL: 	DJNZ R4,DEL
	DJNZ R3,DEL2
	RET

	END

Allen
 

Attachments

  • LCD SCROLL VEAD.PNG
    LCD SCROLL VEAD.PNG
    41.1 KB · Views: 260
Try the codes here...

Code:
	ORG 	0H
RS	EQU	P2.0
RW	EQU	P2.1
EN	EQU	P2.2
PDATA	EQU	P1

MAIN:
	ACALL	INIT	;INITIALIZE LCD
DISPLAY:		;DISPLAY 'VEAD VEAD VEAD'
	MOV	DPTR,#MESSAGE	;POINT DPTR TO BRGINNING OF MESSAGE
DLOOP:	CLR	A	;CLEAR ACC
	MOVC	A,@A+DPTR
	JNZ	DISP1
	ACALL	SCROLL	
HERE:	AJMP	HERE	;STOP HERE

;------------------------------------------------------
DISP1:	ACALL	DATAWRT	;DISPLAY TEXT IN ACC
	ACALL	DELAY
	INC	DPTR
	AJMP	DLOOP

MESSAGE: DB	'VEAD VEAD VEAD  '  ;TEXT TO PRINT ON LCD
	 DB	00	;END OF TEXT	

;-------------------------------------------------------
SCROLL:
	MOV	R5,#18
SLOOP:	ACALL	ROTATE_RIGHT
	DJNZ	R5,SLOOP
	RET

ROTATE_LEFT:		;FOR SCROLLING LEFT TO RIGHT
        CLR 	RS
        MOV 	PDATA,#18h
        SETB 	EN
        CLR 	EN
        ACALL 	DELAY
        ACALL 	DELAY
        ACALL 	DELAY
	RET

ROTATE_RIGHT:		;FOR SCROLLING RIGHT TO LEFT
        CLR 	RS
        MOV 	PDATA,#1Eh
        SETB 	EN
        CLR 	EN
        ACALL 	DELAY
        ACALL 	DELAY
        ACALL 	DELAY
	RET

;----------------------------------------------
INIT:	MOV A,#38H       ; initialize LCD
	ACALL COMNWRT
	ACALL DELAY 
	MOV A,#0EH        ;display on, cursor on
	ACALL COMNWRT 
	MOV A,#01          ;clear LCD
	ACALL COMNWRT 
	ACALL DELAY  
	MOV A,#06         ;shift cursor right
	ACALL COMNWRT    
	ACALL DELAY
	MOV A,#80H 
	ACALL COMNWRT
	ACALL DELAY
	RET

COMNWRT: 		;send command to LCD
	MOV PDATA,A 	;copy reg A to port 1
	CLR RS 		;RS=0 for command
	CLR RW 		;R/W=0 for write
	SETB EN 	;E=1 for high pulse
	ACALL DELAY 	
	CLR EN 		;E=0 for H-to-L pulse
	RET

DATAWRT: 		;write data to LCD
	MOV PDATA,A 	;copy reg A to port 1
	SETB RS 	;RS=1 for data
	CLR RW	 	;R/W=0 for write
	SETB EN 	;E=1 for high pulse
	ACALL DELAY 	
	CLR EN
	RET

;-----------delay subroutine--------------------	
DELAY: 	MOV R3,#50
DEL2: 	MOV R4,#255
DEL: 	DJNZ R4,DEL
	DJNZ R3,DEL2
	RET

	END

Allen
hello Allen
thank you for help I tried your code but same problem. now message repeating in only one time. message should be repeat continuously
 

I tested the 018H command in proteus in the same way I described in post #8. It works on simulation. Have you repeated the command after a specific interval of time? You have to write 018H every after 1 sec delay to scroll the message with a one sec interval.

hello Allen
thank you for help I tried your code but same problem. now message repeating in only one time. message should be repeat continuously
Do you want someone to make the complete code for you? Its your task and you have to do it. We members will try to identify the problem for you, and can give you suggestions. Now as you see neither @Allen's, nor my codes have any infinite loops to repeat the scrolling, you can add it by yourself. All you have to do is do some magic on "HERE: AJMP HERE" loop. ;-)
 
The discussion is somehow confusing. It can be clearly read from LCD datasheets that the 0x18 shift command is shifting by one character position. So pixel shift as claimed in post #6 doesn't work.

pauljulfo suggested a way to implement pixel shift utilizing CGRAM, but it's way beyond the simple codes shown in this thread. Also it doesn't look so well on a character LCD display with its void between characters. But a good coding exercise though.
 

hello Allen
thank you for help I tried your code but same problem. now message repeating in only one time. message should be repeat continuously

Like Genovator said....... if I gave you the complete solution on a silver plate, you would not be bothered to study and understand how the program works.

But still I think I have given you 99% of what you wanted. You just need to put 1% of effort on your part.

Allen
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top