Improve bandwith of peak detector - Page 1
Forum section: electronics / projects

author: marcoccio
author_rank: Newbie
timestamp: July 23, 2019, 11:43:13 pm
content: Hi, i'm in the process of dessigning a peak detector to feed and adc in arm chip for an univercity proyect and have encountered a wall. I need to detetect with 2% accuracy voltages between 50mV and 5V of an AC sinusoidal or triangular waveform with frequency ranging from 5 to 500kHz. For this i have dessigned a peak detector ussing an LM393 comparator. The peak detector will be driven by a pga MCP6S21 controlled by the arm chip to improve the sensibilty. There are two problems i have encountered so far:1. At low frequency, less than 1Khz, the cap C2 can't hold it's voltage for long enouth. My solution to this would be to enlarge R11 and add another (smaller) resistor in parallel controled by the arm chip using a jfet. This resistor would switch on at a predefined frecuency so that the cap C2 is able to rapidly follow the changes in the voltage, frecuency would also be measured by the arm chip.2. At frequencies higher than 200Khz the charge in C2 starts to fall bellow my 2% allowable drop. And despite my efforts i haven't been able to improve the frequency responce of the circuit.Heres a photo of the circuit:Any input would be appreciated!

author: Audioguru again
author_rank: Regular Contributor
timestamp: July 24, 2019, 01:39:04 am
content: Your second comparator does nothing because it is missing an output pullup resistor. If you add the pullup resistor then the negative feedback will cause the comparators to oscillate because they do not have frequency compensation like opamps have. The pullup resistor on your first comparator has a value too low (too much current) for some of them but its current is not enough to quickly charge the capacitor.Use one very fast opamp with the diode inside its negative feedback loop. The opamp will provide a high output current to quickly charge the capacitor.

author: David Hess
author_rank: Super Contributor
timestamp: July 24, 2019, 03:09:41 am
content: A completely different circuit topology would be appropriate. Some operational amplifier peak detectors can be fast enough. The example below is way faster. Replacing the diode with a transistor allows charging the hold capacitor with a much higher current without lowering the value of the pull-up resistance which applies to your existing circuit.

author: marcoccio
author_rank: Newbie
timestamp: July 24, 2019, 01:40:39 pm
content: Thank you! I will explore those options and see what i can do.

author: David Hess
author_rank: Super Contributor
timestamp: July 24, 2019, 03:19:48 pm
content: Quote from: David Hess on July 24, 2019, 03:09:41 amIn case I was not clear enough about this, replace your diode D2 with a transistor with its collector tied to the positive supply. Now the current available from R7 is multiplied by the transistor's current gain to charge the hold capacitor faster. The example I gave uses the same idea.The reverse breakdown voltage of the base-emitter junction will limit the maximum range of operation to about 5 volts peak-to-peak however. If this is a problem, then a diode placed in series with the base can be added.

author: iMo
author_rank: Super Contributor
timestamp: July 24, 2019, 03:55:35 pm
content: I would use an AD8307. Works from DC to 500MHz. You get the LOG(input_peak_value) at the output (0-2.5V output).https://www.analog.com/media/en/technical-documentation/data-sheets/AD8307.pdf

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 24, 2019, 04:20:41 pm
content: QuoteCan the inputs be used with DC-coupling? I've seen series caps in pretty much all of the application schematics... so I'm not completely sure what is meant by "DC" here. Low frequency yes, but DC?Isn't it more adapted to detecting peak-to-peak amplitudes?Then the log output may or may not be a problem depending on what the OP is going to do with it.Other than that, those ICs are pretty handy.

author: iMo
author_rank: Super Contributor
timestamp: July 24, 2019, 04:38:44 pm
content: Quote from: SiliconWizard on July 24, 2019, 04:20:41 pmThere is the newer AD8310 with an example with DC coupling. Not sure it is applicable to AD8307, however..https://www.analog.com/media/en/technical-documentation/data-sheets/AD8310.pdf

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 24, 2019, 04:42:56 pm
content: Yes I see. It requires some level shifting though. Of course depending on your input signal you may not actually need to level shift. The internal structure seems pretty similar, so I guess this should be possible with the AD8307 as well...

