Silicon ChipAM-FM DDS Signal Generator - May 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Most software is a product, not a service
  4. Feature: All About Heat Pipes by Dr David Maddison
  5. Feature: The History of Transistors, Pt3 by Ian Batty
  6. Project: AM-FM DDS Signal Generator by Charles Kosina
  7. Project: 500W Power Amplifier, Part 2 by John Clarke
  8. Feature: Air Quality Sensors by Jim Rowe
  9. Project: Slot Machine by Gianni Palotti
  10. Serviceman's Log: Where there’s a weld, there’s a way by Dave Thompson
  11. Project: Oatley LED Lighting & Driver Kits by John Clarke
  12. Subscriptions
  13. Vintage Radio: Calstan 559M2 superhet by Fred Lever
  14. PartShop
  15. Market Centre
  16. Advertising Index
  17. Notes & Errata: Dual Hybrid Power Supply, March 2022; Remote Control Range Extender, January 2022; Programmable Hybrid Lab Supply with WiFi, May & June 2021
  18. Outer Back Cover

This is only a preview of the May 2022 issue of Silicon Chip.

You can view 39 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • The History of Transistors, part one (March 2022)
  • The History of Transistors, part one (March 2022)
  • The History of Transistors, Pt2 (April 2022)
  • The History of Transistors, Pt2 (April 2022)
  • The History of Transistors, Pt3 (May 2022)
  • The History of Transistors, Pt3 (May 2022)
Items relevant to "AM-FM DDS Signal Generator":
  • AM/FM DDS Signal Generator PCB [CSE211002] (AUD $7.50)
  • ATMEGA644PA-AN programmed for the AM/FM DDS Signal Generator [CSE21100A.HEX] (Programmed Microcontroller, AUD $20.00)
  • Pulse-type rotary encoder with pushbutton and 18t spline shaft (Component, AUD $3.00)
  • 0.96in cyan OLED with SSD1306 controller (Component, AUD $10.00)
  • 0.96in yellow/cyan OLED with SSD1306 controller (Component, AUD $10.00)
  • Firmware for the AM/FM DDS Signal Generator [CSE21100A.HEX] (Software, Free)
  • AM/FM DDS Signal Generator PCB pattern (PDF download) [CSE211002] (Free)
  • Front panel label and drilling diagram for the AM/FM DDS Signal Generator (Panel Artwork, Free)
Items relevant to "500W Power Amplifier, Part 2":
  • 500W Amplifier Module PCB [01107021 RevD] (AUD $25.00)
  • Hard-to-get parts for the 500W Amplifier (Component, AUD $180.00-200.00)
  • Parts collection for the 500W Amplifier (Component, AUD $235.00-250.00)
  • 500W Amplifier Module PCB pattern (PDF download) [01107021] (Free)
Articles in this series:
  • Fan Controller & Loudspeaker Protector (February 2022)
  • Fan Controller & Loudspeaker Protector (February 2022)
  • Amplifier Clipping Indicator (March 2022)
  • Amplifier Clipping Indicator (March 2022)
  • 500W Power Amplifier, Part 1 (April 2022)
  • 500W Power Amplifier, Part 1 (April 2022)
  • 500W Power Amplifier, Part 2 (May 2022)
  • 500W Power Amplifier, Part 2 (May 2022)
  • 500W Power Amplifier, Part 3 (June 2022)
  • 500W Power Amplifier, Part 3 (June 2022)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
Items relevant to "Slot Machine":
  • Slot Machine PCB [08105221] (AUD $5.00)
  • DFPlayer Mini audio player module (Component, AUD $6.00)
  • Micromite Plus LCD BackPack kit without touchscreen (Component, AUD $45.00)
  • Laser-cut acrylic pieces for the Slot Machine (Component, AUD $10.00)
  • Firmware, sounds and images for the Slot Machine [SlotMachine V10] (Software, Free)
  • Slot Machine PCB pattern (PDF download) [08105221] (Free)
  • Cutting diagrams for the Slot Machine (Panel Artwork, Free)

Purchase a printed copy of this issue for $11.50.

