The Philippine Electronics and Technology Forum
February 09, 2012, 08:37:33 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  

Pages: [1]   Go Down
  Print  
Author Topic: changing message in LCD  (Read 363 times)
reve4321
LR44 Battery
*

Pogi/Ganda Points: 1
Offline Offline

Posts: 1


« on: August 28, 2010, 04:20:22 PM »

patulong po ulit....  Cheesy 

is it possible na i-change yung message sa isang line ng LCD gamit ang pic16f84a with a switch??

halimbawa:
 ang first message na nadisplay ay sa first line ng LCD ay "hello...", then using a toggle switch, the first message is overwrite and madi-display ang message na "world!" sa first line ng LCD..

pwede ba yan??? please... patulong ng major major... ^_^


Assembly language pala ang gamit namin... T_T (di kc kami magaling magassembly)
Logged
The Philippine Electronics and Technology Forum
« on: August 28, 2010, 04:20:22 PM »

 Logged
reve4321
LR44 Battery
*

Pogi/Ganda Points: 1
Offline Offline

Posts: 1


« Reply #1 on: August 30, 2010, 07:56:21 PM »

Another sample code in assembly (20x4)




Code:
;*************************************************************/07/30/08*****
; File: LCD_20x4_test.asm @ 4Mhz.
; Project name: LCD Test 4x20   
;***************************************************************************   
            LIST     P=16F84
            INCLUDE "P16F84.INC"
            __CONFIG H'3FF1'
            RADIX HEX
            ERRORLEVEL -302,-202
;***************************************************************************
; Pin configuration for 20x4 LCD 
;*************************************************************************** 
; RB0 = D4
; RB1 = D5
; RB2 = D6
; RB3 = D7
; RB4 = E
; RB5 = RS           
;***************************************************************************                 
LCD_TEMP1   EQU    0X20
LCD_TEMP2   EQU    0X22
LCD_TEMP3   EQU    0X23
COUNT1      EQU    0X24
COUNT2      EQU    0X25
             
#DEFINE     EN     PORTB,4
#DEFINE     RS     PORTB,5       
;***************************************************************************   
            ORG    0X00
           
            BSF    STATUS,RP0
            MOVLW  0X00
            MOVWF  TRISB
            BCF    STATUS,RP0
           
            CLRF   PORTB
            CALL   LCD_INIT
            GOTO   MAIN                     
;***************************************************************************
LCD_TABLE:  ADDWF  PCL,F
            RETLW  0X32                ; Set 4-bit mode
            RETLW  0X2C                ; Set 2 lines LCD
            RETLW  0X08                ; Display OFF
            RETLW  0X06                ; Set so cursor addr is incremented
            RETLW  0X0C                ; Display ON, cursor OFF, blink OFF
            RETLW  0X01                ; Clear display
            RETLW  0X02                ; Home cursor, clear RAM
            RETLW  0X00                ; Return zero as end marker
;***************************************************************************
            ORG    0X100
SET_STRING: ADDWF  PCL,F
              ; 01234567890123456789
MSG_L1:     DT "       I love       ",0
MSG_L2:     DT "   electronicslab   ",0
MSG_L3:     DT "         by:        ",0
MSG_L4:     DT "     bulate1983     ",0
;***************************************************************************         
MAIN:       CALL   LCD_LINE_1
            MOVLW  MSG_L1
            CALL   STRING_OUT
           
            CALL   LCD_LINE_2
            MOVLW  MSG_L2
            CALL   STRING_OUT
           
            CALL   LCD_LINE_3
            MOVLW  MSG_L3
            CALL   STRING_OUT
             
            CALL   LCD_LINE_4
            MOVLW  MSG_L4
            CALL   STRING_OUT
            GOTO   MAIN
;***************************************************************************
STRING_OUT: MOVWF  LCD_TEMP1         ; Save the string
            DECF   LCD_TEMP1,F       ; Subract 1 to string.
LOOP01:     MOVLW  0X01
            MOVWF  PCLATH
            MOVF   LCD_TEMP1,W   
            CALL   SET_STRING        ; Add the Count text to PCL
            XORLW  0X00
            BTFSC  STATUS,Z          ; String = 0?
            GOTO   CLR_PCL
            CALL   LCD_CHAR          ; display to LCD
            INCF   LCD_TEMP1,F       ; Point to next character
            GOTO   LOOP01            ; Keep checking
CLR_PCL:    CLRF   PCLATH
            RETURN   
