1 | 'Anschlussbelegung des Tiny13:
|
2 |
|
3 | 'Pin 1: Reset, Widerstand 10k nach Pin 8 (VCC)
|
4 | 'Pin 2: PB3, ADC-Eingang ADC3, Messeingang
|
5 | 'Pin 3: PB4, ADC-Eingang ADC2, Messeingang
|
6 | 'Pin 4: GND, Masse
|
7 | 'Pin 5: PB0, LED für "Gut-Meldung", 5,0V
|
8 | 'Pin 6: PB1, LED für "Gut-Meldung", Kabel OK
|
9 | 'Pin 7: PB2, ADC-Eingang ADC1, Messeingang
|
10 | 'Pin 8: VCC, Versorgungsspannung
|
11 |
|
12 |
|
13 | $regfile = "attiny13.dat"
|
14 | $crystal = 9600000
|
15 | $hwstack = 16
|
16 | $swstack = 16
|
17 | $framesize = 16
|
18 |
|
19 | Config Portb.0 = Output ' LED grün = 5,0 V
|
20 | Config Portb.1 = Output ' LED grün = Kabel OK
|
21 |
|
22 |
|
23 | Dim W As Word
|
24 | Dim U As Word
|
25 | Dim V As Word
|
26 |
|
27 |
|
28 | Config Adc = Single , Prescaler = Auto , Reference = Avcc
|
29 |
|
30 | Do
|
31 | Start Adc
|
32 |
|
33 | W = Getadc(1) ' messen des Analogwertes
|
34 | U = Getadc(2) ' messen des Analogwertes
|
35 | V = Getadc(3) ' messen des Analogwertes
|
36 |
|
37 | Stop Adc
|
38 |
|
39 | 'Widerstandsschleifen Messung an 2 Punkten
|
40 | 'Wenn die Spannung am ADC 2 mit einer Hysterese
|
41 | 'von 200mV zwischen 3,9V und 4,1V beträgt und
|
42 | 'am ADC 3 mit einer Hysterese von 200mV
|
43 | 'zwischen 1,9V und 2,1V beträgt, dann
|
44 | 'soll eine LED an Portb.0 leuchten.
|
45 |
|
46 |
|
47 | If U > 840 Then 'Spannung > 4,1 V
|
48 | Portb.0 = 0
|
49 | End If
|
50 |
|
51 | If V > 430 Then 'Spannung > 2,1 V
|
52 | Portb.0 = 0
|
53 | End If
|
54 |
|
55 | If U < 840 And U > 799 And V < 430 And V > 389 Then 'Spannungsprüfung
|
56 | Portb.0 = 1
|
57 | End If
|
58 |
|
59 | If U < 799 Then 'Spannung < 3,9V
|
60 | Portb.0 = 0
|
61 | End If
|
62 |
|
63 | If V < 389 Then 'Spannung < 1,9V
|
64 | Portb.0 = 0
|
65 | End If
|
66 |
|
67 | If W > 251 Then ' Spannung > 5,1 V
|
68 | Portb.1 = 0
|
69 | End If
|
70 |
|
71 | If W < 251 And W > 243 Then ' Spannung 4,9 - 5,1 V
|
72 | Portb.1 = 1
|
73 | End If
|
74 |
|
75 | If W < 243 Then ' Spannung < 4,9V
|
76 | Portb.1 = 0
|
77 | End If
|
78 |
|
79 |
|
80 | 'If Portb.0 = 1 And Portb.1 = 1 Then
|
81 |
|
82 | '3x schnelles Piepen , wenn Bedingung erfüllt
|
83 | 'bis zur nächsten Prüfung an Portb.0 oder
|
84 | 'Portb.1 oder aktivieren von Portb.5
|
85 |
|
86 | 'End If
|
87 |
|
88 | Loop
|
89 |
|
90 | End
|