I bought the AC Triac Controller from Krida. I am confident that there is nothing wrong with the controller but I get inconsistent outputs from a 120 volt incandescent lamp with my 60 Hz power. The code from Krida is:
unsigned char AC_LOAD = 7; // Output to Opto Triac pin
unsigned char dimming = 3; // Dimming level (0-100)
unsigned char i;
void setup() {
// put your setup code here, to run once:
pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
attachInterrupt(1, zero_crosss_int, RISING);
// Serial.begin(9600);
}
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 : (50Hz)-> 10ms (1/2 Cycle) For 60Hz (1/2 Cycle) => 8.33ms
// 10ms=10000us
int dimtime = (100*dimming); // For 60Hz =>65
delayMicroseconds(dimtime); // Off cycle
digitalWrite(AC_LOAD, HIGH); // triac firing
delayMicroseconds(10); // triac On propogation delay (for 60Hz use 8.33)
digitalWrite(AC_LOAD, LOW); // triac Off
}
void loop() {
// Serial.println(pulseIn(8, HIGH));
for (i=5;i<85;i++)
{
dimming=i;
delay(20);
}
for (i=85;i>5;i--)
{
dimming=i;
delay(20);
}
}
The light will turn on smoothly and turn off smoothly but then it will start the on-off sequence very rapidly and then maybe recover. I know that the author of the test code was using 50 Hz and maybe the constants need to be changed for 60 Hz. The link to the description is
http://www.inmojo.com/store/krida-electronics/item/ac-led-bulb-dimmer-controller-arduino/
I would appreciate any help explaining the operation of the power controller. I hope that I have provided enough detail. Thanks if you can help. My ultimate goal is a fuzzy controller but I will begin with standard PID.
Bob