;***************************************************************************
; LCD Subroutine 20x4 Display
;***************************************************************************
LCD_INIT:   CALL   DELAY_5           ; Wait to Initialize the LCD
            CLRF   LCD_TEMP2
SET_LCD:    MOVF   LCD_TEMP2,W
            CALL   LCD_TABLE
            XORLW  0X00
            BTFSC  STATUS,Z
            RETURN
            CALL   LCD_CMD
            INCF   LCD_TEMP2,F
            CALL   DELAY_5
            GOTO   SET_LCD 
;***************************************************************************         
LCD_LINE_1: MOVLW  0X80             ; Go to start of line 1   
            CALL   LCD_CMD          ; Yes call Command Display
            RETURN
LCD_LINE_2: MOVLW  0XC0             ; Go to start of line 2   
            CALL   LCD_CMD          ; Yes call Command Display 
            RETURN
LCD_LINE_3: MOVLW  0X94             ; Go to start of line 3       
            CALL   LCD_CMD          ; Yes call Command Display
            RETURN
LCD_LINE_4: MOVLW  0XD4             ; Go to start of line 4   
            CALL   LCD_CMD          ; Yes call Command Display
            RETURN
;***************************************************************************           
PULSE_EN:   BSF    EN 
            NOP
            BCF    EN 
            RETURN
;***************************************************************************
LCD_CMD:    MOVWF  LCD_TEMP3
            SWAPF  LCD_TEMP3,W       ; Send the upper nibble
            ANDLW  B'00001111'       ; Clear the upper 4-bit of W
            MOVWF  PORTB 
            BCF    RS         
            CALL   PULSE_EN
            MOVF   LCD_TEMP3,W       ; Send the lower nibble
            ANDLW  B'00001111'       ; Clear the upper 4-bit of W
            MOVWF  PORTB
            BCF    RS   
            CALL   PULSE_EN
            CALL   DELAY_1
            RETURN         
;*************************************************************************** 
LCD_CHAR:   MOVWF  LCD_TEMP3
            SWAPF  LCD_TEMP3,W       ; Send the upper nibble
            ANDLW  B'00001111'       ; Clear the upper 4-bit of W
            MOVWF  PORTB
            BSF    RS
            CALL   PULSE_EN
            MOVF   LCD_TEMP3,W       ; Send the lower nibble
            ANDLW  B'00001111'       ; Clear the upper 4-bit of W
            MOVWF  PORTB
            BSF    RS   
            CALL   PULSE_EN
            CALL   DELAY_1
            RETURN         
;***************************************************************************           
; Delay Subroutine @ 4Mhz.
;***************************************************************************
DELAY_1:    MOVLW .200
            MOVWF COUNT1
LOOP1:      NOP
            NOP
            DECFSZ COUNT1,F
            GOTO LOOP1
            RETURN
             
DELAY_5:    MOVLW .5
            MOVWF COUNT2
LOOP2:      CALL DELAY_1 
            DECFSZ COUNT2,F
            GOTO LOOP2
            RETURN           
;***************************************************************************             
            END





Another sample code in assembly (20x4)




Code:
;*************************************************************/07/30/08*****
; File: LCD_20x4_test.asm @ 4Mhz.
; Project name: LCD Test 4x20   
;***************************************************************************   
            LIST     P=16F84
            INCLUDE "P16F84.INC"
            __CONFIG H'3FF1'
            RADIX HEX
            ERRORLEVEL -302,-202
;***************************************************************************
; Pin configuration for 20x4 LCD 
;*************************************************************************** 
; RB0 = D4
; RB1 = D5
; RB2 = D6
; RB3 = D7
; RB4 = E
; RB5 = RS           
;***************************************************************************                 
LCD_TEMP1   EQU    0X20
LCD_TEMP2   EQU    0X22
LCD_TEMP3   EQU    0X23
COUNT1      EQU    0X24
COUNT2      EQU    0X25
             
#DEFINE     EN     PORTB,4
#DEFINE     RS     PORTB,5       
;***************************************************************************   
            ORG    0X00
           
            BSF    STATUS,RP0
            MOVLW  0X00
            MOVWF  TRISB
            BCF    STATUS,RP0
           
            CLRF   PORTB
            CALL   LCD_INIT
            GOTO   MAIN                     
;***************************************************************************
LCD_TABLE:  ADDWF  PCL,F
            RETLW  0X32                ; Set 4-bit mode
            RETLW  0X2C                ; Set 2 lines LCD
            RETLW  0X08                ; Display OFF
            RETLW  0X06                ; Set so cursor addr is incremented
            RETLW  0X0C                ; Display ON, cursor OFF, blink OFF
            RETLW  0X01                ; Clear display
            RETLW  0X02                ; Home cursor, clear RAM
            RETLW  0X00                ; Return zero as end marker
