I used a MOC3011 and a Q4015 TRIAC to use my Arduino to blink a few Christmas light strands. I did this a few months ago, yet never posted it here... The MOC is a optoisolator in a way, as it seperates the arduino from the high voltage 110v circuit. It is also used because the arduino doesn't have the power to directly drive the TRIAC.
There are two different configurations: resistive (ex LEDs) or inductive (ex a motor). The symbol for the TRIAC is a little weird, so make sure to check the datasheet for which pins are which. Pin 2 of the MOC is the one you'll want to connect to your arduino.
One thing you should note is that the MOC3011 doesn't have zero point detection, so unlike the MC3041, it cant do PWM based fading correctly correctly due to flickering. Zero point detection is where the chip switches exactly when the sin wave is crossing zero to properly turn on/off the current. The 3011 would actually work quite well with analog fading however and by that I mean a voltage that is varied rather than a constant voltage being switched on and off. The code attached simply uses two pots to control the on and off delays for the LEDs.
#define LedPin 7
int OnDly;
int OffDly;
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(LedPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
OnDly=analogRead(A2);
OffDly=analogRead(A3);
Serial.print(OnDly);
Serial.print(", ");
Serial.println(OffDly);
digitalWrite(LedPin, HIGH); // set the LED on
delay(OnDly); //set to value from pot
digitalWrite(LedPin, LOW); // set the LED off
delay(OffDly); //set to value from pot
}
I think you are making a fundamental mistake in your last sentence. It is not that the MOC3011 cant do fading "because unlike the MOC3041 it doesnt have 'zero point'."
ReplyDeleteThe MOC3041 has a zero cross detection and therefore its ON switching will be smoother. The MOC3011 doesnt have zerocross detection and therefore it will switch at any moment of the AC sin wave and this will create quite 'abrupt' ON ad OFF switching.
"Fading" is something completely different and for that in fact you DO need something like a MOC3011 that doesnt have zerocross detection
right again hah.
Delete