0
\$\begingroup\$

I'm creating a circuit with an infrared led and a transistor connected to a gpio pin on a Raspberry Pi. I'm currently using 5v with a 40 omh resistor (4 10 ohm resistors chained) but I'm not sure what resistor to put on the transistor.

The only transistor I have is the PN2222, will that work, and what resistor should I use?

Update: Here's the circuit I'm using, except with a 5v supply instead of a 12v enter image description here

The LED has a forward current of 100mA and is found here (can't find a part number, specs are under description) I've already calculated the value for the 2nd resistor, 40 ohms (with a 5v power supply)

The GPIO pin I'm using to control the transistor is 3.3 volts.

\$\endgroup\$
6
  • 3
    \$\begingroup\$ Please use the schematic editing tools this site provides to create and provide a schematic diagram that shows your present design. We can't comment on your design if we don't know what it is. Also, what is the part number for the infrared LED you are using? [Hint: You want the transistor to turn fully ON (to "saturate") when driving the LED. So in your calculations, use the transistor's saturation beta which is 10, and not the transistor's "amplifier" (forward active, hFE) beta which is between 100 - 300: i.e., IB(sat) = IC(sat)/Beta(sat).] \$\endgroup\$ Nov 22, 2017 at 5:59
  • \$\begingroup\$ [Hint #2: You will likely have two resistors in your final circuit. One resistor will be in series with the LED. Its job is to limit the amount of current that flows through the LED when the transistor turns ON (saturates). The second resistor will be in series with the BJT's base and it "programs" the amount of current that flows from the GPIO pin (logic HIGH) into the BJT's base, to ensure the BJT saturates (turns fully ON) when a logic HIGH voltage between VOH <= V_LOGIC_HIGH <= VCC is present at the GPIO pin. (Use VOH in your calculations!)] \$\endgroup\$ Nov 22, 2017 at 6:31
  • \$\begingroup\$ Added more information. \$\endgroup\$
    – user169600
    Nov 22, 2017 at 16:02
  • \$\begingroup\$ Regarding the 3.3V GPIO pin, what is the manufacturer's specification for the maximum current a GPIO pin can source (output)? \$\endgroup\$ Nov 22, 2017 at 18:08
  • \$\begingroup\$ 16 mA - it's a Raspberry Pi 3 B+ if you're looking for more information \$\endgroup\$
    – user169600
    Nov 22, 2017 at 18:53

3 Answers 3

1
\$\begingroup\$

Use Kirchoff's Voltage Law (KVL) to solve for the value of resistor R2.

$$ V_{CC}-V_{R2}-V_{LED}-V_{Q1.CE(sat)}=0 \;\;\;\;\;\;\;\;\;\;(1) \\[0.2in] \rightarrow V_{CC}-R_2\,I_{LED}-V_{LED}-V_{Q1.CE(sat)}=0 \;\;\;\;\;\;\;\;\;\;(2) $$

Solve equation (2) for R2. Look at the "saturation" tables/graphs in the transistor's data sheet to estimate the value of voltage \$V_{Q1.CE(sat)}\,@I_{C(sat)}=I_{LED}\$.

The desired base current \$I_{B(sat)}\$ to saturate transistor Q1's collector-emitter path is given by equation (3):

$$ I_{B(sat)}=I_{C(sat)}/\beta_{sat}\bigg\rvert_{I_{C(sat)}=I_{LED},\;\beta_{sat}=10} \;\;\;\;\;\;\;\;\;\;(3) $$

[HINT: \$\beta_{sat}=10\$ comes from the transistor's data sheet.]

Use KVL to solve for the value of resistor R1.

$$ V_{OH}-V_{R1}-V_{Q1.BE(sat)}=0 \;\;\;\;\;\;\;\;\;\;(4) \\[0.2in] \rightarrow V_{OH}-R_1\,I_{Q1.B(sat)}-V_{Q1.BE(sat)}=0 \;\;\;\;\;\;\;\;\;\;(5) $$

where \$V_{OH}\$ is the minimum voltage for a logic HIGH output for the 3V3 logic you are using:

$$ V_{OH} \le V_{LogicHigh} \le 3.3\,V \;\;\;\;\;\;\;\;\;\;(6) $$

Solve equation (5) for R1. Look at the "saturation" tables/graphs in the transistor's data sheet to estimate the value of voltage \$V_{Q1.BE(sat)}\,@I_{C(sat)}=I_{LED}\$.

CHECKS

  1. Check the current ratings for the GPIO pin you are using. Ensure the GPIO pin can safely source \$I_{B(sat)}\$ amps of current when the pin is configured for a logic HIGH output.

  2. Check the electrical specs for the microcontroller's ("uC") POWER pins. Ensure your design does not draw more current through the uC's POWER pins than the specified maximum current for those pins.

  3. Calculate the power each resistor must dissipate. Purchase/use a resistor whose specified power rating is at least two times the calculated power dissipation value \$(P_{SPEC}\ge 2 P_R)\$.

$$ P_R=I_R^2\,R $$

\$\endgroup\$
0
\$\begingroup\$

Both the led and the transistor base use the same formula for calculating the resistor.

(Vs - Vf) / If

Source voltage minus the forward voltage of the diode, divided by the forward current of the diode.

For a normal silicon base transistor like the 2n2222, the Vf is 0.7V, as a rule of thumb.

Assuming a max collector current of (5V / 40 ohms = 0.125 A), the PN2222 is just dandy. Your actual current will be less based on your led added in to that.

\$\endgroup\$
0
\$\begingroup\$

You want to know the value of a resistor, but haven't said which one.

You say the LED should have 100 mA thru it, but didn't say what voltage it will drop. Let's assume 1.2 V, which should be close for a IR LED. Let's figure the transistor will drop 200 mV in saturation.

You are starting with 12 V. That minus the voltage across the LED and the transistor leaves 10.6 V across R2. By Ohms law, R2 = (10.6 V)/(100 mA) = 106 Ω. That's the absolute minimum resistance, and runs the LED right at the edge. For some margin, I'd use 120 Ω at least.

As for R1, I go into detail about how to calculate a base resistor at https://electronics.stackexchange.com/a/341131/4512.

Added in response to comments

I'm using a 5v power supply instead of a 12v

It really looks like your schematic shows 12 V. It's a bit hard to read, but it's certainly not 5 V.

If you really mean 5 V, then I don't get why you wrote 12 V in what is obviously a hand-drawn schematic. That just makes no sense.

I'm trying to calculate R2.

Right. That is exactly what I showed how to do above. You should be able to follow the process above with any power supply voltage, LED forward voltage, and LED current, to arrive at a suitable value for R2.

\$\endgroup\$
3
  • \$\begingroup\$ I'm using a 5v power supply instead of a 12v - and I calculated R2 for 40 ohms already. I'm trying to calculate R2. \$\endgroup\$
    – user169600
    Nov 22, 2017 at 16:20
  • \$\begingroup\$ Sorry, meant to say R1 - and I borrowed someone else's sketch online \$\endgroup\$
    – user169600
    Nov 22, 2017 at 18:54
  • 1
    \$\begingroup\$ @CMalasadas, you can add schematics to your questions using a built-in schematic editor. You can also draw your own sketch and take a picture of it with cell phone or laptop computer. I don't think there is any real excuse for making things so confusing. \$\endgroup\$
    – user57037
    Nov 22, 2017 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.