Electronics > Beginners
74HC390: Ripple Counter is Counting Rubbish
<< < (5/6) > >>
Darkwing:
Alrighty then, I have news! :)
I read all of your comments, first of all: thanks!
I sat on the breadboard again and: I made it work.  :-+

But step by step.

Here is what the status quo was: I captured (with 500ms persistence time) the signal from the HCPL3700 optocoupler (1) and the first counting pulse (2) it triggered in the CD74HC390 counter … and as you can see: this is garbage. Wild jumps on the logic level, no wonder that the counter produced such a weird looking pattern. The rising edge is somehow ringing, maybe that's why sometimes it was interpreted as an additional falling edge by the counter IC.



Here is a capture of the rising edge – this was with 2,2kΩ as a pull-up on the optocoupler and 220Ω as a "pin protection" on the counter:



And here is the falling edge of that signal:





I then tried some other optocouplers: 6N138 and ILD620GB – with an even more terrible Fall Time.

6N138:


ILD620GB:




I discarded that and switched back to the HCPL3700. And I was able to clean up my signal. I simply used 100k as a pull-up and connected the optocoupler's output directly to the clock input of the counter. So I use a much higher value now as a pull-up, not a lower one. I don't know why I used the 220Ω resistor as a pin protection in the first place. Guess I had this in my mind from some Arduino tutorials ("Protect your pins! Never connect something directly to the pins or the current will destroy it!" Stuff like that ...).

I also decoupled the optocoupler now on pins 5 and 8 with a 0.1µF capacitor like the datasheet suggested. It made a liiiiittle difference, but not much. I also grounded the unused pins of the CD74HC390 counter. It made no noticable difference.



And now the signal looks like this – the rising edge:



And the falling edge:



Much more clean! But it did not want to work. Still counting rubbish.

So I decided that it is now time for some zeriouzz Schmitt action! For this, I first moved the optocoupler on the breadboard a little bit away from the counter IC, to make some space for a Schmitt trigger IC. But before installing it, I measured my optocoupler's signal again: lo and behold!, it was even better and now the counter triggered correctly! My pulse signal is divided by 10:



(My scope is of course not a 5-channel one – I photoshopped that for you.  ;D)

This is what you would expect it would look like – but I couldn't believe this. So I switched back and forth and back and forth the position of the optocoupler on the breadboard. Sometimes it seemed to work, sometimes there were some small glitches on the scope, but after all the dividing was correct. So I can only assume, that a mixture of signal quality and bad connnections on the breadboard or the fact alone that I use a breadboard is all part of the problem. I have no clear explanation for this behavior, but I wouldn't trust this arrangement.

So back to the Schmitt! I tried two different Schmitt triggers: the SN74HC14N and the CD40106BE:

SN74HC14N – Fall Time ≈12ns:



CD40106BE – Fall Time ≈27ns, but cleaner signal:



Side quest: Why is it that with the SN74HC14N (a CMOS device) the signal is faster but more jittered? With the CD40106BE (also a CMOS device), for me it's fast enough, I have clean levels and edges and it works very reliable so far. This means: I'm happy and we solved the problem.  :clap:


So here it is: my little optocoupled, Schmitt-triggered, AC pulse divider:





With it I'm dividing the 50Hz mains frequency (Europe) to a 1Hz signal. The LED flashes every second. This was the goal for this project.  :phew:


I hope this was insightful for someone, especially for the beginners who don't own a scope yet, to better understand and see "the inner workings" of all this stuff in more detail. I remember, back in the days, when I was scopeless, I would have wished for some real world pictures and explanations like this.

You're welcome to add, comment, suggest and recommend to this learning project.  :)


Thanks y'all!  :) 8)
Brumby:
Congratulations on success - and having learned some important lessons along the way (I picked up a couple of things.)


One point:

--- Quote from: Darkwing on May 09, 2019, 04:55:23 am ---I also grounded the unused pins of the CD74HC390 counter.

--- End quote ---
Only ground the unused INPUT pins.  Grounding outputs could cause you other problems.  Input pins are looking for a signal, so grounding these makes that signal stable and known.  Output pins aren't looking for anything.  Their level is set by the function of the chip.  Best leave the chip to set these - leave them disconnected.


--- Quote ---It made no noticable difference.

--- End quote ---
Quite often this is the case, but it is good practice.  One day you might have a circuit that is susceptible and if you don't ground unused inputs, you might be chasing your tail for a while until you remember this advice.
schratterulrich:
To your side question:

The faster the signal, the more important the correct probing technique becomes.
If you use a ground lead with your probe you can try to roll it up. If the signal changes even a little, you have found the problem.
mikerj:

--- Quote from: schratterulrich on May 09, 2019, 07:18:21 am ---To your side question:

The faster the signal, the more important the correct probing technique becomes.

--- End quote ---

And also the more important supply decoupling and a solid low impedance ground becomes.  This is why fast logic devices and breadboards are a bad mix.
schmitt trigger:
Good job!  :-+
A good reason for beginners to use CD40xx logic is because it is very forgiving. Specially if your clock frequencies are below 1 Mhz.
Now you know.

Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod