LED sequencing problem

clwhitt

Joined Dec 23, 2009
16
It's a matter of balancing how much current the 4000 series CMOS IC's can source or sink, keeping in mind the current it takes to light the LEDs, along with what voltage is required to operate the logic portion of the circuit.

Even 2.2k Ohms was pushing it. With Vdd=12v, sourcing 4mA will cause the IC's output to drop a volt or two according to the datasheet.
I hope I'm not replying to a closed thread, but here goes anyway:

I've been building sequencers for Christmas lights using the 4017 for quite sometime, but had a request for a sequencer that would leave each previous channel on much as Oxbo is doing with his period counter. Similar to Oxbo, I've used current limiting resistors based on feel and success, rather than formulae. That has worked so far, until coming up with this project.
Largely built copying Oxbo's schematic, I find that I run into trouble when substituting triac drivers (MOC3011's) in place of LED's. Still LED's, their Vf and current specs vary a bit.
I tried using the formulae that SgtWookie has graciously offered, but it just doesn't work with the optoisolators. I suspect that is largely due to my lack of understanding in the current and voltage losses across the 4017. I just don't know how to read the datasheet to come up with what the Sarge has mentioned above.
Through trial and error, I found that a 22 ohm resistor (and boosting the power to 12v) on the first channel made everything work, but I wonder just how reliable this circuit is going to be. I'd rather run it at 5v as the schematic shows (and which worked fine with just LED's), but don't think I have enough power left on the other side of the second diode to do so.
Where am I going wrong here?

Chuck
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,210
This really should've been a new thread, with a link back to the original thread; it might get moved, so I'll just tack in a link back to this one to save our moderators a little work...

Original thread: http://forum.allaboutcircuits.com/showthread.php?t=21283

One problem is that the MOC3011 requires 10mA current through the emitter in order to trigger. The circuit will not work with that much of a load. You will need to use a different tactic; NPN transistors to sink current from the cathode of the MOC3011 emitter, and a resistor connecting the anode to Vcc.

Note that the MOC3011 is a triac driver, not a triac itself. If you try to use this with line voltage, you'll likely fry the MOC3011s.

Another problem related to safety is that it appears that you are switching the neutral line, not the hot line. Note that the wider blade/socket is the one the neutral wire goes to. Also, there is no fuse in the AC hot line.

I've marked up your schematic with the necessary changes. The NPN transistors could be 2N2222, 2N3904, 2N4401 - many general purpose transistors. Note that I have calculated the values based on a 5v supply.
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,210
Well, you're still going to run into problems; you copied Oxbo's earlier schematic. By the time OUT3 is trying to keep all of the transistors turned on, it's probably not going to work very well - if at all. I'd forgotten about that part.
 

clwhitt