;***************************************************************************
            ORG    0X100
SET_STRING: ADDWF  PCL,F
              ; 01234567890123456789
MSG_L1:     DT "       I love       ",0
MSG_L2:     DT "   electronicslab   ",0
MSG_L3:     DT "         by:        ",0
MSG_L4:     DT "     bulate1983     ",0
;***************************************************************************         
MAIN:       CALL   LCD_LINE_1
            MOVLW  MSG_L1
            CALL   STRING_OUT
           
            CALL   LCD_LINE_2
            MOVLW  MSG_L2
            CALL   STRING_OUT
           
            CALL   LCD_LINE_3
            MOVLW  MSG_L3
            CALL   STRING_OUT
             
            CALL   LCD_LINE_4
            MOVLW  MSG_L4
            CALL   STRING_OUT
            GOTO   MAIN
;***************************************************************************
STRING_OUT: MOVWF  LCD_TEMP1         ; Save the string
            DECF   LCD_TEMP1,F       ; Subract 1 to string.
LOOP01:     MOVLW  0X01
            MOVWF  PCLATH
            MOVF   LCD_TEMP1,W   
            CALL   SET_STRING        ; Add the Count text to PCL
            XORLW  0X00
            BTFSC  STATUS,Z          ; String = 0?
            GOTO   CLR_PCL
            CALL   LCD_CHAR          ; display to LCD
            INCF   LCD_TEMP1,F       ; Point to next character
            GOTO   LOOP01            ; Keep checking
CLR_PCL:    CLRF   PCLATH
            RETURN   
;***************************************************************************
; LCD Subroutine 20x4 Display
;***************************************************************************
LCD_INIT:   CALL   DELAY_5           ; Wait to Initialize the LCD
            CLRF   LCD_TEMP2
SET_LCD:    MOVF   LCD_TEMP2,W
            CALL   LCD_TABLE
            XORLW  0X00
            BTFSC  STATUS,Z
            RETURN
            CALL   LCD_CMD
            INCF   LCD_TEMP2,F
            CALL   DELAY_5
            GOTO   SET_LCD 
;***************************************************************************         
LCD_LINE_1: MOVLW  0X80             ; Go to start of line 1   
            CALL   LCD_CMD          ; Yes call Command Display
            RETURN
LCD_LINE_2: MOVLW  0XC0             ; Go to start of line 2   
            CALL   LCD_CMD          ; Yes call Command Display 
            RETURN
LCD_LINE_3: MOVLW  0X94             ; Go to start of line 3       
            CALL   LCD_CMD          ; Yes call Command Display
            RETURN
LCD_LINE_4: MOVLW  0XD4             ; Go to start of line 4   
            CALL   LCD_CMD          ; Yes call Command Display
            RETURN
;***************************************************************************           
PULSE_EN:   BSF    EN 
            NOP
            BCF    EN 
            RETURN
;***************************************************************************
LCD_CMD:    MOVWF  LCD_TEMP3
            SWAPF  LCD_TEMP3,W       ; Send the upper nibble
            ANDLW  B'00001111'       ; Clear the upper 4-bit of W
            MOVWF  PORTB 
            BCF    RS         
            CALL   PULSE_EN
            MOVF   LCD_TEMP3,W       ; Send the lower nibble
            ANDLW  B'00001111'       ; Clear the upper 4-bit of W
            MOVWF  PORTB
            BCF    RS   
            CALL   PULSE_EN
            CALL   DELAY_1
            RETURN         
;*************************************************************************** 
LCD_CHAR:   MOVWF  LCD_TEMP3
            SWAPF  LCD_TEMP3,W       ; Send the upper nibble
            ANDLW  B'00001111'       ; Clear the upper 4-bit of W
            MOVWF  PORTB
            BSF    RS
            CALL   PULSE_EN
            MOVF   LCD_TEMP3,W       ; Send the lower nibble
            ANDLW  B'00001111'       ; Clear the upper 4-bit of W
            MOVWF  PORTB
            BSF    RS   
            CALL   PULSE_EN
            CALL   DELAY_1
            RETURN         
;***************************************************************************           
; Delay Subroutine @ 4Mhz.
;***************************************************************************
DELAY_1:    MOVLW .200
            MOVWF COUNT1