By Charles Kosina ∎ Output Frequency: 100kHz to 75MHz in 1Hz steps ∎ Frequency Accuracy: ±0.1Hz immediately after calibration against a precise standard ∎ Output Level: 0dBm +0,-0.5dB 100kHz to 55MHz; +0,-3dB 55-75MHz ∎ Modulation: none, AM or FM ∎ AM: 50Hz-10kHz, 50% modulation ∎ FM: 50Hz-1kHz; 2.5kHz, 5kHz or 10kHz deviation ∎ 5V, 140mA power supply ∎ Digital frequency readout ∎ low RF leakage Precision AM-FM DDS Signal Generator This signal generator aims to provide very high calibrated accuracy with an error of just ten parts in a billion (108), which translates to 0.1Hz at 10MHz. It also has plenty of features, including amplitude and frequency modulation. N umerous cheap signal generators are available online but their accuracy leaves a lot to be desired. So I decided that if I wanted to have a maximum error of 0.1Hz at 10MHz, which would be ideal, I would have to design one. The first decision I had to make was what I wanted it to look like. This would determine the type of enclosure needed, the display and the controls. With the current worldwide shortage of many components, choosing these parts can be difficult. There is no escaping the fact that most advanced components are only available in surface-­ mount packages, some with very small lead pitch. Good shielding is essential for a signal generator. You want the signal to be via the output connector and not radiated from the device itself. For this reason, I chose a diecast aluminium box with a minimum number of apertures that need to be cut. The largest of these is for the display, and by using a small OLED module, RF leakage is cut down substantially. Next, I had to decide whether to use siliconchip.com.au ready-made modules or individual parts. Let’s take the frequency generating chip, the Analog Devices AD9851. This is available on a prebuilt module with its own clock generator and output filtering. Those have several problems, starting with the crystal oscillator module, which is just a standard cheap 30MHz unit. The accuracy and temperature stability is dubious and does not fit my design criteria. Yes, you can remove it and add a wire link to an accurate temperature-­ compensated crystal oscillator (TCXO) on the main board. Applying amplitude modulation requires access to the RSET pin on the AD9851 chip, meaning another wire link to the main board. The type of output I want to use requires a wideband transformer from two pins on the DDS chip. This is now getting into the too hard category and is the final reason for rejecting the prebuilt module. The cheapest Arduino modules mostly use an ATMega328 chip running at 16MHz. All the I/O pins are Australia's electronics magazine brought out, so there are no changes needed. But with my design, the number of pins available from the ATmega328 are inadequate, so a fancy pin-sharing arrangement would be necessary. Also, much processing is needed to apply frequency modulation, and the 16MHz clock speed is marginal for this. So instead, I am using a 44-pin ATmega644. This gives me more than enough I/O pins and I can arrange for it to run at 20MHz for a 25% boost in processing power. The display needs to convey lots of information, but a large screen is ruled out by the need for a small cutout to give low RF leakage. That’s why I chose a 0.96in (24mm) diagonal OLED. It does have rather small characters, but conveys all the needed information. By eliminating ready-made modules, the final PCB size (and thus enclosure required) is much smaller. Diecast boxes are expensive, so using the smaller one makes it considerably cheaper. The final major component needed is another DDS chip, the AD9833. This May 2022  43 Fig.1: the signal generator circuit is based on three main chips: IC1, the AD9833 DDS that’s used for the AM signal; IC2, the ATmega644 microcontroller; and IC3, the AD9851 DDS that produces the output signal. IC3 is clocked by the high-precision 30MHz TCXO, while IC1 & IC2 are both clocked by the same 20MHz crystal (X1) driven by IC2’s internal amplifier. Microcontroller IC2 also monitors user controls EN1, VR1 & VR2. comes only in a tiny 10-pin MSOP package but it is available on a small, ready-made module. I was tempted to use such a module in my design, and could have fitted it in, but I did not want yet another oscillator running in the unit (the module has an onboard 25MHz oscillator). 44 Silicon Chip So I am just using the bare chip. It gets its 20MHz clock source from the clock output pin on the ATmega644 processor. Component Selection Given the present severe shortage of electronic components, I paid Australia's electronics magazine particular attention to being able to source parts from several suppliers. The AD9851 DDS chip is available from several suppliers on AliExpress for about US$14 (around $20) delivered. The AD9833 DDS chip is also available for about US$3.50 ($5) from numerous AliExpress sellers. siliconchip.com.au If you want to stick to a more reputable supplier, Digi-Key has the AD9851 for $56.76 and the AD9833 for $14.95. The ATmega644 chip is another matter. I could only find one supplier on AliExpress who charged US$2.05 each plus US$5.26 shipping, for a total of around $11. Similarly, I could only find one supplier on eBay with a ridiculously high price. But Silicon Chip will have these chips available pre-programmed. Wherever you get it, make sure it’s the 20MHz, 44-pin TQFP variant. The 30MHz TCXO is best obtained from AliExpress, and the delivered price is about $15. I have found none suitable at Mouser, Digi-Key or element14. The OLED is a 0.96in, 128 x 64 pixel type with the SSD1306 controller. There are multiple suppliers for this, and it comes in different colours. The one I have has the top quarter yellow and the rest blue, and this highlights the set frequency, but you can choose whatever colour combination pleases you. Likewise, the potentiometers and the encoder are standard items. Make sure that they are the same size. The distance from the PCB to the end of the shaft should be about 25mm. That leaves the magnetic components. The output transformer is made by Coilcraft, with the PWB-16-BL giving the best result. siliconchip.com.au M3216/1206-size chip inductors are suitable for the remaining inductors. These have pretty close tolerances, far better than trying to wind your own. At 85MHz, the low-pass filter (LPF) for the RF output needs three 120nH coils. These are readily available at element14, although they can also be sourced from AliExpress. I paid $2.80 for 100, with free postage, and by some miracle, they arrived from China in two weeks. The rest of the components are standard resistors and capacitors, almost all in the standard M2012/0805 SMD size. The toggle switches can be bought from Jaycar and Altronics, as can the diecast box. The full parts list will come later in this article. Circuit details The complete circuit is shown in Fig.1. The microcontroller IC1 drives the two Analog Devices direct digital synthesis (DDS) chips. The AD9851 (IC3) generates frequencies from 100kHz to 75MHz, while the second DDS chip (IC1, AD9833) provides the amplitude modulation (AM) from 50Hz to 10kHz. The SSD1306 OLED screen (OLED1) shows the current status. The reference clock for the AD9851 is a 30MHz TCXO which is multiplied by the AD9851 to 180MHz. The output frequency is adjusted by an incremental shaft encoder (EN1) in steps set by its integral pushbutton Australia's electronics magazine switch. Pressing it cycles through step sizes from 1Hz to 1MHz. Potentiometers VR1 and VR2 are connected to two of IC2’s analog inputs. One sets the modulating frequency for both AM and FM. Rather than have a continuous range of frequencies, I instead opted for 11 separate frequencies. The other adjusts the FM deviation and also for calibration. Three-position toggle switch S2 selects between AM, CW and FM. Almost everything that I design includes a simplified RS232 serial port using transistors Q2 and Q3. I find this an invaluable tool for debugging while developing the code. It could also be used for controlling the unit from a PC as part of a future upgrade. The two DAC outputs from the AD9851 are connected to centre-­ tapped RF transformer T1, which has a 7th-order Chebyshev low-pass filter connected to its secondary to reduce harmonics and spurs. With a clock frequency of 180MHz, it is possible to generate frequencies up to the Nyquist limit of 90MHz, but the waveform is extremely distorted by then. I set the limit at 75MHz and, with the output filter, it does not contain too many spurs even at that frequency. The unit draws 140mA from a 5V DC supply. I find that a mobile phone charger is ideal for powering it. I must have at least ten of these; I am sure most people have lots of spares. As mentioned earlier, the whole May 2022  45 thing fits in a standard diecast box, making it quite robust and providing good shielding. Tuning The shaft encoder used to adjust the output frequency is available from numerous suppliers on eBay and AliExpress as well as Digi-Key, Mouser, element14 and others. They come in different shaft lengths and prices; choose one with a 20mm shaft length. I have added pull-up resistors on all the pins. There are weak internal pullups in IC2, but I have found the lower value external resistors plus capacitors to ground (for contact bounce filtering) give far more reliable operation. You want the frequency to increase when you wind the knob clockwise but depending on the shaft encoder, it can operate either way. To solve this, a jumper placed between pins 4 & 6 of the programming header will reverse the encoder direction. The firmware detects this by enabling a pull-up and checking the level on the MOSI SPI programming pin (PB5, pin 1 of IC2). With the jumper on, this pin is low; otherwise, it is high. The interrupt handler tests the state of the PB5 and selects the rotation direction based on this. With a range of 100kHz to 75MHz, you don’t want to turn the knob millions of times to set the frequency. This is where its integral pushbutton switch comes into use. Pressing it cycles through step sizes of 1Hz, 100Hz, 1kHz, 10kHz, 100kHz and 1MHz. 0.1Hz at 10MHz. More on this later. The FTW can be loaded into the AD9851 using serial or parallel methods. Serial loading takes far too much time and would make FM virtually impossible. Hence, I’m using parallel loading with five bytes transferred: one control byte plus four for the FTW (4 × 8 = 32 bits). You can see in the circuit diagram that I have split this up into four bits from two separate ports on microcontroller IC2. I did this because I can’t use all of Port A as I need two analog inputs, and the only available analog inputs are on Port A. Port B has the 20MHz clock output required by the AD9833 (PB1), so that’s ruled out. Port C has dedicated SDA and SCL pins for the I2C interface to the OLED, and I want to use INT0 and INT1 on port D for the shaft encoder. Therefore, I couldn’t dedicate all eight lines of one port for loading the FTW. So I split up the parallel interface into four bits from Ports C and D. The extra few lines of code required to do this don’t slow things down very much. Once the byte is set up, it is clocked in by the WCLK pin, and after all five bytes have been sent, the FQUD pin is pulsed to update the AD9851’s internal latch. RF output There are two outputs from the DAC (digital-to-analog converter) on the AD9851. Application note AN-423 from Analog Devices suggests using a wideband transformer to couple these two outputs to the external load. This makes for clean amplitude modulation (AM), also described in the note. The transformer in their example is 1:1 centre tapped, which for a 50W load, reflects 25W to the DAC outputs. I used a Coilcraft transformer with this ratio and found it to be most unsatisfactory. The 25W load on the DAC outputs is far too low in impedance; it reduced the output levels, and the waveform became very noisy. I feel that specifying such a transformer is an error. Experimenting with other Coilcraft transformers, I found the best results were with the PWB-16-BL with a 16:1 impedance ratio that reflects 400W to each DAC output; a far more satisfactory value. The transformer -3dB bandwidth is 75kHz to 90MHz, so there is a slight drop in level at 100kHz and 75MHz. This gave me an output close to 0dBm over much of the range (Fig.2). Output Filter Without a low-pass filter on the output, there will be many undesirable harmonics and spurs. While it is feasible to use some of these spurs for frequencies well above the Nyquist limit, for simplicity, I decided not to use this approach. Filter design is so easy these days. Rather than ploughing through some complex s-parameter mathematics, there are online calculators. The one I used to work out the C and L values for a 7th-order Chebyshev low-pass AD9851 interface The AD9851 has a 32-bit Frequency Tuning Word (FTW) that controls the output frequency. There is a handy online tool for calculating the required value at siliconchip.com.au/link/abc8 For a 1MHz output, FTW = 23860929, which is 16C16C1 in hexadecimal. The actual frequency with this FTW is 999.999982305kHz, an error of about 0.02Hz. But this assumes that the TCXO is exactly 30.000000MHz. The ones that I have bought from AliExpress have been within about 10Hz. Is that good enough? It depends on your application, but with some of the digital communication techniques used, an error of just a few hertz can make message decoding impossible. So I developed a calibration technique that reduces this error to less than 46 Silicon Chip Fig.2: the Signal Generator’s output level varies by about 1/4dB between 100kHz and 55MHz, except for a dip at -1/2dB between about 10MHz and 22MHz. It’s usable up to 75MHz, although the level drops considerably above 55MHz, reaching nearly -3dB at 70MHz. Australia's electronics magazine siliconchip.com.au Fig.3: here’s what the 100kHz output signal looks like with 5kHz AM (yellow). The AM signal output from the AD9833 is shown below (cyan). filter with 85MHz cutoff and 0.5dB passband ripple is at https://rf-tools. com/lc-filter/ The output of this calculator can be exact or standard values; the difference in performance between the two is minimal. The choice of inductors was discussed above in the component selection section. Amplitude modulation The ATmega644 processor (IC2) could generate amplitude modulation, but why bother with the complicated coding involved when we can use a second low-cost DDS chip instead? The AD9833 (IC1) can run at clock speeds of up to 25MHz. It is a tiny 10-pin chip with a three-wire serial control interface. Rather than having a separate clock generator, I use the 20MHz clock out pin on PB1 (pin 41) of IC1. The output of the AD9833 is applied to the gate of Mosfet Q1 via a 10kW trimpot, and this controls the RSET pin on the AD9851 as per the aforementioned application note AN-423. Rather than having a separate knob on the front panel, I preset the modulation level to about 50%. Potentiometer VR1 sets the modulation frequency. The voltage read using the 10-bit analog-to-digital converter (ADC) in IC2 is converted by software into the tuning word required by the AD9833. I could have had a continuous range but found that setting the frequencies was very fiddly. I decided instead on dividing the ADC reading into 11 distinct values: 50Hz, 100Hz, 200Hz, 400Hz, 1kHz, 2kHz, 3kHz, 5kHz, 6kHz, 8kHz and 10kHz. Fig.3 shows a 100kHz generated signal with 50%, 5kHz amplitude siliconchip.com.au Fig.4: as expected, the spectrum of the signal from Fig.3 has a single prominent peak at 100kHz with two smaller peaks, 5kHz on either side (ie, at 95kHz and 105kHz). modulation on channel 1, with the sinewave modulation signal on channel 2. The spectrum of this signal is shown in Fig.4. Frequency modulation Applying FM proved to be the trickiest part of the design. To approximate a sinewave, we have to change the AD9851 output frequency continuously. This sinewave is divided into 24 samples, each 15° apart. Taking the sine of that angle and multiplying it by the maximum deviation gives the instantaneous deviation for that sample. For example, if the maximum deviation is 3kHz, sin(30°) = 0.5, so we add a value to the FTW equivalent to 1.5kHz (3kHz x 0.5). The numbers become negative past 180° and subtract from the frequency. This takes quite a bit of processor time; so much that the maximum modulation frequency possible is 1000Hz. At this frequency, the micro’s timer generates 24,000 interrupts per second, and each triggers a new FTW value to be calculated and sent. For other modulation frequencies, the timer interrupt is 24 times the modulation frequency. See Table 1 for the values that are added and subtracted to the FTW to give ±2.5kHz deviation. The available modulation frequencies are 50Hz, 100Hz, 200Hz, 400Hz, 500Hz, 600Hz, 700Hz, 800Hz, 900Hz and 1kHz. There are ways of getting a higher modulation frequency. If we can stand having a rougher sinewave, we could have samples 30° apart, which would allow a maximum frequency of 2kHz. The spectrum of an FM signal is far more complex; advanced mathematics is needed to derive it. It has sidebands that go on forever, but their amplitude decreases rapidly so that only the first few are important. For more details visit: https://w.wiki/4eC$ Table 1 – frequency modulation FTW offsets for ±2.5kHz deviation angle θ sin(θ) Δf (Hz) ΔFTW angle θ sin(θ) Δf (Hz) ΔFTW 0° 0 0 0 180° 0 0 0 15° 0.259 647 15,437 195° -0.259 -647 -15,437 30° 0.500 1250 29,825 210° -0.500 -1250 -29,825 45° 0.707 1767 42,160 225° -0.707 -1767 -42,160 60° 0.877 2192 52,301 240° -0.877 -2192 -52,301 75° 0.966 2415 57,622 255° -0.966 -2415 -57,622 90° 1.000 2500 59,650 270° -1.000 -2500 -59,650 105° 0.966 2415 57,622 285° -0.966 -2415 -57,622 120° 0.877 2192 52,301 300° -0.877 -2192 -52,301 135° 0.707 1767 42,160 315° -0.707 -1767 -42,160 150° 0.500 1250 29,825 330° -0.500 -1250 -29,825 165° 0.259 647 15,437 345° -0.259 -647 -15,437 Australia's electronics magazine May 2022  47 Display Screen 1: this shows the screen layout during normal operation. The output frequency (in Hz) is at the top, the step size and FM deviation on the second line and the amplitude and frequency modulation signal frequencies on the last two lines. Screen 2: calibration mode is entered by rotating the Function knob fully clockwise; the bottom two lines of the display change, with the last line showing the FTW. If you have the right gear, you can get the output frequency within 0.1Hz. The OLED module has an SSD1306 controller and a resolution of 128 x 64 pixels. My original design used an 8 x 8 font which gave eight lines each of 16 characters. This allowed for a fair bit of information to be displayed but with rather tiny characters. I changed it to a 16 x 16 font, which is much easier to read, but this gives only four lines of eight characters. So I had to considerably simplify what is displayed. Screen 1 shows the unit’s normal display. The top line readout is the frequency in Hz, while the second has the frequency adjustment step size. Line 3 shows the AM frequency, one of 11 fixed frequencies from 50Hz to 10kHz. Line 4 shows the FM frequency, which steps through 11 fixed settings from 50Hz to 1kHz. With the Function knob fully clockwise, the unit enters calibration mode, shown in Screen 2. The modulation frequencies are replaced with line 3 showing “Calib” and line 4 showing the Frequency Tuning Word (FTW). The calibration procedure is explained later in the article. Power supply Fig.5: use this PCB overlay diagram to help with board assembly. Remember to link out REG1 and note that Q2, Q3, and associated 15kW & 1kW resistors are only needed if you will use the serial debugging interface. Make sure that the three ICs, D1, REG2, T1, TCXO1 and VR1 are orientated as shown. Note that the orientation of REG2 is swapped in the prototype, this is because regulator that was used has a different pinout than the one specified in the parts list. 48 Silicon Chip Australia's electronics magazine Many readers would have numerous mobile phone chargers lying around, left over from generations of phones. Most of them deliver a nominal 5V at up to 2A. The maximum current drawn by the Generator is about 140mA, well within the capability of all chargers. I included a schottky diode in the design as reverse polarity protection. This drops the supply voltage by about 0.37V. The charger that I used had an output of 5.2V, dropping to 4.85V through the diode. It’s a simple matter of cutting off the connector on the cable and replacing it with a DC barrel plug to suit your DC socket (either 2.1mm or 2.5mm inner pin diameter). The PCB design includes another regulator, REG1, so that a higher supply voltage could be used. However, this is probably not necessary, so it’s just linked out in the final design. I have connected another DC socket, CON6, in parallel with CON5. This is for powering the companion Attenuator, to be described in a future article. The OLED requires 3.3V, and this is supplied by a TO-92 low-dropout linear regulator, which draws from the 5V supply. The open-drain SDA and SCL pins for driving the OLED are pulled siliconchip.com.au up to 3.3V by a pair of 4.7kW resistors. Construction The Signal Generator is built on a double-sided PCB coded CSE211002 that measures 100 x 78.5mm. Refer to the PCB overlay diagram, Fig.5, as a guide during construction. It shows which components go where. Most of the parts on the PCB are surface-­mounting types, and two of them are very fine-pitch ICs. These are the two DDS chips, and you should start with these. Soldering them accurately and without short circuits between the pins takes some skill. It helps to spread a little flux paste on the pads before placing the ICs and ensure they are aligned with their pads on both sides after tacking the first pin and before soldering any others. Also, be careful to check that their pin 1s are located correctly before soldering more than one pin! Rather than trying to solder the pins without bridges, concentrate on making sure that each pin gets enough solder and that it flows down onto the corresponding PCB pad. Try to avoid getting any solder high up on the pins, where it is harder to fix bridges. After soldering all the pins, it’s then just a matter of spreading some more flux paste over them and carefully using a length of solder wick to remove any excess solder, including that which might be bridging adjacent pins. Clean off the flux residue with some flux cleaner or alcohol, then inspect the IC leads to make sure all the solder joints look good and there are no remaining bridges. If you find anything that looks suspect, add a dab of flux paste, heat the offending pin(s) and use solder wick if necessary. Repeat this process as many times as needed until you have nicely soldered ICs. Following these, mount the ATmega644 chip (with wider pin spacings than the first two, but pins on four sides), again being careful with its pin 1 orientation, followed by all the other SMD components. The orientation of SMD transformer T1 also matters. Then give the board a good clean to remove flux residue. Now fit the through-hole parts from lowest profile to tallest. Be careful to orientate diode D1, the TCXO, VR3, and REG2 as shown. Don't forget the wire link across REG1, which can be made from a component lead off-cut. siliconchip.com.au Parts List – AM-FM DDS Signal Generator 1 double-sided plated-through PCB coded CSE211002, 100 x 78.5mm 1 diecast aluminium enclosure, 119 x 93.5 x 34mm [Jaycar HB5067 or Altronics H0454] 1 0.96in OLED display module with I2C interface and SSD1306 controller (OLED1) 1 mechanical rotary encoder with integrated pushbutton switch and 20mm total height (RE1) [Bourns PEC11R-4215F-S0024] 2 10kW PCB-mount vertical 10mm 20mm-tall linear potentiometers (VR1, VR2) [Alpine RK09K1130AH1] 1 10kW side-adjust multi-turn trimpot (VR3) [Altronics R2361] 1 large knob to suit RE1 2 medium knobs to suit VR1 & VR2 1 20MHz 18pF 30ppm crystal resonator, HC-49 (X1) 1 30MHz 20 x 12mm TCXO module (TCXO1) [aliexpress.com/item/32719087266.html] 1 Coilcraft PWB-16-BL SMD wideband transformer (T1) 3 Coilcraft 1206CS-121XJEC 120nH chip inductors or equivalent, M3216/1206 size (L1-L3) 1 3x2 pin header, 2.54mm pitch (ICSP) (optional; for programming IC1) 1 2-pin polarised locking header with matching plug, 2.54mm pitch (CON1) 1 3-pin polarised header with matching plug, 2.54mm pitch (optional; CON3) 1 panel-mount BNC socket (CON4) 2 panel-mount DC barrel sockets (CON5, CON6) 1 4-way female header socket (for OLED1) 1 SPDT panel-mount switch (S1) [Altronics S1310] 1 SPDT panel-mount centre-off switch (S2) [Altronics S1330] 1 tactile pushbutton switch (S3) 4 12mm-long M3 tapped metal spacers 2 10mm untapped spacers 4 M3 x 6mm panhead machine screws 4 M3 x 8mm countersunk head machine screws 2 M2 x 12mm panhead machine screws and nuts 4 M3 flat washers Semiconductors 1 AD9833 12.5MHz DDS generator, MSOP-10 (IC1) 1 20MHz ATmega644 microcontroller in TQFP-44 (eg, ATMEGA644PA-AN or ATMEGA644PA-AU) programmed with CSE21100A.hex (IC2) 1 AD9851BRS 180MHz DDS generator, SSOP-28 (IC3) 1 LP2950CZ-3.3 3.3V low-dropout linear voltage regulator, TO-92 (REG2) 3 2N7002 60V 2A N-channel 3.3V drive Mosfets, SOT-23 (Q1-Q3) 1 1N5819 40V 1A schottky diode (D1) Capacitors (all SMD M2012/0805 size unless otherwise stated) 1 100μF 6.3V X5R ceramic, M3216/1206 size 3 10μF 6.3V X5R ceramic 1 220nF 50V X7R ceramic 10 100nF 50V X7R ceramic 2 10nF 50V X7R ceramic 2 100pF 50V NP0/C0G ceramic 2 68pF 50V NP0/C0G ceramic 2 22pF 50V NP0/C0G ceramic Resistors (all SMD M2012/0805 size 1% thick film unless otherwise stated) 6 27kW 2 15kW ERRATA: the gate bias for Mosfet Q1 is fixed at 1.5V, which might not suit all 2N7002 devices. If there is no output from 2 4.7kW IC3, the bias might be too low, in which case the 3.3kW 1 3.9kW resistor can be changed to 4.7kW (1.8V) or 6.2kW (2.0V). If 1 3.3kW there is output from IC3, but the modulation is weak, the bias 1 1.5kW might be too high, in which case the 3.3kW resistor can be 1 1kW changed to 1.8kW (1.05V). 1 51W Australia's electronics magazine May 2022  49 You can safely omit Q2, Q3, the two adjacent resistors and CON3. These are the simplified RS232 interface and are used as a debugging aid. The OLED screen plugs into a fourpin socket strip and is held in place by two screws and standoffs. Rather than cutting down an 8-pin strip that I already had, I just removed four pins. Depending on the OLED, the mounting holes may be either 2mm or 2.5mm in diameter. While M2 screws are not as easy to find as M3, I bought some from eBay. Some larger online electronics retailers also stock M2 screws and nuts. Don’t try to drill the holes out on the OLED to bigger screw sizes! There are four screw holes provided but two are adequate. The potentiometers and encoder should be installed last, after cleaning off any flux residue on the board. Preparing the case The adjacent photo shows the diecast box with the board already mounted in the base. The positions of the required holes are shown in the drilling and cutting template/ guide, Fig.6. The raw aluminium is not very attractive, so I sprayed it with three coats of matte black paint. I used the blank circuit board as a template to accurately drill the mounting holes and the holes for the control shafts. There are small holes on the PCB in the centre of the controls for this purpose. Once the PCB has been mounted in the case and the wire to the BNC socket soldered, all you need to do is wire up and plug in the DC socket. You only need one, as shown here, but if you’re thinking of building the upcoming matching attenuator, add a second socket in parallel so you can daisy-chain the power. It takes a bit of care to make the rectangular cutout. There are various ways of doing it. If you have a milling machine, that’s great, but very few readers would possess one. I started by drilling a circular hole of 25mm diameter centred on the rectangle with a step drill. Then I filed it out into the required 26 x 28mm rectangle. It takes a bit of time but results in a neat finish. You will also need to drill two holes in the side of the base, near the lid, to accept the barrel sockets. Make sure they are placed so that they will not foul the PCB assembly once it’s dropped in. You might also want to drill a hole in the side so that you can access VR3 (the AM depth adjustment trimpot) once the board has been mounted in the case. Fig.6: this template shows the cutouts on the diecast box. This template can be downloaded from the Silicon Chip website and then printed at actual size. You can also use the blank PCB to mark the hole positions. Fig.7: the front panel label for the ► Precision DDS Signal Generator. 50 Silicon Chip Australia's electronics magazine siliconchip.com.au A ‘sneak peak’ at the companion attenuator PCB that we will describe in an upcoming issue. The panel label shown in Fig.7 can be downloaded from the Silicon Chip website and printed onto photographic paper. Make the OLED and shaft cutouts with a sharp scalpel or hobby knife. I cut a piece of 1mm-thick clear acrylic to 112 x 86 mm to protect the label, again using the blank PCB as a template to drill the holes. Attach the PCB to the front panel siliconchip.com.au using 12mm threaded spacers with countersunk screws on the outside. Add a washer under each spacer to slightly increase the distance. Now it’s time to install the panel-­ mount connectors. It turned out to be too difficult to mount the BNC connector on the PCB itself. Connect a 50mm length of stiff wire to the connector and pass this through Australia's electronics magazine the centre hole of the BNC connector location on the PCB. Once the board is attached to the box, cut off the excess and solder it. To remove the board, you will have to desolder this one wire. After the PCB has been fitted, connect the DC sockets in parallel, then wire them to the matching plug for CON1. Make sure the wires are the right length to reach CON1. Also, ensure the polarity is correct. You can check this by testing for continuity between the barrel socket’s tip and one end of power switch S1, and also continuity from the outer barrel (with a plug inserted) to PCB ground. Apply power and check that everything works before fitting the lid to the box with the supplied screws. You should get a sensible display on the OLED as soon as it’s switched on. Check that you can adjust all the parameters with the knobs. If you run into any problems, remove the PCB and have a good look at it. Check that all the solder joints look good, especially on the SMDs, and that everything is where it should be, referring to Fig.5. Calibration Without calibration, the accuracy of the signal generator is entirely dependent on the TCXO. The best calibration procedure requires a two-channel oscilloscope, a GPS-disciplined 10MHz reference and a high-precision frequency counter (which might be built into some higher-end oscilloscopes). Set the three-position switch to “CW” and the output frequency to 10000000Hz (10MHz). Rotate the Function knob fully clockwise and adjust the tuning knob to get FTW = 23860929. This is the value needed if the TCXO has an output of precisely 30MHz. If you have no other equipment available, press the tuning button to save that value into EEPROM and turn the Function knob back a bit. If you have an accurate frequency counter, repeat above but adjust the FTW for exactly 10MHz on the frequency counter, and save it into EEPROM as before. For best accuracy, first, adjust the frequency using the counter as above. Then connect the GPS disciplined reference 10MHz signal to one channel of a two-channel oscilloscope, and trigger on that channel to produce a stationary display. Set the signal May 2022  51 A 300kHz signal with 10kHz amplitude modulation applied, resulting in smaller peaks 10kHz on either side of the carrier wave. Here frequency modulation has been applied. This results in many small peaks of all sorts of multiples of modulating waves either side of the carrier wave, but this spectrum analyser doesn't have the resolution to separate them. generator to 10MHz and connect it to the other scope channel. If the frequencies are identical, the signal generator waveform will be steady. But this will hardly ever be the case; it will drift left or right. Set the Function knob fully clockwise, and using the tuning knob, adjust the FTW for minimum drift. Typically, the drift will take 10 or more seconds across one complete cycle. The 10 seconds corresponds to an error of 0.1Hz at 10MHz. Press the frequency button to save the calibrated FTW value into the EEPROM. The calibrated frequency may hold for several hours depending on temperature fluctuations; the TCXO is by no means perfect. Do the calibration just before you want to do any seriously accurate work. There is a multi-turn trimpot accessible through a hole in the left side of the case. Setting the amplitude modulation level is best done using an oscilloscope. Still, if you loosely couple the output to an AM receiver, you can simply adjust the level for a clear tone. It will overmodulate and create lots of spurious and harsh harmonics if you wind it up too much. A matching attenuator Spectral analysis of a 75MHz output signal. Because of how a DDS works, you not only get spurious peaks at multiples of the signal frequency but also at fractions. The most significant in this case is at 30MHz, 35dB below the fundamental. Given the relatively small enclosure size, it was impractical to fit an attenuator into the same housing. There have been various RF attenuators described in Silicon Chip in the past, but the maximum attenuation has been about 30dB. I have designed a separate attenuator in another identical enclosure with an attenuation range from 1dB to 110dB in 1dB steps. As the output of the Signal Generator is about 0dBm, this means the lowest signal level that the pair can generate is around -110dBm. The photo on the previous page shows a preview of the attenuator, to be described in an upcoming SC article. ► A 100kHz output signal modulated by 1kHz at 10kHz deviation. This doesn't show on my digital scope, but my old analog scope provides this pattern. 52 Silicon Chip Australia's electronics magazine siliconchip.com.au