Silicon ChipCircuit Surgery - May 2025 SILICON CHIP
  1. Contents
  2. Publisher's Letter: Ferrite beads are not inductors
  3. Feature: Techno Talk by Max the Magnificent
  4. Feature: A short history of Sinclair’s handheld calculators by Chris Morris
  5. Project: The Skill Tester 9000, part one by Phil Prosser
  6. Feature: Circuit Surgery by Ian Bell
  7. Review: Raspberry Pi 5 by Tim Blythman
  8. Project: DIY USB-C Serial Adaptor by Tim Blythman
  9. Feature: Max’s Cool Beans by Max the Magnificent
  10. Project: Three DC Supply Input Protectors by John Clarke
  11. Feature: Adding Solar Charging to a Renault Kangoo EV by Roderick Boswell
  12. Subscriptions
  13. Feature: Precision Electronics, part five by Andrew Levido
  14. Feature: Audio Out by Jake Rothman
  15. Feature: The Fox Report by Barry Fox
  16. Feature: The History of Electronics, part five by Dr David Maddison
  17. PartShop
  18. Advertising Index
  19. Market Centre
  20. Back Issues

This is only a preview of the May 2025 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)
Items relevant to "The Skill Tester 9000, part one":
  • Skill Tester 9000 PCB [08101241] (AUD $15.00)
  • Skill Tester 9000 PCB pattern (PDF download) [08101241] (Free)
