Rectifying an unbalanced signal

Started by fryingpan, September 20, 2024, 05:07:25 PM

Previous topic - Next topic

ElectricDruid

Quote from: jorg777 on September 25, 2024, 02:35:40 PMThe extra transistor does make a big difference; at least in simulation I didn't do much tweaking at all.  Main thing is the load resistor of the first stage has to be pretty beefy because it is driving the collector and emitter of the output directly.

The circuit attenuates by a few percent, but unless it's used in test equipment, I don't see how that is very important.  You'll surely have something after this circuit (EQ, buffer, AC coupling, etc) and building a teeny bit of gain in should be pretty much free, if indeed you need a gain of exactly 1.

Yeah, I've been having a play with it in LTspice and I'm quite impressed. On a 9V supply, it works pretty well up to +/-3V input. Above that it starts to clip half the waveform, but that's fair enough. If the input isn't nicely centred around 4.5V, the two  peaks don't match up, but that's fair enough too. It doesn't handle really low levels as well as an op-amp precision rectifier either, but again - that's totally fair enough.

For the simplicity of it, it's a really useful circuit and it works nicely for most of the sort of range that we'd probably need it for. Thanks.

fryingpan

Quote from: ElectricDruid on September 25, 2024, 03:40:12 PM
Quote from: jorg777 on September 25, 2024, 02:35:40 PMThe extra transistor does make a big difference; at least in simulation I didn't do much tweaking at all.  Main thing is the load resistor of the first stage has to be pretty beefy because it is driving the collector and emitter of the output directly.

The circuit attenuates by a few percent, but unless it's used in test equipment, I don't see how that is very important.  You'll surely have something after this circuit (EQ, buffer, AC coupling, etc) and building a teeny bit of gain in should be pretty much free, if indeed you need a gain of exactly 1.

Yeah, I've been having a play with it in LTspice and I'm quite impressed. On a 9V supply, it works pretty well up to +/-3V input. Above that it starts to clip half the waveform, but that's fair enough. If the input isn't nicely centred around 4.5V, the two  peaks don't match up, but that's fair enough too. It doesn't handle really low levels as well as an op-amp precision rectifier either, but again - that's totally fair enough.

For the simplicity of it, it's a really useful circuit and it works nicely for most of the sort of range that we'd probably need it for. Thanks.
Yes, I played with it too, and it has some minor issues (such as that beefy emitter follower before, the fact that it clips easily, etc.) but you can easily design around those. The second transistor, anyway, also needs something after it, methinks, because if you want to preserve some bandwidth in the detection (mainly for fast attack times, 1776 style) then it's best followed by another emitter follower (even directly coupled). So it's three transistors? No biggie.

Rob Strand

#42
Quote from: ElectricDruid on September 25, 2024, 03:40:12 PMYeah, I've been having a play with it in LTspice and I'm quite impressed. On a 9V supply, it works pretty well up to +/-3V input. Above that it starts to clip half the waveform, but that's fair enough. If the input isn't nicely centred around 4.5V, the two  peaks don't match up, but that's fair enough too. It doesn't handle really low levels as well as an op-amp precision rectifier either, but again - that's totally fair enough.

For the simplicity of it, it's a really useful circuit and it works nicely for most of the sort of range that we'd probably need it for. Thanks.

It's actually very similar to the "Electron Design" transistor circuits we discussed earlier.   Same set of problems. 
https://www.diystompboxes.com/smfforum/index.php?topic=132441.msg1289861#msg1289861

The advantage of the preceding buffer is the VBE drop of the buffer lets you set the base bias voltage of the buffer conveniently and more reliably at 4.5V.   Whereas the "Electron Design" circuit the bias point is with resistors.

