seguidor de lineas (linea blanca en fondo negro)
Hola bueno días realice este programa para un robot seguidor de lineas hace algun tiempo, ahora mi profesor me lo pide para que siga una linea blanca en un fondo negro y que tenga 5 sensores en lugar de 4 he tratado de mil maneras de hacerlo pero nada mas no funciona y para colmo es para mañana, les pido de la manera mas atenta si hay alguien que me pueda ayudar ayudenme mi materia depende de eso se los agradeceria muchisimo:
Este es el programa: LIST P=16F877A INCLUDE <P16F877A.INC> __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _LVP_OFF & _DEBUG_OFF & _CPD_OFF #DEFINE SendLinIzq PORTB,0 #DEFINE SenLinDer PORTB,1 #DEFINE SenCruDer PORTB,2 #DEFINE SenCruIzq PORTB,3 #DEFINE RuedaDer PORTB,4 #DEFINE RuedaIzq PORTB,5 CBLOCK OX21 registro registro1 ContadorRetardos ENDC ORG 0 goto INICIO org 4 goto recibedato ;Interrupcion por recepcion INICIO bsf RCSTA,SPEN ;SE ACTIVA LA USART bsf STATUS,RP0 ;cambio al banco 1 bcf RuedaIzq bcf RuedaDer bsf SenLinDer bsf SenLinIzq bsf SenCruIzq bsf SenCruDer movlw b'00001111' ;configura entradas y salidas del puerto B movwf TRISB bsf TRISC,7 ;RX bcf TRISC,6 ;TX movlw b'00100100' ;configuracion USART movwf TXSTA ;y activaciob de transmision movlw .25 ;9600 baudios movwf SPBRG bsf PIE1,RCIE ;habilitacion interrupcion RX bcf STATUS,RP0 ;cambio albanco 0 bcf RCSTA,SPEN ;se activa la USART movlw b'10010000' ;configuracion de la usart movwf RCSTA ;para recepcion continua movlw b'11000000' ;habilitacion para las movwf INTCON ;interrupciones generales bsf STATUS,RP0 ;cambio al banco 1 bsf TXSTA,TXEN ;habilita la transmision bcf STATUS,RP0 ;cambio al banco 0 sensado btfss SenLinDer btfsc SenLinIzq goto sensado2 goto adelante sensado2 movf registro1,w sublw .0 btfsc STATUS,Z goto sensado3 movf registro1,w sublw .1 btfsc STATUS,Z goto Lizquierda movf registro1,w sublw .2 btfsc STATUS,Z goto Lderecha sensado3 btfss SenLinDer goto Etiqueta1 btfss SenLinIzq goto Etiqueta2 goto Etiqueta3 Etiqueta1 call CorrigeDerecha goto sensado Etiqueta2 call CorrigeIzquierda goto sensado Etiqueta3 call Avanza goto sensado ;--------------------------------------------------------------------------------------- Avanza movlw .28 movwf ContadorRetardos bsf RuedaDer bsf RuedaIzq Etiqueta4 btfss SenLinDer return btfss SenLinIzq return movf ContadorRetardos,w sublw .10 btfsc STATUS,Z bcf RuedaDer call Retardo_50micros decfsz ContadorRetardos,F goto Etiqueta4 bcf RuedaIzq movlw .180 movwf ContadorRetardos call completaperiodo return ;--------------gira hacia la izquierda CorrigeDerecha movlw .21 movwf ContadorRetardos bsf RuedaDer bcf RuedaIzq Etiqueta6 btfsc SenLinDer return call Retardo_50micros decfsz ContadorRetardos,F goto Etiqueta6 movlw .180 movwf ContadorRetardos call completaperiodo return ;------------gira hacia la derecha CorrigeIzquierda movlw .31 movwf ContadorRetardos bsf RuedaIzq bcf RuedaDer Etiqueta8 btfsc SenLinIzq return call Retardo_50micros decfsz ContadorRetardos,F goto Etiqueta8 bcf RuedaIzq movlw .180 movwf ContadorRetardos call completaperiodo return Lderecha clrf registro1 movlw .31 movwf ContadorRetardos bsf RuedaIzq bsf RuedaDer Etiqueta21 btfsc SenLinIzq goto sale call Retardo_50micros decfsz ContadorRetardos,F goto Etiqueta21 bcf RuedaIzq bcf RuedaDer movlw .180 movwf ContadorRetardos call completaperiodo btfsc SenLinIzq goto sale goto Lderecha ;------------------------------------------- Lizquierda clrf registro1 movlw .21 movwf ContadorRetardos bsf RuedaDer bsf RuedaIzq Etiqueta23 btfsc SenLinDer goto sale call Retardo_50micros decfsz ContadorRetardos,F goto Etiqueta23 bcf RuedaDer bsf RuedaIzq movlw .180 movwf ContadorRetardos Etiqueta24 call completaperiodo btfsc SenLinDer goto sale goto Lizquierda ;-----------------no retorna hasta salir comtamente del cruce sale btfss SenLinDer goto Etiqueta25 btfss SenLinIzq goto Etiqueta26 goto Etiqueta27 Etiqueta25 call CorrigeDerecha goto Etiqueta28 Etiqueta26 call CorrigeIzquierda goto Etiqueta28 Etiqueta27 call Avanza Etiqueta28 btfss SenCruIzq btfsc SenCruDer goto sale goto sensado adelante movf registro1,w sublw .0 btfsc STATUS,Z goto etiqu1 movf registro1,w sublw .1 btfsc STATUS,Z goto Lizquierda movf registro1,w sublw .2 btfsc STATUS,Z goto Lderecha etiqu1 movlw .28 movwf ContadorRetardos bsf RuedaDer bsf RuedaIzq call Retardo_1ms call Retardo_200micros bcf RuedaDer call Retardo_500micros call Retardo_100micros bcf RuedaIzq movlw .20 movwf ContadorRetardos call completaperiodo1 goto adelante completaperiodo call Retardo_50micros decfsz ContaorRetardos,F goto completaperiodo return completaperiodo1 ;se completa el periodo de os servos y se envia a la pc el estado de los sensores movf PORTB,W andlw b'00001111' call enviadato call Retardo_500micros decfsz ContadorRetardos,F goto completaperiodo1 return enviadato bcf INTCON,GIE ;se deshabilitan las interrupciones generales movwf TXREG ;se envia el dato a la pc bsf STATUS,RP0 ;cambio al banco 1 COMP_TX btfss TXSTA,TRMT ;comprueba si acabo de Tx goto COMP_TX bcf STATUS,RP0 bsf INTCON,GIE ;se habilitan de nuevi las interrupciones generales return recibedato btfss PIR1,RCIF ;¿Interrupcion por recepcion? goto volver btfsc RCSTA,OERR goto clareabit btfsc RCSTA,FERR goto volver movwf RCREG,W ;lectura dato r4ecibido movwf registro sublw .2 btfss STATUS,C goto volver movf registro,w call tabla movwf registro1 volver bcf PIR1,RCIF retfie tabla ADDWF PCL,F retlw .0 retlw .1 retlw .2 clareabit bcf RCSTA,CREN bsf RCSTA,CREN bcf PIR1,RCIF ;Si. Reponer Flag retfie INCLUDE <RETARDOS.INC> y los materiales que utilice: *1 microcontrolador pic16f877a *base de 40 pines para el pic *1 cristal de 4MHz *2 capacitores de 22 pf *1 resistencia de 4.7 Kohm *2 servomotores de 180° * 4 senswores de reflexion CNY70 *3 sensores IS471F *1 integrado MAX232 *1 buffer schmitch trigger 40106BE |
La franja horaria es GMT +2. Ahora son las 23:20. |
Powered por vBulletin™ Version 3.8.10
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.
Traducido por vBsoporte - vBulletin en español
ZackYFileS - Foros de Debate