# Dimmer lamp 220v ac

#### Diver300

##### Well-Known Member
I suggest you have around 20 mA as the input current to the MOC3021. The typical forward voltage is about 1 V, so you want about 100 Ohms for R5 if the microcontroller supply is 3 V, and about 200 Ohms if the supply is 5 V.

You don't need R1 and R2. Either can be used, and the other can be 0.

The output current for the MOC3021 is more difficult to decide. The maximum current is 100 mA. The gate threshold current for the Q4010L5 in quadrants I and III is 50 mA. That gives a margin of 2 times. The problem is that if you want to the triac to turn on near zero, the voltage is quite small, but if you try to turn on near the peak voltage, you will get a large current through the MOC3021. If your software in the microcontroller is wrong, you could blow the MOC3021.

However, the peak current allowed is 1 A. If you aim for that at 350 V, the peak with 240 V ac, then you will get around 50 mA at around 20 V, so that will happen quite near the zero.

To get that, R1 (or R2) needs to be around 400 Ohms.

Have a look at the circuit here:- https://www.mouser.co.uk/datasheet/2/239/MOC302-1175440.pdf

The capacitor and the resistor between MT1 and G on the triac are both sensible precautions.

##### Well-Known Member
Also see Fairchild AN-3006 and AN-3003.
Max,

• akalii

#### akalii

##### New Member
tH
I suggest you have around 20 mA as the input current to the MOC3021. The typical forward voltage is about 1 V, so you want about 100 Ohms for R5 if the microcontroller supply is 3 V, and about 200 Ohms if the supply is 5 V.

You don't need R1 and R2. Either can be used, and the other can be 0.

The output current for the MOC3021 is more difficult to decide. The maximum current is 100 mA. The gate threshold current for the Q4010L5 in quadrants I and III is 50 mA. That gives a margin of 2 times. The problem is that if you want to the triac to turn on near zero, the voltage is quite small, but if you try to turn on near the peak voltage, you will get a large current through the MOC3021. If your software in the microcontroller is wrong, you could blow the MOC3021.

However, the peak current allowed is 1 A. If you aim for that at 350 V, the peak with 240 V ac, then you will get around 50 mA at around 20 V, so that will happen quite near the zero.

To get that, R1 (or R2) needs to be around 400 Ohms.

Have a look at the circuit here:- https://www.mouser.co.uk/datasheet/2/239/MOC302-1175440.pdf

The capacitor and the resistor between MT1 and G on the triac are both sensible precautions.
I don't understand how did you get 400 ohms resistor for R1

#### Diver300

##### Well-Known Member
400 Ohms is to limit the peak current in the opto-triac to under 1 A, in case the microcontroller output turns on at the peak of the mains voltage. The peak mains voltage is around 350 V.

That is a direct application of Ohms law, with a bit of a safety factor added in.

• akalii 