elektronik:beleuchtung
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
elektronik:beleuchtung [2009/04/16 19:27] – patrickbeck | elektronik:beleuchtung [2014/03/16 19:43] (aktuell) – patrickbeck | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== Beleuchtung ====== | ||
+ | |||
+ | Das Projekt " | ||
+ | |||
+ | Die Hardware wurde in zwei Modulen geplant. Die Basisplatine mit allen Steuerungsaufgaben, | ||
+ | |||
+ | Als Programmiersprache wurde Bascom Basic gewählt. Das angehängte Programm fadet alle Grundfarben, | ||
+ | |||
+ | Ist es von Anfang an beabsichtigt das alle vier LEDs das gleiche Programm ablaufen lassen sollen, so kann die Hardware natürlich dementsprechend vereinfacht werden. | ||
+ | |||
+ | ===== Schaltplan ===== | ||
+ | |||
+ | Der Schaltplan wurde mit Eagle entworfen | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Hier noch die Eagle-Datei | ||
+ | {{: | ||
+ | |||
+ | Die Basisplatine wurde frei auf einer Punktrasterplatine aufgebaut. Für die Leucht-Module habe ich mir dagegen ein kleines Layout überlegt. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===== Bascom-Programm ===== | ||
+ | |||
+ | < | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | 'of a ATMEL AVR Mega8 microcontroller. | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | $regfile = " | ||
+ | $framesize = 60 | ||
+ | $hwstack = 40 | ||
+ | $swstack = 32 | ||
+ | |||
+ | $crystal = 8000000 | ||
+ | |||
+ | Ddrb = & | ||
+ | Ddrc = & | ||
+ | Ddrd = & | ||
+ | |||
+ | Config Timer0 = Timer , Prescale = 1 ' fading timer | ||
+ | On Timer0 Fadingroutine | ||
+ | |||
+ | Enable Interrupts | ||
+ | Enable Timer0 | ||
+ | |||
+ | Red1 Alias Portd.7 | ||
+ | Green1 Alias Portd.6 | ||
+ | Blue1 Alias Portd.5 | ||
+ | |||
+ | Red2 Alias Portd.4 | ||
+ | Green2 Alias Portd.3 | ||
+ | Blue2 Alias Portd.2 | ||
+ | |||
+ | Red3 Alias Portd.1 | ||
+ | Green3 Alias Portd.0 | ||
+ | Blue3 Alias Portc.3 | ||
+ | |||
+ | Red4 Alias Portc.2 | ||
+ | Green4 Alias Portc.1 | ||
+ | Blue4 Alias Portc.0 | ||
+ | |||
+ | Commonanode Alias Portb.0 | ||
+ | |||
+ | |||
+ | Dim Dimm As Byte ' | ||
+ | Dim Reddim As Byte | ||
+ | Dim Greendim As Byte | ||
+ | Dim Bluedim As Byte | ||
+ | |||
+ | Dim Colourcounter As Byte | ||
+ | Dim Light As Byte | ||
+ | |||
+ | Dim Fade As Byte | ||
+ | Dim Up As Byte | ||
+ | Dim Down As Byte | ||
+ | |||
+ | Dimm = 0 ' startvalues | ||
+ | Fade = 0 ' the variables dimm, fade are for the fadding effect | ||
+ | Light = 0 ' | ||
+ | Colourcounter = 0 ' | ||
+ | |||
+ | Up = 0 ' indicates that the variable fade will be count up | ||
+ | Down = 0 ' indicates that the variable fade will be count down | ||
+ | |||
+ | Do | ||
+ | |||
+ | ' | ||
+ | |||
+ | If Fade = 0 Then | ||
+ | Down = 0 | ||
+ | Up = 1 | ||
+ | End If | ||
+ | |||
+ | If Fade = 255 Then | ||
+ | Up = 0 | ||
+ | Down = 1 | ||
+ | End If | ||
+ | ' | ||
+ | If Up = 1 Then | ||
+ | Incr Fade | ||
+ | | ||
+ | |||
+ | End If | ||
+ | |||
+ | If Down = 1 Then ' out fading | ||
+ | Decr Fade | ||
+ | | ||
+ | |||
+ | End If | ||
+ | |||
+ | ' | ||
+ | |||
+ | Reddim = Lookup(colourcounter , Redtable) | ||
+ | Greendim = Lookup(colourcounter , Greentable) | ||
+ | Bluedim = Lookup(colourcounter , Bluetable) | ||
+ | |||
+ | If Light < Reddim Then ' when the variable light is smaller than reddim then switch all red leds on | ||
+ | Red1 = 1 | ||
+ | Red2 = 1 | ||
+ | Red3 = 1 | ||
+ | Red4 = 1 | ||
+ | Else ' when its bigger then reddim, all leds off | ||
+ | Red1 = 0 | ||
+ | Red2 = 0 | ||
+ | Red3 = 0 | ||
+ | Red4 = 0 | ||
+ | End If | ||
+ | |||
+ | If Light < Greendim Then | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | Else | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | End If | ||
+ | |||
+ | If Light < Bluedim Then | ||
+ | Blue1 = 1 | ||
+ | Blue2 = 1 | ||
+ | Blue3 = 1 | ||
+ | Blue4 = 1 | ||
+ | Else | ||
+ | Blue1 = 0 | ||
+ | Blue2 = 0 | ||
+ | Blue3 = 0 | ||
+ | Blue4 = 0 | ||
+ | End If | ||
+ | |||
+ | Incr Light ' increase the variable light with one | ||
+ | |||
+ | If Light = 255 Then ' | ||
+ | Light = 0 | ||
+ | End If | ||
+ | |||
+ | If Fade = 0 Then ' change the colour when all leds off - not between a fading | ||
+ | Incr Colourcounter | ||
+ | End If | ||
+ | ' | ||
+ | If Colourcounter = 7 Then | ||
+ | | ||
+ | End If | ||
+ | |||
+ | Loop | ||
+ | End | ||
+ | |||
+ | 'RGB table with colours - one table for each color | ||
+ | Redtable: | ||
+ | Data 255 , 255 , 255 , 255 , 0 , 0 , 0 , | ||
+ | Greentable: | ||
+ | Data 255 , 0 , 0 , 255 , 255 , 255 , 0 , | ||
+ | Bluetable: | ||
+ | Data 255 , 255 , 0 , 0 , 0 , 255 , 255 , | ||
+ | |||
+ | |||
+ | Fadingroutine: | ||
+ | If Dimm < Fade Then ' when dimm smaller than fade switch the commonanode off - leds off | ||
+ | Commonanode = 0 | ||
+ | Else | ||
+ | Commonanode = 1 ' | ||
+ | End If | ||
+ | |||
+ | Incr Dimm | ||
+ | |||
+ | If Dimm = 255 Then | ||
+ | Dimm = 0 | ||
+ | End If | ||
+ | Return | ||
+ | </ | ||
+ | |||
+ | Hex-File zum direkten flashen {{: | ||
+ | |||
+ | ===== Bilder ===== | ||
+ | |||
+ | ==== Platine ==== | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | |||
+ | ==== Endergebnis ==== | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | {{: | ||
+ | |||