# LED Dimmer problem

Discussion in 'Electronic Basics' started by Allen Bong, Dec 21, 2005.

1. ### Allen BongGuest

Hi Group,

My friend designed a circuit to light up an LED when a switch is
pressed. The led lighted would be duplicated to another identical
circuit board via RS232 link (2400 b/s). When an LED is lighted, the
LED would flash at 1 Hz interval. One would acknowledge by pressing
the corresponding switch on the board. Once acknowledged, the LED
would be on permanently until another switch is pressed.

The switches and LED are arranged as 2 rows of 12 . Only one switch is
allowed per row so there can only be 2 LED lighted and 2 LED in
flashing condition.

After he completed the circuit and fabricated the PCB, he wanted to add
a dimmer so he could control the brightness of all the LEDs (the
circuit is used in a boat). As you can see from the circuit below, he
turned the LED on by sourcing the LEDs and all the LEDs were common at
ground through 220 ohm resistors. So what I did is gathering all the
cathods and connected them to the drain of a MOSFET BUZ71A. This
worked fine when the brightness is high. But when the LEDs were
dimmed, the permanent lighted LED danced with the flashing LEDs and I
couldn't find a simple solution to solve it.

If instead he had sinked the current to switch on the LEDs, I would
have combined all the anodes of the LEDs and connected them to a LM317
and supplying 2V to 5V to the LEDs. But that would be major work for
him and also rewriting the PIC software.

Can someone help?

.-------------------------------------------.
| |
| PIC |
'-------------------------------------------'
VCC VCC VCC
+ + +
pulsed dc at 1Hz | | |
| |LED |LED |LED
V -> V -> V -> V ->
-LED - - -
VCC | | | |
+ | | | |
| .-. .-. .-. .-.
| | | | | | | | |
.-. | |220 | |220| |220| |220
47K| | '-' '-' '-' '-'
| | | | | |
'-' o-----------+-----+------
| |D
| ||-+
.-. 100 ||<- MOSFET
50K pot| |<---|___|--||-+
| | |S
'-' |
| ===
| GND
.-.
| | DIMMER CIRCUIT
150K | |
'-'
|
===
GND
(created by AACircuit v1.28.6 beta 04/19/05 www.tech-chat.de)

Allen Bong

2. ### Ben JacksonGuest

Easiest way to do this is to make the PIC drive a varying duty cycle
on the LEDs (eg you are already scanning an array, just pause between
scans to get dimmer output).

Barring that, keep your FET, but drive it (to saturation, not with the
pot) with the PIC using an PWM output to get the same effect.

If nothing is free on the PIC, drive the FET with a 555 with a pot
controlled duty cycle.

3. ### RichardGuest

How about switching in one or more resistors in your cathode circuit? Using
a 3-position switch, you could add 100, 220, and 1000 ohms to progressively
dim the LEDs. If a mechanical switch won't work, how about a pushbutton and
using the PIC to drive 3 electronic switches to switch the resistors into
the circuit?

Richard

4. ### The Cheese MachineGuest

Feed the FET with a squarewave (freq high enough to stop flicker), vary
the mark/space ratio to give you brigtness control. A simple 555 will do
this.

TCM

5. ### Allen BongGuest

Easiest way to do this is to make the PIC drive a varying duty cycle
The LEDs are not connected as a matrix but one LED per port pin. The
switch is directly wired to the same port pin as the LED (I will submit
another post regarding this design) so this method is not applicable
here.
Though there are some ports not used, but the 2 pwm ports were
allocated for the SW and LED. I've asked him if he could spare me one
pwm port and his answer is negative. Guess his software is not that
modular. So another NO here.
This option seems to be the most convenient for me to implement. The
dimmer will be mounted on a small PCB and glue to the main PCB using
hot glue. 555s are readily available but I have to get a suitable
circuit and do some breadboarding before I commit to PCB.

Thank you very much for your feedback and your ideas really start me
thinking.
Merry Christmas & Happy New Year!!!!

Allen

6. ### Allen BongGuest

Hmmm... a 3-position 24-pole switch would cost a fortune. And I think
one can only find these parts in test gears like o-scopes and frequency
counters.

You mean electronic switches like 4066? 24 LED * 3 / 4 =18 pieces of
4066. That would occupy too much board space.

Thanks for your inovative idea anyway.

Allen

7. ### Allen BongGuest

