Download - A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

Transcript
Page 1: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

I decided to design a simple, easilyreproducible counter around a PIC16F876A. The basic counter range isextended to at least 180MHz using two74Fxx devices. A divide-by-64presca ler i s used for h igherfrequencies up to at least 4.5GHz. Allresults of the measurement are shownon an inexpensive, 2x16 alphanumericLCD module with large characters. Ablock diagram of the counter is shownin Fig 1.The counter has three front ends: amicrowave (prescaled) input, an RFinput and a TTL input. Themicrowave and RF inputs are ACcoupled and terminated at lowimpedance (around 50Ω). The TTLinput is DC coupled and has high inputimpedance. A progress bar indicator isprovided on the LCD display for the

gate timing.Both the microwave and RF inputshave an additional feature, usually notfound in frequency counters: a simplesignal level detector driving a barindicator on the LCD display. This isvery useful to check for the correctinput signal level as well as anindicator for circuit tuning orabsorption wave meter dip display.

1.The counter

The whole counter design is based on a16F876A PIC microcontroller. Thisincludes several peripherals but just a

Matjaz Vidmar, S53MV

A simple RF/Microwavefrequency counter

Fig 1: Block diagram of the frequency counter.

VHF COMMUNICATIONS 3/2007

130

Page 2: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

few of them are used in this project. Themost important in this project are twointernal hardware counter/timers calledTMR0 and TMR1. The TMR0 timergenerates very precise interrupts every100 microseconds (10kHz) from the20MHz clock/reference. All requiredtimings for the counter timebase aresimply integer multiples of this basicperiod.

The TMR1 is used as a 16bit (binary)input signal counter. It’s maximumcounting frequency is just around16.7MHz. Therefore, the first four flip-flops of the input signal counter chain areadded externally as 74Fxxx logicdevices. The first two stages use one ofthe fastest 74Fxxx series devices, the74F50109 dual J/K flip-flop. The74F50109 is also specified as metastableimmune and is therefore the idealcomponent for the counter gate. Thecircuit diagram of the counter is shown inFig 2.

A more conventional 74F74 dual D flip-flop is used in the third and fourth stages.The TTL flip-flops require pull-upresistors to drive the PIC ports RC0,RC1, RC2 and RC3. RC0 is used as aclock input to the TMR1 at the sametime. Replacing the 74F74 with a74ACT74 could save some current andtwo pull-up resistors. The 74F50109 hasthe same pin-out and logical function asthe 74F109, but the latter has a lowerfrequency limit and is not specifiedmetastable free.

The typical frequency limit of the74F50109 is specified as 150MHz.Driving the 74F50109 with a fastswitching transistor 2N3960 (ft =1.6GHz) and a schottky diode 1N5712 toprevent saturation, reliable counting canbe achieved up to 190 - 200MHz! Unlikeconventional AND or OR gates, the J/Kgate minimises the jitter of the countingresult (wandering of the last digit)regardless of the input signal. Since the

/K input of the 74F50109 is inverted, twoport pins (RA2 and RA3) of the PIC arerequired to drive the J and /K inputs withminimal skew.

On the other end, the counter needs to beextended beyond the 4 bits of the 74Fxxxlogic and 16 bits of the TMR1 are usedadding up to 20 bits of resolution. Toavoid disrupting the operation of themain 100μs timer, the TMR1 is notallowed to generate interrupts. TheTMR1 overflow (interrupt) flag ischecked during every 100μs (TMR0)interrupt. The overflows are counted intwo additional 8 bit registers. The overallcounter resolution is therefore 36 bits.

These 36 bits are truncated to 32 bits, theupper 4 bits are not used. 32 bits allowcounting beyond 400MHz with aresolution of 0.1Hz (gate time 10s). Noneof these counters is ever reset! Thecounter value at the beginning of themeasurement is stored and subtractedfrom the end value. Finally, the 32 bitbinary result is converted to a 10 digitdecimal number and the latter isdisplayed with the leading zeros blanked,decimal point and units (MHz or kHz).

The basic counter software allows threeresolutions (selected with RC4 and RC5):10Hz, 1Hz and 0.1Hz in direct countingmode (no prescaler), corresponding togate times of 100ms, 1s and 10s. Whenused with a divide-by-64 prescaler, thethree available resolutions become 1kHz,100Hz and 10Hz, corresponding to gatetimes of 64ms, 640ms and 6.4s. All thesegate times are obtained by counting the100μs (10kHz TMR0) interrupts.

The PIC 16F876A drives a standard LCDmodule with a HD44780 controller and aresolution of two rows of 16 characterseach. The HD44780 requires 8 data lines(port B of the 16F876A) and threecontrol signals: Register Select (RC6),Read/Write (GND) and Enable (RC7).Since the data presented on the 8-bit-

