Author Topic: Improve bandwith of peak detector  (Read 4489 times)

0 Members and 1 Guest are viewing this topic.

Offline marcoccioTopic starter

  • Newbie
  • Posts: 5
  • Country: ar
Improve bandwith of peak detector
« on: July 23, 2019, 11:43:13 pm »
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!
 

Offline Audioguru again

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ca
Re: Improve bandwith of peak detector
« Reply #1 on: July 24, 2019, 01:39:04 am »
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. 
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 17427
  • Country: us
  • DavidH
Re: Improve bandwith of peak detector
« Reply #2 on: July 24, 2019, 03:09:41 am »
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.

 

Offline marcoccioTopic starter

  • Newbie
  • Posts: 5
  • Country: ar
Re: Improve bandwith of peak detector
« Reply #3 on: July 24, 2019, 01:40:39 pm »
Thank you! I will explore those options and see what i can do.
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 17427
  • Country: us
  • DavidH
Re: Improve bandwith of peak detector
« Reply #4 on: July 24, 2019, 03:19:48 pm »
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.

In 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.
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 5570
  • Country: va
Re: Improve bandwith of peak detector
« Reply #5 on: July 24, 2019, 03:55:35 pm »
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
« Last Edit: July 24, 2019, 04:03:43 pm by imo »
Readers discretion is advised..
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15797
  • Country: fr
Re: Improve bandwith of peak detector
« Reply #6 on: July 24, 2019, 04:20:41 pm »
Quote
I would use an AD8307.

Can 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.
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 5570
  • Country: va
Re: Improve bandwith of peak detector
« Reply #7 on: July 24, 2019, 04:38:44 pm »
Can 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?
There 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
Readers discretion is advised..
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15797
  • Country: fr
Re: Improve bandwith of peak detector
« Reply #8 on: July 24, 2019, 04:42:56 pm »
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...
 

Offline iMo

  • Super Contributor
  • ***
  • Posts: 5570
  • Country: va
Re: Improve bandwith of peak detector
« Reply #9 on: July 24, 2019, 04:48:30 pm »
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,  :phew: :
« Last Edit: July 24, 2019, 04:56:09 pm by imo »
Readers discretion is advised..
 

Offline MasterT

  • Frequent Contributor
  • **
  • !
  • Posts: 851
  • Country: ca
Re: Improve bandwith of peak detector
« Reply #10 on: July 24, 2019, 04:52:50 pm »
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.

In 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.

The 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.
« Last Edit: July 24, 2019, 05:41:56 pm by MasterT »
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15797
  • Country: fr
Re: Improve bandwith of peak detector
« Reply #11 on: July 24, 2019, 05:32:34 pm »
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.

Well... 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...

 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 17427
  • Country: us
  • DavidH
Re: Improve bandwith of peak detector
« Reply #12 on: July 24, 2019, 11:49:43 pm »
In 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.

The problem with BJT is high reverse leakage current, that is just cross out any gain in charge current it's introduced.

Common 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.
 

Offline MasterT

  • Frequent Contributor
  • **
  • !
  • Posts: 851
  • Country: ca
Re: Improve bandwith of peak detector
« Reply #13 on: July 25, 2019, 12:29:28 am »
In 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.

The problem with BJT is high reverse leakage current, that is just cross out any gain in charge current it's introduced.

Common 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.
Probably, 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,
793686-0
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.
« Last Edit: July 25, 2019, 12:32:45 am by MasterT »
 

Offline radix

  • Contributor
  • Posts: 43
  • Country: si
Re: Improve bandwith of peak detector
« Reply #14 on: July 25, 2019, 12:36:26 am »
100 nA is enormous current in such application.
*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.
« Last Edit: July 25, 2019, 12:41:22 am by radix »
 

Offline MasterT

  • Frequent Contributor
  • **
  • !
  • Posts: 851
  • Country: ca
Re: Improve bandwith of peak detector
« Reply #15 on: July 25, 2019, 01:43:00 am »
100 nA is enormous current in such application.
*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*
Good 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.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 15151
  • Country: de
Re: Improve bandwith of peak detector
« Reply #16 on: July 25, 2019, 09:39:33 am »
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.
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 17427
  • Country: us
  • DavidH
Re: Improve bandwith of peak detector
« Reply #17 on: July 25, 2019, 11:49:34 pm »
Probably, 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.

They 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.

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).

Sometimes 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.
 

Offline MasterT

  • Frequent Contributor
  • **
  • !
  • Posts: 851
  • Country: ca
Re: Improve bandwith of peak detector
« Reply #18 on: July 26, 2019, 04:07:20 am »
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.
I'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.
 

Offline marcoccioTopic starter

  • Newbie
  • Posts: 5
  • Country: ar
Re: Improve bandwith of peak detector
« Reply #19 on: July 26, 2019, 02:42:53 pm »
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.

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

I 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.
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.

Well... 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...



That was my first thought, sadly, analog implementation is as must, teacher's requirement :palm: . 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.

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.

I 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.
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.

In 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.


Thank you for the clarification, i tryed this approach and found it works really well.... But (there is always a but :palm:) 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  :-+
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15797
  • Country: fr
Re: Improve bandwith of peak detector
« Reply #20 on: July 26, 2019, 02:52:42 pm »
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.

Well... 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...

That was my first thought, sadly, analog implementation is as must, teacher's requirement :palm: . 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.

OK 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... ;D

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...
« Last Edit: July 26, 2019, 02:59:53 pm by SiliconWizard »
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 15151
  • Country: de
Re: Improve bandwith of peak detector
« Reply #21 on: July 26, 2019, 03:23:16 pm »
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.
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 17427
  • Country: us
  • DavidH
Re: Improve bandwith of peak detector
« Reply #22 on: July 27, 2019, 02:12:43 am »
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.

I'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.

The 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.

Thank you for the clarification, i tryed this approach and found it works really well.... But (there is always a but :palm:) 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.

The 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.
 

Offline marcoccioTopic starter

  • Newbie
  • Posts: 5
  • Country: ar
Re: Improve bandwith of peak detector
« Reply #23 on: July 27, 2019, 03:16:26 pm »
I'm back, after reading this http://www.ti.com/lit/an/snoaa35/snoaa35.pdf application 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. Here https://1drv.ms/u/s!AifPFXqjPaa5jO0mQEpj4kh6gF_2dg is the multisim file if anyone want's to play with it. The file uses vanilla libraries.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15797
  • Country: fr
Re: Improve bandwith of peak detector
« Reply #24 on: July 27, 2019, 03:22:52 pm »
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?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf