Silicon ChipCircuit Surgery - August 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions
  5. Publisher's Letter: The power of batteries
  6. Feature: Time for a total rethink? by Mark Nelson
  7. Feature: Net Work by Alan Winstanley
  8. Project: Multi-purpose Battery Manager by Tim Blythman
  9. Project: Simple MIDI Music Keyboard by Tim Blythman
  10. Project: NANO PONG ON YOUR TV by TIM BLYTHMAN
  11. Project: USB Power Delivery Chargers by Jim Rowe
  12. Feature: Make it with Micromite by Phil Boyce
  13. Feature: KickStart by Mike Tooley
  14. Feature: Max’s Cool Beans by Max the Magnifi cent
  15. Feature: Flowcode Graphical Programming by Martin Whitlock
  16. Feature: Circuit Surgery by Ian Bell
  17. PCB Order Form
  18. Advertising Index

This is only a preview of the August 2022 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)
Circuit Surgery Regular clinic by Ian Bell Distortion and distortion circuits – Part 3 F or the past two months we have been looking at distortion – the effect of non-linearities in circuits such as amplifiers on the shape of their output waveforms. Distortion is often an unwanted characteristic that circuit designers make significant efforts to minimise. The amount of unwanted distortion is commonly measured using Total Harmonic Distortion (THD), particularly in audio applications, which, along with the basic concepts of distortion, was covered in the first article (PE, June 2022). Last month, we looked at signal spectra in the context of distortion. A spectrum is a plot of signal strength against frequency, thus showing the frequencies present in a signal. Periodic waveform can be formed by adding together a set of sinewaves of various frequencies and different amplitudes (known as a Fourier series). Therefore, the spectrum plot of a periodic signal shows a set of peaks at specific frequencies. The spectrum of the output of a linear circuit will not contain frequencies which were not in the input (although the relative amplitude of the original frequencies may change). If distortion occurs due to non-linearities there will be frequencies present in the output which were not in the input. For a sinewave input, the additional output frequencies due to distortion will be at integer multiples of the input frequencies, that is, harmonics of the input. This is the basis of quantifying distortion using THD. LTspice is able to plot signal spectra and calculate THD, hence providing insights into distortion. However, this requires some care and attention in setting up the simulation, and this was a key part of last month’s discussion. Although often unwanted, distortion also has its uses, including in sound processing effects used by musicians – the most well-known example is probably the distortional pedals used by electric guitar players. In fact, this series of articles was inspired by musical effects projects by John Clarke in PE over the past year or two. This month, we are going to look at circuits which can be used to deliberately produce distortion for creative purposes. Clipping Most musical distortion is obtained from circuits which deliberately cause the signal to be clipped – that is, the amplitude of the signal is limited so that the peaks of the waveform are flattened. This is also referred to as saturation. We will recap what we mean by clipping and look at a couple of key variations (hard/soft and symmetrical/asymmetrical) before considering some of the circuits that can be used to achieve these effects. If we plot the transfer function (input amplitude vs output amplitude) of an ideal amplifier it will be a perfect straight line for all possible amplitudes (the grey line for v(y1) on the plots on the left of Fig.1). Real amplifiers have a maximum output amplitude which results in transfer functions more like those shown by the coloured traces for v(y2) and v(y3) on the left of Fig.1. These two differ in how sharp the transition is between the linear region at low amplitudes and the fully limited region at high amplitudes. A relatively fast transition is referred to as ‘hard clipping’ (eg, for y2). ‘Soft clipping’ refers to a more gradual transition (eg, for y3). The plots in Fig.1 were obtained from a mathematically defined transfer function discussed in the first article. The grey traces on the right side show the undistorted sinewave output. For a given amplifier, or other circuit which produces clipping, the amount of distortion depends on the input signal amplitude. This is illustrated in Fig.2, which shows the output from the same transfer function as in Fig.1, but with more than twice the input amplitude (1.3V peak in Fig.1, 3V in Fig.2). As amplitude is increased for a sinewave input, the output of clipping circuits will tend towards producing square waves. Softer clipping functions will produce rounder corners on the square wave, but this will also occur if the distorted signal is low-pass filtered. The transfer function of a distorting circuit does not have to be symmetrical. Non-symmetrical distortion will occur if the transfer function is asymmetrical, or if a signal with a DC offset is applied to a symmetrical transfer function. The latter case is illustrated in Fig.3. This uses the same signal amplitude as in Fig.1 (1.3V peak) but with a +0.65V DC offset on the input sinewave. This means that Simulation files Most, but not every month, LTSpice is used to support descriptions and analysis in Circuit Surgery. The examples and files are available for download from the PE website. Practical Electronics | August | 2022 Fig.1. Hard (top) and soft (bottom) clipping. 65 in the first article, the soft clipping function used a behavioural source with the function: sgn(v(x))*uplim(abs(v(x)), lim,0.4) Here, lim is the limit or clipping voltage. For asymmetrical clipping, two such versions of the function were used with limit values of 0.5 and 1.0. The two functions were selected using an if function: V=if(v(x)+0.5,a,b) Fig.2. The same clipping function as in Fig.1 with a larger input signal. Here, a and b are the two limiting functions. The LTspice function if(x,y,z) returns y if x > 0.5, else z. Refer to the first article for the LTspice schematic. Peddling terminology Distortion effects pedals used by musicians are often described as providing ‘boost’, ‘overdrive’, ‘distortion’ and ‘fuzz’. The term overdrive was originally used to describe turning up the volume (gain) of a guitar amplifier sufficiently to cause it to clip, thus giving a fuller, grittier sound. In the early days of electric guitars (before the widespread availability of effects pedals), this was necessary to obtain a distortion effect in the amplifier itself. These early amplifiers were built using ‘valve’ – vacuum tube – technology (not transistors/semiconductors), which produced a relatively soft clipping due to the characteristics of Fig.3. Asymmetrical distortion obtained by applying the devices. Thus, a pedal marketed a sinewave with DC offset to the transfer functions as providing overdrive will typically provide soft clipping and aim to shown on the left-hand side in Fig.1. emulate the sound obtained by overdriving a valve amplifier. the negative peak is at –1.0V and only A ‘boost’ function simply provides gain just reaches the limiting voltage of the (amplification) without any clipping. Tone clipping function. The negative peak is controls may also be provided to control not significantly distorted, but the positive frequency response (provide different peak is heavily clipped. The signal in Fig.3 gain at different frequencies). As noted has DC offset, but this is easily removed above, and seen in Fig.2, increasing signal using a coupling capacitor. amplitude produces more distortion, Fig.4 shows an asymmetrical soft thus a signal boost can be used to help clipping transfer function and the force an amplifier to clip, or increase the resulting output waveform for a 1.3V amount of distortion provided by the sinewave with no offset. As discussed Fig.4. Asymmetrical distortion from an asymmetrical transfer function. 66 clipping circuit (distortion effects unit) connected to the output of the boost unit. The terms ‘overdrive’, ‘distortion’ and ‘fuzz’ all refer to signal distortion caused by clipping. As noted above, overdrive typically refers to softer clipping. Effects units marketed as providing distortion and fuzz typically provide harder clipping and/or drive the clipping circuitry at relatively high amplitudes, so are likely to produce outputs which tend more towards square waves, with ‘fuzz’ often implying a more extreme effect than ‘distortion’. As well as introducing distortion the nonlinear transfer functions of clipping circuits (eg, the left side of Fig.1 and Fig.4) affect the dynamics (volume range) of the output signal. Soft clipping causes smaller signals to be amplified more than larger ones – a process known as compression. For a guitar player (for example) this causes sustain of the notes played. When a string is plucked on an instrument the volume decreases as the vibrations decay. If the gain of the signal increases with decreasing signal this output will tend to remain at a more constant volume than the signal directly from the instrument, resulting in longer lasting notes. This relates to something like the situation in Fig.1, assuming the sinewave shown is around the typical maximum amplitude of a note. In this situation, only the loudest parts of the sound will be distorted. If even relatively quiet notes result in the more extreme clipping like that shown in Fig.2 then there will be relatively little change in output volume for different inputs. As discussed in depth in the previous article, distortion changes the frequency content of a signal by adding harmonics and (for other than sinewaves) other frequencies. To obtain a good sound from a distortion effect, filtering of the higher additional frequencies using a low-pass filter may be desirable. Also, using frequency-dependent circuitry, distortion can be applied differently at different frequencies. Many distortion units have some form of tone controls (filters) which can adjust the sound, along with the amount of distortion applied. Diode characteristics Clipping circuits are essentially amplitude (or voltage) limiters. Diodes are well known for having a near constant voltage across them for a wide range of currents and therefore naturally act as voltage limiters. We can make distortion (clipping) circuits using diodes instead of forcing a full amplifier into saturation. Diode clipping is the basis of many, but not all, distortion effects units. We can plot the current against voltage (IV) characteristic of diodes using a DC sweep in LTspice – for Practical Electronics | August | 2022 Fig.5. LTspice circuit to obtain diode IV characteristics. example, using the setup shown in Fig.5. Here we investigate the IV curves of a very commonly used silicon diode, the 1N4148 and also a germanium diode, the OA91. Germanium diodes were widely used before silicon versions replaced them in most application. Silicon diodes have much higher performance in terms of reverse leakage, maximum reverse voltage, stability, maximum operating temperature and cost. However, germanium diodes still have some niche uses and one of them is in distortion circuits. The OA91 was somewhat arbitrarily selected as an example to use here because the model was found after a quick online search. The current set of diode models provided with LTspice does not include any with type=germanium. The .model statement is shown in Fig.5. Fig.6 shows the results from the simulation in Fig.5. There are two key points. First, the germanium diode conducts at a lower voltage than the silicon one – at around 0.2-0.3V rather than 0.6-0.7V. Second, the germanium diode has a less abrupt rise in current as forward voltage increases – this will equate to a softer response when the diode is used in a clipping circuit. Distortion effects circuits Fig.7 shows the block diagram of a basic distortion effects unit. This is more of a concept illustration of what happens along the signal path rather than the true schematic structure as the functions may be combined in some implementations. It is also common to have a bypass switch to route the signal past the whole effects circuit to allow the player to switch the effect on and off when needed (not shown). More complex units may have more complex signal paths; for example, to select or mix different distortion effects. The signal path in Fig.7 starts with a buffer which provides the correct input conditions for the intended source (eg, electric guitar pickup). It may include some filtering, for example to remove very high frequencies such as radio interference. The gain stage is a variable gain amplifier which drives the clipping circuit. As discussed above, and shown in Fig.1 and Fig.2, the signal amplitude into a clipping circuit affects the amount of distortion produced – thus varying the gain varies the amount of distortion for a given input. The clipping stage is a nonlinear circuit with a limiting transfer function (as in Fig.1 and Fig.4). It may be hard or soft, symmetrical, or asymmetrical, or have switches selecting different options, or controls to adjust factors such as asymmetry. The input buffer function may be provided by the same amplifier as the gain stage – it is not necessarily a separate amplifier. After the clipping stage we have our distorted signal, but its amplitude may need adjusting to be suitable for the destination (amplifier input, or next effects unit in a chain) – this is provided by the output buffer in Fig.7. Some distortion effects also feature tone adjustment – typically a filter to cut high frequencies by a variable amount. In some designs the output stage may not include an active amplifier, and level and tone adjustment may be part of the clipping circuit. Diode clipping The circuit shown in Fig.8 is a typical diode clipping circuit used for distortion effects. Not all components are used in all versions and variants exist. The input (typically from a variable gain amplifier, which sets the distortion level) is coupled Fig.8. Diode clipping circuit. In C1 R1 D1 D2 C2 R2 Level Out Fig.6. IV characteristics for a silicon (green) and a germanium (red) diode. Buffer Gain Clipping Buffer In Out Distortion Fig.7. Block diagram of distortion effects unit. Practical Electronics | August | 2022 Level Tone Fig.9. LTspice schematic for simulating the diode clipping circuit with two different diodes. 67 to the left. LEDs have forward voltages in the range 1.2 to 4V, depending on the colour. R1 limits the current in the diodes, and R1, R2 and C2 form a low-pass filter which can be used to remove the higher harmonics from the distorted waveform. Potentiometer R2 allows a proportion of the diode signal to be output, providing level adjustment. This can be directly used as the output or passed to an amplifier circuit which may have a tone control. R1 and R2 are typically a few kilohms and C2 is typically a few nanofarads. Simulation example The circuit in Fig.9 is an LTspice version of Fig.8 without lowpass capacitor C2. This is so that the full effect of the diodes on the harmonic content can be observed. The input coupling capacitor (C1) is also not included – it is not needed with an ideal signal source, and specifically in Fig.8 we need DC coupling to obtain the transfer function. The results in Fig.10 show that the transfer function is similar to the soft function in Fig.1, with the germanium diode circuit having a softer response. If we change the voltage source in the circuit in Fig.9 to produce a sinewave and run a transient simulation instead of a DC sweep: V1 source: SINE(0 1.5 500) Fig.10. Simulation results from the circuit in Fig.9 – the transfer functions of the clipping circuit with different diodes (top: silicon, bottom: germanium). via capacitor C1, which removes any DC offset, prevents the diodes from disrupting the bias of the amplifier stage (where applicable), and reduces gain at low frequencies. C1 is typically a few microfarads. The maximum output signal is limited by (clipped) at the forward voltages of the diodes (D1 and D2). Two diodes are used to cover the positive and negative half cycles of the waveform. Asymmetrical clipping can be achieved by using different types of diode for D1 and D2, or by using a different number of diodes in series in each direction. Diode options are standard silicon didoes, Schottky diodes, germanium diodes and LEDs. Silicon and germanium diodes were compared above. Schottky diodes have a similar characteristic shape to silicon, but a lower forward voltage – closer to germanium at around 0.2V – this is like shifting the silicon curve in Fig.6 Simulation command: .tran 0 50m 0 10n We get the results shown in Fig.11, which shows that the silicon diodes result in harder clipping (or a more square-wave shape) than the germanium diodes. The results from the transient simulation can be used to obtain spectra of the output signals using the LTspice FFT function (taking account of the requirements for doing this effectively, which were discussed in detail last month). The results are shown in Fig.12; using a linear frequency plot here makes it easier to see which harmonic is which. They show that both circuits add odd harmonics, but not even ones. The relative levels of different harmonics are different for the two types of diode. The difference in harmonic content will result in different effects on note timbre – implementing the circuit with different diodes will sound different. In order to make the spectra easier to compare they have been normalised so that the fundamental (input sine frequency of 500Hz) is at 0dB in both cases. This was done by measuring the fundamental peak on the initial result and calculating the scaling factor required to shift up to 0dB. The scaled signal was then plotted. For example, initially the fundamental peak of the silicon circuit was at −6.34dB. The scaling required is 1/10−6.34/20 = 2.075, so the trace was edited to become 2.075*V(outsi) – right click the trace title to do this. Listening test Given that we are discussing sound processing circuits, it would be useful to be able to listen to the results. Of course, ultimately, we’d want to do listening tests on a real circuit if we were actually developing a distortion effects unit. However, just for fun, or for quickly investigating a range of possible circuits, LTspice can provide listening opportunities via WAV files. For example, you can use a short recoding of (say) a note from a guitar as the input, and listen to the simulated results. We discussed WAV files in detail in July 2020, so we will be briefer here. For input, change the ‘value’ of an LTspice source to the form: wavefile=filename Fig.11. Transient simulation results for a sinewave input to the diode clipping circuit with different diodes (top: silicon, bottom: germanium). 68 Where filename is the name of a WAV file in the same folder as the schematic, or the full path to the file if it is elsewhere. By Practical Electronics | August | 2022 measure the peak level so the scaling can be set appropriately. The circuit in Fig.13 is a version of Fig.9 configured for WAV input and output. This was tested using a guitar sample found online (freewavesamples.com) – the change in timbre of the output and the difference between the two diode types could be heard. Other circuits Fig.12. Spectra of the signals from Fig.11 (top: silicon, bottom: germanium). default, the signal used will be the first channel in the WAV file (typically there are two channels for stereo). To write a WAV file you need to place an LTspice .wave directive on the schematic. For audio signals it is best to configure this to a standard format such as stereo 16-bit 44.1 kHz (as used for CDs). For example, to output voltage out1 to both stereo channels in file output1.wav use: .wave output1.wav 16 44.1K V(out1) V(out1) One key issue is that the WAV file maximum amplitude is 1V. We typically have to scale both the input and outputs to fit with the circuit amplitudes. This is straightforward to do using behavioural sources, but for the output an initial simulation will often be required to The diode clipping circuit discussed here is not the only circuit that can be used. Another common approach is to use diodes in the feedback of an op amp amplifier – this is similar to the logarithmic amplifiers discussed in December 2021. A typical configuration is shown in Fig.14, but as before there are variants of this circuit. In this circuit, R1 and R2 set the gain for AC signals as a conventional non-inverting amplifier (gains of 10s to 100s are typical), but C2 blocks DC giving 100% feedback and hence unity gain for DC (not in all variants). The diodes limit the output amplitude to cause clipping. As before, different diodes, or numbers of diodes, can be used for asymmetry. R2 is typically a variable resistor – changing the gain controls the amount of distortion. C1 is typically a small capacitor to reduce gain at high frequencies to reduce the chance of instability. The shape of the transfer function of this circuit is a little different from the diode clipper discussed above, so it will sound different. Some distortion pedals combine both circuits. The Nutube Guitar Overdrive and Distortion Pedal by John Clarke (PE, March 2021) uses a different approach – by driving an amplifier into clipping rather than using diodes. The amplifier is a common-cathode stage built using the Nutube low-voltage triode. Asymmetric clipping is achieved by varying the DC bias of the input. R2 C1 D1 D2 – In U1 Out + R1 C2 Fig.13. LTspice schematic for simulating the diode clipping circuit with WAV file input and output. Practical Electronics | August | 2022 Fig.14. Op amp-based distortion circuit. 69