author: iMo
author_rank: Super Contributor
timestamp: July 24, 2019, 04:48:30 pm
content: I saw somewhere the DC coupling example was there in 8307 DS till some revision, then they removed it. Otherwise the chips are pretty similar.PS: DS revB with DC coupling,:

author: MasterT
author_rank: Frequent Contributor
timestamp: July 24, 2019, 04:52:50 pm
content: Quote from: David Hess on July 24, 2019, 03:19:48 pmThe problem with BJT is high reverse leakage current, that is just cross out any gain in charge current it's introduced.To OP: What is the arm chip? If it has an ADC, may be you don't need peak detector after all, sampling input fast enough by 12-bits ADC and running peak detector in software.LF398 data sheet is good place to start in case hardware solution preferable.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 24, 2019, 05:32:34 pm
content: Quote from: MasterT on July 24, 2019, 04:52:50 pmWell... you're right. The OP talks about 500kHz max. Many recent MCUs have several-MSPS 12-bit ADCs, so that should be doable in software without much problem.Now if a 12-bit ADC would not have enough resolution for the OP's needs, then I think they would be dreaming if they think they can get better than the equivalent of 12-bit with a simple, fast and pure analog peak detector...

author: David Hess
author_rank: Super Contributor
timestamp: July 24, 2019, 11:49:43 pm
content: Quote from: MasterT on July 24, 2019, 04:52:50 pmCommon transistors have lower base-emitter leakage than gold doped diodes like the 1N4148. They just do not bother testing it below the 50 or 25 nanoamps specified in the datasheet because nobody cares and the tests at low currents take significant time on the test machine which increases costs quickly. The input bias current of the second stage is greater and the 1 megohm shunt resistor is greater yet.

author: MasterT
author_rank: Frequent Contributor
timestamp: July 25, 2019, 12:29:28 am
content: Quote from: David Hess on July 24, 2019, 11:49:43 pmProbably, they don't test reverse current of the common BJT because they have no idea that someone is gonna to build a peak detector with B-E junctions. 100 nA is enormous current in such application. Same time circuit and components selection shown in the original post is also wrong, and indeed BJT wouldn't make much harm.There is example out of TI data sheet,though TI didn't bother to draw reset switch. Resistor connected to uCPU will work as reset, just changing pin mode from Input to Output all it would takes to do resetting.

author: radix
author_rank: Contributor
timestamp: July 25, 2019, 12:36:26 am
content: Quote from: MasterT on July 25, 2019, 12:29:28 am*proceeds to post a schematic with a schottky diode that has max. leakage specified at 250 nA at 3 V reverse voltage at room temperature*David Hess also stated that a BJT has lower leakage than the 1N4148 (specified at 25 nA at 20 V reverse voltage at room temperature).On a more constructive note: You can also substitute the opamp with a few discrete transistors, although I suspect there is going to be way more offset in such a circuit. Description in the attached pdf document.

author: MasterT
author_rank: Frequent Contributor
timestamp: July 25, 2019, 01:43:00 am
content: Quote from: radix on July 25, 2019, 12:36:26 amGood catch, means don't trust anyone. Though I tested circuits with DG419 instead of BAT17, it operates quite accurate - down to 18-bits of resolution. Offset is not an issue, as long as its constant over input common mode voltage.

author: Kleinstein
author_rank: Super Contributor
timestamp: July 25, 2019, 09:39:33 am
content: The version I know of the simple 2 OP circuit uses an additional diode in feedback for the 1 st. OP, so that the OP only has to slew some 1.4 V when a new maximum is detected.For long hold times, one can combine 2 such circuits in series.: a fast one with a rather small hold capacitor and a slower one to extend the hold time.The fast part should than have a defined drift direction down.The transistor circuits look good.

