Silicon ChipCircuit Surgery - September 2024 SILICON CHIP
  1. Contents
  2. Publisher's Letter: Hello from the other side of the planet
  3. Feature: Techno Talk - I don’t want to be a Norbert... by Max the Magnificent
  4. Feature: The Fox Report by Barry Fox
  5. Feature: Net Work by Alan Winstanley
  6. Subscriptions
  7. Project: Build Your Own Calibrated Microphones by Phil Prosser
  8. Feature: Using Electronic Modules – 1.3-inch monochrome OLED by Jim Rowe
  9. Project: Modern PIC Programming Adaptor by Nicholas Vinen
  10. Feature: Circuit Surgery by Ian Bell
  11. Back Issues
  12. Feature: Audio Out by Jake Rothman
  13. Feature: Max’s Cool Beans by Max the Magnificent
  14. Project: Salad Bowl Speakers by Phil Prosser
  15. Feature: Teach-In 2024 – Learn electronics with the ESP32 by Mike Tooley
  16. Back Issues
  17. PartShop
  18. Market Centre
  19. Advertising Index
  20. Back Issues

This is only a preview of the September 2024 issue of Practical Electronics.

You can view 0 of the 80 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)
Articles in this series:
  • The Fox Report (July 2024)
  • The Fox Report (September 2024)
  • The Fox Report (October 2024)
  • The Fox Report (November 2024)
  • The Fox Report (December 2024)
  • The Fox Report (January 2025)
  • The Fox Report (February 2025)
  • The Fox Report (March 2025)
  • The Fox Report (April 2025)
  • The Fox Report (May 2025)
Articles in this series:
  • Win a Microchip Explorer 8 Development Kit (April 2024)
  • Net Work (May 2024)
  • Net Work (June 2024)
  • Net Work (July 2024)
  • Net Work (August 2024)
  • Net Work (September 2024)
  • Net Work (October 2024)
  • Net Work (November 2024)
  • Net Work (December 2024)
  • Net Work (January 2025)
  • Net Work (February 2025)
  • Net Work (March 2025)
  • Net Work (April 2025)
Articles in this series:
  • Circuit Surgery (April 2024)
  • STEWART OF READING (April 2024)
  • Circuit Surgery (May 2024)
  • Circuit Surgery (June 2024)
  • Circuit Surgery (July 2024)
  • Circuit Surgery (August 2024)
  • Circuit Surgery (September 2024)
  • Circuit Surgery (October 2024)
  • Circuit Surgery (November 2024)
  • Circuit Surgery (December 2024)
  • Circuit Surgery (January 2025)
  • Circuit Surgery (February 2025)
  • Circuit Surgery (March 2025)
  • Circuit Surgery (April 2025)
  • Circuit Surgery (May 2025)
  • Circuit Surgery (June 2025)
Articles in this series:
  • Audio Out (January 2024)
  • Audio Out (February 2024)
  • AUDIO OUT (April 2024)
  • Audio Out (May 2024)
  • Audio Out (June 2024)
  • Audio Out (July 2024)
  • Audio Out (August 2024)
  • Audio Out (September 2024)
  • Audio Out (October 2024)
  • Audio Out (March 2025)
  • Audio Out (April 2025)
  • Audio Out (May 2025)
  • Audio Out (June 2025)
Articles in this series:
  • Max’s Cool Beans (April 2024)
  • Max’s Cool Beans (May 2024)
  • Max’s Cool Beans (June 2024)
  • Max’s Cool Beans (July 2024)
  • Max’s Cool Beans (August 2024)
  • Max’s Cool Beans (September 2024)
  • Max’s Cool Beans (October 2024)
  • Max’s Cool Beans (November 2024)
  • Max’s Cool Beans (December 2024)
