Silicon ChipKickStart - December 2021 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions: PicoLog Cloud
  5. Back Issues: PICOLOG
  6. Publisher's Letter
  7. Feature: The Fox Report by Barry Fox
  8. Feature: Techno Talk by Mark Nelson
  9. Feature: Net Work by Alan Winstanley
  10. Project: Easy-to-build Digital AM/FM/SW Receiver by Charles Koslna
  11. Project: Balanced Input and Attenuator for the USB by Phil Prosser
  12. Project: Mini Digital Volt/ Amp Panel Meters by Jim Rowe
  13. Feature: Max’s Cool Beans by Max the Magnifi cent
  14. Feature: KickStart by Mike Tooley
  15. Feature: Circuit Surgery by Ian Bell
  16. Feature: AUDIO OUT by Jake Rothman
  17. Feature: Electronic Building Blocks by Julian Edgar
  18. PCB Order Form
  19. Advertising Index

This is only a preview of the December 2021 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
KickStart b y Mi k e T o o l e y Part 6: Exploring DDS Our KickStart series aims to show readers how to use readily available low-cost components and devices to solve a wide range of common problems in the shortest possible time. Each of the examples and projects can be completed in no more than a couple of hours using ‘off-the-shelf’ parts. As well as briefly explaining the underlying principles and technology used, the series will provide you with a variety of representative solutions and examples, along with just enough information to enable you to adapt and extend them for your own use. This sixth instalment provides you with an introduction to the technology used for direct digital synthesis (DDS). To help I n recent years a range of devices has become available that greatly simplify the task of generating signals and waveforms that are both highly accurate and stable. These handy and increasingly low-cost devices use direct digital synthesis (DDS) where phase-related data is converted into amplitude data before being fed to a digital-to-analogue converter (DAC), and the resulting output is then filtered to produce a sinusoidal analogue signal. Modern DDS devices are often Fig.6.1. How a sinewave’s phase angle plot changes linearly with time. programmed through a serial peripheralinterface (SPI) and need only an external clock to generate sinusoidal (and other) DDS principles waveforms. This makes them extremely As readers will doubtless be aware, easy to use and increasingly competitive sinusoidal waves repeat on a continuous with alternative solutions based on basis with 360° phase rotation (equivalent phase-locked loops and programmable to 2 radians) over each cycle, as shown in dividers. The latest generation of DDS Fig.6.1. Note how the corresponding phase chips can generate frequencies from waveform also repeats every 360° but is less than 1Hz up to 400MHz (based linear in shape. The underlying principle on a 1.2GHz clock) with exceptional of DDS generators is simply that this linear resolution. Key features of DDS include: change of phase can be translated into a sinusoidal change in voltage. The key to  Ability to generate signals over a wide this process is a circuit that can convert range of frequency with a very high a change in phase angle to a change in degree of accuracy and stability amplitude, as shown in Fig.6.2.  The generated frequencies may Fig.6.2 illustrates the basic principle of be changed very quickly without DDS signal generation. The arrangement the additional loop settling time is based on four functional blocks: a associated with phase-locked signal sources, which ensures exceptional frequency agility  With many of the latest DDS chips, frequency-shift keying (FSK) and phase-shift keying (PSK) can be very easily implemented  Modern DDS devices built into lowcost, readily available modules offer flexibility and ease of programming using commonly available low-cost platforms such as the Arduino, Micromite or Raspberry Pi (see Fig.6.2. Basic principle of DDS signal generation. Going Further for examples). 48 you get started, we’ve provided some practical circuit arrangements and sample code based on the popular and inexpensive Analog Devices AD9833 DDS chip. This versatile device can form the basis of projects ranging from simple fixed-frequency sources to programmable waveform generators and FSK/PSK generators. phase register (or phase accumulator), a phase-to-amplitude converter (PAC), a digital-to-analogue converter (DAC), and a low-pass filter. The phase register stores an n-bit digital word that determines the output frequency, while the PAC is typically a read-only memory (ROM) comprising a look-up table of sinusoidal amplitude data. The output of the PAC is taken to a DAC that usually has a resolution of between 10 and 14 bits. In a practical DDS arrangement, the phase accumulator is a digital counter that increments its stored data during each clock cycle. The tuning word (M) sets the increment in phase, effectively jumping forward in the data from the counter that’s then passed to the PAC. The phase accumulator is designed so that it will overflow when the maximum count is exceeded, thereby restarting the count so that the process repeats indefinitely. The output frequency of the signal generated by the DDS arrangement shown in Fig.6.2 is given by the relationship: fOUT = (M × fC)/2n fOUT M fC n output frequency of the DDS tuning word clock frequency number of bits (resolution) of the phase accumulator. Practical Electronics | December | 2021 Fig.6.3. Waveform plotted using spreadsheet data generated by Listing 6.1. Changes to M produces an immediate – and importantly – phase-continuous change in output frequency. Plus, as mentioned, there is also no loop settling time which would be incurred with a conventional phase-locked loop. Note that the phase increment (the constant value determined by the tuning word) is added to the phase accumulator on each clock cycle. If the phase increment is large, the PAC will step quickly through the sine look-up table and thus generate a high-frequency sinewave. If the phase increment is small, the PAC will take many more steps, generating a lower frequency sinewave. We can illustrate this important point with some simple software. Listing 6.1 shows some simple Python code that demonstrates the DDS principle. (This code, and the other two listings (6.2 and 6.3) referenced in this article can be downloaded from the December 2021 page of the PE website.) The code uses a lookup table of 16 sinusoidal values and the main loop is executed four times for incremental values ranging from 1 to 4. A list of waveform data is generated on each passage through the loop, and the values produced can then be examined and compared. On the first passage through the loop the unity increment just produces a list of data values that are the same as those stored in the lookup table. This produces a single cycle of a sinusoidal waveform constructed from the 16 data points. On the second passage through the loop (where the increment is 2) every other data point is used, and the sinusoidal waveform is therefore generated at twice the frequency (but still using 16 data points). On the third and fourth passage through the loop the increment is increased to 3 and 4 respectively. This produces outputs that are respectively three and four times the original frequency. Practical Electronics | December | 2021 Do try the Python code (see Going Further), it can be very instructive to work through the generated data obtained during each of the four iterations. To help you visualise what’s going on, Fig.6.3 shows the waveform data plotted using spreadsheet software. Notice how the blue sinewave uses all the stored data points when passing through the loop (Series 1). The red sinewave corresponds to the second pass through the loop corresponding to an increment of 2 (Series 2), while the green and mauve plots correspond to increments of 3 and 4 (Series 3 and Series 4 respectively). Note how the waveform becomes distinctly less sinusoidal as the increment is increased and fewer data points are used in its generation. Any larger value of increment would result in a very strange waveform because we simply don’t have enough data values in the lookup table. Limitations As the output frequency is increased, the number of samples per cycle generated by a DDS will decrease proportionately. The Nyquist theorem dictates that at least two samples per cycle are required to reconstruct an output waveform, so the theoretical maximum output frequency of a DDS is half that of the maximum clock frequency. However, for practical applications and to produce a waveform of acceptable quality, the output frequency must be limited to significantly less than fC/2. Note also that a low-pass filter must be used in the DAC output to remove spurious signal components present in the output waveform. We will look at this a little later when we describe a practical design example. The spectral purity of the output of a DDS is expressed in terms of its ‘spuriousfree dynamic range’ (SFDR). This is an important measure of the performance of a DDS system, and it relates to the ratio (measured in dB) between the highest amplitude of the fundamental signal to the highest amplitude of any spurious, signal (including harmonically related components and aliases). SFDR is particularly important in communication applications where the frequency spectrum is being shared with other signals. Fig.6.4 shows an example of determining SFDR from the output spectrum of a DDS system. Note how the indicated SFDR is about 60dB which will be adequate for many applications. Using a DDS design tool A design tool (see Going Further) can be invaluable when attempting to assess the performance of a DDS chip. Fig.6.4 shows the Analog Devices DDS design tool being used to evaluate the performance of a low-cost AD9833 device. This chip operates with a 25MHz clock, and we have set a target output frequency of 1MHz. The design tool has calculated the tuning word which appears as 0A3D70A in hexadecimal (this is the value that we would need to program into the device for the desired 1MHz output frequency). To access this excellent free tool, just go to: https://bit.ly/pe-dec21-ad3 In Fig.6.4, the Analog Devices design tool has also calculated the magnitude of the harmonic components relative to the fundamental output. This is shown Listing 6.1 A simple Python module using a lookup table to demonstrate the DDS principle. # DDS principle using a lookup table # Sine lookup table with 16 values sine = [0,48,90,117,127,117,90,48,0,-48,-90,-117,-127,-117,-90,-48] # Initialise the counter counter = 0 for increment in range(1,5): # Use four incremental values print(“Waveform data for increment =”,increment) for clock in range(0,16): counter = counter + increment if counter > 15: counter = 0 print(sine[counter]) else: print(“Done!”) 49 (left) Fig.6.4. The excellent DDS design tool from Analog Devices. (above) Fig.6.5. Frequency and time domain plots generated by the Analog Devices DDS design tool. as −50dB but to provide us with a better impression of the output spectrum, the design tool generates frequency and time domain plots of the output waveform (see Fig.6.5). The response shown in Fig.6.5 also incorporates the low-pass response of the Butterworth filter that we plan to include in the output of the DAC. To provide the desired amount of harmonic attenuation we’ve set the filter parameters to a third-order response with Filter design to be changed to suit your own particular circumstances. The circuit of the thirdorder low-pass filter is shown in Fig.6.7, together with its simulated frequency response in Fig.6.8 generated by Tina TI (see Going Further). If required, the Analog Devices design tool can also produce tabular data for any major spurious and harmonic components present in the output waveform. The third-order Butterworth filter can be quickly and easily designed with the aid of an on-line tool like that shown in Fig.6.6 (see Going Further). Note that we have used a design impedance of 50Ω for these filter calculations, but this might need Fig.6.7. Circuit of the third-order Butterworth low-pass filter. a cut-off frequency of 2MHz (twice that of the output frequency). It is important to note that Fig.6.5 indicates the presence of second, third and fifth harmonics (shown in red, green and brown respectively) as well as mixing components at 1MHz either side of the clock frequency (ie, 24MHz and 26MHz). Fig.6.6. On-line design tool to create a simple third-order Butterworth low-pass filter. 50 Fig.6.8. Using Tina TI to check the response of the Butterworth low-pass filter. Practical Electronics | December | 2021 Fig.6.9. Low-cost DDS module using an AD9833 chip. Introducing the AD9833 DDS chip Having explained some of the basic principles behind DDS signal generation it’s time to introduce an example of a typical DDS chip. For this, we’ve chosen the inexpensive but very capable Analog Devices AD9833 device. This device forms the basis of a range of low-cost DDS modules (see Figs.6.9 and 6.10) that can be used in a wide variety of waveform generators and signal sources. Modules are much the easiest, quickest and – surprisingly! – the cheapest way to use the AD9833. The two modules shown in Figs.6.9 and 6.10 are widely available from just a few tuned to a very impressive resolution of 0.004Hz. The AD9833 operates from a power supply between 2.3V and 5.5V with a typical power consumption of just 12.65mW at 3V. This makes the AD9833 ideal for use in continuously operating low-power applications. The internal arrangement of an AD9833 chip is shown in Fig.6.11. Tuning data enters the chip via the serial interface and is Fig.6.10. An AD9833 module with an enhanced loaded into the frequency specification (operates at higher frequencies). and phase registers. Note that the frequency and phase registers are duplicated, which pounds – see aliexpress.com, eBay and makes FSK (frequency-shift keying), Amazon. Prices do vary enormously, so and PSK (phase-shift keying) very it definitely pays to shop around. straightforward. The AD9833 can produce sine, The phase accumulator is a 28-bit triangular, and square-wave outputs, register, the output of which can be and the output frequency and phase combined with either of the two phase are software programmable using a registers to provide the digital address standard serial peripheral interface input to the sine look-up table ROM. (SPI). The frequency registers are 28The corresponding stored value from the bits wide and a resolution of 0.1Hz look-up table is fed to a 10-bit digital-tocan be obtained with a 25MHz clock. analogue converter (DAC). Using a 1MHz clock the device can be (above) Fig.6.11. Internal arrangement of an AD9833 DDS chip. (right) Fig.6.12. Circuit arrangement of the AD9833 function generator. Practical Electronics | December | 2021 51 The output of the chip can be software configured for sine or square-wave operation using internal switches S1 and S2. For square-wave operation only the most-significant bit from the DAC is used, producing an output voltage that is high for half a cycle and low for the other half. For a triangular output the sine ROM can be bypassed so that only the truncated digital output from the phase accumulator is sent to the DAC, which will then produce a 10-bit linear triangular function. Fig.6.13. Circuit arrangement of the AD9833 variable frequency oscillator (VFO). Arduino control The AD9833 can be very easily controlled using software. As an example, Listing 6.2 is the code for a simple function generator application with sine, square and triangular outputs variable from 1Hz to 100kHz in three switched ranges. The code is designed for use with an Arduino Nano controller using the circuit arrangement shown in Fig.6.12. Note that you will first need to use the Arduino IDE’s Library Manager to locate and download the required library file (see Going Further) before compiling the code. The total cost of this project is well under £20. Listing 6.3 provides a further example of AD9833 code in the form of a variable frequency oscillator (VFO) for radio frequency (RF) applications. In this project we’ve used the enhanced DDS module shown earlier in Fig.6.10 and chosen a rotary encoder (SunFounder type TS0194D) for more precise frequency adjustment than can be obtained with a standard variable potentiometer. The output frequency of the VFO is adjustable over the range 1990kHz to 2000kHz in steps of 100Hz but the tuning limits and steps can be easily altered by modifying the code. The code is for an Arduino Nano controller used in the circuit and prototype configurations shown in Figs.6.13 and 6.14. Once again, it will be necessary to download the required library file before compiling the code (see Going Further). As with the previous example, the total cost of this project is under £20. Micromite control We have covered the combination of the AD9833 and the Micromite in several articles over the last few years – see Going Further. Going further Fig.6.14. Breadboard testing of the AD9833 variable frequency oscillator (VFO). The table opposite details a variety of sources that will help you find ideas, code and further information that will allow you to understand DDS and make good use of this technology in your own projects. It also provides links to relevant underpinning knowledge and manufacturers’ data sheets and online tools. NEW DOWNLOAD! 5-year collection 2015-2019 All 60 issues from Jan 2015 to Dec 2019 for just £35.95 i Fig.6.15. A programmable signal source based on an AD9833 that can form the basis of low-cost test equipment (such as signal, function and sweep generators). 52 files ready or ediate do nload Purchase and download at: www.electronpublishing.com Practical Electronics | December | 2021 Table 6.1: Going Further with DDS Topic Understanding DDS Filter design Python Source The main Analog Devices DDS homepage is located at: www.analog.com/dds The latest Analog Devices DDS chip selection guide can be found at: https://bit.ly/pe-dec21-ad1 For an in-depth DDS technology tutorial, see: https://bit.ly/pe-dec21-ad2 The excellent Analog Device DDS design tool can be found at: https://bit.ly/pe-dec21-ad3 The Butterworth low-pass filter on-line design tool can be found at: http://leleivre.com/rf_butterworth_LPF.html For the Tina TI circuit analysis tool, go to: www.ti.com/tool/TINA-TI The Python programming language is available freely for Windows, Linux, Raspberry Pi OS, and macOS – see: www.python.org The official Arduino website provides a variety of resources to support the Nano. Go to: https://bit.ly/pe-dec21-ard1 Arduino Nano Notes The Arduino’s integrated development environment (IDE) can be downloaded from: https://bit.ly/pe-dec21-ard2 Electronics Teach-In 8 Introducing the Arduino (available from the PE shop) provides a one-stop source of ideas and practical information. An Arduino Uno can be substituted for the Nano but the board will require a significantly larger enclosure. The code samples can be downloaded from the December 2021 page of the PE website. Note that before the code can be successfully compiled you will need to use the Arduino IDE’s built-in Library Manager to locate and download the latest MD-AD9833.h library file For a good introduction to using the AD9833 with the Micromite, see the June 2018 issue. Micromite PE/EPE has covered the Micromite-AD9833 combo in several articles and projects for you to learn and explore further. The April 2018 issue ran a Touchscreen DDS Signal Generator that generates sine, triangle and square. See the Superhet IF Alignment using Direct Digital Synthesis project in the September 2018 issue. AD9833 DDS module The AD9833 data sheet can be found at: https://bit.ly/pe-dec21-ad4 Inexpensive AD9833 DDS modules can be obtained from online suppliers including Amazon and eBay. These can easily form the basis of home-constructed low-cost test equipment (see Fig.6.15). Teach-In 8 CD-ROM Exploring the Arduino This CD-ROM version of the exciting and popular Teach-In 8 series has been designed for electronics enthusiasts who want to get to grips with the inexpensive, immensely popular Arduino microcontroller, as well as coding enthusiasts who want to explore hardware and interfacing. Teach-In 8 provides a one-stop source of ideas and practical information. The Arduino offers a remarkably effective platform for developing a huge variety of projects; from operating a set of Christmas tree lights to remotely controlling a robotic vehicle wirelessly or via the Internet. Teach-In 8 is based around a series of practical projects with plenty of information for customisation. The projects can be combined together in many different ways in order to build more complex systems that can be used to solve a wide variety of home automation and environmental monitoring problems. The series includes topics such as RF technology, wireless networking and remote web access. PLUS: PICs and the PICkit 3 – A beginners guide The CD-ROM also includes a bonus – an extra 12-part series based around the popular PIC microcontroller, explaining how to build PIC-based systems. EE FR -ROM CD ELECTRONICS TEACH-IN 8 £8.99 FREE CD-ROM SOFTWARE FOR THE TEACH-IN 8 SERIES FROM THE PUBLISHERS OF INTRODUCING THE ARDUINO • Hardware – learn about components and circuits • Programming – powerful integrated development system • Microcontrollers – understand control operations • Communications – connect to PCs and other Arduinos PLUS... PIC n’MIX PICs and the PICkit 3 - A beginners guide. The why and how to build PIC-based projects Teach In 8 Cover.indd 1 04/04/2017 12:24 PRICE £8.99 Includes P&P to UK if ordered direct from us SOFTWARE The CD-ROM contains the software for both the Teach-In 8 and PICkit 3 series. ORDER YOUR COPY TODAY at: www.electronpublishing.com Practical Electronics | December | 2021 53