VHF COMMUNICATIONS 3/2007

131

Page 3: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

wide output port RB0-7 is only written tothe HD44780, the R/W input ishardwired to ground (/Write). The LCDback light LEDs are supplied through

two 10Ω current limiting resistors.

The input signal level is fed to the only

Fig 2: Circuit diagram of the frequency counter.

Fig 3: PCB layout for the frequencycounter.

Fig 4: Picture of the component sideof the counter PCB.

VHF COMMUNICATIONS 3/2007

132

Page 4: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

remaining PIC peripheral used in thisproject, the A/D converter. The latter hasa resolution of 10 bits, but only the mostsignificant 7 bits are used. These drive abar indicator on the LCD module with 36segments, corresponding to an inputvoltage between zero and 1.4V (fullscale) on the analogue inputs RA0 (MWmode) or RA1 (RF mode). The operatingmode is selected with switches drivingthe digital inputs RA4 and RA5.

The main counter module is built on asingle sided printed circuit boardmeasuring 60mm x 60mm. Good quality

IC sockets are used for the PIC 16F876Aand as connectors. The PCB layout isshown in Fig 3 and the component layoutin Figs 4 and 5.

Most of the components are in SMDpackages and are installed on the bottom(solder) side of the printed circuit board.Due to the single sided circuit, manyjumpers are required. The PCB isdesigned for 0805 jumpers shown as 0Ron the picture of the completed board Fig5.

A 20MHz crystal is used both as a clock

Fig 5: Picture of the track side of the counter PCB with SMD compoenetsfitted, note the 0R links.

VHF COMMUNICATIONS 3/2007

133

Page 5: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

source for the PIC and as a frequencyreference for the frequency counter.20MHz crystals are usually designedeither for 20pF - 32pF parallel resonanceor series resonance. Since the internaloscillator inside the PIC 16F876A is notable to oscillate on the correct frequencywith large capacitors, a series inductor isrequired to bring the crystal on the exactfrequency. The recommended 2.2μHinductor is suitable for 32pF parallelresonance crystals. Of course, the PIC 16F876A is also ableto operate with an external clock source.This has to be connected to pin 9 whilepin 10 is left open. If a high qualityfrequency reference for 5MHz, 10MHzor 100MHz is avai lable , i t i srecommended to multiply or divide itsoutput to obtain the required 20MHzclock. Other clock frequencies than 20MHz canbe accepted by modifying the software toobtain the 10kHz TMR0 interrupt. TheTMR0 time constant allows changing theclock in 80kHz frequency steps (4 clockcycles per instruction and divide-by-2prescaler for the TMR0). Smaller clocksteps of 40kHz can be obtained byinserting NOP instructions in the TMR0interrupt routine, for example using ahigh quality (telecom SDH) TCXO for19.44MHz.

2.Front ends

The counter is equipped with threedifferent front ends. The front ends arebuilt as separate modules to allow aneasy interchange as better components(prescalers) become available or newrequirements show up.

2.1 Microwave prescalerThe microwave prescaler front end isdesigned around the NEC μPB1505 chip,the circuit diagram is shown in Fig 6.This counts up to 4.9GHz and unlike theproducts from some other manufacturersit is very reliable. An ERA-2 MMIC isused to boost the input sensitivity andprovide some protection for theμPB1505. The ERA-2 can accept inputsignal levels up to +15dBm (30mW). A6dB attenuator behind the ERA-2prevents saturating the μPB1505.

A 33kΩ resistor can be used to kill theself oscillation of the μPB1505 around2.6GHz, but this resistor also adverselyaffects the sensitivity and the maximum

Fig 6: Circuit diagram of the microwave prescaler.

VHF COMMUNICATIONS 3/2007

134

Page 6: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

frequency of the prescaler. A BAT62-03W zero bias schottky diode is used as asignal level detector. The gain of theERA-2 sets the full scale on the barindicator to about 0dBm.

The microwave prescaler front end isbuilt on a single sided printed circuitboard measuring 30mm x 60mm. ThePCB layout is shown in Fig 7 and thecomponent layout in Fig 8. The 50Ωlines are built as coplanar waveguides ona 1.6mm thick FR4 substrate. The inputcable is soldered directly to the PCB. Toavoid parasitic resonances between thePCB and metal ground plane, twoadditional 39Ω damping resistors areinstalled in series with two mountingscrews.

2.2 RF front endThe RF front end is designed for a highinput sensitivity and low (close to 50Ω)input impedance. The circuit diagram isshown in Fig 9. A high input impedance

