Anda di halaman 1dari 6

SEGUIDOR DE TRAYECTORIA

CURSO: DISEO DE MAQUINAS AUTOMAQUINAS ALUMNO: GAMARRA VARGAS, YHONY SANTIAGO

1. ALGORITMO 1. L= sensor de la izquierda se lee como 0; R= sensor de la derecha se lee como 0. Si no hay ningn sensor en la izquierda (o derecha) es 0; entonces L (o R) es igual a cero; Ejemplo: Izquierda, derecha, centro Aqu L=3 R=0 Izquierda, derecha, centro Aqu L=2 R=4 2. si todos los sensores se leen como 1, vaya al paso 3 Adems, Si L>R mover a la izquierda Si L<R mover a la derecha Si L=R mover adelante Ir al paso 4 3. mover hacia la derecha si la lnea fue vista por ltima vez a la derecha Mover en sentido anti horario si la lnea fue vista por ltima vez a la izquierda Repita el paso 3 hasta que la lnea sea encontrada 4. Vaya al paso 1 L4 L3 L2 L1 R1 R2 R3 R4 10011111 L4 L3 L2 L1 R1 R2 R3 R4 11000000

Diagrama bloque El robot utiliza los sensores del IR para detectar la lnea, un arsenal de 8 IR LED (Tx) y sensores (Rx), la salida de los sensores es una seal analgica que depende de la cantidad de luz reflejada detrs.

3.

IMPLEMENTACION

3.1. Circuito sensor: Para obtener una buena oscilacin de voltaje, el valor de R1 debe ser cuidadosamente elegido. La resistencia del sensor disminuye cuando la luz IR cae en l. Un buen sensor tendr cerca de cero resistencia en presencia de luz y una gran resistencia en ausencia de luz. Hemos usado esta propiedad del Sensor para formar un divisor de potencial.

Esto es especialmente importante si usted planea usar un ADC en el lugar del comparador. Sin embargo, con una alta resistencia, la corriente ser muy pequea, por lo tanto hay la posibilidad de que esta sea distorsionada por el ruido. La solucin es encontrar un equilibrio entre la sensibilidad y el ruido. El valor de la resistencia depender de los valores del sensor.

3.2 . Posibles mejoras Uso de direccin diferencial con el cambio gradual en la velocidad de las ruedas. El uso de ADC para que la posicin exacta de la lnea pueda ser interpolado El uso de silla de ruedas o tres ruedas para reducir la traccin Mejoras generales, como el uso de un regulador de voltaje bajo de desercin, etc.

3.3. Cdigo fuente Aplicacin desarrollada por Programador -> mikroC. Computadora -> PIC MEGA16 Seguidor de Trayectoria: //#define debug 1 #include <mega16.h> #include <delay.h> #ifdef debug #include <stdio.h> #endif #define FWD 0xAA #define REV 0x55 #define R 0x22 #define L 0x88 #define CW 0x99 #define CCW 0x66 #define STOP 0x00 #define B 0xFF #define RSPEED OCR1AL #define LSPEED OCR1BL #define SPEED0 255 #define SPEED1 0 #define SPEED2 0 #define SPEED3 0 #define MAX 3 #define HMAX 1

void move (unsigned char dir,unsigned char delay,unsigned char power); unsigned char i,rdev,ldev,ip,delay,dir,power,dirl,history[MAX],hcount=0,rotpow; #ifdef debug unsigned char rep=0,prev=0; #endif void main(void) { // Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTA=0x00; DDRA=0x00; // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00; DDRB=0x00; // Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00; DDRC=0xFF; // Port D initialization // Func7=In Func6=In Func5=Out Func4=Out Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=0 State4=0 State3=T State2=T State1=T State0=T PORTD=0x00; DDRD=0x30; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=FFh // OC0 output: Disconnected TCCR0=0x00; TCNT0=0x00; OCR0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: 921.600 kHz // Mode: Fast PWM top=00FFh // OC1A output: Non-Inv. // OC1B output: Non-Inv. // Noise Canceler: Off // Input Capture on Falling Edge TCCR1A=0xA1; TCCR1B=0x0A; TCNT1H=0x00; TCNT1L=0x00;

ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0xFF; OCR1BH=0x00; OCR1BL=0xFF; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer 2 Stopped // Mode: Normal top=FFh // OC2 output: Disconnected ASSR=0x00; TCCR2=0x00; TCNT2=0x00; OCR2=0x00; // External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off MCUCR=0x00; MCUCSR=0x00; #ifdef debug // USART initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART Receiver: On // USART Transmitter: On // USART Mode: Asynchronous // USART Baud rate: 57600 UCSRA=0x00; UCSRB=0x18; UCSRC=0x86; UBRRH=0x00; UBRRL=0x07; #endif // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; while (1){ #ifdef debug if(rep<255) rep++; if(prev!=PINA) { prev=PINA; printf("%u\r",rep); for(i=0;i<8;i++) printf("%u\t",(prev>>i)&0x01); rep=0; } #endif if(PINA!=255){ rotpow=255; ldev=rdev=0; if(PINA.3==0)

rdev=1; if(PINA.2==0) rdev=2; if(PINA.1==0) rdev=3; if(PINA.0==0) rdev=4; if(PINA.4==0) ldev=1; if(PINA.5==0) ldev=2; if(PINA.6==0) ldev=3; if(PINA.7==0) ldev=4; if(rdev>ldev) move(R,0,195+12*rdev); if(rdev<ldev) move(L,0,195+12*ldev); if(rdev==ldev) move(FWD,0,200); } else { for(i=0,dirl=0;i<MAX;i++) { if(history[i]==L) {dirl++;} } if(rotpow<160) {rotpow=160;} if(rotpow<255) {rotpow++;} if(dirl>HMAX) {move(CW,0,rotpow);} else {move(CCW,0,rotpow);} } }; } void move (unsigned char dir,unsigned char delay,unsigned char power) { PORTC=dir; if(dir==L || dir==R) { hcount=(hcount+1)%MAX; history[hcount]=dir; } LSPEED=RSPEED=255;//power; //delay_ms(delay);

4. REFERENCIAS

4.1. Libros y links

Libros: Programming and Customizing the AVR Microcontroller Dhananjay V. Gadre. Parallel Port Complete Jan Axelson.

Links: Atmel Corp. Fabricantes de los microcontroladores AVR http://www.atmel.com

AVRbeginners.net http://www.avrbeginners.net/

Uno de los mejores sitios AVR http://www.avrfreaks.net

Diseo de robots bsicos http://www.x-robotics.com/robots_simples.htm

Electrnica bsica http://www.kpsec.freeuk.com/

Sensores de pequeos robots http://www.andrew.cmu.edu/user/rjg/websensors/robot_sensors2.html

Anda mungkin juga menyukai