a pic-based hf/vhf power meter - ka7exm · pdf filea pic-based hf/vhf power meter by roger...

8
May/June 2005 3 13405 SW Juanita Pl Beaverton, OR 97008 [email protected] A PIC-based HF/VHF Power Meter By Roger Hayward, KA7EXM Add an LCD display and a versatile pic-Programmed CPU to this popular log amp for 80 dB of calibrated resolution on your bench. Introduction A variety of articles has been pre- sented recently on simple, accurate, power measurement using a logarith- mic amplifier by Analog Devices. The article by Wes Hayward, W7ZOI, and Bob Larkin, W7PUA, 1 revealed the AD8307 log amp, capable of measure- ments from –80 dBm to +7 dBm and from 1 to 500 MHz. Measurements can be taken to levels up to nearly 100 W with the use of an easy-to-build 40 dB tap. As is the case with most power meters, an accurate calibration step is required. This is performed by using either a signal of known level, or by comparing an unknown signal level against another calibrated measure- ment device. Bob Kopski, K3NHI, presented an article describing a way to provide the home-experimenter with a method to calibrate the meter. He translated the output of the log amplifier into a 1 mV/ dB range, such that the measurements could be displayed by a digital volt- meter (DVM) module without the need to convert measurement levels through a lookup chart. 2 In a later paper, he presented a simple RF sig- nal source that can be calibrated with an oscilloscope or RMS voltmeter. 3 This project begins with the same log amplifier, and adds a PIC proces- sor, LCD display and user control. With a small on-board microprocessor, significant additional features may be employed: Calibration points are stored within the FLASH memory of the PIC pro- cessor. Power measurement levels are dis- played on the screen in dBm, and, optionally, in watts. When using a coupler, on-screen off- set is included within the software. A high-accuracy differential mea- surement mode allows the opera- tor to measure insertion loss with resolution better than 0.1 dB. Amplifier gain, return loss and even VSWR can also be measured and displayed with this differential mode. There are two goals in the presen- tation of this article: First, if you haven’t built a general-purpose RF 1 Notes appear on page 10.

Upload: vutuong

Post on 06-Feb-2018

275 views

Category:

Documents


9 download

TRANSCRIPT

Page 1: A PIC-based HF/VHF Power Meter - KA7EXM · PDF fileA PIC-based HF/VHF Power Meter By Roger Hayward, KA7EXM Add an LCD display and a versatile pic-Programmed ... the RF measurement

May/June 2005 3

13405 SW Juanita PlBeaverton, OR [email protected]

A PIC-basedHF/VHF Power Meter

By Roger Hayward, KA7EXM

Add an LCD display and a versatile pic-ProgrammedCPU to this popular log amp for 80 dB of

calibrated resolution on your bench.

IntroductionA variety of articles has been pre-

sented recently on simple, accurate,power measurement using a logarith-mic amplifier by Analog Devices. Thearticle by Wes Hayward, W7ZOI, andBob Larkin, W7PUA,1 revealed theAD8307 log amp, capable of measure-ments from –80 dBm to +7 dBm andfrom 1 to 500 MHz. Measurements canbe taken to levels up to nearly 100 Wwith the use of an easy-to-build 40 dBtap.

As is the case with most powermeters, an accurate calibration step is

required. This is performed by usingeither a signal of known level, or bycomparing an unknown signal levelagainst another calibrated measure-ment device.

Bob Kopski, K3NHI, presented anarticle describing a way to provide thehome-experimenter with a method tocalibrate the meter. He translated theoutput of the log amplifier into a 1 mV/dB range, such that the measurementscould be displayed by a digital volt-meter (DVM) module without theneed to convert measurement levelsthrough a lookup chart.2 In a laterpaper, he presented a simple RF sig-nal source that can be calibrated withan oscilloscope or RMS voltmeter.3

This project begins with the samelog amplifier, and adds a PIC proces-sor, LCD display and user control.With a small on-board microprocessor,

significant additional features may beemployed:

• Calibration points are stored withinthe FLASH memory of the PIC pro-cessor.

• Power measurement levels are dis-played on the screen in dBm, and,optionally, in watts.

• When using a coupler, on-screen off-set is included within the software.

