Difference between revisions of "Omnibot(Krajči,Dluhý)"
From RoboWiki
(→Úvod) |
(→Zdrojový kód pre pohyb) |
||
(32 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
Robota sme programovali v jazyku C vo vývojovom prostredí AVR Studio 4. | Robota sme programovali v jazyku C vo vývojovom prostredí AVR Studio 4. | ||
− | Použili sme čip [http://www.atmel.com/Images/Atmel-2513-8-bit-AVR-Microntroller-ATmega162_Datasheet.pdf ATmega 162V] a dva radiče typu L293D. | + | Použili sme čip [http://www.atmel.com/Images/Atmel-2513-8-bit-AVR-Microntroller-ATmega162_Datasheet.pdf ATmega 162V] a dva radiče typu [http://pdf.datasheetcatalog.com/datasheet/texasinstruments/l293d.pdf L293D]. |
== Čo to z technického hľadiska == | == Čo to z technického hľadiska == | ||
− | '''Prepojenie riadiacich pinov [http://www.atmel.com/Images/Atmel-2513-8-bit-AVR-Microntroller-ATmega162_Datasheet.pdf ATmega 162V] s [http://pdf.datasheetcatalog.com/datasheet/texasinstruments/l293d.pdf | + | '''Prepojenie riadiacich pinov [http://www.atmel.com/Images/Atmel-2513-8-bit-AVR-Microntroller-ATmega162_Datasheet.pdf ATmega 162V] s [http://pdf.datasheetcatalog.com/datasheet/texasinstruments/l293d.pdf L293D] radičmi''' |
OC3B-1A(1) | OC3B-1A(1) | ||
Line 21: | Line 21: | ||
PA3-3A(2) | PA3-3A(2) | ||
− | + | TIMER 1 a 3 pobeží na frekvencii 2kHz, s prescaler 8, TOP=499 | |
TCCR1A/TCCR3A 0b10100010 | TCCR1A/TCCR3A 0b10100010 | ||
Line 33: | Line 33: | ||
M3 = v reali 3 | M3 = v reali 3 | ||
M4 = v reali 2 | M4 = v reali 2 | ||
+ | |||
+ | == Zdrojový kód pre pohyb == | ||
+ | '''Pohyb do ľubovoľného smeru''' | ||
+ | |||
+ | void move(int angle,int speed,int time) | ||
+ | { | ||
+ | int uhol=0; | ||
+ | float zvislo = 0.0; | ||
+ | float vodorovne = 0.0; | ||
+ | |||
+ | |||
+ | if (angle>=0 && angle <90){ | ||
+ | uhol = angle; | ||
+ | zvislo = (90.0-uhol)/90.0*speed; // vypocet percent akou rychlostou sa tocia motory v smere x-ovej osi | ||
+ | vodorovne = uhol/90.0*speed; // vypocet percent akou rychlostou sa tocia motory v smere y-ovej osi | ||
+ | int z = zvislo; | ||
+ | int v = vodorovne; | ||
+ | setMotor(3,z,1); | ||
+ | setMotor(2,z,1); | ||
+ | setMotor(1,v,1); | ||
+ | setMotor(4,v,0); | ||
+ | |||
+ | wait(time); | ||
+ | setMotor(1, 0, 0); | ||
+ | setMotor(2, 0, 0); | ||
+ | setMotor(3, 0, 0); | ||
+ | setMotor(4, 0, 0); | ||
+ | } | ||
+ | |||
+ | if (angle>=90 && angle <180){ | ||
+ | |||
+ | uhol = angle-90; | ||
+ | zvislo = (90.0-uhol)/90.0*speed; | ||
+ | vodorovne = uhol/90.0*speed; | ||
+ | int z = zvislo; | ||
+ | int v = vodorovne; | ||
+ | |||
+ | setMotor(3,v,0); | ||
+ | setMotor(2,v,0); | ||
+ | setMotor(1,z,1); | ||
+ | setMotor(4,z,0); | ||
+ | wait(time); | ||
+ | setMotor(1, 0, 0); | ||
+ | setMotor(2, 0, 0); | ||
+ | setMotor(3, 0, 0); | ||
+ | setMotor(4, 0, 0); | ||
+ | } | ||
+ | |||
+ | if (angle>=180 && angle <270){ | ||
+ | |||
+ | uhol = angle-180; | ||
+ | zvislo = (90.0-uhol)/90.0*speed; | ||
+ | vodorovne = uhol/90.0*speed; | ||
+ | int z = zvislo; | ||
+ | int v = vodorovne; | ||
+ | |||
+ | setMotor(3,z,0); | ||
+ | setMotor(2,z,0); | ||
+ | setMotor(1,v,0); | ||
+ | setMotor(4,v,1); | ||
+ | wait(time); | ||
+ | setMotor(1, 0, 0); | ||
+ | setMotor(2, 0, 0); | ||
+ | setMotor(3, 0, 0); | ||
+ | setMotor(4, 0, 0); | ||
+ | } | ||
+ | |||
+ | if (angle>=270 && angle <=360){ | ||
+ | |||
+ | uhol = angle-270; | ||
+ | zvislo = (90.0-uhol)/90.0*speed; | ||
+ | vodorovne = uhol/90.0*speed; | ||
+ | int z = zvislo; | ||
+ | int v = vodorovne; | ||
+ | |||
+ | setMotor(3,v,1); | ||
+ | setMotor(2,v,1); | ||
+ | setMotor(1,z,0); | ||
+ | setMotor(4,z,1); | ||
+ | wait(time); | ||
+ | setMotor(1, 0, 0); | ||
+ | setMotor(2, 0, 0); | ||
+ | setMotor(3, 0, 0); | ||
+ | setMotor(4, 0, 0); | ||
+ | } | ||
+ | |||
+ | '''Rotácie''' | ||
+ | |||
+ | void RotateLeft(int speed, int time) | ||
+ | { | ||
+ | setMotor(1,speed,0); | ||
+ | setMotor(2,speed,1); | ||
+ | setMotor(3,speed,0); | ||
+ | setMotor(4,speed,0); | ||
+ | wait(time); | ||
+ | setMotor(1, 0, 0); | ||
+ | setMotor(2, 0, 0); | ||
+ | setMotor(3, 0, 0); | ||
+ | setMotor(4, 0, 0); | ||
+ | } | ||
+ | |||
+ | void RotateRight(int speed, int time) | ||
+ | { | ||
+ | setMotor(1,speed,1); | ||
+ | setMotor(2,speed,0); | ||
+ | setMotor(3,speed,1); | ||
+ | setMotor(4,speed,1); | ||
+ | wait(time); | ||
+ | setMotor(1, 0, 0); | ||
+ | setMotor(2, 0, 0); | ||
+ | setMotor(3, 0, 0); | ||
+ | setMotor(4, 0, 0); | ||
+ | } | ||
+ | |||
+ | == Fotodokumentácia == | ||
+ | |||
+ | [[Image:omni1.jpg|middle|375px]] | ||
+ | [[Image:omni2.jpg|middle|375px]] | ||
+ | [[Image:omni3.jpg|middle|375px]] | ||
+ | |||
+ | == Videá == | ||
+ | |||
+ | '''Test motorov''' | ||
+ | |||
+ | <youtube>Q-npISlpJzw</youtube> | ||
+ | |||
+ | '''Pohyb robota''' | ||
+ | |||
+ | <youtube>ZAsk2Ngpf18</youtube> | ||
+ | |||
+ | '''Wannabe valčík''' | ||
+ | |||
+ | <youtube>kb6KHMCVrMM</youtube> | ||
+ | |||
+ | == Súbory na stiahnutie == | ||
+ | |||
+ | [[Media:omnidirectional.rar]] |
Latest revision as of 19:11, 25 June 2013
Contents
Úvod
Cieľom nášho projetku bolo zostrojiť a naprogramovať všesmerového robota.
Robota sme programovali v jazyku C vo vývojovom prostredí AVR Studio 4.
Použili sme čip ATmega 162V a dva radiče typu L293D.
Čo to z technického hľadiska
Prepojenie riadiacich pinov ATmega 162V s L293D radičmi
OC3B-1A(1) PA0-2A(1) OC3A-4A(1) PA5-3A(1)
OC1A-1A(2) PA4-2A(2) OC1B-4A(2) PA3-3A(2)
TIMER 1 a 3 pobeží na frekvencii 2kHz, s prescaler 8, TOP=499
TCCR1A/TCCR3A 0b10100010 TCCR1B/TCCR3B 0b00011010 ICR1/ICR3 = 499 OCR1A, OCR1B, OCR3A, OCR3B = 0..499 => motor speed
M1 = v reali 4 M2 = v reali 1 M3 = v reali 3 M4 = v reali 2
Zdrojový kód pre pohyb
Pohyb do ľubovoľného smeru
void move(int angle,int speed,int time) { int uhol=0; float zvislo = 0.0; float vodorovne = 0.0; if (angle>=0 && angle <90){ uhol = angle; zvislo = (90.0-uhol)/90.0*speed; // vypocet percent akou rychlostou sa tocia motory v smere x-ovej osi vodorovne = uhol/90.0*speed; // vypocet percent akou rychlostou sa tocia motory v smere y-ovej osi int z = zvislo; int v = vodorovne; setMotor(3,z,1); setMotor(2,z,1); setMotor(1,v,1); setMotor(4,v,0); wait(time); setMotor(1, 0, 0); setMotor(2, 0, 0); setMotor(3, 0, 0); setMotor(4, 0, 0); } if (angle>=90 && angle <180){ uhol = angle-90; zvislo = (90.0-uhol)/90.0*speed; vodorovne = uhol/90.0*speed; int z = zvislo; int v = vodorovne; setMotor(3,v,0); setMotor(2,v,0); setMotor(1,z,1); setMotor(4,z,0); wait(time); setMotor(1, 0, 0); setMotor(2, 0, 0); setMotor(3, 0, 0); setMotor(4, 0, 0); } if (angle>=180 && angle <270){ uhol = angle-180; zvislo = (90.0-uhol)/90.0*speed; vodorovne = uhol/90.0*speed; int z = zvislo; int v = vodorovne; setMotor(3,z,0); setMotor(2,z,0); setMotor(1,v,0); setMotor(4,v,1); wait(time); setMotor(1, 0, 0); setMotor(2, 0, 0); setMotor(3, 0, 0); setMotor(4, 0, 0); } if (angle>=270 && angle <=360){ uhol = angle-270; zvislo = (90.0-uhol)/90.0*speed; vodorovne = uhol/90.0*speed; int z = zvislo; int v = vodorovne; setMotor(3,v,1); setMotor(2,v,1); setMotor(1,z,0); setMotor(4,z,1); wait(time); setMotor(1, 0, 0); setMotor(2, 0, 0); setMotor(3, 0, 0); setMotor(4, 0, 0); }
Rotácie
void RotateLeft(int speed, int time) { setMotor(1,speed,0); setMotor(2,speed,1); setMotor(3,speed,0); setMotor(4,speed,0); wait(time); setMotor(1, 0, 0); setMotor(2, 0, 0); setMotor(3, 0, 0); setMotor(4, 0, 0); }
void RotateRight(int speed, int time) { setMotor(1,speed,1); setMotor(2,speed,0); setMotor(3,speed,1); setMotor(4,speed,1); wait(time); setMotor(1, 0, 0); setMotor(2, 0, 0); setMotor(3, 0, 0); setMotor(4, 0, 0); }
Fotodokumentácia
Videá
Test motorov
Pohyb robota
Wannabe valčík