This program tries to find the best multiple (harmonic) and divisor (ala TTL, HCMOS or PIC) to get closest to a desired low output frequency given that you start with a crystal. For example, if you've got a 3.579575 mhz crystal and you want 466 khz, use the third harmonic then divide by 23 to get 466.90109 khz for mixing with a 455 khz IF. If you can adust the oscillator with a trimmer cap to 3.57266666 you'll be dead on. This program uses harmonics rather than trying to anticipate what the overtone frequencies will be, so you may need one or more multiplier stages.
Dividing by 23 (or almost any other integer) with a PIC is really simple. There's a sample program at the bottom of the page. Download the free mplab from microchip and install it. Run through the simulation until you get the results you want, then find or borrow a programmer to write the program into the chip. Hint: you turn on an output pin, waste enough program cycles to use up half the amount of time, turn off the output pin, waste more time, then loop and do it over. That gives something close to a 50% duty cycle. The frequency the PIC's running at is your crystal frequency or a harmonic of it. The upper limit on frequency input comes from what the PIC can handle for a clock frequency.
If you've got a bunch of crystals, type or paste the frequencies in and the program will show the best matches. Crystal frequencies need to be in MHZ. 3.579545 is given as an example because almost everyone probably has one of those around (old NTSC colorburst frequency, found in junk TVs or VCRs). The list of crystals can be longer than the box: a scrollbar will appear when it's needed. You can use the same list over and over by clearing the log and entering different other numbers.
The old "garbage in : garbage out" maxim applies here. If you enter a value that's not actually a number the results are unpredictable. It won't blow up your computer (except maybe if you're using Internet Explorer). This may take a while to calculate and you don't need to pay attention to what's happening in the log except at the end (you may have to scroll it).
How this works:
For each crystal frequency you enter, the program calculates harmonics until they would go above the max frequency you entered that your divider logic can handle. Then it tries dividing each of those frequencies by 2 and up to the maximum feasible divisor you entered. It subtracts that frequency from the target frequency you entered and looks at the absolute value. If it's the closest match found so far it keeps it. When its gone through all the harmonics and all the divisors the best match is output. Once it's given a best match, it "back-calculates" by multiplying the target freqency by the best divisor, then dividing by the harmonic number to give the exact frequency you need to trim the crystal to.
If you're trying to get some small frequency like 60 HZ out of a crystal like 3.579 MHZ, set the max divisor really big. The program does work for getting 60 hz from 3.579 MHZ, but the divisor has to be free to go up to 59659. Trimming the crystal to 3.57954 MHZ gets exactly 60 HZ out. I haven't written a PIC program for a divisor that big, but you'd just turn on the output pin, count up half the divisor, turn the pin off, and count the other half. Actually you'd preload the counts and count down to 0 because 0 is easy to detect. You could even make a more versatile divider by using DIP switches to set the count, but then you'd need a bigger PIC with more I/O pins to be able to read the switches. Trying to get 3.885 MHZ from 3.579 doesn't work. You can get really dead on with PL tones this way though.AB1JX / calcs