Combining 339 Dark Sensor Circuit with Counter Circuit

CoachKalk

Joined Sep 20, 2011
141
I have gone through my many pages of notes and printed info from threads on this forum that have been offered for my project of a dark sensor circuit that will use a counter circuit to count the number of time the LDR's go dark.

Hopefully the scanned image I have attached will be clearer and provide for the ability for the correction of mistakes.

I have tried to combine all of the suggestions I have received and put everything together so I know if I have understood all of the info provided. I expect my remaining components to arrive tomorrow so I will be jumping in very soon.

I tried to copy the circuit Ron H. provided as an example when I asked about using all 4 comparators in the 339. I do have a question about the 4 outputs though. After he posted his circuit, I went to my proto board and jumped my 10K pot to a second comparator and added a second LDR/resistor combo for the second comparator. Because I didn't know any better, I just connected the outputs from the 2 comparators I had setup. I only used the 1 pull-up resistor and 1 resistor into the base of the 3906. It seemed to work great. I alternately covered both LDR's and each one, when covered separately, caused the buzzer to sound.

Obviously his suggestion and my attached circuit handles each output separate and they meet up "down the road". Will either way work? Or did I just get lucky in my setup?

The major assumption on my part is that I can just "swap" out the buzzer/LED portion of my proto with the 4553/4543 counter circuit. I would appreciate some feedback on what I have shown - how well did I combine the overload of info?

Thanks

Motardo

Joined Sep 21, 2011
22
A potentional problem with the circuit is the way the clock is triggered. The 4553 uses a falling edge on the clock pin to advance the count. I think your circuit doesn't really have a way to pull the clock input down; the 3906's will pull it high when they are on, but otherwise it's just kind of floating.
You could add a pull-down resistor from the clock input to ground, but even then, the falling edge wouldn't occur until the 3906 switched back off. The count would advance the instant light returned to the LDR, but I think you want the count to advance the instant light is interrupted?
Maybe OR the four outputs to trigger a one-shot that sends a nice falling edge pulse to the 4553 clock?

SgtWookie

Joined Jul 17, 2007
22,221
Here's a possible fix which addresses Motardo's good catch:

I just used an NPN to invert the output.

Attachments

• 54.8 KB Views: 172

CoachKalk

Joined Sep 20, 2011
141
Here's a possible fix which addresses Motardo's good catch:

I just used an NPN to invert the output.
Thanks to both of you for your help. In reality, this is not a high importance set-up, just a way to track how many tiimes the laser gets blocked. It probably wouldn't be earth shattering if the counter didn't register until the LDR lit back up. But, if Sgt. Wookie's suggestion fixes that glitch, I'm game. Just a quick question about the fix - what is it about using the NPN that fixes the problem? It seems like the clock pin would still go high when the LDR is blocked, but I don't see what the new setup does to "pull" it low again. It seems just like the PNP version - but I am a complete newbie so please explain the difference realizing that fact.

Also, can anyone offer some input on my question about whether all of the 3906's are necessary? I am just looking ahead to my actual build and if I can minimize components hopefully I can minimize the number of screw ups I make with connections.

Thanks everyone.

SgtWookie

Joined Jul 17, 2007
22,221
Just a quick question about the fix - what is it about using the NPN that fixes the problem? It seems like the clock pin would still go high when the LDR is blocked, but I don't see what the new setup does to "pull" it low again.
The NPN transistor inverts the output from the PNP's & wired-OR diodes. If that's high, the NPN collector's output will be low; otherwise high.

It seems just like the PNP version - but I am a complete newbie so please explain the difference realizing that fact.
Since there was a diode drop between the PNP's collector and the OR'ed output, using another PNP transistor wouldn't work as well. The PNP collectors can source current, but can't sink it. The NPN needs current sourced to it to turn on; they are complementary.

Also, can anyone offer some input on my question about whether all of the 3906's are necessary? I am just looking ahead to my actual build and if I can minimize components hopefully I can minimize the number of screw ups I make with connections.
Actually, you only need a single PNP. If any of the comparator outputs are conducting, it'll turn on a single PNP transistor.

CoachKalk

Joined Sep 20, 2011
141
I have updated the dark sensor/counter circuit based on Sgt Wookies addition of the NPN and I removed the extra PNP's - all outouts using 1 now.

I didn't know how to represent the connectors, but all of the LDR's will be connected with male/female connectors suggested by elec mech in a different thread.

My last big question is the best way to power this. From what I have read, I am leaning toward using a wall wart. As many people have mentioned - and I have confirmed tonight - a quick look in the garage yielded 2 in no time at all. Neither of the 2 I found would work very good for this as the outputs were 20V and 24V. Even though I know I will need to regulate the output, both of these seem like overkill.

