Electronics - Peak detector circuits and models

 
19-03-2016, Changed; 05/06/2025 - 04/06/2025

Modelling tools used;

  • Tina-TI 9 or Tina, SiMetrix 9.20, and LT Spice 24, the LTspice support group, is good, the CAD is free, unrestricted and claims to model faster and better than other tools.  The other tools are the free versions.  SiMetrix is the easiest but LTspice is the most comprehensive.  They produce similar results, but of course, they do not model circuit board parasitic components unless parts are added to represent the PCB parasitic components.  Therefore, take care with the results and ensure you figure out what you want and what you expect before you start any modelling. 
  • By comparison, obviously, there are some points you can not test directly on a real circuit because the test probe will affect the circuit, such as the output of low-power, low-speed op-amps, and the high impedance part of fast circuits.  An oscilloscope probe's capacitance is usually 10pF (x10) or 100pF (x1).  Consequently, the model will let you see points in the circuit that you can not accurately probe, but take care to not become overconfident in the circuit reproducibility because the model results are good. 
See; http://www.andrew-lohmann.me.uk/engineer/electronics/electronics-simulation-judgement


Tina-TI 9 conventional peak detector;

Tina-TI is now quite old, but it works well enough, though the graphical entry is poor and can leave warnings and errors.  You can download Tina-TI, and TI still offer models for it; you must use at least one Texas Instrument part in your design.  Or use the Tina Simulator is also available; the free version has a design size limit. 


AL-0020-03H LTSpice & AL-0018-01C Tina-TI conventional peak detector circuit and a variant of a conventional circuit.  The circuits have differences that may or may not improve them; the gain is 11. 

The feedback capacitor and output series need to be set for best speed and to just undershoot.  That can be avoided; see the circuits below, which don't include these parts requiring optimal tuning.   A fast rail-to-rail I/O op-amp has been chosen, but a TSV494 would also be a good choice.  D1 speeds up the switch by limiting the op-amps' output swing.
 
The above circuit has with +-25mV peak-peak 100Hz square wave input. Gain x10.
  • The op-amp gain bandwidth product is 50MHz, will at best could give a circuit accuracy of;
  • At 1KHz, gain of 10;  50MHz/1KHz/10 = 5000:1
  • The actual performance is not as good as this.  I have found that a big margin is required with a peak detector. 
  • Peak detectors do not work as well as the gain-bandwidth product arithmetic suggests; the best strategy is to use a faster op-amp. 
The above circuit has a +-150mV pk-pk 100Hz square wave input. The gain is x10. Same waveform as above, but zoomed in.

 It can be seen that the circuit continues to work well with a big signal.
The circuit now does not work well with just +-250uV 100Hz. Gain x10 zoomed in.

The short spike is where the work of peak detection was done.  It is not possible to correct the overshoot without compromising something else.  The overshoot in any case is trivial <1%. 

------------------------------------------------------------------------------------------

 SiMetrix - the circuit above is refined and modelled with a similar tool. 


You will need to reinstall some added parts if you move a design to another PC.  In this case, copy and drop the BAV199 diode and OPA365 op-amp into SiMetrix.  I changed the circuit to use because it is a rail-rail i/o low Ib part.

AL-0017-01F This is a conventional peak detector, but after simulating using SiMetrix but C2 has been removed.  The circuit does not work well down to 10 mV peak to peak, though it is better than the circuit further above.



AL-0017-01F 1V peak-peak 100Hz.

AL-0017-01F 10mV peak-peak 100Hz.  The first cycle has overshot, so capacitors around the op-amp need to be added or changed.

The circuit appears to be consistent to <1mV with an offset within the tolerance of the operational amplifier in this case, 8mV.  This is a model, and C1 may be too small when real circuit board parasitic capacitance's are included.  This circuit is improved further for small signals if R1 is reduced to 470K - the first waveform shows the problem.
 
