Está en la página 1de 4

EJE_X NORMAL 0001=1 0011=3 0010=2 0110=6 0100=4 1100=12 1000=8 1001=9 EJE_Y NORMAL 10000

EJE_X INVERTIDO 1110=14 1100=12 1101=13 1001= 9 1011=11 0011= 3 0111= 7 0110= 6 EJE_Y INVERTIDO

#define Conta cblock Conta1 Conta2 Conta3 endc Retardo200ms clrf Conta1 clrf Conta2 Repeat decfsz Conta1, F ;Salta cuando Conta1 llega a 0 bra Repeat ;Salta a Repeat para Decrementar Conta1 decfsz Conta2, F ;Salta cuando Conta2 llega a 0 bra Repeat ;Salta a Repeat Return Se guardan los cambios y se continua editando el archivo fuente como sigue: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

81 82 83 84 85 86 87 88 89 90 91 92 93 ; ******************************************************** ; Desarrollo de Microcontroladores y DSPS ; Control de un Motor a pasos Bipolar ; Prctica 3 ; ; Fecha: 15/06/2012 ; Notas: Control de un motor a pasos bipolar mediante ; dos botones que controlan su direccin ; ; Autor: ek ; ************************************************************ LIST P = 18F4550 INCLUDE <P18F4550.INC> ;************************************************************ CONFIG FOSC = HS ;INTOSC_XT no disponible para simulacin, usar HS CONFIG PWRT = ON CONFIG BOR = OFF CONFIG WDT = OFF CONFIG MCLRE = ON CONFIG PBADEN = OFF CONFIG LVP = OFF CONFIG DEBUG = OFF CONFIG XINST = OFF ; CODE ****************************************************** cblock SecuenC ;Indice de la Secuencia endc ORG 0x00 ;Iniciar el programa en el registro 0x00

movlw 0x62 ;Palabra de congiguracin del OSC Interno movwf OSCCON ;Configurar OSCC2ON <- W clrf PORTD clrf PORTB movlw 0x03 movwf TRISD clrf TRISB clrf SecuenC ;Borra posibles valores en PORTD ;Borra posibles valores en PORTB ;Configurar RD0 y RD1 como entradas ;TRISD <- W ;Configurar PORTD como salida ;Estado de Posicin a 0x00

INICIO movf SecuenC, W call MotorPosition movwf PORTB call Retardo200ms ButtonRight ;Verificar Botn Derecho

btfss PORTD, 0 bra ButtonLeft btfsc PORTD, 1 bra INICIO bra MoveRight ButtonLeft btfss PORTD, 1 bra INICIO bra MoveLeft MoveRight movf SecuenC, xorlw 0x06 btfss STATUS, bra Continue1 clrf SecuenC bra INICIO Continue1 incf SecuenC, incf SecuenC, bra INICIO MoveLeft movf SecuenC, xorlw 0x00 btfss STATUS, bra Continue2 movlw 0x06 movwf SecuenC bra INICIO Continue2 decf SecuenC, decf SecuenC, bra INICIO MotorPosition addwf PCL, F retlw 0x0A retlw 0x09 retlw 0x05 retlw 0x06 W

;Verificar RB0 == 1, R == ON ;RB0 == 0, R == OFF ;Verificar RB1 == 0, L == OFF ;Ambos estn Presionados ;Entradas RB0 == 1, RB1 == 0 ;Verificar Botn Izquierdo ;R == OFF ahora Verificar RB1 == 0, L == ON ;Ambos estn Sueltos ;Aumentar indice para la tabla ;Verificar el indice Max Z ;Salta si Z == 1, SecuenC = Indice Max

F F

W ;SecuenC -> W ;Comprobar si W == 0 Z ;Salta si Z == 1, SecuenC = Indice Min ;Secuence =/= 0 ;Rotar hasta Indice Max ;Asignar Indice Max -> SecuenC F F

;0000 ;0000 ;0000 ;0000

1010 1001 0101 0110 ;Agregar librera Retardo.inc

include "Retardo.inc" END ;Fin de Programa

También podría gustarte