LOOP1:      NOP
            NOP
            DECFSZ COUNT1,F
            GOTO LOOP1
            RETURN
             
DELAY_5:    MOVLW .5
            MOVWF COUNT2
LOOP2:      CALL DELAY_1 
            DECFSZ COUNT2,F
            GOTO LOOP2
            RETURN           
;***************************************************************************             
            END








nakita ko po 'tong program and its working... pero ang project po namin ay maglagay ng switch para po machange yung mga message na  nadisplay... so, pagnatrigger po yung switch, ibang message naman ang madi-display... pagna trigger po yung switch again, babalik po yung unang message na nadisplay.. we try enhancing the program pero wala pong lumabas na message.. di po gumana eh...  can it be done using pic16f84a???


please.. pahlep po... T_T
Logged
customer_9
Size AAA Battery
***

Pogi/Ganda Points: 2
Offline Offline

Posts: 75


« Reply #2 on: January 02, 2012, 11:20:21 PM »

w0w assembly, maybe the masters are not replying to these thread because the  code will be long and its hard to manipulate.
Logged

simple hobbyist
dummy_c
Diesel Generator
*

Pogi/Ganda Points: 88
Offline Offline

Gender: Male
Posts: 1045


Learning PIC uC. Posting datasheets on my wall.


WWW
« Reply #3 on: January 02, 2012, 11:56:04 PM »

Sa tingin ko hindi impossible ito ma modify para ma satisfy ang gusto ni TS, since well commented naman ang codes.
Logged

motion55
Technical People
Diesel Generator
*****

Pogi/Ganda Points: 189
Offline Offline

Gender: Male
Posts: 1247


Been there and done that already.


« Reply #4 on: January 03, 2012, 09:22:04 AM »

Yes, it's well written. And no it's not hard to modify.

First, modify the initialization to add an input for the switch. Let's pick PORTB bit 7 (RB7).

Quote
           BSF    STATUS,RP0
            MOVLW  0X80
            MOVWF  TRISB
            BCF    STATUS,RP0

Secondly, modify the code so that the switch selects a different string to display. For example:

Quote
MAIN:       CALL   LCD_LINE_1
            MOVLW  MSG_L1
           BTFSS  PORTB,7
            MOVLW  MSG_L2
           CALL   STRING_OUT


@TS

BTW, both sample codes above are the same.

Kung kokopya ka ng codes from the net, at least make a small effort to understand what you are copying. Hindi ito mahirap. Hindi kailangan 100% naintidihan mo para maka modify and try. Mayroon ka naman ng Proteus pang trial and error. Mas mahirap magbago ng attitudes.
Logged

"Set your mind free!"
_basura_man()
Lead Acid Battery
*******

Pogi/Ganda Points: 23
Offline Offline

Posts: 611


To invent, you need a pile of junk.


WWW
« Reply #5 on: January 03, 2012, 09:33:09 AM »

Mas mahirap magbago ng attitudes.
+1! Attitude is more important,skills will follow...
Logged

Becoming minimalist,then simplify life.
NO TO Text Speak and
NO TO Hijack Technical Threads.

Looking for an affordable way to automate?
http://www.e-gizmo.com/

Learn SMPS here: http://www.smps.us/Unitrode.html
The Philippine Electronics and Technology Forum
   

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
TCL-2027U auto-changing of channels
TCL Televisions
oldskul 14 1862 Last post November 21, 2009, 09:52:26 AM
by pete
changing colors of CRT monitor
General Electronics and Technology Discussion
ty-rap 8 539 Last post March 25, 2010, 01:30:16 PM
by ty-rap
changing the impedance
Electrical Circuits and Devices
ying25082 10 493 Last post April 03, 2010, 07:53:11 AM
by ying25082
Changing frequency (RC) how???
Sports and Recreation
centOS 1 225 Last post June 14, 2010, 11:53:07 AM
by centOS
pc Clock Keeps Changing On Its Own!! « 1 2 »
Computer Repair (Computer Technicians Forum)
de PatAtas 35 972 Last post January 28, 2011, 10:35:13 AM
by de PatAtas
need help changing voltage on a chip (willing to pay)
Electrical Circuits and Devices
gm_jonjon 6 502 Last post March 17, 2011, 07:37:13 PM
by bravokilo
Installing winXp after changing mobo,, whats d best way.... « 1 2 »
Analog and Mixed Signal Device Repair (Electronics Technician Forum)
noman75 34 578 Last post January 28, 2012, 11:32:22 AM
by marcialnasi
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!