An output buffer is not shown fitting, but it may be too many parts for this free version of the modelling tool to include it.  In any case, circuits to be modelled should be kept to the critical part of the function that requires modelling in order for the modelling to be completed in good time.

The circuit is now quite good for this type of circuit.  The circuit is probably good enough if the input slew rate, bandwidth is limited.  But increasing the rise and fall time from 50u/s to 500u/s has only a small benefit. 
 AL-0017-05B This could be better or worse because the gain is not 1+feedback as in the previous circuit, but -feedback factor solely.  That is the rise time is limited by R1, R2 and C1 a little more. 

AL-0017-05B 2V peak to peak - peak has 4mV ripple.

AL-0017-05B 10 mV peak to peak - peak has 250 uV ripple.

There is always value in having a theory, but a theory will be difficult to write or say until it answers enough questions and the engineer's mind is clearer about what is happening.  But it is necessary to use your feeling for a design and to find a way to express what you have found in imprecise words like, reckon and as-if.  Do say and ask someone, I do understand, but please help me express it in a better way.
 
---------------------------------------

Tina TI - Putting two peak detectors together to record the greater of  positive and negative peak detectors.  

See separate page, Pos Neg Peak detector circuits and models
 
AL-0018-05A, but the output series resistor R5 is 220R instead of 10R (AL-0018-02K).
The peak detector now works better and is slightly over-damped, so there is no overshoot when R5 (was R3 and R5) is increased in value from 10R to 220R.  There is little difference between this graph and AL-0018-06A, which I have not included. 
 
AL-0018-05A and AL-0018-06A The greater of the positive or negative peaks detector
The circuit shares one hold capacitor, but there is no interaction between the two peak detectors.  As before, I have not included capacitors across D2 and D4, but it is reasonable to place do-not-fit parts on a PCB so that they could be fitted subsequently? C1, C2, R2, R3, D1 and D3 can be omitted if faster op-amps are used (see version -05A).

Many variations have been tested, and version -02K works well, but for the little overshoot.  That overshoot has been reduced by increasing R5. 

There is an unresolved fault in this model when the input is increased from 20 mV to 25 mV, which causes the output voltage to increase greatly.  Looking at earlier graphs at 25 mV input, but with different R5, the circuit did work, so it may be that this op-amp does not work well when overdriven. 
 
+-250uV 100Hz Zoomed in.  Circuit gain is 30


The combined output is different to a peak to peak detector shown right, which requires a greater supply voltage. 

AL-0017-08B peak-peak detector.  This circuit is too big to model on this free simulator.  The outputs would be summed using an instrumentation amplifier, which need not be included in this model. Instrumentation Amplifiers generally need a greater supply voltage, which is explained well in a graph in their data sheet. 
AL-0018-05A, +-2.5mV 100Hz input x30 - Zoomed in
 
The amplifier offset voltage would be apparent in the real circuit, but I have not added an offset mismatch to this model.  The .step function in LTspice could handle that, for example.
AL-0018-05A, +-20mV 100Hz square wave input - Zoomed in. Gain is about x30 as above.

With increased R5 to 220R, the simulation does not work at +-25mV square wave input.  The waveform has the same parameters as the first in this set.  The new -02 version's output is nearly 2V rather than 750mV, it should be. 

AL-0018-02K old version with R5=10R overshoots a little, but now the simulation works at +-25mV
This is almost an identical circuit and works well enough.  This earlier final version before I reviewed the blog. 
  • Brown - peak detector 1 op-amp.
  • Green-ish - peak detector 2 op-amp.  The consequence of a little offset error voltage means this side is not doing so much work.
  • Green - Peaks output.
-----------------------------------------------------

Mean peak detector or mean rectified signal

These are good what is required to process a capacitance moisture sensor. 
Traditional precision rectifier
A smoothing capacitor should be fitted across R5

