Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 2nd May 2008, 10:36 AM   (permalink)
Default LCD 2x16 animation

Dear,

I now doing some animation (moving text/scrolling text) in the LCD 2x16. How to do that? Any example code? I can't find any. I just want to do a simple moving the text from left to right and continuously moving. Please help.

Last edited by Paris Heng; 2nd May 2008 at 10:48 AM.
Paris Heng is offline  
Reply With Quote
Old 2nd May 2008, 11:01 AM   (permalink)
Default

Quote:
Originally Posted by Paris Heng
Dear,

I now doing some animation (moving text/scrolling text) in the LCD 2x16. How to do that? Any example code? I can't find any. I just want to do a simple moving the text from left to right and continuously moving. Please help.
hi,
Its like this;
movlw 0x1C;move all 1 right
call lcd_cmd

movlw 0x18; move all 1 left
call lcd_cmd

Do you follow.?

EDIT: which PIC are you using and how do you have it connected.?
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 2nd May 2008 at 11:15 AM.
ericgibbs is online now  
Reply With Quote
Old 2nd May 2008, 11:23 AM   (permalink)
Default

Quote:
Originally Posted by ericgibbs
hi,
Its like this;
movlw 0x1C;move all 1 right
call lcd_cmd

movlw 0x18; move all 1 left
call lcd_cmd

Do you follow.?

EDIT: which PIC are you using and how do you have it connected.?
AT80S52. But i write in C code. Can you show me the C code? I am newbie. What is 0x1C? and 0x18 for? It is for LCD position?

Thank your reply again.

Last edited by Paris Heng; 2nd May 2008 at 11:37 AM.
Paris Heng is offline  
Reply With Quote
Old 2nd May 2008, 11:49 AM   (permalink)
Default

Those are control codes for the LCD - basically most LCD's are really 2x40 in size, with the actual display a 'window' on to that screen buffer. Those control codes scroll the window along the buffer.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 2nd May 2008, 12:04 PM   (permalink)
Default

hi.
As Nigel points out these are control codes for the LCD.

You must have initialised the LCD anyway in 'C' in order to display text.?

So, use the same LCD command instruction call that you used to initialise the LCD, except insert the 1CHand 18H to do SHIFTs.

If you dont follow, post the initialise code section from your 'C' program and we will try to help...
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now  
Reply With Quote
Old 2nd May 2008, 12:25 PM   (permalink)
Default

Quote:
Originally Posted by ericgibbs
hi.
As Nigel points out these are control codes for the LCD.

You must have initialised the LCD anyway in 'C' in order to display text.?

So, use the same LCD command instruction call that you used to initialise the LCD, except insert the 1CHand 18H to do SHIFTs.

If you dont follow, post the initialise code section from your 'C' program and we will try to help...
The code i actually refer to Ajay Bhargav from 8051 forum. Below is the code for the LCD,

lcd.c
Quote:
#include "ports.h"
#include "lcd.h"

bit_8 code *intro[]={" Digi clock by:"," Ajay Bhargav "};
bit_8 code cgram[]={0x4,0xe,0xe,0xe,0x1f,0x0,0x4,0x0,0x1,0x3,0xf,0xf ,0xf,0x3,0x1,0x0,0x8,0x10,0x0,0x18,0x0,0x10,0x8,0x 0,0x0,0xe,0x15,0x17,0x11,0xe,0x0,0x0,0x0,0x1,0x3,0 x16,0x1c,0x8,0x0,0x0,0xa,0x1f,0x1f,0x1f,0xe,0x4,0x 0,0x0,0x2,0x3,0x2,0x0e,0x1e,0x0c,0x0,0x0};