Joined Dec 23, 2009
16
Well, you're still going to run into problems; you copied Oxbo's earlier schematic. By the time OUT3 is trying to keep all of the transistors turned on, it's probably not going to work very well - if at all. I'd forgotten about that part.
Is that because of the inability of the 4017 to sink the current? How do you figure the total load on the 4017, just add up the current usage downstream? If that's so, then my problem is understanding how to account for the voltage drop you mentioned across the 4017 in the current equation for the MOC's.
Would one of the LED driver chips that you mentioned earlier (msg#47 - ULN2004) make more sense here?
I will note that it does work as I have it breadboarded now, but am concerned about that small 22 ohm resistor on OUT1 passing too much current to the MOC3011 (50mA max limit, I think). This based on your earlier warning to Oxbo on driving the LED's too hard. And I'd rather use the 7805 (5V) regulator the schematic reflects instead of the 7812 (12V) I have plugged into the breadboard now.
Thanks for the safety advise, I'm not sure how it's wired up now (hot vs. neutral - I'm 150 miles from the project and can't check until Thursday), but I do at least have it fused (on each line), though it's not shown in the schematic. And I am using Q4015 triacs to carry the load, so the triac part of the MOC's should be OK.
Dumb question follows - why is neutral safer than hot on an AC line (because neutral is wired to ground in the breaker panel)?
 

SgtWookie

Joined Jul 17, 2007
22,210
Is that because of the inability of the 4017 to sink the current?
It has very limited source OR sink current ability. It's one thing if you're just driving a single LED or single series string of LEDs from the output; but if you're trying to source current to parallel strings - forget it. You need about 11mA-12mA through each MOC3011's emitter, and there is no way that a single 4017 output can source that much current. I don't think it'll even work for the total 6mA required by the new circuit I posted.

How do you figure the total load on the 4017, just add up the current usage downstream?
Basically, but it's more complicated than that. You also have the Vf of the diodes in the circuit to contend with. Using an AND or and OR gate as a buffer in each stage will help to keep the voltage/curret up, as each will only be driving one load plus the downstream logic.

If that's so, then my problem is understanding how to account for the voltage drop you mentioned across the 4017 in the current equation for the MOC's.
Each MOC needs 11mA-12mA to fire the emitter. That's why I changed it from a current source configuration, to a current sink using NPN transistors. The 4017 can source a couple of mA, but not 11-12mA for multiple LEDs.

Would one of the LED driver chips that you mentioned earlier (msg#47 - ULN2004) make more sense here?
Kind of overkill for this. What you need now is an AND or an OR gate to keep the current/voltage up.

I will note that it does work as I have it breadboarded now, but am concerned about that small 22 ohm resistor on OUT1 passing too much current to the MOC3011 (50mA max limit, I think). This based on your earlier warning to Oxbo on driving the LED's too hard.
That's far too much current for the LED or the 4017 to handle. The MOCs have a max recommended 16mA current through the emitter. The emitter has a typical Vf of 1.15v. I added on another 100mV for the Vce of the transistor when saturated, for a total of 1.25v.
Rlimit >= (Vsupply -Vf_LED) / DesiredCurrent
Rlimit >= (5v - 1.25) / 11.5mA
Rlimit >= 3.75 / 0.0115
Rlimit >= 326 Ohms. Hmm, I put 360 in the schematic, but that should be OK too.
3.75v / 360 Ohms = 10.41mA
3.75v / 330 Ohms = 11.36mA
Either would work.

And I'd rather use the 7805 (5V) regulator the schematic reflects instead of the 7812 (12V) I have plugged into the breadboard now.
5v should be OK, but you're going to need another AND or OR gate to cascade the signal.
Thanks for the safety advise, I'm not sure how it's wired up now (hot vs. neutral - I'm 150 miles from the project and can't check until Thursday), but I do at least have it fused (on each line), though it's not shown in the schematic. And I am using Q4015 triacs to carry the load, so the triac part of the MOC's should be OK.
OK, good.
Dumb question follows - why is neutral safer than hot on an AC line (because neutral is wired to ground in the breaker panel)?
Yes. The Neutral line is grounded at the breaker panel. Even under moderate loads, the Neutral line should be less than a couple volts away from ground. However, it is not a replacement for an actual ground wire. Whenever possible, use the actual ground as a chassis ground to protect the humans using the device. Neutral and ground should never be connected after leaving the breaker panel.
 

clwhitt

Joined Dec 23, 2009
16
5v should be OK, but you're going to need another AND or OR gate to cascade the signal.
As previously noted, I'm not home so I can not build this circuit, but knowing that I have some CD4073BE triple input AND gates, does this circuit look viable? Based on the 4073 datasheet that this chip can handle 500mW, I figured I could dump the transistors and drive the MOC's directly. Am I right?
I also assumed the output from the AND gate to be 5V, so I have a calculation of 5V-1.15V/0.0115 which puts me right around a 330 Ω resistor. Is that correct too?
What do the N and L notations stand for on the AC line?

I appreciate your help here, you obviously know far more than me about all this stuff. Thanks.

Chuck
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,210
As previously noted, I'm not home so I can not build this circuit, but knowing that I have some CD4073BE triple input AND gates, does this circuit look viable? Based on the 4073 datasheet that this chip can handle 500mW, I figured I could dump the transistors and drive the MOC's directly. Am I right?
Nope, sorry - not running from 5v.
Download Motorola/ONsemi's datasheet for the MC14001B Series. You'll see that when Vdd is 5v, the output voltage drops like a rock at even light loads.

I also assumed the output from the AND gate to be 5V, so I have a calculation of 5V-1.15V/0.0115 which puts me right around a 330 Ω resistor. Is that correct too?
Not from 4000-series CMOS outputs when Vdd=5v.

What do the N and L notations stand for on the AC line?
Neutral and Line, respectively.

I appreciate your help here, you obviously know far more than me about all this stuff. Thanks.
I've been at it a couple weeks longer than you have ;)
 

SgtWookie

Joined Jul 17, 2007
22,210
OK, here's another revision...

It's using your 4073 three-input AND gates.

I had to add a couple of 10k pull-down resistors past the diodes so the gates could discharge.

The MOC resistors are now 330 Ohms.

The transistor base resistors are now 3.9k Ohms.
 

Attachments

clwhitt

Joined Dec 23, 2009
16
Download Motorola/ONsemi's datasheet for the MC14001B Series. You'll see that when Vdd is 5v, the output voltage drops like a rock at even light loads.
I'm looking at the datasheet, but I'm not really sure that I can discern the data that shows the voltage drop. Looking at the textual "Characteristics" section it shows the output voltage (VOH) as 4.95-5.0 on a 5V input. Now VIH shows 3.5 to 2.25 volts - does this signify the voltage loss?
The graphs are another area I don't quite grasp - are they too showing voltage loss? And what's with the negative numbers in the current axes?

I'll breadboard the schematic you've modified when I get home on Thursday and let you know how it works out. Thanks again.

Chuck
 

SgtWookie

Joined Jul 17, 2007
22,210
I'm looking at the datasheet, but I'm not really sure that I can discern the data that shows the voltage drop. Looking at the textual "Characteristics" section it shows the output voltage (VOH) as 4.95-5.0 on a 5V input. Now VIH shows 3.5 to 2.25 volts - does this signify the voltage loss?
Nope - that's shown in the plots.
The graphs are another area I don't quite grasp - are they too showing voltage loss? And what's with the negative numbers in the current axes?
Negative numbers are when current is being sourced from rather than sunk to the device.

Here's the plot I was talking about:


See how it's for 5v power? I've marked the spot where the current source is for the 3.9k resistors; about -1mA. You'll lose about 0.5v from Vdd, and measure about 4.5v on the output pin. This is enough for the next stage to "see" a logical "1" as an input.

I'll breadboard the schematic you've modified when I get home on Thursday and let you know how it works out. Thanks again.

Chuck
Sounds good - have fun ;)
 

Attachments

clwhitt

Joined Dec 23, 2009
16
Nope - that's shown in the plots.

Negative numbers are when current is being sourced from rather than sunk to the device.

Here's the plot I was talking about:


See how it's for 5v power? I've marked the spot where the current source is for the 3.9k resistors; about -1mA. You'll lose about 0.5v from Vdd, and measure about 4.5v on the output pin. This is enough for the next stage to "see" a logical "1" as an input.
Thank you for that. I can definitely see how quickly the power loss adds up now. Wow, that's steep!

Chuck
 

clwhitt

Joined Dec 23, 2009
16
I've built and rebuilt the AND gate circuit multiple times and was never able to get all three circuits lit at once. At first I could get two of three circuits to light, but it eventually devolved into a standard three light sequence as if the AND gate was not there at all. I'm suspicious in how well the AND gate is working and have ordered some replacements from Mouser (as well as some OR gates).
In the meantime, I've rebuilt the circuit as I originally had it in my first posted schematic (MOC3011/Q4015 Triacs driven from the 4017 through diodes), except powered with 12V. As it did before, it works flawlessly. In measuring the current with my DVM at the third MOC3011 input, I would get a reading of about 3.4 on the 20mA scale with 2.2KΩ resistors, and 1.8 with 4.7kΩ resistors (with 4.7kΩ's the first circuit would go out when the the second and third lit, so I dropped the first MOC back to 3.9KΩ and now all three work OK).
Do the current readings equate to 34 and 18 mA's? It just seems to me that 3.4 and 1.8 would be too low for the MOC3011's. (The voltage at pin 1 on the MOC's, with the 4.7k/3.9kΩ resistor combination is 1.1V, which doesn't seem right to me either.)
Anyway, that's where I'm at now.
Chuck
 
Top