Go Down

Topic: Switching another circuit with a transistor (Read 2015 times) previous topic - next topic

marian42

Hi,

I built this circuit:
(Source, transistor)

As RLoad I'm using an LED with a resistor. RB is 1k (is that correct?)

The circuit is connected to an arduino pin that changes every second.
This circuit works and the LED blinks.

As soon as I replace 5V of the emitter (from the Arduino) with an external 5V source and connect GNDs, the LED stops blinking and stays on.

I want to use the circuit to switch 7 LEDs without drawing the current from the Arduino, the LEDs' cathodes are connected to GND.

dc42


As soon as I replace 5V of the emitter (from the Arduino) with an external 5V source and connect GNDs, the LED stops blinking and stays on.


I suspect that your external 5V source is an unregulated supply and is supplying rather more than 5V under the lightly-loaded conditions in which you are using it. In which case, either use a regulated 5V supply, or drive the PNP transistor from an NPN transistor which is in turn driven from the chip output.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

tack

#2
Dec 16, 2012, 03:11 pm Last Edit: Dec 16, 2012, 03:16 pm by tack Reason: 1
It's usually simpler to use an NPN transistor in Common Emitter setup, with the LED connected (with a series reistor) between Vcc and the Collector. This means you can have a power source for the LED circuit that is a different voltage to the MCU signal onto the Base. One of the other benefits is you could have the transistor switch, say, a 12V source into series LED's, meaning lower current drain.

You just need to remember that if you use multi-LED, such as RGB, you need Common Anode LED's, rather than Common Cathode, and that series LED's won't work.

Is using an NPN transistor an alternative option in your case?

You'd need an NPN for dc42's suggestion anyway, so it seems more sensible to just switch to an NPN Common Emitter circuit anyway.

The value of Rb will depend on the current you need in C-E and the DC Current Gain of the transistor. To use as a switch you want to saturate the transistor so need the base current to be more than CE/Gain, otherwise you risk not saturating the transistor and it will get warm in operation.

dhenry

Quote
an external 5V source and connect GNDs, the LED stops blinking and stays on.


Likely the external "5v" source is outputting more than 5v.

If that's the case, you can use a diode to help drop the voltage or to use a level shifter.

marian42


I suspect that your external 5V source is an unregulated supply and is supplying rather more than 5V under the lightly-loaded conditions in which you are using it. In which case, either use a regulated 5V supply, or drive the PNP transistor from an NPN transistor which is in turn driven from the chip output.

On the wallwart it says 4.5V. I just measured 8.6V.
I didnt know this before. Does it mean that I can use this wallwart to power the Arduino (because 5V sources are not suitable)?

Quote
Is using an NPN transistor an alternative option in your case?

It is, but I already connected all of the LEDs anodes so I had to unsolder them.

I would like to power the LEDs without buying further components.


Can you post a link with a circuit for a NPN transistor?
Why does my current circuit not work? Is it possible to fix it?

dhenry

Quote
Is it possible to fix it?


Multiple ways to fix it:

1) you can put the led + resistor to the pnp's emitter; simplest fix but requires rewiring.
2) you can put additional diodes (including leds) into pnp's emitter;
3) you can put additional diodes (including leds) into the pnp's base.

marian42


1) you can put the led + resistor to the pnp's emitter; simplest fix but requires rewiring.

So its not possible to fix it and to keep the LED connected to ground?

Runaway Pancake

You need to get that "8.xV" down to 5V.
Is there a 7805 in the house?
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

tack

#8
Dec 16, 2012, 04:21 pm Last Edit: Dec 16, 2012, 04:27 pm by tack Reason: 1

Can you post a link with a circuit for a NPN transistor?


Google 'NPN Transistor switch' gets you to http://www.kpsec.freeuk.com/trancirc.htm

The NPN Common Emitter is one of the first transistor circuits to learn.

A PNP set up like you have expects Vcc to be common, not Gnd, therefore the + rail needs to be common to the Arduino and your transistor source. By using a seperate supy for the LED circuit this isn't the case. An NPN Common Emitter arrangement would make sense IMO.


You need to get that "8.xV" down to 5V.
Is there a 7805 in the house?


The OP would still need to common up, so the Arduino/328 would also need to take supply form that 7805. The NPN switch is a lot simpler and something like a 2N3904 will switch 200mA and they cost pennies.

dc42


So its not possible to fix it and to keep the LED connected to ground?


Yes it is, by driving the PNP transistor from an NPN transistor. Or by using a 5V regulated supply instead of the unregulated one you have.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Runaway Pancake


The OP would still need to common up, so the Arduino/328 would also need to take supply form that 7805.

The wallpack negative and Arduino Gnd would have to be "commoned", Yes, but the Arduino 5V and the wallpack derived +5 (via 7805) can be separate - no problem.


The NPN switch is a lot simpler and something like a 2N3904 will switch 200mA and they cost pennies.

I agree, but it's too late for what ought to have been done.
Sounds like he wanted a way to stay with what he's got - and putting a 7805 into the deal will let him do that, no modification to existing circuitry required.
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

oric_dan

Quote
On the wallwart it says 4.5V. I just measured 8.6V.
I didnt know this before. Does it mean that I can use this wallwart to power the Arduino (because 5V sources are not suitable)?


Good measurement. Unregulated wallwarts always read 4-5V higher than the rated value with
no loads on them.

This one is probably NOT a good choice to run the Arduino bd, however, because the voltage
will drop too low when you start connecting loads to the Arduino. Better selection is a 6V
unregulated wall wart, 500 mA or better. The actual Vin to the Arduino bd needs 1-2V overhead
to keep the voltage regulator operating properly.

marian42

PROBLEM SOLVED!!!

I found another wallwart (HTC usb charger) that outputs 5.1 V. I connected this to my circuit without changes and it works!

Thank you all for your help!

dhenry


Krupski


Hi,

I built this circuit:
(Source, transistor)

As RLoad I'm using an LED with a resistor. RB is 1k (is that correct?)

The circuit is connected to an arduino pin that changes every second.
This circuit works and the LED blinks.

As soon as I replace 5V of the emitter (from the Arduino) with an external 5V source and connect GNDs, the LED stops blinking and stays on.

I want to use the circuit to switch 7 LEDs without drawing the current from the Arduino, the LEDs' cathodes are connected to GND.


That circuit requires the emitter of the transistor to be no higher than the logic 1 value of the microcontroller.

A better circuit would be a common emitter NPN transistor. Emitter directly to ground, base to the arduino pin via about a 470 ohm resistor and the collector to control your LED's.

That circuit will allow you to have a voltage higher than the arduino supply and it will still work. That is, if you used 12 volts and a resistor for the LED's, the common emitter NPN circuit would still work properly.

The "upside-down" PNP circuit you have cannot have the LED supply voltage any higher than the Arduino VCC.
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Go Up