Jump to content
Electronics-Lab.com Community

taxi meter using PIC16f84


zam e

Recommended Posts


Sorry, no ones going to do your project for you. This is not a free electronic design service, I apologise if that's not clear. Electronics Lab is a forum where people help each other with their projects.

If you want someone to design your project for you, they'll more than likely charge you a fee and require you to supply them with a design specification first.

Link to comment
Share on other sites

LIST P=PIC16F84
PORTA EQU 05H
PORTB EQU 06H
COUNTER EQU 37
Hibyte EQU 020
Lobyte EQU 021
Count EQU 26
Tents EQU 022
Thous EQU 023
Hunds EQU 024
Tens EQU 025
Ones EQU 028
d1 EQU 019
d2 EQU 018
d3 EQU 017
Timer1 EQU 29
TimerX EQU 2A
Point EQU 2B ; Program table pointer
Select EQU 2C ; Copy of RS bit
OutCod EQU 2D ; Temp store for output code
RS EQU 1 ; Register select output bit
E EQU 2 ; Display enable
NUM_HIGH EQU 30H
NUM_LOW EQU 31H
X1 EQU 32
X2 EQU 33
X3 EQU 34


ORG 100H
GOTO START
ORG 0H


START MOVLW B'00000001'
TRIS PORTA
MOVLW B'00000000'
TRIS PORTB
CALL InitLCD
CALL Out_LCD0


CLRF PORTB
LOOP BTFSS PORTA,0
GOTO START
CALL Out_LCD1
CALL DELAY
BTFSS PORTA,0
GOTO START
CALL Out_LCD2
CALL DELAY
BTFSS PORTA,0
GOTO START
CALL Out_LCD3
CALL DELAY
GOTO LOOP



RETURN

DELAY ;30minutes delay
movlw 0xB6
movwf d1
movlw 0x64
movwf d2
movlw 0x20
movwf d3
Delay30min_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay30min_0
nop
return

;-----------------------------------------------------------------------------------------------------------
Out_LCD1:
BSF Select,RS ; Set display data mode
MOVLW 'R' ; Time period
CALL send ; Display it
MOVLW 'M' ; Space
CALL send ; Display it
MOVLW ' ' ; Equals
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it

; Show fixed characters----------------------------------------------------------------------------
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; micro
CALL send ; Display it
MOVLW '3' ; secs
CALL send ; Display it
MOVLW '.' ; Space
CALL send ; Display it
MOVLW '0' ; Space
CALL send ; Display it
MOVLW '0' ; Space
CALL send ; Display it

; Home cursor-----------------------------------------------------------------------------------------

BCF Select,RS ; Set display command mode
MOVLW 0x80 ; Code to home cursor
CALL send ; Do it
RETURN ; done

;------------------------------------------------------------------
Out_LCD2
BSF Select,RS ; Set display data mode
MOVLW 'R' ; Time period
CALL send ; Display it
MOVLW 'M' ; Space
CALL send ; Display it
MOVLW ' ' ; Equals
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it

; Show fixed characters----------------------------------------------------------------------------
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; micro
CALL send ; Display it
MOVLW '3' ; secs
CALL send ; Display it
MOVLW '.' ; Space
CALL send ; Display it
MOVLW '1' ; Space
CALL send ; Display it
MOVLW '0' ; Space
CALL send ; Display it

; Home cursor----------------------------------------------------------------------------------------

BCF Select,RS ; Set display command mode
MOVLW 0x80 ; Code to home cursor
CALL send ; Do it
RETURN ; done

;------------------------------------------------------------------
Out_LCD3
BSF Select,RS ; Set display data mode
MOVLW 'R' ; Time period
CALL send ; Display it
MOVLW 'M' ; Space
CALL send ; Display it
MOVLW ' ' ; Equals
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it

; Show fixed characters----------------------------------------------------------------------------
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; micro
CALL send ; Display it
MOVLW '3' ; secs
CALL send ; Display it
MOVLW '.' ; Space
CALL send ; Display it
MOVLW '2' ; Space
CALL send ; Display it
MOVLW '0' ; Space
CALL send ; Display it
; Home cursor----------------------------------------------------------------------------------------

