Silicon ChipCircuit Surgery - September 2021 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions: PicoLog Cloud
  5. Back Issues: PICOLOG
  6. Publisher's Letter
  7. Feature: The Fox Report by Barry Fox
  8. Feature: Techno Talk by Mark Nelson
  9. Feature: Net Work by Alan Winstanley
  10. Project: USB SUPERCODEC by Phil Prosser
  11. Project: USB Supercodec by Andrew Woodfield
  12. Project: High-power Ultrasonic Cleaner Part 1 by John Clarke
  13. Project: Night Keeper Lighthouse by Andrew Woodfield
  14. Feature: AUDIO OUT by Jake Rothman
  15. Feature: Max’s Cool Beans by Max the Magnificent
  16. Feature: Flowcode Graphia I Programming by Martin Whitlock
  17. Feature: PIC n’Mix by Mike Hibbett
  18. Feature: Practically Speaking by Jake Rothman
  19. Feature: Circuit Surgery by Ian Bell
  20. PCB Order Form
  21. Advertising Index

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

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

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Circuit Surgery Regular clinic by Ian Bell Multistage log amplifiers for RF power measurement T he August edition of PE featured a low-cost wideband digital RF Power Meter by Jim Rowe. This is based around the AD8318 1MHz to 8GHz, 70dB Logarithmic Detector/ Controller IC from Analog Devices. The project uses a modified version of a prebuilt module, but essentially the key analogue functionality of the project is based on the AD8318 IC. These pre-built modules are a great way of using a large range of advanced ICs without having to worry about the difficulties of designing a PCB and soldering the often very small surface mount devices needed for an optimum layout. In the project, instrument functionality is provided by software running on an Arduino Nano, which receives a digitised version of the AD8318’s output via an LTC2400 DAC. The article provides a brief description of the AD8318, but there is insufficient space to go into its principles of operation in much depth, so that is the topic of this month’s Circuit Surgery. We will explain the basics of how this class of ICs work (Analog Devices produce several devices based on similar principles, not just the AD8318), illustrating the theory with some idealised LTspice simulations based on behavioural sources. Before getting into how the AD8318 works, it is worth discussing RF power measurement in general, as there are some potential points of confusion. Signal power measurement An electrical signal producing a voltage V across, and a current I through a load delivers instantaneous power of P = VI to the load. If the load is a resistance of value R we can also express the power as P = V2/R or P = I2R by substituting for I or V using Ohm’s law (V = IR, I = V/R). So, if we know R, then we can obtain power values 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. 62 just by measuring voltage (or current). In RF systems the signal path is usually matched to a specific impedance (for example 50 ) so it is possible to obtain signal power from voltage measurements. This is the assumption used in the RF Power Meter project, which has a nominal input impedance of 50 . The power dissipated in a resistor driven by a signal such as a sinewave varies from instant to instant in accordance with the equations given above; however, we often need to know the average power over a period of time (at least one cycle). This applies to signal strength indicators (eg, on your mobile phone), or instrumentation such as the RF Power Meter project, but also in the internal circuitry of radio systems. For example, received radio signal strength varies considerably and it is often necessary to adjust the gain of parts of the system to accommodate this (AGC, or automatic gain control) – this requires accurate signal strength measurement. As discussed, with a fixed/assumed load we can obtain power from voltage, but finding average power for an AC signal is not simply a matter of taking the average voltage or current – it is zero for a sinewave over any whole number of cycles. The heating effect produced in a resistor forms the basis of how we define power for non-DC signals – AC power is equal to the DC power which would produce the same heating effect in a resistor. For a fixed R, this can be obtained by averaging V2 over time (P = V2/R). If we take the square root of the average of V2 we get a value called the ‘Root Mean Square’ (RMS) voltage – this is the DC voltage, which, if applied across the load, would result in the same power dissipation as that produced by our AC signal. For a cyclic waveform of fixed shape (eg, sine, triangle and square) there is a fixed relationship between the peak voltage and the RMS value, which is known as the crest factor. Mathematically, this can be obtained by integrating the square of the waveform function over one cycle, but of course the results are well known for common waveforms. For a sinewave Vpeak = 2 × VRMS = 1.4142VRMS (the crest (C) factor is 1.4142). The crest factor for a triangle wave is: C = 3 = 1.7321, and for a square wave, C = 1. These values apply to waveforms which are undistorted and symmetrical about 0V. If we know or assume the waveform shape and have a fixed, known load resistance it follows that we can obtain power from a measurement of peak voltage (or average peak voltage over multiple cycles). The average power is V 2RMS/R – which can be found from the average peak voltage by an appropriate scaling obtained from R and the crest factor. However, if the waveform is of arbitrary shape and we need a ‘true RMS’ measurement then the process is more complex. The AD8318 IC, and hence the RF Power Meter project on which it is based, do not measure true RMS. Decibels Power in RF systems is typically expressed in dBm units – this is power in decibels (dB) referenced to 1mW – this is the measurement unit used by the RF Power Meter project. The decibel is based on the logarithm of the power ratio of two signals (say P1 and P2). If we are interested in gain or attenuation (input-output relationship) then the two signals are obviously the input and output. However, to use decibel units for expressing the power of an individual signals one of the power values must be a fixed reference, and the units are written to express this (eg, dBm for 1mW reference and dBW for 1W reference). Decibels are useful because their logarithmic nature means very large ranges of power levels are compressed into a small range of decibels values. An instrument, such as the RF Power Meter which responds directly to the decibel signal level is able to handle a very wide range of signal power. Using decibels on graph scales allows details to be seen at both large and small signals levels (the small level details would be lost on a linear graph). When considering signal paths, expressing gain and attenuation in decibels makes calculations Practical Electronics | September | 2021 – which is exactly what is provided by the AD8318 and various other similar devices. Responding to the peak means that the output tracks the log of the envelope of the input waveform amplitude. This is similar to the process of detection or demodulation in AM radio receivers, so these types of circuit are referred to as detecting or demodulating logarithmic amplifiers. A=4 A = 20 Piecewise log amplifiers There is more than one way to make a circuit with a logarithmic response. A common approach for DC or low frequencies is to use the exponential current-voltage relationship of a diode or transistor in an op amp feedback loop. However, for high frequencies such as those targeted by the AD8318 a piecewiselinear approximation is often used instead. The circuit has a gain which varies over segments of the input range and so appears as a series of straight-line segments when the input-output relationship is plotted. This is illustrated in Fig.1, where the piecewise-linear approximation is the set of solid blue lines, which closely approximates the true logarithmic function shown by the dashed red line. The piecewise response in Fig.1 has its highest gain (× 84) for small inputs (the gain is the slope of the graph, so a steeper slope is a higher gain). At a certain point (about Vin = 16mV in Fig.1) the gain reduces from × 84 to × 20. This segment is longer than the first one, extending for about 47mV to Vin = 63mV. The third segment has an even lower gain of × 4 and covers a longer range again, up to about Vin = 250mV. Above this input voltage the output limits at a fixed 3V. The piecewise response in Fig.1 approximates the logarithmic function quite well over the range 3 to 300mV. For higher input voltages the saturated (fixed final output level) would deviate more and more from the log function as the input level and hence log of the input increased. For very small input voltages the log function would produce large negative values. A real circuit will only produce a log response over a limited range. The piecewise log response can be implemented by using a cascade of output-limited amplifiers with their outputs summed, as shown in Fig.2 A = 84 Fig.1. Piecewise-linear approximation (solid blue line) to a logarithmic (dashed red line) input-out relationship. straightforward – the multiplication of gain or attenuation stages is translated to addition or subtraction in the logarithmic world of the decibel. A power ratio in decibels is given by 10log 10(P 2/P 1) dB, where P 1 is the reference level (for example 1mW) and P2 is the value we are measuring. The term ‘decibel’ means one tenth (deci, hence d) of a bel (symbol B). One bel is log10(P2/P1), but as we use 10log10(P2/P1) we are counting in tenths of a bel. The bel is named after Alexander Graham Bell. We can also use decibels to express voltage levels. Given that P = V2/R, if we consider a power ratio involving the same R then P2/P1 = V22/V21 as both instances of R cancel in the ratio. If we square something inside a logarithm it is equivalent to multiplying the log by two (without the square). That is log(x2) = 2log(x). So, to express a voltage in decibels we use 20log10(V 2/V 1). Note that we are multiplying by 20, not by 10 as we did with the power ratio. Again, for signals levels rather than gains, we need to indicate the reference level (for example dBV is referenced to 1V). Demodulating log amplifiers for power measurement We can write an expression for the average power of a signal in terms of dBm, related to the RMS voltage of a signal (VRMS). Using P2 = V 2RMS/R and P1 = 1mW: PdBm = 10log10((Vpeak/C)2/R /1mW) For a sinewave into 50 and R = 50 we get: PdBm = 10log10(V2peak/2 × 50 × 0.001) = 10log10(V2peak/0.1) Dividing inside a logarithm is equivalent to subtraction of logs, so: PdBm = 10log10(V2peak) − 10log10(0.1) = 10log10(V2peak) − 10 Using voltage rather than its square: PdBm = 20log10(Vpeak) − 10 Thus, if we build a circuit with an input impedance of 50 that produces an output proportional to the logarithm of the peak value of the input signal we obtain an output voltage which is proportional to the power in dBm. There is an offset (10 in the above equation) which is easily accounted for in calibration. The crest factor just changes this offset, so calibration could be done for different fixed wave shapes. Similarly, the input impedance also changes the offset in the above equation, but for a real implementation this has to be correctly matched, which would usually be to the reference impedance. The key thing here is the logarithmic response to the peak input voltage PdBm = 10log10(V 2RMS/R /1mW) Note that R is not cancelled in this equation, so we should state the value used (for example, 50 ). For a fixed waveform with a known crest factor we have: Vpeak = C × VRMS, so: V 2RMS = (Vpeak/C)2 Practical Electronics | September | 2021 with C = 2 In p u t S ta g e 1 S ta g e 2 S ta g e 3 A A A S ta g e N A O u tp u t Fig.2. A cascade of N limiting amplifiers with summed outputs, which approximates a logarithmic response. 63 V in Z e r o g a in lim ite d a t V L V L G a in A 0 V L/ A V out Fig.3. Transfer function of a limiting amplifier with gain A and output limit VL. – this form of circuit structure is used in the AD8318. The amplifiers have gain A until the output reaches a limiting voltage (VL), above this the gain is zero. Inputs greater than or equal to VL/A produce an output limited at VL. The input-output relationship of the limiting amplifier is shown in Fig.3 – this is for positive inputs, for negative inputs the output limits at −VL. If a sufficiently small input signal is applied to the circuit in Fig.2 none of the amplifiers will limit and the gain to the final output will be AN, for example with three stages the gain is A × A × A = A3. The penultimate stage output has a gain of A(N−1), the one before that A(N−2), and so on. These outputs are summed; so, for example, the total output with three stages is (A3 + A2 + A)Vin. If A = 4 then the gain is (43 + 42 + 4)Vin = (64 + 16 + 4)Vin = 84Vin, the same as the first segment in Fig.1. If the input signal is increased to the point where the output of the penultimate amplifier is equal to V L then at this, and higher inputs, the final amplifier will limit. This occurs at ANVin = VL, or Vin = VL/AN, for example, with three stages, and VL = 1 at 1/64 = 16mV – the end of the first segment in Fig.1. Under these conditions the final amplifier will contribute a constant VL to the summed output. For three stages, the output will be (A2 + A)Vin + VL. If A = 4 and VL = 1 this segment will have the function 20Vin + 1, starting at Vin = 16mV, so Vout at this point is 20 × 0.016 + 1 = 1.3V, as seen on Fig.1. The next segment occurs when the penultimate amplifier limits at A(N−1)Vin = VL. For three stages, the second amplifier limits at VL/A2, which for A = 4 and VL = 1 is at Vin = 1/16 = 63 mV – the end of the second segment in Fig.1. In this segment the last two amplifiers are contributing a constant VL to the output. For three stages this will be AVin + 2VL. For A = 4 and VL = 1 this (third) segment will have the function 4Vin + 2, starting at Vin = 63mV, so Vout at this point is 4 × 0.063 + 2 = 2.3V, as seen on Fig.1. 64 Fig.4. LTspice behavioural simulation of a summed cascade of limiting amplifiers. With a sufficiently large input (Vin > VL/A) the first amplifier, and all the others in the cascade, will limit and the summed output will limit at NVL. For our example, with N = 3, A = 4 and VL = 1 this occurs at Vin = 1/4 = 250 mV. Above this input voltage, the output is constant at 3VL = 3V. Again, this is seen in Fig.1. The preceding discussion has shown that the circuit in Fig.2 can produce the piecewise approximation to a log function shown in Fig.1. This example used just three stages, which is sufficient for illustration, but much better performance can be obtained with more stages – the AD8318 has nine. LTspice Behavioural Simulation We can simulate an idealised version of the amplifier cascade in LTspice using behavioural sources. These are voltage or current sources for which we can write equations – the output of the source can be expressed as a mathematical function of other voltages and currents in the circuit, time and the constant π. For example, we can model an amplifier with gain 4 by using Fig.5. Simulation results for the circuit in Fig.4. Practical Electronics | September | 2021 Fig.7 Diode envelope detector circuit (part of the LTspice schematic). showing the sinewave signal clipping as Bamp3 goes into limit. Fig.6. Zoom-in on two of the signals in Fig.5. Envelope Detector The circuit described so far has a logarithmic gain response but does not do all we need to implement the RF Power Meter – specifically, it just amplifies the input signal, it does not output a voltage equal to the peak value. A simple way to obtain the peak (but not that used by the AD8318) is to use a half-wave rectifier and RC filter – a diode detector, or envelope demodulator, often associated with basic AM radio circuits. To do this, the circuit in Fig.7 is added to the schematic in Fig.4 (Fig.7 only shows the detector, the rest of the schematic is the same as Fig.4). The diode is idealised – it has zero forwardvoltage drop. The simulation results with the detector are shown in Fig.8, in which V(out) is the same as in Fig.5. The output voltage V(det) follows the envelop of the V(out) waveform, which due to the linear input amplitude sweep, is close to the piecewise linear curve in Fig.1. There is some ripple on the detected output as the RC filter does not provide perfect smoothing of the envelope. Fig.8. Simulation results for the circuit in Fig.7 – V(det) follows the envelope of V(o u t). a behavioural source with the equation V=4*V(in). The output of the source will be four times the voltage on node in. To create a limiting amplifier, we can use the limit function. The output from LTspice function limit(x,min,max) is x if x is between min and max, otherwise it limits to either min or max, depending on which value is exceeded. We can use V=limit(4*V(in),-1,1) to produce an amplifier of gain 4, limiting its output to ±1V, as used in the previous discussion. The LTspice schematic in Fig.4 has three such amplifiers (Bamp1, Bamp2 and Bamp3) cascaded (eg, the output of B a m p 1 is on node o u t 1 , which is the input to Bamp2). Another behavioural source (Bsum) is used to add the three outputs from the amplifier together. To see the response of the circuit we create a 1GHz sinewave input signal which increases in amplitude linearly from 0V to 300mV (the same input range as in Fig.1) in 200ns. The results of the simulation are shown in Fig.5. The simulation is over so many cycles of the 1GHz sine wave that the waveform detail cannot be shown – the plots show blocks of colour, with the shape of the blocks following the envelope of the signal amplitude. As the input (V(in)) increases the three Practical Electronics | September | 2021 amplifiers limit in turn (the final amplifier output V(out3) limits first). We see their output amplitudes increase linearly until the 1V limit is reached in each case. The summed output envelope (v(out)) follows the shape of the piecewise curve in Fig.1. Fig.5 is a zoom-in of the first part of the V(out3) and V(out) waveforms V IN g m S ta g e 1 S ta g e 2 S ta g e 3 A A A g m g m S ta g e N A g m g m IO U T Fig.9. Using transconductance amplifiers to sum the amplifier cascade outputs. Fig.10. Absolute value transconductance, current summing and filtering circuit (part of the LTspice schematic). 65 Fig.11. Simulation result from the circuit in Fig.10. Transconductance Amplifiers Summing voltages directly is relatively difficult and the half-wave diode detector does not provide very high performance – real diodes may have too large a voltage drop to be used directly on low-level signals. There are better approaches to addition and detection. Addition of signals is easily achieved using currents – simply connect all the current outputs together. This can be done using the version of the circuit in Fig.2 shown in Fig.9. The output of each amplifier in the cascade is fed to a transconductance amplifier (gain gm). Transconductance amplifiers have an input of voltage and an output of current. The transconductance amplifier outputs are connected together to sum the currents. To achieve detection the transconductance amplifi ers can have an absolute value characteristic (both positive and negative inputs give positive outputs), or a squarelaw characteristic (the square of both positive and negative values is positive). The current output can be converted to a voltage by passing it through a resistor and then a low-pass filter to provide a signal related to the amplitude envelope. Fig.12. Plot of V(det) from Fig.11 vs the logarithm of the peak input voltage. Your best bet since MAPLIN Chock-a-Block with Stock Visit: www.cricklewoodelectronics.com O r p h o n e o u r f r i e n d l y kn o w l e d g e a b l e st a f f o n 020 8452 0161 Components • Audio • Video • Connectors • Cables Arduino • Test Equipment etc, etc Visit our Shop, Call or Buy online at: www.cricklewoodelectronics.com 020 8452 0161 66 Visit our shop at: 40-42 Cricklewood Broadway London NW2 3ET The circuit in Fig.10 is a version of the circuit in Fig.9 in LTspice using behavioural current sources to implement transconductance amplifiers with an absolute function. Each current source has function I=100e-6*abs(v(out3)) – note the use of abs(). The gain is gm = 100µA/V. The rest of this schematic is the same as Fig.4, but without the Bsum source as this function is replaced by the circuit in Fig.9. The current sources are paralleled to sum the currents and a constant current is added to provide positive offset when transconductance amplifier outputs are zero. The current is fed to an RC circuit to convert it to a voltage and provide low-pass filtering. The simulation result for the circuit in Fig.10 are shown in Fig.11 – this is just the V(det) signal, the V(in) and V(out1), V(out2) and V(out3) are the same as in Fig.5. The negative slope of the V(det) response is like the response of the AD8318. To verify this is a log function, Fig.12 shows V(det) plotted against the log of the peak of V(in). This was obtained by exporting the LTspice data to Excel. Fig.12 shows a more or less linear negativeslope relationship between the V(det) and the log of the peak input voltage, which corresponds with the AD8318 response (Fig.2 in the RF Power Meter article). As already noted, the LTspice circuit, although idealised, is a crude implementation as it only uses three stages rather than the nine in the AD8318. Various other details do not match exactly, but this example is sufficient to illustrate the basic principles of operation. Readers interested in knowing more of the specifics of how these devices operate should read the AD8318 datasheet and also the AD8307 datasheet, which is a logarithmic amplifier based on similar principles – the datasheet for AD8307 provides more details on the theory of operation. Practical Electronics | September | 2021