Below, R1 C3 represent a humidity sensor. Although the part values are arbitrary.
HIH6030-021-001 <£10, SPI or I2C output.
246-5637 RS stock number < £2.50 capacitive element. 1V peak sine wave, 1KHz, impedance 6M to 2K for 20 to 95% humidity at 25'C.
HS1101LF TE, <£8.50, 10V peak sine wave, 0.31pf/1%RH (31pF). 180pF at 55%RH. 10KHz (5KHz - 300KHz)
   



 
 AL-0056-01A I have used the calculator link below.  From that calculator, the circuit 
does not require compensation D1 and D2, but the Spice model shows that they are required.  There is a 100mS delay to show steady state conditions before the oscillator starts. 

 
AL-0056-01A, D3 & D8 form a voltage-doubling rectifier.  This circuit will have temperature and voltage offset with a temperature coefficient, which could be mitigated by running with a higher signal voltage.  This circuit will be non-linear rather than a true mean measurement if the signal were spiky, which would matter. 

£20, 1970s Mulimeter's lowest ranges are 250mV DC, 1.5V AC at 50K ohms/V DC and 10K ohms/V AC.  You can see that the red AC Voltage scale is only slightly non-linear compared to the black DC ranges.  The movement is therefore <20uA, I think it is about 15uA and <<250mV?

The multimeter's movement is protected by two diodes connected in anti-parallel, but somehow the forward current does not affect the voltage measurement accuracy?  The answer is probably that particularly low-leakage germanium diodes were used in the multimeter's rectifier, but silicon diodes were used for the multimeter's protection. 

This circuit should work well as a capacitance measurement, such as a humidity sensor in series with C2.  C2 is required to block DC leakage current.  R1 is required to make the simulator work and to ensure there is no DC bias across the sensor.  This simulation contradicts the calculator result or what I observe in my moving coil multimeter, which has a lowest AC Volts range of 1.5V; the scale is only slightly non-linear.
 
 
AL-0057-01A, AL-0057-02A, and AL-0057-03A 
Diode versus Schottky diode rectifier, with differential output.  The operating current is higher because the Schottky diodes have higher leakage current.  The amplifier gain is about 30, and the steps are 10%, 50% and 95% humidity.

The output would be connected to an instrumentation amplifier, but the circuit has now become ridiculously big and performs poorly because of the high and variable diode voltage drop.  The voltage drop is 550mV or 250 mV for regular or Schottky diodes.  One of the op-amp solutions would be better if the model is correct, but the diode calculators are wrong. 

1PS66SB82; 1PS88SB82 Schottkey diode has a better reverse leakage of 3uA 85 °C than many others.  But the operating current needed to be high so that the circuit accuracy would not be too compromised.  Adding this part and using an existing symbol is more complicated than using automatically generated symbols.
  • Create the .include with the model file path.  The '.' makes it a spice directive rather than a text comment.
  • Select a part from the library and ALT-right-click.  Not right click, which lets you change the part to another in the built-in library, but so you can use a standard symbol with a new part.
  • Change; prefix to 'X', and change the value to the exact model name, such as '1PS66SB82'.  That name is in the file, which is a text file that may have many part definitions. 
  • Finally, check that the symbol pin out is correct or try again, but use an automatically generated symbol; they are usually correct. 
Many spice models from different manufacturers work in many simulation tools such as LTspice. 

----------------------------------------------------

What can be concluded?

Almost certainly, different combinations of things shown could improve these circuits further.  The capacitive coupling directly to the peak detectors was not a good move for large signals - this is probably something to do with the op-amps, with the diodes not drawing current in a symmetrical way when the signal is too large.  But inversion or gain in the peak detector is a good move, whether I have figured out quite why that is so yet, and that does need to be figured out.  But there is some point where refinement is enough, and the designer must stop and move on to the next problem.  That is the hardest thing to do.

The TED talk linked below is interesting.  The speaker discusses how it is necessary to be open to trying many things (procrastinate, he says) to be a successful original thinker.  I think the speaker is coming at Temperament (that I discuss on my website), but in another way. 



No comments:

Post a Comment