Archive for Frequency Counter

Dividing Frequency

Crystal oscillator and dividing it’s frequency to make something useful

Last time I was messing with crystals, I managed to get a stable 0.5Hz timebase for my nixie clock and frequency counter projects. After some investigation through data sheets, I thought I’d take a moment and de-mystify a very useful IC called the 4521 24-stage frequency divider. Not that it is much of a mystery to those who know electronics, but for an amateur like myself who is figuring this all out for the first time, it can be a bit annoying to build something and not know why it works. I won’t go into the details of the crystal oscillator part, but focus on the 4521 IC.

Basically what this little beastie does is take the frequency pulses from a pulse generator (in this case, a crystal oscillator) and performs some math on them to divide the frequency down from the megahertz range to the hertz range which is more suitable for clocks and things that humans actually will see.

Consider the schematic on the right.


Pretty simple huh? The crystal’s frequency (printed on the can) is 4.194304MHz. That’s 4,194,304 cycles per second. You might think that is a weird number to pick but as usual, math comes to the rescue. Stick with me. The 4521 frequency divider exponentially divides the frequency generated by the crystal oscilator by powers of 2. You can see outputs labelled Q18-24. These are the exponents of 2. So Q18 is 218. What it does is divide the frequency from its input by this number and out pops the result on the appropriate pin of the IC. So in the case of Q18: 4,194,304/218 = 16Hz. Get it? Not hard at all. For my 0.5Hz timebase, I used the Q23 pin so: 4,194,304/223 = 0.5Hz. I’ve helpfully labelled the outputs on the schematic for you to show the various output frequencies.

Of course, if you substitute a crystal with a different frequency, you will get different results using the math above proportional to that frequency.

Fried crystals mmmm

Parallel to my power supply project are two others, both requiring an accurate timebase.

These are my nixie tube clock and my frequency counter (which I will probably combine with my function generator that I will also build).

The two, being time-based, are inherently related. The nixie clock happens to use the mains frequency as a timebase and I really do not like the idea of using an un-isolated mains if I can possibly avoid it. The frequency counter schematics I have all seem to use a crystal timebase which seems more logical. After all, if all of our clocks and watches rely on them, why can’t my nixie clock?

With the mind to use the same time base circuit for both projects, I thought I’d quickly whack it up on the breadboard and see what I get.

I first tried the timebase from Miguel Pedroso‘s cmos frequency counter project. I liked the look of this project, as it seemed simpler than the other one I was looking at which looks scanned from an old electronics magazine. Also, it uses the more modern 4000 series cmos chips rather than the 74HC ones (which I am sure are good too). Anyway, his timebase was deceptively simple, involving only a CD4521 24-stage divider, a 4.194304MHz crystal, a trimmer cap, and a 10pF cap. Great, I like simple.

So I build it up and immediately notice something wrong. It’s not oscillating. What’s more, the 7805 regulator powering the thing is heating up, which it most definitely should not. I tried fiddling with it, checking my wiring, swearing at it, nothing worked. It could have been a dodgy trimmer cap or some other mistake of mine, after all Miguel Pedroso seems to have got his working fine and he did warn me the thing was touchy.

Reaching a dead end, I figured I’d try another schematic I found in a forum, which seems to agree with many others I find floating around the internet. Posted here:

1Hz timebase

My sincerest apologies to the original author and the gentleman (or woman) who posted and cleaned it up. I have forgotten where I found it.

Anyway, I build this up and the bloody thing still doesn’t work! On a whim, I swap the crystal out for another one and behold! My ‘scope starts twitching hi and low every second – making a 0.5Hz square wave. Joy.

I tried the original crystal and discovered it is indeed dead. For all I know, it could have always been dead, or it could have been fried due to the absence of resistors connected to the crystal in Mr. Pedroso’s diagram. Either way I got it working!

Even more fun, I noticed the other output pins on the 4521 give you different divisions of time. It appears I can get 0.5Hz, 1Hz, 2Hz etc. Handy!