1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Why are you driving the LEDs from the 9V supply? \$\endgroup\$ – Ignacio Vazquez-Abrams Jan 1 '14 at 6:35
  • \$\begingroup\$ 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. \$\endgroup\$ – Marko Jan 1 '14 at 6:38
  • \$\begingroup\$ 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. \$\endgroup\$ – Ignacio Vazquez-Abrams Jan 1 '14 at 6:43
  • \$\begingroup\$ 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. \$\endgroup\$ – PeterJ Jan 1 '14 at 6:48
  • \$\begingroup\$ 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. \$\endgroup\$ – Marko Jan 1 '14 at 6:53
6
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ 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 \$\endgroup\$ – Marko Jan 2 '14 at 10:03
  • \$\begingroup\$ @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 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. The resistors, I would go with something like R1=4K7, R2=1K, R3=10K but different values will work too. \$\endgroup\$ – alexan_e Jan 2 '14 at 10:24
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – Marko Jan 1 '14 at 7:20
  • \$\begingroup\$ 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. \$\endgroup\$ – C. Towne Springer Jan 1 '14 at 16:52

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.