Feed the FET with a squarewave (freq high enough to stop flicker), vary

the mark/space ratio to give you brigtness control. A simple 555 will
do
this.

TCM

This is the same idea suggested by Ben Jackson (refer option#3) and I
am going to try this out.

Thanks and regards.

Allen

8. ### RichardGuest

If you have already gathered all the cathodes ("So what I did is gathering
all the
cathods and connected them to the drain of a MOSFET BUZ71A"), you would
only need to connect that gathered connection to the the wiper on the swtch
instead of the MOSFET. Connect three differenct value resistors to ground
off the switch positions. Alternatively, three optical switches (for
example, PVA3324) may also work (that is what we used as a dimmer circuit on
a piece of equipment where we had to simultaneously dim 17 LEDs, so it may
work for you). The components were all surface mount, so not much space
required.

9. ### The Cheese MachineGuest

That would achieve a result no different from the FET/POT - the modulated
LED would affect the current in the others.

PWM is the easy way to go, whether by a 555 or extra code in the PIC. If
this is a one-off I'd go the 555 route for simplicity.

TCM

11. ### petrus bitbyterGuest

Allen,

If you have two groups of LEDs, a flashing group and a non-flashing one, you
can control them separately by using a dual pot and two mosfets.

petrus bitbyter

12. ### Allen BongGuest

That would achieve a result no different from the FET/POT - the
modulated
LED would affect the current in the others.

PWM is the easy way to go, whether by a 555 or extra code in the PIC.
If
this is a one-off I'd go the 555 route for simplicity.

I totally agree with you. But it is very educative to learn something
new called PVA3324 optical switch too. Tks.

Allen

13. ### Allen BongGuest

You can get a wide duty cycle adjustment (5% to 95%) using an extra
diode with a 555 oscillator. Example is here titled 12 volt lamp
dimmer, using a pot.

http://ourworld.compuserve.com/homepages/Bill_Bowden/page6.htm#dimmer...

-Bill

This is exactly what I'd been looking for. The LM555 datasheet for
PWM schematics is rather incomplete.

Thanks very much.

Allen

14. ### Allen BongGuest

If you have two groups of LEDs, a flashing group and a non-flashing
one, you
can control them separately by using a dual pot and two mosfets.

petrus bitbyter

I am sorry I didn't explain the circuit very well and the schematic was
rather vague. The fact was that all 24 LEDs were connected to a port
pin each on the 16F877 but arranged as 2 rows of 12 on the front panel
only. We didn't use scanning mathod to light the LEDs and they were
not connected as 2 by 12 matrix.

Tks,

Allen

15. ### Bob MonsenGuest

You claim that the fixed LEDs are pulsing at 1Hz? That is probably because
the mosfet is being used as a resistor. In order to dim the LEDs, you need
to set the resistance with the gate voltage. Sadly, this is just
the same as using a pot, meaning that the pulsing LED changes the
current through the resistor, changing the voltage at the other

The other problem with the circuit is that the range of adjustment is
going to be very fine, with a particular point that causes the brightness
to jump.

You can fix both of these problems by using a follower configuration
instead of the common source amplifier. Replace the MOSFET with a PNP
bipolar transistor. Then, the voltage at the cathodes will vary much less
with the flashing LED. The voltage at the cathodes will be adjustable
between 0.8V and 5V. Use a 1k pot, and dump the other resistors...

Vcc-----o-------- To Vcc on PIC
|
\ .--to cathodes ->
/ |<
\<-----|
/ |\
\ |
| |
GND-----o--------o

have at least 0.7V on them, due to the Vbe of the transistor. If this is a
real problem, then you can fix it by using an NPN transistor in a buffer
configuration with some PNP bipolar transistors:

VCC-----o--------o---------------o-----o-----.
| | | | |
| | pulsed | | |
| | |LED |LED |LED |LED
| | V -> V -> V -> V ->
| | - - - -
| | | | | |
| | | | | |
| 100 .-. .-. .-. .-.
| | | | | | | | | |
| .--o--. | |220| |220| |220| |220
| | | '-' '-' '-' '-'
.-. e e | | | |
50K pot| |<--b PNP b-----o-----+-----+------
| | c c |
'-' | | |
| | | c
| o-----)-----b NPN
| | | e
| 10k 10k |
| | | |
| | | |
| | | |
GND-----o-----o-----o------'

While the circuit is far more complex than the alternatives above, it will
allow you to set the voltage at the cathodes far better than your
amplifier scheme, allow voltages down to nearly 0 allowing full
brightness, and will prevent almost all of the crosstalk between the LEDs.

--
Regards,
Bob Monsen

Patricia's nature was an endless wish to make other people as happy as
she was.

16. ### Allen BongGuest

You can get a wide duty cycle adjustment (5% to 95%) using an extra
diode with a 555 oscillator. Example is here titled 12 volt lamp
dimmer, using a pot.

http://ourworld.compuserve.com/homepages/Bill_Bowden/page6.htm#dimmer...

-Bill

I have constructed your circuit on a strip board and tested with 8
LEDs. It works on my first trial.

The brightness disappeared after turning 40% on the pot and no flicker
was noticeable. I have to trim the top 1K resistor higher so that the
brightness only disappears until the pot has reached the end.

The diode doesn't have to be 1n400x. I substituted it with a 1n4148
and it also worked. It was magical to see how the duty cycle drops to
50% if the diode was disconnected.

Allen

17. ### Allen BongGuest

You claim that the fixed LEDs are pulsing at 1Hz? That is probably because
Yes, that's right. The reason I didn't use a pot was because we can
find a wire-wound
50 ohm pot in the town we live in. The same reason for using BUZ71A
(7A mosfet) as
I can't find anything smaller than that.

Vcc-----o-------- To Vcc on PIC
|
\ .--to cathodes ->
/ |<
\<-----|
/ |\
\ |
| |
GND-----o--------o

Didn't try out this one but as you said the drop across the CE is 0.8V
which is unacceptable.
The same reason I turned to MOSFET which has a drop of <0.1V when fully
turned ON.

VCC-----o--------o---------------o-----o-----.
| | | | |
| | pulsed | | |
| | |LED |LED |LED |LED
| | V -> V -> V -> V ->
| | - - - -
| | | | | |
| | | | | |
| 100 .-. .-. .-. .-.
| | | | | | | | | |
| .--o--. | |220| |220| |220| |220
| | | '-' '-' '-' '-'
.-. e e | | | |
50K pot| |<--b PNP b-----o-----+-----+------
| | c c |
'-' | | |
| | | c
| o-----)-----b NPN (Q3)
| | | e
| 10k 10k |
| | | |
| | | |
| | | |
GND-----o-----o-----o------'

