Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Precision Rectifier...what's going on here?

Status
Not open for further replies.
One thing to watch with the LMx39 comparators is the low sink current: worst case 6mA, although you can generally squeeze around 10mA out of most of them. So long as 6mA LED forward current would give sufficient brightness that would not be a problem.
spec
True. Luckily today you can get high brightness LEDs that will put your eye out with 5 mA.
 
I saw that but didn't want to hurt your feelings. :)
As I recall, I selected it because I needed one with near zero input bias current that ran on only one rail. It was probably a part just released so I found something to use it in to make the Marketing guy happy.....
 
I think bounty hunter wins the contest for economical. Looks like a pretty clever design. Since I already have dual supplies and voltage references distributed across the whole system, those wouldn't cost me anything per channel.
I would want to upgrade the '358s though for faster response.
Just remember that the op amp's input bias current drains the peak detect cap so make sure it isn't too high. I think the LM358 is typically a couple of hundred nano Amps because the input is a darlington. If you use a FET op-amp it will be close to zero. Some NPN input op amps have pretty high input bias current.
 
Just remember that the op amp's input bias current drains the peak detect cap so make sure it isn't too high. I think the LM358 is typically a couple of hundred nano Amps because the input is a darlington. If you use a FET op-amp it will be close to zero. Some NPN input op amps have pretty high input bias current.
The TI OPA192 would be my choice of op amp both for the precision rectifier and any summer/ buffer- might be a bit pricey for this application though.

spec

https://www.electro-tech-online.com/articles/game-changer-opamp-opax192.768/
 
Last edited:
Hy bounty,

I can't believe I'm exchanging posts with a National Semiconductor applications engineer. At work we used to eagerly anticipate the latest creations and words of wisdom from Nat Semi and I had every data book (blue) and application report they ever published. It was a great shame they were taken over by TI, in my opinion anyway.

spec
 
It was a great shame they were taken over by TI, in my opinion anyway.

Agree. The databooks were fun to read. Although the TI TTL databook was a nice piece of work. Precision Monolithics was a cool company too. AD and PI really had to merge tp be able to use all the intellectual properties of each.

There was another side of AD that's gone now. I did a design using their uMAC 4000 series https://www.datasheetarchive.com/uMAC4000-datasheet.html DAQ products. The datasheet was impressive at the time, BUT it failed to tell you that the inputs had to be configured in groups of 4. So, four R,S,K or K TC's and no auto-range. The serial port was a bit slow too.

When I asked for a manual to look at for the $5,000 USD system we needed, AD said no one has ever asked for that before.
 
I wondered how the LM111 avoided avalanche breakdown of the reverse-biased emitter-base junction of its output transistor and the datasheet showed me that the transistor was actually a pile of many parts.
 
Agree. The databooks were fun to read. Although the TI TTL databook was a nice piece of work. Precision Monolithics was a cool company too. AD and PI really had to merge tp be able to use all the intellectual properties of each.

There was another side of AD that's gone now. I did a design using their uMAC 4000 series https://www.datasheetarchive.com/uMAC4000-datasheet.html DAQ products. The datasheet was impressive at the time, BUT it failed to tell you that the inputs had to be configured in groups of 4. So, four R,S,K or K TC's and no auto-range. The serial port was a bit slow too.

When I asked for a manual to look at for the $5,000 USD system we needed, AD said no one has ever asked for that before.

Yeah, I always had a soft spot for National. They looked after us engineers with tons of excellent data sheets and application reports and, in the main, their chips were available and reasonably priced. As you say PMI were good too- I loved their classy audio chips. Analog Devices is a real quality outfit. They always seem to under rate their chips. I used one of their 80MHz opamps once and they all tested out at 100Mhz. It is often the other way around, especially if you get stuff from Ebay. Another class company was Burr Brown, another TI acquisition. Then of course there was Harris with their high speed chips. Still the chips that are on the market now are unbelievable and so well priced too.

spec
 
Last edited:
Agree. The databooks were fun to read. .
But they were expensive to print and there was always a political civil war inside the company to get a printing paid for. And the irony is that we in Applications usually couldn't get any books. They were used as "leverage" to get into see people at companies where the sales guy would deliver the books and bend somebody's ear as the price.

The most prized book of all was the audio-radio handbook, of which I ended up with two copies by guile and cunning.

