Z2C2 es un pequeño robot rastreador de línea negra sobre fondo blanco, el cual se basa en el sistema diferencial, este consiste en dos motores DC que mueven cada uno las ruedas.
Programa en asembler.
; RASTREADOR Z2C2
; OSCILLATOR XT
; WATCHDOG TIMER ON
; POWER UP TIMER ON
; CODE PROTECT OFF
;----------------------------------------
STATUS EQU 03
PORTA EQU 05
PORTB EQU 06
TRISA EQU 85
TRISB EQU 86
TIME EQU 0C
AUX1 EQU 11
AUX2 EQU 12
AUX3 EQU 13
AUX4 EQU 14
;-----------------------------------------
RESET ORG 00
GOTO INICIO
ORG 05
;-----------------------------------------
CURVE MOVLW D'17'
MOVWF TIME
NOP
RON DECFSZ TIME
GOTO RON
NOP
RETLW 00
;-----------------------------------------
POWER MOVLW D'13'
MOVWF TIME
NOP
TRON DECFSZ TIME
GOTO TRON
NOP
RETLW 00
;-----------------------------------------
REVERS MOVLW D'9'
MOVWF TIME
NOP
ROL DECFSZ TIME
GOTO ROL
NOP
RETLW 00
;-----------------------------------------
STOP MOVLW D'7'
MOVWF TIME
NOP
LOR DECFSZ TIME
GOTO LOR
NOP
RETLW 00
;--------------------------------------------
INICIO BSF STATUS,5
MOVLW B'00110000'
MOVWF TRISB
MOVLW B'00011111'
MOVWF TRISA
BCF STATUS,5
;-----------------------------------------
MOVLW B'00001100'
MOVWF AUX1
MOVLW B'00001111'
MOVWF AUX2
MOVLW B'00001101'
MOVWF AUX3
MOVLW B'00001110'
MOVWF AUX4
;-----------------------------------------
BUCLE MOVLW B'11000000'
MOVWF PORTB
CALL STOP
BTFSC PORTA,4
GOTO BUCLE
GOTO MIRAR
;-----------------------------------------
MIRAR MOVF PORTA,0
XORWF AUX1,0
BTFSC STATUS,2
GOTO ATRAS
MOVF PORTA,0
XORWF AUX2,0
BTFSC STATUS,2
GOTO ADELANTE
MOVF PORTA,0
XORWF AUX3,0
BTFSC STATUS,2
GOTO IZQUIERDA
MOVF PORTA,0
XORWF AUX4,0
BTFSC STATUS,2
GOTO DERECHA
GOTO BUCLE
;-------------------------------------------
ATRAS MOVLW B'11001001'
MOVWF PORTB
CALL REVERS
GOTO BUCLE
ADELANTE MOVLW B'11000110'
MOVWF PORTB
CALL POWER
IZQUIERDA MOVLW B'00000100'
MOVWF PORTB
CALL CURVE
GOTO BUCLE
GOTO BUCLE
IZQUIERDA MOVLW B'00000100'
MOVWF PORTB
CALL CURVE
GOTO BUCLE
DERECHA MOVLW B'00000010'
MOVWF PORTB
CALL CURVE
GOTO BUCLE
;------------------------------------------
END
;------------------------------------------
; CARLOS ALBERTO GOYENECHE ALFONSO.