For hams who program MCUs, a frequency counter seems to be one of several obligatory projects, with others being a keyer and a controller for a DDS or PLL type synthesizer. So I wanted to get in my frequency counter project.
Counters such as this one have been around for a while, often integrated into radios with analog VFOs. With the tap of a button, you hear the frequency accurately announced in Morse and thus the need for a calibrated dial is avoided.
I said "With Morse Output" but it's common to refer to the device function as AFA, for Audible Frequency Annunciation.
Before I ramble much more, let me list the features of my counter. Every programmer likes to add a wrinkle or two to previous implementations and I've added one or two:
• One button control to initiate count or menu actions
• User programming of superhet IF frequency offset
• Selectable 1 Hz or 100 Hz resolution
• Option to suppress higher digits for faster readings
• Can be built SMT or through hole
• Small size - I used a RS proto board 1.75 x 2.75 inch
• Setup saved on EEPROM and recalled on power-up
• Three selectable Morse annunciation speeds
• Selectable audible marker for each 1 kHz change while tuning
• Accuracy: Depending on the time base, can be as good as 1 Hz
• Resolution: Selectable to 1 Hz or 100 Hz
• Response time: 1 s for 1 Hz resolution and 10 ms for 100 Hz
• Sensitivity: 35 mVpp to 180 mV through 6 meters
• Idling current draw at 12 V input is 11 mA
• My prototype SMT version will read to just over 140 MHz
• Minimum frequency is about 50 kHz with input capacitor shown
Some hardware notes and schematic
I'd switched from PICs to AVR MCUs a few years ago but the PIC is unique in having a prescaler that can count really fast - independent of the chip's clock. So I went back to the 16F683 8-pin PIC for this project.
I looked at several other designs although I didn't have their source code to guide me. Some use Microchip's AN592 app note as a starting point, but its accuracy can degrade to 1 kHz or worse at higher frequencies. I liked the Stinger Singer counter sold by the Arizona SQRPions group and designed by Dan Tayloe. The use of a 74HC00 AND-gate package allowed precise gating of the input stream and also gating out and counting the remainder stuck in the prescaler, which can't be read directly.
Sorry it's fuzzy. I'll provide a link to a better schematic.
I built my DIP version on a Radio Shack 276-150 prototype board. Radio Shack is gone but I found some at B.G Micro. I also built a SMT version on a board I made using the toner transfer technique. You could omit the programming header if you have a pre-programmed chip.
Want to try it?
I've added a link to the HEX code. You can burn it to a PIC with a PICkit-2 or PICkit-3. Or I could program a PIC for you and mail it in the USA. Say $4 to firstname.lastname@example.org which is my PayPal address. Or four ones to my QRZ address. First make sure I'm still alive and capable of fulfilling the request by emailing me at email@example.com.
I've also linked a manual below, with a lot more info on building and operating the counter.
I like the feature I added to give an audible "tick" marker with every kHz of change. But it introduced an artifact. When this feature is ON, the counter must read the frequency continuously and the pin that drives the speaker is also used in counting logic. This results in a low "puttering" sound from the speaker that's almost but not quite inaudible. Of course you can turn it OFF if it's a bother. One fix I've considered is to use a separate crystal oscillator with a transistor for the timebase. That would free up one PIC pin to dedicate to the speaker. Another fix would be to use a higher pin count PIC. But a 14 or 18 pin PIC would make the counter so much larger. I could justify it by integrating a keyer function into the chip as others have done. That would make it worthwhile.
HEX program file: http://pages.suddenlink.net/wa5bdu/FreqCountWA5BDU_V103.hex
Manual in PDF: http://pages.suddenlink.net/wa5bdu/PIC_Counter_Manual.pdf