Please help newbie in simple task why this PNP transistor doesn't work in PWM output as it should? If I supply to base constant +5v that led is on but pwm output from microcontroller doesn't dim it. Is it too slow or what's wrong? I know I should use P channel mosfet instead but I don't have them on hand at the moment..
If uC output drops down to 0V, the transistor will conduct the current.But 10 Ohm is too low..
If we assume Bdc=200, this resistor should be approx. 3K Ohm.
It doesn't work because you used PNP transistor, small 10ohm resistor and maybe PIC is dead. Use NPN BC337 instead, 1k base resistor and hope PIC has survived. Interchange 12VDC and ground and turn arround your LED.
I think the base-emitter diode of the transistor from 12V and the 10 ohm resistor caused a 630mA to 1.1A current surge to the output of the PIC that destroyed the PIC. It also probably destroyed the poor little overloaded transistor.
The maximum allowed output current for a PIC is only 25mA. The transistor is not even needed because the PIC can directly drive a 2V LED through a series resistor of about 120 ohms when the LED is connected to +5V or 0V.
In the first place I thought that I'm not able to put this transistor to negative wire as it's grounded elsewhere. Am I right that if I had to put it between positive wire I need to use PNP transistor instead (transistor between positive terminal and load)?
I had the negative wire on hand too so I did like Borber described and it works. Thank you all.
@ Audioguru: The LED is rated 12V/260mA. A transistor is helpful.
@Veketti: Be sure the LED has built in current limiting resistor.
Instead of NPN you could use a N channel logic level MOSFET. (The benefit is: lower voltage drop = lower dissipated power, about no PIC pin current. )
I don't think you have a negative wire. Instead you have 0V (which is ground), +5V and +12V wires.
DO NOT use +12V for the transistor or for the LED if you use a PNP transistor.
Why do you power the LED from +12V?
Did you try using the PIC output to directly drive the LED to 0V or +5V directly through a series 120 ohm resistor?
Thanks, I missed that. A blinding bright 3W LED.
I was concerned about the PNP transistor, LED and power supply being upside down with grid lines all over the place.
Alright, I'll use n-channel fet IRF510 which I have few extra instead.
Sorry, still bit unclear to me that is there possibility to use n-channel fet or NPN transistor between +12V and load? At least in the first place I wasn't able to make it work with IRF510.
Thank you all and sorry for my ignorance, I wasnt aware of these logic level fet's which turns on on lower voltage. Thought that they're all the same 4V Vgs. Just ordered bunch of IRL's.