Rev 744 Rev 745
Line 10... Line 10...
10 //piezo pipak 10 //piezo pipak
11 #DEFINE SOUND_HI PIN_B4 11 #DEFINE SOUND_HI PIN_B4
12 #DEFINE SOUND_LO PIN_B5 12 #DEFINE SOUND_LO PIN_B5
13   13  
14 //radkovy senzor 14 //radkovy senzor
15 #define SDIN PIN_D4 // seriovy vstup 15 #define SDIN PIN_D4 // seriovy vstup
16 #define SDOUT input(PIN_B2) // seriovy vystup 16 #define SDOUT input(PIN_B2) // seriovy vystup
17 #define SCLK PIN_D5 // takt 17 #define SCLK PIN_D5 // takt
18   18  
19 int main_reset[8]={1,1,0,1,1,0,0,0}; // hlavni reset 19 int main_reset[8]={1,1,0,1,1,0,0,0}; // hlavni reset
20 int set_mode_rg[8]={1,1,1,1,1,0,1,0}; // zapsani do MODE registru 20 int set_mode_rg[8]={1,1,1,1,1,0,1,0}; // zapis do MODE registru
21 int clear_mode_rg[8]={0,0,0,0,0,0,0,0}; // nulovani MODE registru 21 int clear_mode_rg[8]={0,0,0,0,0,0,0,0}; // nulovani MODE registru
22   22  
23 int olsa_l[51]={0}; // leva polovina radkoveho senzoru 23 int olsa_line[96]={0}; // radkovy senzor
24 int olsa_r[51]={0}; // prava polovina radkoveho senzoru -  
25   -  
26   24  
27 //naraznik 25 //naraznik
28 #define BUMPL input(PIN_D6) 26 #define BUMPL input(PIN_D6)
29 #define BUMPR input(PIN_D7) 27 #define BUMPR input(PIN_D7)
30   28  
31 //nouzove senzory 29 //nouzove senzory
32 #define LINEL 0 30 #define LINEL 0
33 #define LINER 1 31 #define LINER 1
34 #define TRESHOLD 200 // rozhodovaci uroven (zmereno 0 - cerna, 255 cerna) 32 #define TRESHOLD 200 // rozhodovaci uroven (zmereno 0 - cerna, 255 cerna)
35 int8 line_l; 33 int8 line_l;
36 int8 line_r; 34 int8 line_r;
37   35  
38 // motory 36 // motory
39 #define LMF PIN_D0 37 #define LMF PIN_D0
Line 41... Line 39...
41 #define RMF PIN_D2 39 #define RMF PIN_D2
42 #define RMB PIN_D3 40 #define RMB PIN_D3
43   41  
44 //PODPROGRAMY 42 //PODPROGRAMY
45 //SENZORY 43 //SENZORY
46   -  
47 //OLSA01A 44 //OLSA01A
48 void olsa_pulses(int count) // vytvori impulzy pro ridici logiku 45 void olsa_pulses(int count) // vytvori impulzy pro ridici logiku
49 { 46 {
50 int8 ct; 47 int8 ct;
51 for(ct=0;ct<=count;ct++) 48 for(ct=0;ct<=count;ct++)
52 { 49 {
53 delay_us(1); 50 delay_us(1); // doba pro ustaleni
54 output_high(SCLK); 51 output_high(SCLK);
55 delay_us(1); 52 delay_us(1); // doba pro ustaleni
56 output_low(SCLK); 53 output_low(SCLK);
57 } 54 }
58 } 55 }
59   56  
60 void olsa_pulse() // vytvori jeden impulz 57 void olsa_pulse() // vytvori jeden impulz
61 { 58 {
62 delay_us(1); 59 delay_us(1); // doba pro ustaleni
63 output_high(SCLK); 60 output_high(SCLK);
64 delay_us(1); 61 delay_us(1); // doba pro ustaleni
65 output_low(SCLK); 62 output_low(SCLK);
66 } 63 }
67   64  
68 void olsa_send(int info[]) // USART komunikace s modulem OLSA01A - poslani zpravy 65 void olsa_send(int info[]) // USART komunikace s modulem OLSA01A - poslani zpravy
69 { 66 {
Line 105... Line 102...
105 //ZACHRANNE SENZORY 102 //ZACHRANNE SENZORY
106 void read_blue_sensors() // cteni nouzovych senzoru 103 void read_blue_sensors() // cteni nouzovych senzoru
107 { 104 {
108 set_adc_channel(LINEL); // cti levy nouzovy senzor 105 set_adc_channel(LINEL); // cti levy nouzovy senzor
109 delay_us(10); 106 delay_us(10);
110 line_l=read_adc(); 107 line_l=read_adc();
111 -  
112 set_adc_channel(LINER); // cti pravy nouzovy senzor 108 set_adc_channel(LINER); // cti pravy nouzovy senzor
113 delay_us(10); 109 delay_us(10);
114 line_r=read_adc(); 110 line_r=read_adc();
115 } 111 }
116 112