The first set of books I got was obtained by theft when I plundered the ofice of a laid off senior Apps engineer named jay Scolio. I also took his desk since I have been working off a folding table since being hired (seriously).

Jay pulled the funnies practical joke I ever saw: he was immediately hired by maxim who was our competitor one block down. Jay still remembered everybody's mailstop and he had Maxim ship us all complete sets of their data books as kind of a tweak to say:

"Hey! The new place actually prints data books!"
 
Yeah, I always had a soft spot for National. They looked after us engineers
We actually did have the best customer service. What was hilarious was when somebody would be trying to get a Linear Technology part to work and couldn't get through to them and they would call me and say:

"I'm trying to design in your LM2087 and I need...."

I'd listen and say:

"We don't make any such part. Just because you put LM in front of it, doesn't mean we make it."

Then the guy would beg for help and I would usually do it just for customer good will.
 
But they were expensive to print and there was always a political civil war inside the company to get a printing paid for. And the irony is that we in Applications usually couldn't get any books. They were used as "leverage" to get into see people at companies where the sales guy would deliver the books and bend somebody's ear as the price.

The most prized book of all was the audio-radio handbook, of which I ended up with two copies by guile and cunning.

The first set of books I got was obtained by theft when I plundered the ofice of a laid off senior Apps engineer named jay Scolio. I also took his desk since I have been working off a folding table since being hired (seriously).

Jay pulled the funnies practical joke I ever saw: he was immediately hired by maxim who was our competitor one block down. Jay still remembered everybody's mailstop and he had Maxim ship us all complete sets of their data books as kind of a tweak to say:

"Hey! The new place actually prints data books!"
We actually did have the best customer service. What was hilarious was when somebody would be trying to get a Linear Technology part to work and couldn't get through to them and they would call me and say:

"I'm trying to design in your LM2087 and I need...."

I'd listen and say:

"We don't make any such part. Just because you put LM in front of it, doesn't mean we make it."

Then the guy would beg for help and I would usually do it just for customer good will.

:D I was one of the customers who pinched all your books, including the Audio/Radio one! I still had them all until they got lost in a house move in 2011.

Funny about a chap phoning you about how to use an LT part! :joyful:

It is surprising what goes on the other side of the fence. I got the impression that Nat Semi was very well run and that the apps engineers were sort of demi Gods who only had to snap their fingers to get what they wanted.

spec
 
It is surprising what goes on the other side of the fence. I got the impression that Nat Semi was very well run and that the apps engineers were sort of demi Gods who only had to snap their fingers to get what they wanted.

spec
Truth is that Apps was the great dumping ground of all the other departments. We had weak managers and the other managers siezed on that like how a lion senses the weakest gazelle. As for "well run", it was a zoo. Every level of management lied to the level above and below it. But the company survived despite itself.....
 
Truth is that Apps was the great dumping ground of all the other departments. We had weak managers and the other managers siezed on that like how a lion senses the weakest gazelle. As for "well run", it was a zoo. Every level of management lied to the level above and below it. But the company survived despite itself.....
OMG not National Semi too :eek::eek:
 
I LOVE those National Semiconductor books!
It seems simple to me: if you show engineers how to use your chips they will use them, if you don't, you won't sell any.
Spec, thanks for the interesting circuit idea. I'll have more to say about that but I think that's a very good way to do this.
...but...
I thought I got it figured out:

Harp12 Meter AsIs 1.jpg Meter Response Chart.jpg

I have a buffer / isolation amp on the input to avoid loading down the audio signal. It is AC coupled with a pretty big cap, and the 1K will ensure that any charge on the cap can not damage the op amp on power down. Next it goes into a R-D-R network that I think helped the circuit perform faster, it clips the positive peaks with a Schottky diode that I believe keeps the following stage from driving itself far into the negative output. Without that R-D-R it takes a while for the output to return to positive, so some of the fast peaks are lost while the op amp output recovers. Without it, I could easily see the start of the positive sine waves clipped like how an AC dimmer circuit works, and the response falls off a lot at 20KHz, even though its a 15 MHz op amp.

