Silicon ChipCircuit Surgery - March 2025 SILICON CHIP
  1. Contents
  2. Publisher's Letter: Microsoft’s constantly moving target
  3. Feature: Net Work by Alan Winstanley
  4. Project: The Pico Gamer by Geoff Graham
  5. Subscriptions
  6. Feature: Audio Out by Jake Rothman
  7. Feature: Precision Electronics, part three by Andrew Levido
  8. Feature: Max’s Cool Beans by Max the Magnificent
  9. Project: Compact Frequency Divider by Nicholas Vinen
  10. Feature: Techno Talk by Max the Magnificent
  11. Feature: Circuit Surgery by Ian Bell
  12. Feature: The Fox Report by Barry Fox
  13. Feature: The History of Electronics, part three by Dr David Maddison
  14. Project: Mains Power-Up Sequencer, part two by John Clarke
  15. Back Issues
  16. Feature: Harold S. Black, Negative Feedback & the Op Amp by Roderick Wall & Nicholas Vinen
  17. PartShop
  18. Market Centre
  19. Advertising Index
  20. Back Issues

This is only a preview of the March 2025 issue of Practical Electronics.

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

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:
  • 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:
  • 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:
  • 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:
  • (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:
  • 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:
  • 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)
Items relevant to "Mains Power-Up Sequencer, part two":
  • Mains Power-Up Sequencer PCB [10108231] (AUD $15.00)
  • Firmware (ASM and HEX) files for the Mains Power-Up Sequencer (Software, Free)
  • Mains Power-Up Sequencer PCB pattern (PDF download) [10108231] (Free)
  • Panel labels and cutting diagrams for the Mains Power-Up Sequencer (Panel Artwork, Free)
Articles in this series:
  • Mains Power-Up Sequencer, Pt1 (February 2024)
  • Mains Power-Up Sequencer, Pt2 (March 2024)
  • New use for Mains Sequencer (July 2024)
  • Mains Power-Up Sequencer, part one (February 2025)
  • Mains Power-Up Sequencer, part two (March 2025)
