0
\$\begingroup\$

I have been studying transistors and decided to try my knowledge in my lab to find out that nothing works as I thought it would..

I had a small lamp 12V and a handful of 2N3904 transistors, along with a 12V DC power supply.

Attached to the base of the transistor was a pin from my Raspberry Pi, along with a 150 ohm resistor to provide ~20 mA of current. The rest of the transistor was wired as the picture.

enter image description here

However, as soon as I plugged in the power supply, the lamp lit! Even though no current was passing through the base. I tried flipping the transistor around, to see what would happen, as as expected the lamp wouldn't light.

I switched out the lamp with a small solenoid (SparkFun ROB-11015), but now nothing happened while toggling the GPIO pin. I switched out the transistor thinking I fried it, but still nothing... am I missing something?

From what I understand, as long as there is enough current running through the base to saturate the transistor, it should allow current to pass from the power supply to the load. When the transistor is not saturated, the circuit is open.

As an aside, from multimeter readings the GPIO pin is a steady 3.3V and the solenoid draws ~500 mA initially and stabilizes at ~140 mA when wired directly to the power supply.

\$\endgroup\$
  • 2
    \$\begingroup\$ You don't have common ground for two parts of the circuit. At least in the schematic. \$\endgroup\$ – Eugene Sh. May 4 '15 at 18:04
  • \$\begingroup\$ the Rpi should not be sourcing 20mA current. \$\endgroup\$ – KyranF May 4 '15 at 18:04
  • \$\begingroup\$ And I agree with @EugeneSh. on this, make sure the GROUND of both circuits are connected. Run a wire from the ground point of the transistor and light circuit and put that into a ground pin on the RPI header. \$\endgroup\$ – KyranF May 4 '15 at 18:05
  • 1
    \$\begingroup\$ Another thing is, the transistor does not need to saturate. In fact it can take a huge amount of current (for a RPi anyway) to do so, for most transistors. Can take 40-60mA some times, which your Rpi should never be trying to do. Use a Darlington pair \$\endgroup\$ – KyranF May 4 '15 at 18:07
  • \$\begingroup\$ Thanks, @EugeneSh. KyranF, what's a more reasonable amount of current for an RPi? I tried to find some information on this earlier and found that ~30 mA was the maximum.. I guess it is bad to run anything at maximum? If I run a common ground for the transistor and light circuit, do I run the risk of damaging the RPi if some weird voltage spike happens? \$\endgroup\$ – Kevin May 5 '15 at 1:14
2
\$\begingroup\$

Whatever you have driving the base is not connected to a common ground with the rest of the circuit.

To turn on a NPN transistor, the control current flows into the base and out the emitter. You have provided no path for that current coming out of the emitter back into whatever voltage source is driving the bottom of the base resistor. In the context of your schematic, you need to connect the emitter of the transistor to the same ground as the bottom of the 3.3 V source.

The strange thing is that the light is on instead of always off. With no base current, the transistor should be off. This indicates something is not as you have it wired, or the transistor is connected incorrectly or is damaged.

\$\endgroup\$
  • \$\begingroup\$ Thanks, Olin. The transistor is likely damaged from me tinkering or the wiring was incorrect. I will check tomorrow. However, if I attach a common ground between the emitter and the base voltage source, I'm worried that a voltage spike will harm my logic device (Raspberry Pi). Would a diode fix this? \$\endgroup\$ – Kevin May 4 '15 at 23:47
  • \$\begingroup\$ What "voltage spike"? The RPi will be driving the bottom end of the 1k resistor as I understand it. As long as the RPi can source 4.3 mA, which it most likely can, there should be no problem. The ground of the RPi and the emitter of the transistor need to be connected together. \$\endgroup\$ – Olin Lathrop May 5 '15 at 11:55
0
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

I achieved something similar with the below circuit. Does use some extra components, but will happily switch the 12V on and off!

Whilst I think this achieves what you're looking for - i've found it to be better to use a transistor to switch the path to ground on or off, rather than using it to turn the 12V supply on.

See Below;

schematic

simulate this circuit

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

Late...

In the first original diagram there's another error, beside the fact that there's no common ground: when no base voltage is present, lets say the Raspberry Pi is not connected, the base of the transistor lies open... What happens then is that the circuit becomes very sensitive for the net frequency that flows around (50 or 60 Hz), and will open on the positive flank of its sinus. To overcome this, place a relatively high resistor between the base and the emitter, so that the base voltage is always pulled down to zero when there is no input. In this case something like 100KΩ or 220KΩ will do fine.

Another point to mention is the lamp with this transistor: the 2N3904 can have a max. of 200 mA (0.2 A), so beware that the lamp can really not be more than 2.4 Watt, or the transistor will blow. For endurance, 1.5 Watt would be my maximum.

\$\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.