# Combining 339 Dark Sensor Circuit with Counter Circuit

#### CoachKalk

Joined Sep 20, 2011
141
Sgt Wookie/elec mech (others too of course, but you 2 have been guiding me through this the most),

After my screw up ordering the incorrect 7 seg displays, I decided to order the correct CA displays and wait patiently for them to arrive. Instead of going with the .3", I decided to make the strike counter more visible and ordered the 1.0" displays from Mouser.

Per Sgt Wookies suggestion, I also have switched from using a 9V battery during the debugging to a regulated power supply. One point to note is my regulated power supply is 12V, not the 9V previously referenced.

I have updated the circuit below based on my current power supply and the fact that I am using larger displays. I tried to read over past threads, both involving my project and others, and have tried to adjust components accordingly.

First, based on the fact I am not using the low current displays, I inserted the ULN2804 between the 4543 and the resistors (the same set-up I plan to use on the extra large 5" displays). Second, I adjusted the pull up resistors (R6, R11-R13) to 3.3K (used to be 1.8K). I found a thread where Sgt Wookie provided/suggested an equation so I jumped in and used it for this calculation.

I have built this circuit with the following mods: Only using U1a and I have a LED being lit when the light is blocked as a visual reference.

I would like to explain what is happening in the hope that someone can help troubleshoot my issues. Make no mistake, I have tripple checked the connections so I hope it is not that "type" of a screw up.

When I plug in the power supply, the displays range from 2 displays blank, 1 with a ZERO, 2 displays blank, 1 with a 3. When I cover the LDR, the reference LED lights up, but there is only a slight flicker on the displays and then the one that is lit goes out. I am using a wire at the MR of the 4543 and when I touch it to the positive rail, the displays flicker and the 1 display that was on at first come back on (used to be a ZERO, now a 3?)

Any suggestions would be appreciated. Certain places to check with my meter to see if componets are whacked? It seems like my 4553/4543 is not responding to the 339 at all - or not getting to the displays? As mentioned above, the Vcc was 9V and is now 12V because of what was available to me. Please let me know if other adjustments are necessary and/or where to start troubleshooting this baby.

Thanks everyone.

#### SgtWookie

Joined Jul 17, 2007
22,221
Is the 3.7v @ 30mA the maximum specification, or typical? You don't want to use the maximum specification. With the 470 Ohm resistors, 12v supply, 3.7v Vf and the ~0.7 Vce drop on the Darlingtons, you'll get about 16mA current per segment.

7 x 16mA ~=114mA when all 7 segments are lit, which means you need 11.4mA base current on the 2N2907 transistors. Rbase = (Vcc - Vbe) / desired_current = (12-0.8)/11.4mA = 982.4 Ohms. 1k Ohms is close enough. 3.3k Ohms is far too high.

Inserting the ULN2804 means that you inverted the 4543's output logic. You may need to connect Ph to GND instead of Vcc. Ph inverts the logic for the output of the 4543.

#### CoachKalk

Joined Sep 20, 2011
141
SgtWookie - THANK YOU for being around your puter - even if you disappear, now I have something to work on ...

Is the 3.7v @ 30mA the maximum specification, or typical? You don't want to use the maximum specification. With the 470 Ohm resistors, 12v supply, 3.7v Vf and the ~0.7 Vce drop on the Darlingtons, you'll get about 16mA current per segment.

7 x 16mA ~=114mA when all 7 segments are lit, which means you need 11.4mA base current on the 2N2907 transistors. Rbase = (Vcc - Vbe) / desired_current = (12-0.8)/11.4mA = 982.4 Ohms. 1k Ohms is close enough. 3.3k Ohms is far too high.
The datasheet has 3.7 V typical and 30mA under absolute max.
Do your calculations regarding the 2N2907's only impact the 3 2N2907's coming from the 4553? Is the 3.3K resistor up at the 339 ok?

Inserting the ULN2804 means that you inverted the 4543's output logic. You may need to connect Ph to GND instead of Vcc. Ph inverts the logic for the output of the 4543.
Of all the things I am slowly picking up, this was absolutely NOT one of them. I will make that switch per your suggestion as give it a go.

Thank you very much!

#### SgtWookie

Joined Jul 17, 2007
22,221
The datasheet has 3.7 V typical and 30mA under absolute max.
Well, you should be OK with 16mA through each segment then. You STILL haven't said what the current is when the Vf = 3.7v.

Do your calculations regarding the 2N2907's only impact the 3 2N2907's coming from the 4553?
Yes, R11 through R13 need to be changed to 1k resistors.

Is the 3.3K resistor up at the 339 ok?
Yes, it needs to stay at 3.3k. If you decrease it, the 339's won't be able to sink the current.

Of all the things I am slowly picking up, this was absolutely NOT one of them. I will make that switch per your suggestion as give it a go.
It's kind of difficult to pick that up from the TI datasheets.
It's much easier to see in the Philips/NXP datasheet for the HEF4543B.

If one display is staying "stuck" on and the others dark, suspect the timing cap on the 4553, or maybe pin 3 or 4 is shorted to +V or ground.

#### CoachKalk

Joined Sep 20, 2011
141
Well, you should be OK with 16mA through each segment then. You STILL haven't said what the current is when the Vf = 3.7v.
Sorry about that - missed it the first time - 20 mA @ 3.7 Vf

Yes, R11 through R13 need to be changed to 1k resistors.

Yes, it needs to stay at 3.3k. If you decrease it, the 339's won't be able to sink the current.
Good deal - that is what I did.

If one display is staying "stuck" on and the others dark, suspect the timing cap on the 4553, or maybe pin 3 or 4 is shorted to +V or ground.
I will check/replace the cap on the 4553. It isn't even that 1 is stuck on. The one that does light up fades to off in approx. 4 secs. Then nothing. If I unplug/replug the power supply, the same display lights up - then fades to off. Over and over and over again!

I just switched the 3.3K's to 1K and the Ph to ground - same exact result. It seems as though from the 339 output on, the train is stopping - at least with respect to the 2N2907 path. My reference LED lights up fine when the LDR is dark. I took a look at the 339 datasheet and it states the Min Output Sink Current is 6 mA with the typical being 16 mA. I know from a different thread I read when I searched the forum, you had mentioned staying below the 6 mA - targeting around 3.5mA. In that thread, I thought the 6mA figure was the max and/or typ. Based on what the datasheet info, should I target a figure slightly above 6 mA? HELP! I am now more confused that before.

At what point do I just start replacing components 1 by 1? Does that even make sense to do?

#### Ron H

Joined Apr 14, 2005
7,014
I just discovered this thread. Too bad you didn't just add on to the previous one. I subscribe to the threads that I contribute to. If you start a new one on the same topic, I may or may not stumble across it.
I'm not implying that Wookie and others are not competent. It's just that more eyes on a problem may generate more ideas.
I don't think you need the two transistors following the comparators. The 4553 has a Schmitt trigger on the clock input, so they are redundant.
Edit: The comparators can't supply enough current to light an LED unless you have one that can be driven with 4-5 mA or less.

#### Attachments

• 262.9 KB Views: 16
Last edited:

#### CoachKalk

Joined Sep 20, 2011
141
Ron,

I am not sure when to start a new thread or continue the old - this particular project has evolved quite a lot and I figured I would start fresh when I changed to the 339 comparator. Either way, I do appreciate any and all help offered.

Do you anticipate feeding the 4553 directly as a solution (4553/4543 responding to the 339/LDR) or are you just saying that using the 2 transistors isn't necessary? I am still not sure on the current specs of the 339 because the datasheet states 6 mA min and 16 mA typical.

I hope that this circuit (with these components) is a possibility. Even if I have to add a few other components to get the displays to work.

I am curious ... what type of circuit/feature is usually used with the 4553/4543 setup to feed into the 4553 clock pin? Just a crystal/4060/4013 clock setup only?

I just discovered this thread. Too bad you didn't just add on to the previous one. I subscribe to the threads that I contribute to. If you start a new one on the same topic, I may or may not stumble across it.
I'm not implying that Wookie and others are not competent. It's just that more eyes on a problem may generate more ideas.
I don't think you need the two transistors following the comparators. The 4553 has a Schmitt trigger on the clock input, so they are redundant.
Edit: The comparators can't supply enough current to light an LED unless you have one that can be driven with 4-5 mA or less.

#### Ron H

Joined Apr 14, 2005
7,014
Ron,

I am not sure when to start a new thread or continue the old - this particular project has evolved quite a lot and I figured I would start fresh when I changed to the 339 comparator. Either way, I do appreciate any and all help offered.

Do you anticipate feeding the 4553 directly as a solution (4553/4543 responding to the 339/LDR) or are you just saying that using the 2 transistors isn't necessary? I am still not sure on the current specs of the 339 because the datasheet states 6 mA min and 16 mA typical.

I hope that this circuit (with these components) is a possibility. Even if I have to add a few other components to get the displays to work.

I am curious ... what type of circuit/feature is usually used with the 4553/4543 setup to feed into the 4553 clock pin? Just a crystal/4060/4013 clock setup only?
The interface between the 339 and the 4553 should work in your application as I drew it. If you want to light an LED at the output of the 339, you will have to limit the total 339 sink current to about 6mA, as you pointed out. This could be an LED and a series resistor from the 339 output to Vcc running at 6mA, with a 100k resistor added from the 339 output to Vcc, to ensure that the output pulls up to Vcc in a timely fashion.

I don't think there is a "usual" way of driving the clock input. It all depends on the application.

#### CoachKalk

Joined Sep 20, 2011
141
UGH!!!

I absolutely cannot get the displays to do anything other than flash then fade out. I have wired the circuit per Ron H's mods, checked the cap on the 4553, changed out the 4553 and 4543 and still only get flashing displays. One difference now is that all 3 flash the number 3, then they start a staggered fade - DS3 first, then DS2 then DS1 - all blank.

Just because I am grasping at straws, I put the Ph of the 4543 back to Vcc (had changed it to Ground per SgtWookie) and the only change was instead of flashing 3's, the displays flashed a "wrong sided 1 (e and f segs).

I do not know what to look at next. Any help? Anyone?
The interface between the 339 and the 4553 should work in your application as I drew it. If you want to light an LED at the output of the 339, you will have to limit the total 339 sink current to about 6mA, as you pointed out. This could be an LED and a series resistor from the 339 output to Vcc running at 6mA, with a 100k resistor added from the 339 output to Vcc, to ensure that the output pulls up to Vcc in a timely fashion.

I don't think there is a "usual" way of driving the clock input. It all depends on the application.

#### SgtWookie

Joined Jul 17, 2007
22,221
You have something shorted out somewhere.

Find it.

#### Ron H

Joined Apr 14, 2005
7,014
You show a connection to vcc (pin 16, I assume) on both ICs, but you don't seem to show ground on pin 8 of either one. Are they connected? Missing grounds can cause the symptoms that you see.

#### thatoneguy

Joined Feb 19, 2009
6,359
SgtWookie and elec mech,

First, I am sorry about being so confusing with my posts. I know both circuits I have been asking about involve the 4553/4543 with 7 seg Displays, so it doesn't help matters.

I am working on 2 separate circuits for the same overall "BIG" project.

Circuit Number 1
Dark Sensor with 3 Small .3" 7seg Displays
This circuit will not need the massive 24V supply for the displays like my "Seconds Clock" circuit. When the LDR's go dark, the displays will keep count of how many times it happens. .3" Displays are planned for the final circuit.

Basically, it looks like I screwed up when I got the small displays from radio shack - I think my RS only carries CC displays. I completely missed that highly important detail. If I can make the stupid CC displays that I bought work that would be great, if not I can order the CA's. Again, this as no impact on the other, large display circuit you have been supporting me on.

Circuit Number 2
Seconds Clock with LARGE 7 Seg Displays
After a few seconds of panic, I checked and at least I ordered the correct (CA) 5" displays for this circuit. I should still be good with all of the help you have provided.

Thank you ... and now I return you to your regularly scheduled programming ...

For your second project, have you ever looked into microcontrollers? Examples are Basic Stamp (Spendy and slow), PICAxe (cheap and decent) or Arduino (mid priced and pretty good) for "ready to go" uC boards.

Just something to keep in mind, don't switch horses in mid stream on this project, but it may be something to consider for the timer part, or a future project. uC controlled projects still leave a lot of room for discrete circuits, but make many tasks easier, if you know how to program.

Just food for thought if you plan to do a good deal more in hobby electronics with displays/counters/ADC conversions, etc.

#### CoachKalk

Joined Sep 20, 2011
141
I started over with the wiring and must have had one (more?) things whacked even though I "thought" I checked everything many times.

Upon power up, I now get 3 solid zeros (flickering quickly - not sure is that is tied to the C1A-C1B cap?), but they all stay on.

Unfortunately, I still get no response from the displays when the LDR goes dark. Is it possible I toasted either the 4553 or 4543 if/when I had something wired wrong? Or would I have noticed the magic smoke?

I think I am closer than last night and I hate to say this again, but I have looked over the wiring again and nothing obvious jumps out at me. At least I have the displays looking correct, now just to get them to respond.

As I was checking each IC pin by pin, I did note that pin 14 (Overflow) on the 4553 is not tied to anything. Should it be? I think that is currently the only pin open (anywhere) in the circuit.

Thanks again everyone - sorry to be such a pain in the @.

#### Ron H

Joined Apr 14, 2005
7,014
Is the multiplex oscillator cap (C1A -C1B) really 1nF (.001uF)? If so, you shouldn't have any flicker.
You should post a schematic of what you currently have.
Do you have an LED monitoring the 4553 clock pin?

#### CoachKalk

Joined Sep 20, 2011
141
I will update my circuit and get it posted as soon as I can. I just went to my work station to check the cap and figured I would add the LED at the clock pin real quick. Powered up and covered the LDR - both the 339 output ref. LED and the clock ref. LED light up when the LDR goes dark.

As far as the C1A-C1B cap goes, good catch on your part, stupid on my part. I do not have electrolytic caps that low so I have to place several in series: 100 uF x .1 uF x .1 uF x .1 uF. I had missed the 3rd .1 uF. D'oh! No more flickering!

I know it hardly does any good without the actual circuit/pic to look at, but I will say I printed your suggested change (going directly to clock with 10K resistor) and have changed the 3.3K resistors at DS1, DS2 and DS# to 1K's. Also, per SgtWookie's other suggestion, the Ph on the 4543 is set to ground now, not to Vcc as the current circuit shows. I will get an actual updated circuit drawn up ASAP and add it the thread.
Thanks

Is the multiplex oscillator cap (C1A -C1B) really 1nF (.001uF)? If so, you shouldn't have any flicker.
You should post a schematic of what you currently have.
Do you have an LED monitoring the 4553 clock pin?

#### elec_mech

Joined Nov 12, 2008
1,500
I do not have electrolytic caps that low so I have to place several in series: 100 uF x .1 uF x .1 uF x .1 uF. I had missed the 3rd .1 uF. D'oh! No more flickering!
Electrolyic caps aren't made that low. Ceramic or mylar are and either will work fine.

As far as the display changing when the LDR is covered, I'd try removing the connection from the LDR circuit to the clock pin of 4553. Put a 10kΩ pull-up resistor on the clock pin and attach a N.O. momentary switch between the clock and ground. Now press the switch. Does the display change?

#### Ron H

Joined Apr 14, 2005
7,014
As far as the C1A-C1B cap goes, good catch on your part, stupid on my part. I do not have electrolytic caps that low so I have to place several in series: 100 uF x .1 uF x .1 uF x .1 uF. I had missed the 3rd .1 uF. D'oh! No more flickering!
You don't need an electrolytic. 1nF (.001uF) is not an electrolytic, and the series combination you listed is still 33nF (.033uF). The frequency of the scan oscillator is about 5kHz with a 1nF cap. With 33nF, it will be about 150Hz. I believe that, since the chip multiplexes 3 counters, the flicker frequency will be (150/3)=50Hz. This is barely above the persistence of vision threshold. I would not go higher than 10nF.

#### CoachKalk

Joined Sep 20, 2011
141
I thought the formula for caps in series was Ct = ((c1xc2xc3xc4)/(c1+c2+c3+c4))? That is what I was basing my caps on. I thought a regular cap is designated with 2 straight lines and an electrolytic is designated with 1 straight/1curved? (I should also note, in case you have missed it in my previous threads, I am a complete NOOB trying my best to muddle through this stuff. If something seems obvious to you, it probably isn't to me ...)

Once I updated my circuit, I realized that with your mod. of going straight to the clock, the LED I added is really checking the same thing as the one I already had been using as the 339 output ref LED.

Anyway, here is where the circuit stands now. I will work on hooking up a switch directly shortly and let you know the outcome. Thanks again for your help.

You don't need an electrolytic. 1nF (.001uF) is not an electrolytic, and the series combination you listed is still 33nF (.033uF). The frequency of the scan oscillator is about 5kHz with a 1nF cap. With 33nF, it will be about 150Hz. I believe that, since the chip multiplexes 3 counters, the flicker frequency will be (150/3)=50Hz. This is barely above the persistence of vision threshold. I would not go higher than 10nF.

#### CoachKalk

Joined Sep 20, 2011
141
Electrolyic caps aren't made that low. Ceramic or mylar are and either will work fine.
And I guess that is why I was struggling to find one ...

#### Ron H

Joined Apr 14, 2005
7,014
The series capacitor equation is

$$\frac{1}{\frac{1}{C_1}+\frac{1}{C_2}+{\dots}+{\fra{1}{C_N}}}$$

Do the math. It's not the same as the equation you posted.
You can come up with a product divided by a sum of products, but the reciprocal of a sum of reciprocals is much easier to calculate, at least on my HP reverse Polish notation calculator.