Fig.3: part of the filter schematic from last month showing 5 of the 24 delay sources. The input signal source is also not shown. drawing a schematic. A single line can be pasted many times and the index numbers of the signals edited on each line, or software code, or a spreadsheet can be used to generate the text. The filter output function and coefficient table are also required for a complete implementation (remember, some of the filter definitions are in the “include file” [Coeffs25.txt] in the example Figs.3 & 4). However, these also have a well-­defined structure that is straightforward to generate using code or a spreadsheet. Subcircuits The best way to use a netlist for the filter implementation is to create a subcircuit containing the netlist. A SPICE subcircuit is a netlist that can be used like a component in other circuits. It can be linked to a symbol and included in other schematics, or simply referenced via text statements. Libraries of symbols linked to subcircuit-based models of real devices, such as op amps, are included in the LTspice download. Defining a subcircuit involves two SPICE directives (commands): .subckt and .ends. The general format is: .subckt name p1 p2 p3 … circuit netlist .ends Here, name is the name of the subcircuit and p1, p2, p3 etc are the pin names (the input/output connections of the subcircuit). Between these two directives is a normal SPICE netlist defining the structure of the subcircuit. To use a subcircuit, it can be referred to using a text statement in another netlist or on a schematic. Subcircuits are components when used in other circuits, so the syntax follows the same general structure as other components. Subcircuit instance (individual component) names start with an X, similar to how resistor names start with an R and capacitors with a C. The syntax for using a subcircuit is: Xxxxx n1 n2 n3 … name + param_name1=param_value1 … Here, xxxx is the name of the individual Practical Electronics | March | 2025 * D:\LTspice\DigitalFilter\DSP-SincFilters-fig9.asc V1 x24 0 PULSE(0 1 2m 1u 1u 2m 4m) AC 1 B2 x23 0 V=delay(V(x24),{sp}) B3 x22 0 V=delay(V(x23),{sp}) B4 x21 0 V=delay(V(x22),{sp}) ⋮ B23 x2 0 V=delay(V(x3),{sp}) B24 x1 0 V=delay(V(x2),{sp}) B25 x0 0 V=delay(V(x1),{sp}) B1 Vout 0 V=filter(V(x0),V(x1),V(x2),V(x3),V(x4),…) .param sp=20.83u .ac dec 300 1 24k Fig.4: an abbreviated SPICE .inc Coeffs25.txt netlist of a schematic. .backanno .end .subckt lp_5k_48k_rec_25 inp outp .func a(i) {table(i,0,0.0260921095,1,0.02258210425,…)} B1 x23 0 V=delay(V(inp),{sp}) B2 x22 0 V=delay(V(x23),{sp}) B3 x21 0 V=delay(V(x22),{sp}) ⋮ B22 x2 0 V=delay(V(x3),{sp}) B23 x1 0 V=delay(V(x2),{sp}) B24 x0 0 V=delay(V(x1),{sp}) Fig.5: the LTspice subcircuit code for a sinc filter. B25 outp 0 V=a(0)*V(inp)+a(1)*V(x23)+ … +a(24)*V(x0) .ends instance of the subcircuit (eg, X1 or Xfilter); n1, n2, n3 etc are the nodes (wires) in the circuit which connect to the pins of the subcircuit (listed in the same order as the subcircuit definition); and name is the Fig.6: an LTspice schematic using a digital filter subcircuit. name of the subcircuit. complete filter definition. Only the beginIf the subcircuit netlist contains referning and end of the lines including the ences to parameters (ie, the parameter .func and B25 statements in Fig.5 are name inside braces {param_name1}), shown here due to their lengths. the value(s) to use for the parameter(s) are specified after the subcircuit name. Fig.5 shows the subcircuit code for a Simulating the subcircuit 10kHz low-pass filter with 25 coefficients A subcircuit can be referenced on a (similar to the filter partly shown in Fig.3). schematic as shown in Fig.6. The code The subcircuit description includes the in Fig.5 is in the text file DigitalFilters. delay sources discussed above, together lib, which is referred to as an include with the table of coefficients and the filter file on the schematic. The extension .lib output function that were in the include (library) is commonly used for LTspice file previous examples (this was discussed subcircuits, which are often found in in January 2025 Circuit Surgery). component libraries, but it is just a text Thus, the subcircuit file contains the file and can use other extensions. 47 Fig.7: the simulation results from the circuit in Fig.6 (dB/log plot). Subcircuit/library files may contain multiple subcircuit definitions. The function of the circuit in Fig.6 is essentially the same as the example from last month partly shown in Fig.3, although the cutoff frequency is different. Consider the following statement on the schematic: X_LP x24 out_lp + lp_10k_48k_rec_25 sp={period} This statement creates an instance of the lp_10k_48k_rec_25 subcircuit defined in the DigitalFilters.lib file, with the component name X_LP. It is connected to nodes x24 (filter input) and out_lp (output). The parameter sp (sample period) used inside the subcircuit is set equal to the value of the parameter period defined on the schematic using sp={period} in the subcircuit statement. The DigitalFilters.lib file must be in the same folder as the schematic; otherwise, the full path would be required in the .inc statement. The 1kΩ resistor (R1) on the filter output is not necessary for the simulation to run, but serves as a focus for the output signal, given that there is no circuit symbol for the filter itself. Of course, in a real circuit, the next stage would present some input impedance, which this resistor could represent. As the output of the filter is an idealised voltage source, the resistor value is not particularly important in this example. The results of the simulation of the circuit in Fig.6 are shown in Figs.7 & 8 0.25 Amplitude Fig.8: the simulation results from the circuit in Fig.6 (linear plot). (decibel/log frequency and linear plots, respectively). The cutoff frequency of 10kHz occurs at a gain of 0.5, or -6dB, not the more commonly used definition of -3dB. In general, the definition of cutoff is somewhat arbitrary on a smooth response curve and may be different for different types of filter. The mathematics of coefficient calculation for sinc filters naturally maps the desired cutoff to the 0.5 gain point. Also, the stopband and passband responses are symmetrical about the 0.5 point. If you imagine the peaks in the stopband at 12kHz and 16kHz in Fig.8 going negative, this may be easier to understand. So a gain of 0.5 is a natural choice for the cutoff frequency definition. The schematic in Fig.6 does not have a circuit symbol for the filter. The include file and subcircuit component statements on the schematic are written directly into the netlist, so they work fine. However, if a symbol is preferred, it is possible to create one. Windowing The response of the sinc filters we have investigated so far is not particularly good. There is significant ripple (gain variation) in the passband (see Fig.8) and the stopband attenuation is poor, being only -21dB at its worst level (see Fig.7). This situation is not improved by increasing the number of coefficients, although as discussed last month, this will improve the sharpness of cutoff (reduce 1.2 Amplitude the transition bandwidth). The problem is caused by the fact that the sinc function of the impulse response extends to infinity, but we are only using part of this function. For a filter with N coefficients, we are effectively truncating or windowing the sinc function to only those values in the ±(N – 1)/2 range. Mathematically, this is equivalent to multiplying by a rectangular function, which is 1 in the range ±(N – 1)/2 and zero elsewhere. Fig.9 shows the impulse response for a 5kHz low-pass filter with 48kHz sampling rate. This was obtained using a spreadsheet similar to the one discussed last month. Fig.10 shows a rectangular window function for N=25 and Fig.11 shows the result of multiplying the impulse response by the rectangular window. There is an abrupt cutoff at the end of the windowed impulse response, which tends to impact negatively on filter performance. The rectangular widow occurs by default if we just truncate the sinc function to use a specific number of coefficients in the filter. However, we can use other functions that will reduce the sinc function coefficients towards the edges of the used range to make the transition at the ends less abrupt. Doing this can provide certain benefits. One way to do this is to reduce the window value linearly from 1 at the centre to zero at the edges, as shown in Fig.12. This is known as a triangular or Bartlett 0.25 0.20 1.0 0.20 0.15 0.8 0.15 0.10 0.6 0.10 0.05 0.4 0.05 0.00 0.2 0.00 –0.05 0.0 –24 –20 –16 –12 –8 –4 0 4 8 12 16 20 24 Sample index Fig.9: sinc impulse response coefficients. 48 Amplitude –0.05 –24 –20 –16 –12 –8 –4 0 4 8 12 16 20 24 Sample index Fig.10: 25-coefficient rectangular window. –24 –20 –16 –12 –8 –4 0 4 8 12 16 20 24 Sample index Fig.11: a plot of FIg.10 applied to Fig.9. Practical Electronics | March | 2025 Amplitude 1.2 1.2 Amplitude 1.2 1.0 1.0 1.0 0.8 0.8 0.8 0.6 0.6 0.6 0.4 0.4 0.4 0.2 0.2 0.2 0.0 0.0 –24 –20 –16 –12 –8 –4 0 4 8 12 16 20 24 Sample index Amplitude 0.0 –24 –20 –16 –12 –8 –4 0 4 8 12 16 20 24 Sample index –24 –20 –16 –12 –8 –4 0 4 8 12 16 20 24 Sample index Fig.12: Bartlett window for 25 coefficients. Fig.13: Hamming window for 25 coefficients. Fig.14: Blackman window for 25 coefficients. window. It provides an improvement, but better performance can be obtained using more smoothly varying functions. These window functions are named after their originators, as is usually the case, although the Hanning window is based on work by Julius von Hann and was given the name “Hanning” by Ralph Blackman (of the Blackman window) and John Tukey. It is confusingly similar to the name of the Hamming window, which is attributed to Richard Hamming. These three window functions have similar shapes. Figs.13 & 14 show the Hamming and Blackman windows, respectively. Fig.15 shows the Blackman window applied to the impulse response (filter coefficients) in Fig.9. Comparison with Fig.11 shows a significant reduction in abruptness of the transition at the ends of the index range (±12). 0.25 Window functions There are a large number of possible window functions that can be used, but a few based on cosine functions are commonly used in FIR filter designs. These are the Hanning, Hamming and Blackman windows, the formulae for which are stated below. These are written using the same symbols for sample index (i) and the total number of coefficients (N) as the formula for coefficients discussed last month. In all cases, the value is zero for index values outside the ±(N – 1)/2 range. Hanning: ( ) ( ) (( )) ( ) ) ( )( ) ( ) ( 2 πi 0.5 − 0.4 cos N2−1 πi 0.5 − 0.4 cos N2−1 Hamming: 2πiπi 0.5 − − 0.46 0.4 cos 0.54 cos N −1 N2−1 πi 0.54 − 0.46 cos N −1 2 πi 2 πi 4 πi 0.54 0.42 − 0.5 cos− 0.46 cos+ 0.8 cos N −1 Blackman: N2−1 N4−1 πi πi 0.42 − 0.5 cos + 0.8 cos N2−1 N4−1 πi πi 0.42 − 0.5 cos + 0.8 cos N −1 N −1 ( ( ( Simulating windowed filters ) ) ) Fig.16 shows an LTspice schematic for comparing the responses of the rectangular, Hamming and Blackman windows. The filters are all 5kHz lowpass types with a sampling rate of 48kHz. The approach is similar to that used in the circuit in Fig.6, and each filter is defined by a subcircuit like that shown in Fig.5. All three subcircuits are included in Amplitude 0.20 0.15 0.10 0.05 0.00 –0.05 –24 –20 –16 –12 –8 –4 0 4 8 12 16 20 24 Sample index Fig.15: a sinc impulse response with the Blackman window in Fig.14 applied. the file WindowedFilters.lib, and each one only differs from the code in Fig.5 by the coefficient values used in the table. The coefficient values were calculated using a spreadsheet similar to the one discussed last month. The sinc function impulse response is calculated the same way as before and normalised to give the rectangular windowed filter coefficients. The window functions for the Hamming and Blackman windows are calculated using the formulae above over the same index range as the sinc function. The raw sinc function is multiplied by the window function values to give the raw impulse response with these windowed filters. These are individually Fig.16: an LTspice schematic for a simulation to compare different window functions. Practical Electronics | March | 2025 49 Fig.17: the simulation results from the circuit in Fig.16 (dB/log plot). Fig.18: the simulation results from the circuit in Fig.16 (linear plot). Fig.19: an LTspice schematic for simulating a 25-coefficient rectangular windowed filter (top) and a 129-coefficient Blackman windowed filter (bottom). normalised to obtain unity-gain versions of the windowed filters. The results of simulating the circuit in Fig.16 are shown in Figs.17 & 18 (decibel/ log frequency and linear plots, respectively). The green trace is the rectangular windowed filter, the red trace is the Hamming and the cyan one is the Blackman. The Hamming and Blackman windows provide much better (worst-case) stopband attenuation at around 51dB and 74dB, respectively, compared with only around 20dB for the rectangular window (see Fig.17). The rectangular windowed filter has much more passband ripple (see Fig.18). One negative aspect of the Hamming and Blackman windows is their slower transition from passband to stopband. The Blackman is worse than the Hamming in this respect, but as just noted, provides better stopband attenuation. The transition bandwidth can be reduced by increasing the number of coefficients. The circuit in Fig.19 includes the same rectangular windowed filter as in Fig.16, along with a 129-coefficient Blackman windowed filter (also 5kHz cutoff at a 48kHz sampling rate). The 129-coefficient filter was added to the existing .lib file and follows the same pattern as the other examples. The results are shown in Figs.20 & 21 (decibel/log frequency and linear plots, respectively). In this case, the transition of the Blackman filter (cyan trace) is closer to that of the original rectangular filter (green trace) with this version. The stopband attenuation of this Blackman widowed filter is the same as previously, at around 74dB at the highest peak in the stopband – increasing the number of coefficients does not change this. We can obtain very good frequency responses using windowed sinc FIR filters, but they require a large number of coefficients to achieve fast cutoffs. Improving the sharpness therefore requires an increase in run time or faster processing for software implementation, or more circuitry for hardware implementation. Also, the coefficient values must be accurate to give good results and the typically large range in values between different coefficients means that floating point calculations are often needed. PE Fig.20: the simulation results from the circuit in Fig.19 (dB/log plot). Fig.21: the simulation results from the circuit in Fig.19 (linear plot). 50 Practical Electronics | March | 2025