;*******************************************************************
; Motor Controller.asm
;
; ___________
; + To positive !Vdd Vss! To ground -
; LED 17 !A5 A0! LED 1
; LED 16 !A4 A1! LED 2
; !A3 A2! LED 3
; LED 15 !C5 C0! LED 4
; LED 14 !C4 C1! LED 5
; LED 13 !C3 C2! LED 6
; LED 12 !C6 B4! LED 7
; LED 11 !C7 B5! LED 8
; LED 10 !B7 B6! LED 9
; -----------
;
;
;*******************************************************************
; This is the program for the motor controller. The pot controlls the speed of the motor
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
org 0 ; reset vector
;***** Variables ******
;Reserve our Regesters
cblock H'20'
count1
count2
count3
endc
;***** I/O ******
;Bank 3
;BSF STATUS,RP1
;BCF STATUS,RP0
;movlw B'00000001' ; Turns it to analog
movwf ANSEL ;digital I/O
CLRF ANSELH ;digital I/O
;Bank 2
BCF STATUS,RP1
BSF STATUS,RP0
movlw B'00000000' ; 0=out 1=in
movwf TRISC ; Set tristate mode
movlw B'00000000' ; 0=out 1=in
movwf TRISB ; Set tristate mode
movlw B'00000000' ; 0=out 1=in
movwf TRISA ; Set tristate mode
;Bank 1
BCF STATUS,RP1
BCF STATUS,RP0
;***** Fill Variables ******
;Clear registers
clrf PORTA
clrf PORTB
clrf PORTC
;fill varialbes
movlw B'00000001'
; movwf
;Clear w register
movlw b'00000000'
;*****************************************
;*** MAIN *************************
;*****************************************
main
CALL slide
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
CALL slide
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
CALL slide
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call blink
call pause3
CALL slide
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
CALL slide
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
CALL slide
call pause2;
call pause2;
call pause2;
call pause2;
call pause2;
call blink
call pause3
call blink
call blink
call blink
call blink
CALL slide
CALL slideback
CALL slide
CALL slideback
CALL slide
CALL slideback
CALL slide
CALL slideback
CALL slide
CALL slideback
CALL slide
CALL slideback
CALL slide
CALL slideback
CALL slide
CALL slideback
CALL slide
CALL slideback
CALL slide
CALL slideback
goto main;
blink
call allOff
call allOn
call pause
call allOff
call pause
call allOn
call pause
call allOff
call pause
return
slide
call offLine17;
call onLine1;
call pause;
call offLine1;
call onLine2;
call pause;
call offLine2;
call onLine3;
call pause;
call offLine3;
call onLine4;
call pause;
call offLine4;
call onLine5;
call pause;
call offLine5;
call onLine6;
call pause;
call offLine6;
call onLine7;
call pause;
call offLine7;
call onLine8;
call pause;
call offLine8;
call onLine9;
call pause;
call offLine9;
call onLine10;
call pause;
call offLine10;
call onLine11;
call pause;
call offLine11;
call onLine12;
call pause;
call offLine12;
call onLine13;
call pause;
call offLine13;
call onLine14;
call pause;
call offLine14;
call onLine15;
call pause;
call offLine15;
call onLine16;
call pause;
call offLine16;
call onLine17;
call pause;
call offLine17;
return
slideback
call onLine17;
call pause;
call offLine17;
call onLine16;
call pause;
call offLine16;
call onLine15;
call pause;
call offLine15;
call onLine14;
call pause;
call offLine14;
call onLine13;
call pause;
call offLine13;
call onLine12;
call pause;
call offLine12
call onLine11;
call pause;
call offLine11;
call onLine10;
call pause;
call offLine10;
call onLine9;
call pause;
call offLine9;
call onLine8;
call pause;
call offLine8;
call onLine7;
call pause;
call offLine7;
call onLine6;
call pause;
call offLine6;
call onLine5;
call pause;
call offLine5;
call onLine4;
call pause;
call offLine4;
call onLine3;
call pause;
call offLine3;
call onLine2;
call pause;
call offLine2;
call onLine1;
call pause;
call offLine1;
return
allOff
clrf PORTA
clrf PORTB
clrf PORTC
return
allOn
movlw B'11111111' ;
movwf PORTA
movwf PORTB
movwf PORTC
return
;**********************************
;** Subroutines **
;**********************************
offLine1;
BCF PORTA,0
return
offLine2;
BCF PORTA,1
return
offLine3;
BCF PORTA,2
return
offLine4;
BCF PORTC,0
return
offLine5;
BCF PORTC,1
return
offLine6;
BCF PORTC,2
return
offLine7;
BCF PORTB,4
return
offLine8;
BCF PORTB,5
return
offLine9;
BCF PORTB,6
return
offLine10;
BCF PORTB,7
return
offLine11;
BCF PORTC,7
return
offLine12;
BCF PORTC,6
return
offLine13;
BCF PORTC,3
return
offLine14;
BCF PORTC,4
return
offLine15;
BCF PORTC,5
return
offLine16;
BCF PORTA,4
return
offLine17;
BCF PORTA,5
return
onLine1;
BSF PORTA,0
return
onLine2;
BSF PORTA,1
return
onLine3;
BSF PORTA,2
return
onLine4;
BSF PORTC,0
return
onLine5;
BSF PORTC,1
return
onLine6;
BSF PORTC,2
return
onLine7;
BSF PORTB,4
return
onLine8;
BSF PORTB,5
return
onLine9;
BSF PORTB,6
return
onLine10;
BSF PORTB,7
return
onLine11;
BSF PORTC,7
return
onLine12;
BSF PORTC,6
return
onLine13;
BSF PORTC,3
return
onLine14;
BSF PORTC,4
return
onLine15;
BSF PORTC,5
return
onLine16;
BSF PORTA,4
return
onLine17;
BSF PORTA,5
return
pause
CLRF count1
movlw B'01000000' ;
movwf count2 ; number of shocks
Pause_loop
DECFSZ count1, 1
goto Pause_loop
DECFSZ count2, 1
goto Pause_loop
return
pause2
CLRF count1
CLRF count2
Pause2_loop
DECFSZ count1, 1
goto Pause2_loop
DECFSZ count2, 1
goto Pause2_loop
return
pause3
CLRF count1
CLRF count2
movlw B'00001001' ;
movwf count3
Pause3_loop
DECFSZ count1, 1
goto Pause3_loop
DECFSZ count2, 1
goto Pause3_loop
DECFSZ count3, 1
goto Pause3_loop
return
END