Hallo,
das mit den Dateianhängen hat nicht geklappt, die Dateiformate werden nicht akzeptiert, dann also als Bilder:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
'schrankenantrieb mit schrittmotor
'attiny2313 Lieferzustand, keine fuse-bits verändert
$regfile = "attiny2313.dat"
$crystal = 1000000
$hwstack = 38
$swstack = 10
$framesize = 32
'taster runter an portb.0
'taster hoch an portb.1
'taster stellen auf an portb.2
'taster stellen ab an portb.3
'rote led mit vorwiderstand an portb.4
'grüne led mit vorwiderstand an portb.5
'schrittmotor an portd.2 bis portd.5
Config Portb = &B11000011
Portb.2 = 1
Portb.3 = 1
Portb.4 = 1
Portb.5 = 1
Config Portd = Output
'timer0 für blinklicht andreaskreuze
Config Timer0 = Timer , Prescale = 1024
Timer0 = 158
On Timer0 Blinklicht
'Blinklicht erstmal aus
Disable Timer0
Enable Interrupts
'variablen definieren
Dim A As Byte
Dim B As Word
Dim C As Byte
Dim Marke As Byte
Dim E_marke As Eram Byte
'zahl der schritte, die der motor zwischen oben und unten zurücklegen soll
Const Ziel = 10500
'letzten zustand aus eprom lesen, falls schranke noch zu dann schranke auf
A = 1
Marke = E_marke
If Marke = 1 Then
Portb.0 = 1
Portb.1 = 0
Else
Gosub Heben
End If
Do
'schranke senken
If Pinb.3 = 0 Then Gosub Runter
'schranke heben
If Pinb.2 = 0 Then Gosub Hoch
'schrankenposition manuell nach oben verstellen
If Pinb.4 = 0 Then Gosub Aufstellen
'schrankenposition manuell nach unten verstellen
If Pinb.5 = 0 Then Gosub Abstellen
Loop
End
Drehen:
'Tabelle Halbschrittsteuerung
Select Case A
Case 1 : Portd = &B00000100
Case 2 : Portd = &B00001100
Case 3 : Portd = &B00001000
Case 4 : Portd = &B00011000
Case 5 : Portd = &B00010000
Case 6 : Portd = &B00110000
Case 7 : Portd = &B00100000
Case 8 : Portd = &B00100100
End Select
Return
Aufstellen:
'schranke um einen schritt nach oben
A = A + 1
If A = 9 Then A = 1
Gosub Drehen
Waitms 5
Portd = 0
Return
Abstellen:
'schranke um einen schritt nach unten
A = A - 1
If A = 0 Then A = 8
Gosub Drehen
Waitms 5
Portd = 0
Return
Runter:
'wenn schranke oben, dann senken, wenn schranke unten passiert nichts
If Marke = 1 Then
'blinklicht starten
Enable Timer0
'10sec warten
Wait 10
'schranke senken
Gosub Senken
End If
Return
Hoch:
'wenn schranke unten, dann heben, wenn schranke oben passiert nichts
If Marke = 0 Then
'schranke heben
Gosub Heben
'2sec warten
Wait 2
'blinklicht anhalten
Disable Timer0
'andreaskreuze aus
Portb.6 = 0
End If
Return
Heben:
'rote led im stellpult aus
Portb.1 = 0
'setzt portd.2 - portd.5 entsprechend der tabelle -> motor dreht
For B = 1 To Ziel Step 1
A = A - 1
If A = 0 Then A = 8
'hier wird die geschwindigkeit eingestellt, je höher der wert, desto
'kleiner die geschwindigkeit
Waitms 1
Gosub Drehen
'das ganze so oft, bis schranke oben ist
Next B
'grüne led im stellpult an
Portb.0 = 1
'aktuellen zustand in eprom schreiben
Marke = 1
E_marke = Marke
'schrittmotor aus
Portd = 0
Return
Senken:
'grüne led im stellpult aus
Portb.0 = 0
'wie beim heben, nur anders herum
For B = 1 To Ziel Step 1
A = A + 1
If A = 9 Then A = 1
Waitms 1
Gosub Drehen
Next B
'rote led im stellpult an
Portb.1 = 1
'aktuellen zustand in eprom schreiben
Marke = 0
E_marke = Marke
'schrittmotor aus
Portd = 0
Return
Blinklicht:
'timerinterruptroutine erzeugt blinken ca. 1Hz
Timer0 = 158
C = C + 1
If C = 5 Then
C = 1
Toggle Portb.6
End If
Return
Schönen Abend noch
Ulli