Hola ha todos, me llamo Jorge, me presento ya que soy nuevo, hace mucho tiempo, hice un par de robots minisumo que publicaron en el nº 1 de la revista francesa Electronique Pratique (Micros & Robots).
En el CD, venía la PCB y archivo HEX para grabar en un PIC 16F84. El problema es que junto a este HEX, también traía dos archivos, minisumo.asm y minisumo.inc. Estos archivos deben ser macros para modificar ciertos valores de funcionamiento en el Minisumo.
no consigo meter estas macros dentro del archivo source ya que he probado de mil formas con el MPLAB IDE v8.02, pero no tengo conocimientos de programación y no consigo detectar porque me sale BUILD FAILED.
Os adjunto foto y los archivos en cuestión para que alguien que sepa en este tema me eche un cable, se lo agradecería enormemente ya que ambos robots funcionan bien pero a casusa de la macro no se detectan entre ellos a través de los infrarrojos.
Por último un consejo de por donde debo empezar a aprender a programar, soy preferido de MICROCHIP....Gracias de antemano
Archivo minisumo.ASM
;************************************************************************
; *
; Nom du fichier: minisumo.asm *
; Date: 14/01/2001 *
; *
; Auteur: Frederic GIAMARCHI *
; Societe: I.U.T. G.E.I.I. de NIMES *
; * *
;************************************************************************
; *
; Fichiers requis: macro1.inc *
; minisumo.inc *
; *
;************************************************************************
; *
; Notes: *
; *
; *
; *
; *
;************************************************************************
errorlevel -302 ; supprime l'alerte sur les banks
list p=16F84 ; list directive to define processor
include <p16F84.inc> ; processor specific variable definitions
include <macro1.inc> ; fichier des macros de base
include <minisumo.inc> ; macro et constantes associées
LIST ;
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _XT_OSC
;******************************************************************
; Definitions des entrees/sorties des option et des interruptions
;******************************************************************
; 0 en sortie 1 en entree
TRISA_VAL equ b'00000000' ; Port A: RA3 en sortie
TRISB_VAL equ b'11000000' ; Port B: LED en sortie
OPTION_VAL equ b'00000001' ; portB pull-up, tmr0 int.
; Timer increment: Fosc/4/4= 250 kHz soit 4 µsec
INTCON_VAL equ b'10101000' ; set GIE, T0IE, RBIE
;**********************************************************************
ORG 0x000 ; Vecteur de reset
goto DEBUT ; Saut vers debut du programme
goto DEBUT
ORG 0x004 ; Vacteur d'interruption
sauve_W_ET_STATUS
INT_ROUTINE
restaure_W_et_STATUS
retfie ; return from interrupt
;**********************************************************************
; programme principal
DEBUT
RAZ_RAM
call INIT
FLASH_DR On
movlw 1 ; fait clignoter alternativement
movwf DUREE
call TEMPO
FLASH_GA On
RET_1
btfss SUMO,CERCLE ; Boucle d'attente
goto RET_1 ;
bcf SUMO,CERCLE
FLASH_DR Off
FLASH_GA Off
movlw .50 ; 5 secondes
movwf DUREE
call TEMPO
;**********************************************************************
PROG ; boucle principale
btfsc SUMO, CERCLE
goto SOL_CERCLE
btfsc SUMO, RADAR_IR
goto TOURNE
goto EN_AVANT
PROG_1
movlw .10 ; attente 1 seconde
movwf DUREE
call TEMPO
call RADAR
goto PROG
SOL_CERCLE
ARRET DR ; arret
ARRET GA
LED_DR_Off
LED_GA_Off
movlw 2 ; rotation sur place
movwf DR_Vit
MOT_DR AV
movlw 2
movwf GA_Vit
MOT_GA AR
bsf SUMO, MOTEUR ; valide les nouvelles vitesses
movlw .20 ; 2 secondes
movwf DUREE
call TEMPO
ARRET DR ; arret
ARRET GA
bcf SUMO, CERCLE
goto PROG
;======================================= Marche avant
EN_AVANT
movlw 2
movwf DR_Vit
MOT_DR AV
movlw 2
movwf GA_Vit
MOT_GA AV
bsf SUMO, MOTEUR ; valide les nouvelles vitesses
clrf MS_100
goto PROG_1
;======================================= programme une rotation
TOURNE
btfss SUMO, RADAR_IR_DR
goto TOURNE_GAUCHE
btfss SUMO, RADAR_IR_GA
goto TOURNE_DROITE
bcf SUMO, RADAR_IR
bcf SUMO, RADAR_IR_DR
bcf SUMO, RADAR_IR_GA
FLASH_DR On
movlw 1 ; fait clignoter alternativement
movwf DUREE
call TEMPO
FLASH_GA On
goto EN_AVANT
TOURNE_GAUCHE
FLASH_DR Off
FLASH_GA On
movlw 1 ; rotation sur place
movwf DR_Vit
MOT_DR AV
movlw 1
movwf GA_Vit
MOT_GA AR
bsf SUMO, MOTEUR ; valide les nouvelles vitesses
movlw .10 ; 1 seconde
movwf DUREE
call TEMPO
bcf SUMO, RADAR_IR
bcf SUMO, RADAR_IR_DR
bcf SUMO, RADAR_IR_GA
goto PROG
TOURNE_DROITE
FLASH_DR On
FLASH_GA Off
movlw 1 ; rotation sur place
movwf DR_Vit
MOT_DR AR
movlw 1
movwf GA_Vit
MOT_GA AV
bsf SUMO, MOTEUR ; valide les nouvelles vitesses
movlw .10 ; 1 seconde
movwf DUREE
call TEMPO
bcf SUMO, RADAR_IR
bcf SUMO, RADAR_IR_DR
bcf SUMO, RADAR_IR_GA
goto PROG
;**********************************************************************
; Initialisation des ports, option et interruptions
INIT
BANK1
movlw TRISA_VAL ; configure ...
movwf TRISA ; ...le Port A
movlw TRISB_VAL ; configure ...
movwf TRISB ; ...le Port B
movlw OPTION_VAL ; configure ...
movwf OPTION_REG ; ...Pic
BANK0
movlw INTCON_VAL ; configure les interruptions et ...
movwf INTCON ; ...valide les interruptions
clrf TMR0
movlw 03
movwf PORTA
movlw 30
movwf PORTB
return
TABLE_MLI ; 6 vitesses
addwf PCL,F
dt b'00000000'
dt b'10001000'
dt b'10010010'
dt b'10101010'
dt b'11101110'
dt b'11111111'
;==============================================================
; Temporisation en multiple de 100ms
TEMPO
movf DUREE,W
bcf INTCON, GIE
addwf MS_100,W
movwf DUREE
bsf INTCON, GIE
Tempo_1
movf DUREE, W
xorwf MS_100, W
btfss STATUS, Z
goto Tempo_1
return
;==============================================================
; RADAR InfraRouge
RADAR
FLASH_DR Off
FLASH_GA Off
bcf SUMO, RADAR_IR_DR
bcf SUMO, RADAR_IR_GA
bcf SUMO, RADAR_IR
ARRET DR ; arret
ARRET GA
movlw .05 ; 0,5 seconde
movwf DUREE
call TEMPO
bcf INTCON,GIE ; bloque les interruptions
clrf TMR0
RADAR_1
btfsc TMR0, 7 ; impulsion pendant 512 microsec
goto RADAR_2
PULSE_IR DR ;
goto RADAR_1
RADAR_2
btfsc PORTB, LIRE_IR ; test photomodule
goto RADAR_SUITE
bsf SUMO, RADAR_IR_DR ; reception valide a droite
bsf SUMO, RADAR_IR
RADAR_SUITE ; Test IR a gauche
clrf TMR0
RADAR_3
btfsc TMR0, 7 ; impulsion pendant 512 microsec
goto RADAR_4
PULSE_IR GA ;
goto RADAR_3
RADAR_4
btfsc PORTB, LIRE_IR ; test photomodule
goto RADAR_FIN
bsf SUMO, RADAR_IR_GA ; reception valide a gauche
bsf SUMO, RADAR_IR
RADAR_FIN
bsf INTCON,GIE ; debloque les interruptions
return
END ; directive 'fin de programme'
;==============================================================
Archivo minisumo.inc
LIST
; PERSO.INC
NOLIST
; Ce fichier definit des macros et les constantes
; pour le robot MiniSumo
; Ce fichier doit etre inclus dans le fichier source par la directive
; include <minisumo.inc>
; copié avec le fichier source
;==========================================================================
;
; Historique des revisions
;
;Rev: Date: Raison:
;1.00 14/01/2001 realisation initiale
;==========================================================================
;***** DEFINITIONS DES CONSTANTES
LIRE_IR EQU RB7
LIRE_SOL EQU RB6
IR_DRO EQU RB5
IR_GAU EQU RA0
LED_DRO EQU RB4
LED_GAU EQU RA1
SENS_DR EQU RB0
SENS_GA EQU RA2
EN_DR EQU RB1
EN_GA EQU RA3
PIEZO EQU RA3 ; non utilisé
AV EQU h'00'
AR EQU h'11'
DR EQU h'22'
GA EQU h'33'
RADAR_IR_DR EQU 6
CERCLE EQU 5
MOTEUR EQU 4
RADAR_IR_GA EQU 3
RADAR_IR EQU 2
FLASH_DRO EQU 7
FLASH_GAU EQU 6
On EQU h'44'
Off EQU h'55'
#DEFINE LED_DR_On bcf PORTB,LED_DRO
#DEFINE LED_DR_Off bsf PORTB,LED_DRO
#DEFINE LED_GA_On bcf PORTA,LED_GAU
#DEFINE LED_GA_Off bsf PORTA,LED_GAU
#DEFINE MOT_DR_On bsf PORTB,EN_DR
#DEFINE MOT_DR_Off bcf PORTB,EN_DR
#DEFINE MOT_GA_On bsf PORTA,EN_GA
#DEFINE MOT_GA_Off bcf PORTA,EN_GA
;***** DEFINITIONS DES VARIABLES
cblock 0x0F
GA_Vit, DR_Vit, VIT_DR, VIT_GA, SUMO, LED_ETAT, TEMP_LED
MS_100, MSEC, DUREE
endc
;==============================================================
; Initialisation
;
;init macro
; bcf STATUS, RP0 ; banque 0
; endm
;==============================================================
; Routine d'interruption activée toutes les 1ms
INT_ROUTINE macro
btfsc INTCON, RBIF ; ligne noire au Sol ?
goto AUTRE
bcf INTCON,T0IF ; 1 msec
movlw 255-250
movwf TMR0
incf MSEC,F ; compte les ms
movlw .99
xorwf MSEC, W
btfss STATUS, Z
goto MLI_DR ; saut vers les moteurs
incf MS_100,F ; compte les 100 ms
clrf MSEC
;==============================================================
; routine pour faire cligniter les DELs toutes les 200ms
btfss MS_100,0
goto FIN_LED
btfss LED_ETAT,FLASH_DRO
goto FLASH_2
btfss PORTB,LED_DRO ; Flash Led droite
goto FLASH_1
LED_DR_On
goto FLASH_2
FLASH_1
LED_DR_Off
FLASH_2
btfss LED_ETAT,FLASH_GAU
goto FIN_LED
btfss PORTA,LED_GAU ; Flash Led droite
goto FLASH_3
LED_GA_On
goto FIN_LED
FLASH_3
LED_GA_Off
FIN_LED
;==============================================================
; routine pour les moteurs
MLI_DR
btfss SUMO, MOTEUR ; Robot en marche ?
goto FIN_MOT
bcf STATUS,C
rlf VIT_DR,F ; change la vitesse si necessaire
btfss STATUS,C ;
b OFF_DR ;
MOT_DR_On ; moteur on
incf VIT_DR,F
b MLI_GA ;
OFF_DR MOT_DR_Off ; moteur off
;
MLI_GA
bcf STATUS,C
rlf VIT_GA,F
btfss STATUS,C
b OFF_GA
MOT_GA_On
incf VIT_GA,F
b FIN_MOT
OFF_GA MOT_GA_Off
FIN_MOT
goto FIN_INT
;==============================================================
; Traitement du capteur au sol
AUTRE
movf PORTB,F
bcf INTCON, RBIF
btfsc PORTB,LIRE_SOL ; bande noire = 1
bsf SUMO,CERCLE
FIN_INT
endm ; fin de la routine d'interruption
;==============================================================
; Moteur
MOT_DR macro var
if ( var == AV )
bcf PORTB,SENS_DR ; marche avant
else
bsf PORTB,SENS_DR ; marche arriere
endif
movf DR_Vit,W
call TABLE_MLI
movwf VIT_DR
bsf SUMO, MOTEUR
endm
; = = = = = = = =
MOT_GA macro var
if ( var == AV )
bcf PORTA,SENS_GA ; marche avant
else
bsf PORTA,SENS_GA ; marche arriere
endif
movf GA_Vit,W
call TABLE_MLI
movwf VIT_GA
bsf SUMO, MOTEUR
endm
; = = = = = = = =
ARRET macro var
if ( var == DR )
MOT_DR_Off
clrf VIT_DR
else
MOT_GA_Off
clrf VIT_GA
endif
bcf SUMO, MOTEUR
endm
;==============================================================
; Valide le clignotement des deux Leds
FLASH_DR macro var
if ( var == On )
LED_DR_On
bsf LED_ETAT,FLASH_DRO
else
LED_DR_Off
bcf LED_ETAT,FLASH_DRO
endif
endm
FLASH_GA macro var
if ( var == On )
LED_GA_On
bsf LED_ETAT,FLASH_GAU
else
LED_GA_Off
bcf LED_ETAT,FLASH_GAU
endif
endm
;==============================================================
; Genere les implusions de 38 kHz
PULSE_IR macro var
if ( var == DR )
bcf PORTB,IR_DRO
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
bsf PORTB,IR_DRO
nop
nop
nop
nop
nop
nop
nop
nop
else
bcf PORTA,IR_GAU
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
bsf PORTA,IR_GAU
nop
nop
nop
nop
nop
nop
nop
nop
endif
endm
;==============================================================
Archivo MINISUMO(HEX).ASM
; Generated by WinDis84, (c) Nigel Goodwin 1998.
LIST P=16F84, F=INHX8M
include "P16FXX.inc"
ORG 0x0000
GOTO Label_0001
GOTO Label_0001
ORG 0x0004
MOVWF 0x0C
MOVF STATUS , W
MOVWF 0x0D
BTFSC INTCON , RBIF
GOTO Label_0002
BCF INTCON , T0IF
MOVLW 0x05
MOVWF TMR0
INCF 0x17 , f
MOVLW 0x63
XORWF 0x17 , W
BTFSS STATUS , Z
GOTO Label_0003
INCF 0x16 , f
CLRF 0x17
BTFSS 0x16 , 00
GOTO Label_0003
BTFSS 0x14 , 07
GOTO Label_0004
BTFSS PORTB , 04
GOTO Label_0005
BCF PORTB , 04
GOTO Label_0004
Label_0005 BSF PORTB , 04
Label_0004 BTFSS 0x14 , 06
GOTO Label_0003
BTFSS PORTA , 01
GOTO Label_0006
BCF PORTA , 01
GOTO Label_0003
Label_0006 BSF PORTA , 01
Label_0003 BTFSS 0x13 , 04
GOTO Label_0007
BCF STATUS , C
RLF 0x11 , f
BTFSS STATUS , C
GOTO Label_0008
BSF PORTB , 01
INCF 0x11 , f
GOTO Label_0009
Label_0008 BCF PORTB , 01
Label_0009 BCF STATUS , C
RLF 0x12 , f
BTFSS STATUS , C
GOTO Label_000A
BSF PORTA , 03
INCF 0x12 , f
GOTO Label_0007
Label_000A BCF PORTA , 03
Label_0007 GOTO Label_000B
Label_0002 MOVF PORTB , f
BCF INTCON , RBIF
BTFSC PORTB , 06
BSF 0x13 , 05
Label_000B MOVF 0x0D , W
MOVWF STATUS
SWAPF 0x0C , f
SWAPF 0x0C , W
RETFIE
Label_0001 MOVLW 0x30
MOVWF 0x0E
MOVLW 0x0F
MOVWF FSR
Label_000C CLRF INDF
INCF FSR , f
DECFSZ 0x0E , f
GOTO Label_000C
CALL Label_000D
BCF PORTB , 04
BSF 0x14 , 07
MOVLW 0x01
MOVWF 0x18
CALL Label_000E
BCF PORTA , 01
BSF 0x14 , 06
Label_000F BTFSS 0x13 , 05
GOTO Label_000F
BCF 0x13 , 05
BSF PORTB , 04
BCF 0x14 , 07
BSF PORTA , 01
BCF 0x14 , 06
MOVLW 0x32
MOVWF 0x18
CALL Label_000E
Label_0014 BTFSC 0x13 , 05
GOTO Label_0010
BTFSC 0x13 , 02
GOTO Label_0011
GOTO Label_0012
Label_0016 MOVLW 0x0A
MOVWF 0x18
CALL Label_000E
CALL Label_0013
GOTO Label_0014
Label_0010 BCF PORTB , 01
CLRF 0x11
BCF 0x13 , 04
BCF PORTA , 03
CLRF 0x12
BCF 0x13 , 04
BSF PORTB , 04
BSF PORTA , 01
MOVLW 0x02
MOVWF 0x10
BCF PORTB , 00
MOVF 0x10 , W
CALL Label_0015
MOVWF 0x11
BSF 0x13 , 04
MOVLW 0x02
MOVWF 0x0F
BSF PORTA , 02
MOVF 0x0F , W
CALL Label_0015
MOVWF 0x12
BSF 0x13 , 04
BSF 0x13 , 04
MOVLW 0x14
MOVWF 0x18
CALL Label_000E
BCF PORTB , 01
CLRF 0x11
BCF 0x13 , 04
BCF PORTA , 03
CLRF 0x12
BCF 0x13 , 04
BCF 0x13 , 05
GOTO Label_0014
Label_0012 MOVLW 0x02
MOVWF 0x10
BCF PORTB , 00
MOVF 0x10 , W
CALL Label_0015
MOVWF 0x11
BSF 0x13 , 04
MOVLW 0x02
MOVWF 0x0F
BCF PORTA , 02
MOVF 0x0F , W
CALL Label_0015
MOVWF 0x12
BSF 0x13 , 04
BSF 0x13 , 04
CLRF 0x16
GOTO Label_0016
Label_0011 BTFSS 0x13 , 06
GOTO Label_0017
BTFSS 0x13 , 03
GOTO Label_0018
BCF 0x13 , 02
BCF 0x13 , 06
BCF 0x13 , 03
BCF PORTB , 04
BSF 0x14 , 07
MOVLW 0x01
MOVWF 0x18
CALL Label_000E
BCF PORTA , 01
BSF 0x14 , 06
GOTO Label_0012
Label_0017 BSF PORTB , 04
BCF 0x14 , 07
BCF PORTA , 01
BSF 0x14 , 06
MOVLW 0x01
MOVWF 0x10
BCF PORTB , 00
MOVF 0x10 , W
CALL Label_0015
MOVWF 0x11
BSF 0x13 , 04
MOVLW 0x01
MOVWF 0x0F
BSF PORTA , 02
MOVF 0x0F , W
CALL Label_0015
MOVWF 0x12
BSF 0x13 , 04
BSF 0x13 , 04
MOVLW 0x0A
MOVWF 0x18
CALL Label_000E
BCF 0x13 , 02
BCF 0x13 , 06
BCF 0x13 , 03
GOTO Label_0014
Label_0018 BCF PORTB , 04
BSF 0x14 , 07
BSF PORTA , 01
BCF 0x14 , 06
MOVLW 0x01
MOVWF 0x10
BSF PORTB , 00
MOVF 0x10 , W
CALL Label_0015
MOVWF 0x11
BSF 0x13 , 04
MOVLW 0x01
MOVWF 0x0F
BCF PORTA , 02
MOVF 0x0F , W
CALL Label_0015
MOVWF 0x12
BSF 0x13 , 04
BSF 0x13 , 04
MOVLW 0x0A
MOVWF 0x18
CALL Label_000E
BCF 0x13 , 02
BCF 0x13 , 06
BCF 0x13 , 03
GOTO Label_0014
Label_000D BSF STATUS , RP0
MOVLW 0x00
MOVWF TRISA
MOVLW 0xC0
MOVWF TRISB
MOVLW 0x01
MOVWF OPTION_REG
BCF STATUS , RP0
MOVLW 0xA8
MOVWF INTCON
CLRF TMR0
MOVLW 0x03
MOVWF PORTA
MOVLW 0x30
MOVWF PORTB
RETURN
Label_0015 ADDWF PCL , f
RETLW 0x00
RETLW 0x88
RETLW 0x92
RETLW 0xAA
RETLW 0xEE
RETLW 0xFF
Label_000E MOVF 0x18 , W
BCF INTCON , GIE
ADDWF 0x16 , W
MOVWF 0x18
BSF INTCON , GIE
Label_0019 MOVF 0x18 , W
XORWF 0x16 , W
BTFSS STATUS , Z
GOTO Label_0019
RETURN
Label_0013 BSF PORTB , 04
BCF 0x14 , 07
BSF PORTA , 01
BCF 0x14 , 06
BCF 0x13 , 06
BCF 0x13 , 03
BCF 0x13 , 02
BCF PORTB , 01
CLRF 0x11
BCF 0x13 , 04
BCF PORTA , 03
CLRF 0x12
BCF 0x13 , 04
MOVLW 0x05
MOVWF 0x18
CALL Label_000E
BCF INTCON , GIE
CLRF TMR0
Label_001B BTFSC TMR0 , 07
GOTO Label_001A
BCF PORTB , 05
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BSF PORTB , 05
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
GOTO Label_001B
Label_001A BTFSC PORTB , 07
GOTO Label_001C
BSF 0x13 , 06
BSF 0x13 , 02
Label_001C CLRF TMR0
Label_001E BTFSC TMR0 , 07
GOTO Label_001D
BCF PORTA , 00
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BSF PORTA , 00
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
GOTO Label_001E
Label_001D BTFSC PORTB , 07
GOTO Label_001F
BSF 0x13 , 03
BSF 0x13 , 02
Label_001F BSF INTCON , GIE
RETURN
ORG 0x2000
DATA 0x0F
DATA 0x0F
DATA 0x0F
DATA 0x0F
ORG 0x2007
DATA 0x19
ORG 0x2100
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
END