Yes, I tried this circuit and it works well. I use 2n2907 for the 2
PNP but different NPNs
for Q3 have different results.

I took 2 voltages across CE of Q3. One when Q3 is fully conducting and
one when the LEDs are dimmed.
The results are as follows:

Q3 fully ON LEDs
dimmed
--------------------------------------------------------------------------------------------------
2n3019 1.44V 2.13 -
2.15V
2n3053 0.48V 2.16 -
2.19V
TIP31 0.1V 2.26
- 2.29V

Only TIP31 can get almost 0V as you mentioned. I'll also tried
Darlington NPN (2SD768) tomorrow as it is getting too
late now. Does the gain of the PNP matters? There is about 100mA
flowing through Q3 when all the LEDs
were ON at startup. A TIP31 would be overkill.

Cheers.

Allen Bong

18. ### Bob MonsenGuest

OK. However, adjusting the values of the 220 ohm resistors in the original
circuit can compensate for this problem.
Your table looks wrong. The 2N3019 has a Vce(sat) of between 0.1 and 0.5V,
so there is probably something wrong with the transistor, perhaps the beta
has been compromised, or you have it in backwards. If not, then you might
want to decrease the size of the pot to see what happens (if you are
curious). There might be some edge case in the circuit that you are
falling into with this particular transistor.