In either circuit the *input* bias voltage needs to be tuned to be so the second transistor is riding on saturation.   Without resistor tolerance that ends up at around half supply - so there is DC voltage output of 4.5V with no input.  The further the output is mis-biased from that point the worse it behaves for small signals and the bigger the offset between the rectified output peaks for positive an negative inputs.  (The input and output bias don't track so the DC levels on the input and output need to be accounted for separately and independently.)

In either circuit, the output impedance is different for positive and negative inputs.   If you place even a high value resistive load to ground it will upset the output peak balance.

Both the above means the circuit can effectively end up performing like a half wave rectifier with a diode drop for small signals.

As I recall  the extra Rx resistor on the Electronics Design circuit lets you tweak the imbalance and improve the output for small signals.  But off hand it only works if the misbiased output transistor is misbiased in one direction - don't quote me on that it's been a while since I looked at it.

Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

Rob Strand

#43
Quote from: Rob Strand on September 25, 2024, 07:26:57 PMAs I recall  the extra Rx resistor on the Electronics Design circuit lets you tweak the imbalance and improve the output for small signals.  But off hand it only works if the misbiased output transistor is misbiased in one direction - don't quote me on that it's been a while since I looked at it.
So it seems this is the case.

Here's four circuits: Circuit 1 is the AC couple version and Circuit 2 is the DC coupled version.  At 1Vpk in the two circuits perform the same.

Here's the analysis of the effect of Rx on the Electronics Design article in compensating for the misbased DC input level.  Which essentially  mixes some AC input voltage with the output voltage.

Circuit 2 has the DC bias tweaked for equal positive an negative peaks with 1V pk input.
Circuits 3 and 4 shifts the DC bias by about 33mV in each direction from the tweak circuit,
that causes the peaks to be mismatched.  According to the method in the Electronics Design
article we add some fraction of the input voltage to the rectified output to compensate for
the peak mismatch.

The mixed level was tuned to match the peaks 1V pk input.  Then we see what happen to the peak tracking when the input level is reduced to 0.1Vpk



Circuit tuned at a 1V peak input level:



Now what happens when we reduce the input to 0.1V pk:



So we can see if we deliberately add misbias *in the right direction* then use the mixing technique given in the Electronics design article the rectifier works over a much wider range of input.  It even out-performs the basic circuit with hand tweaked DC bias level.

So in theory the addition of Rx in the Electronics Article does help the circuit.  I think the main thing missing is the DC bias point needs to be deliberately shifted from the "optimal" of the basic circuit.  Another point in the original article Rx loads the collector whereas my analysis mixes theoretically without loading and avoids that problem.

The output at low input levels isn't really a full-wave rectification it's more of a shifted AC waveform.  It's upto the following circuit to account for the offset.

FWIW: What is better is a matter of interpretation.  At low inputs the equal peak versions has an error in the form of an offset.  Whereas we can tweak the circuit to produce a peak equal to the input but then it's no longer full-wave.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

fryingpan

#44
Case in point:



This circuit slews quite a lot.

0.1V input (which is amplified, like, 3x right now):



Red trace is at the output of Q3. I didn't show it earlier because it was basically identical to the green trace.

Green trace is after the diode, blue trace is after the 5k resistor.

0.5V input:



This could well be a feature, actually. Big transients get squashed slower than small transients.

The problem arises when you try and give it any meaningful release (4.7u cap to ground after the diode):



The red trace is at Q3's collector. I didn't post it earlier because it's basically the same as the green trace, minus the diode drop.

jorg777

For this application (almost any application really) the output of this circuit should be buffered.  That would address the slew issue for the envelope detector, and (some of) the symmetry issues discussed by Druid and Rob.

fryingpan

Yes, but I'm thinking, maybe a wimpy buffer could maintain some of that slow slewing, which can help in preserving some transients and compress in a more dynamic way. Vari-mu compressors are supposed to have some of this non-linearity in compressing.

Rob Strand

#47
Quote from: fryingpan on September 26, 2024, 09:57:48 AMYes, but I'm thinking, maybe a wimpy buffer could maintain some of that slow slewing, which can help in preserving some transients and compress in a more dynamic way. Vari-mu compressors are supposed to have some of this non-linearity in compressing.

The output impedance for negative inputs is the value of the collector resistor (33k on my schematic, 18k on yours).  The output impedance for positive inputs is around 100ohm to 1k with resistive loads, which comes from the output impedance of Q1 and CB diode of Q2.  (I suspect the output could rise to the follower emitter resistor value (4k7 on my schematic, 10k on yours) with capacitive loads.)

You could use the output impedance to define the attack time constant.  However because the output impedance isn't constant you would need to add series resistance.   To swamp out the output impedance the series resistance would need to be too high.

You can add an output buffer or even replace the diode in your schematic with an emitter follower where the BE junction also acts as a rectifier diode and but it also boosts the output drive.

When you use a capacitor (C4 of your schematic) to remove the DC you will need some means of discharging it.   With the current flowing one way the capacitor charges up and causes the output of the rectifier to shift.  If you look at the Orange Squeezer example I posted earlier there is a resistor to ground after the capacitor to stop that happening.

https://www.diystompboxes.com/smfforum/index.php?topic=132441.msg1289943#msg1289943



Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

fryingpan

Quote from: Rob Strand on September 26, 2024, 03:16:05 PM
Quote from: fryingpan on September 26, 2024, 09:57:48 AMYes, but I'm thinking, maybe a wimpy buffer could maintain some of that slow slewing, which can help in preserving some transients and compress in a more dynamic way. Vari-mu compressors are supposed to have some of this non-linearity in compressing.

The output impedance for negative inputs is the value of the collector resistor (33k on my schematic, 18k on yours).  The output impedance for positive inputs is around 100ohm to 1k with resistive loads, which comes from the output impedance of Q1 and CB diode of Q2.  (I suspect the output could rise to the follower emitter resistor value (4k7 on my schematic, 10k on yours) with capacitive loads.)

You could use the output impedance to define the attack time constant.  However because the output impedance isn't constant you would need to add series resistance.   To swamp out the output impedance the series resistance would need to be too high.

You can add an output buffer or even replace the diode in your schematic with an emitter follower where the BE junction also acts as a rectifier diode and but it also boosts the output drive.

When you use a capacitor (C4 of your schematic) to remove the DC you will need some means of discharging it.   With the current flowing one way the capacitor charges up and causes the output of the rectifier to shift.  If you look at the Orange Squeezer example I posted earlier there is a resistor to ground after the capacitor to stop that happening.

https://www.diystompboxes.com/smfforum/index.php?topic=132441.msg1289943#msg1289943




Yes, I added it in, this was just a quick and dirty simulation.

Rob Strand

#49
Quote from: fryingpan on September 26, 2024, 04:18:52 PMYes, I added it in, this was just a quick and dirty simulation.


Here's a circuit which gets around all the output issues.  It's essentially a full-wave diode but it has strong drive (buffers are built-in), zero DC output so it doesn't need a coupling cap.   It's non-precision in that it has a built-in diode drop.  See notes on schematic for more details.

It's not an amazing circuit but it's an example of working around things.

As a passing note, something I was going to mention before is the Bearhug turns off the control JFET when the signal is high to reduce the gain.   Whereas the Orange squeezer turns on the control JFET when the signal is high to reduce the gain.  If you do a Bearhug type circuit you need to incorporate the inversion of the control signal.  (The Soul preacher sort of did it.)

Schematic


Low Level inputs:


High Level inputs:

Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

fryingpan

#50
Quote from: Rob Strand on September 26, 2024, 06:19:29 PM
Quote from: fryingpan on September 26, 2024, 04:18:52 PMYes, I added it in, this was just a quick and dirty simulation.


Here's a circuit which gets around all the output issues.  It's essentially a full-wave diode but it has strong drive (buffers are built-in), zero DC output so it doesn't need a coupling cap.   It's non-precision in that it has a built-in diode drop.  See notes on schematic for more details.

It's not an amazing circuit but it's an example of working around things.

As a passing note, something I was going to mention before is the Bearhug turns off the control JFET when the signal is high to reduce the gain.   Whereas the Orange squeezer turns on the control JFET when the signal is high to reduce the gain.  If you do a Bearhug type circuit you need to incorporate the inversion of the control signal.  (The Soul preacher sort of did it.)

Schematic


Low Level inputs:


High Level inputs:


This is great! Thanks! Although I was looking to get to something like it myself (I'm learning). But of course this will be better than whatever I can come up with on my own (the weaknesses of this kind of circuit are negligible for the application, that is, bass/guitar/track compression). The inversion is already accounted for, should I go with an N-channel JFET. I have quite a few J113, which have some of the characteristics I want (such as lowish Rds, lowish Vgs(off)). My main issue at the moment is coming up with a low distortion *and* low gain topology for the amp. The CFP topology I was using needs strong attenuation coming in, because at 2Vpp (my upper bound) it should not clip at all. I am looking into other discrete, relatively low part count topologies that allow for more flexible feedback.

fryingpan

Such as this one, perhaps?



Although the gain is set by Rg, and I have to try and see what happens if I shunt it to ground with two different branches, one with the JFET + small resistor, the other with the compression setting resistor.

Rob Strand

Quote from: fryingpan on September 26, 2024, 06:57:38 PMAlthough the gain is set by Rg, and I have to try and see what happens if I shunt it to ground with two different branches, one with the JFET + small resistor, the other with the compression setting resistor.

There's so many topologies and designs to choose from.

For that circuit you would probably want to split RG and put the JFET to ground.  Perhaps increasing the input resistor value.  In this case the gain will increase when the JFET is on, sort of like the Bearhug.
Some care is always required with the resistor values to get the right range of gains.   The JFET resistance sets the resistor scaling factor.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

Rob Strand

#53
Quote from: fryingpan on September 26, 2024, 06:38:19 PMThis is great! Thanks! Although I was looking to get to something like it myself (I'm learning). But of course this will be better than whatever I can come up with on my own (the weaknesses of this kind of circuit are negligible for the application, that is, bass/guitar/track compression).

Here's another spin.  This rectifier roughly has the properties of the previous rectifier but doesn't need any fine tuning.    It shift the DC using the RC networks I mentioned earlier.  As a option to tweak I've added a bias to set the diode drop like the previous rectifier.

Schematic:


Low Level Inputs: (0.5Vpk)


High Level Inputs: (2.5V pk)

Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

ElectricDruid

Nice video about using the precision rectifier circuit with guitar:


Guitar examples start at 2:27 or so.

fryingpan

Quote from: fryingpan on September 26, 2024, 06:57:38 PMSuch as this one, perhaps?



Although the gain is set by Rg, and I have to try and see what happens if I shunt it to ground with two different branches, one with the JFET + small resistor, the other with the compression setting resistor.
I experimented with this circuit and it is suboptimal for my specs (it appears to be hard to bias at 18V for 2Vpp input signals). I think my best bet is to go with the CFP and attenuating the input signal by 3/4ths, or 1/3rds. (Or run it at 9V and have lower gain). Otherwise can you point me towards a design that allows, at a low part count, to set idle gain high with an "on" JFET (shunted to ground) and compression by turning it off? (8:1 ratio, so 8dB difference). Of course I could go with a simple common emitter with degeneration, but that's always going to have significant THD.

Rob Strand

#56
Quote from: fryingpan on September 30, 2024, 10:20:57 AMI experimented with this circuit and it is suboptimal for my specs (it appears to be hard to bias at 18V for 2Vpp input signals). I think my best bet is to go with the CFP and attenuating the input signal by 3/4ths, or 1/3rds. (Or run it at 9V and have lower gain). Otherwise can you point me towards a design that allows, at a low part count, to set idle gain high with an "on" JFET (shunted to ground) and compression by turning it off? (8:1 ratio, so 8dB difference). Of course I could go with a simple common emitter with degeneration, but that's always going to have significant THD.

Is the amp not working by itself, or is it not working in the compressor configuration?

With a 30V supply it looks OK to me.  As drawn I'm seeing over +/- 12V peak output swing
with an input of 0.3V pk.

With 18V supply and R4 changed to 5.6k I get about +/- 7.7V output swing with an input of 0.2V pk.

If the output at the emitter of Q2 doesn't stay at half supply your JFET connections might be affecting
the DC level.  If the JFET is in the RG circuit path it shouldn't affect the DC.


Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

fryingpan

#57
Quote from: Rob Strand on September 30, 2024, 08:37:06 PM
Quote from: fryingpan on September 30, 2024, 10:20:57 AMI experimented with this circuit and it is suboptimal for my specs (it appears to be hard to bias at 18V for 2Vpp input signals). I think my best bet is to go with the CFP and attenuating the input signal by 3/4ths, or 1/3rds. (Or run it at 9V and have lower gain). Otherwise can you point me towards a design that allows, at a low part count, to set idle gain high with an "on" JFET (shunted to ground) and compression by turning it off? (8:1 ratio, so 8dB difference). Of course I could go with a simple common emitter with degeneration, but that's always going to have significant THD.

Is the amp not working by itself, or is it not working in the compressor configuration?

With a 30V supply it looks OK to me.  As drawn I'm seeing over +/- 12V peak output swing
with an input of 0.3V pk.

With 18V supply and R4 changed to 5.6k I get about +/- 7.7V output swing with an input of 0.2V pk.

If the output at the emitter of Q2 doesn't stay at half supply your JFET connections might be affecting
the DC level.  If the JFET is in the RG circuit path it shouldn't affect the DC.



Just the amp wasn't working well enough to justify biasing it and everything. I simply added a buffer in front with a low-resistance attenuator. The noise simulation tells me that as it is right now, noise is below 200nV/Hz^(1/2) over 200Hz, and reaches at most 780nV/Hz^(1/2) at the low end of the spectrum. It should be close to noiseless, considering that even when fully compressed at max ratio, the output signal is 1.5x the input. (Total RMS noise is about 27uV).

I also ended up just designing the detector around a buffered phase splitter, then boosted, because it was already simulating good enough.

This is my tentative design:





The pre-amplifier for the detector may be a bit too strong, but on the other hand, with JFETs being what they are, you never know how much voltage you need to turn the JFET off. As it is, you can turn the compression fully on even with just 0.1Vpeak.