The middle stage has a cap for negative feedback. I didn't need it, but I will put that in the PCB; I might need it to kill oscillations. (I don't think I have any, but on the solderless breadboard there is a lot of noise that could be hiding something.) The middle stage does the hard work of rectifying. D3 is the main rectifier and it's in the feedback loop to effectively null out most of the errors of the 350mV diode drop. I had to loose the transistor rectifier/driver because it was pointed out by audioguru that it couldn't handle the reverse voltage. (In hindsight, I guess I could have just added a diode before the base.) I looked into a Darlington transistor, which could just handle a reverse 12 volts but that was pushing it, and I'd have speed-killing 1.2 volt diode drop that the op amp's slew rate had to compensate for. I also looked into MOSFETs, they could also handle the voltage but I didn't have any PMOSFETS available and not sure how I would have hooked that up.

Either way, this version responds fast enough. D4 is in there so whatever is left of the positive input peak (which is negative here) will be cut down to a lower gain after 350mV is reached and will help prevent the op amp from going hard negative, again for speed.

From the rectifier, it drives a fairly big 33uF cap so there will be a loooonnnng peak hold time. Again I was worried about a big charge on the cap when the power goes off (when audio may likely pop), so D17 will drain most of that charge through the dying +15 supply, and whatever's left has to get through the 10K resistor before it can damage the final op amp stage.

I drew up a clever (at least I thought) idea to enhance the drive current to the big cap using a transistor so it could respond faster, but I thought I should test this out first and apparently it didn't need any more work. Worst case, using a 24 volt peak-to-peak input signal at 20,000Hz, I was catching the peaks. The charts I attached show the response from 20 Hz to 20,000 Hz, and it's fairly flat. Yes, you can see some variation there but 1) I don't have fancy lab equipment in my basement and 2) we are looking at a chart with linear data. If you convert it to a log scale (which a dB meter is supposed to be), the variation seen converts to a small fraction of a dB - far too small to be noticed by the output meter with 4dB resolution. (For reference, I used a 22uF cap, didn't have 33uF with enough voltage rating.)

So the frequency response is good at the worst-case maximum input. The other concern is reasonable accuracy at the lower levels. That is where the precision of the rectifier is critical. At 8, 2.4, and 800mV it appears pretty much the same, with a bit of rolloff at 20KHz, but still a fraction of a dB. By the time I got to the 240mV level (about -35dB), I was running into the noise floor of my solderless breadboard. I'm hoping for a -40dB reading that is valid, but I'll have to wait until I can test a soldered version.

So I was 'scoping it out and playing with the audio input levels, and saw a pretty cool thing going on. When the audio is at a high level, I can see the output of the op amp (pin 8) driving the rectifier and cap. It produces a steady stream of pulses that start at just before the next peak comes along as the cap has lost a little juice. As soon as it charges the cap back to full value, the op amp shuts off and the pulses disappear. If I turn the output down lower, for the next two or three seconds there are no pulses at all, until the op amp "decides" that the decaying voltage is getting too low. Then the pulses start up again. It's like there is a digital processor in there making PWM signals to control this thing. (OK, I am a nerd if I found this interesting).

So getting back to where I started, I think the circuit that spec has shown (post#40) is quite interesting. Whenever the comparator sees the input is higher than the output voltage, it turns on a transistor to dump more current into the cap. When it's satisfied, it turns off. I don't really know what could be simpler!

Maybe now I have to scrap this whole thing and start with that #40 post...
(sigh) I was going to start working on a voltage tripler for 48V phantom power.
 
I LOVE those National Semiconductor books!
It seems simple to me: if you show engineers how to use your chips they will use them, if you don't, you won't sell any.
Spec, thanks for the interesting circuit idea. I'll have more to say about that but I think that's a very good way to do this.
...but...
I thought I got it figured out:

View attachment 98502 View attachment 98503

I have a buffer / isolation amp on the input to avoid loading down the audio signal. It is AC coupled with a pretty big cap, and the 1K will ensure that any charge on the cap can not damage the op amp on power down. Next it goes into a R-D-R network that I think helped the circuit perform faster, it clips the positive peaks with a Schottky diode that I believe keeps the following stage from driving itself far into the negative output. Without that R-D-R it takes a while for the output to return to positive, so some of the fast peaks are lost while the op amp output recovers. Without it, I could easily see the start of the positive sine waves clipped like how an AC dimmer circuit works, and the response falls off a lot at 20KHz, even though its a 15 MHz op amp.

The middle stage has a cap for negative feedback. I didn't need it, but I will put that in the PCB; I might need it to kill oscillations. (I don't think I have any, but on the solderless breadboard there is a lot of noise that could be hiding something.) The middle stage does the hard work of rectifying. D3 is the main rectifier and it's in the feedback loop to effectively null out most of the errors of the 350mV diode drop. I had to loose the transistor rectifier/driver because it was pointed out by audioguru that it couldn't handle the reverse voltage. (In hindsight, I guess I could have just added a diode before the base.) I looked into a Darlington transistor, which could just handle a reverse 12 volts but that was pushing it, and I'd have speed-killing 1.2 volt diode drop that the op amp's slew rate had to compensate for. I also looked into MOSFETs, they could also handle the voltage but I didn't have any PMOSFETS available and not sure how I would have hooked that up.

