Close

Ripple Counters II

A project log for PIC Graphics Demo

Generate 640x480 64-color VGA graphics with an 8-bit PIC and an SRAM framebuffer

ted-yapoTed Yapo 12/05/2016 at 13:483 Comments

I found a bag of 74HC4020s in my stash. It's a 14-stage ripple counter with two outputs missing - kind of a bizarre part, if you ask me. I hooked the clock input to a signal generator, and outputs Q0, Q4, Q8, and Q13 to the scope. Here it's at 10 MHz, triggered on the transition of Q13, the MSB - all the lower bits are going low, while Q13 goes high:

You can see a bit of delay between the successive stages. Zooming in, it's easy to measure:

All those wiggles are poor layout (a solderless breadboard) and bad probing (long wires attached to the scope probes). Inside the time cursors, the output lines aren't showing the correct count - it's only after the last (blue) transition that the outputs are correct. The delay from Q0 to Q13 is 56ns - so, during that time, the outputs are wrong. But this counter will typically run at 100+ MHz - how can that be?? Let's turn up the frequency. At 18 MHz, Q0 is now transitioning to its next state before Q13 finishes the last:

At this frequency, there's no longer any point in time at which the outputs show the correct count for this state. The state still gets updated correctly, and if you stopped the clock at the trigger point (mid-screen), the output lines would settle into the correct state, but you couldn't use this counter to generate successive values at this frequency.

The generator I was using only goes up to 25 MHz, and there you can see that things just get progressively worse - you're almost missing two states now:

If I really wanted a nasty hack in this project, I'd cut sections of cheap RG59 coax to the exact lengths to equalize the delay between the bits of these counters. At 1ns/foot with a 66% velocity factor, I'd only need 40 feet of cable for that first bit, with progressively shorter cables for the higher bits. It's almost like the kind of stuff you find in classic oscilloscopes. Still, easier just to buy a few synchronous counters.

Discussions

Eric Hertz wrote 12/07/2016 at 01:48 point

Great hack-idea! Though maybe to occupy a little less space, one could just add in some gate-delays...? Or some software/address-hackish ideas involving always running the system at the same frequency...

Cool to see these results

  Are you sure? yes | no

Ted Yapo wrote 12/07/2016 at 01:54 point

Yeah, gate delays would be a safer bet, because hopefully, they'd track the delays in the counter over voltage and temperature changes.  I could see the cable-delay thing falling apart easily as things drifted.

I ordered a handful of the 74AC163 counters, which should eliminate the whole problem.  There's too much coding to be done to worry that much about the hardware :-)

  Are you sure? yes | no

Yann Guidon / YGDES wrote 12/05/2016 at 15:03 point

"Still, easier just to buy a few synchronous counters."

I agree :-D

  Are you sure? yes | no