3738 Wheelchair

download 3738 Wheelchair

of 28

Transcript of 3738 Wheelchair

  • 8/13/2019 3738 Wheelchair

    1/28

    ;;---------------------------------------------------------------------------------;Set PIC = 16F877;Set PIC Configuration

    list p=pic16f877ainclude p16f877a.inc

    __config 0x1E72 errorlevel -302 ;Suppress bank warning

    ;---------------------------------------------------------------------------------;Declare Variable;---------------------------------------------------------------------------------

    CBlock 0x20N ; Delay register

    s.N1count1counta

    countbcountcrxtime1rxtime2M0RXDMOTORPOSITIONC_POSITIONN_POSITIONFIXDELAYvisdelaypriority

    dataLCOUNTER1COUNTER2temp_digrmng_num ; Digit breaker register

    s.quotienttemp_numrmng_num2 ; Digit breaker register

    s.quotient2temp_num2S1A

    S1BS2AS2BbriteL ; Brightness variable re

    gisters.briteHbritefractBigestdigitbritedata0 ; Brightness data digit register

    s.

  • 8/13/2019 3738 Wheelchair

    2/28

    digitbritedata1digitbritedata2digitbritedataL0digitbritedataL1digitbritedataL2

    britenonfract0 ; Actual Brightness digit registers.

    britenonfract1britenonfract2britefract0britefract1

    tempHtranstempLtransbriteHtransbriteLtransA1A0A_1A_0B1B0C1

    C0D1D0E1E0F1F0X1X0

    briteL2 ; Brightness variable registers.

    briteH2

    britefract2

    digitbritedata02 ; Brightness data digitregisters.

    digitbritedata12digitbritedata22digitbritedataL02digitbritedataL12digitbritedataL22

    britenonfract02 ; Brightness digit registers.britenonfract12britenonfract22

    britefract02britefract12

    tempSPEEDcount90briteHtrans2briteLtrans2M1M2TSPD1

  • 8/13/2019 3738 Wheelchair

    3/28

    TSPD2

    ENDC

    org 0x00

    ;---------------------------------------------------------------------------------;Start Program;---------------------------------------------------------------------------------start call initports ; Initialize Ports as output/inputs.

    call INITLCD ; Initialize LCDcall clrscreen ; Clear LCD SCREENcall DisLCD ;Display Startup Messagecall SECOND_1call SECOND_1call DisTreecall SECOND_1call SECOND_1call DisTwocall SECOND_1call SECOND_1call DisOne

    call SECOND_1 ;1s delay before execute to mainprogram

    bcf PORTD,2 ;Turn OFF All output atstartup

    bcf PORTD,3

    bcf PORTC,4 ;Turn OFF All output atstartup

    bcf PORTC,5

    ;---------------------------------------------------------------------------------;MAIN PROGRAM;---------------------------------------------------------------------------------;------------------MAIN PROGRAM - CONTINOUSLY LOOPING THIS PROGRAM ---------------------------main call DisStanby

    call Stop

    btfss PORTA,0 ;Check button fowardgoto Fwrdbtfss PORTA,1 ;Check button reversegoto Rvsbtfss PORTA,2 ;Check button leftgoto Leftbtfss PORTA,3 ;Check button rightgoto Rightgoto main

  • 8/13/2019 3738 Wheelchair

    4/28

    ;Clear button routines----------------------------------------

    Fwrd call DisFoward ;move foward

    bsf PORTD,2 ;onbcf PORTD,3 ;off

    bsf PORTC,5 ;onbcf PORTD,4 ;offbtfsc PORTA,0 ;Check button fowardgoto maingoto Fwrd

    Rvs call DisRvs ;TURN RIGHT

    bsf PORTD,1bcf PORTD,2 ;off

    bsf PORTD,3 ;on

    bcf PORTC,5 ;offbsf PORTD,4 ;oncall Delay_Tbcf PORTD,1call Delay_Tbtfsc PORTA,1 ;Check button reversegoto maingoto Rvs

    Left call DisLeft ;TURN LEFT

    bsf PORTD,2 ;onbcf PORTD,3 ;off

    bcf PORTC,5 ;offbsf PORTD,4 ;onbtfsc PORTA,2 ;Check button leftgoto maingoto Left

    Right call DisRight ;move right

    bcf PORTD,2 ;offbsf PORTD,3 ;on

    bsf PORTC,5 ;onbcf PORTD,4 ;offbtfsc PORTA,3 ;Check button rightgoto maingoto Right

  • 8/13/2019 3738 Wheelchair

    5/28

    Stop

    bcf PORTD,2 ;offbcf PORTD,3 ;on

    bcf PORTC,5 ;onbcf PORTD,4 ;off

    return

    ;-------------------------END OF MAIN PROGRAM---------------------------

    ;------------------------------------------------------------------------------------------------------------------------; Subroutine for Time&Delay;------------------------------------------------------------------------------------------------------------------------

    Delay_Tx movlw d'250' ;delay 250 ms (4 MHz clock)movwf countc

    d1x movlw 0xC7movwf countamovlw 0x01movwf countb

    Delay_0xdecfsz counta, fgoto $+2decfsz countb, f

    goto Delay_0x

    decfsz countc ,fgoto d1xretlw 0x00

    DelayR movlw d'80' ;delay 250 ms (4 MHz clock)movwf countc

    d1R movlw 0xC7movwf countamovlw 0x01

    movwf countbDelay_0R

    decfsz counta, fgoto $+2decfsz countb, fgoto Delay_0R

    decfsz countc ,fgoto d1Rretlw 0x00

  • 8/13/2019 3738 Wheelchair

    6/28

    Delay_T24l movlw d'150' ;delay 250 ms (4 MHz clock)movwf countc

    d124l movlw 0xC7movwf countamovlw 0x01movwf countb

    Delay_024ldecfsz counta, fgoto $+2decfsz countb, fgoto Delay_024l

    decfsz countc ,fgoto d124lretlw 0x00

    ;------------------------------------------------------------------------------------------------------------------------; Subroutine for Time&Delay;------------------------------------------------------------------------------------------------------------------------

    BUSY_DELAY movlw d'70'movwf N1

    more1 call SECOND_1DECFSZ N1,1goto more1return

    NORMAL_DELAY movlw d'30'movwf N1

    more2 call SECOND_1DECFSZ N1,1goto more2

    return

    CLEAR_DELAY movlw d'15'movwf N1

    more3 call SECOND_1DECFSZ N1,1goto more3return

    MINUTE_1 movlw d'40'movwf N1

    more1_T call SECOND_1

    DECFSZ N1,1goto more1_Treturn

    SECOND_1 movlw d'4'movwf N

    more call Delay_Tcontinue DECFSZ N,1

    goto morereturn

  • 8/13/2019 3738 Wheelchair

    7/28

    Delay_T movlw d'100' ;delay 250 ms (4 MHz clock)movwf count1

    d1 movlw 0xC7movwf countamovlw 0x01movwf countb

    Delay_0decfsz counta, fgoto $+2decfsz countb, fgoto Delay_0

    decfsz count1 ,fgoto d1retlw 0x00

    delay_5s call SECOND_1call SECOND_1call SECOND_1call SECOND_1

    call SECOND_1return

    delay_2s call SECOND_1call SECOND_1return

    ;------------------------------------------------------------------------------------------------------------------------; Subroutine to initialize the PORTs as Inputs or Outputs.;------------------------------------------------------------------------------------------------------------------------

    initportsbcf STATUS,RP0clrf PORTBclrf PORTCclrf PORTAclrf PORTDclrf PORTEbsf STATUS,RP0 ;Change to Bank1bcf OPTION_REG,7MOVLW 0x06 ;CONFIGURED ALL

    PIN AS DIGITAL I/OMOVWF ADCON1movlw b'11111111'movwf TRISA

    movlw b'00000000' ;Set PORTA all OUTmovwf TRISD

    clrf TRISB ;Set PORTBmovlw b'10000000'movwf TRISC

    movlw b'00000111'

  • 8/13/2019 3738 Wheelchair

    8/28

    movwf TRISEbcf STATUS,RP0 ;Change to Bank0return

    ;------------------------------------------------------------------------------------------------------------------------; Initialize the LCD.;------------------------------------------------------------------------------------------------------------------------

    INITLCD

    MOVLW 0xE6 ; Call for 46ms delayCALL NDELAY ; Wait for VCC of the LCD to rea

    ch 5V

    BCF PORTD, 5 ; Clear RS to select Instruction Reg.

    BCF PORTD, 6 ; Clear R/W to write

    MOVLW B'00111011' ; Function Set to 8 bits, 2 lines and 5x7 dot matrix

    MOVWF PORTB

    CALL ENABLEPULSECALL DELAY50CALL ENABLEPULSECALL DELAY50CALL ENABLEPULSECALL DELAY50 ; Call 50us delay and wait for i

    nstruction completion

    MOVLW B'00001000' ; Display OFFMOVWF PORTBCALL ENABLEPULSECALL DELAY50 ; Call 50us delay and wait for i

    nstruction completion

    MOVLW B'00000001' ; Clear DisplayMOVWF PORTBCALL ENABLEPULSEMOVLW 0x09 ; Call 1.8ms delay and wait for

    instruction completionCALL NDELAY

    MOVLW B'00000010' ; Cursor HomeMOVWF PORTBCALL ENABLEPULSEMOVLW 0x09 ; Call 1.8ms delay and wait for

    instruction completion

    CALL NDELAY

    MOVLW B'00001100' ; Display ON, Cursor OFF, Blinking OFF

    MOVWF PORTBCALL ENABLEPULSECALL DELAY50 ; Call 50us delay and wait for i

    nstruction completion

    MOVLW B'00000110' ; Entry Mode Set, Increment & No

  • 8/13/2019 3738 Wheelchair

    9/28

    display shiftMOVWF PORTBCALL ENABLEPULSECALL DELAY50 ; Call 50us delay and wait for i

    nstruction completion

    BSF PORTD, 5 ; Set RS to select DataReg.

    BCF PORTD, 6 ; Clear R/W to write

    RETURN

    ;------------------------------------------------------------------------------------------------------------------------; Enable Pulse for writing or reading instructions or data;------------------------------------------------------------------------------------------------------------------------

    ENABLEPULSE BCF PORTD, 7 ; 2us LOW followed by 3us HIGH Enable Pulse and 2us LOW.

    NOPNOPBSF PORTD, 7NOP

    NOPNOPBCF PORTD, 7NOPNOPRETURN

    ;------------------------------------------------------------------------------------------------------------------------; N DELAY SUBROUTINE, delay in multiples of 200us up to 200us*255 = 51ms (or more);------------------------------------------------------------------------------------------------------------------------

    NDELAYMOVWF N ; N is delay multiplier

    NOTOVER CALL DELAY200 ; Call for 200usDECFSZ N, 1 ; Decrease N by 1GOTO NOTOVER ; The delay isn't doneRETURN

    ;------------------------------------------------------------------------------------------------------------------------; FIXED 200us DELAY (Possibly more due to execution time of the DECFSZ instruction.);-------------------------------------------------------------------------------

    -----------------------------------------

    DELAY200MOVLW 0x42 ; 66 LOOPSMOVWF FIXDELAY ; 200us fixed delay

    NOTDONE200 DECFSZ FIXDELAY, 1 ; Decrement of FIXDELAYGOTO NOTDONE200 ; If 200us isn't up go back to N

    OTDONE200RETURN ; If 200us is up then re

    turn to instruction.

  • 8/13/2019 3738 Wheelchair

    10/28

    ;------------------------------------------------------------------------------------------------------------------------; FIXED 50us DELAY (Possibly more due to execution time of the DECFSZ instruction.);------------------------------------------------------------------------------------------------------------------------

    DELAY50MOVLW 0x10 ; 16 LOOPSMOVWF FIXDELAY ; 50us fixed delay

    NOTDONE50 DECFSZ FIXDELAY, 1 ; Decrement of FIXDELAYGOTO NOTDONE50 ; If 50us isn't up go back to NO

    TDONE50RETURN ; If 50us is up then ret

    urn to instruction.

    ;------------------------------------------------------------------------------------------------------------------------; Visual delay subroutine.;------------------------------------------------------------------------------------------------------------------------

    visualdelay movlw 0x05

    movwf visdelay

    seetemp movlw 0x05call NDELAYdecfsz visdelay, 1goto seetempreturn

    visualdelay1 movlw 0x12 ;FASTmovwf visdelay

    seetemp2 movlw 0xAAcall NDELAY

    decfsz visdelay, 1goto seetemp2return

    ;------------------------------------------------------------------------------------------------------------------------; Fast Directive to write characters to LCD.;------------------------------------------------------------------------------------------------------------------------

    PUTCHARMOVWF PORTB ; A quicker way of writi

    ng characters to LCD.

    CALL ENABLEPULSECALL CHKBUSYRETURN

    ;------------------------------------------------------------------------------------------------------------------------; Subroutine to check for the BUSY flag. Mostly used for instructions that follows up a character write.;------------------------------------------------------------------------------------------------------------------------

  • 8/13/2019 3738 Wheelchair

    11/28

    CHKBUSYbcf PORTD,5 ; Clear RS to select Instruction

    Reg.bsf PORTD,6 ; Set R/W to read.

    banksel TRISB ; Select Bank for TRISC.movlw 0xFF ; Define all PORTC Pins

    as Inputs.movwf TRISB

    banksel PORTD ; Select Bank for PORTC.bsf PORTD,7 ; I tried to write my own code f

    or this part initially but I wasn't successful.movf PORTB,w ; Therefore, I implemented a por

    tion of Peter Ouwehand's LCD Code.bcf PORTD,7 ; Will look more into the BUSY f

    lag of the LCD.andlw 0x80 ; Credits to Peter Ouweh

    and for his code here. :)btfss STATUS,Zgoto CHKBUSY

    banksel TRISB ; Select Bank for TRISB.

    movlw 0x00 ; Define all PORTC Pinsas Outputs.movwf TRISB

    banksel PORTD ; Select Bank for PORTA, B, andC.

    bsf PORTD,5 ; Set RS to select Data Register.

    bcf PORTD,6 ; Clear R/W to write.

    return

    ;-------------------------------------------------------------------------------

    -----------------------------------------; Position Cursor to the next line.;------------------------------------------------------------------------------------------------------------------------

    nextlinebanksel PORTDbcf PORTD, 5 ; Select Instructions Register.bcf PORTD, 6 ; Select Write.

    movlw b'11000000' ; Shift cursor to second line at0x40 RAM address on LCD.

    call PUTCHAR

    return

    ;------------------------------------------------------------------------------------------------------------------------; Clear screen and Cursor home.;------------------------------------------------------------------------------------------------------------------------

    clrscreen

  • 8/13/2019 3738 Wheelchair

    12/28

    banksel PORTDbcf PORTD, 5 ; Clear RS to select Instruction

    s Register.bcf PORTD, 6 ; Clear R/W to select Write.

    banksel PORTBMOVLW B'00000001' ; Clear Displaycall PUTCHAR

    return

    ;------------------------------------------------------------------------------------------------------------------------; Position Cursor to home position.;------------------------------------------------------------------------------------------------------------------------

    cursorhomebanksel PORTDbcf PORTD, 5 ; Select Instructions Register.bcf PORTD, 6 ; Select Write.

    movlw b'00000010' ; Position cursor to home position.

    call PUTCHAR

    return

    ;------------------------------------------------------------------------------------------------------------------------; Wait 20us for Acquisition time in order for holding capacitor to charge up.;------------------------------------------------------------------------------------------------------------------------

    delay20banksel FIXDELAY ; A loop to generate 20us delay.

    movlw 0x08movwf FIXDELAY

    notdone20 decfsz FIXDELAY, 1goto notdone20

    return

    ;------------------------------------------------------------------------------------------------------------------------; Delay to provide some settling time for start up.;-------------------------------------------------------------------------------

    -----------------------------------------

    delaybanksel dataLclrf dataL

    settle decfsz dataL, f ; The delay loop.goto settle

    movf RCREG, w ; Flush the receive buff

  • 8/13/2019 3738 Wheelchair

    13/28

    er.movf RCREG, wmovf RCREG, w

    return

    ;------------------------------------------------------------------------------------------------------------------------; Initialize ADC Subroutine;------------------------------------------------------------------------------------------------------------------------

    initadcbanksel TRISA ; Select Bank for TRISA.movlw b'00111111' ; Initialize RA0 - RA5 as Inputs

    .movwf TRISA

    movlw b'00000111' ; Initialize RA0 - RA5 as Inputs.

    movwf TRISE

    banksel ADCON1 ; Select Bank for ADCON1.movlw b'00000000' ; ADFM for Left Justified, Vref-

    =Vss Vref+=AN3 Analog In=AN0, AN1 (R/C = 1/2).movwf ADCON1

    banksel ADCON0 ; Select Bank for ADCON0.movlw b'01000001' ; Fosc/8, Channel 0, Enable the

    ADC (Default Chan. 0)movwf ADCON0

    return

    ;-------------------------------------------------------------------------------

    -----------------------------------------; This routine starts the AD Conversion and waits for it to complete.;------------------------------------------------------------------------------------------------------------------------

    startadcbanksel ADCON0 ; Select Bank for ADCON0.bsf ADCON0, GO ; Set the GO bit to begin AD Con

    version.

    banksel ADCON0 ; Select Bank for ADCON0.checkdone btfsc ADCON0, GO ; Check if the conversion is done?

    goto checkdone ; If not, check again.

    return ; Else, return to the main programme.

    ;------------------------------------------------------------------------------------------------------------------------; Select Channel AN0 of A/D Converter.;-------------------------------------------------------------------------------

  • 8/13/2019 3738 Wheelchair

    14/28

    -----------------------------------------

    chan0banksel ADCON0bcf ADCON0, 5bcf ADCON0, 4bcf ADCON0, 3

    return

    ;------------------------------------------------------------------------------------------------------------------------; Select Channel AN1 of A/D Converter.;------------------------------------------------------------------------------------------------------------------------

    chan1banksel ADCON0bcf ADCON0, 5bcf ADCON0, 4bsf ADCON0, 3

    return

    ;------------------------------------------------------------------------------------------------------------------------; Select Channel AN1 of A/D Converter.;------------------------------------------------------------------------------------------------------------------------

    chan2banksel ADCON0bcf ADCON0, 5bsf ADCON0, 4bcf ADCON0, 3

    return

    ;------------------------------------------------------------------------------------------------------------------------; Select Channel AN1 of A/D Converter.;------------------------------------------------------------------------------------------------------------------------

    chan3banksel ADCON0bcf ADCON0, 5bsf ADCON0, 4bsf ADCON0, 3

    return

    ;------------------------------------------------------------------------------------------------------------------------; Select Channel AN1 of A/D Converter.;------------------------------------------------------------------------------------------------------------------------

    chan4banksel ADCON0bsf ADCON0, 5bcf ADCON0, 4

  • 8/13/2019 3738 Wheelchair

    15/28

    bcf ADCON0, 3

    return

    ;------------------------------------------------------------------------------------------------------------------------; Select Channel AN1 of A/D Converter.;------------------------------------------------------------------------------------------------------------------------

    chan5banksel ADCON0bsf ADCON0, 5bcf ADCON0, 4bsf ADCON0, 3

    return

    ;------------------------------------------------------------------------------------------------------------------------; Breaks down a number to its individual digits.;-------------------------------------------------------------------------------

    -----------------------------------------

    get_digmovlw d'10' ; To split the digits, d

    ivide them by 10.incf quotient, f ; Increment of quotient with eac

    h subtraction by 10.subwf rmng_num, f ; Subtract the number by 10.skpnc ; If already negative, s

    top division.goto get_dig ; Else, continue dividing.addwf rmng_num, f ; Restore number.decf quotient, f ; Restore quotient.

    movf rmng_num, w ; Move rmng_num to temp_num.movwf temp_nummovf quotient, w ; Move quotient to rmng_num.movwf rmng_nummovf temp_num, w

    return

    get_dig2movlw d'10' ; To split the digits, d

    ivide them by 10.incf quotient2, f ; Increment of quotient with eac

    h subtraction by 10.subwf rmng_num2, f ; Subtract the number by 10.skpnc ; If already negative, s

    top division.goto get_dig2 ; Else, continue dividing.addwf rmng_num2, f ; Restore number.decf quotient2, f ; Restore quotient.

    movf rmng_num2, w ; Move rmng_num to temp_num.movwf temp_num2

  • 8/13/2019 3738 Wheelchair

    16/28

    movf quotient2, w ; Move quotient to rmng_num.movwf rmng_num2movf temp_num2, w

    return

    ;------------------------------------------------------------------------------------------------------------------------;SENSOR2 Conversion Subroutine.;------------------------------------------------------------------------------------------------------------------------

    briteconv2call initadc ; Initialize and begin ADC on AN

    1.call chan0call delay20 ; Delay to charge up holding cap

    acitor.call delay20call startadc ; Start ADC and await the comple

    tion.

    banksel ADRESH ; Pass high byte to briteH.movf ADRESH, w

    movwf briteH2movwf briteHtrans2

    banksel ADRESL ; Pass low byte to briteL.movf ADRESL, wbanksel briteL2movwf briteL2movwf briteLtrans2

    arrgbrite2; bcf STATUS, C ; Rearrange briteL from xx00 0000 to 0000 00xx.

    rlf briteL2, fbtfss STATUS, C

    goto $+2bsf briteL2, 0

    bcf STATUS, Crlf briteL2, fbtfss STATUS, Cgoto $+2bsf briteL2, 0

    bcf STATUS, C ; Pass LSbit of briteH to 2nd bit of briteL.

    rrf briteH2, fbtfss STATUS, C

    goto $+2bsf briteL2, 2

    ;chkbrite movlw d'30' ; Check if brightness is below 30%.

    ; subwf briteH, w; skpc; goto onbklit ; If yes, activate backlit.; goto offbklit ; Else, off backlit.

  • 8/13/2019 3738 Wheelchair

    17/28

    ;onbklit;offbklit

    brkdigbrite2banksel briteH2movf briteH2, wmovwf rmng_num2

    clrf quotient2 ; Break ADC high byte result to individual digits to be displayed.

    call get_dig2movwf digitbritedata02

    clrf quotient2call get_dig2movwf digitbritedata12

    clrf quotient2call get_dig2movwf digitbritedata22

    banksel briteL2movf briteL2, wmovwf rmng_num2

    clrf quotient2 ; Break ADC low byte result to individual digits to be displayed.

    call get_dig2movwf digitbritedataL02

    clrf quotient2call get_dig2movwf digitbritedataL12

    clrf quotient2call get_dig2movwf digitbritedataL22

    calcbrite2banksel briteL2movlw d'13' ; Assign

    multiplier and clear fractional brightness reading.clrf britefract2

    mult132 addwf britefract2, f ; Multiply ADRESL by 13to obtain fractional brightness reading.

    decfsz briteL2, fgoto mult132

    breakbrite2 movf briteH2, w ; Break up brightness re

    adings to ind. digits to be displayed.movwf rmng_num2

    clrf quotient2call get_dig2movwf britenonfract02

    clrf quotient2call get_dig2movwf britenonfract12

  • 8/13/2019 3738 Wheelchair

    18/28

    clrf quotient2call get_dig2movwf britenonfract22

    movf britefract2 , wmovwf rmng_num2

    clrf quotient2call get_digmovwf britefract02

    clrf quotient2call get_dig2movwf britefract12

    return

    ;------------------------------------------------------------------------------------------------------------------------;SENSOR1 Conversion Subroutine.;-------------------------------------------------------------------------------

    -----------------------------------------

    briteconvcall initadc ; Initialize and begin ADC on AN

    1.call chan1call delay20 ; Delay to charge up holding cap

    acitor.call delay20call startadc ; Start ADC and await the comple

    tion.SENSOR1

    banksel ADRESH ; Pass high byte to briteH.

    movf ADRESH, wmovwf briteHmovwf briteHtrans

    banksel ADRESL ; Pass low byte to briteL.movf ADRESL, wbanksel briteLmovwf briteLmovwf briteLtrans

    arrgbrite bcf STATUS, C ; Rearrange briteL from xx00 0000 to 0000 00xx.

    rlf briteL, f

    btfss STATUS, Cgoto $+2bsf briteL, 0

    bcf STATUS, Crlf briteL, fbtfss STATUS, Cgoto $+2bsf briteL, 0

  • 8/13/2019 3738 Wheelchair

    19/28

    bcf STATUS, C ; Pass LSbit of briteH to 2nd bit of briteL.

    rrf briteH, fbtfss STATUS, Cgoto $+2bsf briteL, 2

    ;chkbrite movlw d'30' ; Check if brightness is below 30%.

    ; subwf briteH, w; skpc; goto onbklit ; If yes, activate backlit.; goto offbklit ; Else, off backlit.

    ;onbklit;offbklit

    brkdigbritebanksel briteHmovf briteH, wmovwf rmng_num

    clrf quotient ; Break ADC high byte result to individual digits to be displayed.

    call get_digmovwf digitbritedata0

    clrf quotientcall get_digmovwf digitbritedata1

    clrf quotientcall get_digmovwf digitbritedata2

    banksel briteLmovf briteL, w

    movwf rmng_num

    clrf quotient ; Break ADC low byte result to individual digits to be displayed.

    call get_digmovwf digitbritedataL0

    clrf quotientcall get_digmovwf digitbritedataL1

    clrf quotientcall get_dig

    movwf digitbritedataL2

    calcbritebanksel briteLmovlw d'13' ; Assign

    multiplier and clear fractional brightness reading.clrf britefract

    mult13 addwf britefract, f ; Multiply ADRESL by 13to obtain fractional brightness reading.

  • 8/13/2019 3738 Wheelchair

    20/28

    decfsz briteL, fgoto mult13

    breakbrite movf briteH, w ; Break up brightness readings to ind. digits to be displayed.

    movwf rmng_num

    clrf quotientcall get_digmovwf britenonfract0

    clrf quotientcall get_digmovwf britenonfract1

    clrf quotientcall get_digmovwf britenonfract2

    movf britefract , wmovwf rmng_num

    clrf quotientcall get_dig

    movwf britefract0

    clrf quotientcall get_digmovwf britefract1

    return

    displaydata movlw d'48' ; Convert individual digits to ASCII.

    addwf digitbritedata22, faddwf digitbritedata12, f

    addwf digitbritedata02, faddwf digitbritedataL22, faddwf digitbritedataL12, faddwf digitbritedataL02, f

    addwf britenonfract22, faddwf britenonfract12, faddwf britenonfract02, faddwf britefract12, faddwf britefract02, f

    addwf digitbritedata2, faddwf digitbritedata1, f

    addwf digitbritedata0, faddwf digitbritedataL2, faddwf digitbritedataL1, faddwf digitbritedataL0, f

    addwf britenonfract2, faddwf britenonfract1, faddwf britenonfract0, faddwf britefract1, faddwf britefract0, f

  • 8/13/2019 3738 Wheelchair

    21/28

    return

    ;--------------------Display to LCD-----------------------------------------------------

    DisStanby call clrscreencall cursorhomemovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A'P'call PUTCHARmovlw A'r'call PUTCHARmovlw A'e'call PUTCHARmovlw A's'call PUTCHARmovlw A's'

    call PUTCHARmovlw A' 'call PUTCHARmovlw A'Y'call PUTCHARmovlw A'o'call PUTCHARmovlw A'u'call PUTCHARmovlw A'r'call PUTCHARmovlw A' 'call PUTCHAR

    call nextlinemovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A'B'

    call PUTCHAR

    movlw A'u'call PUTCHARmovlw A't'call PUTCHARmovlw A't'call PUTCHARmovlw A'o'call PUTCHAR

  • 8/13/2019 3738 Wheelchair

    22/28

    movlw A'n'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHAR

    call visualdelayreturn

    DisFinish call clrscreencall nextlinemovlw A'S'call PUTCHAR

    movlw A't'call PUTCHARmovlw A'o'call PUTCHARmovlw A'p'call PUTCHARmovlw A' 'call PUTCHARmovlw A' '

    call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHAR

    call visualdelayreturn

    DisLCD call clrscreencall cursorhome ; Reposition cur

    sor to home. movlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A'R'call PUTCHARmovlw A'e'call PUTCHARmovlw A'a'call PUTCHARmovlw A'd'call PUTCHAR

    movlw A'y'call PUTCHAR

    movlw A'.'call PUTCHAR

    movlw A'.'call PUTCHAR

    call visualdelay

  • 8/13/2019 3738 Wheelchair

    23/28

    return

    DisOne call clrscreen

    call cursorhomemovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A'R'call PUTCHARmovlw A'e'call PUTCHARmovlw A'a'call PUTCHARmovlw A'd'call PUTCHARmovlw A'y'call PUTCHAR

    movlw A'.'call PUTCHAR

    movlw A'.'

    call PUTCHAR

    call nextlinemovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHAR

    movlw A'1'call PUTCHAR

    call visualdelayreturn

    DisTwo call clrscreen

    call cursorhomemovlw A' 'call PUTCHARmovlw A' '

    call PUTCHARmovlw A'R'call PUTCHARmovlw A'e'call PUTCHARmovlw A'a'call PUTCHARmovlw A'd'call PUTCHARmovlw A'y'

  • 8/13/2019 3738 Wheelchair

    24/28

    call PUTCHAR

    movlw A'.'call PUTCHAR

    movlw A'.'call PUTCHAR

    call nextlinemovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A'2'call PUTCHAR

    call visualdelay

    return

    DisTree call clrscreen

    call cursorhomemovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A'R'call PUTCHARmovlw A'e'call PUTCHAR

    movlw A'a'call PUTCHARmovlw A'd'call PUTCHARmovlw A'y'call PUTCHAR

    movlw A'.'call PUTCHAR

    movlw A'.'call PUTCHAR

    call nextlinemovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' '

  • 8/13/2019 3738 Wheelchair

    25/28

    call PUTCHARmovlw A'3'call PUTCHAR

    call visualdelayreturn

    DisFoward call clrscreencall cursorhome ; Reposition cur

    sor to home.movlw A'M'call PUTCHARmovlw A'o'call PUTCHARmovlw A'v'call PUTCHARmovlw A'e'call PUTCHARmovlw A' 'call PUTCHAR

    call nextline

    movlw A'F'call PUTCHARmovlw A'o'call PUTCHARmovlw A'w'call PUTCHARmovlw A'a'call PUTCHARmovlw A'r'call PUTCHAR

    movlw A'd'call PUTCHAR

    movlw A' 'call PUTCHARcall visualdelayreturn

    DisRvs call clrscreencall cursorhomemovlw A'M'call PUTCHARmovlw A'o'call PUTCHARmovlw A'v'call PUTCHAR

    movlw A'e'call PUTCHARmovlw A' 'call PUTCHAR

    call nextlinemovlw A'R'call PUTCHARmovlw A'e'call PUTCHAR

  • 8/13/2019 3738 Wheelchair

    26/28

    movlw A'v'call PUTCHARmovlw A'e'call PUTCHARmovlw A'r'call PUTCHAR

    movlw A's'call PUTCHARmovlw A'e'call PUTCHARmovlw A' 'call PUTCHARcall visualdelayreturn

    DisLeft call clrscreencall cursorhomemovlw A'M'call PUTCHARmovlw A'o'call PUTCHARmovlw A'v'call PUTCHAR

    movlw A'e'call PUTCHARmovlw A' 'call PUTCHAR

    call nextlinemovlw A'L'call PUTCHARmovlw A'e'call PUTCHARmovlw A'f'call PUTCHARmovlw A't'

    call PUTCHARmovlw A' 'call PUTCHAR

    movlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARcall visualdelayreturn

    DisRight call clrscreencall cursorhomemovlw A'M'call PUTCHARmovlw A'o'call PUTCHARmovlw A'v'call PUTCHARmovlw A'e'

  • 8/13/2019 3738 Wheelchair

    27/28

    call PUTCHARmovlw A' 'call PUTCHAR

    call nextlinemovlw A'R'call PUTCHARmovlw A'i'call PUTCHARmovlw A'g'call PUTCHARmovlw A'h'call PUTCHARmovlw A't'call PUTCHAR

    movlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' 'call PUTCHARcall visualdelayreturn

    DisReverse call clrscreencall cursorhomemovlw A' 'call PUTCHARmovlw A' 'call PUTCHARmovlw A' '

    call PUTCHARmovlw A'P'call PUTCHARmovlw A'r'call PUTCHARmovlw A'e'call PUTCHARmovlw A's'call PUTCHARmovlw A's'call PUTCHARmovlw A' 'call PUTCHAR

    movlw A'Y'call PUTCHARmovlw A'o'call PUTCHARmovlw A'u'call PUTCHARmovlw A'r'call PUTCHARmovlw A' 'call PUTCHAR

  • 8/13/2019 3738 Wheelchair

    28/28

    call nextlinemovlw A' 'call PUTCHARmovlw A'R'call PUTCHARmovlw A'e'call PUTCHARmovlw A'v'call PUTCHARmovlw A'e'call PUTCHARmovlw A'r'call PUTCHARmovlw A's'call PUTCHARmovlw A'e'call PUTCHARmovlw A' 'call PUTCHARmovlw A'B'call PUTCHAR

    movlw A'u'

    call PUTCHARmovlw A't'call PUTCHARmovlw A't'call PUTCHARmovlw A'o'call PUTCHARmovlw A'n'call PUTCHAR

    call visualdelayreturn

    ;-------------------------------------------------------------------------------

    -----------------------------------------; End of Programme.;------------------------------------------------------------------------------------------------------------------------

    END