A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency...

of 11/11
I decided to design a simple, easily reproducible counter around a PIC 16F876A. The basic counter range is extended to at least 180MHz using two 74Fxx devices. A divide-by-64 prescaler is used for higher frequencies up to at least 4.5GHz. All results of the measurement are shown on an inexpensive, 2x16 alphanumeric LCD module with large characters. A block diagram of the counter is shown in Fig 1. The counter has three front ends: a microwave (prescaled) input, an RF input and a TTL input. The microwave and RF inputs are AC coupled and terminated at low impedance (around 50Ω). The TTL input is DC coupled and has high input impedance. A progress bar indicator is provided on the LCD display for the gate timing. Both the microwave and RF inputs have an additional feature, usually not found in frequency counters: a simple signal level detector driving a bar indicator on the LCD display. This is very useful to check for the correct input signal level as well as an indicator for circuit tuning or absorption wave meter dip display. 1. The counter The whole counter design is based on a 16F876A PIC microcontroller. This includes several peripherals but just a Matjaz Vidmar, S53MV A simple RF/Microwave frequency counter Fig 1: Block diagram of the frequency counter. VHF COMMUNICATIONS 3/2007 130
  • date post

    06-Mar-2018
  • Category

    Documents

  • view

    254
  • download

    4

Embed Size (px)

Transcript of A simple RF/Microwave frequency counter - VHF · PDF filesource for the PIC and as a frequency...

  • 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

  • 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. Its 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 100s timer, the TMR1 is notallowed to generate interrupts. TheTMR1 overflow (interrupt) flag ischecked during every 100s (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 the100s (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

  • 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

  • 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

  • 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.2Hinductor 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 thePB1505. 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

  • 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 50lines 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.