• A high-accuracy differential mea-surement mode allows the opera-tor to measure insertion loss withresolution better than 0.1 dB.

• Amplifier gain, return loss and evenVSWR can also be measured anddisplayed with this differentialmode.

There are two goals in the presen-tation of this article: First, if youhaven’t built a general-purpose RF

1Notes appear on page 10.

Page 2: A PIC-based HF/VHF Power Meter - KA7EXM · PDF fileA PIC-based HF/VHF Power Meter By Roger Hayward, KA7EXM Add an LCD display and a versatile pic-Programmed ... the RF measurement

4 May/June 2005

Fig 1—Exterior view of the PIC powermeter.

Fig 2—Log amplifier voltage output is interpreted between three calibration points, A, Band C. For relative measurements, an absolute reference is determined and a higher-gainslope output is used to determine the relative change.

power meter for your bench yet, thismay be of interest for you. Second, thePIC code is available in both pre-programmed format, as well as insource-code. With a relatively small in-vestment, the amateur has the capa-bility of developing new projects basedupon the generic PIC and LCD mod-ule presented in this article.

For those interested in replicatingeither part of the design, parts areavailable from Kanga US.4

Theory of OperationThe heart of the entire system in-

volves the Analog Devices AD8307 loga-rithmic amplifier. This part accepts RFinput from 1 to 500 MHz, and convertsthe power level to a voltage. The con-version is on a logarithmic scale, suchas 25 mV of output change per dBchange in input power. The output volt-age is then scaled by an op amp toroughly 50 mV/dB, such that the entire–80 to +7 dBm range spans from 0 tojust under 5 V. This range may be eas-ily captured by an A/D converter andconverted from V to dBm through alookup and interpolation step.

The Microchip-PIC chosen is the18F452.5 The built-in A/D converterhas a resolution of 10 bits or 1024unique values. Assume for a momentthat the RF range of 87 dB spans 0.5V to 4.5 V to the A/D converter. Thisuses 80% of the 1024 points in theA/D converter. With 80 dB relating to800 points, the highest resolutionavailable is roughly 0.1 dB per stepfrom the converter. This limits mea-surements to a ±0.1 dB resolution.

For some applications, power mea-surements accurate to ±0.1 dB are prob-ably sufficient. If you are measuring theoutput power of a transmitter, 0.1 dBvariations in output level are minor.However, if you are checking insertionloss of a filter, or trying to measure theloss in a piece of coax, an error of0.1 dB may be large. Faced with thisdeficiency, I was prompted to find a wayto improve the resolution of the powermeasurement system, without movingto a higher-cost A/D converter.

One simple way of improving theresolution was to add even more gainafter the log amp output. Additionaldc gain (for example, another 5×) canbe added after the log amp to gener-ate greater sensitivity. This creates asystem with 250 mV/dB of sensitivity.Although this exceeds the specified ab-solute accuracy of the AD8307, it is notsignificant for difference measure-ments.

From this, the concept of relativepower measurement is introduced. Fora given input power level, remember

this value and establish a referencevoltage. The power meter then mea-sures the difference from this point,and places a high gain in the signal,allowing the A/D converter to see farmore resolution than during the ab-solute power measurement mode. Thisis shown in Fig 2. The absolute gaincurve depicts the expected output volt-age for a given input level. The rela-tive power gain curve depicts theoutput voltage, once a reference pointhas been established.

A D/A converter is required to set upa reference signal. The Analog DevicesAD7391 is a low-cost 8-bit DAC thatoperates off a single +5 V supply andhas a serial interface that is easily con-trolled via the PIC processor. With thisand a differential op amp (with gain), ahigher-resolution measurement may beperformed.

The reference signal is set up to pro-vide a 2.5 V output from the differen-tial amplifier upon initial setup. Witha feedback gain of approximately 5 inthe op-amp circuit, changes in powerlevel on the order of 0.02 dB relate to a

single bit of resolution in the 10-bitA/D converter. Although a change of0.02 dB is probably nonsense on theworkbench, it does provide the assur-ance that measured values on the or-der of 0.1 dB are now indeed believable.

