VHF/UHF Basic Frequency Counter

Share:

Description

bnc connector femaleA long time ago I built a radio using a Philips UV616/6456 TV tuner that is capable of receiving radio signals over a large range of frequencies. It ranges from 47MHz up to 860Mhz which gives me the possibility of decoding either Over-the-Air or Cable TV signals.

The problem is that the radio doesn't have a frequency display, so tuning a particular frequency is always a challenge. This project is about building a frequency counter, using a 2x16 LCD and a small PIC 18F1320 micro-controller for the UV616/6456 receiver.

Design and Implementation

Things taken into consideration while designing the frequency counter:

 

To measure a frequency there are two approaches [1] that I know of:

 

I chose the pre-set time approach, using one timer to create the fixed measurement window and another timer as a counter to accumulate the number of pulses applied to its input pin, however the second approach usually gives better results when the event being measured repeats itself with sufficient stability and the frequency is considerably lower than that of the clock oscillator being used. The resolution of the measurement can be greatly improved by measuring the time required for an entire number of cycles, rather than counting the number of entire cycles observed for a pre-set duration (often referred to as the reciprocal technique) [1]. The second approach was not implemented.

As for the frequency being measured, the UV616/6456 tuner doesn't output the currently tuned frequency. Instead it outputs the sum of that frequency with its internal I/F (37.3MHz) and then divides the sum by 256. This means when tuning 102.20 MHz we get (102.2e6+37.3e6)/256 = 544.921KHz.

The table below shows the output frequency ranges for every selector position on the radio. The output frequencies include the I/F and are divided by 256:

Selector Tuner Min Tuner Max Output Min Output Max
P1 VHF 47 MHz 110 MHz 329.3 KHz 575.4 KHz
P2 VHF 110 MHz 300 MHz 575.4 KHz 1.318 MHz
P3 UHF 300 MHz 470 MHz 1.318 MHz 1.982 MHz
P4 UHF 470 MHz 860 MHz 1.982 MHz 3.505 MHz

 

These output frequencies range from 329.3KHz to 3.5MHz and will be injected into the micro-controller's counter input. 

The display is a 2x16 LCD in 4 bit mode.

Schematic

The schematic is below:

 

It consists of a complete linear power supply built using a 78L05, a signal shaper to change the sinusoidal input into a square wave that is fed into the timer input pin T0CKI and the 2x16 LCD.

Timer 0 counts the pulses from the radio frequency output and timer 1 creates the pre-set time for timer 0 to count pulses.

 

PCB

The printed circuit board developed for the prototype is single sided with 3 jumper wires.

The connector on left is the AC input from the transformer. The connector in the middle, below the PIC is the frequency input. Its right pin connects to the coaxial's middle wire and the left pin connects to the copper mesh shield. The contrast of the LCD is adjusted on the 10K trimmer. The header near the trimmer is for future expansion and has no use at this time.

 

Software

The software is written in C and implements a frequency counter based on counting frequency pulses on a pre-set time window. Timer 0 counts the pulses on its T0CKI pin. Timer 1 counts the pre-set time window. When the window expires, the counting of pulses stops.

This process repeats it self after the measured frequency is presented on screen.

To reduce the error of the measure, the number of pulses collected should be as large as possible, in the fixed time window, thus increasing the time window. To give the user the notion of real time measure, the time window should not be too big. And the worst problem: Timers can count only up to a limited amount, 65535.

So I set two different scales:

With a prescaler of 1:16 and a pre-set time of 0.496s seconds the frequency counter has a precision of 2 decimal places. But when the prescaler gets set at 1:64 and a pre-set time of 0.16384s the precision drops to 1 decimal place only.

The next table shows the frequencies involved, pre-set times and so on:

 Range  Tuner Min Tuner Max  Prescaler  Min freq after prescaler Max freq after prescaler Pre-set time
 Low 0MHz  612.7MHz  1:16  9106.4Hz 158691.4Hz 0.4096
 High 612.7MHz 2.5GHz  1:64  39672.8Hz 154864.5Hz 0.16384

 

Using these pre-set window times the values obtained in timer 0 will be:

Range Prescaler Min Freq Max Freq Pre-set time Min Count Max Count
 Low 1:16  9106.4Hz  158691.4Hz  0.4096  3730  65000
 High 1:64  39672.8Hz  154864.5Hz  0.16384  6500 25373

The micro-controller main oscillator runs from a 2MHz crystal. No interrupts are needed since everything runs freely in a loop with two tasks: measure and display.

Evaluation

This is how it looks from the outside:

frontrear


And from the inside:

 


Some screens of the unit running

boot screen  lcd no signal

Power on message on the left and No signal on the right

lcd tuned

Listening to "Antena 3" at 102.20MHz while testing


meter and radio

This is the Family picture with the frequency counter on top and the radio below.

 

Downloads

All downloads are free:

References

[1] Frequency counter from Wikipedia, the free encyclopedia.
[2] 45-860MHz Radio receiver based on UV916-tuner

 

Published on Friday 2009/07/10, last modified on Thursday 2012/02/23