Friday, 19 September 2008

Triac Mains Switching

Mains switching is something I've always wandered about; relays always seemed like the way to do things, but what if you don't have a device that can supply enough current to throw the switch, or what if space is quite a limiting factor?

I looked into triacs to solve my problem, and, with my new found knowledge, I set about creating the circuit detailed below:
The MOC3020M is a triac optoisolator - basically, it's a light-sensitive triac with a small light source in one component. Pins 1 and 2 are used to turn the light source on and off, which in turn allows the internal traic (pins 4 and 6) to conduct. This internal triac is used to trigger another traic; one which is capable of dealing with larger currents. Mine, the 2N6073A, could handle 4A if heat-sunk properly. But, I've kept it well away from that with a 2.2A circuit breaker.

There's a fair amount of information on the Internet about how traics work, so I won't put any here; take a look if you're interested. Basically, the triac will conduct (through the main terminals) as long as there is a voltage/current on the 'gate'. It stops conducting, after the gate voltage/current has been removed, as soon as the voltage/current over the main terminals crosses zero.

I decided to put my circuit in a small plastic box to keep it safe and out of the way. I also attached a trailing socket so I could use it for more than one project, easily. The earth wire isn't connected in my circuit (except to the trailing socket) since the box is plastic. For the control cable, I decided to use a length of telephone cable (which normally has RJ11 connectors on the end) using just 2 of the strands - leaving room for expansion.

The mains device can be triggered 'on' by applying 5V to pin 1 of the triac optoisolator. My intention was to have the circuit triggered by my Arduino, opening a world of possibilities.


The Main Circuit

The plug, triac circuit and trailing socket

One thing I have noticed with my circuit is that when certain devices at home are turned on, but the triacs are off, the connected device (to the trailing socket) gets a bit of power for a fraction of a second. The traic miss-fires for a tiny period of time due to the magnitude of dv/dt - the change in voltage per small unit of time. These values are discussed on the triac's datasheet. If this becomes an issue, I'll have to design a snubber circuit to dampen the effect and solder it in (hence the large space to the left of the board).

Words of warning: Mains electricity is very dangerous; do not do anything like this if you're not sure what your doing. I did a fair amount of research before building my circuit. The components in this circuit can become damaged from transient voltage spikes so I'd advise against using inductive loads with this circuit - the triacs may fuse open (or worse!). Stick with resistive loads!

11 comments:

Anonymous said...

Was thinking of doing the same thing. Is it possible to remove the second triac and somehow trigger the traic using a microcontroller directly?

admin said...

Yes, you can!

Take a look at the 2N6073A's datasheet (below). It can be triggered with TTL level voltages, but the datasheet itself recomends using triggering devices (mine being the MOC3020). Besides, what's an extra £1 for completely isolating the microcontroller?

http://www.datasheetcatalog.org/datasheet2/5/0qk1k6oc02kyzqy3gjdzc9laf2cy.pdf

Anonymous said...

Any chance of using the following triac for this? It has better off-state characteristics:

http://snurl.com/tropp

Anonymous said...

BTW, the Triac I'm planning on using is a Littelfuse Q4025L6. The URL is http://snurl.com/trou7 (the previous one is the wrong datasheet)

admin said...

It certainly looks very good, but 25A is a lot of current! Have you chosen one capable of passing 25A because you need to pass just under 25A?

I don't know what you're triggering; my circuit was for non-inductive loads. You may not have realised it, but the alternistor is a proprietary improvement upon the triac specifically to aid triggering inductive loads. If it is inductive loads you are triggering, you'll need a different circuit. There are a number available on the internet, so it shouldn't be too difficult to find one for your needs.

Anonymous said...

I am planning on using it to trigger basically anything whoever uses my device decides to plug in. See, I was making a relay box that you can control with an Arduino Mega, but then I figured out that triacs could be better and actually would be cheaper and smaller than a bunch of relays.

I actually chose an alternistor just in case the user plugged in an inductive load.

About the current... that was the only alternistor that Futurlec sells. I am assuming that an absolute maximum of 15 amps will e drawn from the AC side of things at once. That means that each triac needs to be ready for a 15 amp draw. Yeah, I know it's a lot, but better safe than sorry. Also, what heatsink should I use (assuming that 15 amps is actually being drawn from that triac?)

Unknown said...

What wattage is R3?

I've tested it and I burnt two 1K ohm resistors. Tried with 1/4 and 1/2 watt.

I don't have 2N6073, so I use TYN412. maybe that was the problem, but in the shop tell me that it's "the same thing".

And, watch out about what you turn on. In the MOC3020 datasheet show different circuits in case of resistive or inductive loads.

Unknown said...

I'll answer myself.
The problem was the TYN412. It's not a TRIAC. It's a Thyristor.
I changed it with a BTA08-600C and worked ok with 1W, 1/2W and 1/4 W.

But... low wattage bulb (CFT lamps) doesn't work.

Anyone knows who can I make it work?

Unknown said...

Might be a stupid question, but how can you can run mains voltage into the gate of the 2N6073A when the datasheet says its peak gate voltage is 5V?

Michael Motes said...

The max gate current is 5V, that's the voltage between pins 1 and 2 from the MCU. The maximum voltage between pins 6 and 4 is the peak repetitive off-state voltage from the data sheet, which is 400V.

NJC said...

I believe that the pin orientation of the TRIAC is incorrect. The gate pin goes on the A1 side, and the resistor supplying the current to the gate should be connected to A2.