Maker Pro
Maker Pro

74HC393: 4-Bit Counter in need of debounce?

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
Hello again,

I've built a circuit with a 74HC393, dual 4bit counter (http://www.nxp.com/documents/data_sheet/74HC_HCT393.pdf)

It "occasionally" counts correctly (i understand how binary numbers are meant to count) but usually counts "somewhat randomly" or I get counts on the opposite counter to what I'm expecting... My current theory is that my clock input needs a de-bounce circuit? I haven't built one before but happy with a "yes that's what you need" answer and i'll go work that out :)

  • Chip is powered +5V to VCC, GND straight to ground.
  • All 8 outputs (2 pairs of 4) are going to 2N2222 transistors: these have +5V to collector, emittor goes through 300R to LED then ground.
  • MR and CP inputs (both pairs) have pull-up 1M resistors

For my clock/CP input, I'm using an "astable multivibrator" because:
  • a) at first it seemed to work much better than plugging/unplugging 5V to CP by hand
  • b) because I like looking at flashy lights and they in no way drive me insane and
  • c) i wanted a super slow clock so i can "see" the counter working, know it's working, and get that sweet "ooo it's working!" feeling
  • d) I wanted to play with my my newly arrived components rather than get my raspberry Pi to achieve the same result.

The vib. uses 2N2222, 300R, 100K, 100uF (one of these things)

Click here to see video of the strange output i'm getting. It's low quality, dont expect you to see how i've wired everything, but just shows me plugging and unplugging CP input and the corresponding behaviour. Paper is covering the LED's so I can film them :) Essentially only one side works, but the other side usually has at least one LED on (constantly)... If normal behaviour (numbering bits from 1 to 4) is "1, 2, 1&2, 3, 1&3, 2&3 etc... my behavior is this: 3, 1&2&4, 3&4, 1&2&4, 3&4, 2&3&4, 1&2, 3, 1&2, 3, 1&3, 1&2... etc... So it exhibits certain "loops" then randomly changes, and maybe loops, or goes to other loops... It also seems to "briefly" turn on certain LED's occasionally. Which leads me to the theory i need a debounce circuit but looking at the vib. in Every Circuit it seems that it should be reasonably "clean"?

I've checked and double checked my lines going to transistors, resistors, and LEDs, haven't got any floating inputs or outputs.

Thanks heaps for any suggestions :)
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Debouncing is only needed when bounce is present. Bounce occurs because mechanical contacts don't close cleanly. So you don't need any debouncing.

I couldn't make much sense of the video, sorry.

I would use 10k for your pullup resistors, not 1M. 1M should be OK though.

Do you have a decoupling capacitor connected directly between pins 16 and 8 of the HC393?

Can you post a schematic?
 

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
Gidday Kris, I don't have a decoupling capacitor, do I need one/some do you think? I'll read more about them anyway...

I just had a thought this morning: an output goes to a transistor base, but is this considered "floating" if there's not enough current to switch on the transistor (in low state)? Still has a route to ground doesn't it hmm

Also wondering now, it would seem i've connected the capacitors in the vibrator above the LED's, where usually it's below the LEDs... I'll just remove the LED's all together because they're driving me nuts (reminds me of a joke.. a guy walks in to the bar with a steering wheel on the front of his pants...). I can't seem to get my multimeter working to measure the current going in to CP

Thanks for looking at my schematic: haven't drawn it but "CP2" is wired same as CP1, with pull up resistor... All output LED's wired the same in parallel

IMAG0050.jpg
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Hi Simon,

Yes, you do need a decoupling capacitor. Typically 0.1 µF ceramic. Connect it as directly as possible between pins 14 and 7 (sorry, not 16 and 8) of the chip using wires as short as possible.

Putting the LEDs like that in the multivibrator isn't normal but it should work equally well. But the voltage at the collectors will not swing all the way up to 5V, especially if you have pulldown resistors on the CP1 and CP2 signals, because of the forward voltages of the LEDs. Try removing the 1 MΩ pulldown resistors and using 10k pullup resistors on CP1 and CP2 instead.