The bulk of this system is controlledthrough software inside the PIC proces-sor. Since the PIC has multiple A/D con-verter inputs, both the absolute(RF_ABS) and relative (RF_DIFF)power measurements are capturedseparately. If the operator wishes tomeasure insertion loss, or antenna re-turn loss, the software will automati-cally keep track of what measurementmode the meter should be running in.When relative measurements exceedthe range of the higher-gain differen-tial amplifier, the program will auto-matically shift to using the absolutepower measurement value to determinethe difference. The resolution of themeasurement will change on the dis-play, depending upon which internalmeasurement mode is being utilized.

Consider the example shown inFig 2. If the input signal level is at–28 dBm, then the absolute powermeasurement A/D measures approxi-mately 3.2 V (as seen on the left axis).If a relative measurement needs to betaken from this point, the circuitry willset up a reference value such that therelative power measurement A/D in-put is 2.5 V (as seen on the right axis).Any change in the power level fromthis point on will result in a greaterchange on the relative slope than onthe absolute slope.

By setting the initial referencepoint at half of the supply voltage, the

Page 3: A PIC-based HF/VHF Power Meter - KA7EXM · PDF fileA PIC-based HF/VHF Power Meter By Roger Hayward, KA7EXM Add an LCD display and a versatile pic-Programmed ... the RF measurement

May/June 2005 5

Fig 3—PIC and display module—schematic diagram.

Page 4: A PIC-based HF/VHF Power Meter - KA7EXM · PDF fileA PIC-based HF/VHF Power Meter By Roger Hayward, KA7EXM Add an LCD display and a versatile pic-Programmed ... the RF measurement

6 May/June 2005

Fig 4—RF measurement module—schematic diagram.

Fig 5—Inside view of the meter. The CPUmodule is on the top, the RF measurementsection is on the bottom. The LCD ismounted under the CPU module.

high-resolution system can measuregain as well as loss.

Because the PIC processor containsflash memory, three calibration points(A, B and C) may be stored within themeter. Any measurement betweenthese three data points are interpo-lated automatically. In addition, therelative power measurement mode (D)may be calibrated with any 3 dB to 10dB attenuator and any RF signalsource as input. These will be illus-trated in the examples below.

CPU ModuleThe CPU module utilizes the PIC

18F452. A crystal provides the CPUclock. An on-board voltage regulatorallows the system to be run from a 9V battery.

Various header pins are exposed onthe top and bottom edges of the board.Analog input is on J105. J103 providesroom for the four function buttons.J104 controls the D/A converter

through a 3-wire serial interface. U104is a Lumex 2×16 character LCD. It ismounted on the back side of the PCBwith 4-40 standoffs.

There are two LEDs on the CPUmodule. Although these are for debugpurposes, I would encourage you to in-clude them. The CPU’s most-common

event is watching the four user-inter-face buttons. Within this routine, thetwo diodes are toggled. Under normaloperations, they should continuallyflicker. An occasional stall indicates thatthe CPU is doing something more im-portant than watching the state of thebuttons (such as performing an A/D con-version, or calculating the power orVSWR, updating the LCD display, etc).It is a great way to verify (even beforegetting the LCD connected) that thePIC is alive and well.

On one end of the CPU board isJ102, a header that matches Micro-chip’s ICD header. This allows the de-veloper to program the PIC in place.Although the header is not requiredfor normal power-meter operation,R101 must still be inserted on theboard, in order to keep the part run-ning the stored program.

A large bank of 2.2 KΩ pull-up re-sistors for the push buttons is present,along with a number of headers sur-

Page 5: A PIC-based HF/VHF Power Meter - KA7EXM · PDF fileA PIC-based HF/VHF Power Meter By Roger Hayward, KA7EXM Add an LCD display and a versatile pic-Programmed ... the RF measurement

May/June 2005 7

rounding the PIC, for off-board inter-action.

The board has an empty SO-16 foot-ing, along with a few landings forelectrolytic capacitors. These willaccommodate an RS-232 interface fora future project.

RF ModuleBecause of the low-level signals to

be measured, the RF module was de-signed from the start to be on its ownRF-shielded board.

