Und einmal mehr macht mir mein nicht vorhandenes Englisch Probleme....
Was ich habe:
Einen Arduino Mega (Clon)
Einen AC Licht Dimmer für PWM Steuerung
Eine LED Glühlampe zu Testzwecken.
Einen Code zum Probieren habe ich hier gefunden:
/*
AC Voltage dimmer with Zero cross detection
Author: Charith Fernanado Adapted by DIY_bloke
License: Creative Commons Attribution Share-Alike 3.0 License.
Attach the Zero cross pin of the module to Arduino External Interrupt pin
Select the correct Interrupt # from the below table
(the Pin numbers are digital pins, NOT physical pins:
digital pin 2 [INT0]=physical pin 4 and digital pin 3 [INT1]= physical pin 5)
check: <a href="http://arduino.cc/en/Reference/attachInterrupt">interrupts</a>
Pin | Interrrupt # | Arduino Platform
---------------------------------------
2 | 0 | All -But it is INT1 on the Leonardo
3 | 1 | All -But it is INT0 on the Leonardo
18 | 5 | Arduino Mega Only
19 | 4 | Arduino Mega Only
20 | 3 | Arduino Mega Only
21 | 2 | Arduino Mega Only
0 | 0 | Leonardo
1 | 3 | Leonardo
7 | 4 | Leonardo
The Arduino Due has no standard interrupt pins as an iterrupt can be attached to almosty any pin.
In the program pin 2 is chosen
2 | 0 | All -But it is INT1 on the Leonardo
*/
int R1 = 29;
int AC_LOAD = 4; // Output to Opto Triac pin
int dimming = 128; // Dimming level (0-128) 0 = ON, 128 = OFF
void setup()
{
pinMode(R1, OUTPUT);
pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
attachInterrupt(0, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
}
//the interrupt function must take no parameters and return nothing
void zero_crosss_int() //function to be fired at the zero crossing to dim the light
{
// Firing angle calculation : 1 full 50Hz wave =1/50=20ms
// Every zerocrossing thus: (50Hz)-> 10ms (1/2 Cycle)
// For 60Hz => 8.33ms (10.000/120)
// 10ms=10000us
// (10000us - 10us) / 128 = 75 (Approx) For 60Hz =>65
int dimtime = (75*dimming); // For 60Hz =>65
delayMicroseconds(dimtime); // Wait till firing the TRIAC
digitalWrite(AC_LOAD, HIGH); // Fire the TRIAC
delayMicroseconds(10); // triac On propogation delay
// (for 60Hz use 8.33) Some Triacs need a longer period
digitalWrite(AC_LOAD, LOW); // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
}
void loop() {
digitalWrite(R1, HIGH);
for (int i=5; i <= 128; i++){
dimming=128;
delay(10);
}
}
Mein Leuchtmittel hängt hinter einem Relais, daher minimal angepasst.
Leider finde ich den Dimmer nicht unter Fritzing, daher kein Schaltplan.
+5V und GND sind am selben (MW 5A) Netzteil wie der Arduino Clone,
der PWM Eingang ist auf PIN 4,
der Z-C Anschluß des Dimmers ist auf PIN 2 geklemmt (Interrupt 0, wenn ich das richtig verstanden habe.
Was ich machen möchte:
Das Leuchtmittel in 5 Stufen dimmen (20% 40% 60% 80% 100%)
Was mit dem Testcode passiert:
Leuchtmittel startet mit einem Aufblitzen
Leuchtmittel geht kurz aus
Leuchtmittel leuchtet volle Leistung
Leuchtmittel dimmt herunter
Leuchtmittel geht aus
und dann von vorne
...
Leuchtmittel startet mit einem Aufblitzen
Leuchtmittel geht kurz aus
Da das Leuchtmittel (denke ich) kapazitiv ist, ist die Phasenabschittssteuerung richtig.
Trotzdem bekomme ich (z.B 50% Leistung) nicht hin.
Könnt Ihr mir kleinem Trotteltier helfen?