void busy()
{
D7=1;
rs=0;
rw=1;
while(D7!=0)
{
en=0;
en=1;
}
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**** Writing command to LCD ****
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void wrt_cmd(bit_8 val_lcd)
{
busy();
lcd_port=val_lcd;
rs=0;
rw=0;
en=1;
en=0;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~
**** Writing data on LCD ****
~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

void wrt_data(bit_8 *string)
{
bit_8 i;
for(i=0;string[i]!='\0';i++)
wrt_byte(string[i]);
}

void wrt_byte(bit_8 value)
{
busy();
lcd_port=value;
rs=1;
rw=0;
en=1;
en=0;
}

void LCD_INI(void)
{
wrt_cmd(0X38);
wrt_cmd(0X0C);
wrt_cmd(0X01);
wrt_cmd(0X06);
}

void build_ram()
{
bit_8 i;
wrt_cmd(0x40);
for(i=0;i<56;i++)
wrt_byte(cgram[i]);
}

void disp_intro()
{
bit_8 i;
bit_16 j;
wrt_cmd(0x80);
wrt_byte(CLOCK);
wrt_data(intro[0]);
wrt_cmd(0xc0);
wrt_byte(HEART);
wrt_data(intro[1]);
wrt_byte(HEART);
for(i=0x5;i>0;i--)
for(j=0xffff;j>0;j--);
}
lcd.h
Quote:
#ifndef __LCD_H__
#define __LCD_H__

#include "ports.h"

void wrt_cmd(bit_8);
void wrt_data(bit_8*);
void LCD_INI(void);
void busy(void);
void wrt_byte(bit_8);
void build_ram();
void disp_const(void);
void disp_intro(void);

#endif
How to write the scrolling text? Example I wan to scroll a test "Welcome". I want to scroll the text in void disp_intro(). Mean the intro.

Please assist with some basic C code.

Last edited by Paris Heng; 2nd May 2008 at 12:29 PM.
Paris Heng is offline  
Reply With Quote
Old 2nd May 2008, 12:59 PM   (permalink)
Default

hi,
I am not a 'C' programmer, but this section looks like the init code for the LCD

void LCD_INI(void)
{
wrt_cmd(0X38);
wrt_cmd(0X0C);
wrt_cmd(0X01);
wrt_cmd(0X06);
}

Write your message to the LCD, so that its visible then
try something like

{wrt_cmd(0x1C)} for Right SHIFT

Perhaps a member who uses 'C' will give more help.
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now  
Reply With Quote
Old 2nd May 2008, 01:18 PM   (permalink)
Default

Quote:
Originally Posted by ericgibbs
hi,
I am not a 'C' programmer, but this section looks like the init code for the LCD

void LCD_INI(void)
{
wrt_cmd(0X38);
wrt_cmd(0X0C);
wrt_cmd(0X01);
wrt_cmd(0X06);
}

Write your message to the LCD, so that its visible then
try something like

{wrt_cmd(0x1C)} for Right SHIFT

Perhaps a member who uses 'C' will give more help.
I try 1st, hope someone use C can help me
Paris Heng is offline  
Reply With Quote
Old 3rd May 2008, 08:14 AM   (permalink)
Default

Eric is correct, you need to write command 0x18 to scroll left and 0x1c to scroll right.

This will scroll the display around once.
Code:
    for(i=0;i<40;i++){
        wrt_cmd(0x18);
        DelaymS(100);
    }
Mike.
Pommie is offline  
Reply With Quote
Old 3rd May 2008, 07:08 PM   (permalink)
Exclamation SCROLLING TEXT ON 2x16 LCD USING 8051

May be this code helps you...there may be much room for improvement of this code but i am not very much concerned with it...my main concern is the i want it improved in this regard that it should keep on scrolling the text of any lenght without breaks whereas below given code does not do it for me...
thanx in advance.



;----------------------------------------------------------------------
;----------------------------------------------------------------------
DB0 EQU P1.0
DB1 EQU P1.1
DB2 EQU P1.2
DB3 EQU P1.3
DB4 EQU P1.4
DB5 EQU P1.5
DB6 EQU P1.6
DB7 EQU P1.7
RS EQU P3.3
RW EQU P3.4
EN EQU P3.5

ORG 300H
DB "THIS CODE IS WRITTEN BY MEHMOOD AHMED FOR 8051"
DB "MICROCONTROLLER",0

ORG 00H
START:
ACALL INITLCD
MOV A,#0H
MOV DPTR,#0300H
MAIN:
ACALL COMMANDDELAY
CLR EN
PUSH ACC
CJNE A,#170,ISLESS
CALL SCROLLDELAY
MOV A,#0H
ISLESS:
JZ HERE
MOV B,#40
DIV AB
MOV A,B
JNZ HERE
MOV A,#02H
ACALL COMMAND
HERE:
POP ACC
PUSH ACC
MOVC A,@A+DPTR
ACALL WRITECOMMAND
POP ACC
INC A
LJMP MAIN
COMMAND:
CLR RS
CLR RW
MOV P1,A
SETB EN
ACALL COMMANDDELAY
CLR EN
RET
WRITECOMMAND:
ACALL SCROLLDELAY
ACALL SCROLLDELAY
SETB RS
CLR RW
MOV P1,A
SETB EN
ACALL COMMANDDELAY
CLR EN
RET
INITLCD:
MOV A,#30H
ACALL COMMAND
MOV A,#30H
ACALL COMMAND
MOV A,#30H
ACALL COMMAND
MOV A,#07H
ACALL COMMAND
MOV A,#0cH
ACALL COMMAND
;MOV A,#010h
;ACALL COMMAND
RET
COMMANDDELAY:
MOV R1,#20H
LOOP2: MOV R0,#20H
LOOP1: DJNZ R0,LOOP1
DJNZ R1,LOOP2
RET
SCROLLDELAY:
MOV R3,#2H
LOOPX3:
MOV R2,#90H
LOOPX2: MOV R1,#90H
LOOPX1: DJNZ R1,LOOPX1
DJNZ R2,LOOPX2
DJNZ R3,LOOPX3
RET
LCDWAIT:
PUSH ACC
CLR A
WAIT:
CLR RS
SETB WR
SETB EN
MOV P1,#0FFH
MOV A,P1
CLR EN
JB ACC.7,WAIT
POP ACC
RET
END
Mehmood Ahmed is offline  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Bunch of questions regarding PIC, PCB fabrication, LCD interfacing and PIC-C xieliwei Electronic Projects Design/Ideas/Reviews 9 3rd May 2008 09:12 AM
LCD 2x16 Demo for the Unicorn (18F4550) blueroomelectronics Micro Controllers 20 11th April 2008 08:08 PM
LCD Bargraph (fuel gauge) karenhornby Micro Controllers 10 10th April 2008 05:19 PM
Atmel, assembly:displaying on lcd Haidy Micro Controllers 13 11th February 2008 08:12 PM
PIC16F628A LCD problems. HerbertMunch Micro Controllers 17 2nd October 2007 09:19 AM



All times are GMT. The time now is 06:47 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.