(as offered in many counters) is actuallya disadvantage for RF measurements, lastb u t n o t l e a s t c o r r u p t i n g t h emeasurements due to low frequency(50Hz mains or switching powerssupply) interference. The RF front endincludes a simple RF amplifier with aBFP196 transistor, an input protectionwith a 33Ω resistor and a LL4148 diodeand a signal level detector using aBAT62-03W zero bias schottky diode.

The RF front end is built on a singlesided printed circuit board measuring20mm x 60mm. The PCB layout isshown in Fig 10 and the componentlayout in Fig 11

The input cable is soldered directly to thePCB. Since the RF front end does notinclude any hysteresis, it is not able tooperate with sine wave signals at verylow frequencies.

2.3 TTL front endThe TTL front end is a high impedanceinput. DC coupling is necessary tomeasure pulses with arbitrary dutycycles. The circuit diagram is shown inFig 12 Further it includes hysteresis forreliable low frequency measurements,regardless of the waveform. The circuitincludes a BF998 MOSFET sourcefollower and a 74F04 schmitt trigger.The output of the schmitt trigger is againDC coupled to the 2N3960 in the maincounter module.

Fig 7: PCB layout for the microwaveprescaler.

Fig 8: Componentlayout for themicrowaveprescaler.

VHF COMMUNICATIONS 3/2007

135

Page 7: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

The TTL front end is built on a singlesided printed circuit board measuring20mm x 60mm. The PCB layout isshown in Fig 13 and the componentlayout in Fig 14. The input cable issoldered directly to the PCB. Inputprotection is provided by the 470Ωresistor and the zenner diodes inside theBF998 (breakdown voltage between 8Vand 12V). Further protection could beobtained by additional zenner diodes,however the latter may include a largecapacitive loading (more than 100pF).

3.Assembly

All counter modules require a +5Vpower supply. A 7805 regulator is asimple and efficient solution. Someadditional components are required forinterference and switching transientsuppression. The circuit diagram of thepower supply is shown in Fig 15 The7805 regulator is bolted directly to therear panel for heat sinking.

Two DPDT switches are used for frontend selection. An additional switch isused to select the gate time.

All four printed circuit boards are singlesided, etched on 1.6mm thick FR4laminate (image resolution is 150dpi).

Fig 10: PCB layout for the RF frontend.

Fig 11: Componentlayout for the RFfront end.

Fig 9: Circuit diagram of the RF front end.

VHF COMMUNICATIONS 3/2007

136

Page 8: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

The counter is installed in a box made ofaluminium sheet shown in Fig 16. Thebottom is made from 1mm thickaluminium sheet, the cover is made from0.6mm thick aluminium sheet and theLCD is protected by a small piece ofplexiglass. The internal width is 200mm,depth 100mm and height 45mm.

The RF connectors, switches and LCDmodule are installed on the front panel.The power supply connector is installedon the rear panel.

4.Operation

Immediately after power up, the counterdisplays the software version/date forabout one second.

During normal operation, the leftmostcharacters of both rows are used as avertical bar display of the gate progresswith 10 horizontal segments. Theremaining 15 characters in the top row ofthe display show the measuredfrequency. Three characters in the bottomrow show the operating mode ("MW","RF" or "TTL") and the remaining 12characters are used as a horizontal bardisplay of the signal strength with 36vertical segments.

In the microwave mode both prototypes

Fig 13: PCB layout for the TTL frontend.

Fig 14: Componentlayout for the TTLfront end.

Fig 12: Circuit diagram of the TTL front end.

VHF COMMUNICATIONS 3/2007

137

Page 9: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

operated reliably up to 4.9GHz with aninput signal level of 0dBm (selfoscillating μPB1505 without 33kΩresistor). Below 3GHz the sensitivityimproves to -30dBm. The 33kΩunbalancing resistor to stop selfoscillations degrades this sensitivity bymore than 10dB! Below 500MHz thesensitivity degrades again: the countermay count odd harmonics with too lowsignal levels. The minimum usablefrequency was found around 12MHz. Fig17 shows the counter in the microwavemode with a gate time of 640mscorresponding to a resolution of 100Hz.

In the RF mode the 74F50109 allowscounting up to about 220MHz. Reliableoperation is possible up to 190-200MHz,depending on the internal wiring to theswitches, with an input-signal level of0dBm. The sensitivity improves from -20dBm at 180MHz down to -50dBm at