Fig 4 shows the RF module. The logamp is the Analog Devices AD8307 inan SO-8 package. The RF input stageis virtually identical to the previousdesign of Hayward and Larkin, includ-ing slight equalization to level themeasurement accuracy at higher fre-quencies. The absolute RF output issent to a quad op amp. An AD7391DAC provides the reference voltage forthe high-precision circuitry.

The RF module utilizes surfacemount technology throughout. Al-though this was not an absolute re-quirement, some components (such asthe AD8307) are readily available inSO-8 packaging, while the DIP-8 of-ten has a longer lead time. With nopitches tighter than 0.05”, it is stillpractical to hand-solder these parts tothe printed circuit board.

While studying the schematic, youmay encounter additional componentsin places where you might not expectthem. I encountered some noise issueswith the AD7391 DAC in an earlierprototype. In an effort to isolate thenoise, I employed extra decoupling andbypass stages. Two separate voltageregulators provide a clean supply toeach of the two 5 V devices. Series re-sistors, along with the 0.1 uF capaci-tors, in and out of the regulators actas a low pass filter, designed to stopstray noise from working its waythrough these stages. Series resistorsnear the inputs of op-amps also iso-late noise. I switched to the LM324, aquad op-amp, so I could further iso-late potential noise by adding twopass-thru stages between the DACand the differential amplifier.

The RF module must be enclosedin its own RF-tight enclosure. A lim-ited number of interface wires shouldall be fed to the board via 1000 pF feed-through capacitors, soldered on thewall of the RF enclosure.

Operating the MeterWith the advent of newer miniature

“appliances” from the major vendors,most Amateur Radio operators havebecome accustomed to driving their ra-dios by way of some menu-driven in-

terface. Often, the bottom of the LCDdisplay is lined with push buttons. Thebuttons perform different features, de-pending upon what the radio is doing.The operator can shift to another bankof features by pressing an F button, orperhaps scrolling an optical shaft en-coder until the desired selection isfound.

I’ve grown accustomed to scrollingaround within the menu system tochange power levels on my FT-817,alter CW speed, or rapidly pop be-tween memories or bands. The ’817incorporates an F, or function key thatwakes up the bottom line of the dis-play into a menu-driven mode. But-tons A, B and C perform variousfeatures as indicated on the display.On the ’817, pressing F turns the menuon and off, while advancing to the nextbank of menu features is accomplishedwith the small optical shaft encoder.

I chose to integrate a similar ap-proach on the power meter. Subsequentpresses of the F button will advance theoperator to the next set of features.Typically after choosing a setting, themenu line will return to blank until youneed to set or change something again.

Calibrating Absolute PowerMeasurements

Upon first power-up, the meter willmove factory settings from ROM toflash memory. You will want to cali-brate your meter before taking anyserious measurements. For our discus-sion, assume for a moment that youhave a signal generator capable ofoutput at –70 dBm to +7 dBm.

Three calibration points need to bestored within the meter. It is impor-tant to make sure that Pa < Pb < Pc, asthe interpolation code assumes this.The strongest level, Pc, will be +7 dBm,as an overload warning will triggerwhen any level exceeding this valueis detected.

You may set the calibration pointsin any order you choose. Let’s beginwith point A on the absolute powercurve shown in Fig 2.

The push button under the powerswitch (see Fig 1), acts as the F orfunction key. Press F until the displayreveals the prompt CALA. Press CALA.Apply a very weak signal to the meter,such as –70 dBm. To tell the meterthat this is –70.0 dBm, select the SET_DB button. Use the UP and DOWN but-tons to set the display to the exactvalue that you are applying to themeter, such as –70.0 dBm. The cali-bration point will move in 0.1 dB steps.If you press-and-hold the UP or DOWNbutton, the meter will scroll in 1.0 dBsteps to speed up the process. Once the

display matches the known signallevel, press SAVE. This point has beencalibrated and stored in to the flashmemory of the PIC processor.

If you wish to back out of the cali-bration process, press the F key and thedisplay will return to normal operation.

Repeat the procedure again for a +0dBm signal (or so). This is CALB. Aftersetting the B point, carefully apply a+7 dBm signal source and calibrate forpoint C.

