1

I'm trying to design a mood light system using 4 RGB LEDs which will be powered by an external 9V source and an Arduino for processing.

Link to Fritzing file

enter image description here

Part list:

As you can see, what I've attempted to do is:

  • connect each LEDs common cathode to ground
  • 9V to each (R)(G)(B) collector
  • Arduino PWM output to each (R)(G)(B) base
  • emitter to each (R)(G)(B) anode

What I was expecting is that the PWM output of Arduino would regulate the emitters voltage between 0~9V therefore being able to dim the LED with my pots.

What I have instead got is that the voltage is 0.7V short of what the base is receiving from Arduino and the voltage supplied to the collector is being ignored. In fact, I can even disconnect the 9V battery, and the LEDs would still be lit.

From a previous question, I believe this is emitter-follower behaviour?

Is there a way I can re-wire this and get the expected behaviour? Or will I need to get some different parts. I got given the wrong LEDs (common cathode instead of anode) but the shop isn't open for another few days to go get a replacement so I'm trying to make do with what I have.

Please ignore the lack of resistors between the emitter and LED. I have omitted them for simplicity.

Marko
  • 394
  • 2
  • 3
  • 11
  • Why are you driving the LEDs from the 9V supply? – Ignacio Vazquez-Abrams Jan 01 '14 at 06:35
  • Well firstly, to save on Arduino pins and second and more important, to avoid frying the Arduino by demanding too much power. I'm starting with 4 LEDs but will likely add more. – Marko Jan 01 '14 at 06:38
  • You could consider drawing from the Arduino's power rail instead; limiting each LED component to 5mA will leave room for a decent number of LEDs. Although that still won't solve the CC/CA issue. – Ignacio Vazquez-Abrams Jan 01 '14 at 06:43
  • When I click that link I get "Download this file for free using Tiny DM manager (exe app)" which I've got no intention of installing. You might be better posting the Fritzing schematic view, it should be a lot clearer than the breadboard view. – PeterJ Jan 01 '14 at 06:48
  • Thanks Ignacio, but any ideas on actually solving the mentioned problem? I don't see why I would limit the LEDs to 5mA when their continuous forward current is 20mA. – Marko Jan 01 '14 at 06:53
  • Sorry Peter, I just found the first free hosting I could find. There was a link at the top without an EXE installer when I saw it? It says "Download: LED Lamp.fzz" and it's a direct download. The schematic view is an absolute mess :( – Marko Jan 01 '14 at 06:58
  • The only real way to fix it is to rearchitect the circuit. Reducing the current increases component life, and 20mA LEDs are still fairly visible at 5mA. – Ignacio Vazquez-Abrams Jan 01 '14 at 07:22
  • @Marko, ahh yes I see the direct download button at the top. I'd scrolled down to the bottom to see what else was on the page which is where I saw the EXE download manager button. – PeterJ Jan 01 '14 at 07:22
  • @IgnacioVazquez-Abrams, I'm most happy with rearchitecting the circuit, however I do not plan on using the Arduino as a power rail so that I don't have to rearchitect it again in the future when I decide I want 10W LEDs to make Xmas lights ;) – Marko Jan 01 '14 at 07:26
  • You'll have to. You'll destroy those transistors. Anyways, ULN2803A. – Ignacio Vazquez-Abrams Jan 01 '14 at 07:28
  • @IgnacioVazquez-Abrams, of course :) Now, since I'm gonna be replacing them anyway to a PNP version I may as well get the big daddy ones you mentioned. – Marko Jan 01 '14 at 07:45
  • 1
    *"As you can see, what I've attempted to do is..."* No, we can't see since you didn't provide a schematic. Expecting people, especially those you are asking free help from, to decipher that silly diagram to understand the circuit is ridiculous. -1 – Olin Lathrop Jan 01 '14 at 12:41

2 Answers2

6

Things regarding a high side switching of a voltage higher than the control voltage are not as simple as they seem.
Take for example the following circuit controlled with an Arduino I/O pin enter image description here

When the I/O pin is LOW the voltage to the base will be 0, that means that the Vbe will be 9v and since it is >0.7v the transistor will be on.
When the I/O pin is HIGH the voltage to the base will be 5v, that means that the Vbe will be 4v and since it is >0.7v the transistor will also be on.
So basically that configuration can't work as a switch because the transistor will always be on.

In order to make a circuit like the above work properly you have to add a level translator that will actually drive the base with 0v and 9v (or whatever the collector voltage level is), a circuit like enter image description here

One alternative of a working single transistor high side circuit is an emitter follower like enter image description here

The problem is that in this case the emitter will follow the base voltage when the transistor is on so for 0 and 5v control voltage you will get 0 and 4.3v output irrelevant of the voltage connected to the collector (within transistor specs of course) which may ot may not suite your specific application.

Another alternative is to use a device like ULN2003/2803 but intended for high side switching. Such a device is UDN2981 which has 8 source drivers like the following and can be used as a high side switch controlled by TTL level logic. enter image description here

alexan_e
  • 11,070
  • 1
  • 28
  • 62
  • Hi Alexan, thanks for your answer. With your first suggestion (using a level translator), could you provide a bit more info, i.e. types of transistors to use? Thanks again – Marko Jan 02 '14 at 10:03
  • @Marko There is no specific selection criteria for the shown circuit as long as the devices are withing specs. The NPN current will be very low, just a few mA, if you don't have any available you can go with [2N2222](http://www.fairchildsemi.com/ds/PN/PN2222A.pdf) which is very common. The PNP current will depend on your load, for the LEDs you describe it's 20mA so it will be withing spec of any PNP you choose, for example [2N3904](http://www.fairchildsemi.com/ds/2N/2N3906.pdf). The resistors, I would go with something like R1=4K7, R2=1K, R3=10K but different values will work too. – alexan_e Jan 02 '14 at 10:24
1

Quickest solution is use PNP transistors for "high side" switching and invert your PWM timing. I keep a bag of 50 or 100 2N3904 (NPN) and 2N3906 (PNP) for these situations.

There is a good explanation here Switching 9V using a NPN transistor and an Arduino

You can try using a split supply. Remove the jumpers from the LEDs to ground. Take a second 9V battery and connect the + terminal to your system ground and the - terminal to the LEDs common. This forms a plus and minus 9V supply and lets the LEDs draw current from "below 0V". Move your current limit resistors to the collector side of the NPNs. I think this will work, and if not, shouldn't hurt anything.

C. Towne Springer
  • 2,141
  • 11
  • 14
  • Thanks for that. The link you posted was to my earlier question and although I got the first answer working I still got stuck. I will go ahead and purchase PNP transistors and try it out. Is it safe to assume that I just need to replace the transistors and reverse the PWM code? Everything else should work? – Marko Jan 01 '14 at 07:20
  • Yes, your current limit resistors are already between the transistor and the LED, which will be correct for the PNP. I would experiment. See if the LEDs go all the way off when the digital signal is high and if the transistors get warm or hot. Measure the voltage drop across the transistor when you are in the OFF state (signal high). This can mean it is not really OFF, and is dropping most of the V across the transistor. If the drop across the transistor and the resistor is around 5 to 7 volts (depends on the color of the red LED), the diode will shut off. – C. Towne Springer Jan 01 '14 at 16:52