Articles in this series:
  • Skill Tester 9000, Pt1 (April 2024)
  • Skill Tester 9000, Part 2 (May 2024)
  • The Skill Tester 9000, part one (May 2025)
  • Skill Tester 9000, Part 2 (June 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:
  • Max’s Cool Beans (January 2025)
  • Max’s Cool Beans (February 2025)
  • Max’s Cool Beans (March 2025)
  • Max’s Cool Beans (April 2025)
  • Max’s Cool Beans (May 2025)
  • Max’s Cool Beans (June 2025)
Articles in this series:
  • Precision Electronics, Part 1 (November 2024)
  • Precision Electronics, Part 2 (December 2024)
  • Precision Electronics, part one (January 2025)
  • Precision Electronics, Part 3 (January 2025)
  • Precision Electronics, part two (February 2025)
  • Precision Electronics, Part 4 (February 2025)
  • Precision Electronics, Part 5 (March 2025)
  • Precision Electronics, part three (March 2025)
  • Precision Electronics, part four (April 2025)
  • Precision Electronics, Part 6 (April 2025)
  • Precision Electronics, Part 7: ADCs (May 2025)
  • Precision Electronics, part five (May 2025)
  • Precision Electronics, part six (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:
  • 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:
  • The History of Electronics, Pt1 (October 2023)
  • The History of Electronics, Pt2 (November 2023)
  • The History of Electronics, Pt3 (December 2023)
  • The History of Electronics, part one (January 2025)
  • The History of Electronics, part two (February 2025)
  • The History of Electronics, part three (March 2025)
  • The History of Electronics, part four (April 2025)
  • The History of Electronics, part five (May 2025)
  • The History of Electronics, part six (June 2025)
Circuit Surgery Regular clinic by Ian Bell Topics in digital signal processing – high-pass, band-pass and band-stop filters 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 but originate from and/or are converted to 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 analog input via digital processing to an analog output. This does not necessarily represent every DSP system (not all have all the parts shown), but it serves as a reference for the various subsystems we will consider. Over the last few months, we have explored various aspects of digital filters (the processing part in Fig.1), concentrating on discussing windowed sinc filters, as these are relatively straightforward to implement and understand. As well as covering the theory behind their operation, we have shown how the filter design calculations (finding their coefficient values) can be performed using spreadsheets and how LTspice can be used to simulate filter operation. Last month, we discussed creating symbols for the filters in LTspice so that the subcircuit code used to implement them could be easily reused in different circuit simulations. Beyond low-pass responses We started the discussion on filters with the simple case of a moving average, which is a well-known data smoothing operation and, in circuit terms, provides a low-pass function. The moving average is a weighted sum of the current and past inputs, which leads to the structure shown in Fig.2. Analog In Antialiasing filter Sample and hold This is known as a finite impulse response (FIR) filter because an impulse (input signal comprising just one sample at value one) produces an output that is non-zero for a finite duration. A moving average uses equal weights (coefficients, an in Fig.2), but better filters can be obtained by using different values for individual coefficients. The coefficients for an ideal low-pass (brick wall) filter can be obtained from the inverse Fourier transform of its frequency response, which is found to be the sinc function. A real implementation has a limited number of coefficients (N), but simply truncating the set of values does not give the best results. Instead, we apply a window function to smoothly reduce the values towards the ends of the used range. So far, we have only looked at low-pass filters as they are the most straightforward in terms of theory and mathematics. However, high-pass, band-pass and bandstop (or band-reject) responses are also important in many systems. All of these can be implemented as windowed sinc FIR filters using the same structure as the low-pass (Fig.2). This month, we will look at how to get these other filter response types. From low-pass to high-pass Using FIR filters structured as shown in Fig.2, we can achieve different response types. There is no need to change the fundamental structure; we just need to find the right set of coefficients (filter kernel) to obtain the desired response. The number of coefficients does not affect the response type – just the quality of the response (cut-off sharpness) and delay through the filter. Usefully, if we have the coefficients Digital ADC Digital processing Analog DAC Fig.1: a generic digital signal processing (DSP) system structure. 18 for a low-pass response, we can get the kernel for a related high-pass filter from it with some minor additional steps (another reason we first considered lowpass filters). Furthermore, band-pass and band-stop filters can be obtained by combining high-pass and low-pass responses. From a graphical perspective, highpass filter responses can be obtained from related low-pass responses in a couple of ways. Firstly, we can flip the response curve upside down, as shown in Fig.3. This is referred to as spectral inversion. The high-pass and low-pass cutoff frequencies are the same (fhp = flp). Alternatively, we can reflect the response curve horizontally about a certain frequency. This is called spectral reversal and is illustrated in Fig.4, with the reflection line shown in red at half the Nyquist frequency (ie, half the sampling frequency [fs /2] and the maximum frequency that we can process). The relative cutoff frequencies depend on the reflection point, but in Fig.4 with the reflection around fs /4, we get fhp = fs /2 – flp . The preceding discussion defines how a low-pass response could be made into a high-pass response, but does not explain how it might be achieved in practice. Reconstruction filter a0 x(n) × Σ y(n) a1 Δt x(n–1) × a1x(n–1) Σ a2 Δt x(n–2) × a2x(n–2) Σ aN–1 Δt Out a0x(n) Memory x(n–N–1) × aN–1x(n–N–1) Processing Fig.2: the structure of a finite impulse response (FIR) filter. Practical Electronics | May | 2025 Gain Low-pass Gain Low-pass Gain 1.0 1.0 1.0 0.5 0.5 0.5 0.0 0 fLP 0.0 fS/2 Frequency fLP 0 Flip vertical (spectral inversion) Gain High-pass Gain 1.0 0.5 0.5 0 fHP 0.0 fS/2 Frequency 0.0 fS/2 0 Frequency fS/2 Fig.5: the all-pass filter response. Flip horizontal (spectral reversal) 1.0 0.0 Frequency All-pass High-pass All-pass A Subtractor S=A–B In 0 Frequency fHP Low-pass fS/2 Out S B Fig.3: spectral inversion, a vertical flip of the low-pass frequency response, results in a high-pass response. Fig.4: spectral reversal, a horizontal flip of the low-pass frequency response, also produces a high-pass response. Fig.6: a possible high-pass filter implementation by spectral inversion. We need to know how to calculate the high-pass coefficients from the low-pass coefficients in both cases. achieve the same result. The difference is in the delay of the signal from input to output. The delay is equal to n sample periods if coefficient an is the non-zero value. In order for the subtraction shown in Fig.6 to work correctly, the all-pass and low-pass blocks must have the same delay. Subtracting signals at different time points would lead to signal distortion. As discussed in the February 2025 issue, the fundamental calculation of the sinc function coefficients for the lowpass filter gives a filter with zero delay but only if future values of the signal can be used. Such a non-causal filter cannot be implemented with real­-time processing. The solution is to time shift the coefficients by (N – 1)/2 samples for a filter with N coefficients. The resulting filter has the same delay as the time shift. This means that to match the low-pass filter delay, the all-pass filter must have coefficient at index (N – 1)/2 equal to one, and all others zero. Fig.7 shows the raw coefficients for a 10kHz low-pass filter with 25 coefficients and a 48kHz sampling rate, similar to the previous examples we have looked at. Fig.8 shows the time shifted coefficients that form the causal filter kernel. The shift is (25 – 1) / 2 = 12 samples, so the index range of kernel is n = 0 to 24. Fig.9 shows the kernel required for the all-pass filter in Fig.6 to match its delay to the low-pass filter kernel in Fig.8. Recall from discussions in previous months that the coefficients of a filter are equal to its impulse response. Looking at Fig.9, we see that the impulse response of the all-pass filter is an impulse function, so you may see this filter notated as δ[n]. The high-pass filter does not have to be implemented using the structure shown in Fig.6. This is useful for understanding the concept behind its operation, but it is more effective to perform the subtraction operation directly on the two kernels. This results in a single kernel that will provide the high-pass function without the need to use multistep processing. Doing this is straightforward – we just subtract the low-pass coefficients from the all-pass coefficients at each index. For all the coefficients, apart from the middle one, the all-pass values are zero, so we obtain the high-pass kernel simply by changing the sign of the lowpass coefficients. For the middle one (where the all-pass coefficient is equal to 1), we also change the sign of low-pass coefficient, but High-pass by spectral inversion Starting with spectral inversion, we note that this can be achieved by subtracting the output of a low-pass filter from a circuit with a flat frequency response of gain 1 (assuming the low-pass response varies from 0 to 1, as shown in Fig.3). The flat response circuit is called an all-pass filter (Fig.5). Initially, it might seem that this could be just an ideal wired connection, but there is more to it than that, because we have to consider delay. We can envisage implementing the high-pass filter using a circuit (or software processing) like that show in Fig.6. The signal is processed by the all-pass and low-pass functions in parallel, then a subtraction operation is performed to achieve the high-pass response. How do we implement the all-pass function? Consider the structure in Fig.2. If we set an to one and all the other coefficients to zero, the output will be equal to the input with no variation in gain with frequency – a flat frequency response, as required. In fact, we can set any of the coefficients to one with the others zero and 0.50 Amplitude Amplitude 0.50 0.40 0.40 1.00 0.30 0.30 0.80 0.20 0.20 0.10 0.10 0.00 0.00 0.00 –0.10 –0.10 –0.20 –12 –10 –8 –6 –4 –2 0 2 4 6 8 10 12 Sample index Fig.7: the raw coefficients for an example low-pass filter. Practical Electronics | May | 2025 Amplitude 1.20 0.60 0.40 0.20 0 2 4 6 8 10 12 14 16 18 20 22 24 Sample index Fig.8: the coefficients from Fig.7 shifted to give a kernel for a causal filter. 0 2 4 6 8 10 12 14 16 18 20 22 24 Sample index Fig.9: the kernel for the all-pass filter to match the low-pass filter in Fig.8. 19 Amplitude 0.70 Gain Low-pass 0.60 0.50 0.5 0.40 t 0.0 0.30 0 0.20 fLP fS/2 Frequency Shift response fS/2 0.10 Gain 0.00 Fig.12: a sinusoid sampled at fs /2. Low-pass 1.0 –0.10 –0.20 samples of the fs /2 sinusoid, sampled at the system sampling rate of fs . For this to work, the samples 0.0 have to be sensibly aligned – if they fHP fS/2 0 Frequency were all at the zero crossings, that Fig.11: shifting the frequency response would not work. to achieve spectral reversal. Fig.12 shows a sinusoid of amplitude 1 and frequency fs /2 sampled at the peaks; that antialiasing filtering has been implethe resulting sample values are alternatmented correctly. ing +1 and -1. Any other alignment apart Shifting in the frequency domain by an from the zero-crossing case would give amount f can be achieved by multiplying the same sign alternation, which could in the time domain by a sinusoidal wavebe scaled back to ±1. form of frequency f. The most well-known So, to obtain a high-pass response, we application of this is in modulation and just change the sign of alternate coeffidemodulation. For example, an AM radio cients of the low-pass kernel, leaving the signal can be produced by multiplying others as they are (with the middle one the audio signal by the carrier wave – the unchanged). Fig.13 shows the result of apaudio is shifted to frequencies around plying this to the low-pass kernel in Fig.8. the carrier wave frequency. We discussed this in detail in the CirA simulated example cuit Surgery articles on superheterodyne Fig.14 shows an LTspice schematic radio starting in December 2023. In radio for simulating two high-pass filters (U2 parlance, the high-pass part of the shifted and U3) along with the low-pass filter frequency response in Fig.11 is like the (U1) from which they were derived. lower sideband. These filters were implemented using In the case of the high-pass filter, we the techniques described in recent Cirare not frequency-shifting the signal, but cuit Surgery articles. the response of the filter. This is defined As before, the symbols link to subcirin the time domain by the kernel, so to cuit definitions in a library file, in which shift the frequency response of the filter repetitive parts of the code were generated by fs /2, we need to multiply the kernel using a spreadsheet, with the coefficients copied from another spreadsheet that by a sinusoid of frequency fs /2. was used to calculate their values. The We are working with sampled signals, symbols were created by copying the exso we will be multiplying the kernel by isting symbols and editing the subcircuit name to which they refer. No other edits were required as the other parameters and I/O connections are the same as before. 0.5 –0.30 –0.40 Amplitude 1.0 0 2 4 6 8 10 12 14 16 18 20 22 24 Sample index Fig.10: the kernel for a 10kHz high-pass filter obtained by spectral inversion. then we need to add one to this. Fig.10 shows the coefficients for a 10kHz highpass filter obtained in this way from the kernel in Fig.8. High-pass by spectral reversal Over the range up to the Nyquist frequency (half the sampling frequency, ie, fs /2), spectral reversal is equivalent to shifting the frequency response curve by fs /2. This is shown in Fig.11, which includes the negative frequency part of the frequency response. Negative frequencies, as related to the mathematical representation of signals and systems, were discussed in Circuit Surgery, August 2024. Many circuits and signals have symmetrical responses and spectra in negative frequencies. In Fig.11, we see that the negative frequency part of the response becomes the high-pass part of the curve after shifting. The gain would drop again somewhere above fs /2, but this is not a concern because our sampled signal will not contain any frequencies in this range – assuming that this is true of the sampled signal, or Gain 1.0 Lowpass 0.5 0.0 0 Highpass fLP fHP Frequency fS/2 Addition of low-pass and high-pass Gain Band-stop 1.0 0.5 0.0 Fig.15: the results from simulating the circuit shown in Fig.14. 20 0 fL fU Frequency fS/2 Fig.16: adding low-pass and high-pass responses to obtain a band-stop filter. Practical Electronics | May | 2025 Amplitude 0.50 0.40 0.30 0.20 0.10 0.00 –0.10 –0.20 –0.30 –0.40 0 2 4 6 8 10 12 14 16 18 20 22 24 Sample index Fig.13: the kernel for a 14kHz high-pass filter obtained by spectral reversal. The filters use 25 coefficients, a 48kHz sampling rate and rectangular windows. The low-pass filter has a cut-off frequency of 10kHz, like the kernel shown in Fig.8. High-pass filter U2 has coefficients calculated using spectral inversion. In the spreadsheet, this is achieved by adding a column with values equal to the negative of the normalised low-pass coefficients, calculated by the approach described in February 2025. The middle value has a different formula that adds 1 to the negated low-pass coefficient. The kernel is as shown in Fig.10. High-pass filter U3 has coefficients calculated using spectral reversal. In the spreadsheet, this is achieved by first adding a column in which the rows are alternating 1s and -1s, then adding another column in which the normalised low-pass coefficients are multiplied by these values. The alternating 1s and -1s can be obtained in various ways, including simple copy-paste, but a better approach is to use the formula (-1)i, that is, minus one to the power of the sample index i. This means the same formula can be used in every row, and the middle coefficient, which always has an even index, will be positive. The kernel is as shown in Fig.13. Fig.15 shows the simulation results. The upper pane is the frequency response of the low-pass filter (green trace) and the U2 (spectral inversion) high-pass filter (red trace). The U2 high-pass filter has the same cut-off as the low-pass filter, as expected from Fig.3 and the related discussion above. The lower pane in Fig.15 shows the frequency response of the low-pass filter again (green trace) and the U3 (spectral reversal) high-pass filter (magenta trace). The cutoff frequency of the U3 filter is 14kHz, which is fs /2 - flp (24kHz – 10kHz = 14kHz), as discussed above. Band-pass and band-stop filters Band-pass and band-stop filters can be obtained by combining low-pass and high-pass filters. We need to consider how the two responses would be combined in the frequency domain and what this implies in the time domain. Practical Electronics | May | 2025 Fig.14: an LTspice schematic for simulating the example high-pass filters. This requires an understanding of how operations map between the two domains, similar to how spectral reversal used the correspondence between shifting in the frequency domain and multiplying by a sinusoid in the time domain. Adding suitable low-pass and high-pass functions (where the low-pass cut-off is below the high-pass cut-off) produces a band-stop response, with the resulting stop band being between the two original cut-off frequencies (see Fig.16). This is straightforward to map to the time domain, because addition in one domain corresponds to addition in the other. Therefore, we can obtain a band-stop filter kernel by adding the coefficients at each index from a low-pass and a high-pass filter (with the same number of coefficients). Band-pass filters can be obtained by multiplying suitable low-pass and high-pass functions (where the high-pass cut-off is below the low-pass cut-off) – see Fig.17. At frequencies where either of the original filters has a gain of zero, the resulting filter will also have a gain of zero. Assuming a passband gain of one for both original filters, the gain of the resulting filter will be one where the pass bands overlap. If the transition bands of each filter coincide with the passbands of the other filter, the two transitions of the resulting filter will match those of the original filters (see Fig.16). As discussed when we introduced convolution in Circuit Surgery, August 2024, multiplication in the frequency domain corresponds to convolution in the time domain, and vice versa. Therefore, to obtain a band-pass response from suitable high-pass and low-pass responses, we can perform a convolution calculation on the two kernels. Unfortunately, convolution is significantly more complicated to implement in Excel than the sign-change and addition operations used in the other response conversions discussed above. On the other hand, if you write code to calculate the kernels (in languages such as C or Python) and have the coefficient data in arrays, the convolution calculation is not particularly difficult. A convolution can be calculated in Excel by setting out the convolution’s reverse, shift, multiply, add operations in a grid, but this is cumbersome for anything but a small number of values. Another possible approach is to use Excel’s LAMBDA functions. These can be used to create your own functions, which become available in a workbook like native Excel functions without needing to use macros with their associated security risks. Some examples can be found online. Fortunately, it is possible to avoid convolution when finding a band-pass response by performing spectral inversion on a band-stop response. Imagine flipping the band-stop response in Fig.16 upside-down; you get the band-pass response in Fig.17. Gain 1.0 Highpass 0.5 0.0 Lowpass 0 fLP fHP Frequency fS/2 Multiplication of low-pass and high-pass Gain Band-pass 1.0 0.5 0.0 0 fL fU Frequency fS/2 Fig.17: multiplying low-pass and high-pass responses to obtain a band-pass filter. 21 Therefore, we just need to add two suitable kernels, with the low-pass cutoff below the high-pass cut-off, negate all resulting coefficients and add one to the centre coefficient. Simulation examples Fig.18 shows simulation results for 10kHz to 14kHz band-stop and bandpass filters based on the 10kHz low-pass and 14kHz high-pass filters discussed above. The LTspice schematic (not shown in this article ) is very similar to Fig.14, but comprises four filters: the original 10kHz low-pass (output: out_lp), the 14kHz high-pass obtained by a spectral reversal of the low-pass filter (output: out_hp_rev), the band-stop filter obtained by addition of the low-pass and high-pass kernels (output: out_bs), and the band-pass filter obtained by a spectral reversal of the band-stop filter (output: out_bp). After obtaining the coefficients, the new filters were created using the same process as for those in Fig.14. The upper pane in Fig.18 shows the original low-pass and high-pass filters for reference (green and magenta traces, respectively). The lower two panes show the bandstop (yellow trace) and band-pass (orange trace) filters, respectively. The filters used in the examples discussed so far are not particularly high in performance. The filters’ transitions are not especially fast, and there are significant ripples in the both the passbands and stopbands. As examples, this is perhaps helpful in that it makes it easier to see the relationship between the response of the original filters and those derived by manipulating their coefficients. Still, having said that, it is worth taking a quick look at a higher-performance filter which, as previously discussed, can be achieved using window functions and by incorporating a larger number of coefficients. Fig.19 (linear) and Fig.20 (dB vs log frequency) show the response of a 10kHz to 14kHz band-pass filter using 129 coefficients and a Blackman window. This was derived from the kernel of a 10kHz low-pass filter, similar to the 5kHz version used in the March 2025 issue. This filter has an obviously cleaner and sharper response, but it is nowhere near the limit of what can be achieved with digital filters. Using a large number of coefficients with windowing allows very sharp cut-offs to be achieved, which facilitates the use of very narrow stopbands and passbands. As previously noted, the main disadvantages of the filters we have been 22 Fig.18: LTspice simulations of band-stop and band-pass filters. Fig.19: a higher performance band-pass response using 129 coefficients and a Blackman window. discussing is that they have a relatively large input-output delay, and require a relatively large number of calculations. This may mean that a more powerful DSP system is required to implement them than other types of similar digital filters. However, they have the significant advantage that you have very good control over the response, and sharp roll-offs are possible, as are flat passbands. FIR filters also have some very beneficial properties in terms of phase and delay, which we’ll look at in more detail shortly. Coefficient tools We have shown how to calculate coefficients for the filters we have discussed. However, this can be fair amount of work and, as you might expect, there are tools and online utilities that can do the job for you. If you have access to the MATLAB software, there is a Filter Designer app with wide-ranging capabilities. However, if you are mainly interested in creating the basic types of filter we have been discussing, the FIIIR! online utility from Tom Roelandts (https://fiiir.com/) is very useful. This can calculate coefficients for various types of windowed sinc FIR filters. You specify the sampling rate, cutoff frequency, transition bandwidth and window type, and it computes the filter coefficients for you and plots the responses. Delay and phase Earlier, we mentioned the importance of delay in our discussion of calculations for the high-pass filter. The delay Practical Electronics | May | 2025 Simulation files Most months, LTSpice is used to support descriptions and analysis in Circuit Surgery. The examples and files are available for download from the PE website: https://bit.ly/pe-downloads Fig.20: a decibel/log frequency version of the plot in Fig.19. Fig.21: LTspice plots of phase and delay for the low-pass filter from Fig.14. properties of filters are important, so it is worth looking at this in a little more detail. When discussing circuits such as filters, it is common to show the delay in the form of a phase shift. The phase shift represents the delay of a circuit in terms of the number of waveform cycles of a waveform (whole or partial, expressed as an angle) at the frequency of interest. For the filters we have been discussing, we have already noted that the delay is (N – 1) / 2 sample periods for a filter with N coefficients. Our examples Practical Electronics | May | 2025 have a sample period of 20.833μs (the reciprocal of the sampling frequency of 48kHz). For the 25-coefficient filters we have used in the majority of examples, the delay from input to output is therefore 12 × 20.833μs = 250μs. Consider what happens with a circuit that has a fixed delay from input to output as the frequency varies. At 1kHz, our example 250μs delay is a quarter of the signal’s cycle time of 1ms. This means that the circuit has a phase shift of -90° at 1kHz (one complete cycle of the waveform is 360°). The sign is related to the formula for sinusoid, sin(ωt + Ф), where ω is frequency in radians per second and Ф is the phase shift in radians. A negative value of Ф results in the features of the waveform appearing later in time (lagging) compared with Ф = 0 as the waveforms progress. A fixed delay means that the amount of phase shift will increase linearly with frequency; in this case, -90° for every 1kHz. At 2kHz, 250μs is half the cycle time of the signal, which is a phase shift of -180°; however, due to the symmetry of the sinewave, this is the same as a phase shift of +180°. Similarly, at 4kHz, the delay is a complete cycle, which is 360° but equivalent to 0° (no shift) as the shifted and original sinewaves align. At higher frequencies, the delays correspond to multiple cycles, but will always also be equivalent to a shift within the range ±180°. For example, at 7kHz, the phase shift is 7 × -90° = -630°, which is equivalent to +90°. The ambiguity in phase values due to its circular nature leads to LTspice having two options for displaying phase. The graphs of frequency response we have shown so far have not included the phase shift, just the gain (magnitude) of the response. The phase display can be switched on and off by right clicking on the right axis area of the AC simulation result plot, which opens the Right Vertical Axis dialog. With the phase displayed, if the option “Unravel branch wrap” is selected, the full phase value is plotted; otherwise, it is limited to ±180°. The delay of the circuit can also be plotted by selecting the “Group delay” instead of “Phase” representation. The term ‘group delay’ refers to the delay experienced by a small range (group) of frequencies. For example, this could be the envelope of a modulated signal (eg, the AM signal around a carrier), rather than the simple time delay at a single frequency (referred to as the phase delay). It is defined as the differential of phase with frequency (ie, the slope of the line on the phase plot). For a circuit with 23 The Wireless for the Warrior books are references for the history and development of radio communication equipment used by the British Army from the very early days of wireless up to the 1960s. Volumes 1 & 3 are still available. Order a printed copy now from: https:///pemag.au/link/ac20 https: constant delay, the group and phase delays are equal. Fig.21 shows wrapped phase (top), unwrapped phase (middle) and delay (bottom) for the low-pass filter from Fig.14 for frequencies up to just past the cutoff frequency. The linear increase of phase with frequency and flat delay can be seen and correspond with the values discussed above. For a signal other than a sinewave, there will be multiple frequency components present. If these are delayed by different amounts, the signal will distort (this is called ‘phase distortion’). For this reason, the flat delay/ linear phase behaviour of the FIR filters we have been discussing is often a very desirable characteristic. The allpass filter mentioned above also has a linear phase response. Fig.22 illustrates the distortion caused by a nonlinear phase/delay that varies with frequency. The top waveform is a pulse containing two frequencies (two added sinewaves with an amplitude envelope). The middle waveform is the result of delaying the two frequencies by the same amount – the shape of the waveform is the same as the input. In contrast, the lower waveform, where the delays at the two frequencies are different, is clearly distorted PE (it has a different shape). Fig.22: an example of phase distortion. FIND ALL YOUR ELECTRONIC COMPONENTS IN ONE PLACE BASIC MICRO E L E CT R O N I C S C O M P O N E N T S U P P L I E R w w w . basicmicro . co . u k High-quality, genuine parts 24 Practical Electronics | May | 2025