BCF Select,RS ; Set display command mode
MOVLW 0x80 ; Code to home cursor
CALL send ; Do it
RETURN ; done



Out_LCD0
BSF Select,RS ; Set display data mode
MOVLW 'W' ; Time period
CALL send ; Display it
MOVLW 'E' ; Space
CALL send ; Display it
MOVLW 'L' ; Equals
CALL send ; Display it
MOVLW 'C' ; Space
CALL send ; Display it
MOVLW 'O' ; Space
CALL send ; Display it
MOVLW 'M' ; Space
CALL send ; Display it

; Show fixed characters----------------------------------------------------------------------------
MOVLW 'E' ; Space
CALL send ; Display it
MOVLW ' ' ; micro
CALL send ; Display it
MOVLW ' ' ; secs
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it
MOVLW ' ' ; Space
CALL send ; Display it
; Home cursor----------------------------------------------------------------------------------------

BCF Select,RS ; Set display command mode
MOVLW 0x80 ; Code to home cursor
CALL send ; Do it
RETURN ; done


; MAIN LOOP-----------------------------------------------------------------------------------------

send MOVWF OutCod ; Store output code
ANDLW 0FF ; Clear low nybble
MOVWF PORTB ; Output high nybble
BTFSC Select,RS ; Test RS bit
BSF PORTB,RS ; and set for data

CALL PulseE ; and clock display
CALL Onems ; wait 1ms for display
SWAPF OutCod ; Swap low/high nybbles
MOVF OutCod,W ; Retrieve output code
ANDLW 0FF ; Clear low nybble
MOVWF PORTB ; Output low nybble
BTFSC Select,RS ; Test RS bit
BSF PORTB,RS ; and set for data
CALL PulseE ; and clock display
CALL Onems ; wait 1ms for display
RETURN

; SUBROUTINES------------------------------------------------------------------------------------
; 1ms delay with 1us cycle time (1000 cycles)-------------------

Onems MOVLW D'249' ; Count for 1ms delay
MOVWF Timer1 ; Load count
Loop1 NOP ; Pad for 4 cycle loop
DECFSZ Timer1 ; Count
GOTO Loop1 ; until Z
RETURN ; and finish

; Delay Xms, X received in W -----------------------------------

Xms MOVWF TimerX ; Count for X ms
LoopX CALL Onems ; Delay 1ms
DECFSZ TimerX ; Repeat X times
GOTO LoopX ; until Z
RETURN ; and finish



; Generate data/command clock siganl E -------------------------

PulseE BSF PORTB,E ; Set E high
CALL Onems ; Delay 1ms
BCF PORTB,E ; Reset E low
CALL Onems ; Delay 1ms
RETURN

; Initialize the display -------------------------------------------------------------------------------

InitLCD MOVLW D'100' ; Load count 100ms delay
CALL Xms ; and wait for display
MOVLW 0F0 ; Mask for select code
MOVWF Select ; High nybble not masked
MOVLW 0x30 ; Load initial nibble
MOVWF PORTB ; and output it to display
CALL PulseE ; Latch initial code
MOVLW D'5' ; Set delay 5ms
CALL Xms ; and wait
CALL PulseE ; Latch initial code again
CALL Onems ; Wait 1ms
CALL PulseE ; Latch initial code again
BCF PORTB, 4 ; Set 4-bit mode
CALL PulseE ; Latch it
MOVLW 0x28 ; Set 4-bit mode, 2 lines
CALL send ; and send code
MOVLW 0x08 ; Switch off display
CALL send ; and send code
MOVLW 0x01 ; Clear display
CALL send ; and send code
MOVLW 0x06 ; Enable cursor auto inc
CALL send ; and send code
MOVLW 0x80 ; Zero display address
CALL send ; and send code
MOVLW 0x0C ; Turn on display
CALL send ; and send code

RETURN ; Done

END

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...