1
\$\begingroup\$

I've got a basic setup which allows me to control 230V AC by switching a solid state relay on/off.

I'm using a Raspberry Pi's GPIO output pin and a general-purpose NPN transistor (BC547B) to allow a current to flow through the relay, here's my schematic:

enter image description here

Resistor R1 allows me to limit the current flowing through the SSR (The SSR accepts 4-32V, max 15mA). Assuming the transistor has a 150x voltage gain, this should be about 10mA. (Is this right?)

Resistor R2 acts as a pulldown resistor so that the transistor stays closed when the GPIO pin is turned off/disconnected. However, I don't know what value to choose for this resistor.

After some research I found out that the resistor's value should be between 10kOhm and 100kOhm but does it have to be greater than R1? If so, what happens if the resistance is too great?

So my question is: Does R1's value make any sense and if so, does R2's value depend on it?

Additional information:
Here's a link to the SSR datasheet (The LED-indicated, random-on 240VAC relay).

\$\endgroup\$
  • \$\begingroup\$ Two notes: (a) R1 and R2 form voltage divider, and (b) Are you sure when you say GPIO pin is turned off/disconnected (three states are possible depending on configuration: low, high and high impedance). \$\endgroup\$ – Anonymous Oct 31 '16 at 14:45
  • 2
    \$\begingroup\$ How about a part number and/or link to the SSR datasheet. I suspect it probably already limits the input current so long as you provide a 4-32V input. \$\endgroup\$ – Tut Oct 31 '16 at 14:50
  • 1
    \$\begingroup\$ Here's a link to the SSR datasheet: zettlerelectronics.com/pdfs/sonstige/SSR-Flyer.pdf (The LED-indicated, random-on 240VAC relay) \$\endgroup\$ – Laurent Oct 31 '16 at 15:23
  • 2
    \$\begingroup\$ You shouldn't need a pulldown on a BJT? \$\endgroup\$ – pjc50 Oct 31 '16 at 16:14
12
\$\begingroup\$

You do need a resistor in series with the base but a better design would also put a resistor in series with the SSR's LED to limit the current unambiguously and not be reliant on hFE of the transistor.

So, I would make the base series resistor 1 kohm and this would force about 2.5 mA into the base. This will likely saturate the collector down to about 0.1 volts so that it is acting like a switch.

Whatever volt drop is specified by the SSR data sheet for its LED is then subtracted from 5V to determine the voltage across the LED current limiting resistor. The SSR data sheet will inform you of the nominal LED current so then you can calculate this resistor using ohms law.

\$\endgroup\$
  • \$\begingroup\$ So i'd put a 117Ohm resistor between the relay and +5v input since the SSR's datasheet states a 12mA control current and 300 ohm input impedance at 5v, replace R1 with a 1kOhm resistor and make R2=10kOhm? \$\endgroup\$ – Laurent Oct 31 '16 at 15:40
  • \$\begingroup\$ I can't verify this because the data sheet you linked under your question doesn't appear to state this. It probably does but it's so badly drawn and my eyes are hurting! But I do follow your logic in getting 117 ohms. Probably 110 ohms will be fine. 1 k and 10k are also cool to use. \$\endgroup\$ – Andy aka Oct 31 '16 at 15:46
0
\$\begingroup\$

Put a R3 between the collector of the transistor and the SSR. For a given transistor the gain (hFE) varies by manufacturing lot and temperature. With R3 the current through the SSR will be independent of the transistor gain.

So the saturation voltage of a NPN transistor is about 0.2 volts with 10 ma current for the SSR, R3 = (5 - 0.2) / 0.010 = 480. The standard value of 420 would give (5 - 0.2) / 420 or 11.4 ma. The standard value of 560 would give (5 - 0.2) / 560 or 8.57 ma. Since the 11.4 is below the 15 ma limit, choose R3 as 420.

With small plastic NPN transistors, the gain is 50 to 150. To drive the transistor into saturation, we need at least 11.4 / 50 or 0.228 ma into the base.

When saturated, the base to emitter voltage will be 0.7 for silicon, R1 will be (3.3 - 0.7) / 0.000228 = 11.403 ohms. So picking 10K ohms would drive (3.3 - 0.7) / 10000 = 0.26 ma into the base. Which would be sufficient for 0.26 * 50 or 13 ma of collector current. With R3 limiting us to just 11.4 ma, the transistor should stay in saturation.

R2 is in the circuit to bled off the charge that will collect in the base of the transistor from the leakage from the collector into the base, when the GPIO is disconnected. The base must not be allowed to float up toward the 0.7 volt range or the transistor will turn on.

A rule of thumb is that R2 is 10 times the value of R1 or 100K. You can look on the specs for the transistor and check the leakage current. Multiplying the leakage by 100K should yield a voltage that should be much smaller than 0.7 volts.

Now, with the base of the transistor in parallel with R2, some of the current will flow into the base and some into R2. In saturation, the current into R2 is 0.7 / 100K or 0.007 ma. This is small compared to the 0.260 ma into the base and can be safely ignored.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.