Note that the CALC point of calibra-tion should be set near the strongestacceptable power level for the log amp.Signal levels in excess of +10 dBm mayharm or destroy the log amp. To alertthe operator of an overload, the meterwill flash the measured value on thedisplay, an indication that the inputsignal level needs to be reduced to asafer level.

At this point, your meter is cali-brated against your signal source. Varythe amplitude of the input signal levelto see how well things track. The metershould reflect changes across the spanover which it was calibrated.

When setting calibration points,note that a voltage is present on thedisplay as well. This is the actual mea-sured voltage presented to the A/Dconverter (RF_ABS). Write the dBmand voltage pair down for each ofthree calibration points into your note-book. If you ever need to re-calibratethe meter in the future without a wide-range signal generator, the meter al-lows you to enter the calibration pointswithout a signal source. With no sig-nal source required at the input, sim-ply calibrate the dBm value first, thenenter the voltage by selecting theADJ_V button in the calibration menu.

Calibrating the Differential-Mode Measurement System

To calibrate the absolute powermeasurement points, we input aknown power level to the system andask it to remember the value. Tocalibrate the relative measurementsystem, we have to provide a knownrelative change in power. The easiestway to do this is with an RF carrierand an attenuator of known value.

Apply a signal source to the meter,somewhere in the 0 to –10 dBm range(it is not critical, as long as it is stable).Press F , then ZERO, and wait for themeter to converge on this signal. Thesecond line should show +0.00 dB, orsomething very close to zero. Now in-sert an attenuator, such as 10dB, be-tween the signal source and the meter.The relative measurement shouldshow something near –10.00 dB. Tocalibrate this value, press F until you

Page 6: A PIC-based HF/VHF Power Meter - KA7EXM · PDF fileA PIC-based HF/VHF Power Meter By Roger Hayward, KA7EXM Add an LCD display and a versatile pic-Programmed ... the RF measurement

8 May/June 2005

Table 1—Parts list for the PIC and display module shown in Figure 3.Digi-Key part numbers (DK) are shown.

C101, 102—0.22 µF, 50 V, X7R 1206 DK-399-1251-1-NDC103, 104—0.1 µF, X7R 1206 DK-399-1248-1-NDC105, 106—33 pF, 50 V, NP0 1206 DK-399-1199-1-NDD101—Red, LED (small) DK-67-1069-ND or equiv.D102—Yellow, LED (small) DK-67-1078-ND or equiv.R101—1 kΩ, 5%, SMT 1206 DK-P1.0KECT-NDR102—10 kΩ, variable DK-3329H-103-NDR103, 104, 106—112—2.2 kΩ, 5%, SMT 1206 DK-P2.2KECT-NDU101—78L05-SOT89 DK-NJM78L05UA-NDU102—PIC18F452 (requires programming, see text) DK-PIC18F452-I/P-NDU104—LCM-S01602DSR/A DK-67-1768-NDX101—20 MHz, CA-301 DK-SE3438-ND

Table 2—Parts list for the RF measurement module shown in Figure 4. Digi-Key part numbers (DK) are shown.

C201, 202, 205 – 211, 213—0.1 µF X7R 1206 DK-399-1248-1-NDC203—15 pF, 50 V, NP0 1206 DK-399-1194-1-NDC204—0.01 µF, 50 V, X7R 1206 DK-399-1234-1-NDC212—10 µF tantalum DK-478-1762-1-NDL201—10 nH, 10%, SMD 0805 DK-PCD1160CT-NDR201—51 Ω, 5%, SMT 1206 DK-P51ECT-NDR202—470 Ω, 5%, SMT 1206 DK-P470ECT-NDR203, 204, 211, 212, 215—22 Ω, 5%, SMT 1206 DK-P22ECT-NDR205—6.8 kΩ, 5%, SMT 1206 DK-P6.8KECT-NDR206, 208, 214—4.7 kΩ, 5%, SMT 1206 DK-P4.7KECT-NDR207—1 kΩ, 5%, SMT 1206 DK-P1.0KECT-NDR209, 210, 216, 217—100 Ω, 5%, SMT 1206 DK-P100ECT-NDR213—1 kΩ, 5%, SMT 1206 DK-P1.0KECT-NDU201, 205—78L05-SOT89 DK-NJM78L05UA-NDU202—AD8307AR, log amplifier, SO-8 DK-AD8307AR-ND (or direct from Analog Devices)U203—AD7391AR 8-bit DAC, SO-8 DK-AD7391AR-ND (or direct from Analog Devices)U204—LM324 quad op amp, SO-14 296-9540-5-ND

