LED Dimmer problem

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 ||

Reply to
Allen Bong
Loading thread data ...

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.

--
Ben Jackson

http://www.ben.com/
Reply to
Ben Jackson

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

Reply to
Allen Bong

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

Reply to
Allen Bong

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

Reply to
Allen Bong

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

Reply to
Richard

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.

formatting link

-Bill

Reply to
Bill Bowden

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

Reply to
The Cheese Machine

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.

Reply to
Richard

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

Reply to
Allen Bong

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.

formatting link

-Bill

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

Thanks very much.

Allen

Reply to
Allen Bong

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

Reply to
Allen Bong

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

Reply to
The Cheese Machine

"Allen Bong" schreef in bericht news: snipped-for-privacy@g47g2000cwa.googlegroups.com...

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

Reply to
petrus bitbyter

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 LEDs, causing your flash.

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 ->

/ |< \\ V -> V -> V ->

| | - - - - | | | | | | | | | | | | | 100 .-. .-. .-. .-. | | | | | | | | | | | .--o--. | |220| |220| |220| |220 | | | '-' '-' '-' '-' .-. e e | | | |

50K pot| |
Reply to
Bob Monsen

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.

formatting link

-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.

Thanks for your great circuit!

Allen

Reply to
Allen Bong

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 ->

/ |< \\While the circuit is far more complex than the alternatives above, it will

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

Reply to
Allen Bong

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.
Reply to
Bob Monsen

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 | | \\_/ | | | | 100| | | | '-' | | | === | | GND GND | === GND (created by AACircuit v1.28.6 beta 04/19/05

formatting link

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

Reply to
Allen Bong

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 breadboard and

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

Reply to
Allen Bong

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.