Articles in this series:
  • Teach-In 2024 (April 2024)
  • Teach-In 2024 (May 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (June 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (July 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (August 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (September 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (October 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (November 2024)
Circuit Surgery Regular clinic by Ian Bell Topics in digital signal processing – Filter Requirements W e are looking at various topics related to digital signal processing (DSP). DSP covers a wide range of electronics applications where signals are manipulated, analysed, generated, stored or displayed as digital data. However, they usually originate from and/or end up as real-world signals for interaction with humans or other parts of the physical world. Fig.1 shows the key elements of a generic DSP system with a signal path from an analogue input via digital processing to an analogue output. This does not necessarily represent every DSP system (not all have all the parts shown), but it serves are as reference for the various subsystems we will look at. Last month, we covered some key topics in DSP relating to the frequency domain view of sampled signals. To depict the frequency domain, we used graphs of signal strength versus frequency – the signal’s spectrum. We also plotted parameters such as the gain of a circuit against frequency as a frequency response graph. Looking at frequency responses and signal spectra together shows us the effect circuits or signal processing will have on a signal and helps us understand design requirements. This month, we will look at some aspects of how the spectra of sampled signals informs the requirements for the filters required at the inputs and outputs of DSP systems – the antialiasing and reconstruction filters shown in Fig.1. Frequency Domain Recap Our discussion last month concluded with a graph of the spectrum of a generic sampled signal. A similar example Analogue In Antialiasing filter Sample and hold is shown in Fig.2. In this example, we show a signal where the original spectrum of the signal extends from DC to 20kHz (Fig.2a). This shape is used to represent a general signal which has frequency content from DC to 20kHz. It could be audio, which has frequencies in this range, but here we are not being specific about what the signal is. The spectrum of a 50kHz sampling signal (an impulse train) is shown in Fig.2b. As discussed last month, the spectrum contains single-frequency peaks (impulses) at integer multiples of the sampling frequency. Mathematically, the sampled signal’s spectrum can be obtained by convoluting the sampled and sampling signals’ spectra –the result is shown in Fig.2c. This is because the two signals are multiplied together (in the time domain), which corresponds to convolution in the frequency domain. Convolution has a reputation for being a difficult mathematical concept and, as we have said, DSP in general is a mathsheavy topic. We are avoiding getting into too much detailed mathematics in this series, but will be highlighting a few of the key ideas. Last month, we referenced a YouTube video that shows some graphical representations of convolution. Another video, which readers with some mathematical background (functions, calculus) who are interested in convolution might find useful is from Professor Iain Collings (https://youtu.be/RmePGKWOSMQ). It considers the continuous case, rather than the simplified discrete example we looked at. The video starts with the impulse response – another important concept in signal processing. Digital ADC Digital processing Analogue DAC Fig.1: A generic digital signal processing (DSP) system structure. Practical Electronics | September | 2024 Reconstruction filter Out We previously discussed impulses, which are idealised zero-length pulses with specific areas under the pulse. An impulse response is the output a circuit produces with single impulse applied to the input, something we will mention again later. Sampled Signal Spectra Examples For considering general, straightforward cases of sampled signals in the frequency domain, you do not have to perform detailed convolution calculations. As can be seen in Fig.2c, sampling a signal at a constant sampling rate (fs) results in the spectrum of the sampled signal being replicated at integer multiples of f s . These are referred to as replica spectra or spectral images. We can use this fact to visualize spectra of sampled signals under different scenarios, and look at the implications for the design of DSP systems. Consider what happens if we lower the sampling frequency in the Fig.2 example to 40kHz and 35kHz. The 40kHz xc(f) a) –100 –50 –2fs –fs –100 –50 –2fs –fs –100 –50 0 s(f) 50 100 f/kHz fs 2fs 50 100 f/kHz fs 2fs 50 100 f/kHz b) 0 xs(f) c) 0 Fig.2: Frequency domain views of a sampled signal: (a) original continuous time signal; (b) sampling signal spectrum; (c) sampled signal spectrum. 41 –2fs –100 xs(f) –fs –50 0 fs 2fs 50 100 f/kHz Fig.3: A variation of the spectrum in Fig.2(c), where the sampling frequency is reduced to 40kHz. sampling frequency case is shown in Fig.3, where we see that the replicated spectra (spectral images) of the original signal in the sampled signal abut one another in spectrum but are separate. Due to the replicated spectra being closer together, we can now see part of the copies at +3fs and -3fs in the range plotted in Fig.3. The 35kHz sampling frequency case is shown in Figs.4 & 5. Fig.4 shows the replicas of the original spectra individually, with the ranges where they overlap highlighted. In the overlap ranges, the contributions of two the spectra add up, so the overall spectrum will look something like the one in Fig.5 – this is a sketch, it was not accurately calculated. The labelled overlap in Fig.4 ranges from fs – B, where B is the bandwidth (maximum frequency) of the input signal, to B, which is 15-20kHz in this example. Other overlaps in the spectrum are at the same positions relative to the various replicas of the sampled signal. Looking at the spectra in Figs. 2c & 3, we can imagine that it is straightforward to obtain the original spectrum of the continuous signal, and hence an exact copy of the original signal, by applying a filter that can remove all the frequencies not in the original signal. This is the role of the reconstruction filter shown in Fig.1. There are some additional considerations due to the DAC output not being an ideal impulse train. We will discuss that in a later article; for now, assume that we are filtering an ideal sampled signal in –2fs –fs –100 –50 xs(f) –fs/2 0 fs/2 –100 100 f/kHz –50 fs 0 –50 0 –100 xs(f) –50 –fs/2 0 fs/2 50 100 f/kHz –100 –50 0 0 2fs 50 100 f/kHz t Fig.6: A time domain (waveform) view of a sampled signal. signal frequency of 20kHz – there is no headroom, and we definitely need an ideal filter to achieve this. Ideal filters have infinitely fast cut-off (sometimes referred to as “brick wall” filters for this reason), which is not possible in reality. We will discuss the implications of this in more detail shortly. If we attempt to recover the sampled signal shown in Fig.5 using an ideal low pass filter with a cutoff of fs/2 (17.5kHz in this case), we fail to obtain the original continuous signal. This is shown in Fig.9, where the difference in the shape of the spectrum from Fig.2a can be observed. A different spectrum means a different continuous time waveform and hence failure to reconstruct the sampled signal. The overlapping parts of the spectrum with the replicas produces additional frequency content in range of 15kHz to 17.5kHz, where the overlap region is inside the filter’s pass band. The original signal bandwidth was 20kHz, so perhaps we should use an ideal filter with this cutoff – however, that will not help reconstruct the signal correctly, as the extra bandwidth is also in the overlap range and will contain Ideal filter response fs 2fs 50 –50 fs Sampled signal xs(t) An ideal low pass filter with a cutoff of fs/2 can do a perfect job of recovering or reconstructing the original continuous signal from a correctly sampled signal, as shown in Figs.7 & 8 For the situation in Fig.7, the cutoff frequency is 25kHz and there is some ‘headroom’ between this and maximum signal frequency of 20kHz. For the situation in Fig.8, the cutoff frequency is 20kHz, which is equal to the maximum –fs Overlap xs(f) Fig.5: A sketch of an actual spectrum resulting from the situation in Fig.4, with the overlapping signals combining. Reconstruction Filtering Examples –2fs –100 –fs –2fs 100 f/kHz –100 –50 xc(f) Fig.7: Filtering the sampled signal spectrum from Fig.2c with an ideal filter to recover the original continuous signal (Fig.2a). 42 100 f/kHz form of a weighted impulse train – see Fig.6. For more detail on this, refer to the discussion relating to Fig.10 in last month’s article. The fact that it is possible (at least in theory) to perfectly recover a correctly sampled continuous signal from the sampled data is an important concept in DSP. That applies to the simple cases shown here, where the there is no actual processing (we are just looking at the pure sampled signals), but also to digitally-processed (eg, filtered) and digitally-created (synthesised) sampled signals, as long as the requirements discussed below are met. Of course, absolutely perfect reconstruction of a continuous signal from samples requires ideal circuitry and will not be achieved in practice; however, with good design, very high performance is possible. xc(f) –100 50 –fs –2fs 2fs Fig.4: A variation of the spectrum in Fig.2(c), where the sampling frequency is reduced to 35kHz. The overlapping ranges are highlighted. Ideal filter response fs 2fs 50 –fs –2fs Overlap xs(f) xs(f) –fs/2 fs 0 fs/2 Ideal filter response 2fs 50 100 f/kHz 50 100 f/kHz xc(f) 50 100 f/kHz Fig.8: Filtering the sampled signal spectrum from Fig.3 with an ideal filter to recover the original continuous signal (Fig.2a). –100 –50 0 Fig.9: Filtering the sampled signal spectrum from Fig. with an ideal filter fails to recover the original continuous signal (Fig.2a). Practical Electronics | September | 2024 xs(f) 19kHz 0 19kHz 35kHz 16kHz 19kHz 50 f/kHz Fig.10: A 19kHz component in the original signal produces an unwanted 16kHz signal due to the limited 35kHz sampling rate. additional frequency content. It is not possible to define a filter that will recover the signal correctly in this case. Nyquist and Aliasing in the Frequency Domain In the first article in this series (May 2024), we discussed the NyquistShannon sampling theorem and the concept of aliasing. The theory shows that if the input does not contain any frequency components at or beyond half the sampling frequency, it is possible to perfectly reproduce the original signal from the sample data. The scenarios shown in Figs.7 & 8 meet the Nyquist sampling requirement. When we look at the spectra, we see that sampled signal can be reconstructed correctly if a suitable reconstruction filter is used. If the Nyquist sampling requirement is not met, the sampled data is ambiguous; that is, there could be more than one signal that results in the same set of sample values. Therefore, signals reconstructed from the sampled data will not match the original input. This ambiguity is called aliasing – one signal is an alias of the other, and they cannot be distinguished. The discussion in the May article just looked at the time domain signals. Now we have seen how this problem manifests in the frequency domain. For the scenario in Fig.9, the Nyquist Fig.11: An LTspice schematic for simulating aliasing examples. sampling requirement is not met, so the signal is aliased. The labelled overlap region shown in Figs.4 & 5 runs from 15kHz, which is the sample frequency minus the maximum input signal frequency of 20kHz (35kHz – 20kHz = 15kHz). This overlap range ends at 20kHz (the maximum input signal frequency). Fig.10 shows a zoom-in on part of Fig.4 in which one aliased frequency from the original signal (19kHz) is highlighted. For the replica spectrum centred on fs, the 19kHz component of the original signal (which has components at ±19kHz due to the symmetry of the spectrum in negative frequencies) produces replicas at fs ±19kHz, that is at 35kHz - 19kHz = 16kHz and 35kHz + 19kHz = 54kHz. Here we consider the 16kHz signal, which is inside the original sampled signal bandwidth of 20kHz – it is therefore an alias signal. If we filter the sampled signal with an ideal low-pass filter with a cut-off frequency 20kHz, the alias of 19kHz at 16kHz would not be removed by the filter, but it should not be there – it was not in the original sampled signal. Fig.11 shows an LTspice circuit thatcan demonstrate the aliasing situation Fig.12: The results of simulating the circuits shown in Fig.11. Practical Electronics | September | 2024 just discussed in the time domain. This is similar to the example in the May issue, but with signals relevant to the current example. Sinewaves at 19kHz and 16kHz are generated. The 19kHz waveform is sampled at 35kHz. This is achieved by multiplying the sinewave from source V3 by the sample pulse train from source V2 using behavioural source B1. The top trace in Fig.12, plotted by the simulation of Fig.11, shows the 19kHz waveform and the samples obtained from it. 19kHz is beyond the Nyquist rate of 17.5kHz for 35kHz sampling, so aliasing will occur, with an alias at 16kHz. The bottom trace in Fig.12 shows the 16kHz waveform together with the samples from the 19kHz waveform. All the samples are exactly on points on the 16kHz waveform, showing that the same set of samples could have been obtained from either a 16kHz or 19kHz waveform. Reconstruction Filter Requirements If we sample a signal with frequency content right up to the Nyquist rate (just less than half the sampling frequency, as in Fig.8), no aliasing occurs in the sampling process. However, the signal can only be recovered using an ideal “brick wall” reconstruction filter (as shown in Fig.8), which is impossible to do in practice. If the sampling frequency is above the Nyquist rate, there is some headroom, as shown in Fig.7. However, this does not guarantee that the signal can be perfectly reconstructed. Ideally, the filter must completely remove the replica spectra, but the closer the sampling rate is to the Nyquist rate, the more demanding the filtering requirements become. That is why it’s common for audio to be sampled at either 44.1kHz or 48kHz when the highest frequency that’s intended to be reproduced is 20kHz. That gives 4.1kHz or 8kHz of headroom, allowing the reconstruction filters to have very little attenuation up to 20kHz, but 43 xs(f) –fs –B +B Real low-pass filter response fs f xc(f) –1/T –B –1/2T x(f) Ideal low-pass filter removes frequencies > fs/2 which will cause aliasing +B 1/2T 1/T xc(f) f –B –fs f +B –fs/2 x(f) Real low-pass filter will need cut-off below fs/2 to sufficiently attenuate signals at frequencies above fs/2 fs/2 fs fs/2 Bf fs x(f) Unwanted content in filter output –fs –B +B fs f Fig.13: Filtering a sampled signal with a non-ideal reconstruction filter may result in unwanted frequency content in the output due to imperfect reconstruction. significant attenuation from 22.05kHz or 24kHz and up. The problem with trying to reproduce frequencies right up to the Nyquist limit is illustrated in Fig.13, which shows a case where a realistic reconstruction filter fails to remove part of the spectral images. The result is unwanted frequency content in the output, which means the output waveform will have a different shape from that implied by the sample data – the reconstruction is imperfect. Antialiasing Filter Requirements Similar challenges exist with the requirements for antialiasing filters. If we had an ideal filter, we could simply set the cut-off to be equal to the Nyquist rate, and that would remove any possibility of aliasing, as shown in Fig.14. That figure shows a continuous signal spectrum which is to be sampled (like Fig.2a), with a bandwidth (B) extending beyond the Nyquist rate. Hence, it will cause aliasing. The filter removes all frequencies above half the sample rate (fs/2) to produce a signal with a new bandwidth (BF = fs/2), which will not cause aliasing. We cannot use an ideal filter in real –fs –fs/2 –Bf fs/2 Bf fs f Fig.14: Filtering a continuous signal with an ideal antialiasing filter. –fs –fs/2 –Bf f Fig.15: Filtering a continuous signal with a realistic antialiasing filter. being sampled to guide the antialiasing designs, but we can use a cutoff frefilter design. quency below the Nyquist rate so that Both antialiasing and reconstruction the attenuation at the Nyquist frequency filters require trade-offs. Filters with is sufficient not to cause any problems., very sharp cut-offs are larger, more as illustrated in Fig.15. complex and more expensive than lowerHowever, one problem here is that performance filters, but provide better part of the signal that can be sampled signal quality into and out of the DSP correctly at the chosen sample rate is system. attenuated – the sampled signal will not Increasing the sample frequency (for be aliased, but it will not be a perfect a given input signal bandwidth) reducrepresentation of the original signal in es the demand on the filtering, as there the ±fs/2 bandwidth range. is larger range up to the Nyquist rate, The simplified example in Fig.15 over which the filter’s gain can decrease shows all the unwanted content rewithout affecting the wanted signal. moved, but a real filter may not be able This means lower-performance filto achieve that, resulting in some level ters can be used, or a filter cut-off rate of aliasing. Changing the filter charactersuitable for a lower sampling rate will istics will control how much the parts give better quality. However, a higher of the signal that can be correctly samsample rate increases the demands on pled are unfortunately removed, and other parts of the system (faster ADCs how much aliasing occurs. and DACs, more data to handle at a If the signal content above the Nyfaster rate) so such an approach has its quist frequency (particularly close to the own limitations. Nyquist frequency) is not strong, the filPE tering requirements are less demanding. Simulation files So it is important (if Most, but not every month, LTSpice is used to support possible) to have a descriptions and analysis in Circuit Surgery. good understandThe examples and files are available for download from ing of the frequency the PE website: https://bit.ly/pe-downloads content of the signal Terrington Components • Project boxes designed and manufactured in the UK. • Many of our enclosures used on former Maplin projects. • Unique designs and sizes, including square, long and deep variaaons of our screwed lid enclosures. • Sub-miniature sizes down to 23mm x 16mm, ideal for IoT devices. MADE IN BRITAIN www.terrington-components.co.uk | sales<at>terrington-components.co.uk | Tel: 01553 636999 44 Practical Electronics | September | 2024