Either way, this version responds fast enough. D4 is in there so whatever is left of the positive input peak (which is negative here) will be cut down to a lower gain after 350mV is reached and will help prevent the op amp from going hard negative, again for speed.

From the rectifier, it drives a fairly big 33uF cap so there will be a loooonnnng peak hold time. Again I was worried about a big charge on the cap when the power goes off (when audio may likely pop), so D17 will drain most of that charge through the dying +15 supply, and whatever's left has to get through the 10K resistor before it can damage the final op amp stage.

I drew up a clever (at least I thought) idea to enhance the drive current to the big cap using a transistor so it could respond faster, but I thought I should test this out first and apparently it didn't need any more work. Worst case, using a 24 volt peak-to-peak input signal at 20,000Hz, I was catching the peaks. The charts I attached show the response from 20 Hz to 20,000 Hz, and it's fairly flat. Yes, you can see some variation there but 1) I don't have fancy lab equipment in my basement and 2) we are looking at a chart with linear data. If you convert it to a log scale (which a dB meter is supposed to be), the variation seen converts to a small fraction of a dB - far too small to be noticed by the output meter with 4dB resolution. (For reference, I used a 22uF cap, didn't have 33uF with enough voltage rating.)

So the frequency response is good at the worst-case maximum input. The other concern is reasonable accuracy at the lower levels. That is where the precision of the rectifier is critical. At 8, 2.4, and 800mV it appears pretty much the same, with a bit of rolloff at 20KHz, but still a fraction of a dB. By the time I got to the 240mV level (about -35dB), I was running into the noise floor of my solderless breadboard. I'm hoping for a -40dB reading that is valid, but I'll have to wait until I can test a soldered version.

So I was 'scoping it out and playing with the audio input levels, and saw a pretty cool thing going on. When the audio is at a high level, I can see the output of the op amp (pin 8) driving the rectifier and cap. It produces a steady stream of pulses that start at just before the next peak comes along as the cap has lost a little juice. As soon as it charges the cap back to full value, the op amp shuts off and the pulses disappear. If I turn the output down lower, for the next two or three seconds there are no pulses at all, until the op amp "decides" that the decaying voltage is getting too low. Then the pulses start up again. It's like there is a digital processor in there making PWM signals to control this thing. (OK, I am a nerd if I found this interesting).

