# TRIAC Switching Circuit

Discussion in 'General Electronics Discussion' started by HowlingGoatBoy, Jul 10, 2014.

1. ### HowlingGoatBoy

5
0
Jul 10, 2014
Hi All

This is my first post here, so here goes:

I'm very new to electronics and mostly self taught.
For a project I'm doing for my studies I want to build an irrigation controller, the programming part is fine, that I can do, but my problem lies with the electronic side of things. I've picked this project to learn more about circuit design.

This controller is essentially a microchip switching a solenoid valve on or off.
I have done the design, which I believe is correct, but I can't seem to calculate the resistor values.
I've been stuck with this for weeks now, the problem I have seems to be understanding the datasheets which seem just really not noob friendly.

Explanation of Circuit:

A microcontroller switches a seperate 5V signal using a NPN transistor, which in turn switches on an optocoupler, which in turn switches on the TRIAC which turns on/off a 24VAC Solenoid (about 140mA innitial current)

A seperate 5V signal is used to switch the optocouper as the microcontroller cannot supply enough current
(The schematic is one of the 6 "TRIAC Switches" )

The optocoupler is neccesary to isolate the TRIAC in case of failure, and the transistor and TRIAC both have pull-down resistors

My problem is that I know that the optocoupler requires 15mA, but how do I supply that amount to it?
with my current understanding the gain is about 100 - 125, which gives me a base current of 0.2mA - 0.16mA

Now do I work with how much volt I need to give the transistor (enough pressure to supply the current) or... what?

I am quite sure my understanding is flawed and I'm missing some basic background
(I've done resistor loops and such, Nothing hectic)

I've attached the circuit diagram (Hand drawn with scribbles that probably should be ignored)
and the 3 datasheets of the components I'm using
Transistor : 2N3904_S
TRIAC : MAC97A8
Optocoupler : MOC3041-3M

ANY help would be much appreciated, even if it's just how to get the information I need from the transistor datasheet as this is my first proper circuit design.

Sorry for the long post

File size:
147.3 KB
Views:
682
File size:
259.7 KB
Views:
122
File size:
101.7 KB
Views:
127
File size:
79.3 KB
Views:
213
2. ### BobK

7,682
1,688
Jan 5, 2010
Hi HGB, and welcome to the forum.

The first problem I see is that you have the transistor switch wired incorrectly. The LED and the resistor should be connected between +5V and the collector, and the emitter should be connected to ground.

After that, the calculation for base current is as follows:

Ib = (Vin - Vbe) / Rb

To get 15mA of collector current, you want the base current to be about 1/10 of that, so:

0.0015 = (5 - 0.7) / Rb

Rb = (5 - 0.7) / 0.0015 = 4.3 / 0.0015 = 2866.

A 2.7K resistor would be good.

Bob

3. ### HowlingGoatBoy

5
0
Jul 10, 2014
Thank you very much BobK

That would bias the transistor correctly, right?

Last edited: Jul 10, 2014
4. ### KrisBlueNZSadly passed away in 2015

8,393
1,271
Nov 28, 2011
You CAN connect the transistor that way - it's called the "common collector" or "emitter follower" configuration.

You don't need R1, and you don't need R2. Just connect the MCU output directly to the base of the transistor. Actually, you mustn't have either of them - they reduce the voltage at the base, which you don't want for an emitter follower.

When you calculate R3, remember that the transistor's emitter will be about 0.7V below the 5V rail. And there will be a forward voltage across the LED in the optocoupler.

I don't know where you got the value of 3V for the optocoupler LED's forward voltage. The data sheet says it's typically 1.25V, maximum 1.5V. Assuming worst case, 1.5V, then the voltage across R3 will be (5V - 0.7V - 1.5V) = 2.8V. If you want 15 mA to flow through R3, then calculate R3 using Ohm's Law:
R = V / I
= 2.8 volts / 15 mA
= 2.8 / 0.015 (remember, I is in amps)
= 186.7 ohms
Since you want the current to be AT LEAST 15 mA, you want the resistor to be AT MOST 186.7 ohms. I would use 150 ohms or 120 ohms. You want plenty of safety margin for the optocoupler current. There will be variations in base-emitter voltage of the transistor, in the +5V rail voltage, and in the optocoupler. So you use an engineering safety margin of at least 20%.

BobK's suggestion puts the transistor in common emitter configuration as a saturated switch. This requires one more resistor, but is better in that the voltage lost in the transistor is typically only around 0.1V instead of 0.7V.

This is important if the difference between the power supply voltage and the forward voltage of the load (the LED in the optocoupler) is not great, and you want as much as possible of the supply voltage to appear across the series combination of the LED and the series resistor.

Another option is to use a small N-channel MOSFET such as a BS170 or 2N7000/7002 instead of the transistor. This option doesn't need the resistor from the MCU output, and has an even lower voltage loss in the switching device.

Steve has just recently written up an excellent resource covering the common emitter arrangement, at https://www.electronicspoint.com/resources/using-a-bipolar-transistor-to-turn-a-load-on-and-off.30/

Finally, the points in your schematic that are marked with an earth symbol are actually "0V" not "-5V". I know what you mean; they are the negative side of the 5V supply, but voltages and rail names in a circuit are normally specified relative to a "reference" rail, which may be called "ground", "common", or "0V" - I prefer "0V" because it makes it clear that it's the reference rail. In this case, the +5V supply rail is at +5V relative to the 0V rail, and all of those earth symbols are connections to the 0V rail. A "-5V" rail would be a rail that is 5V negative with respect to the 0V rail, and I'm pretty sure that's not what you mean.

BTW welcome to Electronics Point

5. ### BobK

7,682
1,688
Jan 5, 2010
Kris,

Yes, I almost said that you can, in this case, use that configuration for switching, but I promoted the common emitter configuration because it is more generally the correct way to do a transistor switch.

The problem, of course with using an emitter follower, is that it cannot be switched with a voltage less than the supply voltage on the collector without incurring large losses.

Bob

6. ### KrisBlueNZSadly passed away in 2015

8,393
1,271
Nov 28, 2011
A saturated switch should be common emitter, but a transistor current booster for driving LEDs, motors, relay coils, buzzers or whatever doesn't need to be a saturated switch, and an emitter follower will work, and may be appropriate, as long as the base-emitter voltage drop doesn't cause a problem.

Emitter followers are not unusual in H-bridges where the voltage loss is acceptable. Sometimes an emitter follower is more appropriate than a common emitter stage - for example, driving a common cathode RGB LED from signals that are active high, where a common emitter stage would require another transistor to invert the signal. Provided again that the voltage loss isn't a problem.

In a generic article, I would mention that the transistor's collector has to be at least as positive as the signal; in this case, the schematic shows they are both connected to +5V.