Playing with PICs

Robot seguidor de lĂ­nea

Small program to control a line following robot with 8 sensors, needs to be cleaned. PIC 16F628A, 2 Motors, 8 Sensors


list p=16f628A

errorlevel -302

radix hex

w EQU 0x00
f EQU 0x01
pc EQU 0x02
Z EQU 0x02
C EQU 0x00
STATUS EQU 0x03
PUERTOA EQU 0x05
PUERTOB EQU 0x06
INTCON EQU 0x0b
CMCON EQU 0x1f
Ti0 EQU 0x20
Ti1 EQU 0x21
Ti2 EQU 0x22
OPT EQU 0x81

ORG 0x00

nop
nop
nop

goto ini

ini MOVLW 0x07
MOVWF CMCON
BSF STATUS, 5
CLRF PUERTOA ; PUERTO A son SALIDAS
CLRF PUERTOB ; PUERTO B set como ENTRADAS
MOVLW 0xFF
MOVWF PUERTOB
BCF STATUS, 5

BSF PUERTOA, 1
BSF PUERTOA, 0

CICLO

BTFSC PUERTOB, 7
GOTO BOTH_ON1
BACK

BTFSS PUERTOB, 7
GOTO AP2

BTFSS PUERTOB, 6
GOTO AP2

BTFSS PUERTOB, 5
GOTO AP2

BTFSS PUERTOB, 4
GOTO AP2

BTFSS PUERTOB, 3
GOTO AP1

BTFSS PUERTOB, 2
GOTO AP1

BTFSS PUERTOB, 1
GOTO AP1

BTFSS PUERTOB, 0
GOTO AP1

BSF PUERTOA, 1
BSF PUERTOA, 0

GOTO CICLO

NOP
NOP

BOTH_ON1

BTFSS PUERTOB, 6
GOTO BACK
NOP
BTFSS PUERTOB, 5
GOTO BACK
NOP
BTFSS PUERTOB, 4
GOTO BACK
NOP
BTFSS PUERTOB, 3
GOTO BACK
NOP
BTFSS PUERTOB, 2
GOTO BACK
NOP
BTFSS PUERTOB, 1
GOTO BACK
NOP
BTFSS PUERTOB, 0
GOTO BACK
NOP

BCF PUERTOA, 1
BCF PUERTOA, 0
GOTO CICLO

AP1 BCF PUERTOA,1
BSF PUERTOA,0
NOP
GOTO CICLO

AP2 BCF PUERTOA, 0
BSF PUERTOA, 1
NOP
GOTO CICLO

END