Home > electronica > Frecventmetru V2 by Phil Rice VK3BHR

Frecventmetru V2 by Phil Rice VK3BHR

Frecventmetru V2 by Phil Rice VK3BHR

Frequency Meter v2 PIC16F628

Frequency Meter v2 PIC16F628

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 properly, it must be calibrated. This may be as simple as connecting a known frequency source and adjusting the trimmer capacitor so the correct value is displayed. If you are unable to adjust the displayed frequency, then a “coarse calibration” is required.

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.

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.

Frequency Meter V2 By Phil Rice VK3BHR_1

Frequency Meter V2 By Phil Rice VK3BHR_2

Getting the software:

Click this link for the assembler source code!

Here is the hex code for PIC16F628

  1. stefan
    October 8th, 2017 at 14:14 | #1

    salut,mai ai cumva PCB layout la frecventmetru…multumesc.

  2. June 14th, 2017 at 09:29 | #2

    Hello Stefan,

    con u email me the PCB layout and artwork,

  3. June 10th, 2017 at 11:33 | #3


    Please Send Board artwork, “ready for ironing on” for PCB Making .


  4. vas
    October 27th, 2016 at 17:46 | #4

    Pe schema este pic16f84, hex-ul este pentru pic16f628, cum se folosesc?

    • November 20th, 2016 at 18:38 | #5

      Autorul codului a realizat doua versiuni, una cu F84 si alta cu F628. Pentru 628 ai codul sursa!

  5. Smaer
    September 26th, 2016 at 05:04 | #6

    Hello Stefan. I would like to make this circuit. Can you send me the pcb please? Thank you

  6. Yname
    March 13th, 2016 at 21:40 | #7

    Can you plz send me the pcb files ?
    And can i use BF199 in the place of BFR91 ?

  7. January 9th, 2016 at 05:27 | #8

    Hi friend I could ask about sending PCB proposal I’d like to get this construction built a thank you 73 OK2WF

  8. huiwijaya
    January 4th, 2016 at 19:04 | #9

    hello… the result of freq is not autorange ??? im using PIC16F628A now..

  9. indra
    January 1st, 2016 at 09:56 | #10

    hello, stefan, could u email me the pcb layout and its copper side?? thx 🙂

    • January 2nd, 2016 at 23:00 | #11

      Hi indra,
      Your email address is incorrect. I send PCB to huiwijaya(at)….

  10. Ion
    February 1st, 2015 at 15:28 | #12

    am facut acest frecventmetru cu pic16f628 si merge ok cu hex-ul de aici!
    multumesc mult!

  11. Arif Ahsan
    September 9th, 2014 at 18:32 | #13

    Hello sir. Greetings.

    I want to build the exact circuit as i was looking for this specific type. Can i have the pcb pdf please?

  12. Darrel Heckendorf
    August 20th, 2014 at 01:04 | #14

    Could I get a PDF copy of the PCB artwork?

  13. Stefanovic Z.
    May 31st, 2014 at 16:06 | #15

    Hi Stefan.
    I am in the process of building this frequency counter (pic16f628)
    Display print 00.00000 MHZ you hex.
    I want to show 00.000000 MHZ (00. + 6 numbers)
    Current print is 00.000000 MHz
    Display 1 Hz 00.000001 MHZ
    and 2 Hz 00.000002 MHz
    and 10 Hz 00.000010 MHz
    current version is 00.00001 MHZ
    sorry for my bad English

  14. Paul
    May 27th, 2014 at 00:09 | #16

    Salut Stefan
    Se poate daca te rog sa imi trimiti si mie cablajul
    merci anticipat

  15. jack ryan
    June 23rd, 2013 at 03:25 | #18

    Hello again Stefan,

    i just recently received the pdf file of the pcb and a big thanks for that.

    Could you also include the parts placement or component guide. Again 73’s and good numbers.


  16. jack ryan
    May 28th, 2013 at 15:45 | #19

    Hello Stefan,
    I meant the pdf file of the pcb.


  17. jack ryan
    May 28th, 2013 at 14:16 | #20

    Hello Stefan,

    Can you email me the pcb file in jpg format?

    73 and good number.

  18. Ik6dcl
    May 16th, 2013 at 17:45 | #21

    Hi stefan
    i have made a Frequency counter and with your software and pic 16F628 i have read a direct frequency of 84,870 MHZ……!now i ahve change wit 16f84 and a soft for use a prescaler upb1507,and the max frequency is 2,9ghz, my question is:
    have you a soft for 16f628 modified for use a prescaler /64 /or 128 ?
    73 de giuliano

  19. Ik6dcl
    May 3rd, 2013 at 17:39 | #23

    hallo is possible have a pcb file via mail for frequency counter ?
    many tnx
    73 de

  20. April 4th, 2013 at 13:09 | #25

    Hi Stefan,
    I am in the process of building this frequency counter and noticed that you have a pcb for it and is available for purchase please,

  1. No trackbacks yet.