Rev 913 Rev 914
Line 4... Line 4...
4 // BAUD RATE = 9600 4 // BAUD RATE = 9600
5 // ========================== PRIPRAVA DAT A VYSTUPU =========================== 5 // ========================== PRIPRAVA DAT A VYSTUPU ===========================
6 // pomocne konstanty 6 // pomocne konstanty
7 #define LEFT 0 7 #define LEFT 0
8 #define RIGHT 1 8 #define RIGHT 1
-   9 #define BLACK 0
-   10 #define WHITE 255
9   11  
10 // regulator 12 // regulator
11 #define CONP 2 // konstanta pro proporcionalni regulator 13 #define CONP 2 // konstanta pro proporcionalni regulator
12 #define CONI 45 // konstanta pro integracni regulator *0,01 14 #define CONI 45 // konstanta pro integracni regulator *0,01
13 #define COND 20 // konstanta pro derivacni regulator *0,01 15 #define COND 20 // konstanta pro derivacni regulator *0,01
Line 22... Line 24...
22 int8 err4; 24 int8 err4;
23 int8 err5; // odchylka posledni hodnoty 25 int8 err5; // odchylka posledni hodnoty
24 int8 errp; // prumer chyb 26 int8 errp; // prumer chyb
25   27  
26 // mezera 28 // mezera
27 #define SPACE 20 29 #define SPACE 10
28   30  
29 // univerzalni LED diody 31 // univerzalni LED diody
30 #define LED1 PIN_E1 32 #define LED1 PIN_E1
31 #define LED2 PIN_E0 33 #define LED2 PIN_E0
32   34  
Line 68... Line 70...
68 int8 *lp; // ukazatel pro levou polovinu radky 70 int8 *lp; // ukazatel pro levou polovinu radky
69 int8 *rp; // ukazatel pro levou polovinu radky 71 int8 *rp; // ukazatel pro levou polovinu radky
70   72  
71 int8 position; // ulozeni pozice cary 73 int8 position; // ulozeni pozice cary
72 int8 old_position; // ulozeni predchozi pozice cary 74 int8 old_position; // ulozeni predchozi pozice cary
73 int8 l_position; -  
74 int8 r_position; -  
75 int1 line_sector; // cara je vlevo/vpravo 75 int1 line_sector; // cara je vlevo/vpravo
76 int8 gap; // pocita, jak dlouho neni videt cara 76 int8 gap; // pocita, jak dlouho neni videt cara
77   77  
78 // ================================= NARAZNIK ================================== 78 // ================================= NARAZNIK ==================================
79 #define BUMPL input(PIN_D6) 79 #define BUMPL input(PIN_D6)
Line 567... Line 567...
567 } 567 }
568 else // pokud je videt 568 else // pokud je videt
569 { 569 {
570 gap=0; // gap je roven nule 570 gap=0; // gap je roven nule
571 } 571 }
-   572 if(gap>space) // cara neni urcite videt
-   573 {
-   574 if(line_l==BLACK) // cara videna levym modrym senzorem
-   575 {
-   576 position=1;
-   577 }
-   578 if(line_r==BLACK) // cara videna pravym modrym senzorem
-   579 {
-   580 position=99;
-   581 }
-   582 }
572 calc_error(); 583 calc_error();
573 calc_regulator(); 584 calc_regulator();
574 //printf("regulator: %u\r\n",reg_out); 585 //printf("regulator: %u\r\n",reg_out);
575 if(position<50) 586 if(position<50)
576 { 587 {