1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 $regfile = "m32def.dat"
20 $crystal = 8000000
21 $baud = 4800
22
23
24
25
26
27
28
29
30 Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
31 $timeout = 1000000
32
33
34
35 Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.1 , Rs = Portc.0
36 Config Lcd = 20 * 4 , Chipset = Ks077
37
38 Config Lcdbus = 4
39 Cursor Off Noblink
40
41 Config Porta = Output
42 Config Portb = Input
43
44 Config Timer1 = Timer , Prescale = 8
45
46
47 Enable Interrupts
48
49
50
51
52
53
54
55
56 Dim Laenge1 As Single
57 Dim Laenge2 As Single
58 Dim Laenge3 As Single
59 Dim Laenge1_hoch2 As Single
60 Dim Laenge2_hoch2 As Single
61 Dim Laenge3_hoch2 As Single
62
63 Dim X_mic As Single
64 Dim Y_mic As Single
65 Dim Z_mic As Single
66 Dim X_mic_hoch2 As Single
67 Dim Y_mic_hoch2 As Single
68
69 Dim X_abstand As Single
70 Dim Y_abstand As Single
71 Dim Z_abstand As Single
72 Dim X_abstand_hoch2 As Single
73 Dim Y_abstand_hoch2 As Single
74
75
76 Dim S As Single
77 Dim A As Single
78
79 Dim Dreieckshoehe As Single
80 Dim Dreieckshoehe_hoch2 As Single
81
82 Dim Klammer1 As Single
83 Dim Klammer2 As Single
84 Dim Klammer3 As Single
85 Dim Klammer4 As Single
86
87 Dim Timera As Long
88 Dim Timerb As Long
89 Dim Timerc As Long
90
91 Dim Lautsprecher As Byte
92
93
94
95
96
97
98
99
100 Dim Offset As Single
101 Dim Faktor As Single
102
103 Dim Gpgga$ As String * 100
104 Dim Gprmc$ As String * 100
105
106 Dim Check As Byte
107
108 Dim Hexx$ As String * 2
109
110
111 Dim A$ As String * 1
112 Dim Laenge As Single
113 Dim Breite As Single
114 Dim Laenge_faktor As Single
115 Dim Breite_faktor As Single
116
117 Dim Laengeplus As Single
118 Dim Breiteplus As Single
119 Dim Zeit As Long
120 Dim X As Byte
121 Dim Poti1 As Word
122 Dim Poti2 As Word
123 Dim Kurs As Word
124 Dim Speed As Word
125 Dim X$ As String * 10
126
127
128
129
130 Zeit = 0
131 Breite = 5230.48
132 Laenge = 1320.7
133
134 Breite_faktor = 0.72
135 Laenge_faktor = 2.4
136
137
138
139
140 Offset = 474
141 Faktor = 2907
142
143 Z_abstand = 0.600
144 X_abstand = 0.780
145 Y_abstand = 1.560
146
147
148
149
150
151 Cls
152
153 Locate 1 , 1
154 Lcd " Ruhr-Universit" ; Chr(123) ; "t"
155 Locate 3 , 1
156 Lcd " Bochum"
157 Locate 2 , 1
158 Lcd "Fachdidaktik Physik"
159 Locate 4 , 1
160 Lcd " GPS-Simulator"
161 Wait 3
162
163
164
165
166
167 On Int0 Zeitstop1
168
169
170
171 Anfang:
172
173
174 Lautsprecher = 1
175 Start Timer1
176 Timer1 = 0
177 Enable Int0
178 Pulseout Porta , Lautsprecher , 500
179 Waitms 500
180
181 Lautsprecher = 2
182 Start Timer1
183 Timer1 = 0
184 Enable Int0
185 Pulseout Porta , Lautsprecher , 500
186 Waitms 500
187
188 Lautsprecher = 3
189 Start Timer1
190 Timer1 = 0
191 Enable Int0
192 Pulseout Porta , Lautsprecher , 500
193
194
195
196
197
198 If Laenge1 = 0 Then Goto Fehler
199 If Laenge2 = 0 Then Goto Fehler
200 If Laenge3 = 0 Then Goto Fehler
201
202 If Laenge1 > 10 Then Goto Fehler
203 If Laenge2 > 10 Then Goto Fehler
204 If Laenge3 > 10 Then Goto Fehler
205
206
207
208 Laenge1_hoch2 = Laenge1 ^ 2
209 Laenge2_hoch2 = Laenge2 ^ 2
210 Laenge3_hoch2 = Laenge3 ^ 2
211
212 X_abstand_hoch2 = X_abstand ^ 2
213 Y_abstand_hoch2 = Y_abstand ^ 2
214
215
216
217
218
219
220 X_mic = X_abstand_hoch2 - Laenge1_hoch2
221 X_mic = X_mic + Laenge2_hoch2
222 X_mic = X_mic / 2
223 X_mic = X_mic / X_abstand
224
225
226
227
228
229
230
231
232 A = Y_abstand_hoch2 - Laenge3_hoch2
233 A = A + Laenge2_hoch2
234 A = A / 2
235 Y_mic = A / Y_abstand
236
237
238
239
240
241
242 X_mic_hoch2 = X_mic ^ 2
243 Y_mic_hoch2 = Y_mic ^ 2
244
245 A = Laenge2_hoch2 - X_mic_hoch2
246 A = A - X_mic_hoch2
247 A = A - Y_mic_hoch2
248 Z_mic = Sqr(a)
249 Z_mic = Z_abstand - Z_mic
250
251
252
253
254
255
256
257
258
259
260
261 Cls
262
263 Locate 1 , 1
264
265 Lcd "X=" ; Fusing(x_mic , "#.###") ; "m"
266
267
268
269
270 Locate 3 , 1
271
272 Lcd "Y=" ; Fusing(y_mic , "#.###") ; "m"
273
274
275
276 Locate 2 , 1
277
278 Lcd "Z=" ; Fusing(z_mic , "#.###") ; "m"
279
280
281
282 Locate 1 , 12
283
284 Lcd "L1=" ; Fusing(laenge1 , "#.###") ; "m"
285
286
287
288
289 Locate 3 , 24
290
291 Lcd "L2=" ; Fusing(laenge2 , "#.###") ; "m"
292
293
294
295 Locate 2 , 12
296
297 Lcd "L3=" ; Fusing(laenge3 , "#.###") ; "m"
298
299
300 Locate 4 , 1
301
302 Lcd "T=" ; Timera ; "/" ; Timerb ; "/" ; Timerc
303
304
305
306
307
308
309
310
311
312
313
314 Gps_mouse:
315
316
317 Y_mic = Y_mic / Y_abstand
318 X_mic = X_mic / X_abstand
319
320 X_mic = 1 - X_mic
321
322 Y_mic = Y_mic * Laenge_faktor
323 X_mic = X_mic * Breite_faktor
324
325
326 Y_mic = Y_mic + Laenge
327 X_mic = X_mic + Breite
328
329 Gpgga$ = "GPGGA," + Str(zeit) + ".000," + Str(x_mic) + ",N," + Str(y_mic) + ",E,1, 9,1.0, 142.1,M,47.5,M,,0000"
330 Gprmc$ = "GPRMC," + Str(zeit) + ".000,A," + Str(x_mic) + ",N," + Str(y_mic) + ",E," + Str(speed) + "," + Str(kurs) + ",291206,,,A"
331
332 Check = 0
333 For X = 1 To Len(gpgga$)
334 A$ = Mid(gpgga$ , X , 1)
335 Check = Check Xor Asc(a$)
336 Next
337 Hexx$ = Hex(check)
338 Print "$" ; Gpgga$ ; "*" ; Hexx$
339
340
341 Check = 0
342 For X = 1 To Len(gprmc$)
343 A$ = Mid(gprmc$ , X , 1)
344 Check = Check Xor Asc(a$)
345 Next
346 Hexx$ = Hex(check)
347 Print "$" ; Gprmc$ ; "*" ; Hexx$
348
349 Zeit = Zeit + 1
350
351 If Zeit = 1 Then Print "$GPGSA,A,3,30,25,24,31,06,21,07,16,10,,,,2.0,1.0,1.7*33"
352 If Zeit = 1 Then Print "$GPGSV,3,1,11,07,79,069,36,06,59,074,40,21,48,169,45,31,42,224,36*70"
353 If Zeit = 1 Then Print "$GPGSV,3,2,11,25,42,240,31,16,39,298,36,30,26,128,39,10,18,054,31*7B"
354 If Zeit = 1 Then Print "$GPGSV,3,3,11,24,15,042,25,23,07,311,18,13,07,341,*45"
355 If Zeit >= 9 Then Zeit = 0
356
357
358
359
360
361 Waitms 500
362
363
364 Goto Anfang
365
366
367
368
369
370
371
372
373
374
375
376
377 Zeitstop1:
378 Stop Timer1
379 Disable Int0
380
381
382 Pulseout Porta , 0 , 500
383
384
385 If Lautsprecher = 1 Then
386 Timera = Timer1
387 Laenge1 = Timer1
388 Laenge1 = Laenge1 - Offset
389 Laenge1 = Laenge1 / Faktor
390 End If
391
392 If Lautsprecher = 2 Then
393 Timerb = Timer1
394 Laenge2 = Timer1
395 Laenge2 = Laenge2 - Offset
396 Laenge2 = Laenge2 / Faktor
397 End If
398
399 If Lautsprecher = 3 Then
400 Timerc = Timer1
401 Laenge3 = Timer1
402 Laenge3 = Laenge3 - Offset
403 Laenge3 = Laenge3 / Faktor
404 End If
405
406
407
408 Return
409 Return
410
411
412
413
414
415 Fehler:
416
417
418
419 Cls
420
421 Lcd "Fehler"
422 Wait 2
423
424 Goto Anfang
425
426
427 End