see the CALD (short notation for Cali-brate-Differential) button. Select it.The values you see reveal the gain ofthe op amp. As you did with the abso-lute power measurement system, allyou have to do is press SET_ DB, andenter the amount of attenuation youhave applied to the signal (such as10.0 dB), then press SAVE. From thispoint on, differential power measure-ments are calibrated against your at-tenuator. Again, you may want to writethis value down for future reference.

Calibrating the Tap OffsetI find it very handy to grab my

40 dB tap for higher power measure-ments. The power meter can be shiftedinto TAP mode, in which the signal levelon the screen will reflect the fact thatthe tap is being used. To toggle this fea-ture, press F, then TAP. The letter T willshow up to the left of the absolute powerlevel, to remind you that you are read-ing a shifted value on the display.

If you wish to read or set the tapcalibration point, simply press F thenpress and hold the TAP button until thecalibration is revealed on the display.To change this value, press SET_ DB.Use the UP and DOWN buttons to stepin 0.1 dB steps (press and hold to stepin 1 dB steps). When you have thevalue of your tap, press SAVE.

Although the TAP position is gener-ally thought to correspond to the tapdescribed in the earlier article by Hay-ward and Larkin, it could also be an-other circuit. This could be a powerattenuator, a fixed-gain amplifier, ora directional coupler.

General OperationOnce the calibration points are set,

the meter becomes quite simple to op-erate. Just turn the meter on and wait

for the banner message to clear. Thetop line of the meter always revealsabsolute power level measured.

If you wish to show the power levelin watts, press the F button until themW button is found. The power levelwill auto-scale from picowatts to watts,and be shown on the bottom line. Ifyou are using a tap offset device, youwill see power in watts at the tap in-put on the display. Remember to neverexceed +7 dBm into the front end ofthe meter, or +47 dBm into the tapwith the 40 dB tap being used.

For most toggle modes, such as dis-playing power in watts, the menu willshow the > character next to the menuitem, to indicate this mode is active.

To perform a differential power mea-surement, you must first present thesignal to the meter and let it establisha baseline. Press F, then ZERO. A * willappear on the display while the pro-gram converges to the reference signal.The second line of the display will showthe difference, in dB. Note that this linewill provide a resolution of 0.01 dBwhen the high-precision mode is active.The resolution of the display will shift

to 0.1 dB automatically (a digit will dis-appear), once the range of the high-pre-cision mode has been exceeded. A slightjump in relative measurements may benoticed during the transition, as theCPU shifts from interpolating with thehigh-resolution mode and associatedcalibration points, and the lowerresolution of the absolute power mea-surement. The high-resolution mea-surement mode typically falls out ofrange beyond roughly ±10 dB.

Upon completion of differentialpower measurement, simply pressF ZERO again, and the meter will re-turn back to normal operation.

Some operators may wish to use themeter with a directional coupler tomeasure antenna return loss. Connectthe return loss bridge such that themeter is detecting reflected power.With the antenna disconnected, applya test signal to the meter and pressF ZERO. Then, connect the antenna.The return loss will be shown as a rela-tive power measurement on the sec-ond line of the display. If you wish todisplay this as VSWR, select theVSWR mode through the menu.

Page 7: A PIC-based HF/VHF Power Meter - KA7EXM · PDF fileA PIC-based HF/VHF Power Meter By Roger Hayward, KA7EXM Add an LCD display and a versatile pic-Programmed ... the RF measurement

May/June 2005 9

Table 3—Interconnect parts list.

C221-226—1000 pF feed-thru capacitor EMI-ZPC102D or equiv.SW-A, B, C—N.O. push-button, black cap DK EG2011-ND or equiv.SW-F—N.O. push button, red cap DK EG2015-ND or equiv.EMI—EMI Filter Company (www.emifilterco.com)

I found it extremely handy to moni-tor the values measured by the A/Dconverter during debug and test. Thismay be toggled by pressing the V but-ton under the menu.

