Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

help edit:car parking system using PIC16F84A and 7 segment LED counter

Status
Not open for further replies.

eyan23

New Member
hello,this is my second thread for this coding. i have edited my coding.
but can anyone check it for me? thanks..


;TITLE: AVAILABLE PARKING SPACE
;PIC TYPE: 16F84A
;OSCILLATOR SPEED: 4 MHz

LIST p=16F84A
#include "P16F84A.INC"

;***********PORT A: ALL INPUT**********

#DEFINE EXIT PORTA,3
#DEFINE ENTR PORTA,4

;**********PORT B: ALL OUTPUT**********
#DEFINE LED1 PORTB,0
#DEFINE LED2 PORTB,1
#DEFINE LED3 PORTB,2
#DEFINE LED4 PORTB,3
#DEFINE LED5 PORTB,4
#DEFINE LED6 PORTB,5
#DEFINE LED7 PORTB,6
#DEFINE PAO STATUS,5
DRAWER1 EQU 30H
;**********MAIN PROGRAM STARTS HERE**********

ORG 00H
INIT CLRF PORTA
CLRF PORTB
BSF PAO
MOVLW b'11111'
MOVWF TRISA
MOVLW b'00000000'
MOVWF TRISB
BCF PAO
;*********START*********
MOVLW 04H
MOVWF DRAWER1
CHECK BTFSC ENTR
GOTO NEXT
DECF DRAWER1,1
GOTO DISPLAY
NEXT BTFSC EXIT
GOTO CHECK
INCF DRAWER1,1
GOTO DISPLAY
GOTO CHECK

DISPLAY MOVLW 04H
SUBWF DRAWER1,0
BTFSS STATUS,Z
GOTO NO3
MOVLW H'99'
MOVWF PORTB

NO3 MOVLW 03H
SUBWF DRAWER1,0
BTFSS STATUS,Z
GOTO NO2
MOVLW H'B0'
MOVWF PORTB

NO2 MOVLW 02H
SUBWF DRAWER1,0
BTFSS STATUS,Z
GOTO NO1
MOVLW H'A4'
MOVWF PORTB

NO1 MOVLW 01H
SUBWF DRAWER1,0
BTFSS STATUS,Z
GOTO NO0
MOVLW H'F9'
MOVWF PORTB

NO0 MOVLW 00H
SUBWF DRAWER1,0
BTFSS STATUS,Z
GOTO NO0
MOVLW H'C0'
MOVWF PORTB
END
 
hi eyan,
I have already explained on your other thread for this topic, that you are using bits of 89C51 programming code for the 16F84A PIC, they are not compatible.
Say what the program is supposed to do.

EDIT:

Code:
;TITLE: AVAILABLE PARKING SPACE  
;PIC TYPE: 16F84A  
;OSCILLATOR SPEED: 4 MHz  

    list    p=16F84A

    #include "P16F84A.INC" 

        errorlevel -302, -207    

    __CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;***********PORT A: ALL INPUT**********  

#DEFINE    EXIT    PORTA,3
#DEFINE    ENTR    PORTA,4

;**********PORT B: ALL OUTPUT**********  
#DEFINE    LED1    PORTB,0
#DEFINE    LED2    PORTB,1
#DEFINE    LED3    PORTB,2
#DEFINE    LED4    PORTB,3
#DEFINE    LED5    PORTB,4
#DEFINE    LED6    PORTB,5
#DEFINE    LED7    PORTB,6
#DEFINE    PAO    STATUS,5


DRAWER1    equ    30H
;**********MAIN PROGRAM STARTS HERE**********  

    org    00H
INIT    clrf    PORTA
    clrf    PORTB
    bsf    STATUS,RP0;;;PA0 [B]changed this[/B]
    movlw    b'00011111'
    movwf    TRISA
    movlw    b'00000000'
    movwf    TRISB
    bcf    STATUS,RP0;;;PAO [B]changed this[/B]
;*********START*********  

START:
    movlw    04H
    movwf    DRAWER1
CHECK    btfsc    ENTR; [B]the check of A3 and A4 works OK[/B]
    goto    NEXT
    decf    DRAWER1,1
    goto    DISPLAY
NEXT    btfsc    EXIT
    goto    CHECK
    incf    DRAWER1,1
    goto    DISPLAY
    goto    CHECK

DISPLAY    movlw    04H
    subwf    DRAWER1,0
    btfss    STATUS,Z
    goto    NO3
    movlw    H'99'
    movwf    PORTB

NO3    movlw    03H
    subwf    DRAWER1,0
    btfss    STATUS,Z
    goto    NO2
    movlw    H'B0'
    movwf    PORTB

NO2    movlw    02H
    subwf    DRAWER1,0
    btfss    STATUS,Z
    goto    NO1
    movlw    H'A4'
    movwf    PORTB

NO1    movlw    01H
    subwf    DRAWER1,0
    btfss    STATUS,Z
    goto    NO0
    movlw    H'F9'
    movwf    PORTB

