Verdris, if your specs are confirmed, the solution is not easy.
First off, 0.01Hz on 5kHz means 20ppm and this implies a very good quality crystal, preferably thermo-controlled.
Secondly, I suppose that you need a good frequency stability, so the only feasible way to create a similar circuit is starting from a crystal source, then cascading a certain divider. However, given "fin" as the crystal frequency, is not easy to find an arbitrary integer N which yields the desired "fout". In other words:
N = Fin / Fout, where Fout = 100..5000 and N must be integer.
Moreover, N should be multiple of 2, because you want always a duty of 50%.
For instance, suppose choosing a crystal of 10MHz. To generate a 100Hz sq-wave, you should divide the source by 100,000 and that's fine(*).
Afterward, let's suppose you want an output of 101Hz: this time the division has to be 99,010 (closest integer).
Now suppose to generate 4,987Hz: the closest integer multiple of 2 is 2,006, but the actual frequency is 4,985Hz.
As you may see, it's not an easy solution problem.
The "easiest" way to solve your problem that comes in my mind is using a PLL, but it's *FAR* from being as easy as the hobby-average-knowledge. It would be useful if you clarify, for instance, the purpose and/or whether the specs are correct, or can be relaxed a bit.
Cheers
UPDATE: There's another option, although it's not much easier.
The approach is building the waveform using the super-sampling technique, which consists to "serialize" the waveform on a shift register in order to obtain the desired pattern.
The crystal precision keeps the same, but perhaps the pattern creation would be pretty easier than other ways. Since your goal is having a 1Hz out of 5000, it means that you should have a resolution of *at least* 1/5000 = 200us...which stands for 200us per sample.
That's theoretical, though, because a good super-sampling should be many times faster than the maximum frequency desired.
Cheers
Edited by Mario Vernari, 26 April 2013 - 05:36 AM.
Biggest fault of Netduino? It runs by electricity.