If for any reason you want to restorethe meter back to its default settings, aback door has been provided. With themeter shut off, press and hold the B andC buttons together, and turn the meteron. You will see the display begin withRESETTING FACTORY SETTINGS. Fromthere, you will want to re-calibrate, orenter your calibration points again.

SoftwareThe source code is available for ex-

amination or augmentation, from theWeb site listed at the end of the article.It could also serve as a good springboardfor the development of other projects aswell, since the LCD driver code, flashmemory, and interactive menu have al-ready been written. Since all of the RFmeasurement hardware is on its ownsub-assembly, the CPU/LCD could beused for other creative ideas within theamateur community.

I chose to write the program in C(and purchase the C-compiler), ratherthan to write the application in assem-bly language. This was a directtradeoff between my time and my fi-nancial resources. Although every-thing could have been performed inassembly, my family and I are happyI chose the route of purchasing thecompiler. CCS7 provides not only thecompiler, but many useful tools to easethe development of any project. Testcode, interrupt handlers, and functionsfor manipulating the flash memoryare all available as part of the stan-dard CCS compiler package. This al-lows the developer to concentrate moreon the application at hand, and lesson the inner workings of the PIC.

Programming the PIC processorwas accomplished with the MicrochipUSB ICD-2 module. With the additionof the header J102, the PIC may beprogrammed and re-programmedcountless times without the need toremove the part from the board. Thiswas vital to the development of theproject, as new ideas could be codedand tested within the shack, withoutthe need for expensive programmersor JTAG emulators.

Assembly NotesAs is the case of many projects, this

project is best constructed in stages.Depending upon the size of the chas-sis you have selected, it might be use-ful to perform some dry-fit mountingprior to assembly of the modules. Ifound the Hammond 1590J case to be

Fig 6—Interconnection details.

Fig 7—Side cutout details of RF module and enclosure.

large enough to hold both the circuitry,as well as a 9 V battery. If you plan onusing the meter more routinely, it maybe better to choose a larger enclosure,such that six to eight AA batteriescould be used instead.

Start by cutting a hole for the LCD

display, then finding the right loca-tions for the four mounting holes. Dry-fit the LCD bezel until it fits snuglyon the front panel. After this, mountthe bare PCB in place and locate posi-tions for the four push buttons. Spacethe A, B, and C buttons equally across

Page 8: A PIC-based HF/VHF Power Meter - KA7EXM · PDF fileA PIC-based HF/VHF Power Meter By Roger Hayward, KA7EXM Add an LCD display and a versatile pic-Programmed ... the RF measurement

10 May/June 2005

the bottom of the display. The F keycan be located anywhere you choose.

The CPU module board can bebooted without the need to connect theRF module. Start by soldering all re-sistors and capacitors on the back sideof the board. Populate the front-sidecomponents on the board, including thecrystal oscillator section (X101) andcapacitors. Finally, solder in the socketfor U102, the PIC processor. After veri-fying that the 5 V regulator is supply-ing voltage to the board, it is time toconfirm that the pre-programmed PICprocessor springs to life. Install the pro-cessor into the socket and verify theboard is operational by applying powerand viewing the LEDs D101 and D102on the circuit board. (It may take up to10 seconds after power is applied to seethe LEDs begin to flash.) Once this isverified, mount the LCD on to the backof the board, and mount all 16 wiresfrom the LCD to the CPU board. Thesepads line up with one-another such thatonly a 0.25 inch piece of bare wire isneeded for each. I used the leads from1/4 W resistors to bridge the two. Again,power up the meter and watch the dis-play for the banner. Adjust the LCDcontrast by varying R102—the displaymay appear blank until this has beenadjusted. Next, wire in the push but-tons to make sure the F, A, B, and C but-tons behave as expected.

With the remaining space in thechassis, it is time to construct an RF-tight box for the measurement mod-ule. The RF PCB was designed to restright onto the pin of a BNC connector.See Fig 7 for a detailed side-cutoutdiagram of the RF module.

