Benutzer-Werkzeuge

Webseiten-Werkzeuge


elektronik:beleuchtung

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
elektronik:beleuchtung [2009/04/16 19:27] patrickbeckelektronik:beleuchtung [2014/03/16 19:43] (aktuell) patrickbeck
Zeile 1: Zeile 1:
 +====== Beleuchtung ======
 +
 +Das Projekt "Beleuchtung" war eigentlich dazu gedacht ein Wandbild zu beleuchten. Mangels Interesse  wurde es zur Tischbeleuchtung umfunktioniert. Die Hardware besteht aus einem Atmel ATMega 8, 4 RGB-LEDs von der Firma Vishay, wobei jede Farbe mit einem eigenen Transistor und Port angesteuert wird. Alle Anoden der LEDs liegen zudem zusammen über einen Transistor auf einem Port. 
 +
 +Die Hardware wurde in zwei Modulen geplant. Die Basisplatine mit allen Steuerungsaufgaben, sowie den Leucht-Modulen, diese die RGB-LEDs beinhalten. Beide Platinen wurden mit Steckverbindern ausgestattet um sie einfach mit Flachbandkabel verbinden zu können (siehe Bilder).
 +
 +Als Programmiersprache wurde Bascom Basic gewählt. Das angehängte Programm fadet alle Grundfarben, sowie die durch Mischung von zwei Grundfarben entstehende Farbe ein und aus. Der Farbwechsel geschieht während der Zeit in der die LED komplett aus ist. Alle vier RGB-LEDs werden exakt gleich angesteuert. Die Farbmischung scheint wohl nach ein paar kleinen Tests noch fehlerbehaftet zu sein, wobei mir das Ergebnis so gefiel und ich deshalb nicht weiter nachgeforscht habe.
 +
 +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
 +
 +{{:elektronik:beleuchtung.png?200}}
 +
 +Hier noch die Eagle-Datei
 +{{:elektronik:beleuchtung.sch|}}
 +
 +Die Basisplatine wurde frei auf einer Punktrasterplatine aufgebaut. Für die Leucht-Module habe ich mir dagegen ein kleines Layout überlegt.
 +
 +{{:elektronik:layout_leucht_modul.png?200}}
 +
 +===== Bascom-Programm =====
 +
 +<code>
 +'Beleuchtung Version 0.1 by Patrick Beck
 +'-------------------------------------
 +'Beleuchtung is a ambient light on the base
 +'of a ATMEL AVR Mega8 microcontroller.
 +'Programming language is Bascom basic.
 +'-------------------------------------
 +
 +$regfile = "M8def.dat"
 +$framesize = 60
 +$hwstack = 40
 +$swstack = 32
 +
 +$crystal = 8000000                                          ' internal rc-oscillator on 1 Mhz
 +
 +Ddrb = &B11111111                                           ' PORTB as output
 +Ddrc = &B11111111                                           ' PORTC as output
 +Ddrd = &B11111111                                           ' PORTD as output
 +
 +Config Timer0 = Timer , Prescale = 1                        ' fading timer
 +On Timer0 Fadingroutine                                     ' jump to fadingroutine when the timer0 overrun
 +
 +Enable Interrupts                                           ' enable interrupts and timer0
 +Enable Timer0
 +
 +Red1 Alias Portd.7                                          ' Define alias for the portpins Red1 - first red led
 +Green1 Alias Portd.6                                        ' Green1 - first green led
 +Blue1 Alias Portd.5                                         ' Blue1 - first blue led
 +
 +Red2 Alias Portd.4                                          ' the same as above
 +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                                   ' all anodes over a transistor on an port
 +
 +
 +Dim Dimm As Byte                                            'define the variables
 +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                                                   ' light is for mixing the colours
 +Colourcounter = 0                                           ' colourcounter saves the actual colour for the rgbtable
 +
 +Up = 0                                                      ' indicates that the variable fade will be count up
 +Down = 0                                                    ' indicates that the variable fade will be count down
 +
 +Do
 +
 +'-------------------------- fading --------------------------
 +
 +If Fade = 0 Then
 +   Down = 0
 +   Up = 1
 +End If
 +
 +If Fade = 255 Then
 +   Up = 0
 +   Down = 1
 +End If
 +                                                           ' in fading
 +If Up = 1 Then
 +   Incr Fade
 +   Waitms 10
 +
 +End If
 +
 +If Down = 1 Then                                            ' out fading
 +   Decr Fade
 +   Waitms 10
 +
 +End If
 +
 +'-------------------------- colourmixing --------------------------
 +
 +Reddim = Lookup(colourcounter , Redtable)                   ' table lookup with the rgb value for red
 +Greendim = Lookup(colourcounter , Greentable)               ' green
 +Bluedim = Lookup(colourcounter , Bluetable)                 ' and for blue
 +
 +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
 +   Green1 = 1
 +   Green2 = 1
 +   Green3 = 1
 +   Green4 = 1
 +Else
 +   Green1 = 0
 +   Green2 = 0
 +   Green3 = 0
 +   Green4 = 0
 +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                                         ' when light is 255 set it to 0
 +   Light = 0
 +End If
 +
 +If Fade = 0 Then                                            ' change the colour when all leds off - not between a fading
 +   Incr Colourcounter
 +End If
 +                                                             ' we have 7 colours so we have to set the counter to 0 when it reaches 7
 +If Colourcounter = 7 Then
 +   Colourcounter = 0
 +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:                                              ' controls the fading - switch common anode on and off for all leds
 +   If Dimm < Fade Then                                      ' when dimm smaller than fade switch the commonanode off - leds off
 +      Commonanode = 0
 +   Else
 +      Commonanode = 1                                       ' leds on
 +   End If
 +
 +   Incr Dimm
 +
 +   If Dimm = 255 Then
 +      Dimm = 0
 +   End If
 +Return
 +</code>
 +
 +Hex-File zum direkten flashen {{:elektronik:beleuchtung.hex|}}
 +
 +===== Bilder =====
 +
 +==== Platine ====
 +{{:elektronik:cimg3819.jpg?400}}
 +{{:elektronik:cimg3824.jpg?400}}
 +{{:elektronik:cimg3825.jpg?400}}
 +{{:elektronik:cimg3822.jpg?400}}
 +{{:elektronik:cimg3823.jpg?400}}
 +{{:elektronik:cimg3826.jpg?400}}
 +{{:elektronik:cimg3827.jpg?400}}
 +{{:elektronik:cimg3828.jpg?400}}
 +{{:elektronik:cimg3833.jpg?400}}
 +{{:elektronik:cimg3834.jpg?400}}
 +{{:elektronik:cimg3838.jpg?400}}
 +
 +==== Endergebnis ====
 +{{:elektronik:cimg3840.jpg?400}}
 +{{:elektronik:cimg3841.jpg?400}}
 +{{:elektronik:cimg3842.jpg?400}}
 +{{:elektronik:cimg3843.jpg?400}}
 +