SweepGen 1.1 Release Notes October 4, 2005 Feb 2024 - PLEASE NOTE - Further down in section 2, Quickstart Guide, are the instructions on using the TONES output as a sync output to trigger an oscilloscope - this is pin 1 (PORTA,2) of the PIC in the software available here. Updated 26 Feb 2012 by Terry Mowles VK5TM - See bottom of page Welcome and thanks for checking out the second release of SweepGen! This version is a port of Ver 1.0 to the PIC16F628A, and operates identically. Although I've tried to make the program as intuitive as possible, there's always room for a user's manual. SweepGen is a program that runs on the PICEL and DDS daughter card and generates a swept frequency output based on the user's preferences. This program is a natural extension of PICELGen 2.1. There have been numerous times when I wish I had a sweep generator to take the drudgery out of determining a filter's response. If you enjoy homebrewing, this program will help you get your project right the first time. There are several immediate applications that I can think of: o Aligning RF and IF bandpass filters. o Designing LC and crystal bandpass filters. o Examining crystal parameters o Sweeping antennas O Cable testing o Other applications limited only by you imagination! 1.0 Basic Features: o Multi-purpose signal generator o User-programmable Start, End, and Step frequencies. o User-programmable Marker frequency output. o Pushbutton Frequency Decade selection. o Support for PIC-EL mechanical encoder. o User data is saved in EEPROM. o Calibrate Mode o LED Status & Mode indicators 2.0 Quickstart Guide Since you're reading this, you've already downloaded and unzipped SweepGen_1-1.zip. Program the PIC 16F628A on your PICEL board with the appropriate file. There are three hex files that come with SweepGen 1.1 package: SweepGen_1-1_8.hex, SweepGen_1-1_16.hex and SweepGen_1-1_16L.hex. The first file is assembled to use the original, 8-character LCD displays which were distributed with the early PIC-EL kits. The second file, SweepGen_1-1_16.hex, is meant for later PIC_EL kit shipments which use a 16 character LCD. This display requires a "long jump" between character positions 8 & 9. If you have such a display, then use this file. If you are using an "after market" 16 character LCD that uses linear addressing across the 16 character positions, then use the last file. If you're not sure which display you have, try the last file first. If the display is jumbled, try the second file. If you are using a different display, you'll have to modify the LCD data and build your custom version. After programming, the PIC-EL board display will indicate the program name and version number. This will be displayed for 1 second and then "Start" will appear for 1/2 second. The LCD will the display 2.000000 MHZ. This is the default sweep start frequency. The DDS daughtercard output is set to the displayed frequency. You can change this frequency now, but let's use the default. Momentarily press PB 2 on the PICEL board to accept this frequency. The LCD will then display "End" for about a half-second and then 2.100000 MHz. This is the default sweep end frequency. If you're monitoring the frequency on the BNC connector, your frequency counter will reflect this. Press PB2 again to accept the default end frequency. Next, the LCD will flash "Step" for 1/2 second followed by 100 Hz. You can change this frequency as well, but accept the default for this trial by pressing PB 2. Chances are your frequency counter won't indicate 100 Hz because the DDS daughter card output is very low at this frequency. The LCD will then flash "Marker" for 1/2 second followed by 2.050000 MHz. This is the frequency at which a marker output will be generated. If you are using a frequency counter, it will reflect the displayed frequency. Press PB 2 to accept this value. The LCD will then display "Sweeping." If you still have the PICEL speaker connected, you'll hear a tick-tock sound as the marker bit is toggled. If you have a dual-trace 'scope handy, connect one channel to the BNC connector and the other channel to the TP-H, the "Tones" test point. Trigger the scope on the signal coming from the BNC connector and set the sweep rate so that several cycles of RF output are displayed. You will see the frequency ramp up and then suddenly revert to the starting value. If you're observing TP-H at the same time, you'll see it flip up and down. Now, slow down the sweep to 50 ms/div and set the 'scope to trigger on the falling edge of the TP-H channel. The falling edge coincides with the beginning of a sweep cycle. This is the start frequency. TP-H goes high when the marker frequency was reached, and it stays high until another cycle is started. Press PB2 when you've heard enough tick-tocking. 3.0 Digging Deeper. If you've tried PICELGen 2.1, you're already familiar with selecting the frequency decade to modify by using PB1 and PB2. SweepGen uses some of those features with some differences. Read on. 3.1 Basic Operation. The shaft encoder and PB1 and PB2 are used to set the sweep parameters and control the sweep generation. As distributed, the shaft encoder handler is set to debounce and handle the detented PIC-EL mechanical shaft encoder. The frequency is adjusted at each detent, not in- between. As the quickstart guide illustrated, there are 4 parameters to collect: Start, End, Step and Marker frequencies. Use the shaft encoder to dial in the desired values. The DDS output will reflect the displayed frequency. You can use this feature for generating fixed frequencies. Note that step frequencies below about 10KHz will be low in amplitude because of the limitations in the DDS daughtercard. When all 4 frequencies have been entered, SweepGen stores the values in EEPROM before starting the sweep. 3.2 Pushbutton Operation. Decade Selection ________________ PB1 and PB2 are used to control the operation of SweepGen. PB1 is a multi-function switch. When a frequency is displayed, pressing PB1 advances the underline cursor to the next most-significant decade. The cursor is automatically positioned under the 1 KHz digit for Start, End and Marker frequency displays. For the Step frequency display, the cursor is automatically positioned under the 1Hz digit. Advancing beyond the 10MHz digit wraps the cursor around to the 1 HZ position. Holding PB1 down for more than 1 second starts an auto-repeat function and the cursor moves to the left at a fast rate. This is useful for getting to the decade you want in a hurry. PB2 is also a multi-function switch. To select a lower frequency decade, PB1 must be pressed first. Holding PB1 down and pressing PB2 will move the cursor to the right and lower the decade to adjust. Holdng both PB1 and PB2 down for more than 1 second enables the auto-repeat function and the cursor will move to the right at a swift rate, wrapping from 1 Hz to the 10 MHz position. PB2 Details ___________ There are four frequency values to enter for SweepGen. Pressing PB2 alone accepts the displayed value and the program moves on to collect the next entry. After the Marker frequency has been selected, pressing PB2 starts the frequency sweep. This sweeping continues until PB2 is pressed again. Pressing and holding PB2 during a sweep stops the action at the current DDS frequency. 3.3 Updating Calibration This feature works similarly to the PICELGen software. To calibrate the DDS reference, Press and hold PB1 before or when the power-up message is displayed. When the Calibration mode is entered, the display will indicate "10000000" on the 8 character LCD or "10,000.000 CAL" on the 16 character display. The program stays in Calibrate mode until you release PB1 and move the shaft encoder. You can release PB1 momentarily and stay in this mode as long as you don't move the encoder. Remember to press PB1 before moving the encoder to remain in Caibrate Mode. To home in on the calibration frequency, use PB2 to accelerate the frequency change. This differs from the PICELGen software, which used PB3. When calibrating the DDS, there are several things to consider. First, allow the PIC-EL board to warm up for at least 10 minutes. This allows the DDS reference oscillator to warm up and stabilize its frequency. The oscillator frequency will change with temperature. Second, make sure you have an accurate frequency counter attached to the BNC connector. I discovered that my HP counter was off over 100Hz at 10 MHz, so instead I chose to zero-beat WWV at 10MHz. You can't get a better frequency reference than NIST! A short piece of wire connected to the BNC connector provided enough output that I easily got a sub-Hz beat with WWV's carrier on my portable receiver. To adjust the calibration, rotate the shaft encoder while pressing PB1. When you are satisfied, release PB1 and rotate the shaft encoder. The program will then store the new calibration constant in EEPROM. Normal operation will then commence. 4.0 LED Display Summary Here's what the LED indications mean: LED1 LED2 LED3 | Interpretation ____________________|_______________________ Off Off Off | Calibrate Mode On Off Off | Start Frequency Selection Off On Off | End Frequency Selection Off Off On | Marker Frequency Selection On On On | Sweeping 5.0 What About This Marker Business? In days of old, sweep frequency generators had a marker generator which was used to provide what amounts to a "squiggle" at a certain frequency. These sweep generators were typically used to align wide-bandwidth TV IF strips and it was important to know where the center frequency and the bandpass edges were. Ham radio IFs, are obviously much narrower, so markers aren't as critical. Still, it's useful to know what the center frequency is, as well as the -6 db edges. The SweepGen marker output has two uses: First, it can be used as a trigger which indicates the start of a sweep cycle. A 'scope with provisions for external triggering is needed. Connect the scope's trigger input to TP-H, the "Tones" test point on the PIC-EL board. Set the scope to trigger on the falling edge. The negative-going edge marks the beginning of the sweep cycle. The rising edge of the marker output occurs at the programmed marker frequency. You will want to slow down the scope's time base to allow the entire sweep to be seen. The second use for the marker output is for frequency determination. You program the frequency of the marker output rising edge to whatever value you desire, as long as it's within the sweep range. This frequency can be set to the center frequency or band edges. The choice is up to you. If you don't wish to use the marker output, set the marker frequency to some arbitrary value outside the sweep range. 30 Mhz would work, but be aware that the sweep start output will no longer function because the output will stay low. Here's an example of how I used the marker output. I had an unknown crystal filter in my junkbox that I wanted to check. The input was connected the the PIC-EL output through a 200 Ohm resistor and the output was terminated with another 200 Ohm resistor. I chose these values since these are relatively common for crystal filters. Channel 1 of my dual trace scope was connected to the filter output and channel 2 was connected to TP-H. I set up the trigger to use the falling edge of channel 2. The trigger was set to Auto at this point. Using the Start frequency setting, I adjusted the frequency until I observed a peak on the scope trace. It turned out to be 457 KHz. Not knowing the filter's bandwidth yet, I decided to use a wide sweep and set the start frequency to 430 Khz. The end frequency was chosen as 480 KHz, providing roughly +/- 25 KHz bandwidth around the center frequency. I set the marker frequency to 457 KHz, since this was the peak of the passband. I used a 100 Hz step. The chosen frquencies resulted in about 3.3 sweeps/sec. The scope trigger was set to Normal so that scope only produces a trace when triggered. With the sweep running, I was able to see the filter response and the marker output simultaneously. The response trace was eye-shaped and symmetrical about the center frequency. After a bit of calculation, I determined the amplitudes of the -6dB points in the filter response. A few iterations of trying different marker frequencies produced the filter bandwidth. I determined the filter had a bandwidth of 30KHz. While too broad for even SSB work, it's ideal for hi fi AM. If you use it for nothing else, the marker output provides a valuable trigger for the start of a sweep cycle. Set the marker frequency to any arbitrary frequency within the sweep band. 6.0 Sweep Cycle Timing There are 4 parameters which determine the sweep interval. Three are user-defined while the fourth is fixed, namely program execution. The inner sweep loop takes an average of 590 uS to execute, plus or minus 5us or so. It wasn't practical to time the extremes, so this value is approximate. Let's assume 0.59 mS per iteration. This is the average dwell time on a particular frequency before the program updates it. The user specifes three parameters: Start Frequency, End Frequency and Step size. To determine how long it takes for a single frequency sweep, start by taking the difference between the end and start frequencies. In the example case, this is 2.100000 MHz - 2.000000 Mhz = 100KHz. Next, divide this difference by the step frequency. In the example, it's 100 Hz. The result is 100,000/100 = 1000. This is the number of iterations of the sweep loop requires before the sweep cycle restarts. Multiplying this value by 0.59 mS/iteration for the sweep loop yields a sweep interval of 0.59 Seconds. If you wish to sweep a Ham band RF bandpass filter that's say, 300 KHz wide, you could safely increase the step size to 500 Hz or even 1 Khz and get a pretty good idea of its response. Crystal filters require a little more attention. If you plan to sweep an IF bandpass filter, choose closely spaced start and end frequencies and make the step size small. A step size of 1 Hz wouldn't be out of the question, but be prepared for longer sweep intervals. 7.0 Build Notes This program was developed using MPLAB IDE v7.20 and uses the P16F628A.inc file. If you are using a different environment, you may have to make changes to the source file. There are several options available in building your own program of SweepGen 1.1. The first is the LCD size. Near the top of the source file is are several "#DEFINE LCD_" lines. Comment out those that don't apply to your display. The comments will guide you in this selection. AmQRP supplied 8 character LCDs in the early shipments of the PIC-EL board. Later shipments replaced these with a 16 character LCD. Use the LCD16_LINEAR 0 definition for these displays. I obtained a slightly different 16x1 LCD that used linear addressing that didn't require the long hop to position 9 on the display. If you obtain one of these "after market" LCDs, try using the LCD_16L option. NOTE: AmQRP began shipping PIC-EL semi-kits in late September 2005. These don't include LCDs, so some experimentation may be required. The SweepGen 1.1 code should work with LCDs that use the Hitachi 44780 controller. There are a number of LCDs on the market that use Samsung controllers which operate similarly, but not exactly as the Hitachi controllers. You may have to modify the init_LCD code and other display functions and definitions to make the software work properly. Consult the manufacturer's data sheets for information. Another option is the #define DETENT_ENCODER option. Comment this out if you are using an optical encoder or prefer to use the standard PIC-EL encoder as-is. A third user-customizable feature is the default decade increment. As distributed, this varies accoring to the frequency input. Start, End and Marker frequencies use a default increment of 1KHz, or DECADE_3 in the program. The default increment for the Step frequency value is 1 Hz. To change these, modify the f_struct_table entries. The supplied code is a basic port of the previous version. Migrating to the PIC16F628A opens up a number of options not available with the 16F84. The program memory and the number of EEPROM locations double. The 16F628A can use an internal RC oscillator, which frees up two pins. You can also use the MCLR pin as an input in lieu of a reset input. The Reset pushbutton can then be used as a 4th pushbutton input. There's much more that can be done with the basic code provided, and I invite you to expand upon it! I'd appreciate any comments or feedback. You can email me at: w3cd@arrl.net. Please use "SweepGen" in the subject line. Thanks! Bob Okas 10-04-05 26 Feb 2012 Unfortunately, Bob is now a Silent Key. I have made some small changes to this program to accomodate the use of an AD9851 as well as the original AD9850. Firstly, the Reference Oscillator code section has been updated to include values of 125MHz for the AD9850 and 180MHz for the AD9851. Note that the value specified in the Reference Oscillator code must be that which the chip is running at after multiplication, NOT the Xtal frequency unless the muliplier is not being used. Also, the maximun frequency has been updated to 40MHz for the'50 and 60MHz for the '51. The only other code change required to accomodate the '51 was to change the value of the last byte from 0x00 to 0x01 to accomodate the 6x multiplier of the '51. This change can be found in the calc_dds_word routine. The default status is now AD9851, 180MHz oscillator and max frequency of 60MHz. All the changes are commented in the code so you can change it back to the AD9850 if required. No other changes have been made to the code and it behaves exactly as it did with an AD9850 and as explained in the details from the top of the page. Terry Mowles VK5TM