Based on what I have found discussed on the board, I am assuming I will need to add a regulator because the actual output voltage can be a bit of a crap shoot. I would appreciate any suggestions on output specs I should be looking for. I did forget to label the LED's in the circuit, but these will be the small, Radio Shack sized displays. Should I look for a 12V output and regulate it to 9V?

Thanks again.

SgtWookie

Joined Jul 17, 2007
22,221
You don't need the diode between the 2N3906 and the junction of the two 10k resistors.
It would be better to move the 10k resistor to ground next to the base of the transistor.

Don't worry about showing the connectors for the LDR's for now.

It's too late (early?) for me to be talking about power supplies right now.

CoachKalk

Joined Sep 20, 2011
141
You don't need the diode between the 2N3906 and the junction of the two 10k resistors.
It would be better to move the 10k resistor to ground next to the base of the transistor.

Don't worry about showing the connectors for the LDR's for now.

It's too late (early?) for me to be talking about power supplies right now.
I took out the diode and changed the location of the resistors as well. I think I have all bypass capacitors noted. Now I just need the last of my components to be delivered - hopefully tomorrow. My first attempt will be based on the attached circuit so if anyone sees any show stopping issues, please let me know.

Thanks

CoachKalk

Joined Sep 20, 2011
141
I have the following circuit made up on a solderless protoboard with the following changes:
1. No SCR/PB's to start and stop - the 339 is direct to the Vcc.
2. Only 1 of the 339 comparators is being used - all others set to ground.
3. Only 2 7-seg displays will fit on my board so I have left off the 3rd (DS3 currently open)
4. Using a wire at MR in the 4553 (thinking I would just touch Vcc to reset for proto)
5. Added a red LED for feedback purposes/to help troubleshoot.

Stupid Question: Where/how does the 2n3906 connect into the 7 seg displays? The displays have 10 pins total (7 segs, dec. pt, 2 common cathodes). Help... please ...

SgtWookie

Joined Jul 17, 2007
22,221
Oh, boy - you bought common cathode displays, and this circuit is for common anode displays.

Didn't we go over that before?

This doesn't mean the situation is hopeless - but you're going to need seven more PNP transistors to invert the logic for the a through g outputs of the 4543, and three NPN's to invert the logic from the three PNP's you have.

You'll also need more current limiting resistors for the bases of those extra transistors.

What is the part number of your common cathode displays?

Last edited:

elec_mech

Joined Nov 12, 2008
1,500
Stupid Question: Where/how does the 2n3906 connect into the 7 seg displays? The displays have 10 pins total (7 segs, dec. pt, 2 common cathodes). Help... please ...
CoachKalk, are you sure you have two common cathode pins? What part number did you order from Futurelec?

We need to verify what kind of 7-segments you have before we can advise you on hooking them up. Using CC displays on a CA circuit won't work and may cook the displays.

As far as mounting and hook up, I like to put my 7-segment displays on boards too, but I've found with large displays, it just isn't practical since most readily available boards won't be big enough. I tape them together around the sides and back (within the open portions) using aluminum tape which you can buy at any hardware store in the plumbing section near the duct work. I often use ribbon cable with heat shrink and terminate the ends onto 0.1" male headers. I then solder female headers to the circuit board. In this way I can mount the display where I need it and place the circuit board elsewhere, in edition to having the ability to change displays and troubleshoot the board separately. Just my two cents . . .

CoachKalk

Joined Sep 20, 2011
141
elec mech - The circuit I am working on now is the easier of the two (I thought ). The 7 seg displays are small, .3" common cathode displays from radio shack (PN 276-075). I figured I would get standard sized displays working first, then jump to my large display Seconds Time circuit. This circuit is the dark sensor/strike counter.

Thanks

CoachKalk, are you sure you have two common cathode pins? What part number did you order from Futurelec?

We need to verify what kind of 7-segments you have before we can advise you on hooking them up. Using CC displays on a CA circuit won't work and may cook the displays.

As far as mounting and hook up, I like to put my 7-segment displays on boards too, but I've found with large displays, it just isn't practical since most readily available boards won't be big enough. I tape them together around the sides and back (within the open portions) using aluminum tape which you can buy at any hardware store in the plumbing section near the duct work. I often use ribbon cable with heat shrink and terminate the ends onto 0.1" male headers. I then solder female headers to the circuit board. In this way I can mount the display where I need it and place the circuit board elsewhere, in edition to having the ability to change displays and troubleshoot the board separately. Just my two cents . . .

SgtWookie

Joined Jul 17, 2007
22,221
If those displays are indeed common cathode, they can still be used.

However, the connections get more complex.

