2 |
kaklik |
1 |
CCS PCW C Compiler, Version 3.110, 15448
|
|
|
2 |
|
|
|
3 |
Filename: d:\kaklik\programy\pic_c\robot\tank\main.LST
|
|
|
4 |
|
|
|
5 |
ROM used: 893 (22%)
|
|
|
6 |
Largest free fragment is 2048
|
|
|
7 |
RAM used: 82 (43%) at main() level
|
|
|
8 |
101 (53%) worst case
|
|
|
9 |
Stack: 3 locations
|
|
|
10 |
|
|
|
11 |
*
|
|
|
12 |
0000: MOVLW 00
|
|
|
13 |
0001: MOVWF 0A
|
|
|
14 |
0002: GOTO 2CB
|
|
|
15 |
0003: NOP
|
|
|
16 |
.................... #include "D:\@KAKLIK\programy\PIC_C\robot\tank\main.h"
|
|
|
17 |
.................... #include <16F873.h>
|
|
|
18 |
.................... //////// Standard Header file for the PIC16F873 device ////////////////
|
|
|
19 |
.................... #device PIC16F873
|
|
|
20 |
.................... #list
|
|
|
21 |
....................
|
|
|
22 |
.................... #use delay(clock=4000000)
|
|
|
23 |
00A8: MOVLW 73
|
|
|
24 |
00A9: MOVWF 04
|
|
|
25 |
00AA: MOVF 00,W
|
|
|
26 |
00AB: BTFSC 03.2
|
|
|
27 |
00AC: GOTO 0BC
|
|
|
28 |
00AD: MOVLW 01
|
|
|
29 |
00AE: MOVWF 21
|
|
|
30 |
00AF: CLRF 20
|
|
|
31 |
00B0: DECFSZ 20,F
|
|
|
32 |
00B1: GOTO 0B0
|
|
|
33 |
00B2: DECFSZ 21,F
|
|
|
34 |
00B3: GOTO 0AF
|
|
|
35 |
00B4: MOVLW 4A
|
|
|
36 |
00B5: MOVWF 20
|
|
|
37 |
00B6: DECFSZ 20,F
|
|
|
38 |
00B7: GOTO 0B6
|
|
|
39 |
00B8: NOP
|
|
|
40 |
00B9: NOP
|
|
|
41 |
00BA: DECFSZ 00,F
|
|
|
42 |
00BB: GOTO 0AD
|
|
|
43 |
00BC: RETLW 00
|
|
|
44 |
.................... #fuses XT,NOWDT,NOLVP
|
|
|
45 |
....................
|
|
|
46 |
....................
|
|
|
47 |
....................
|
|
|
48 |
.................... //motory
|
|
|
49 |
.................... #define FR output_high(PIN_B4);output_low(PIN_B5) // Vpred
|
|
|
50 |
.................... #define FL output_high(PIN_B6);output_low(PIN_B7)
|
|
|
51 |
.................... #define BR output_high(PIN_B5);output_low(PIN_B4) // Vzad
|
|
|
52 |
.................... #define BL output_high(PIN_B7);output_low(PIN_B6)
|
|
|
53 |
.................... #define STOPR output_low(PIN_B4);output_low(PIN_B5)
|
|
|
54 |
.................... #define STOPL output_low(PIN_B6);output_low(PIN_B7)
|
|
|
55 |
....................
|
|
|
56 |
.................... //cidla
|
|
|
57 |
.................... #define RSENSOR 1 // Senzory na caru
|
|
|
58 |
.................... #define LSENSOR 0
|
|
|
59 |
.................... //#define BUMPER SENSOR_2 // Senzor na cihlu
|
|
|
60 |
....................
|
|
|
61 |
.................... //human interface
|
|
|
62 |
.................... #DEFINE LED PIN_A2
|
|
|
63 |
....................
|
|
|
64 |
.................... #DEFINE SOUND_HI PIN_B2
|
|
|
65 |
.................... #DEFINE SOUND_LO PIN_B3
|
|
|
66 |
.................... #include "sound.c"
|
|
|
67 |
.................... // Knihovna pro generovani hudebnich zvuku dane frekvence a delky nebo
|
|
|
68 |
.................... // dane noty temperovaneho ladeni a delky.
|
|
|
69 |
.................... //
|
|
|
70 |
.................... // Pro gnerovani nepouziva zadnou podporu HW, vse se generuje ciste SW.
|
|
|
71 |
.................... //
|
|
|
72 |
.................... // (c)miho 2003
|
|
|
73 |
.................... //
|
|
|
74 |
.................... // Historie
|
|
|
75 |
.................... // 1.00 Uvodni verze
|
|
|
76 |
.................... //
|
|
|
77 |
....................
|
|
|
78 |
....................
|
|
|
79 |
.................... // Konfiguracni parametry
|
|
|
80 |
.................... //#define SOUND_HI PIN_xx // Pozitivni vystup
|
|
|
81 |
.................... //#define SOUND_LO PIN_xx // Komplementarni vystup
|
|
|
82 |
.................... #ifndef SOUND_REZIE
|
|
|
83 |
.................... #define SOUND_REZIE 72 // Piskvorcova konstanta zahrnuje celkovou rezii ve smycce
|
|
|
84 |
.................... #endif
|
|
|
85 |
.................... #ifndef SOUND_CLOCK
|
|
|
86 |
.................... #define SOUND_CLOCK 4000000 // Frelvence krystalu v Hz
|
|
|
87 |
.................... #endif
|
|
|
88 |
....................
|
|
|
89 |
....................
|
|
|
90 |
.................... // Definice hudebnich tonu (not) pro proceduru SoundNote()
|
|
|
91 |
.................... #define SOUND_C 0
|
|
|
92 |
.................... #define SOUND_Cis 1
|
|
|
93 |
.................... #define SOUND_D 2
|
|
|
94 |
.................... #define SOUND_Dis 3
|
|
|
95 |
.................... #define SOUND_E 4
|
|
|
96 |
.................... #define SOUND_F 5
|
|
|
97 |
.................... #define SOUND_Fis 6
|
|
|
98 |
.................... #define SOUND_G 7
|
|
|
99 |
.................... #define SOUND_Gis 8
|
|
|
100 |
.................... #define SOUND_A 9
|
|
|
101 |
.................... #define SOUND_Ais 10
|
|
|
102 |
.................... #define SOUND_H 11
|
|
|
103 |
.................... #define SOUND_Space 12 // Pomlka
|
|
|
104 |
....................
|
|
|
105 |
....................
|
|
|
106 |
.................... // Prototypy verejnych procedur
|
|
|
107 |
....................
|
|
|
108 |
.................... void SoundBeep(unsigned int16 Frequency, unsigned int16 Duration);
|
|
|
109 |
.................... // Predava se frekvence v Hz a doba trvani v ms (0 znamena ticho)
|
|
|
110 |
....................
|
|
|
111 |
.................... void SoundNote(unsigned int8 Note, Octave, unsigned int16 Duration);
|
|
|
112 |
.................... // Predava se cislo noty (0 je C), posunuti v oktavach (0 nejnizsi ton,
|
|
|
113 |
.................... // SOUND_Space je ticho), doba trvani v ms
|
|
|
114 |
....................
|
|
|
115 |
.................... // Alternativni makra pro generovani konstatnich tonu
|
|
|
116 |
.................... // SoundBeepMacro(Frequency, Duration) - frekvence nesmi byt 0
|
|
|
117 |
.................... // SoundNoteMacro(Note, Octave, Duration) - nepodporuje SOUND_Space
|
|
|
118 |
.................... // SoundSpaceMacro(Duration) - hraje ticho
|
|
|
119 |
....................
|
|
|
120 |
.................... // Privatni cast
|
|
|
121 |
....................
|
|
|
122 |
....................
|
|
|
123 |
.................... #ORG 0x100, 0x128 // Aby skok nebyl pres hranici 0x100
|
|
|
124 |
.................... void DelaySpecial(unsigned int16 Time)
|
|
|
125 |
.................... // Pomocna procedura pro mereni spozdeni s granularitou 1 instrukcni takt
|
|
|
126 |
.................... // Cas v instrukcnich cyklech, skutecny cas je vetsi o _konstantni_ rezii
|
|
|
127 |
.................... // Maximalni cas je 65536 us
|
|
|
128 |
.................... {
|
|
|
129 |
.................... unsigned int8 TimeHi; // Pro pristup k horni casti Time
|
|
|
130 |
....................
|
|
|
131 |
.................... *0x0A = LABEL_ADDRESS(Next)>>8; // Nastav PCLATH
|
|
|
132 |
*
|
|
|
133 |
0100: MOVLW 01
|
|
|
134 |
0101: MOVWF 23
|
|
|
135 |
0102: MOVLW 0A
|
|
|
136 |
0103: MOVWF 7E
|
|
|
137 |
0104: MOVF 23,W
|
|
|
138 |
0105: MOVWF 0A
|
|
|
139 |
.................... #asm
|
|
|
140 |
.................... movf Time,w // Zpracuj nejnizsi 3 bity
|
|
|
141 |
0106: MOVF 7B,W
|
|
|
142 |
.................... xorlw 7 // Pro hodnotu 0 skakej pres vsechny nopy
|
|
|
143 |
0107: XORLW 07
|
|
|
144 |
.................... andlw 7 // Ber jen spodni 3 bity
|
|
|
145 |
0108: ANDLW 07
|
|
|
146 |
.................... addwf 2,f // Preskoc zadny az vsech 8 nopu (2 je PCL)
|
|
|
147 |
0109: ADDWF 02,F
|
|
|
148 |
.................... Next:
|
|
|
149 |
.................... nop // Spozdeni s granularitou 1 takt
|
|
|
150 |
010A: NOP
|
|
|
151 |
.................... nop
|
|
|
152 |
010B: NOP
|
|
|
153 |
.................... nop
|
|
|
154 |
010C: NOP
|
|
|
155 |
.................... nop
|
|
|
156 |
010D: NOP
|
|
|
157 |
.................... nop
|
|
|
158 |
010E: NOP
|
|
|
159 |
.................... nop
|
|
|
160 |
010F: NOP
|
|
|
161 |
.................... nop
|
|
|
162 |
0110: NOP
|
|
|
163 |
.................... nop
|
|
|
164 |
.................... #endasm
|
|
|
165 |
0111: NOP
|
|
|
166 |
.................... Time = Time >> 3; // Zahod spodni 3 bity
|
|
|
167 |
0112: RRF 7C,F
|
|
|
168 |
0113: RRF 7B,F
|
|
|
169 |
0114: RRF 7C,F
|
|
|
170 |
0115: RRF 7B,F
|
|
|
171 |
0116: RRF 7C,F
|
|
|
172 |
0117: RRF 7B,F
|
|
|
173 |
0118: MOVLW 1F
|
|
|
174 |
0119: ANDWF 7C,F
|
|
|
175 |
.................... TimeHi=Time>>8; // Oddel horni cast citace
|
|
|
176 |
011A: MOVF 7C,W
|
|
|
177 |
011B: MOVWF 7D
|
|
|
178 |
.................... Time++; // Korekce na casovani typu dcfsz
|
|
|
179 |
011C: INCF 7B,F
|
|
|
180 |
011D: BTFSC 03.2
|
|
|
181 |
011E: INCF 7C,F
|
|
|
182 |
.................... TimeHi++;
|
|
|
183 |
011F: INCF 7D,F
|
|
|
184 |
.................... #asm
|
|
|
185 |
.................... Loop:
|
|
|
186 |
.................... nop // Smycka musi trvat 8 taktu
|
|
|
187 |
0120: NOP
|
|
|
188 |
.................... nop // a ma 16 bitu dlouhy citac
|
|
|
189 |
0121: NOP
|
|
|
190 |
.................... nop
|
|
|
191 |
0122: NOP
|
|
|
192 |
.................... decfsz Time
|
|
|
193 |
0123: DECFSZ 7B,F
|
|
|
194 |
.................... goto Next1
|
|
|
195 |
0124: GOTO 126
|
|
|
196 |
.................... decfsz TimeHi
|
|
|
197 |
0125: DECFSZ 7D,F
|
|
|
198 |
.................... Next1:
|
|
|
199 |
.................... goto Loop
|
|
|
200 |
.................... #endasm
|
|
|
201 |
0126: GOTO 120
|
|
|
202 |
0127: RETLW 00
|
|
|
203 |
....................
|
|
|
204 |
.................... }
|
|
|
205 |
....................
|
|
|
206 |
....................
|
|
|
207 |
.................... unsigned int32 SoundCount; // Pocet pulperid geneovaneho signalu
|
|
|
208 |
.................... unsigned int32 SoundPeriod; // Delka pulperiody v us (zmensene o SOUND_REZIE)
|
|
|
209 |
....................
|
|
|
210 |
....................
|
|
|
211 |
.................... void SoundLoop()
|
|
|
212 |
.................... // Pomocna funkce - hlavni zvukova smycka
|
|
|
213 |
.................... {
|
|
|
214 |
.................... int1 Data;
|
|
|
215 |
.................... unsigned int16 i;
|
|
|
216 |
....................
|
|
|
217 |
.................... for(i=SoundCount;i>0;i--) // Pocet pulperiod
|
|
|
218 |
*
|
|
|
219 |
019F: MOVF 26,W
|
|
|
220 |
01A0: MOVWF 78
|
|
|
221 |
01A1: MOVF 25,W
|
|
|
222 |
01A2: MOVWF 77
|
|
|
223 |
01A3: MOVF 77,F
|
|
|
224 |
01A4: BTFSS 03.2
|
|
|
225 |
01A5: GOTO 1A9
|
|
|
226 |
01A6: MOVF 78,F
|
|
|
227 |
01A7: BTFSC 03.2
|
|
|
228 |
01A8: GOTO 1C9
|
|
|
229 |
.................... {
|
|
|
230 |
.................... output_bit(SOUND_HI,Data); // Nastav vystup
|
|
|
231 |
01A9: BTFSC 76.0
|
|
|
232 |
01AA: GOTO 1AD
|
|
|
233 |
01AB: BCF 06.2
|
|
|
234 |
01AC: GOTO 1AE
|
|
|
235 |
01AD: BSF 06.2
|
|
|
236 |
01AE: BSF 03.5
|
|
|
237 |
01AF: BCF 06.2
|
|
|
238 |
.................... output_bit(SOUND_LO,~Data);
|
|
|
239 |
01B0: BCF 03.5
|
|
|
240 |
01B1: BTFSS 76.0
|
|
|
241 |
01B2: GOTO 1B5
|
|
|
242 |
01B3: BCF 06.3
|
|
|
243 |
01B4: GOTO 1B6
|
|
|
244 |
01B5: BSF 06.3
|
|
|
245 |
01B6: BSF 03.5
|
|
|
246 |
01B7: BCF 06.3
|
|
|
247 |
.................... Data=~Data; // Otoc stav vystupu
|
|
|
248 |
01B8: MOVLW 01
|
|
|
249 |
01B9: BCF 03.5
|
|
|
250 |
01BA: XORWF 76,F
|
|
|
251 |
.................... DelaySpecial(SoundPeriod); // Pockej po dobu plperiody
|
|
|
252 |
01BB: MOVF 2A,W
|
|
|
253 |
01BC: MOVWF 7A
|
|
|
254 |
01BD: MOVF 29,W
|
|
|
255 |
01BE: MOVWF 79
|
|
|
256 |
01BF: MOVF 2A,W
|
|
|
257 |
01C0: MOVWF 7C
|
|
|
258 |
01C1: MOVF 29,W
|
|
|
259 |
01C2: MOVWF 7B
|
|
|
260 |
01C3: CALL 100
|
|
|
261 |
.................... }
|
|
|
262 |
01C4: MOVF 77,W
|
|
|
263 |
01C5: BTFSC 03.2
|
|
|
264 |
01C6: DECF 78,F
|
|
|
265 |
01C7: DECF 77,F
|
|
|
266 |
01C8: GOTO 1A3
|
|
|
267 |
.................... }
|
|
|
268 |
....................
|
|
|
269 |
....................
|
|
|
270 |
.................... void SoundBeep(unsigned int16 Frequency, unsigned int16 Duration)
|
|
|
271 |
.................... // Predava se frekvence v Hz a doba trvani v ms (0 znamena ticho)
|
|
|
272 |
.................... // Rozumne frekvence jsou v rozsahu cca 10Hz az 5000Hz pro krystal 4MHz,
|
|
|
273 |
.................... // cas do cca 5s (2*Cas/1000*Freq musi byt < nez 65536)
|
|
|
274 |
.................... {
|
|
|
275 |
.................... if (Frequency==0)
|
|
|
276 |
*
|
|
|
277 |
0129: MOVF 72,F
|
|
|
278 |
012A: BTFSS 03.2
|
|
|
279 |
012B: GOTO 140
|
|
|
280 |
012C: MOVF 73,F
|
|
|
281 |
012D: BTFSS 03.2
|
|
|
282 |
012E: GOTO 140
|
|
|
283 |
.................... {
|
|
|
284 |
.................... for(;Duration>0;Duration--)
|
|
|
285 |
012F: MOVF 74,F
|
|
|
286 |
0130: BTFSS 03.2
|
|
|
287 |
0131: GOTO 135
|
|
|
288 |
0132: MOVF 75,F
|
|
|
289 |
0133: BTFSC 03.2
|
|
|
290 |
0134: GOTO 13F
|
|
|
291 |
.................... {
|
|
|
292 |
.................... DelaySpecial(1000); // Zhruba 1ms
|
|
|
293 |
0135: MOVLW 03
|
|
|
294 |
0136: MOVWF 7C
|
|
|
295 |
0137: MOVLW E8
|
|
|
296 |
0138: MOVWF 7B
|
|
|
297 |
0139: CALL 100
|
|
|
298 |
.................... }
|
|
|
299 |
013A: MOVF 74,W
|
|
|
300 |
013B: BTFSC 03.2
|
|
|
301 |
013C: DECF 75,F
|
|
|
302 |
013D: DECF 74,F
|
|
|
303 |
013E: GOTO 12F
|
|
|
304 |
.................... return;
|
|
|
305 |
013F: GOTO 1C9
|
|
|
306 |
.................... }
|
|
|
307 |
....................
|
|
|
308 |
.................... SoundPeriod=(SOUND_CLOCK/4/2)/Frequency-SOUND_REZIE;
|
|
|
309 |
0140: CLRF 79
|
|
|
310 |
0141: MOVLW 07
|
|
|
311 |
0142: MOVWF 78
|
|
|
312 |
0143: MOVLW A1
|
|
|
313 |
0144: MOVWF 77
|
|
|
314 |
0145: MOVLW 20
|
|
|
315 |
0146: MOVWF 76
|
|
|
316 |
0147: CLRF 7D
|
|
|
317 |
0148: CLRF 7C
|
|
|
318 |
0149: MOVF 73,W
|
|
|
319 |
014A: MOVWF 7B
|
|
|
320 |
014B: MOVF 72,W
|
|
|
321 |
014C: MOVWF 7A
|
|
|
322 |
014D: CALL 004
|
|
|
323 |
014E: MOVF 23,W
|
|
|
324 |
014F: MOVWF 79
|
|
|
325 |
0150: MOVF 22,W
|
|
|
326 |
0151: MOVWF 78
|
|
|
327 |
0152: MOVF 21,W
|
|
|
328 |
0153: MOVWF 77
|
|
|
329 |
0154: MOVF 20,W
|
|
|
330 |
0155: MOVWF 76
|
|
|
331 |
0156: MOVLW 48
|
|
|
332 |
0157: SUBWF 76,W
|
|
|
333 |
0158: MOVWF 29
|
|
|
334 |
0159: MOVF 77,W
|
|
|
335 |
015A: MOVWF 2A
|
|
|
336 |
015B: MOVLW 00
|
|
|
337 |
015C: BTFSS 03.0
|
|
|
338 |
015D: MOVLW 01
|
|
|
339 |
015E: SUBWF 2A,F
|
|
|
340 |
015F: MOVF 78,W
|
|
|
341 |
0160: MOVWF 2B
|
|
|
342 |
0161: MOVLW 00
|
|
|
343 |
0162: BTFSS 03.0
|
|
|
344 |
0163: MOVLW 01
|
|
|
345 |
0164: SUBWF 2B,F
|
|
|
346 |
0165: MOVF 79,W
|
|
|
347 |
0166: MOVWF 2C
|
|
|
348 |
0167: MOVLW 00
|
|
|
349 |
0168: BTFSS 03.0
|
|
|
350 |
0169: MOVLW 01
|
|
|
351 |
016A: SUBWF 2C,F
|
|
|
352 |
....................
|
|
|
353 |
.................... SoundCount=Duration; // Vypocet poctu pulperiod signalu Duration*Frequency*2/1000
|
|
|
354 |
016B: CLRF 28
|
|
|
355 |
016C: CLRF 27
|
|
|
356 |
016D: MOVF 75,W
|
|
|
357 |
016E: MOVWF 26
|
|
|
358 |
016F: MOVF 74,W
|
|
|
359 |
0170: MOVWF 25
|
|
|
360 |
.................... SoundCount*=Frequency;
|
|
|
361 |
0171: MOVF 28,W
|
|
|
362 |
0172: MOVWF 79
|
|
|
363 |
0173: MOVF 27,W
|
|
|
364 |
0174: MOVWF 78
|
|
|
365 |
0175: MOVF 26,W
|
|
|
366 |
0176: MOVWF 77
|
|
|
367 |
0177: MOVF 25,W
|
|
|
368 |
0178: MOVWF 76
|
|
|
369 |
0179: CLRF 7D
|
|
|
370 |
017A: CLRF 7C
|
|
|
371 |
017B: MOVF 73,W
|
|
|
372 |
017C: MOVWF 7B
|
|
|
373 |
017D: MOVF 72,W
|
|
|
374 |
017E: MOVWF 7A
|
|
|
375 |
017F: GOTO 066
|
|
|
376 |
0180: MOVF 23,W
|
|
|
377 |
0181: MOVWF 28
|
|
|
378 |
0182: MOVF 22,W
|
|
|
379 |
0183: MOVWF 27
|
|
|
380 |
0184: MOVF 21,W
|
|
|
381 |
0185: MOVWF 26
|
|
|
382 |
0186: MOVF 20,W
|
|
|
383 |
0187: MOVWF 25
|
|
|
384 |
.................... SoundCount/=500;
|
|
|
385 |
0188: MOVF 28,W
|
|
|
386 |
0189: MOVWF 79
|
|
|
387 |
018A: MOVF 27,W
|
|
|
388 |
018B: MOVWF 78
|
|
|
389 |
018C: MOVF 26,W
|
|
|
390 |
018D: MOVWF 77
|
|
|
391 |
018E: MOVF 25,W
|
|
|
392 |
018F: MOVWF 76
|
|
|
393 |
0190: CLRF 7D
|
|
|
394 |
0191: CLRF 7C
|
|
|
395 |
0192: MOVLW 01
|
|
|
396 |
0193: MOVWF 7B
|
|
|
397 |
0194: MOVLW F4
|
|
|
398 |
0195: MOVWF 7A
|
|
|
399 |
0196: CALL 004
|
|
|
400 |
0197: MOVF 23,W
|
|
|
401 |
0198: MOVWF 28
|
|
|
402 |
0199: MOVF 22,W
|
|
|
403 |
019A: MOVWF 27
|
|
|
404 |
019B: MOVF 21,W
|
|
|
405 |
019C: MOVWF 26
|
|
|
406 |
019D: MOVF 20,W
|
|
|
407 |
019E: MOVWF 25
|
|
|
408 |
....................
|
|
|
409 |
.................... SoundLoop(); // Pozor pouzivaji se globalni parametry
|
|
|
410 |
*
|
|
|
411 |
01C9: RETLW 00
|
|
|
412 |
.................... }
|
|
|
413 |
....................
|
|
|
414 |
.................... // Definice casu pulperody pro nejnizsi oktavu, v mikrosekundach
|
|
|
415 |
.................... // Periody tonu v dalsich oktavach se ziskavaji rotaci vpravo
|
|
|
416 |
.................... #define SOUND_Peri_C (30578*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 30578us
|
|
|
417 |
.................... #define SOUND_Peri_Cis (28862*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 28862us
|
|
|
418 |
.................... #define SOUND_Peri_D (27242*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 27242us
|
|
|
419 |
.................... #define SOUND_Peri_Dis (25713*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 25713us
|
|
|
420 |
.................... #define SOUND_Peri_E (24270*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 24270us
|
|
|
421 |
.................... #define SOUND_Peri_F (22908*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 22908us
|
|
|
422 |
.................... #define SOUND_Peri_Fis (21622*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 21622us
|
|
|
423 |
.................... #define SOUND_Peri_G (20408*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 20408us
|
|
|
424 |
.................... #define SOUND_Peri_Gis (19263*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 19263us
|
|
|
425 |
.................... #define SOUND_Peri_A (18182*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 18182us
|
|
|
426 |
.................... #define SOUND_Peri_Ais (17161*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 17161us
|
|
|
427 |
.................... #define SOUND_Peri_H (16198*(SOUND_CLOCK/1000)/1000/4/2) // Perioda 16198us
|
|
|
428 |
....................
|
|
|
429 |
.................... #if SOUND_Peri_C > 65535
|
|
|
430 |
.................... #error "Sound Clock too high (Note C requires delay > 65535 cycles)"
|
|
|
431 |
.................... #endif
|
|
|
432 |
....................
|
|
|
433 |
.................... const int16 Table[12] = SOUND_Peri_C, SOUND_Peri_Cis, SOUND_Peri_D, SOUND_Peri_Dis,
|
|
|
434 |
.................... SOUND_Peri_E, SOUND_Peri_F, SOUND_Peri_Fis, SOUND_Peri_G,
|
|
|
435 |
.................... SOUND_Peri_Gis, SOUND_Peri_A, SOUND_Peri_Ais, SOUND_Peri_H;
|
|
|
436 |
....................
|
|
|
437 |
.................... void SoundNote(unsigned int8 Note, Octave, unsigned int16 Duration)
|
|
|
438 |
.................... // Predava se cislo noty (0 je C), posunuti v oktavach (0 nejnizsi ton)
|
|
|
439 |
.................... // doba trvani v ms (0 znamena ticho)
|
|
|
440 |
.................... // Zahraje zadanou notu v zadane oktave dane delky
|
|
|
441 |
.................... {
|
|
|
442 |
....................
|
|
|
443 |
.................... if (Note==SOUND_Space)
|
|
|
444 |
.................... {
|
|
|
445 |
.................... for(;Duration>0;Duration--)
|
|
|
446 |
.................... DelaySpecial(1000); // Zhruba 1ms
|
|
|
447 |
.................... return;
|
|
|
448 |
.................... }
|
|
|
449 |
....................
|
|
|
450 |
.................... SoundPeriod=(Table[Note]>>Octave)-0; // Zde je chyba prekladace, nula musi zusat
|
|
|
451 |
....................
|
|
|
452 |
.................... SoundCount=Duration;
|
|
|
453 |
.................... SoundCount*=1000;
|
|
|
454 |
.................... SoundCount/=SoundPeriod;
|
|
|
455 |
....................
|
|
|
456 |
.................... SoundPeriod=SoundPeriod-SOUND_REZIE;
|
|
|
457 |
....................
|
|
|
458 |
.................... SoundLoop(); // Pozor pouzivaji se globalni parametry
|
|
|
459 |
.................... }
|
|
|
460 |
....................
|
|
|
461 |
....................
|
|
|
462 |
.................... // Sada maker, ktera neobsahuji slozity vypocet a jsou
|
|
|
463 |
.................... // tedy vhodna pro jednoduche pipnuti. Parametry jsou stejne
|
|
|
464 |
.................... // jako o funkci.
|
|
|
465 |
.................... #define SoundBeepMacro(F,D) \
|
|
|
466 |
.................... SoundPeriod=SOUND_CLOCK/4/2/F-SOUND_REZIE; \
|
|
|
467 |
.................... SoundCount=D*F/500; \
|
|
|
468 |
.................... SoundLoop();
|
|
|
469 |
....................
|
|
|
470 |
.................... #define SoundNoteMacro(N,O,D) \
|
|
|
471 |
.................... SoundPeriod=(Table[N]>>O)-SOUND_REZIE; \
|
|
|
472 |
.................... SoundCount=D*1000/(Table[N]>>O); \
|
|
|
473 |
.................... SoundLoop();
|
|
|
474 |
....................
|
|
|
475 |
.................... #define SoundPauseMacro(D) \
|
|
|
476 |
.................... { \
|
|
|
477 |
.................... #if D>255 \
|
|
|
478 |
.................... unsigned int16 i=D; \
|
|
|
479 |
.................... #else \
|
|
|
480 |
.................... unsigned int8 i=D; \
|
|
|
481 |
.................... #endif \
|
|
|
482 |
.................... for(;i>0;i--) \
|
|
|
483 |
.................... { \
|
|
|
484 |
.................... DelaySpecial(1000); \
|
|
|
485 |
.................... } \
|
|
|
486 |
.................... }
|
|
|
487 |
....................
|
|
|
488 |
....................
|
|
|
489 |
.................... #DEFINE TXo PIN_C0 // Vysilac
|
|
|
490 |
.................... #include "C:\library\kaklik\CCS\AX25.c" // Podprogram pro prenos telemetrie
|
|
|
491 |
.................... //#define PTT PIN_A2 // PTT control
|
|
|
492 |
.................... //#define TXo PIN_C0 // To the transmitter modulator
|
|
|
493 |
.................... #define PERIODAH delay_us(222) // Halfperiod H 222;78/1200 500;430/500
|
|
|
494 |
.................... #define TAILH delay_us(78)
|
|
|
495 |
.................... #define PERIODAL delay_us(412) // Halfperiod L 412;345/1200 1000;880/500
|
|
|
496 |
.................... #define TAILL delay_us(345)
|
|
|
497 |
.................... #byte STATUS = 3 // CPUs status register
|
|
|
498 |
....................
|
|
|
499 |
.................... byte SendData[16] = {'A'<<1, 'L'<<1, 'L'<<1, ' '<<1, ' '<<1, ' '<<1, 0x60,
|
|
|
500 |
.................... 'C'<<1, 'Z'<<1, '0'<<1, 'R'<<1, 'R'<<1, 'R'<<1, 0x61,
|
|
|
501 |
.................... 0x03, 0xF0};
|
|
|
502 |
....................
|
|
|
503 |
.................... boolean bit;
|
|
|
504 |
.................... int fcslo, fcshi; // variabloes for calculating FCS (CRC)
|
|
|
505 |
.................... int stuff; // stuff counter for extra 0
|
|
|
506 |
.................... int flag_flag; // if it is sending flag (7E)
|
|
|
507 |
.................... int fcs_flag; // if it is sending Frame Check Sequence
|
|
|
508 |
.................... int i; // for for
|
|
|
509 |
....................
|
|
|
510 |
.................... void flipout() //flips the state of output pin a_1
|
|
|
511 |
.................... {
|
|
|
512 |
.................... stuff = 0; //since this is a 0, reset the stuff counter
|
|
|
513 |
.................... if (bit)
|
|
|
514 |
.................... {
|
|
|
515 |
.................... bit=FALSE; //if the state of the pin was low, make it high.
|
|
|
516 |
.................... }
|
|
|
517 |
.................... else
|
|
|
518 |
.................... {
|
|
|
519 |
.................... bit=TRUE; //if the state of the pin was high make it low
|
|
|
520 |
.................... }
|
|
|
521 |
.................... }
|
|
|
522 |
....................
|
|
|
523 |
.................... void fcsbit(byte tbyte)
|
|
|
524 |
.................... {
|
|
|
525 |
.................... #asm
|
|
|
526 |
.................... BCF STATUS,0
|
|
|
527 |
.................... RRF fcshi,F // rotates the entire 16 bits
|
|
|
528 |
.................... RRF fcslo,F // to the right
|
|
|
529 |
.................... #endasm
|
|
|
530 |
.................... if (((STATUS & 0x01)^(tbyte)) ==0x01)
|
|
|
531 |
.................... {
|
|
|
532 |
.................... fcshi = fcshi^0x84;
|
|
|
533 |
.................... fcslo = fcslo^0x08;
|
|
|
534 |
.................... }
|
|
|
535 |
.................... }
|
|
|
536 |
....................
|
|
|
537 |
.................... void SendBit ()
|
|
|
538 |
.................... {
|
|
|
539 |
.................... if (bit)
|
|
|
540 |
.................... {
|
|
|
541 |
.................... output_high(TXo);
|
|
|
542 |
.................... PERIODAH;
|
|
|
543 |
.................... output_low(TXo);
|
|
|
544 |
.................... PERIODAH;
|
|
|
545 |
.................... output_high(TXo);
|
|
|
546 |
.................... PERIODAH;
|
|
|
547 |
.................... output_low(TXo);
|
|
|
548 |
.................... TAILH;
|
|
|
549 |
.................... }
|
|
|
550 |
.................... else
|
|
|
551 |
.................... {
|
|
|
552 |
.................... output_high(TXo);
|
|
|
553 |
.................... PERIODAL;
|
|
|
554 |
.................... output_low(TXo);
|
|
|
555 |
.................... TAILL;
|
|
|
556 |
.................... };
|
|
|
557 |
.................... }
|
|
|
558 |
....................
|
|
|
559 |
.................... void SendByte (byte inbyte)
|
|
|
560 |
.................... {
|
|
|
561 |
.................... int k, bt;
|
|
|
562 |
....................
|
|
|
563 |
.................... for (k=0;k<8;k++) //do the following for each of the 8 bits in the byte
|
|
|
564 |
.................... {
|
|
|
565 |
.................... bt = inbyte & 0x01; //strip off the rightmost bit of the byte to be sent (inbyte)
|
|
|
566 |
.................... if ((fcs_flag == FALSE) & (flag_flag == FALSE)) fcsbit(bt); //do FCS calc, but only if this
|
|
|
567 |
.................... //is not a flag or fcs byte
|
|
|
568 |
.................... if (bt == 0)
|
|
|
569 |
.................... {
|
|
|
570 |
.................... flipout();
|
|
|
571 |
.................... } // if this bit is a zero, flip the output state
|
|
|
572 |
.................... else
|
|
|
573 |
.................... { //otherwise if it is a 1, do the following:
|
|
|
574 |
.................... if (flag_flag == FALSE) stuff++; //increment the count of consequtive 1's
|
|
|
575 |
.................... if ((flag_flag == FALSE) & (stuff == 5))
|
|
|
576 |
.................... { //stuff an extra 0, if 5 1's in a row
|
|
|
577 |
.................... SendBit();
|
|
|
578 |
.................... flipout(); //flip the output state to stuff a 0
|
|
|
579 |
.................... }//end of if
|
|
|
580 |
.................... }//end of else
|
|
|
581 |
.................... // delay_us(850); //introduces a delay that creates 1200 baud
|
|
|
582 |
.................... SendBit();
|
|
|
583 |
.................... inbyte = inbyte>>1; //go to the next bit in the byte
|
|
|
584 |
.................... }//end of for
|
|
|
585 |
.................... }//end of SendByte
|
|
|
586 |
....................
|
|
|
587 |
.................... void SendPacket(char *data)
|
|
|
588 |
.................... {
|
|
|
589 |
.................... bit=FALSE;
|
|
|
590 |
....................
|
|
|
591 |
.................... fcslo=fcshi=0xFF; //The 2 FCS Bytes are initialized to FF
|
|
|
592 |
.................... stuff = 0; //The variable stuff counts the number of 1's in a row. When it gets to 5
|
|
|
593 |
.................... // it is time to stuff a 0.
|
|
|
594 |
....................
|
|
|
595 |
.................... // output_low(PTT); // Blinking LED
|
|
|
596 |
.................... // delay_ms(1000);
|
|
|
597 |
.................... // output_high(PTT);
|
|
|
598 |
....................
|
|
|
599 |
.................... flag_flag = TRUE; //The variable flag is true if you are transmitted flags (7E's) false otherwise.
|
|
|
600 |
.................... fcs_flag = FALSE; //The variable fcsflag is true if you are transmitting FCS bytes, false otherwise.
|
|
|
601 |
....................
|
|
|
602 |
.................... for(i=0; i<10; i++) SendByte(0x7E); //Sends flag bytes. Adjust length for txdelay
|
|
|
603 |
.................... //each flag takes approx 6.7 ms
|
|
|
604 |
.................... flag_flag = FALSE; //done sending flags
|
|
|
605 |
....................
|
|
|
606 |
.................... for(i=0; i<16; i++) SendByte(SendData[i]); //send the packet bytes
|
|
|
607 |
....................
|
|
|
608 |
.................... for(i=0; 0 != *data; i++)
|
|
|
609 |
.................... {
|
|
|
610 |
.................... SendByte(*data); //send the packet bytes
|
|
|
611 |
.................... data++;
|
|
|
612 |
.................... };
|
|
|
613 |
....................
|
|
|
614 |
.................... fcs_flag = TRUE; //about to send the FCS bytes
|
|
|
615 |
.................... fcslo =fcslo^0xff; //must XOR them with FF before sending
|
|
|
616 |
.................... fcshi = fcshi^0xff;
|
|
|
617 |
.................... SendByte(fcslo); //send the low byte of fcs
|
|
|
618 |
.................... SendByte(fcshi); //send the high byte of fcs
|
|
|
619 |
.................... fcs_flag = FALSE; //done sending FCS
|
|
|
620 |
.................... flag_flag = TRUE; //about to send flags
|
|
|
621 |
.................... SendByte(0x7e); // Send a flag to end packet
|
|
|
622 |
.................... }
|
|
|
623 |
....................
|
|
|
624 |
....................
|
|
|
625 |
....................
|
|
|
626 |
....................
|
|
|
627 |
....................
|
|
|
628 |
.................... //program
|
|
|
629 |
.................... #define MEZERA 38 // jak se muze jet dlouho bez cary
|
|
|
630 |
.................... #define COUVEJ 700 // kolik se ma couvat po detekci diry
|
|
|
631 |
.................... #define CIKCAK 40 // kolik se ma jet cik/cak
|
|
|
632 |
.................... #define PRES_DIRU 350 // jak predpokladame velkou diru
|
|
|
633 |
.................... #define TRESHOLD 50
|
|
|
634 |
....................
|
|
|
635 |
.................... #define L 0 // left
|
|
|
636 |
.................... #define R 1 // right
|
|
|
637 |
.................... #define S 2 // straight
|
|
|
638 |
....................
|
|
|
639 |
.................... char AXstring[40]; // Buffer pro prenos telemetrie
|
|
|
640 |
....................
|
|
|
641 |
.................... int movement; // smer minuleho pohybu
|
|
|
642 |
.................... int line; // na ktere strane byla detekovana cara
|
|
|
643 |
.................... int dira; // pocitadlo pro nalezeni preruseni cary
|
|
|
644 |
.................... int n; // pomocna promena pro cyklus FOR
|
|
|
645 |
....................
|
|
|
646 |
.................... void cik_cak() // Hledani cary
|
|
|
647 |
.................... {
|
|
|
648 |
.................... n=CIKCAK/2; // poprve hned zatoc opacne, nez se jelo pred detekci diry
|
|
|
649 |
.................... switch(movement) // zmenime smer zataceni
|
|
|
650 |
.................... {
|
|
|
651 |
.................... case L:
|
|
|
652 |
.................... FL;STOPR; // doprava
|
|
|
653 |
.................... movement=R; // poznamenej kam jedem
|
|
|
654 |
.................... line=L; // kdyz prejedem, tak bude cara vlevo
|
|
|
655 |
.................... break;
|
|
|
656 |
.................... case R:
|
|
|
657 |
.................... FR;STOPL; // doleva
|
|
|
658 |
.................... movement=L; // poznamenej kam jedem
|
|
|
659 |
.................... line=R; // kdyz prejedem, tak bude cara vpravo
|
|
|
660 |
.................... break;
|
|
|
661 |
.................... }
|
|
|
662 |
....................
|
|
|
663 |
.................... while(true) // jed cik-cak, dokud nenajdes caru
|
|
|
664 |
.................... {
|
|
|
665 |
.................... set_adc_channel(RSENSOR);
|
|
|
666 |
.................... if (TRESHOLD > read_adc()) // je cara ??
|
|
|
667 |
.................... {
|
|
|
668 |
.................... STOPL;
|
|
|
669 |
.................... STOPR;
|
|
|
670 |
.................... break;
|
|
|
671 |
.................... };
|
|
|
672 |
.................... if (CIKCAK < n++) // Jedeme uz dost dlouho cik??Pak jed cak.
|
|
|
673 |
.................... {
|
|
|
674 |
.................... n=0;
|
|
|
675 |
.................... STOPL;
|
|
|
676 |
.................... STOPR;
|
|
|
677 |
.................... switch(movement) // zmenime smer zataceni
|
|
|
678 |
.................... {
|
|
|
679 |
.................... case L:
|
|
|
680 |
.................... FL; // doprava
|
|
|
681 |
.................... movement=R; // poznamenej kam jedem
|
|
|
682 |
.................... line=L; // kdyz prejedem, tak bude cara vlevo
|
|
|
683 |
.................... break;
|
|
|
684 |
.................... case R:
|
|
|
685 |
.................... FR; // doleva
|
|
|
686 |
.................... movement=L; // poznamenej kam jedem
|
|
|
687 |
.................... line=R; // kdyz prejedem, tak bude cara vpravo
|
|
|
688 |
.................... break;
|
|
|
689 |
.................... }
|
|
|
690 |
.................... }
|
|
|
691 |
.................... }
|
|
|
692 |
.................... }
|
|
|
693 |
....................
|
|
|
694 |
....................
|
|
|
695 |
.................... void diagnostika()
|
|
|
696 |
.................... {
|
|
|
697 |
.................... int n;
|
|
|
698 |
....................
|
|
|
699 |
.................... while (input(PIN_C4))
|
|
|
700 |
01CA: BSF 44.4
|
|
|
701 |
01CB: MOVF 44,W
|
|
|
702 |
01CC: BSF 03.5
|
|
|
703 |
01CD: MOVWF 07
|
|
|
704 |
01CE: BCF 03.5
|
|
|
705 |
01CF: BTFSS 07.4
|
|
|
706 |
01D0: GOTO 2C9
|
|
|
707 |
.................... {
|
|
|
708 |
....................
|
|
|
709 |
.................... for (n=500; n<5000; n+=100)
|
|
|
710 |
01D1: MOVLW F4
|
|
|
711 |
01D2: MOVWF 71
|
|
|
712 |
.................... {
|
|
|
713 |
.................... SoundBeep(n,50); //beep
|
|
|
714 |
01D3: CLRF 73
|
|
|
715 |
01D4: MOVF 71,W
|
|
|
716 |
01D5: MOVWF 72
|
|
|
717 |
01D6: CLRF 75
|
|
|
718 |
01D7: MOVLW 32
|
|
|
719 |
01D8: MOVWF 74
|
|
|
720 |
01D9: CALL 129
|
|
|
721 |
.................... };
|
|
|
722 |
01DA: MOVLW 64
|
|
|
723 |
01DB: ADDWF 71,F
|
|
|
724 |
01DC: GOTO 1D3
|
|
|
725 |
.................... Delay_ms(1000);
|
|
|
726 |
01DD: MOVLW 04
|
|
|
727 |
01DE: MOVWF 72
|
|
|
728 |
01DF: MOVLW FA
|
|
|
729 |
01E0: MOVWF 73
|
|
|
730 |
01E1: CALL 0A8
|
|
|
731 |
01E2: DECFSZ 72,F
|
|
|
732 |
01E3: GOTO 1DF
|
|
|
733 |
....................
|
|
|
734 |
.................... STOPL; //zastav vse
|
|
|
735 |
01E4: BSF 03.5
|
|
|
736 |
01E5: BCF 06.6
|
|
|
737 |
01E6: BCF 03.5
|
|
|
738 |
01E7: BCF 06.6
|
|
|
739 |
01E8: BSF 03.5
|
|
|
740 |
01E9: BCF 06.7
|
|
|
741 |
01EA: BCF 03.5
|
|
|
742 |
01EB: BCF 06.7
|
|
|
743 |
.................... STOPR;
|
|
|
744 |
01EC: BSF 03.5
|
|
|
745 |
01ED: BCF 06.4
|
|
|
746 |
01EE: BCF 03.5
|
|
|
747 |
01EF: BCF 06.4
|
|
|
748 |
01F0: BSF 03.5
|
|
|
749 |
01F1: BCF 06.5
|
|
|
750 |
01F2: BCF 03.5
|
|
|
751 |
01F3: BCF 06.5
|
|
|
752 |
....................
|
|
|
753 |
.................... FR; //pravy pas
|
|
|
754 |
01F4: BSF 03.5
|
|
|
755 |
01F5: BCF 06.4
|
|
|
756 |
01F6: BCF 03.5
|
|
|
757 |
01F7: BSF 06.4
|
|
|
758 |
01F8: BSF 03.5
|
|
|
759 |
01F9: BCF 06.5
|
|
|
760 |
01FA: BCF 03.5
|
|
|
761 |
01FB: BCF 06.5
|
|
|
762 |
.................... Delay_ms(1000);
|
|
|
763 |
01FC: MOVLW 04
|
|
|
764 |
01FD: MOVWF 72
|
|
|
765 |
01FE: MOVLW FA
|
|
|
766 |
01FF: MOVWF 73
|
|
|
767 |
0200: CALL 0A8
|
|
|
768 |
0201: DECFSZ 72,F
|
|
|
769 |
0202: GOTO 1FE
|
|
|
770 |
.................... STOPR;
|
|
|
771 |
0203: BSF 03.5
|
|
|
772 |
0204: BCF 06.4
|
|
|
773 |
0205: BCF 03.5
|
|
|
774 |
0206: BCF 06.4
|
|
|
775 |
0207: BSF 03.5
|
|
|
776 |
0208: BCF 06.5
|
|
|
777 |
0209: BCF 03.5
|
|
|
778 |
020A: BCF 06.5
|
|
|
779 |
.................... Delay_ms(1000);
|
|
|
780 |
020B: MOVLW 04
|
|
|
781 |
020C: MOVWF 72
|
|
|
782 |
020D: MOVLW FA
|
|
|
783 |
020E: MOVWF 73
|
|
|
784 |
020F: CALL 0A8
|
|
|
785 |
0210: DECFSZ 72,F
|
|
|
786 |
0211: GOTO 20D
|
|
|
787 |
.................... BR;
|
|
|
788 |
0212: BSF 03.5
|
|
|
789 |
0213: BCF 06.5
|
|
|
790 |
0214: BCF 03.5
|
|
|
791 |
0215: BSF 06.5
|
|
|
792 |
0216: BSF 03.5
|
|
|
793 |
0217: BCF 06.4
|
|
|
794 |
0218: BCF 03.5
|
|
|
795 |
0219: BCF 06.4
|
|
|
796 |
.................... Delay_ms(1000);
|
|
|
797 |
021A: MOVLW 04
|
|
|
798 |
021B: MOVWF 72
|
|
|
799 |
021C: MOVLW FA
|
|
|
800 |
021D: MOVWF 73
|
|
|
801 |
021E: CALL 0A8
|
|
|
802 |
021F: DECFSZ 72,F
|
|
|
803 |
0220: GOTO 21C
|
|
|
804 |
.................... STOPR;
|
|
|
805 |
0221: BSF 03.5
|
|
|
806 |
0222: BCF 06.4
|
|
|
807 |
0223: BCF 03.5
|
|
|
808 |
0224: BCF 06.4
|
|
|
809 |
0225: BSF 03.5
|
|
|
810 |
0226: BCF 06.5
|
|
|
811 |
0227: BCF 03.5
|
|
|
812 |
0228: BCF 06.5
|
|
|
813 |
.................... Delay_ms(1000);
|
|
|
814 |
0229: MOVLW 04
|
|
|
815 |
022A: MOVWF 72
|
|
|
816 |
022B: MOVLW FA
|
|
|
817 |
022C: MOVWF 73
|
|
|
818 |
022D: CALL 0A8
|
|
|
819 |
022E: DECFSZ 72,F
|
|
|
820 |
022F: GOTO 22B
|
|
|
821 |
....................
|
|
|
822 |
.................... FL; //levy pas
|
|
|
823 |
0230: BSF 03.5
|
|
|
824 |
0231: BCF 06.6
|
|
|
825 |
0232: BCF 03.5
|
|
|
826 |
0233: BSF 06.6
|
|
|
827 |
0234: BSF 03.5
|
|
|
828 |
0235: BCF 06.7
|
|
|
829 |
0236: BCF 03.5
|
|
|
830 |
0237: BCF 06.7
|
|
|
831 |
.................... Delay_ms(1000);
|
|
|
832 |
0238: MOVLW 04
|
|
|
833 |
0239: MOVWF 72
|
|
|
834 |
023A: MOVLW FA
|
|
|
835 |
023B: MOVWF 73
|
|
|
836 |
023C: CALL 0A8
|
|
|
837 |
023D: DECFSZ 72,F
|
|
|
838 |
023E: GOTO 23A
|
|
|
839 |
.................... STOPL;
|
|
|
840 |
023F: BSF 03.5
|
|
|
841 |
0240: BCF 06.6
|
|
|
842 |
0241: BCF 03.5
|
|
|
843 |
0242: BCF 06.6
|
|
|
844 |
0243: BSF 03.5
|
|
|
845 |
0244: BCF 06.7
|
|
|
846 |
0245: BCF 03.5
|
|
|
847 |
0246: BCF 06.7
|
|
|
848 |
.................... Delay_ms(1000);
|
|
|
849 |
0247: MOVLW 04
|
|
|
850 |
0248: MOVWF 72
|
|
|
851 |
0249: MOVLW FA
|
|
|
852 |
024A: MOVWF 73
|
|
|
853 |
024B: CALL 0A8
|
|
|
854 |
024C: DECFSZ 72,F
|
|
|
855 |
024D: GOTO 249
|
|
|
856 |
.................... BL;
|
|
|
857 |
024E: BSF 03.5
|
|
|
858 |
024F: BCF 06.7
|
|
|
859 |
0250: BCF 03.5
|
|
|
860 |
0251: BSF 06.7
|
|
|
861 |
0252: BSF 03.5
|
|
|
862 |
0253: BCF 06.6
|
|
|
863 |
0254: BCF 03.5
|
|
|
864 |
0255: BCF 06.6
|
|
|
865 |
.................... Delay_ms(1000);
|
|
|
866 |
0256: MOVLW 04
|
|
|
867 |
0257: MOVWF 72
|
|
|
868 |
0258: MOVLW FA
|
|
|
869 |
0259: MOVWF 73
|
|
|
870 |
025A: CALL 0A8
|
|
|
871 |
025B: DECFSZ 72,F
|
|
|
872 |
025C: GOTO 258
|
|
|
873 |
.................... STOPL;
|
|
|
874 |
025D: BSF 03.5
|
|
|
875 |
025E: BCF 06.6
|
|
|
876 |
025F: BCF 03.5
|
|
|
877 |
0260: BCF 06.6
|
|
|
878 |
0261: BSF 03.5
|
|
|
879 |
0262: BCF 06.7
|
|
|
880 |
0263: BCF 03.5
|
|
|
881 |
0264: BCF 06.7
|
|
|
882 |
.................... Delay_ms(1000);
|
|
|
883 |
0265: MOVLW 04
|
|
|
884 |
0266: MOVWF 72
|
|
|
885 |
0267: MOVLW FA
|
|
|
886 |
0268: MOVWF 73
|
|
|
887 |
0269: CALL 0A8
|
|
|
888 |
026A: DECFSZ 72,F
|
|
|
889 |
026B: GOTO 267
|
|
|
890 |
....................
|
|
|
891 |
.................... FL; //oba pasy
|
|
|
892 |
026C: BSF 03.5
|
|
|
893 |
026D: BCF 06.6
|
|
|
894 |
026E: BCF 03.5
|
|
|
895 |
026F: BSF 06.6
|
|
|
896 |
0270: BSF 03.5
|
|
|
897 |
0271: BCF 06.7
|
|
|
898 |
0272: BCF 03.5
|
|
|
899 |
0273: BCF 06.7
|
|
|
900 |
.................... FR;
|
|
|
901 |
0274: BSF 03.5
|
|
|
902 |
0275: BCF 06.4
|
|
|
903 |
0276: BCF 03.5
|
|
|
904 |
0277: BSF 06.4
|
|
|
905 |
0278: BSF 03.5
|
|
|
906 |
0279: BCF 06.5
|
|
|
907 |
027A: BCF 03.5
|
|
|
908 |
027B: BCF 06.5
|
|
|
909 |
.................... Delay_ms(1000);
|
|
|
910 |
027C: MOVLW 04
|
|
|
911 |
027D: MOVWF 72
|
|
|
912 |
027E: MOVLW FA
|
|
|
913 |
027F: MOVWF 73
|
|
|
914 |
0280: CALL 0A8
|
|
|
915 |
0281: DECFSZ 72,F
|
|
|
916 |
0282: GOTO 27E
|
|
|
917 |
.................... STOPL;
|
|
|
918 |
0283: BSF 03.5
|
|
|
919 |
0284: BCF 06.6
|
|
|
920 |
0285: BCF 03.5
|
|
|
921 |
0286: BCF 06.6
|
|
|
922 |
0287: BSF 03.5
|
|
|
923 |
0288: BCF 06.7
|
|
|
924 |
0289: BCF 03.5
|
|
|
925 |
028A: BCF 06.7
|
|
|
926 |
.................... STOPR;
|
|
|
927 |
028B: BSF 03.5
|
|
|
928 |
028C: BCF 06.4
|
|
|
929 |
028D: BCF 03.5
|
|
|
930 |
028E: BCF 06.4
|
|
|
931 |
028F: BSF 03.5
|
|
|
932 |
0290: BCF 06.5
|
|
|
933 |
0291: BCF 03.5
|
|
|
934 |
0292: BCF 06.5
|
|
|
935 |
.................... Delay_ms(1000);
|
|
|
936 |
0293: MOVLW 04
|
|
|
937 |
0294: MOVWF 72
|
|
|
938 |
0295: MOVLW FA
|
|
|
939 |
0296: MOVWF 73
|
|
|
940 |
0297: CALL 0A8
|
|
|
941 |
0298: DECFSZ 72,F
|
|
|
942 |
0299: GOTO 295
|
|
|
943 |
.................... BL;
|
|
|
944 |
029A: BSF 03.5
|
|
|
945 |
029B: BCF 06.7
|
|
|
946 |
029C: BCF 03.5
|
|
|
947 |
029D: BSF 06.7
|
|
|
948 |
029E: BSF 03.5
|
|
|
949 |
029F: BCF 06.6
|
|
|
950 |
02A0: BCF 03.5
|
|
|
951 |
02A1: BCF 06.6
|
|
|
952 |
.................... BR;
|
|
|
953 |
02A2: BSF 03.5
|
|
|
954 |
02A3: BCF 06.5
|
|
|
955 |
02A4: BCF 03.5
|
|
|
956 |
02A5: BSF 06.5
|
|
|
957 |
02A6: BSF 03.5
|
|
|
958 |
02A7: BCF 06.4
|
|
|
959 |
02A8: BCF 03.5
|
|
|
960 |
02A9: BCF 06.4
|
|
|
961 |
.................... Delay_ms(1000);
|
|
|
962 |
02AA: MOVLW 04
|
|
|
963 |
02AB: MOVWF 72
|
|
|
964 |
02AC: MOVLW FA
|
|
|
965 |
02AD: MOVWF 73
|
|
|
966 |
02AE: CALL 0A8
|
|
|
967 |
02AF: DECFSZ 72,F
|
|
|
968 |
02B0: GOTO 2AC
|
|
|
969 |
.................... STOPL;
|
|
|
970 |
02B1: BSF 03.5
|
|
|
971 |
02B2: BCF 06.6
|
|
|
972 |
02B3: BCF 03.5
|
|
|
973 |
02B4: BCF 06.6
|
|
|
974 |
02B5: BSF 03.5
|
|
|
975 |
02B6: BCF 06.7
|
|
|
976 |
02B7: BCF 03.5
|
|
|
977 |
02B8: BCF 06.7
|
|
|
978 |
.................... STOPR;
|
|
|
979 |
02B9: BSF 03.5
|
|
|
980 |
02BA: BCF 06.4
|
|
|
981 |
02BB: BCF 03.5
|
|
|
982 |
02BC: BCF 06.4
|
|
|
983 |
02BD: BSF 03.5
|
|
|
984 |
02BE: BCF 06.5
|
|
|
985 |
02BF: BCF 03.5
|
|
|
986 |
02C0: BCF 06.5
|
|
|
987 |
.................... Delay_ms(1000);
|
|
|
988 |
02C1: MOVLW 04
|
|
|
989 |
02C2: MOVWF 72
|
|
|
990 |
02C3: MOVLW FA
|
|
|
991 |
02C4: MOVWF 73
|
|
|
992 |
02C5: CALL 0A8
|
|
|
993 |
02C6: DECFSZ 72,F
|
|
|
994 |
02C7: GOTO 2C3
|
|
|
995 |
.................... }
|
|
|
996 |
02C8: GOTO 1CA
|
|
|
997 |
02C9: BCF 0A.3
|
|
|
998 |
02CA: GOTO 2F0 (RETURN)
|
|
|
999 |
.................... }
|
|
|
1000 |
....................
|
|
|
1001 |
.................... void main()
|
|
|
1002 |
.................... {
|
|
|
1003 |
02CB: CLRF 04
|
|
|
1004 |
02CC: MOVLW 1F
|
|
|
1005 |
02CD: ANDWF 03,F
|
|
|
1006 |
02CE: MOVLW 07
|
|
|
1007 |
02CF: BSF 03.5
|
|
|
1008 |
02D0: MOVWF 1F
|
|
|
1009 |
02D1: MOVLW 82
|
|
|
1010 |
02D2: BCF 03.5
|
|
|
1011 |
02D3: MOVWF 2D
|
|
|
1012 |
02D4: MOVLW 98
|
|
|
1013 |
02D5: MOVWF 2E
|
|
|
1014 |
02D6: MOVWF 2F
|
|
|
1015 |
02D7: MOVLW 40
|
|
|
1016 |
02D8: MOVWF 30
|
|
|
1017 |
02D9: MOVWF 31
|
|
|
1018 |
02DA: MOVWF 32
|
|
|
1019 |
02DB: MOVLW 60
|
|
|
1020 |
02DC: MOVWF 33
|
|
|
1021 |
02DD: MOVLW 86
|
|
|
1022 |
02DE: MOVWF 34
|
|
|
1023 |
02DF: MOVLW B4
|
|
|
1024 |
02E0: MOVWF 35
|
|
|
1025 |
02E1: MOVLW 60
|
|
|
1026 |
02E2: MOVWF 36
|
|
|
1027 |
02E3: MOVLW A4
|
|
|
1028 |
02E4: MOVWF 37
|
|
|
1029 |
02E5: MOVWF 38
|
|
|
1030 |
02E6: MOVWF 39
|
|
|
1031 |
02E7: MOVLW 61
|
|
|
1032 |
02E8: MOVWF 3A
|
|
|
1033 |
02E9: MOVLW 03
|
|
|
1034 |
02EA: MOVWF 3B
|
|
|
1035 |
02EB: MOVLW F0
|
|
|
1036 |
02EC: MOVWF 3C
|
|
|
1037 |
02ED: MOVLW FF
|
|
|
1038 |
02EE: MOVWF 44
|
|
|
1039 |
.................... diagnostika();
|
|
|
1040 |
02EF: GOTO 1CA
|
|
|
1041 |
....................
|
|
|
1042 |
.................... SoundBeep(640,200); //beep
|
|
|
1043 |
02F0: MOVLW 02
|
|
|
1044 |
02F1: MOVWF 73
|
|
|
1045 |
02F2: MOVLW 80
|
|
|
1046 |
02F3: MOVWF 72
|
|
|
1047 |
02F4: CLRF 75
|
|
|
1048 |
02F5: MOVLW C8
|
|
|
1049 |
02F6: MOVWF 74
|
|
|
1050 |
02F7: CALL 129
|
|
|
1051 |
.................... Delay_ms(50);
|
|
|
1052 |
02F8: MOVLW 32
|
|
|
1053 |
02F9: MOVWF 73
|
|
|
1054 |
02FA: CALL 0A8
|
|
|
1055 |
.................... SoundBeep(640,200);
|
|
|
1056 |
02FB: MOVLW 02
|
|
|
1057 |
02FC: MOVWF 73
|
|
|
1058 |
02FD: MOVLW 80
|
|
|
1059 |
02FE: MOVWF 72
|
|
|
1060 |
02FF: CLRF 75
|
|
|
1061 |
0300: MOVLW C8
|
|
|
1062 |
0301: MOVWF 74
|
|
|
1063 |
0302: CALL 129
|
|
|
1064 |
....................
|
|
|
1065 |
.................... setup_adc_ports(RA0_RA1_RA3_ANALOG);
|
|
|
1066 |
0303: MOVLW 04
|
|
|
1067 |
0304: BSF 03.5
|
|
|
1068 |
0305: MOVWF 1F
|
|
|
1069 |
.................... setup_adc(ADC_CLOCK_DIV_2);
|
|
|
1070 |
0306: BCF 03.5
|
|
|
1071 |
0307: MOVF 1F,W
|
|
|
1072 |
0308: ANDLW 38
|
|
|
1073 |
0309: IORLW 01
|
|
|
1074 |
030A: MOVWF 1F
|
|
|
1075 |
.................... Delay_ms(1000); // 1s
|
|
|
1076 |
030B: MOVLW 04
|
|
|
1077 |
030C: MOVWF 71
|
|
|
1078 |
030D: MOVLW FA
|
|
|
1079 |
030E: MOVWF 73
|
|
|
1080 |
030F: CALL 0A8
|
|
|
1081 |
0310: DECFSZ 71,F
|
|
|
1082 |
0311: GOTO 30D
|
|
|
1083 |
....................
|
|
|
1084 |
.................... movement=R;
|
|
|
1085 |
0312: MOVLW 01
|
|
|
1086 |
0313: MOVWF 6D
|
|
|
1087 |
.................... line=S;
|
|
|
1088 |
0314: MOVLW 02
|
|
|
1089 |
0315: MOVWF 6E
|
|
|
1090 |
.................... dira=0;
|
|
|
1091 |
0316: CLRF 6F
|
|
|
1092 |
....................
|
|
|
1093 |
.................... //cik_cak(); // toc se, abys nasel caru
|
|
|
1094 |
.................... FL; FR; // vpred
|
|
|
1095 |
0317: BSF 03.5
|
|
|
1096 |
0318: BCF 06.6
|
|
|
1097 |
0319: BCF 03.5
|
|
|
1098 |
031A: BSF 06.6
|
|
|
1099 |
031B: BSF 03.5
|
|
|
1100 |
031C: BCF 06.7
|
|
|
1101 |
031D: BCF 03.5
|
|
|
1102 |
031E: BCF 06.7
|
|
|
1103 |
031F: BSF 03.5
|
|
|
1104 |
0320: BCF 06.4
|
|
|
1105 |
0321: BCF 03.5
|
|
|
1106 |
0322: BSF 06.4
|
|
|
1107 |
0323: BSF 03.5
|
|
|
1108 |
0324: BCF 06.5
|
|
|
1109 |
0325: BCF 03.5
|
|
|
1110 |
0326: BCF 06.5
|
|
|
1111 |
....................
|
|
|
1112 |
.................... // Sledovani cary
|
|
|
1113 |
.................... while(true)
|
|
|
1114 |
.................... {
|
|
|
1115 |
.................... snimani:
|
|
|
1116 |
.................... set_adc_channel(RSENSOR);
|
|
|
1117 |
0327: MOVLW 08
|
|
|
1118 |
0328: MOVWF 21
|
|
|
1119 |
0329: MOVF 1F,W
|
|
|
1120 |
032A: ANDLW C7
|
|
|
1121 |
032B: IORWF 21,W
|
|
|
1122 |
032C: MOVWF 1F
|
|
|
1123 |
.................... Delay_us(2);
|
|
|
1124 |
032D: NOP
|
|
|
1125 |
032E: NOP
|
|
|
1126 |
.................... if (TRESHOLD > read_adc()) // Cara pod pravym senzorem
|
|
|
1127 |
032F: BSF 1F.2
|
|
|
1128 |
0330: BTFSC 1F.2
|
|
|
1129 |
0331: GOTO 330
|
|
|
1130 |
0332: MOVF 1E,W
|
|
|
1131 |
0333: SUBLW 31
|
|
|
1132 |
0334: BTFSS 03.0
|
|
|
1133 |
0335: GOTO 34A
|
|
|
1134 |
.................... {
|
|
|
1135 |
.................... dira=0; // nuluj pocitadlo diry, protoze jsme videli caru
|
|
|
1136 |
0336: CLRF 6F
|
|
|
1137 |
.................... line=R; // zaznamenej, kdes videl caru
|
|
|
1138 |
0337: MOVLW 01
|
|
|
1139 |
0338: MOVWF 6E
|
|
|
1140 |
.................... FL;FR;
|
|
|
1141 |
0339: BSF 03.5
|
|
|
1142 |
033A: BCF 06.6
|
|
|
1143 |
033B: BCF 03.5
|
|
|
1144 |
033C: BSF 06.6
|
|
|
1145 |
033D: BSF 03.5
|
|
|
1146 |
033E: BCF 06.7
|
|
|
1147 |
033F: BCF 03.5
|
|
|
1148 |
0340: BCF 06.7
|
|
|
1149 |
0341: BSF 03.5
|
|
|
1150 |
0342: BCF 06.4
|
|
|
1151 |
0343: BCF 03.5
|
|
|
1152 |
0344: BSF 06.4
|
|
|
1153 |
0345: BSF 03.5
|
|
|
1154 |
0346: BCF 06.5
|
|
|
1155 |
0347: BCF 03.5
|
|
|
1156 |
0348: BCF 06.5
|
|
|
1157 |
.................... goto snimani;
|
|
|
1158 |
0349: GOTO 327
|
|
|
1159 |
.................... }
|
|
|
1160 |
....................
|
|
|
1161 |
.................... set_adc_channel(LSENSOR);
|
|
|
1162 |
034A: MOVLW 00
|
|
|
1163 |
034B: MOVWF 21
|
|
|
1164 |
034C: MOVF 1F,W
|
|
|
1165 |
034D: ANDLW C7
|
|
|
1166 |
034E: IORWF 21,W
|
|
|
1167 |
034F: MOVWF 1F
|
|
|
1168 |
.................... Delay_us(2);
|
|
|
1169 |
0350: NOP
|
|
|
1170 |
0351: NOP
|
|
|
1171 |
.................... if (TRESHOLD > read_adc()) // Cara pod levym senzorem
|
|
|
1172 |
0352: BSF 1F.2
|
|
|
1173 |
0353: BTFSC 1F.2
|
|
|
1174 |
0354: GOTO 353
|
|
|
1175 |
0355: MOVF 1E,W
|
|
|
1176 |
0356: SUBLW 31
|
|
|
1177 |
0357: BTFSS 03.0
|
|
|
1178 |
0358: GOTO 36C
|
|
|
1179 |
.................... {
|
|
|
1180 |
.................... dira=0; // nuluj pocitadlo diry, protoze jsme videli caru
|
|
|
1181 |
0359: CLRF 6F
|
|
|
1182 |
.................... line=L; // zaznamenej, kdes videl caru
|
|
|
1183 |
035A: CLRF 6E
|
|
|
1184 |
.................... FL;FR;
|
|
|
1185 |
035B: BSF 03.5
|
|
|
1186 |
035C: BCF 06.6
|
|
|
1187 |
035D: BCF 03.5
|
|
|
1188 |
035E: BSF 06.6
|
|
|
1189 |
035F: BSF 03.5
|
|
|
1190 |
0360: BCF 06.7
|
|
|
1191 |
0361: BCF 03.5
|
|
|
1192 |
0362: BCF 06.7
|
|
|
1193 |
0363: BSF 03.5
|
|
|
1194 |
0364: BCF 06.4
|
|
|
1195 |
0365: BCF 03.5
|
|
|
1196 |
0366: BSF 06.4
|
|
|
1197 |
0367: BSF 03.5
|
|
|
1198 |
0368: BCF 06.5
|
|
|
1199 |
0369: BCF 03.5
|
|
|
1200 |
036A: BCF 06.5
|
|
|
1201 |
.................... goto snimani;
|
|
|
1202 |
036B: GOTO 327
|
|
|
1203 |
.................... }
|
|
|
1204 |
....................
|
|
|
1205 |
.................... // oba senzory mimo caru
|
|
|
1206 |
.................... if (0==dira) // v prvnim cyklu po ztrate cary zacneme zahybat
|
|
|
1207 |
036C: MOVF 6F,F
|
|
|
1208 |
036D: BTFSS 03.2
|
|
|
1209 |
036E: GOTO 3BF
|
|
|
1210 |
.................... // v ostatnich cyklech nedelame nic (pro urychleni snimani)
|
|
|
1211 |
.................... {
|
|
|
1212 |
.................... STOPL;
|
|
|
1213 |
036F: BSF 03.5
|
|
|
1214 |
0370: BCF 06.6
|
|
|
1215 |
0371: BCF 03.5
|
|
|
1216 |
0372: BCF 06.6
|
|
|
1217 |
0373: BSF 03.5
|
|
|
1218 |
0374: BCF 06.7
|
|
|
1219 |
0375: BCF 03.5
|
|
|
1220 |
0376: BCF 06.7
|
|
|
1221 |
.................... STOPR;
|
|
|
1222 |
0377: BSF 03.5
|
|
|
1223 |
0378: BCF 06.4
|
|
|
1224 |
0379: BCF 03.5
|
|
|
1225 |
037A: BCF 06.4
|
|
|
1226 |
037B: BSF 03.5
|
|
|
1227 |
037C: BCF 06.5
|
|
|
1228 |
037D: BCF 03.5
|
|
|
1229 |
037E: BCF 06.5
|
|
|
1230 |
.................... BL;
|
|
|
1231 |
037F: BSF 03.5
|
|
|
1232 |
0380: BCF 06.7
|
|
|
1233 |
0381: BCF 03.5
|
|
|
1234 |
0382: BSF 06.7
|
|
|
1235 |
0383: BSF 03.5
|
|
|
1236 |
0384: BCF 06.6
|
|
|
1237 |
0385: BCF 03.5
|
|
|
1238 |
0386: BCF 06.6
|
|
|
1239 |
.................... BR;
|
|
|
1240 |
0387: BSF 03.5
|
|
|
1241 |
0388: BCF 06.5
|
|
|
1242 |
0389: BCF 03.5
|
|
|
1243 |
038A: BSF 06.5
|
|
|
1244 |
038B: BSF 03.5
|
|
|
1245 |
038C: BCF 06.4
|
|
|
1246 |
038D: BCF 03.5
|
|
|
1247 |
038E: BCF 06.4
|
|
|
1248 |
.................... Delay_ms(20);
|
|
|
1249 |
038F: MOVLW 14
|
|
|
1250 |
0390: MOVWF 73
|
|
|
1251 |
0391: CALL 0A8
|
|
|
1252 |
.................... STOPL;
|
|
|
1253 |
0392: BSF 03.5
|
|
|
1254 |
0393: BCF 06.6
|
|
|
1255 |
0394: BCF 03.5
|
|
|
1256 |
0395: BCF 06.6
|
|
|
1257 |
0396: BSF 03.5
|
|
|
1258 |
0397: BCF 06.7
|
|
|
1259 |
0398: BCF 03.5
|
|
|
1260 |
0399: BCF 06.7
|
|
|
1261 |
.................... STOPR;
|
|
|
1262 |
039A: BSF 03.5
|
|
|
1263 |
039B: BCF 06.4
|
|
|
1264 |
039C: BCF 03.5
|
|
|
1265 |
039D: BCF 06.4
|
|
|
1266 |
039E: BSF 03.5
|
|
|
1267 |
039F: BCF 06.5
|
|
|
1268 |
03A0: BCF 03.5
|
|
|
1269 |
03A1: BCF 06.5
|
|
|
1270 |
.................... Delay_ms(200);
|
|
|
1271 |
03A2: MOVLW C8
|
|
|
1272 |
03A3: MOVWF 73
|
|
|
1273 |
03A4: CALL 0A8
|
|
|
1274 |
.................... // kdyz nevidis caru, tak jed tam, kdes ji videl naposled
|
|
|
1275 |
.................... if(line==L)
|
|
|
1276 |
03A5: MOVF 6E,F
|
|
|
1277 |
03A6: BTFSS 03.2
|
|
|
1278 |
03A7: GOTO 3B1
|
|
|
1279 |
.................... {
|
|
|
1280 |
.................... // doleva
|
|
|
1281 |
.................... // STOPL;
|
|
|
1282 |
.................... FR;
|
|
|
1283 |
03A8: BSF 03.5
|
|
|
1284 |
03A9: BCF 06.4
|
|
|
1285 |
03AA: BCF 03.5
|
|
|
1286 |
03AB: BSF 06.4
|
|
|
1287 |
03AC: BSF 03.5
|
|
|
1288 |
03AD: BCF 06.5
|
|
|
1289 |
03AE: BCF 03.5
|
|
|
1290 |
03AF: BCF 06.5
|
|
|
1291 |
.................... movement=L; // poznamenej kam jedes
|
|
|
1292 |
03B0: CLRF 6D
|
|
|
1293 |
.................... }
|
|
|
1294 |
.................... if(line==R)
|
|
|
1295 |
03B1: DECFSZ 6E,W
|
|
|
1296 |
03B2: GOTO 3BD
|
|
|
1297 |
.................... {
|
|
|
1298 |
.................... // doprava
|
|
|
1299 |
.................... // STOPR;
|
|
|
1300 |
.................... FL;
|
|
|
1301 |
03B3: BSF 03.5
|
|
|
1302 |
03B4: BCF 06.6
|
|
|
1303 |
03B5: BCF 03.5
|
|
|
1304 |
03B6: BSF 06.6
|
|
|
1305 |
03B7: BSF 03.5
|
|
|
1306 |
03B8: BCF 06.7
|
|
|
1307 |
03B9: BCF 03.5
|
|
|
1308 |
03BA: BCF 06.7
|
|
|
1309 |
.................... movement=R; // poznamenej kam jedes
|
|
|
1310 |
03BB: MOVLW 01
|
|
|
1311 |
03BC: MOVWF 6D
|
|
|
1312 |
.................... }
|
|
|
1313 |
.................... dira++; // zvets pocitadlo diry, aby to pristi cyklus tudy neslo
|
|
|
1314 |
03BD: INCF 6F,F
|
|
|
1315 |
.................... goto snimani; // co nejrychleji se vrat na snimani cary
|
|
|
1316 |
03BE: GOTO 327
|
|
|
1317 |
.................... }
|
|
|
1318 |
....................
|
|
|
1319 |
.................... /*if (MEZERA < dira++) // nejedeme uz moc dlouho bez cary??
|
|
|
1320 |
.................... {
|
|
|
1321 |
.................... dira=0;
|
|
|
1322 |
.................... switch(movement) // kam se jelo ??
|
|
|
1323 |
.................... {
|
|
|
1324 |
.................... case L:
|
|
|
1325 |
.................... BR; // couvej doprava
|
|
|
1326 |
.................... Delay_ms(COUVEJ);
|
|
|
1327 |
.................... movement=R;
|
|
|
1328 |
.................... break;
|
|
|
1329 |
.................... case R:
|
|
|
1330 |
.................... BL; // couvej doleva
|
|
|
1331 |
.................... Delay_ms(COUVEJ);
|
|
|
1332 |
.................... movement=L;
|
|
|
1333 |
.................... break;
|
|
|
1334 |
.................... }
|
|
|
1335 |
.................... STOP(); // konec couvani
|
|
|
1336 |
.................... FL; FR; // rovne pres diru
|
|
|
1337 |
.................... Delay_ms(PRES_DIRU);
|
|
|
1338 |
.................... STOP();
|
|
|
1339 |
.................... cik_cak(); // najdi caru
|
|
|
1340 |
.................... FR; FL; // vpred
|
|
|
1341 |
.................... } // dira*/
|
|
|
1342 |
....................
|
|
|
1343 |
.................... } // while(true)
|
|
|
1344 |
03BF: GOTO 327
|
|
|
1345 |
....................
|
|
|
1346 |
.................... }
|
|
|
1347 |
....................
|
|
|
1348 |
03C0: SLEEP
|
|
|
1349 |
.................... /*void objizdka()
|
|
|
1350 |
.................... {
|
|
|
1351 |
.................... BL; BR; // zacouvej
|
|
|
1352 |
.................... Delay_ms(150);
|
|
|
1353 |
.................... STOP();
|
|
|
1354 |
....................
|
|
|
1355 |
.................... cik_cak(); // vyrovnej se na caru
|
|
|
1356 |
.................... cik_cak(); // radeji 3x, aby se vyrovnaly setrvacne sily
|
|
|
1357 |
.................... cik_cak();
|
|
|
1358 |
....................
|
|
|
1359 |
.................... BL; FR; Delay_ms(220); // vlevo
|
|
|
1360 |
.................... STOP();
|
|
|
1361 |
.................... FL; FR; Delay_ms(650); // rovne
|
|
|
1362 |
.................... STOP();
|
|
|
1363 |
.................... FL; BR; Delay_ms(220); // vpravo
|
|
|
1364 |
.................... STOP();
|
|
|
1365 |
.................... FL; FR; Delay_ms(770); // rovne
|
|
|
1366 |
.................... STOP();
|
|
|
1367 |
.................... FL; BR; Delay_ms(210); // vpravo
|
|
|
1368 |
.................... STOP();
|
|
|
1369 |
.................... FL; FR;
|
|
|
1370 |
.................... Delay_ms(200); // kousek rovne
|
|
|
1371 |
.................... // rovne, dokud nenarazis na caru
|
|
|
1372 |
.................... while(input(RSENSOR)); // pravej senzor, protoze cihla je vpravo
|
|
|
1373 |
.................... STOP();
|
|
|
1374 |
.................... BL; FR; // toc se doleva, dokud nenarazis na caru
|
|
|
1375 |
.................... while(input(LSENSOR)); // levej senzor, protoze cara je urcite vlevo
|
|
|
1376 |
.................... STOP();
|
|
|
1377 |
.................... line=R; // caru predpokladame vpravo, kdybysme ji prejeli
|
|
|
1378 |
.................... dira=0;
|
|
|
1379 |
.................... FL; FR; // vpred
|
|
|
1380 |
.................... }*/
|
|
|
1381 |
....................
|