author: David Hess
author_rank: Super Contributor
timestamp: July 25, 2019, 11:49:34 pm
content: Quote from: MasterT on July 25, 2019, 12:29:28 amThey do test it. They just only test it down to typically 25 or 50 nanoamps because the testing is fast at that level and that level is adequate for typical applications.The least expensive commonly available low leakage diode is the gate junction of a 2N4117 which really is tested down to 10 picoamps. The 2N4117A is tested to 1 picoamp.Quote from: radix on July 25, 2019, 12:36:26 amSometimes designers get into trouble using 1N4148s as clamp diodes for differential stages and discover that even at zero volts, they have a low resistance associated with their leakage current.I grade my own 2N3904s to use as low leakage diodes as needed but I have never found one which was much greater than 10 picoamps on either the emitter or collector junction. The emitter junction is very fast but has a low reverse breakdown voltage. The collector junction is slow and higher capacitance but has a high breakdown voltage.

author: MasterT
author_rank: Frequent Contributor
timestamp: July 26, 2019, 04:07:20 am
content: Quote from: David Hess on July 25, 2019, 11:49:34 pmI've checked on mouser, they have bav170 that has lower price and lower reverse current. Though data "typical" , but tested with high 70 Voltage.Still if consider max value 5 nA and 2N3904 - 50 nA it's 10 times difference. Decent OPA has output current 20 mA, bringing into picture 200 mA transistor gets 10x faster charge time, AND 10x faster discharge. So, what is the point to bother with more complex circuits, except impress your professor.

author: marcoccio
author_rank: Newbie
timestamp: July 26, 2019, 02:42:53 pm
content: I don't think extreamly low leakage transistors are required since the input signal is permanent, meaning the hold time should be enough to mantain an stable output at low frequecy's and not much more since it will always be charging with the next peak of the input signal.Quote from: imo on July 24, 2019, 03:55:35 pmI found abaout it in other post but it scapes my knowledge of how i should implement it, also it's expensive and where i live they don´t sell it. If i can't make this work i will look at it again and maybe i can get it shipped in a reasonable time, here customs take from two to five moths if you are a normal buyer like me.Quote from: SiliconWizard on July 24, 2019, 05:32:34 pmThat was my first thought, sadly, analog implementation is as must, teacher's requirement. We are using an F103C8T6 which has a 14Mhz ADC.. More than enouth to sample a 500Khz signal. If this gets too difficult maybe i can persuade him haha.Quote from: Kleinstein on July 25, 2019, 09:39:33 amI tryed that technique, however, the problem here is the op not able to deliver the necesary current to charge the cap at high frequencies, so the primary diode gets replaced by the base-emiter junction of a bjt.Quote from: David Hess on July 24, 2019, 03:19:48 pmThank you for the clarification, i tryed this approach and found it works really well.... But (there is always a but) i have some doubts about the circuit i came up with. Replacing both diodes with bjt's works, however, now at low input voltages (1V) the diference in voltage between the inputs and the feedbak from the output needs to be almost 100mV higher for the LM393 to stop charging the cap and there is always a 50 to 80 mV diference in charged value at 5v, i can live with that even though it's higher than 2% error. Here is the circuit:And here the simulated results, first at 1kHz and 1V peak, then 400kHz and 1V peak, finally 400kHz and 5V peak value.Once again thank you all for the replys

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 26, 2019, 02:52:42 pm
content: Quote from: marcoccio on July 26, 2019, 02:42:53 pmOK then... Sure a pure analog implementation is more "interesting" here design-wise... not that it's necessarily a good lesson engineering-wise though, as you have another solution that looks much easier to implement. Keep things simple! Ah teachers...Edit: quick note: the STM32F103C8 doesn't have a "14MHz" ADC... it's a 12-bit, with a max sampling rate of 1MHz. 14MHz is the max ADC's clock frequency, which is not its max sampling rate. Just making things clear. 1MHz should be fine here for a 500kHz signal, but you'd have no margin whatsoever. Just to make things clearer...

