# The 2002 DFD Updated

## By Phil Rice VK3BHR

Here is an updated version of the Digital Frequency Display published in AR in September 2002. Since then I have learned quite a bit about PIC programming and, with inspiration from a Web page by IK3OIL, have managed to perform all counting functions "on chip".

This version features a much simpler front end, an extended frequency range and a coarse calibration function implemented in software. It retains the ability to add or subtract one of three IF offsets, making it suitable as a frequency display for a direct conversion or superhet receiver (also for transmitters using "on frequency" VFOs or using mixing). Resolution remains at 10Hz and accuracy is in the order of 100Hz.

### How it works:

A self biased common emitter amplifier produces a pseudo-TTL driving signal. The 10uH inductor in the collector lead helps extend the high frequency response. Any "fast" NPN transistor should be suitable. I used a BFR91, but you may substitute a transistor scrounged from an old TV tuner or a VHF receiver.

The amplifier's quiescent Vce is set to 1.8 to 2.2 volt by the resistor marked * on the diagram. It is nominally 10K, but you may need to change it. The collector voltage is applied to the PIC's counter/timer via a series 470 ohm resistor.The PIC is able to short this signal to ground via an internal pull-down transistor to disable counting. It is crude, but quite effective.

The PIC implements a 32 bit counter, partly in internal hardware and partly in software. Counting is enabled by turning off the internal pull-down transistor for "exactly" 0.4 second. At the end of this time, the PIC divides the count by 4, then adds or subtracts the appropriate IF frequency to get the actual frequency. The resulting count is converted to printable characters and delivered to the display.

### Setting up!

Before the frequency meter will work at all, it must be calibrated.

This involves starting with the power off. Pin 10 is connected to ground and the power is then turned on (and held on). The PIC will measure and display the input frequency, followed by the letters CAL. If you can't adjust the indicated frequency to the correct value (by adjusting the 33 pF trimmer), then coarse adjustments can be made by briefly connecting pin 12 or pin 13 to ground. It may take several tries, because the program only checks these pins once each measurement (0.4 second). Once you are happy with the adjustment, remove the ground from pin 10 (while power is still applied). This will cause the PIC to store the calibration in non volatile internal memory.

If you are lucky and use a 4MHz crystal that is similar to mine, calibration may be as simple as (a) shorting pin 10 to ground, (b) turning the power on then (c) removing the ground short from pin 10 (with power still applied).

Normally pin 10 is floating at turn on, but may be grounded later to "program" the Intermediate frequency offsets. The next few paragraphs, copied (with amendments) from the September 2002 article describe how this is done.

To program the intermediate frequencies, connect the BFO to the the counter then set up the PIC as follows:

Ground pins 12 and/or 13 of the PIC to select one of three IF offsets. Pin 12 when pulled low, indicates the BFO is on its lower frequency. Pin 13 when pulled low, indicates the BFO is on its higher frequency. Alternatively, you can pull both pins 12 and 13 low to use the third offset. If both pins 12 and 13 are left floating, the PIC will not actually store anything!

To store the measured BFO in the selected internal EEPROM, just ground pin 10 of the PIC for at least 0.5 second, then release it.

For normal operation, the RF input of the counter is connected to the receiver VFO and the PIC uses the stored IF offsets to calculate the actual frequency. If neither BFO selection pin (12 and/or 13) is pulled low, the PIC uses the average BFO frequency. If no IF offset is required, just measure and store 0Hz for both offsets. Alternatively, you can pull both pins 12 and 13 low to use the third offset (which must also be programmed to 0Hz.)

Pin 11 when held low, indicates that the selected IF is to be added to the measured VFO frequency to give the indicated frequency. If pin 11 is floating, then a subtraction is done (VFO-IF or IF-VFO, whichever is appropriate).

Some LCD displays are configured as "8 character by 2 line" but with all the characters displayed on the one line. To cater for these displays, the PIC tests pin 18 occasionally. If it finds this pin grounded, it it inserts a "move to line 2" command after the eighth character. If your display only shows eight characters, then try grounding pin 18 of the PIC.

### Getting the software:

Click this link for the assembler source code!

And, for the "assembler challenged" here is the hex code!

And for your complete diversion from the project, here is a programmer to blast the HEX code into the PIC.

### The last word:

This frequency meter has much simpler hardware than the 2002 version and because of "improvements" in the software (32 bit counter instead of 24) has a higher frequency limit. The 2002 frequency meter was hard limited to 41.94303 MHz. This one exceeds 50 MHz, limited only by the PIC's counter/timer. The prototype was still counting reliably at 60+ MHz.