1 | '-------------------------------------------------------------------------------
|
2 | ' Filename : 433MHZ Code Sender
|
3 | ' Purpose : Funk Steckdosen Control Transmitter
|
4 | ' Author : Volker Vogeley
|
5 | ' Controller : ATMEGA16
|
6 | ' Compiler : BASCOM-AVR Rev. 1.11.9.3
|
7 | '--------------------------------------------------------------
|
8 | ' Free only for non comercial use !!!
|
9 | ' For commercial use contact development.nospam@web.de
|
10 | '--------------------------------------------------------------
|
11 |
|
12 | '-------------------------------------------------------------------------------
|
13 | ' Testaufbau auf Pollin
|
14 | ' ATMEL Evaluations-Board V2.0.1 mit Atmega 16
|
15 | ' und Funkset Flamingo (optisch wie http://avr.börke.de/Funksteckdosen.htm)
|
16 | ' Auch Geignet :
|
17 | ' Pollin Funk-Steckdosenset 2605 (und gleiche gibts in den Baumärkten)
|
18 | '
|
19 | '-------------------------------------------------------------------------------
|
20 | '
|
21 | $regfile "m88def.dat"
|
22 | $framesize = 32
|
23 | $swstack = 64 'Muss 64 seirn i:egen den Vielen 3pr "lagen der Unterprc_sran,n•.ei, da sonst nichts au" '_ den Display angezeigt wird
|
24 | $hwstack = 64 'Muss 64 sein (Wegen den vielen Sur.':uqen der Untsrprogramme), da sonst nichts auf den Di5play ar.geze_gt wird
|
25 | $crystal = 16000000
|
26 | $baud = 9600
|
27 |
|
28 | 'Uart Anfang
|
29 | On Urxc Onrxd
|
30 | Enable Urxc
|
31 | Enable Interrupts
|
32 | Dim Ret_uart As Word
|
33 |
|
34 | Dim Uart_buffer As String * 100
|
35 | Dim Uart_buffer_excute As String * 100
|
36 | Dim Excute_uart_buffer As Bit
|
37 | 'Uart Ende
|
38 |
|
39 | '##########################################
|
40 | Const Fdelay = 345 ' 345 funktioniert
|
41 | Dim I As Byte
|
42 | Dim X As Byte
|
43 | Dim Funk_repeat As Byte
|
44 | Funk_repeat = 10
|
45 | Dim Funkcode_complete As String * 12
|
46 | Dim One_str As String * 1
|
47 |
|
48 |
|
49 | Const Dose_ein = "0F"
|
50 | Const Dose_aus = "F0"
|
51 | Dim Systemcode As String * 5
|
52 | Dim Steckdose As String * 5
|
53 | Systemcode = "0FF0F" 'Wenn auf dem Sender der DIP auf ON ist eine 0 ansosnten ein F
|
54 | Steckdose = "F0FFF" 'Wenn der der Pin der Steckdose auf on ist dann eine 0 setzen ansonsten ein F
|
55 |
|
56 | '#########################################
|
57 |
|
58 | Config Portd.4 = Input 'Taster 3
|
59 | Config Portd.3 = Input 'Taster 2
|
60 | Config Portd.2 = Input 'Taster 1
|
61 |
|
62 | Config Portd.5 = Output
|
63 | Led1 Alias Portd.5 'LED 1
|
64 | Config Portd.6 = Output
|
65 | Led2 Alias Portd.6 'LED 2
|
66 |
|
67 | Config Portc.0 = Output
|
68 | Funkpin Alias Portc.0 'geht an die Rosa Leitung des Senders (signal) dann nur Masse Atmega mit Masse Handsender verbinden
|
69 | Funkcode_complete = ""
|
70 |
|
71 | '========= Anfang Hauptprogramm =========
|
72 | Do
|
73 |
|
74 | If Excute_uart_buffer = 1 Then
|
75 | Print
|
76 | Print "uart_buffer_excute: " ; Uart_buffer_excute
|
77 | Print
|
78 |
|
79 | Select Case Uart_buffer_excute
|
80 | Case "10"
|
81 | Funkcode_complete = Systemcode + "0FFFFF0"
|
82 | Case "11"
|
83 | Funkcode_complete = Systemcode + "0FFFF0F"
|
84 |
|
85 | Case "20"
|
86 | Funkcode_complete = Systemcode + "F0FFFF0"
|
87 | Case "21"
|
88 | Funkcode_complete = Systemcode + "F0FFF0F"
|
89 |
|
90 | Case "30"
|
91 | Funkcode_complete = Systemcode + "FF0FFF0"
|
92 | Case "31"
|
93 | Funkcode_complete = Systemcode + "FF0FF0F"
|
94 |
|
95 | Case "50"
|
96 | Funkcode_complete = Systemcode + "FFFF0F0"
|
97 | Case "51"
|
98 | Funkcode_complete = Systemcode + "FFFF00F"
|
99 |
|
100 | Case "60"
|
101 | Funkcode_complete = Systemcode + "00FFFF0"
|
102 | Case "61"
|
103 | Funkcode_complete = Systemcode + "00FFF0F"
|
104 |
|
105 | Case "70"
|
106 | Funkcode_complete = Systemcode + "FFF00F0"
|
107 | Case "71"
|
108 | Funkcode_complete = Systemcode + "FFF000F"
|
109 |
|
110 | Case "a1"
|
111 | Funkcode_complete = "000FFF0FFFF0"
|
112 | Case "a1"
|
113 | Funkcode_complete = "000FFF0FFF0F"
|
114 |
|
115 | Case "b1"
|
116 | Funkcode_complete = "000FFFF0FFF0"
|
117 | Case "b0"
|
118 | Funkcode_complete = "000FFFF0FF0F"
|
119 |
|
120 | Case "c1"
|
121 | Funkcode_complete = "000FFFFF0FF0"
|
122 | Case "C1"
|
123 | Funkcode_complete = "000FFFFF0F0F"
|
124 |
|
125 | Case "d1"
|
126 | Funkcode_complete = "000FFFFFF0F0"
|
127 | Case "d0"
|
128 | Funkcode_complete = "000FFFFFF00F"
|
129 |
|
130 | Case Else
|
131 | Uart_buffer_excute = "keinen"
|
132 | Funkcode_complete = "Nicht Def."
|
133 |
|
134 | End Select
|
135 | Print "Sende " ; Uart_buffer_excute ; " Code : " ; Funkcode_complete
|
136 | Gosub Sendecodes
|
137 | Uart_buffer_excute = "" ' Inhalt von Buffer loeschen
|
138 | Excute_uart_buffer = 0 'nicht mehr ausführen
|
139 | End If
|
140 |
|
141 |
|
142 |
|
143 | If Pind.2 = 1 Then ' Ein schalten
|
144 | Funkcode_complete = Systemcode + Steckdose + Dose_ein
|
145 | Print "Sende EIN Code: " ; Funkcode_complete
|
146 | Gosub Sendecodes
|
147 | Bitwait Pind.2 , Reset
|
148 | End If
|
149 |
|
150 | If Pind.3 = 1 Then ' Aus schalten
|
151 | Funkcode_complete = Systemcode + Steckdose + Dose_aus
|
152 | Print "Sende AUS Code: " ; Funkcode_complete
|
153 | Gosub Sendecodes
|
154 | Bitwait Pind.3 , Reset
|
155 | End If
|
156 |
|
157 |
|
158 | If Pind.4 = 1 Then
|
159 | Print "Toggle PIND.4: " ; Pind.4 ' Aus schalten
|
160 | Toggle Funkpin
|
161 | Bitwait Pind.4 , Reset
|
162 |
|
163 | Waitms 200
|
164 | End If
|
165 |
|
166 |
|
167 | Toggle Led2
|
168 |
|
169 |
|
170 | Loop
|
171 | End
|
172 | '======== Ende HauptProgramm =============
|
173 | Sendecodes:
|
174 | Led1 = 1
|
175 | For I = 1 To Funk_repeat
|
176 | For X = 1 To 12
|
177 | 'Toggle Portd.6
|
178 | One_str = Mid(funkcode_complete , X , 1)
|
179 | Select Case One_str
|
180 | Case "0"
|
181 | Gosub Sende_null
|
182 | Case "F"
|
183 | Gosub Sende_float
|
184 | Case "1"
|
185 | Gosub Sende_eins
|
186 | End Select
|
187 | Next X
|
188 | Gosub Sende_sync
|
189 | Next I
|
190 | Led1 = 0
|
191 | Return
|
192 |
|
193 |
|
194 |
|
195 | Sende_float:
|
196 | Funkpin = 1
|
197 | Waitus Fdelay
|
198 | Funkpin = 0
|
199 | Waitus Fdelay
|
200 | 'Funkpin = 0
|
201 | Waitus Fdelay
|
202 | 'Funkpin = 0
|
203 | Waitus Fdelay
|
204 | ' die nächsten 4 tasks
|
205 | Funkpin = 1
|
206 | Waitus Fdelay
|
207 | 'Funkpin = 1
|
208 | Waitus Fdelay
|
209 | 'Funkpin = 1
|
210 | Waitus Fdelay
|
211 | Funkpin = 0
|
212 | Waitus Fdelay
|
213 | Return
|
214 |
|
215 |
|
216 | Sende_null:
|
217 | Funkpin = 1
|
218 | Waitus Fdelay
|
219 | Funkpin = 0
|
220 | Waitus Fdelay
|
221 | 'Funkpin = 0
|
222 | Waitus Fdelay
|
223 | 'Funkpin = 0
|
224 | Waitus Fdelay
|
225 | ' die nächsten 4 tasks
|
226 | Funkpin = 1
|
227 | Waitus Fdelay
|
228 | Funkpin = 0
|
229 | Waitus Fdelay
|
230 | 'Funkpin = 0
|
231 | Waitus Fdelay
|
232 | 'Funkpin = 0
|
233 | Waitus Fdelay
|
234 | Return
|
235 |
|
236 |
|
237 | Sende_sync:
|
238 | 'laenge gesamt 32 Takte
|
239 | Funkpin = 1
|
240 | Waitus Fdelay
|
241 | Funkpin = 0
|
242 | Waitus Fdelay
|
243 | Waitus Fdelay
|
244 | Waitus Fdelay
|
245 | Waitus Fdelay
|
246 | Waitus Fdelay
|
247 | Waitus Fdelay
|
248 | Waitus Fdelay
|
249 | Waitus Fdelay
|
250 | Waitus Fdelay
|
251 | Waitus Fdelay
|
252 | Waitus Fdelay
|
253 | Waitus Fdelay
|
254 | Waitus Fdelay
|
255 | Waitus Fdelay
|
256 | Waitus Fdelay
|
257 | Waitus Fdelay
|
258 | Waitus Fdelay
|
259 | Waitus Fdelay
|
260 | Waitus Fdelay
|
261 | Waitus Fdelay
|
262 | Waitus Fdelay
|
263 | Waitus Fdelay
|
264 | Waitus Fdelay
|
265 | Waitus Fdelay
|
266 | Waitus Fdelay
|
267 | Waitus Fdelay
|
268 | Waitus Fdelay
|
269 | Waitus Fdelay
|
270 | Waitus Fdelay
|
271 | Waitus Fdelay
|
272 | Waitus Fdelay
|
273 | Return
|
274 |
|
275 | Sende_eins:
|
276 | Funkpin = 1
|
277 | Waitus Fdelay
|
278 | Funkpin = 1
|
279 | Waitus Fdelay
|
280 | Funkpin = 1
|
281 | Waitus Fdelay
|
282 | Funkpin = 0
|
283 | Waitus Fdelay
|
284 | ' die nächsten 4 tasks
|
285 | Funkpin = 1
|
286 | Waitus Fdelay
|
287 | Funkpin = 1
|
288 | Waitus Fdelay
|
289 | Funkpin = 1
|
290 | Waitus Fdelay
|
291 | Funkpin = 0
|
292 | Waitus Fdelay
|
293 | Return
|
294 |
|
295 | Onrxd:
|
296 | Ret_uart = Udr
|
297 | If Ret_uart = 13 Then
|
298 | Excute_uart_buffer = 1
|
299 | Uart_buffer_excute = Uart_buffer
|
300 | Print "uart_buffer_excute: " ; Uart_buffer_excute
|
301 | Uart_buffer = ""
|
302 |
|
303 | Else
|
304 | Print "Uart_buffer: " ; Uart_buffer ; " ret_Uart: " ; Ret_uart ; " / " ; Chr(ret_uart)
|
305 | Uart_buffer = Uart_buffer + Chr(ret_ Uart)
|
306 | Print "Uart_Buffer: " ; Uart_buffer
|
307 | End If
|
308 |
|
309 | 'If Len(uart_buffer) = 4 Then
|
310 | 'Uart_buffer_excute = Uart_buffer
|
311 |
|
312 | 'Uart_buffer = ""
|
313 | 'End If
|
314 |
|
315 |
|
316 | Return
|