10MHz. The RF signal-level meterfollows a similar increase in itssensitivity. This increase at lowerfrequencies matches the performance ofthe described loop probes!U n f o r t u n a t e l y , t h e 7 4 F 5 0 1 0 9 ,manufactured by Signetics (Philips) isnot easily available. A 74F109 from thesame manufacturer only operated up toabout 140MHz. A combination of74AC109 and 74AC74 (both fromNational Semiconductor) counted up toabout 170MHz. The 74ACxxx logiccircuits require a different input DC bias:replace the 2.2kΩ resistor between theinput and the collector of the 2N3960with a 47kΩ resistor. All four pull-upresistors can be omitted with 74ACxxxlogic. Finally, the 2N3960 itself does nothave many valid replacements. A2N2369 will decrease the 74F50109counting rate down to just 165MHz whileRF and microwave transistors provide

Fig 15: PSU circuitdiagram for thefrequency counter.

Fig 16: A pictureof the completedfrequency counter.

VHF COMMUNICATIONS 3/2007

138

Page 10: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

even worse results!In the TTL mode the prototypes operatedreliably beyond 100MHz. This frequencylimit is however reduced by the coaxialcable feeding TTL signals and even morewhen using oscilloscope probes. Theinput signal level is not indicated in theTTL mode. The built in hysteresis allowsreliable counting of very low frequencies,like the 50Hz mains.The current software version does notdetect the mode switching before the endof the gate period. Therefore one mayhave to wait up to 10 seconds for the gateperiod to expire and another 10 secondsto get some meaningful reading. Thecurrent software also does not make anyuse of the measured signal level.Therefore it will display the selfoscillating frequency of the prescalerwith no signal input in the microwavemode or any other invalid data due to lowsignal levels in the RF or microwavemodes. The software is designed using the samerules as the whole counter: keep thisp r o j e c t u s e f u l , s i m p l e a n dstraightforward. A simple prescaler istherefore used in place of a considerablymore complex direct microwave counter.Some simple 74Fxxx logic ensuresenough overlap between the prescaledmicrowave frequency range and thedirect RF frequency range. A TTL inputwith hysteresis is an efficient solution forlow frequencies and extreme duty cycles.Finally, an input signal level indicator isan inexpensive but very useful addition

to a frequency counter. Last but not least, all detailedinformation like PCB files or softwaresource code are available on MatjazVidmar's web site [2].

5.Probes

A very common problem of manyfrequency counters is that these aresupplied to the end user without (any)su i tab le probes! In fac t , mostRF/microwave sources cannot beconnected directly to a counter input. Theconventional oscilloscope probe is not agood solution for most RF/microwavemeasurements either. Worst of all, mostcounters are not even designed to be usedwith some useful probe types.

Any serious RF/microwave engineer hashis/her own set of suitable attenuators,circulators, loads and directional couplersto connect spectrum analysers, powermeters, counters and other instruments tothe circuit under test. A complete set oftransitions between different RFconnectors is also required. Finally, anumber of pigtailed connectors to besoldered directly to the circuit under testis always of great help.

Fig 17: The counter in the microwave mode with a gate time of 640mscorresponding to a resolution of 100Hz.

VHF COMMUNICATIONS 3/2007

139

Page 11: A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency reference for the frequency counter. 20MHz crystals are usually designed either for 20pF

A very useful probe to be used withRF/microwave counters is a simpleinductive pickup or in other words a5mm diameter loop at the end of a shortlength of 50Ω coaxial cable. Accordingto my own experience it does not makesense to make this loop much smaller orlarger than 5mm. The same loop can beused from a few MHz up to several GHz.A small resistor (around 50Ω) can beinstalled in series with the loop tosuppress any cable resonances.

The loop is simply approached toinductors or resonators in the circuitunder test (Fig 18). The undesiredloading of the circuit can be minimisedby keeping the loop at the maximumdistance that still provides a stablereading on the counter. Finally, the loopprobe is never affected by low frequency(50Hz mains or similar) interference.Since the coupling to the circuit under

test is not very efficient, it is ratherunlikely to damage the counter with largeRF signal levels.

A standard oscilloscope probe is apractical solution to measure lowfrequencies, pulsed signals and in somecases even RF signals. In order to use anoscilloscope probe efficiently, theinternal operation of the probe has to beunderstood (Fig 19). Most probes areequipped with a X1/X10 switch. Furtherthere is a series damping resistor (around500Ω) to avoid cable resonances thatcould both corrupt the oscilloscopedisplay and severely disturb the circuitunder test . Finally, one shouldunderstand that although the TTL inputof the counter operates in excess of100MHz, the oscilloscope probe mayreduce the upper frequency limit to50MHz or even less!

6.References

[1] 13GHz prescaler, Zeljko Bozic, VHFCommunications Magazine, 2/2006, pp89 – 94

[2] Matjaz Vidmar web site forfrequency counterhttp://lea.hamradio.si/~s53mv/counter/history.html

Fig 18: Loop probes.

Fig 19: Circuit diagram of a standard oscilloscope probe.

VHF COMMUNICATIONS 3/2007

140