You can use a 2N4401 at the current your require, so I would go with
that, since it has a fairly small Vce(sat). Also, I would increase
the 100 ohm common resistor to 1k. You could probably go up to 4.7k with
no problem. It was set to 100 because I didn't know how much current
your Q3 would need to pass. Having it that low can cause temperature
differences on the transistor, leading to inaccuracy (not that it is very
accurate anyway...

--
Regards,
Bob Monsen

It would be a waste of breath to tell a man who believes in guns that
you've got something better.

19. ### Allen BongGuest

Didn't try out this one but as you said the drop across the CE is 0.8V
OK. However, adjusting the values of the 220 ohm resistors in the
original
circuit can compensate for this problem.
========================

This at least I'll try on a breadboard.

======================
Your table looks wrong. The 2N3019 has a Vce(sat) of between 0.1 and
0.5V,
so there is probably something wrong with the transistor, perhaps the
beta
has been compromised, or you have it in backwards. If not, then you
might
want to decrease the size of the pot to see what happens (if you are
curious). There might be some edge case in the circuit that you are
falling into with this particular transistor.
================

To be honest, I didnt try the circuit on the real thing, but just on a
simulator. I was also surprised when I see the results as well. But
when I short the BC of 2n3019, the Vce did not drop vigorously as I was
expecting. It just dropped merely 0.15V to 1.29V.

Anyway I am going to try out the circuit below on various transistors
that I have .

VCC -------
+ | |
| | o
-------------| \
| \
| o \o
| | |
| --| |
| | |
| | |
| .-. .-.
| | | | |
| 100| | | |1000
.-. '-' '-'
10k | |<----| | |
| | | o-----o---
'-' | | |
| | | |
| | | |
| | |/ / \
| ------| (_/_)
.-. |> \_/
| | | |
100| | | |
'-' | |
| === |
| GND GND
|
===
GND
(created by AACircuit v1.28.6 beta 04/19/05 www.tech-chat.de)

to see if the simulator is lying to me.

The datasheet also stated that to get Vce(sat) on 2n3019, you need
Ic=150mA and Ib=15mA. I put an mA meter on the simulator and the
current is only 58+mA through Q3.

==============================

You can use a 2N4401 at the current your require, so I would go with
that, since it has a fairly small Vce(sat). Also, I would increase
the 100 ohm common resistor to 1k. You could probably go up to 4.7k
with
no problem. It was set to 100 because I didn't know how much current
your Q3 would need to pass. Having it that low can cause temperature
differences on the transistor, leading to inaccuracy (not that it is
very
accurate anyway...

======================================

I have only 1 or 2 2n4401 but plenty of 2n3019 and 2n4033. So I would
give the 2n4401 a try this weekend to construct it on breadboard.

On the simulator, changing the pot resistance down to 10K doesn't
change anything with the 3019. I also change the 2 10K resistors to
4.7K and it got worse. Changing the 100 ohm to 1k didn't have much
influence on the 3019 too.

Cheers and Merry Christmas.......

Allen Bong

20. ### Allen BongGuest

Hi Bob,

======================

Your table looks wrong. The 2N3019 has a Vce(sat) of between 0.1 and
0.5V,
so there is probably something wrong with the transistor, perhaps the
beta
has been compromised, or you have it in backwards. If not, then you
might
want to decrease the size of the pot to see what happens (if you are
curious). There might be some edge case in the circuit that you are
falling into with this particular transistor.
================
After buying some 2N4401 & BC337 yesterday I tried out the circuit on a

have the results shown as below:

Q3 fully ON LEDs dimmed
------------------------------------
2n3019 0.12-0.18V 2.98 - 3.07V
2n4401 0.13-3.20V 3.05 - 3.12V
BC337 0 -0.02 2.91 - 2.97V

All 3 transistors worked well in the circuit. I also measured the Vbe
when Q3 was

fully turned ON and I got the values of 0.73-0.74 volts for all the 3
Tr. Can't

understand why it differed so much on the simulator. I'm going to down
another one to

try out the circuit again!

=====

You can use a 2N4401 at the current your require, so I would go with
that, since it has a fairly small Vce(sat). Also, I would increase
the 100 ohm common resistor to 1k. You could probably go up to 4.7k
with no problem. It was set to 100 because I didn't know how much
current
your Q3 would need to pass. Having it that low can cause temperature
differences on the transistor, leading to inaccuracy (not that it is
very accurate anyway...

===================

I thought that I still have some 2N4401 but when I checked into my
spare part box, I

noticed that they were actually 2N4403. After getting some new 2N4401,
the circuit

finally worked as it should be.

In the datasheet, the Vce(sat) for 2N3019 was measured at Ic=150mA when
Ib=15mA. But I

can Q3 to saturate at a much lower current. Was the Vce(sat)
controlled by Ib or Vbe?

Thanks so much for helping me to get my circuit working. Not
forgetting Bill Bowden's 555 PWM and others who posted.

Best regards.

Allen Bong