I hadn't heard that joke before. Here's one for you. A woman walks into a bar and asks for a double entendre. So the barman gives her one.

Everything else looks fine.
 

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
hehe awesome, thanks heaps for that! Will give it a try. PS what do you get when you cross a joke with a rhetorical question?
 

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
Might just be a bit out of my depth with this one... I made those changes. And fixed my multimeter ;) I've now got 1K and 10K resistors on the vibrator, 10K pull upts, 100nF between VCC and GND.
Was wondering if the chip was cupput: I have two, the other one does exactly the same thing so if it was symptom of being fried i would they would both exhibit different strange behaviour? not sure what happens when you fry something... maybe they both break at the same point *ponder*

I slowed it right down so i can see what's going on: from the vibrator output to ground, it alternates between 5.5V and 20mV, current between vibrator output and chip input alternates between 2uA and 460uA. To me that seems crazy low? Perhaps i just need to drive this thing properly... from a 555 timer perhaps?

I have a big newbook from the library to go through... feel free to tell me to go read some more lol

hmm on second thoughts, looking at data sheet, maybe that current is too high if anything? it doesn't give minimum current... I don't really get it: i thought things just use as much current as they need? hmmmm

[EDIT: or I guess the 5.5V/2uA is the high state, so that should be OK? hmm]

datasheet.jpg
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
It's odd that the collector of the multivibrator transistor goes to 5.5V... It's running from a 5V supply, right? There's nothing in the circuit to generate a continuous voltage higher than the supply voltage. So is the supply voltage really 5.0V? If it's 5.5V that might possibly be causing the misbehaviour in the HC393.

You're right, things draw as much current as they need. Unless you exceed voltage limits; in that case, they may draw more current than they should, and be damaged. But I don't think that's happening here.

I think it's unlikely that two HC393s would be damaged in a way where they would both misbehave in an identical way.

Can you post some close-ups of your breadboard layout? Take photos from above, and several slightly off-angle so it's absolutely clear which holes each component and wire are connected to.
 

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
Thanks Kris i'll take some photos tonight...

It is a bit weird about that 5.5V... I put some 1000uF capacitors to slow it right down to take readings, and i'm pretty sure the multimeter is getting to a "stable" state but it might just still be "settling" and reading incorrectly (paying off credit card is more important to me than buying oscilliscope right now :)

For power I'm using a dedicated little USB power supply thingo and it gives a steady 5V: much steadier than the Raspberry Pi i was using for power previously.
 

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
Now working fine with a 555 timer :) not sure what the deal with my home made oscillator was... will try again later. could try run it through a schmitt trigger i guess? might make the feed a bit cleaner? (if that was the issue) i assume it's not outputing as nice a square wave as a 555 does. But would be nice to feel i'm in "control" of what's going on.. early days I guess. Perhaps relook at it when i get the oscilliscope :)

Thanks for your help Kris!
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Sure :)

The 555's output will swing pretty quickly, so you won't need a Schmitt trigger. It doesn't swing all the way from 0V to 5V though; run the 555 at a low frequency and use your multimeter to see how far it swings. When it swings high, it'll probably swing somewhere between 3V and 4V. When it swings low, it'll probably swing less than 1V. Both cases are within the low/high thresholds for 74HC logic, but the 555 is not the ideal oscillator.
 

Simon101

Oct 8, 2014
38
Joined
Oct 8, 2014
Messages
38
oh yeah i meant a schmitt on the home made astable multivibrator, for the hell of it or to give me a reason to try the schmitt trigger i have :p i've got some crystal oscillators ill start playing with soon... every day the case for buying an oscilloscope gets stronger :p
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Agreed! An oscilloscope is like opening a window on the hidden world of component and circuit behaviour.

Crystal oscillators are good. There's also a very simple oscillator based on a Schmitt trigger - they are versatile circuit components! Just a single Schmitt trigger inverter, plus an R and a C, can form an oscillator. See https://www.google.co.nz/search?q=schmitt+inverter+oscillator&tbm=isch
 
Top