Mobilní robot
Z MediaWiki SPŠ a VOŠ Písek
(Rozdíly mezi verzemi)
(Není zobrazeno 10 mezilehlých verzí od 1 uživatele.) | |||
Řádka 1: | Řádka 1: | ||
+ | |||
==Zadání:== | ==Zadání:== | ||
Řádka 13: | Řádka 14: | ||
# Propagujte výsledky své práce - např. vyhotovte [[poster]], je možné se přihlásit na [[SOČ]], zhotovit www stránky apod. | # Propagujte výsledky své práce - např. vyhotovte [[poster]], je možné se přihlásit na [[SOČ]], zhotovit www stránky apod. | ||
+ | ==Fotogalerie:== | ||
+ | |||
+ | [[Soubor:mobilni-robot-17.jpg|200px]] | ||
+ | [[Soubor:mobilni-robot-08.jpg|200px]] | ||
+ | [[Soubor:mobilni-robot-09.jpg|200px]] | ||
+ | [[Soubor:mobilni-robot-10.jpg|200px]] | ||
+ | [[Soubor:mobilni-robot-11.jpg|200px]] | ||
+ | [[Soubor:mobilni-robot-12.jpg|200px]] | ||
+ | [[Soubor:mobilni-robot-13.jpg|200px]] | ||
+ | [[Soubor:mobilni-robot-14.jpg|200px]] | ||
+ | [[Soubor:mobilni-robot-15.jpg|200px]] | ||
+ | [[Soubor:mobilni-robot-16.jpg|200px]] | ||
+ | |||
+ | [[Soubor:mobilni-robot-02.jpg|300px|thumb]] | ||
+ | |||
+ | [[Soubor:mobilni-robot-03.jpg|300px|thumb]] | ||
+ | |||
+ | [[Soubor:mobilni-robot-04.jpg|300px|thumb]] | ||
+ | |||
+ | [[Soubor:mobilni-robot-06.jpg|300px|thumb] | ||
+ | |||
+ | ==Program:== | ||
<source lang="C"> | <source lang="C"> | ||
Řádka 23: | Řádka 46: | ||
Data Stack size : 256 | Data Stack size : 256 | ||
**************************/ | **************************/ | ||
− | + | ||
#include <mega16.h> | #include <mega16.h> | ||
#include <stdio.h> | #include <stdio.h> | ||
Řádka 29: | Řádka 52: | ||
#define F_CPU 18423000 | #define F_CPU 18423000 | ||
#include <delay.h> | #include <delay.h> | ||
− | + | ||
#define ADC_VREF_TYPE 0x60 | #define ADC_VREF_TYPE 0x60 | ||
int hrana; | int hrana; | ||
bit por0; | bit por0; | ||
− | + | ||
//Deklarace globálních proměnných | //Deklarace globálních proměnných | ||
unsigned int read_adc(unsigned char kanal) { | unsigned int read_adc(unsigned char kanal) { | ||
Řádka 42: | Řádka 65: | ||
return ADCW; | return ADCW; | ||
} | } | ||
− | + | ||
− | + | ||
void main(void) | void main(void) | ||
{ | { | ||
− | + | ||
// Input/Output Ports initialization | // Input/Output Ports initialization | ||
// Port A initialization | // Port A initialization | ||
PORTA=0x00; | PORTA=0x00; | ||
DDRA=0x00; | DDRA=0x00; | ||
− | + | ||
// Port B initialization | // Port B initialization | ||
PORTB=0x00; | PORTB=0x00; | ||
DDRB=0x00; | DDRB=0x00; | ||
− | + | ||
// Port C initialization | // Port C initialization | ||
PORTC=0x00; | PORTC=0x00; | ||
DDRC=0xC0; | DDRC=0xC0; | ||
− | + | ||
// Port D initialization | // Port D initialization | ||
PORTD=0x00; | PORTD=0x00; | ||
DDRD=0b11111111; | DDRD=0b11111111; | ||
− | + | ||
// Timer/Counter 0 initialization | // Timer/Counter 0 initialization | ||
// Clock source: System Clock | // Clock source: System Clock | ||
Řádka 72: | Řádka 95: | ||
TCNT0=0x00; | TCNT0=0x00; | ||
OCR0=0x00; | OCR0=0x00; | ||
− | + | ||
// Timer/Counter 1 initialization | // Timer/Counter 1 initialization | ||
// Clock source: System Clock | // Clock source: System Clock | ||
Řádka 95: | Řádka 118: | ||
OCR1BH=0x00; | OCR1BH=0x00; | ||
OCR1BL=0x00; | OCR1BL=0x00; | ||
− | + | ||
// Timer/Counter 2 initialization | // Timer/Counter 2 initialization | ||
// Clock source: System Clock | // Clock source: System Clock | ||
Řádka 105: | Řádka 128: | ||
TCNT2=0x00; | TCNT2=0x00; | ||
OCR2=0x00; | OCR2=0x00; | ||
− | + | ||
// External Interrupt(s) initialization | // External Interrupt(s) initialization | ||
// INT0: Off | // INT0: Off | ||
Řádka 112: | Řádka 135: | ||
MCUCR=0x00; | MCUCR=0x00; | ||
MCUCSR=0x00; | MCUCSR=0x00; | ||
− | + | ||
// Timer(s)/Counter(s) Interrupt(s) initialization | // Timer(s)/Counter(s) Interrupt(s) initialization | ||
TIMSK=0x00; | TIMSK=0x00; | ||
− | + | ||
// USART initialization | // USART initialization | ||
// USART disabled | // USART disabled | ||
UCSRB=0x00; | UCSRB=0x00; | ||
− | + | ||
// Analog Comparator initialization | // Analog Comparator initialization | ||
// Analog Comparator: Off | // Analog Comparator: Off | ||
Řádka 125: | Řádka 148: | ||
ACSR=0x80; | ACSR=0x80; | ||
SFIOR=0x00; | SFIOR=0x00; | ||
− | + | ||
// ADC initialization | // ADC initialization | ||
// ADC Clock frequency: 575,719 kHz | // ADC Clock frequency: 575,719 kHz | ||
Řádka 135: | Řádka 158: | ||
ADCSRA=0xA5; | ADCSRA=0xA5; | ||
SFIOR&=0x1F; | SFIOR&=0x1F; | ||
− | + | ||
// SPI initialization | // SPI initialization | ||
// SPI disabled | // SPI disabled | ||
SPCR=0x00; | SPCR=0x00; | ||
− | + | ||
// TWI initialization | // TWI initialization | ||
// TWI disabled | // TWI disabled | ||
TWCR=0x00; | TWCR=0x00; | ||
− | + | ||
− | DDRC=0b00000011; | + | DDRC=0b00000011; //bity 7. až 3. nastaveny jako vstupní, ostatní výstupní = připojeny LED |
− | DDRA=0b00000000; | + | DDRA=0b00000000; //všechny bity vstupní |
− | PORTC=0b00000011; | + | PORTC=0b00000011; // na bitech 1. a 0. připojeny LED log. "1" |
delay_ms(200); | delay_ms(200); | ||
− | PORTC=0b00000001; | + | PORTC=0b00000001; // na bit 0. log. "1" |
delay_ms(200); | delay_ms(200); | ||
− | PORTC=0b00000010; | + | PORTC=0b00000010; // na bit 1. log. "1" |
delay_ms(2000); | delay_ms(2000); | ||
hrana=(read_adc(0)+read_adc(1))/2; | hrana=(read_adc(0)+read_adc(1))/2; | ||
Řádka 156: | Řádka 179: | ||
while(1){ | while(1){ | ||
if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ | if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ | ||
− | PORTD=0b00100111; | + | PORTD=0b00100111; //0000 - 00L00PLP |
}; | }; | ||
if ((read_adc(0)>hrana)*(read_adc(1)<hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ | if ((read_adc(0)>hrana)*(read_adc(1)<hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ | ||
− | PORTD=0b01101011; | + | PORTD=0b01101011; //1000 – OPL000LP |
}; | }; | ||
if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)<hrana)*(read_adc(3)>hrana)){ | if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)<hrana)*(read_adc(3)>hrana)){ | ||
− | PORTD=0b01101011; | + | PORTD=0b01101011; //0001 – 0PL000LP |
}; | }; | ||
if ((read_adc(0)<hrana)*(read_adc(1)>hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ | if ((read_adc(0)<hrana)*(read_adc(1)>hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ | ||
− | PORTD=0b01011011; | + | PORTD=0b01011011; //0100 – 0P0L00LP |
} | } | ||
− | if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ PORTD=0b00100111;}; | + | if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ |
− | + | PORTD=0b00100111; //0010 - 00L00PLP | |
− | PORTD=0b00100111; | + | }; |
+ | if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ | ||
+ | PORTD=0b00100111; //0010 - 00L00PLP | ||
}; | }; | ||
if ((read_adc(0)>hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)> hrana)){ | if ((read_adc(0)>hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)> hrana)){ | ||
if (por0){ | if (por0){ | ||
− | PORTD=0b01011011; | + | PORTD=0b01011011; //1111 – 0P0L00LP |
delay_ms(100); | delay_ms(100); | ||
− | PORTD=0b01101011; | + | PORTD=0b01101011; //1111 – 0PL000LP |
delay_ms(2000); | delay_ms(2000); | ||
por0=0;}else{ | por0=0;}else{ | ||
− | PORTD=0b00100111; | + | PORTD=0b00100111; //1111 – 00L00PLP |
delay_ms(200); | delay_ms(200); | ||
por0=1; | por0=1; | ||
Řádka 184: | Řádka 209: | ||
}; | }; | ||
if ((read_adc(0)<hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ | if ((read_adc(0)<hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ | ||
− | PORTD=0b01100011; | + | PORTD=0b01100011; //0110 – 0PL000LP |
}; | }; | ||
if ((read_adc(0)>hrana)*(read_adc(1)>hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ | if ((read_adc(0)>hrana)*(read_adc(1)>hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ | ||
− | PORTD=0b01010001; | + | PORTD=0b01010001; //1100 – 0P0L000P |
}; | }; | ||
if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)>hrana)*(read_adc(3)>hrana)){ | if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)>hrana)*(read_adc(3)>hrana)){ | ||
− | PORTD=0b00100110; | + | PORTD=0b00100110; //0011 – 00L00PLP |
}; | }; | ||
if ((read_adc(0)<hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)>hrana)){ | if ((read_adc(0)<hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)>hrana)){ | ||
− | PORTD=0b00100110; | + | PORTD=0b00100110; //0111 – 00L00PL0 |
}; | }; | ||
if ((read_adc(0)>hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ | if ((read_adc(0)>hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ | ||
− | PORTD=0b00100101; | + | PORTD=0b00100101; //1110 – 00L00P0P |
}; | }; | ||
} | } | ||
− | + | ||
+ | |||
+ | |||
</source> | </source> | ||
+ | |||
+ | |||
+ | |||
+ | ==www:== | ||
+ | |||
+ | [[Soubor:mobilni-robot-vznika-na-VSPJ.jpg|300px]] [http://vspj-robot.blogspot.com/ Projekt "Mobilní robot" vzniká na VŠPJ] | ||
+ | |||
+ | [[Soubor:mobilni-robot-07.jpg|300px]] [http://shop.snailinstruments.com/index.php?main_page=product_info&cPath=81_84&products_id=346 Výkonový IO L298N] | ||
+ | |||
+ | [[Soubor:D10 HW 034.jpg |200px]] [http://shop.snailinstruments.com/index.php?main_page=product_info&cPath=77&products_id=382 Podvozek MOB-03] |
Aktuální verze z 1. 5. 2011, 14:09
Obsah |
Zadání:
- Proveďte teoretický rozbor možností řešení vývoje autonomního robota
- Vyberte vhodné řešení
- Nakreslete blokové schéma
- Jednotivé bloky kompletně popište
- Navrhněte el. schéma a DPS
- Obvod realizujte
- Naprogramujte robota pro jízdu v bludišti
- Otestujte funkčnost
- Zpracujte dokumentaci dle metodického návrhu
- Zpracujte ppt prezentaci pro účely obhajoby
- Propagujte výsledky své práce - např. vyhotovte poster, je možné se přihlásit na SOČ, zhotovit www stránky apod.
Fotogalerie:
[[Soubor:mobilni-robot-06.jpg|300px|thumb]
Program:
/************************** Chip type : ATmega16 Program type : Application AVR Core Clock frequency: 18,423000 MHz Memory model : Small External RAM size : 0 Data Stack size : 256 **************************/ #include <mega16.h> #include <stdio.h> #include <stdlib.h> #define F_CPU 18423000 #include <delay.h> #define ADC_VREF_TYPE 0x60 int hrana; bit por0; //Deklarace globálních proměnných unsigned int read_adc(unsigned char kanal) { ADMUX=kanal; ADCSRA|=0x40; while ((ADCSRA & 0x10)==0); ADCSRA|= 0x10; return ADCW; } void main(void) { // Input/Output Ports initialization // Port A initialization PORTA=0x00; DDRA=0x00; // Port B initialization PORTB=0x00; DDRB=0x00; // Port C initialization PORTC=0x00; DDRC=0xC0; // Port D initialization PORTD=0x00; DDRD=0b11111111; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=0xFF // OC0 output: Disconnected TCCR0=0x00; TCNT0=0x00; OCR0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: Timer1 Stopped // Mode: Normal top=0xFFFF // OC1A output: Discon. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off TCCR1A=0x00; TCCR1B=0x00; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer2 Stopped // Mode: Normal top=0xFF // 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; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00; // USART initialization // USART disabled UCSRB=0x00; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; // ADC initialization // ADC Clock frequency: 575,719 kHz // ADC Voltage Reference: AVCC pin // ADC Auto Trigger Source: Free Running // Only the 8 most significant bits of // the AD conversion result are used ADMUX=ADC_VREF_TYPE & 0xff; ADCSRA=0xA5; SFIOR&=0x1F; // SPI initialization // SPI disabled SPCR=0x00; // TWI initialization // TWI disabled TWCR=0x00; DDRC=0b00000011; //bity 7. až 3. nastaveny jako vstupní, ostatní výstupní = připojeny LED DDRA=0b00000000; //všechny bity vstupní PORTC=0b00000011; // na bitech 1. a 0. připojeny LED log. "1" delay_ms(200); PORTC=0b00000001; // na bit 0. log. "1" delay_ms(200); PORTC=0b00000010; // na bit 1. log. "1" delay_ms(2000); hrana=(read_adc(0)+read_adc(1))/2; PORTC=0b00000000; while(1){ if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ PORTD=0b00100111; //0000 - 00L00PLP }; if ((read_adc(0)>hrana)*(read_adc(1)<hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ PORTD=0b01101011; //1000 – OPL000LP }; if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)<hrana)*(read_adc(3)>hrana)){ PORTD=0b01101011; //0001 – 0PL000LP }; if ((read_adc(0)<hrana)*(read_adc(1)>hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ PORTD=0b01011011; //0100 – 0P0L00LP } if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ PORTD=0b00100111; //0010 - 00L00PLP }; if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ PORTD=0b00100111; //0010 - 00L00PLP }; if ((read_adc(0)>hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)> hrana)){ if (por0){ PORTD=0b01011011; //1111 – 0P0L00LP delay_ms(100); PORTD=0b01101011; //1111 – 0PL000LP delay_ms(2000); por0=0;}else{ PORTD=0b00100111; //1111 – 00L00PLP delay_ms(200); por0=1; }; }; if ((read_adc(0)<hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ PORTD=0b01100011; //0110 – 0PL000LP }; if ((read_adc(0)>hrana)*(read_adc(1)>hrana)*(read_adc(2)<hrana)*(read_adc(3)<hrana)){ PORTD=0b01010001; //1100 – 0P0L000P }; if ((read_adc(0)<hrana)*(read_adc(1)<hrana)*(read_adc(2)>hrana)*(read_adc(3)>hrana)){ PORTD=0b00100110; //0011 – 00L00PLP }; if ((read_adc(0)<hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)>hrana)){ PORTD=0b00100110; //0111 – 00L00PL0 }; if ((read_adc(0)>hrana)*(read_adc(1)>hrana)*(read_adc(2)>hrana)*(read_adc(3)<hrana)){ PORTD=0b00100101; //1110 – 00L00P0P }; }