See the attached. It's not the complete circuit, just the 4543/4553 and 7-segment display connections that need to be changed.

I am uncertain what voltage you're actually using for the display now (I think it's 24v) and I'm not certain about the display Vf @ current either.

I selected R8's value based on +24v LED supply, LEDs 11.5v @25mA/segment, and R1's value based on 24v LED supply.

[eta]
Rats, I thought you were using 12v for the rest of the circuit supply; that means R2 thru R7's values need to be changed.

You have so many threads going on about this project that I'm not sure where things are at the moment, and I don't have the time to go through all of them to try to sort it out.

Attachments

• 56.8 KB Views: 64
Last edited:

SgtWookie

Joined Jul 17, 2007
22,221
I posted before I saw your post, coach.

Here is the back of the package of the Radio Shack 7-segment displays:

You can see which pin is which. [eta] This also means that the pin numbers on the displays in the schematic I posted will not match the pin numbers on your displays.

You can test these displays using the diode test function on a multimeter. If your multimeter doesn't have a diode test function, you can pick one up at a Harbor Freight store for $3 to$8 depending on whether they're on sale or not.

Are your large displays common anode or common cathode?

Last edited:

SgtWookie

Joined Jul 17, 2007
22,221
Anyway, I don't know for certain what you are using for your LED supply. 20v? 24v? Is it regulated?

Are you going to be using 9v or 12v for the logic?

The 5" displays you bought - are they common anode or common cathode?

If the 5" displays are common anode, it doesn't make sense to monkey with the common cathode displays.

If the 5" displays are also common cathode, then the small displays could still be used to test things. However, you will need more current limiting resistors in between the additional seven PNP transistors' collectors and the displays themselves; either that or you will have to change the 7 resistors shown in the drawing, which kind of defeats the purpose of using the small displays for a test.

CoachKalk

Joined Sep 20, 2011
141
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 ...

SgtWookie

Joined Jul 17, 2007
22,221
OK, the circuit I basically threw together for lucky reply #13 above has pretty much the modifications you'll need to do. The pin numbers for the LEDs are wrong, of course.

Q7 through Q13 can be 3906's or 4403's instead of 2907's.
Likewise, Q1 thru Q3 can be 3904's or 4401's instead of 2222's.

But just to confirm - are you powering the entire dark circuit from 9v?
What are you using for the 9v supply; a regulated supply or a PP3 "transistor" battery? (the latter would be a poor choice).

Radio Shack usually carries a battery holder that takes eight AA cells; if powered using alkaline batteries, it puts out 12v; rechargeable NiCD or NiMH put out ~9.6v.

CoachKalk

Joined Sep 20, 2011
141
OK, the circuit I basically threw together for lucky reply #13 above has pretty much the modifications you'll need to do. The pin numbers for the LEDs are wrong, of course.

Q7 through Q13 can be 3906's or 4403's instead of 2907's.
Likewise, Q1 thru Q3 can be 3904's or 4401's instead of 2222's.
Great. Thank you very much. I know it is probably poor design to add so many components just because I screwed up my displays, but I will def. try your suggestion. I kind of just want to have something work other than my simple red LED!!!

But just to confirm - are you powering the entire dark circuit from 9v?
What are you using for the 9v supply; a regulated supply or a PP3 "transistor" battery? (the latter would be a poor choice).

Radio Shack usually carries a battery holder that takes eight AA cells; if powered using alkaline batteries, it puts out 12v; rechargeable NiCD or NiMH put out ~9.6v.
I hope this doesn't screw everything up, but yes and yes. My master plan is to use a power supply above 9V and regulate it down to 9V. I mentioned this project to my father-in-law and 2 days later I received a package in the mail FULL of old wall warts he had laying around. For proto purposes, I have just been using a 9V battery. I hope the only difference would be in the calculation of the resistors based on the actual supply voltage. Key word in the last sentence ... HOPE!

SgtWookie

Joined Jul 17, 2007
22,221
Well, the PP3 "transistor" battery will die quickly while testing, as the LED displays will draw a good bit of current.

You'll really be better off making the regulated wall wart supply 1st, and powering the circuit from that.

Otherwise, you'll wind up regulating a wall wart, and then finding out that it puts out less voltage than you thought, and then having to change a bunch of resistors again.

CoachKalk

Joined Sep 20, 2011
141
Suggestion noted and taken. I will get the power supply worked out/hooked up before starting on the LED's.

Thanks

Well, the PP3 "transistor" battery will die quickly while testing, as the LED displays will draw a good bit of current.

You'll really be better off making the regulated wall wart supply 1st, and powering the circuit from that.

Otherwise, you'll wind up regulating a wall wart, and then finding out that it puts out less voltage than you thought, and then having to change a bunch of resistors again.