NO0    movlw    00H      ;[B]This loops forever[/B]
    subwf    DRAWER1,0
    btfss    STATUS,Z
    goto    NO0               ;[B].....................................[/B]
    movlw    H'C0'
    movwf    PORTB

    goto     START

    end
 
Last edited:
thanks for your edit on my coding.this is explanation for my coding.this program is about to check,calculate and display the amount of parking space available.
the system start with 4 parking space.the sensor at entrance and exit will detect the car in and out.
when there is car in the entrance,the value of 4 parking space will decrease 1 and when the car out at the exit the space will increase 1.
is there any wrong with my coding process?

ASSEMBLY CODING:
FOR THIS FINAL YEAR PROJECTS, THIS CAR PARKING SYSTEM PHOTOTYPE ONLY CONSISTS OF 4 PARKING SPACE OR LOT.
MAIN PROGRAM:
1. INITIALIZE VARIABLE
 MOVLW 04H
{MOVE LITERAL TO W ,04H: MEANS STATE THE INITIAL PARKING SPACE IS 4}
 MOVWF DRAWER1
{MOVE W TO F, DRAWER1: MEANS THAT ALL THE FILE IS SENT AND STORE IN DRAWER 1}
2. CHECK FOR SPACE AVAILABILITY
 CHECK BTFSC ENTR
{CHECK: -BIT TEST F,SKIP IF CLEAR(ENTRANCE) : MEANS THAT THE PROGRAM WILL CHECK THE ENTRANCE IF THERE IS ANY CAR ENTRANCE IT WILL SKIP THE NEXT ONE STEP AND DECREASE THE VALUE IN DRAWER1}
 GOTO NEXT
{GOTO,NEXT STEP: MEANS THAT IN THIS STEP IF THE CHECKING STEP ABOVE IS SATISFIED IT GO TO THE NEXT STEP}
 DECF DRAWER1,1
{DECREASE THE VALUE CONTENT IN DRAWER1 AND STORE IN 1}
 GOTO DISPLAY
{THE PROGRAM WILL GO TO DISPLAY STEP BELOW}
 NEXT BTFSC EXIT
GOTO CHECK
INCF DRAWER1,1
GOTO DISPLAY
GOTO CHECK

{IN THIS NEXT STEP IT WILL DO:- BIT TEST F,SKIP IF CLEAR(SKIP THE NEXT CODING IF SATISFIED),
GOTO,CHECK(GOTO CHECK PROCESS ABOVE),
INCREASE THE VALUE IN DRAWER1 AND STORE IN 1,
GOTO,DISPLAY(GOTO DISPLAY PROCESS BELOW),
GOTO,CHECK(GOTO CHECK PROCESS ABOVE).
3. CALCULATING/DISPLAY BOARD USING 7 SEGMENT LED
 DISPLAY MOVLW 04H
SUBWF DRAWER1,0
BTFSS STATUS,Z
GOTO NO3
MOVLW H'99'
MOVWF PORTB

NO3 MOVLW 03H
SUBWF DRAWER1,0
BTFSS STATUS,Z
GOTO NO2
MOVLW H'B0'
MOVWF PORTB

NO2 MOVLW 02H
SUBWF DRAWER1,0
BTFSS STATUS,Z
GOTO NO1
MOVLW H'A4'
MOVWF PORTB

NO1 MOVLW 01H
SUBWF DRAWER1,0
BTFSS STATUS,Z
GOTO NO0
MOVLW H'F9'
MOVWF PORTB

NO0 MOVLW 00H
SUBWF DRAWER1,0
BTFSS STATUS,Z
GOTO NO0
MOVLW H'C0'
MOVWF PORTB
END
DESRIPTION ABOUT THE DISPLAY STEP
 MOVLW 04H
{THE DISPLAY PROCESS WILL START AT 4 AVAILABLE PARKING SPACE/LOT}
 SUBWF DRAWER1,0
{IT WILL SUBTRACT THE VALUE IN DRAWER1 AND STORE IT IN 0}
 BTFSS STATUS,Z
{IT WILL SKIP THE SET AND GO TO STATUS ZERO(IF NO CAR ENTRY,NO VALUE IS SUBTACTED)}
 GOTO NO3
{IT WILL GO TO NO3 STEP,AND REDO THE PROCESS SAME LIKE STEP ABOVE}
 MOVLW H'99'
{IT WILL MOVE TO SEGMENT CODE FOR NO 4}
 
hi eyan,
Its important to have code that loops around the sensors.
When NO0 executes the program should just not END.
 
thank you for your help. but i'm still facing problem to fully understand the assembly code especially in doing loops.
i dun know how to write the loop. i hope you can help me.
thanks..
 
thank you for your help. but i'm still facing problem to fully understand the assembly code especially in doing loops.
i dun know how to write the loop. i hope you can help me.
thanks..

hi,
Look at Nigels tutorials link, its near my signature on this post.
 
Status
Not open for further replies.

Latest threads

Back
Top