Peak detector design - Page 1
Forum section: electronics / projects

author: Oaklander
author_rank: Regular Contributor
timestamp: May 06, 2018, 06:41:13 pm
content: I've been designing a peak detector. It must detect a pulse between 0 and 5 volts which is about 1-2 microseconds long. My design is in the attached picture. I've simulated it in LTSpice and it works quite well. However I have some questions.1. The output of the peak detector is always about 10% higher than the highest peak at input. Why?2. How should I select the diodes and the MOSFET to reset the capacitor? What are the properties to consider?3. How is the negative power supply usually made? I've found inverting switching regulators and they seem to do the job but what other options do I have? A center tapped transformer is not possible.4. Is there anything wrong in my design?

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 06, 2018, 07:34:26 pm
content: 1. Are you certain it's a proportional factor and not just an offset? Those op amps have relatively high input offset.3. You may not need a negative supply if you use a single supply op amp with rail-to-rail input AND output with ultra low offset. You could try the AD8628. Its slew rate is limited but it may be enough. Otherwise just look for faster op amps with similar characteristics.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 06, 2018, 07:37:20 pm
content: 1. Consider the effect of capacitive loading on op-amp output causing oscillation.Opamps are not perfectly fast (that much is obvious -- an infinite-gain block in any real physical circuit would oscillate at lord knows how many frequencies!). Consider further, the effect of anintegratorin the circuit. The output rate is proportional to the input voltage. Since the capacitor cannot be charged instantly, it takes time to get there; and it takes input voltage to get there too, so you must end up with some loss.But you're not getting loss, you're getting overshoot? Ah well, opamps aren't perfect integrators either, they have higher order effects, and finite output impedance. So the capacitor can't even be charged at the same rate as the integrator integrates. In the feedback loop, excess input voltage occurs, and then the output swings past, overshooting the target. It soon settles down, but the diodes prevent this.The outcome is, you simply need an opamp that much faster, so that its integrating behavior (and higher order effects) are able to follow the input signal accurately. You might need an opamp GBW of 100MHz to get within a few percent of nominal. The error is rate-dependent, so anything you can do to a. calibrate out the error (when it's consistent) and b. make the input pulses more consistent between themselves, is a bonus to your overall accuracy.2. Nothing very critical, 1N4148 or BAT54 or etc. would be fine. I suppose something ideally matched to the application would be on the order of 30V, 20mA, under a few pF, and low leakage, but you can only find boutique RF diodes with those specs, and something like a 1N4148 handily meets or exceeds most of those criteria.Likewise for the FET, 2N7002 or BSS138 would be the default go-to, but if you need better performance (lower stray capacitance, lower charge injection, etc.), something like RUM001L02T2CL might be better (I recommend it as a jellybean replacement for 2N7002, better suited to modern lower voltage circuitry). Or just use an open-drain logic gate, like 74HC07 (as many outputs wired in parallel to get the discharge speed you want, or use a single- or few-gate 74HC1G07 or the like to save on area).You could also use a diode to turn a full (active driven) logic signal into a faked open-drain signal. If you don't mind the voltage drop, that is. Diodes can behave more simply than MOSFETs, so it can be a worthwhile change. Though unlikely to be a problem for such a slow circuit here!3. Sure, an inverting (charge pump or buck-boost) circuit is usually used, but mind the noise generation too.You may find it's far, far better to simply use a single-supply or RRIO opamp instead. These are readily available, in good speeds as well, usually in the 5V-and-less range. (There are amps up to 36V with the same wide range and tight specs, but they get /much/ more expensive..) If you don't need a 12V supply (your input is only 5V), this may be very worthwhile, even if it means adding a 78L05 just for the amp.4. Just one thing, no integrator windup clamping on the first opamp. That is, while the signal is low, its output saturates to -V. When the signal comes up again, it takes a long time to ramp up to the 0-5V range. Usually, this is dealt with by adding a series resistor in the -in path, then a diode from output to -in, clamping the output at -0.7V or so. (With an RRIO amp, it can only wind down to 0V, so you don't need the diode.)Tim

author: AbuIbraheem
author_rank: Newbie
timestamp: May 06, 2018, 09:10:29 pm
content: I designed sometime ago a peak detector.For that you need:1- High speed op amp to follow the input without delay and overshoot.2- high output current to charge the capacitor quickly.3- use low input bias current opamp connected to the capacitor, low leakage current diode & high off resistance mosfet to not discharge the capacitor.4- use Schottky diode to get high speed.5- prevent the opamps from saturation because that will delay them from following the coming pulse as they need to come from saturation to conduction. A good design is this:source:http://www.analog.com/en/technical-articles/ltc6244-high-speed-peak-detector.htmledit: Also consider using low pass filter at the input to reduce signal speed.

author: David Hess
author_rank: Super Contributor
timestamp: May 06, 2018, 10:36:03 pm
content: http://www.analog.com/media/en/reference-design-documentation/design-notes/dn61f.pdf?Domain=www.linear.com.cn]Linear Technology DN61 - Peak Detectors Gain in Speed and Performance

author: Kalvin
author_rank: Super Contributor
timestamp: May 07, 2018, 09:30:04 am
content: When you simulate circuits containing diodes, transistor and FETs etc. with LTSpice you should always use real device models. Now you are using just generic models like D and NMOS which will give you very weird simulation results compared to the actual devices like 1N4148 and 2N7002 etc.

author: iMo
author_rank: Super Contributor
timestamp: May 07, 2018, 10:51:59 am
content: FYI:The PeakDet_4 looks nice, imho..

author: iMo
author_rank: Super Contributor
timestamp: May 07, 2018, 03:19:27 pm
content: To verify the Q2/Q3 model actually works in that simulation (the "diodes") here is a comparison of a "fast settling op-amp" vs. a "slow op-amp" (both Jfets op-amps).

author: Oaklander
author_rank: Regular Contributor
timestamp: May 07, 2018, 06:02:14 pm
content: Thank you for replies.My own design is based on Dave's video. I selected real models for the diodes and the FET and its performance changed quite a bit. It seems to work if zener diodes are used.I want to keep the design a simple as possible as I will need quite a few of them. Therefore I also like the TL082 (or TL084) as they are very cheap. They would be much cheaper even with the extra components for negative supply voltage.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 07, 2018, 07:12:50 pm
content: Try some compensation between OUT and -IN of the first amp, and an integrator windup catch diode.Even with this, TL082 may be hopelessly slow.Try CA3130?Tim

author: Oaklander
author_rank: Regular Contributor
timestamp: May 07, 2018, 08:04:25 pm
content: I just realized that I haven't said anything about the rise time of the signalIt is five microseconds at minimum so speed is not that big of a problem.I changed the pulse parameters in my simulation. The diodes are now BZX84C33. The resulting graph is attached. I think it looks pretty good but wonder how accurate it is with realityEdit. Wrong graph attached at first.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 07, 2018, 09:01:29 pm
content: FYI, the only difference with zeners is probably capacitance. Try 1N4148 with a capacitor across it. But mind that the amount recovered by the capacitance depends on output swing.Tim

author: Oaklander
author_rank: Regular Contributor
timestamp: May 08, 2018, 08:59:24 pm
content: I simulated the Analog reference design linked by AbuIbraheem. It worked pretty well but had the problem of capacitor discharging way too quickly.I noticed that is has a resistor between the opamps. I added it to my original design and selected 1N4148 as diodes. This gave me the best results so far. It seems to give accurate results, the capacitor does not discharge and it is simple with small number of components.

author: Kleinstein
author_rank: Super Contributor
timestamp: May 08, 2018, 10:12:42 pm
content: So far here are mainly 2 types of peak detector shown: mainly the one with 2 diodes in series for a low drift version and in reply #4 a fast version with slightly better precision (the offset error of the 2 nd OP is compensated). In principle one can also use 2 diodes in series with the version from #4.One point to observe is input bias of the OPs. If the input bias of the 2 nd OP, there can be a slow upward drift, that can be a problem, if there is no frequent reset. A negative input bias tends to slowly return the peak value down and may be even desirable in some cases. How important slow drift is also depends on the application. Today longer time hold is more like done digital anyway.

author: Oaklander
author_rank: Regular Contributor
timestamp: May 09, 2018, 04:56:33 am
content: I have no idea how slow a drift do I need. The peak detector outputs will be connected to ADCs. A microcontroller will read the values and check if a peak has occurred by comparing them to previous values. Due to device architecture the internal ADC of the microcontroller can't be used.The problem is I don't know how fast it can be done. I think it will take a while as there are separate ADC chips and a high number of channels (over 100). However I have no idea whether it can be done 10Hz, 100Hz, 1000Hz or even faster. Of course it will depend on the components used but I want to find a tradeoff between speed and cost. It seems that relatively slow speed ADC and low drift peak detector is the best solution.

author: Kleinstein
author_rank: Super Contributor
timestamp: May 09, 2018, 03:02:41 pm
content: I don't think it would be practical to use one µC to handle anything near 100 channels. I would expect more like 1 µC for maybe 8 or 16 channels and than 8 to 16 such units together. With do many channels even just a diode and capacitor as peak detector might be possible. It will be nonlinear, but with so many channels it could be worth correcting numerical and saving on the HW side. I see no real reason to exclude the µC internal ADC, unless higher performance is needed - some µC have pretty powerful ADCs inside (e.g. up to 24 Bits or > 5 MHz 12 Bits).The speed of the peaks (repeat rate) and length of pulses (signals to look for peaks) are important factors on the peak detector design.

author: Oaklander
author_rank: Regular Contributor
timestamp: May 09, 2018, 07:25:35 pm
content: I can’t see why one microcontroller could not handle all the channels. The processing done after the measurement is quite simple, so one microcontroller would easily be enough. The pulses are very infrequent. There will be at least 10 seconds between them but much longer delay is also possible.I agree that internal ADC would be much simpler to use. I have also considered multiplexing all the channels to the internal ADC of the microcontroller. Speed is not important at all. All that matters is to get accurate voltage of the peaks.The problem with the simplest peak detectors is drift. How could it be corrected in software as the program has no way of knowing how much time has passed since the peak?

author: David Hess
author_rank: Super Contributor
timestamp: May 10, 2018, 01:42:50 am
content: Common solutions include lowering the drift. Low leakage diodes and low input bias current operational amplifiers help here. Raising the capacitance helps but slows the peak detector.In extreme cases, a fast peak detector might be followed by a slow low drift precision peak detector.

author: Oaklander
author_rank: Regular Contributor
timestamp: May 10, 2018, 03:35:19 pm
content: I now simulated the simplest form of peak detector, just a diode and a capacitor. To my surprise some of the simulations worked really well. Of course the output is slightly less than input because of diode voltage drop but it could be corrected in software. The most surprising thing is that with some diodes the drift is very small. Example is attached. Shouldn't the capacitor discharge faster?

author: Kleinstein
author_rank: Super Contributor
timestamp: May 10, 2018, 04:18:09 pm
content: The simulation is still only a relatively short time and a 1 nF capacitor is already not that small for a fast peak detector. At something like a 10 bit accuracy level drift is not that critical. The accuracy of those peak detector circuits is limited anyway with short pulses.There is the option to multiplex more channels to a single µC. However using more µCs might not be that much more complicated than using multiplexers. The large part would be 100 peak detectors. With just capacitors more MUX channels might add to the leakage - though one could still use something like 8:1 MUX connected to one of the ADC input of the µC. So one could even get away without individual discharge circuits.The advantage of using multiple µCs is that one can build / design an smaller part and than just build some 8 or so of the same type. This makes testing / building much easier than a single huge board. A µC handling less channels also speeds up things, so drift gets less critical. A fast µC (STM32 like) could get to less than 1 µs to check a channel. So even with many channels this could be fast enough that drift should not be such a big problem.One might get way with a 1 OP version with a MUX (e.g. 1:between the capacitor and the output buffer-amplifier and discharge FET. So something like 9 OPs, 8 diodes+caps, 1 MUX (8:1) and 1 FET for 8 channels.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: May 10, 2018, 05:44:05 pm
content: Note that a SPICE source has zero resistance or inductance. The only limiting factor is the diode's voltage drop.Consider the effect of a 1000uF capacitor here (again assuming very low ESR, which SPICE assumes is zero unless noted otherwise; note that LTspice may put in a default without you telling it to).SPICE might say it works, that doesn't mean the model you've created is realistic.Tim

author: mikerj
author_rank: Super Contributor
timestamp: May 10, 2018, 08:18:20 pm
content: Quote from: Oaklander on May 10, 2018, 03:35:19 pmYou have nothing loading the capacitor such as e.g. an A/D converter, so nothing to discharge the capacitor apart from diode leakage. You also have a perfect voltage source behind the diode, which is not realistic. Not that you seem to have used a zener diode for some reason, not the ideal part in this case!You also can't fully compensate for the diode drop in software since the actual drop depends on the current flowing through the diode, which depends on the rise time of the signal, dynamic impedance of the diode at that current, value of capacitor etc.

author: Oaklander
author_rank: Regular Contributor
timestamp: May 10, 2018, 09:05:24 pm
content: I think that just a diode and a capacitor connected to multiplexer may be enough. Then the capacitor would discharge because of reverse leakage in the diode and off leakage in the multiplexer, right? I looked through datasheets and it seems that a combined leakage current of just 2 nanoamps or even less could be achievable with low cost parts. Then the capacitor would discharge 0.002 volts in a millisecond. That’s already very little and I think the microcontroller can cycle through the channels even faster.There probably should be an opamp as voltage follower between the multiplexer and the microcontroller.

author: Kleinstein
author_rank: Super Contributor
timestamp: May 11, 2018, 11:08:46 am
content: The version with just diodes and capacitor also require a reasonably low impedance of the signal sources. So it depends on the signal source.Also the accuracy is limited as the diode drop depends on the current and thus peak size/shape.

author: Oaklander
author_rank: Regular Contributor
timestamp: May 12, 2018, 04:45:51 pm
content: I've simulated different circuits and calculated how they would fit in my application.The evolution of the original circuit now seems to be the best solution. Its performance is very good. Response to the peak is good and drfit is small. It does have quite a few components but that not a big deal as they are pretty cheap and space is not an issue.I think next step is to build a prototype and test it in reality.

author: David Hess
author_rank: Super Contributor
timestamp: May 12, 2018, 06:52:30 pm
content: Another interesting peak detector design can be found in the adaptive trigger circuit Jim Williams designed as shown in figure 130 on page 59 ofLinear Technology application note 47. This was inspired by a similar circuit used by Tektronix for peak-to-peak triggering in oscilloscopes.You might recognize the two transistor configuration as half of a sampling diode bridge. Using transistors in place of diodes raises the impedance seen by the amplifier in this case and transistor base-emitter junctions are fast and low leakage.