So getting back to where I started, I think the circuit that spec has shown (post#40) is quite interesting. Whenever the comparator sees the input is higher than the output voltage, it turns on a transistor to dump more current into the cap. When it's satisfied, it turns off. I don't really know what could be simpler!

Maybe now I have to scrap this whole thing and start with that #40 post...
(sigh) I was going to start working on a voltage tripler for 48V phantom power.

Hi Rich,

You are quite right about data books. For example, given a choice, I always specified components from the manufacturers with the best technical support. Over the years, that must have amounted to a lot of business going their way.

Glad you got your peak detector circuit working OK- they can be ticklish little devils- and nice write up on your design process and how the circuit works. I was trying to figure the 1N4148 diode, but get it now from your description.

It is interesting that your monitoring shows that the opamp in your circuit is operating like a comparator. Intuitively you would not think that to be the case. The thing is that opamps do not make good comparators, in fact some get decidedly upset in that role, not to mention that they are like slugs coming out of saturation/overdrive. On the other hand comparators don't make good opamps. One important feature about comparators is that their indecision window is very small and some comparators even have a touch of hysteresis which greatly improves the performance in the precision detector role.

About changing tack with a design, there is an adage in writing: 'Don't be afraid to slaughter your babies' It applies to electronic too!

I have designed quite a few sample and holds and precision rectifiers and your post made me realise how much I had forgotten.
There are a number of precision rectifier typologies:

(1) Opamp: as you have been perusing

(2) Comparator

(3) Shunt: a comparator shunts either the positive or negative half cycle to 0V and leaves the other half cycle untouched

(4) Saturating: chose an opamp where the output saturates at 0V and recovers well and simply connect the -ve supply pin to 0V and feed the opamp with an input signal centered on 0V

(5) Synchronous: switch a pass element on and off with a comparator output- this is one of the fastest precision rectifiers

(6) Constant current steering: convert the input signal into a proportional current and use diode switching to only pass on half of the input signal- blindingly fast and also well behaved.

(7) Steering: a comparator drives a single pole double throw solid state switch (CMOS) which routes one half of the input signal to one capacitor and the other half to another capacitor. I didn't get to build one of these unfortunately.

Here are a few general notes:

(1) The LM311 is a much faster comparator than the ubiquitous LM339 family of comparators. It is also an industry standard and jelly-bean priced but it is not as cheap as the LM339 types. The LM319 is effectively a dual LM311 without the strobe functions, so the LM319 would probably be a good choice for your application as it is also cheap and freely available. One drawback with the LM311/LM319 is that their input range does not include the negative supply rail like the LM339 types.

(2) The smaller you can make the holding capacitor the better: less currents lurching around your circuit and also gives the chip driving it an easier time. In the quick design I did, 1nF seemed to do the job adequately. This brings the advantage that you can use a solid polycarb capacitor quite cheaply. If you use an electrolytic go for an HF solid tantalum type rather than an aluminum type though. A FET input amp is best for the capacitor buffer, because they have practically zero input current. As you no doubt know, there are million and one types that would be suitable. The creme d la creme would be an OPA192 (also good for a precision rectifier too)

(3) Schottky diodes are good for rectifying because they are fast and have a low forward voltage, but they have comparatively high reverse leakage which goes up rapidly with junction temperature. A conventional silicon diode often performs better. The BAS116 would be a good choice.

(4) It is a good idea to have a high value resistor of around 2M Ohms from the output of the opamp to the non inverting input of the opamp so that, in the quiescent state, the opamp knows what to do and doesn't jangle up and down trying to find balance in the diode Vf dead zone.

(5) It is important to keep the input signal within optimum bounds. On one hand you want accuracy, but on the other hand you need to watch the large signal high current capability of the opamp. My feeling is that a 6V peak input signal is a bit on the high side.

(6) You will get much more consistent display timing if use use a restoring constant current rather than a restoring resistor.

(7) It seems to me that you really want a bar graph with three modes.
(7.1) Standard VU
(7.2) Peak detect and hold
(7.3) Peak detect and restore
It would be possible to select these modes with a switch rather than using three bar graph displays. Of course, the Rolls Royce approach would be to have three separate displays. Also you would get a load of street cred!

(8) Have you thought about using a moving coil meter as a display. A suitable moving coil meter is available on Ebay for around £3 UK. This is just a thought- retro is all the rage at the moment.

End of lecture
spec
 
Last edited:
Hi Rich.
It looks good, especially the low frequency noise generator at the upper left. With a open loop voltage gain of more than 100,000 times at low frequencies the unused opamp output will be 28Vp-p of low frequency noise. I think it should have its output connected to its inverting input so that it gain is only 1.
 
An op amp trying to charge up a 33uF cap is going to miss a fast transient going by. It doesn't have enough current to charge it fast enough. It will eventually get to the right peak value if the signal is repetitive. It's been quite a few years since I calculated it, but I recall that the ballpark of maybe 0.5 uF is what you can use given the op amp only has maybe 10mA max for charging it.

I think the R1 input resistor can be omitted. I don't think it does anything looking into the input impedance.
 
(8) Have you thought about using a moving coil meter as a display. A suitable moving coil meter is available on Ebay for around £3 UK. This is just a thought- retro is all the rage at the moment.

spec

Analog meters are very useful.

The audio VU meter I built for processing MP3 tracks in my computer has both an analog and LED bar graph displays. The LED display uses peak hold and the analog meter is more average responding and actually gives a much better representation of "loudness" because of the weighting I used for that signal path. Peak display is always useful information but notoriously misleading for adjusting volume levels. Sometimes analog is the best.
 

Attachments

  • LED VU Image_edited.jpg
    LED VU Image_edited.jpg
    167.1 KB · Views: 210
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top