Cut a piece of copper-clad materialapproximately 0.1 inch wider on alledges than the RF module circuitboard. Plan on having it rest upagainst the back-side of the frontpanel. Drill a hole for the BNC con-nector, centered over J201 on the RFmodule. Include a ground lug whilebolting on the BNC. Drill another holeat the opposite side of the board, suchthat the printed circuit board will havemechanical stability. Plan on using ashort 6-32 spacer to hold the RF mod-ule away from the copper material.

Using soft 0.75 inch strips of brass,

cut a wall for the back side of the RFmodule. Pre-drill six holes for the feed-thru capacitors in this wall, add thecapacitors, and solder the wall on tothe copper-clad material. This needsto be done before mounting the RFmodule in-place, as it will be nearlyimpossible to get a hot soldering ironto it afterwards.

Verification of RF module operationshould be completed prior to mount-ing it into the chassis. Apply +9 V topins 2 and 1 of J204. Verify each ofthe two 5 V regulators, U201 andU205, are functioning properly. Witha DVM, measure the DC voltage outof the log amplifier and from the out-put of the op amp U204. Rememberthat even with no RF input to the logamplifier, a small residual output willstill be measured. Early prototypes,when shielded properly, measuredapproximately 0.65 V at RF_ABS.

To mount the RF module, slip thecenter pin of J201 directly onto thecenter pin of the BNC connector. Toprovide a solid RF ground to the board,bend the ground lug of the BNC untilthe end of the lug is pushing upagainst the back-side of the RFmodule’s ground plane. You may needto scrape off additional solder maskin the location where the ground lugtouches the ground plane. Using aHOT soldering iron, solder the lug di-rectly to the backside of the PC board.(Do not omit this step. A solid ground-return is required for accurate mea-surements.)

Solder the center pin of J201 to theBNC connector. Mount a 6-32 screwto your spacer on the other end of theboard.

Now that the board is in place, buildand mount the other three sides of theRF box using brass material. Seal thecontainer with a lid made of copper orbrass. Although it is recommendedthat this box be as RF tight as pos-sible, remember that you may want toget back in to the box at some point intime, so don’t seal it so tight that youcan’t get the lid back off again!

After mechanical assembly, com-plete wiring the interface to the CPU.When running in ZERO mode, the DACshould present a 2.5 V output to the

A/D converter on the RF_DIFF net.

AcknowledgmentsA big “Thanks!” goes to Microchip

Application Engineer Steve Bible,N7HPR, for advice and encouragementin working with the PIC on AmateurRadio projects. Thanks also to CCS fortheir generous assistance with the PICC compiler. The PIC CPU, in combina-tion with the CCS C compiler and ICD,proved to be a very easy package forhome project development. Thanks alsoto Wes Hayward, W7ZOI, and BobLarkin, W7PUA, for consultation asso-ciated with this project.

Parts are made available via KangaUS. If you are interested in develop-ing your own project with the CPU/LCD module, it is available separately.Source code may be downloaded viathe authors Web site listed below.

First licensed in 1979, Roger Hayward,KA7EXM, is active in portable VHFhilltopping adventures, as well as ex-periments in the shack. He is married,with three children in Beaverton,Oregon. Experiment notes, softwaresource code and updates, and achronicle of past adventures may befound on his Web site at www.ka7exm.net. You may reach Roger at13405 SW Juanita Pl, Beaverton, OR97008 or at ka7exm@ arrl.net.

!!

Notes1W. Hayward, W7ZOI, and R. Larkin,

W7PUA, “Simple RF-PowerMeasurement,”QST, Jun 2001, pp 38-43.

2R. Kopski, K3NHI, “An Advanced VHFWattmeter,” QEX, May/June 2002, pp 3-8.

3R. Kopski, K3NHI, “A Simple RF PowerCalibrator,” QEX Jan/Feb 2004, pp 51-54.

4Parts are available from Kanga US in avariety of configurations. See www.kangaus.com for details. Pre-programmedCPUs will be available in addition to the fullpart kitting. See Web site for details.

5The Microchip PIC-18F452 is pin-compat-ible with the more popular 16F877. Seewww.microchip.com.

6See Note 1.7Custom Computer Services offers a C com-

piler for most of the PIC processor families.See www.ccsinfo.com for more details.The PCH module was used to compile thecode for the 18F452 target.