Hallo liebe Mikrocontroller-Gemeinde,
Ich habe im Studium ein kleines bisschen über Mikrocontroller und
embedded Systems gelernt und wollte nun mein Wissen anwenden:
Ich bin begeisterter Geocacher und wollte nun mit Freunden einen
Nachtcache legen. Als eine Station wollten wir ein Nachtaktives
Reaktivlicht setzen. Weil ich schon mal was von Microcontrollern gehört
hab, hab ich die Aufgabe übernommen und stehe jetzt vor nem kleinen
Problem.
Mein kleines Reativlicht soll auf eine Fernbedinung reagieren und als
Ausgabe den neuen Waypoint in Form eines Morsecodes ausgeben.
Die Schaltung habe ich soweit gelötet und sollte auch so funktionieren.
Ich verwende einen ATMega8-16DIP mit TSOP1738 und normalen LEDs als
ausgabe.
Ich programmiere mit micropascal for AVR Pro.
Mein Programmcode sieht so aus
1 | program geo;
|
2 |
|
3 |
|
4 | { Declarations section }
|
5 |
|
6 |
|
7 |
|
8 | { Declarations section }
|
9 |
|
10 |
|
11 | // Hauptprogramm (Main)
|
12 |
|
13 | var incoming_IR_yes : boolean ;
|
14 |
|
15 | // Ausgabe auf die LED´s
|
16 | procedure Ausgabe ;
|
17 | //var ;
|
18 | begin
|
19 |
|
20 | PORTB.B5 := 0x00 ;
|
21 | Delay_ms (3000) ;
|
22 | PORTB.B3 := 0x00 ;
|
23 |
|
24 |
|
25 | end;
|
26 |
|
27 |
|
28 | //Hauptschleife für Abfrage Infrarot
|
29 |
|
30 | procedure Abfrage_infrarot_eingang ; // oder alles als function
|
31 | var i : integer ;
|
32 |
|
33 |
|
34 | begin
|
35 |
|
36 |
|
37 | PORTC := 0x00 ; //alles aus auf port c einga infrarot
|
38 | PORTB := 0xff ; //alles aus auf port b
|
39 |
|
40 | PORTB.B5 := 0x00 ; //rot an
|
41 | Delay_ms (1000) ; //pause
|
42 | PORTB.B5 := 0x01 ; //rot aus
|
43 | Delay_ms (1000) ; //pause
|
44 | PORTB.B5 := 0x00 ; //rot an
|
45 | Delay_ms (1000) ; //pause
|
46 | PORTB.B5 := 0x01 ; //rot aus
|
47 | Delay_ms (1000) ; //pause
|
48 | PORTB.B5 := 0x00 ; //rot an
|
49 | Delay_ms (1000) ; //pause
|
50 | PORTB.B5 := 0x01 ; //rot aus
|
51 |
|
52 | {while PORTC.B3 <> 0x00 do // unendlich schleife start
|
53 | begin
|
54 |
|
55 |
|
56 |
|
57 | // if PORTC.B3 <> 0x01 then Ausgabe //else
|
58 | {begin // oder ne braek und er läuft weiter in die nächste function weiß noch nciht genau ob das funst
|
59 | Delay_ms (100) ; //mit dem delay müssen wir noch mal spielen bzw rechnen weil einmal in der gesamt signallaufzeit reicht mussen ja nur eine 1 erwischen um auzulösen
|
60 | PORTB.B1 := 0x00 ;
|
61 | Delay_ms (100) ;
|
62 | PORTB.B1 := 0x01 ;
|
63 | Delay_ms (100) ;
|
64 |
|
65 | PORTB.B3 := 0x00 ;
|
66 | Delay_ms (100) ;
|
67 | PORTB.B3 := 0x01 ;
|
68 | Delay_ms (100) ;
|
69 |
|
70 | PORTB.B5 := 0x00 ;
|
71 | Delay_ms (100) ;
|
72 | PORTB.B5 := 0x01 ;
|
73 | end;
|
74 | delay_ms (10)
|
75 | end;} // unendlich schleife ende
|
76 |
|
77 | i := 0 ;
|
78 | while i <> 0 do
|
79 | begin
|
80 | i := PORTC.B3 ;
|
81 | i := sbit at PORTC.B3;
|
82 |
|
83 | end;
|
84 | Ausgabe;
|
85 |
|
86 | end;
|
87 |
|
88 |
|
89 |
|
90 | begin
|
91 | DDRC := 0x00 ; //port auf eingang
|
92 | DDRB := 0xff ; //port auf ausgang
|
93 | PORTB := 0xff ; //alle ausgaänge port b aus
|
94 | Delay_ms (3000) ;
|
95 |
|
96 | incoming_IR_yes := false;
|
97 | PORTB.B5 := 0x00 ; //dide 1 an an is 0x00
|
98 | PORTB.B3 := 0x00 ;
|
99 | PORTB.B1 := 0x00 ;
|
100 | Delay_ms (500) ;
|
101 | PORTB.B5 := 0x01 ; //diode aus aus is 0x01
|
102 | PORTB.B3 := 0x01 ;
|
103 | PORTB.B1 := 0x01 ;
|
104 | Delay_ms (2500) ;
|
105 |
|
106 |
|
107 |
|
108 | Abfrage_infrarot_eingang;
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | end.
|
Problem ist nun, dass wenn ich auf den Eingang PortB.B3 eine 1 setze,
wird die Ausgabeprozedur nicht aufgerufen.
Ich hab das erstmal am SKT500 ausprobiert? hat jemand eine Idee,
Ich bin schon ziemlich ratlos, daher auch die vielen auskommentierten
Codestückchen...
Vielen Dank im Vorraus