author: Kleinstein
author_rank: Super Contributor
timestamp: July 26, 2019, 03:23:16 pm
content: A fast peak detector would use a much smaller storage cap. Not 100 nF, but more like < 100 pF. If needed for longer hold time a 2 nd slower (larger capacitor and low bias OPs) peak hold stage could be added after the first. This can be useful with the transistor only version from the link (PDF from AD), that should have a tendency to drift down.Using the LM393 as a high slew rate OP is also tricky, it may work, but there can be ringing. Not all LM393 may behave the same as this is a common chip produced by several sources. Also the bias current limits the storage time or requires large capacitors. With the LM399, I would not worry much about the diode leakage - especially as the bias is positive, making it drift upwards, which is bad. A slow down drift can actually be a good thing.The use of a 2 nd diode has nothing to do with having enough current to charge the cap fast, it is about limiting the negative output voltage. This is especially important if a real OP, and not a comparator is used.I don't know how fast the base to emitter junction actually is, it could be an issue with a slow transistor.Usually fast recovery diodes also have higher leakage currents - so high speed comes at a price. A BE junction can be a good source for a medium speed (probably not as fast as the 1N4148) low leakage diode.

author: David Hess
author_rank: Super Contributor
timestamp: July 27, 2019, 02:12:43 am
content: Quote from: MasterT on July 26, 2019, 04:07:20 amThe maximum value is the only thing tested. While the maximum value for a 2N39056 is 50 nanoamps, its typical value is comparable to the BAV170. In both cases, you have to grade them yourself if you want to be sure. And unlike the base-emitter junction of a 2N3904, the BAV170 is slow.The 2N4117 and 2N4117A have tested maximum leakages of 10 picoamps and 1 picoamp respectively.Quote from: marcoccio on July 26, 2019, 02:42:53 pmThe speed is so much better that it now reveals other sources of error. More advanced peak detectors use various methods to improve accuracy but 2% is a tough specification for any fast peak detector.

author: marcoccio
author_rank: Newbie
timestamp: July 27, 2019, 03:16:26 pm
content: I'm back, after reading thishttp://www.ti.com/lit/an/snoaa35/snoaa35.pdfapplication note from TI i changed the desing for the better... I think. Yes the bjt works so much better that it shows a lot of sources of error that previusly one doesn't take into account. Here is the dessing:I'm not able to test the circuit today, on monday i will go to my university's lab and try it. I will update my findings.I think it is a good compromise between speed and accuracy, 2% error wasn't obtainable for me but maybe it will suffice my professor. Herehttps://1drv.ms/u/s!AifPFXqjPaa5jO0mQEpj4kh6gF_2dgis the multisim file if anyone want's to play with it. The file uses vanilla libraries.

author: SiliconWizard
author_rank: Super Contributor
timestamp: July 27, 2019, 03:22:52 pm
content: Maybe you could replace the TL061 with an opamp with smaller input offset (and slightly faster?).Have you characterized your error? Is it mainly a gain or offset error?

author: Kleinstein
author_rank: Super Contributor
timestamp: August 12, 2019, 06:11:24 pm
content: In the 2 OP peak detector the 2 nd OP has to quite fast, as it's inside the feedback loop of the other OP.For a fast detector the memory cap should be way smaller. So not 1 µF, but more like 10-100 pF. If long time storage is needed, a second slower stage can be added. Especially when using 2 stages, the input bias for the first, fast stage is not critical - it is than more help full to to have a defined negative bias. Some years ago I used LF356 and LM318 for a fast peak detector. At first it look counter intuitive to have the high bias LM318 as the buffer, but the bias is more a good thing than a problem.

author: AE7OO
author_rank: Regular Contributor
timestamp: August 23, 2019, 05:50:00 am
content: I would take a look at the modern versions of the LMC660(I have a tube of original Nat Semi's I picked up over 15 years ago). When you combine them with a analog switch they are an extremely low loss sample and hold, which would be foundation for a peak detector.I doubt you could use the LMC660 itself, GBP of 1.4Mhz and a low slew rate. But the newer versions are faster.I've included a copy of the LMC660's datasheet so you can see what I'm talking about.