WØPCE "Sweep Gen"
Automated DDS Sweep Generator Measurement System
As in original article by Sam Green, WØPCE (in QEX for Nov-Dec 2008)
WØPCE combines a Digital to Analog Converter (DAC), an Analog to Digital Converter (ADC), and a Direct Digital Synthesis (DDS) module to create a swept frequency measurement system called SweepGen. Under control of a PC, the DDS synthesizes a ramping voltage that drives the horizontal input of the display oscilloscope in a repetitive sweep, while also serving as the input signal to the external circuitry-under-test. The output of the external circuitry is buffered by a logarithmic amplifier to provide a very wide dynamic range for RF measurements, as converted by the ADC and read into the PC over a parallel printer port. Custom-designed software applications on the PC analyze and plot the measured characteristics of the external circuitry-under-test. The DAC and ADC are also used separately (without the DDS) to measure the external circuit's transfer function (output voltage vs. input voltage.)
The DAC, ADC and DDS have similar control interfaces, thus enabling them to be easily manipulated by the PC over its parallel printer port. Additional unused parallel port pins can control still another chip with a serial interface. Experimentation has been done to add a second ADC using these pins.
Many uses are described for this flexible measurement system, thus enabling the experimenter to better understand the nature of RF components, transmission lines and electronic circuits being used in projects.
The AmQRP Club’s
Synthesis Daughtercard Kit provides direct digital synthesis on a 1 × 2
inch pluggable card. The new version, called the DDS-60, synthesizes
and the original version that I have synthesizes 1-30 MHz. Several popular
projects based on a variety of microprocessors incorporate the AmQRP DDS daughtercards, and there is free downloadable software available online to
drive the DDS as a variable frequency oscillator or as a sweep generator
when interfaced to a computer parallel port, as shown below.
I wanted to use the DDS as a sweep generator but was disappointed to find that the available sweep generator application sweeps both up and down, and then repeats, while providing no way to display a stable, observable waveform on an oscilloscope. This project describes the changes I made and the features I added once I learned how to program the DDS from a computer parallel port.
I added a discrete output to trigger an oscilloscope sweep at the beginning of a frequency sweep, a digital-to-analog converter (DAC) to synthesize a horizontal sweep, an analog-to-digital converter (ADC) to measure response at each frequency and save the results to a text file, and a logarithmic detector to measure RF signal levels over a wide dynamic range. Unused pins of the same parallel port that controls the DDS control theDAC and the ADC. How cool is that?
I chose an MX7543 for the DAC and a MAX110 for the ADC because they both communicate serially and thus each only requires a few of the remaining pins on the same parallel port as the DDS, and also because MAXIM sent me free evaluation samples.2, 3 This is an honored tradition. The NJQRP Club tells you to obtain a free sample of the DDS chip from Analog Devices and does not include it in the daughtercard kit. I also honored this tradition in obtaining the Analog Devices logarithmic detector and the Texas Instruments reference diodes. TI no longer provides the free sample reference diodes, but Linear Technology does provide equivalents.
This project provides a complete sweep-frequency measurement system that operates very well from 100 kHz to 30 MHz with only the DDS daughtercard, these three chips, a dual op-amp, the voltage reference diodes, and some voltage regulators. The new DDS daughtercard will operate to 60 MHz with appropriate adjustments to the data-word calculation. I offer my thanks to the vendors for these samples.
I put an AD8307 logarithmic detector in the box so it could connect to one input of the ADC.4 This device is so sensitive to pickup from the DDS that it might be better to package it separately. The AD8307 has an enormous dynamic range to provide a display that reaches orders of magnitude below what you can see with an ordinary diode detector.
Both the DDS and the logarithmic detector are direct coupled, so it is possible to work through the audio range. I will discuss difficulties that appear at low frequencies later.
You can download sample software programs from the ARRL QEX Web site.5 I program in C in the Microsoft Visual Studio 6.0 environment, but you can translate my source code to your environment as needed. If you do not program, you can run my executable files from a command line in a DOS window, but you do not get to change anything. You will be stuck with the parallel port at 0x378, the 30 MHz DDS, and the calibration constants for the specific components in my prototype. To get to a DOS window in Windows, click on “Start” and then “Run” and then type “cmd” in the text box that appears. Finally, hit “Enter.”
I expect a real programmer will step up and generate a fully general version of this prototype software with a Windows Graphical User Interface to replace my simple console applications.
Windows does not allow executable application programs running in a DOS window to alter the I/O ports, so install UserPort to enable these programs to access the parallel port.6 Download and unzip UserPort. Copy UserPort.sys to C:\WINDOWS\system32\drivers. To run UserPort.exe, double click on its icon and then click “Start” in the UserPort dialog box. Now, all of these programs reach the parallel port.
Try the simple setups shown below in the Applications section to automate your own measurements! There isn’t much to it besides the DDS daughterboard, four chips, three reference diodes, and three regulators to provide ±5 V and +8 V. The prototype isn’t pretty, but this hardware offers vast capability. Note that I moved the logarithmic detector from the perforated board to a position next to the input connector and that I expended much effort to filter interference conducted by the power leads.
I followed the programming instructions in the data sheet for the Analog Devices AD9850. The heart of the program is the subroutine shown in Figure 4. This routine writes 40 data bits sequentially to pin 2 of the parallel port (DØ) while toggling the clock pin 3 (D1) high and low between data bits, and finally loads the data into the frequency/phase data register by toggling the load pin (D2) high and low. The rest of the program decides the next frequency and computes the value of the variable freqword that constitutes the sequential data bit stream.
I built and debugged prototypes of the DAC and the ADC separately using a solderless breadboard before trying to make them work with the DDS. There is nothing critical here. The clock and data lines of the DAC operate just like the DDS, so the software routines are similar. The ADC is more complex because it has a second data line, a chip select, and a busy output to indicate that data is ready to read, but the principles are the same. Once individual programs work separately, you must take care in programming so that you do not mess up one device while attempting to write to another. Follow the examples in the downloadable source code that I provide.
My Parallel Port wiring was adapted from www.soft-collection.com/images/ParallelPortViever.gif. It shows the allocation of pins on the parallel port to each device. A parallel port has status and control registers at consecutive addresses following the data register that provide more inputs and outputs at the DB-25F connector on your computer. I use six of eight general-purpose pins on the data port that can be inputs or outputs. I use two of five input-only pins read by the status port, and I use all four output pins written to by the control port, including one I provide as a signal to the external trigger input of an oscilloscope time base, when I don’t want to use the horizontal sweep waveform that I generate with the DAC.
In case of any conflict or confusion, I provide references to the manufacturer’s data sheets for the critical components.
The MX7543 Digital-to-Analog Converter
The DAC circuitry closely follows the MAXIM data sheet for bipolar operation. The circuit requires two general-purpose op-amps. You can use a dual op-amp such as an LM358, but I used an LM324 quad op-amp, with three sections in parallel to triple the available output drive current. Unipolar operation requires only one op-amp, but the ability to generate both positive and negative voltages proves worthwhile as, you will see below. Prototype this as I did to be sure you can make it work before building a final circuit.
The DAC interface on the control port is identical to that of the DDS on the data port, except the data and clock pins I selected have inverse polarity, requiring an appropriate software adjustment. The oscilloscope trigger discrete (as we in the aerospace community call individual digital on-off signals) is on the same port, so be sure to toggle only the correct bits when writing to the control port.
The reference diode sets and stabilizes the output voltage range, but the actual voltage is not critical unless you want to do precision work. Calibration constants in the executable software depend on the reference diode value and the offset of the op-amps. These will be close without revising the software if you follow the parts list.
The MAX110 Analog-to-Digital Converter
The MAX110 is a bipolar input ADC. Because the AD8307 always has a positive output, it makes sense to consider using the unipolar MAX111 ADC in this application. This would save one reference diode and increase the measurement resolution by one bit, or a factor of two. I preferred a more general-purpose instrument and selected the bipolar version. Again, the ability to measure both positive and negative input signals proves worthwhile as you will see later.
Software for the ADC is more complex than for the DDS or DAC because there are more lines to write and read, and the main subroutine sequentially reads an output data bit after writing a corresponding input data bit. In addition, there are many options to select in the control word written to the ADC, such as the resolution, which affects the measurement time. The calibration procedure involves several writes and reads.
Incredibly, these MAXIM ADC chips provide very accurate measurements and consistently agree with my Fluke 77 Multimeter. Thermal stability of the reference diodes is critical. After the internal three-step calibration procedure, the input range extends from negative Vref to positive Vref, where Vref equals the sum of both reference diode voltages. It is difficult to gain an understanding of these important points from the data sheet, where the reference diode voltages are REF– and REF+. I, for one, consistently confuse REF+ with +Vref, which leads to a factor-of-two error. Before the calibration procedure, the input range is, strangely, half the calibrated value or ±Vref / 2. There’s that factor of two again. Calibration constants in the executable software depend on the reference diodes, which will be close without revising the software if you follow the parts list.
The AD8307 Logarithmic Detector
I previously used the AD8307 in a few projects, including a recent patent application. I can’t tell you about that now, but it’s really useful, so go to the uspto.gov Web site, search on my name after mid-2009, and sort among the results to see it.7 The Patent and Trademark Office publishes patent applications 18 months after the filing date, whether or not a patent has issued or will ever issue.
I first learned of the AD8307 in a QST article.8 I obtained the data sheet and a couple of samples. Studying the data sheet showed me that I could build a direct-reading RF power meter by subtracting 2.10 V from the output, multiplying by 0.4, and applying the result to a ±200 mV digital panel meter with the decimal point moved two positions to the right. I designed and built this in a small box and use it frequently. It is essentially a direct-reading digital version of the instrument in the Hayward QST article. This sweep measurement project needs the same functionality, but after measuring the logarithmic-detector output with the ADC, it is simpler to subtract and multiply in software in place of the op-amps and trim-pots I used.
The logarithmic detector has no connections to the parallel port. For observation of rapid scans on an oscilloscope, less output filtering is desirable. For slower measurement with an ADC, more filtering is desirable. Consider adjusting these values for your particular usage. Input 2 of the ADC connects to the logarithmic detector output. I retain the Input 1 for general-purpose use, but you might want to connect it to a different output filter after the logarithmic detector.
With nothing else running, measure the output of the logarithmic detector. With no input, the output should be below 0.25 V. With no shielding, local RF emitters will provide enough signal level to exceed this level. Mount the detector in a shielded case to minimize pickup. If the logarithmic detector is in the same case as the DDS, power up the DDS to see if there is any interaction. The DDS does not even require programming to emit enough electromagnetic interference to obscure several orders of magnitude of the logarithmic detector’s dynamic range. Isolate as required. Use a separate shielding case, or a case within a case, if you must. This exercise reveals that the logarithmic detector is incredibly sensitive. I originally placed the logarithmic detector on the board near the DDS and could not prevent pickup. I moved the logarithmic detector to the input connector and mounted related components directly onto adhesive backed copper tape serving as a ground plane. Separate packaging external to the case would have been easier and less problematic.
Circuit Isolation Hints
It is good practice to decouple the power supply leads at all microcircuits with capacitors small and large to minimize the coupling of signals between different functions along the power lines. All power pins have bypass capacitors with short leads to ground even though not explicitly shown in the schematics. The DDS and the logarithmic detector have many bypass capacitors, typically 0.1 mF ceramic capacitors with very short leads and 10 mF teardrop electrolytic capacitors. The logarithmic detector also has some six-hole ferrites in its power lead. The DDS has its own 8 V regulator, and the other circuits share +5 V and –5 V regulators. Next time I would provide a separate voltage regulator for the logarithmic detector.
I used an external ±12V supply and fed it into the box through some serious feed-through filters to keep external RF fields away from the logarithmic detector. Again, it would be simpler to package the AD8307 in its own separate shielded box, preferably with a battery power supply.
The downloads listed below contain programs called ADC, DAC, LSW, SSW, SWCENTER, SWDDS, and TRANSFER. The executable DOS console programs have a .EXE suffix, and the source files have a .CPP suffix.
Right-click on the desired file and Save As to download it to your computer. Then unzip the file to see the specific programs discussed below ...
Analog to Digital Converter
The application program ADC.EXE digitizes the analog signal at input 1 and writes the value to the screen. This is a simple test program to demonstrate functionality. It is useful for making simple measurements, comparing your DVM to the results, and determining whether you need to adjust the calibration constants. Do this first, so you can use the ADC to check and calibrate the DAC. ADC will start from a command line or by double clicking the file name in explorer. In either case, a usage statement appears that tells you the command line parameters to enter to decrease the resolution to 12 bits for faster measurements or increase it to 14 bits for more precise, but slower, measurements. The MAX110 data sheet explains the detailed operation and the tradeoffs involved. The calibration procedure built into ADC.EXE provides extremely good accuracy. The program scales the internal result by a calibration factor Vref that depends on the individual reference diodes in your implementation. Again, the result will be close without revising the software if you follow the parts list.
Digital to Analog Converter
The application program DAC.EXE writes numbers to the DAC that appear as an output voltage. Again, this is a simple test program to demonstrate functionality. DAC will only start from a command line. With no parameters following the command, the program displays a usage statement that tells you proper syntax. With a single parameter, the output is a constant voltage. With two parameters, the output voltage sweeps from the first entry, which must be the most negative value to the second entry, which represents the most positive value, and repeats. The possible range is about –2.5 V to +2.5 V. Enter start and end values in integer millivolts as parameters following the command to select values within this range. This sawtooth waveform generator is useful to demonstrate that the DAC functions. In principle, you can generate an arbitrary waveform if you change the program to read the contents of a lookup table and write the values to the DAC.
RF Sweep Generator with Synthesized Sweep
The application program SWDDS.EXE provides a repetitive linear sawtooth sweep between a lower and an upper frequency and synthesizes a sawtooth voltage waveform from the DAC to drive a horizontal oscilloscope input to display the trace. SWDDS will start from a command line or by double clicking the file name in explorer. With no parameters, SWDDS comes up running default settings and sweeps from 1 MHz to 10 MHz in 4096 steps. Set frequency start, end, and step number parameters in the command line. The numeric keypad allows coarse increases and decreases of start and end frequencies and number of steps. The maximum number of steps is 4096, the maximum resolution of the DAC, which cannot operate below a step count of 1. The DDS is able to provide resolution to a small fraction of a hertz if you eliminate the DAC analog sweep.
The application program SWCENTER.EXE provides the same functionality as SWDDS with entry in the form of center frequency and sweep width. Default settings are a center frequency of 1 MHz and a sweep width of 100 kHz, so the default sweep range is between 950 kHz and 1150 kHz. The numeric keypad allows fine as well as coarse changes of center frequency and number of steps. Enter numeric values and observe the effects on the displayed parameters as well as what you’ll see on an oscilloscope.
RF Sweep Generator with Data Log
The application program SSW.EXE provides a single linear sweep between lower and upper frequencies with an adjustable number of frequency steps. It instructs the ADC to measure the voltage out of the logarithmic detector at each frequency, and writes the data measurement to a text file. When SSW completes, I import the data text file into a spreadsheet and plot it, as shown in Figure 9. SSW has evenly spaced frequency steps and is especially useful for narrow or moderate sweep widths with very high resolution.
The application program LSW.EXE provides a single logarithmic sweep between a lower and upper frequency. It instructs the ADC to measure the voltage out of the logarithmic detector at each frequency, and writes the data measurement to a text file. When LSW completes, I import the data text file into a spreadsheet and plot it, as shown in Figure 10. LSW has increasingly spaced frequency steps and is especially useful for sweep widths that extend over most or all of the full range. If a logarithmic frequency display best suits your measurement application, choose LSW, because it samples many fewer points and completes sooner It provides the highest resolution where needed at low frequencies, and larger frequency steps at high frequencies.
Both SSW and LSW will start from a command line only. With no parameters, the programs print usage statements to explain the parameters they require. You must enter an output filename as the first parameter. If you enter anything else, a text file will appear on your drive with that as the filename. It is most convenient to append .TXT to the filename, so you can open the file with WordPad or an equivalent text editor. The output file appears in the same folder as the executable unless you redirect it using the old DOS filename rules. For example, if you enter “..\” before the filename, it will appear in the next higher folder in the pathname.
Note that the usage statement for LSW indicates that the fourth parameter is something called “step fraction denominator.” This integer number allows you to control the frequency increment of the logarithmic sweep. For a value of 100, each frequency will be 1/100 or 1% higher than the previous value. For a value of 10000, each frequency will be 1/10000 or 0.01% higher than the previous one. LSW allows the step fraction denominator to be as large as you want, and still advance the frequency by a minimum of one count.
Voltage Transfer Function
The application program TRANSFER.EXE drives the DAC rather than the DDS, and provides a single linear sweep between a lower and an upper voltage to apply to an external circuit under test. It instructs the ADC to measure the voltage into input number 1 at each output voltage, and writes the data measurement to a text file. When TRANSFER completes, I import the data text file into a spreadsheet and plot it, as shown below to display the transfer function. The plot on the left shows a calibration waveform with the DAC output connected to the ADC input. Note that the DAC output voltage range is wider than the ADC can accommodate for the particular reference diodes I chose. The plot on the right shows the current versus voltage characteristic curves of a signal diode and a tunnel diode.
The Spectrum Analysis diagram/plot shows the result of a crude attempt at spectrum analysis. I drove the L-port of a double balanced mixer with the amplified output of the DDS and the R-port with a short antenna and a wideband preamplifier. Signals from the I-port passed through a low pass filter and to the logarithmic detector input. LSW.EXE measured power from the I-port into the logarithmic detector and yielded a plot of IF signal power versus local oscillator frequency.
5 The software files associated with this article are available for download from theARRL QEX Web site. Go to www.arrl.org/qexfiles and look for the file 11x08_Green.zip.
8 Wes Hayward, W7ZOI, “Simple RF Power Measurement,” QST, June 2001, pp 38-43.
10 Private communication 17 June 2008.
A kit containing a printed circuit board, all parts and enclosure is being prepared. Target availability is early February. Please check back here for further updates as the date grows closer.