DIYstompboxes.com

DIY Stompboxes => Building your own stompbox => Topic started by: Steben on September 22, 2021, 03:52:57 PM

Title: LM386 softer clipping
Post by: Steben on September 22, 2021, 03:52:57 PM
Hey Guys, would adding a diode pair and resistor in series between pin 1 and 5 on a 386 chip make for softer onset of clipping?
Title: Re: LM386 softer clipping
Post by: antonis on September 22, 2021, 04:22:50 PM
By maintainig gain cap between pin 1 and 8 or not..?? :icon_wink:
Title: Re: LM386 softer clipping
Post by: Rob Strand on September 22, 2021, 06:00:29 PM
You will need a series cap like a Big Muff because the DC pins 1 and 5 is different (and non zero).

Without the cap you would need an asymmetrical clipper to "take up" the DC offset.  Something like a zener might seem like it will work but it's likely to be conducting to some degree and act a little differently than expected because zener needs current to create the voltage drop.  So taking this route is likely to need more work.  For example a zener to the output then a resistor to ground to shift the voltage then that feeds the two diodes.  Since the diode clipper is only +/- 0.7V the DC voltage at the shifted point is going to be very sensitive to circuit conditions.   So instead of zener use a resistive divider to set the DC voltage at the divider output to be equal to the DC voltage on pin 5.    The only reason I mentioned the crazier versions is it might sound OK  ;D.

Title: Re: LM386 softer clipping
Post by: Vivek on September 23, 2021, 12:47:27 AM
Which stage(s) clip inside the LM386 ?

In which order do they clip ?

Do we lose the LM386ness of the Opamp if we add external diodes (ie it becomes equivalent to any other Opamp if external diodes control the clipping)
Title: Re: LM386 softer clipping
Post by: Steben on September 23, 2021, 01:45:50 AM
Quote from: Rob Strand on September 22, 2021, 06:00:29 PM
You will need a series cap like a Big Muff because the DC pins 1 and 5 is different (and non zero).

Without the cap you would need an asymmetrical clipper to "take up" the DC offset.  Something like a zener might seem like it will work but it's likely to be conducting to some degree and act a little differently than expected because zener needs current to create the voltage drop.  So taking this route is likely to need more work.  For example a zener to the output then a resistor to ground to shift the voltage then that feeds the two diodes.  Since the diode clipper is only +/- 0.7V the DC voltage at the shifted point is going to be very sensitive to circuit conditions.   So instead of zener use a resistive divider to set the DC voltage at the divider output to be equal to the DC voltage on pin 5.    The only reason I mentioned the crazier versions is it might sound OK  ;D.

Yes, the cap seems obvious now....
The "diodes" might be back to back zeners in series as well  8) Did not have fixed 0.7v in my mind.
Title: Re: LM386 softer clipping
Post by: Steben on September 23, 2021, 01:47:25 AM
Quote from: Vivek on September 23, 2021, 12:47:27 AM
Which stage(s) clip inside the LM386 ?

In which order do they clip ?

Do we lose the LM386ness of the Opamp if we add external diodes (ie it becomes equivalent to any other Opamp if external diodes control the clipping)

The idea would be to add some soft clipping with some resistance in series in order to have the chip itself still clipping. The treshold of "the diodes" shoudl be not much lower than the clipping of the chip itself.
Title: Re: LM386 softer clipping
Post by: Steben on September 23, 2021, 04:47:08 AM
Quote from: antonis on September 22, 2021, 04:22:50 PM
By maintainig gain cap between pin 1 and 8 or not..?? :icon_wink:

Interesting. You mean higher gain is less feedback and softer onset?
Title: Re: LM386 softer clipping
Post by: Vivek on September 23, 2021, 08:55:42 AM
Please check this logic and inform me if there is an error :

Lm386 clips due to rail saturation

Which depends upon the rail voltage

Hence, to soften down the clipping, we will need external clipping diodes that are referenced to Vcc.


If I remember, Rob S. has posted a schematic of clipping level referenced to rail.
Title: Re: LM386 softer clipping
Post by: antonis on September 23, 2021, 09:17:01 AM
Maybe bootstrapping supply rails could result into softer "onset" clipping..
Title: Re: LM386 softer clipping
Post by: r080 on September 23, 2021, 10:10:38 AM
Like Merlin's glassblower? It seems like it might be possible to try that without too much trouble.

http://www.valvewizard.co.uk/glassblower.html
Title: Re: LM386 softer clipping
Post by: Steben on September 23, 2021, 12:41:55 PM
Never knew blowing the glass ceiling might result in softer onset of clipping.
Can anyone explain? Is it about the base-emitter connection?


Fact: a 386 based amp draws some nice variable current that can be used to create power sag.
Title: Re: LM386 softer clipping
Post by: r080 on September 23, 2021, 03:16:58 PM
I don't know enough about bootstrapping to explain how it might work, but my understanding is it is a form of positive feedback. Since negative feedback reduces distortion and tends to make the transition to clipping faster, maybe bootstrapping would have an opposite effect.
Title: Re: LM386 softer clipping
Post by: anotherjim on September 23, 2021, 03:51:51 PM
Some chip amps you can overlay an opamp style Rf/Rin gain network. Not sure about a blocking cap - the 386 inputs are ground referenced - it would probably be needed from output pin5.
Title: Re: LM386 softer clipping
Post by: antonis on September 23, 2021, 04:11:44 PM
Quote from: r080 on September 23, 2021, 03:16:58 PM
I don't know enough about bootstrapping to explain how it might work..

(https://i.imgur.com/IUbYqVX.png)

From Douglas Self (as usual.. :icon_redface:) Small Signal Audio Design
Title: Re: LM386 softer clipping
Post by: Rob Strand on September 23, 2021, 05:55:11 PM
FYI, something that occurred to me about putting diodes in the feedback loop is the feedback loop could go unstable.   Fixed gain amplifiers are often only stable with that gain.   Most opamps people use are unity gain stable.    When you add clipping diodes the gain drops significantly during clipping that could cause the LM386 to oscillate.    For the LM386 it might be possible to add a feedback cap to help stabilize it under clipping.

If you see oscillation issues then try pulling the clipping diodes.
Title: Re: LM386 softer clipping
Post by: teemuk on September 23, 2021, 10:58:47 PM
Why not just limit the input signal?
Title: Re: LM386 softer clipping
Post by: Steben on September 24, 2021, 01:43:12 AM
Quote from: teemuk on September 23, 2021, 10:58:47 PM
Why not just limit the input signal?

Tricky one. I do see the 386 as main clipper. Sounds best with full gain. Any clipping in front around onset of 386 would need very low treshold.
Title: Re: LM386 softer clipping
Post by: teemuk on September 24, 2021, 02:25:37 AM
You can always attenuate the (clipping) limited signal to chip's input range.

Title: Re: LM386 softer clipping
Post by: Rob Strand on September 24, 2021, 03:31:29 AM
This might workout for a softening idea.

The LM386 as two gain settings high (x200) and low (x20).  High gain bridges pins 1 and 8.

So what if you configure the amp as high gain but you set-up the clipping network so it soft clips instead of hard clips.
In soft clipping to gain limits at the LM386 low gain setting (x20).   That means it's still within spec as far as stability is concerned.

The difference is how low gain is implemented.   Normal we open pins 1 and 8 for low gain which raises the resistance between the emitters inside the LM386 from 150 ohm to 1.35k + 150 = 1.5k.    So instead of opening pins 1 and 8 for low gain, we leave pins 1 and 8 shorted then decrease the gain by paralleling a resistance across the 15k feedback resistor.   For a clipping network all we need to do is add resistance in series with the clipper clipping levels at the lower gain.

However ...

If you look at the gain of the LM386 it's quoted as x200 and x20  but notice the ratio of the resistors is 15k/150 =100 and 15k/1.5k = 10.  There's a factor of 2 missing.   I have a feeling missing factor of 2 comes from the second 15k which is between the emitter of the first transistor and pin 7!!!.  So maybe a clipper isn't so simple because shorting out one 15k only reduces the gain by a factor of 2.    Taking that idea further perhaps leaving of the bypass cap increases the gain.   I need to look at this closer.  Seems like a little bit more going on.
Title: Re: LM386 softer clipping
Post by: Vivek on September 24, 2021, 04:00:49 AM
Yes, I want to investigate the pin 1 and 8 approach also !!!

Maybe for a compressor or sag or tone controls.


There are Spice models for LM386 for blackbox approach. I will have to input or find a discrete model.
Title: Re: LM386 softer clipping
Post by: Rob Strand on September 24, 2021, 04:07:55 AM
QuoteHowever ...

If you look at the gain of the LM386 it's quoted as x200 and x20  but notice the ratio of the resistors is 15k/150 =100 and 15k/1.5k = 10.  There's a factor of 2 missing.   I have a feeling missing factor of 2 comes from the second 15k which is between the emitter of the first transistor and pin 7!!!.  So maybe a clipper isn't so simple because shorting out one 15k only reduces the gain by a factor of 2.    Taking that idea further perhaps leaving of the bypass cap increases the gain.   I need to look at this closer.  Seems like a little bit more going on.
OK after a few mins of thought in the quite of my own home ... the 15k on pin7 doesn't affect the gain.  The x2 is to do with the mirror.
Title: Re: LM386 softer clipping
Post by: teemuk on September 24, 2021, 04:32:41 AM
ElectroSmash site features analysis of the LM386, which also explains how the internal gain setting and DC biasing circuits work.
https://www.electrosmash.com/lm386-analysis
Title: Re: LM386 softer clipping
Post by: Vivek on September 24, 2021, 04:34:00 AM
Quote from: Rob Strand on September 24, 2021, 04:07:55 AM
The x2 is to do with the mirror.


That explains why I look fat !!
Title: Re: LM386 softer clipping
Post by: Rob Strand on September 24, 2021, 04:46:03 AM
QuoteElectroSmash site features analysis of the LM386, which also explains how the internal gain setting and DC biasing circuits work.
https://www.electrosmash.com/lm386-analysis
Well spotted!   That's exactly what I did.   That site has done everything.   It's even got an example of the changing the gain with a resistor (and cap) across pins 1 and 5, which is what I was getting at before about the stable/soft clipper.
Title: Re: LM386 softer clipping
Post by: Vivek on September 24, 2021, 05:35:47 AM
Rob, do you mean gain set by pins 1 and 8 ?


The pin 1 and 5 trick has only been shown for the bass boost application which is straight from the data sheet.

Or do you mean to make the Pins 1 and 5 bass filter's bandwidth so wide that it becomes a gain control instead ?




How to use it for softer clipping
Sag
Tone controls
Compressor ???

Title: Re: LM386 softer clipping
Post by: Vivek on September 24, 2021, 05:48:30 AM
Opamp style feedback supposedly improves characteristics.

Might allow use of standard tricks to soften clipping, add tone controls ????

(https://i.postimg.cc/YSTNrvzY/lm386-supercharged4-1.png) (https://postimg.cc/cKMtT4jL)

from http://stephan.win31.de/music.htm
Title: Re: LM386 softer clipping
Post by: Vivek on September 24, 2021, 06:18:33 AM
18K and 10uF

Fc =  0.48 Hz if I calculated it properly

= gain setting rather than bass boost  ?

(http://www.minidisc.org/schem.gif)
Title: Re: LM386 softer clipping
Post by: Rob Strand on September 24, 2021, 06:47:48 AM
QuoteRob, do you mean gain set by pins 1 and 8 ?


The pin 1 and 5 trick has only been shown for the bass boost application which is straight from the data sheet.

Or do you mean to make the Pins 1 and 5 bass filter's bandwidth so wide that it becomes a gain control instead ?

For the clipper I was thinking pins 1 and 5 like a normal clipper.   The main point was not to let the gain go below 20 during clipping and that way it stays stable.

If you make the cap large enough it's pretty much going to reduce the gain across the whole band-width.   The other caps, like the output caps, would then dominate the roll-off so no bass boost in practical terms.

Title: Re: LM386 softer clipping
Post by: Rob Strand on September 24, 2021, 06:54:26 AM
QuoteOpamp style feedback supposedly improves characteristics.

Might allow use of standard tricks to soften clipping, add tone controls ????
That method might be worth investigating.    Something different for the LM386.
Title: Re: LM386 softer clipping
Post by: Vivek on September 24, 2021, 07:55:42 AM
If we put diodes into feedback loop

But big compliance resistor

We could acheive 2 knee transfer characteristics

Worth trying


But back to the question : what really does LM386 bring to the table ? Can softer edges around clipping be achieved more easily with Opamps ? What's special about LM386 for this application ? Are we beating a horse that died 20 years ago ?
Title: Re: LM386 softer clipping
Post by: teemuk on September 24, 2021, 08:35:35 AM
^ This.

Do you need the capability to drive a very low impedance load? If not, LM386 seems redundant. Just use an opamp.

If yes, why do you need to control how the actua LM386 circuit clips instead of just peak limiting the input signal and attenuating it to proper amplitude?

And if you must clip within the LM386 circuit then what's wrong with employing feedback diodes from output to inverting input? (Use a voltage divider to match chip's peak output to diode's lower forward voltage. This also prevents the chip driving clipping diodes to excessive power dissipation).

Or is the sole intention to just experiment with more unconventional ideas? 
Title: Re: LM386 softer clipping
Post by: Steben on September 24, 2021, 08:44:17 AM
Experiments partially, lm386 as a power amp.
Mind you, the 386 is already tasty on its own. Think of noisy cricket but with supro twist.
Title: Re: LM386 softer clipping
Post by: Steben on September 24, 2021, 12:06:38 PM
Quote from: Vivek on September 24, 2021, 05:48:30 AM
Opamp style feedback supposedly improves characteristics.

The HiFi ones :)

Clipping will likely be harder
Title: Re: LM386 softer clipping
Post by: Rob Strand on September 25, 2021, 12:51:09 AM
Something I always find interesting and sometimes amusing (and sometimes frustrating) is the internal schematics on ICs.

Thinking about the sound of the LM386 you might take a look at the internal schematic.  Then as your mind scans over it you realized it's obviously not quite like the real schematic.

Here's the common schematic,

(https://i.postimg.cc/MvPnTGB0/LM386-Internal-Schematic-Nat-Semi2000.png) (https://postimg.cc/MvPnTGB0)

So obvious things that are oversimplified are:
- textbook current source.  The precise current source will affect the swing and how it clips.
   It's going to be done with some sort of common transistor current source.
- Lack of compensation caps.   They would have to be there.
- The output stage biasing.  Far too simplified as shown.  Some resistance is needed in the base and/or the emitters.
- something to limit the current on the negative swings.

Some behavioural quirks of LM386 from the datasheet are how the output swing becomes quite limited with a 4 ohm load.   It's not so clear how positive and negative cycles individually behave with 4 ohm, or without a load.

Other stuff is input bias currents, which is obviously set by the transistor gains, and the quiescent supply current.    There's many other datasheet values to match up for sure.

So digging around I found, this which seems to plug the gap a bit more between the schematic and reality, possible still not real,

(https://i.postimg.cc/jWVPx5Vg/NJM386-Detailed-Internal-Schematic-JRC1999-2019.png) (https://postimg.cc/jWVPx5Vg)
Title: Re: LM386 softer clipping
Post by: PRR on September 25, 2021, 03:35:23 PM
Also read on LM380.

The biasing, current limiting, and compensation can be built into the chip, if you control/know the process. Make two junctions on the same wafer, trim the relative areas, you set the relative bias currents. Older mono PNPs had severe loss of hFE at some current, and fT maybe not a MHz.

The "discrete schematic" is often a poor approximation how it works. Widlar was a master of leveraging parasitics to do his bidding. 380/386 is not a Widlar but they all drank in the same places.
Title: Re: LM386 softer clipping
Post by: anotherjim on September 26, 2021, 06:52:15 AM
What is the thing with the BJTs showing more than one collector wire? I know multi-emitter, but the collector variety baffles me.
Title: Re: LM386 softer clipping
Post by: teemuk on September 26, 2021, 08:54:55 AM
Think of it as a "parallel" transistor that just has its collector connected to a different place. Current mirror still forces specific current flow in each transistor.
(https://i1.wp.com/www.electroniclinic.com/wp-content/uploads/2021/04/Parallel-BJT-current-mirror.jpg)

I think there may be an IC manufacturing process where a single transistor can have several collectors but it still essentially behaves like there would be several individual transistors. If not anything else, it's a method to simplify the circuit diagram.
Title: Re: LM386 softer clipping
Post by: pinkjimiphoton on September 26, 2021, 12:09:19 PM
best way i've found to soften clipping on a 386 is to add a hi pass filter to the input of it.
less bass = softer clipping and less dirt.
Title: Re: LM386 softer clipping
Post by: Rob Strand on September 26, 2021, 09:34:33 PM
QuoteThink of it as a "parallel" transistor that just has its collector connected to a different place. Current mirror still forces specific current flow in each transistor.
Teemuk's example gives the basic current mirror with Iref feeding the input to the current mirror.

The LM386 circuit uses a better mirror but it's not a Wilson.  The left most transistor is called a "helper transistor" and supplies the base current to all the transistors.   The current down the 15k resistor is Iref.  There is a 2 Vbe drop from the rail to the 15k resistor instead of a single Vbe drop in Teemuk's example.

The way the helper transistor is drawn on the LM386 circuit looks different to the common drawing for a current source with helper but it's actually the same circuit.   Using Teemuk's NPN example:  The BC wire on Qref is replaced with the helper transistor, the base goes to Qref's collector, the emitter goes to Qref's base and the collector goes to the +ve supply.   The reason the drew it like that is to show Qref is the same as Q1, Q2,  Q3.

You can see the connection at the bottom left of the LM741 (which has emitter  resistors),
http://www.learningaboutelectronics.com/images/Lm741-internal-schematic-diagram.png
Title: Re: LM386 softer clipping
Post by: antonis on September 27, 2021, 04:44:48 PM
Quote from: anotherjim on September 26, 2021, 06:52:15 AM
What is the thing with the BJTs showing more than one collector wire? I know multi-emitter, but the collector variety baffles me.

Just an idea.. :icon_wink:

Multi-Emitter BJTs do not conduct only if all the VBE are below Vγ, in the sort of wired AND...
Multi-Collector BJTs Collectors total current is set as usual by IB, and if all the Collectors are of the same size (area at silicon level) the current is equally split...

A bit further:
Multi-Emitter BJTs are usually used to close some sort of feedback from following stages, maybe avoiding BJT saturation, or in logic input stages where the logic funcion is implemented directly by the wired AND, like in some TTL AND input stages..
Multi-Collector BJTs are useful in IC's since it is rather easy to match the ratio between the Collector areas and split a polarizing current in precise ratios...
(as in the all-time-classic uA741 output stage polarization..)


Or it's just too late here.. :icon_redface:

Title: Re: LM386 softer clipping
Post by: Vivek on September 28, 2021, 03:49:09 AM
Rob Strand had posted a clipper/ limiter system with diodes referenced to power supply.

(https://slideplayer.com/slide/5778979/19/images/4/Figure+%28a%29+A+popular+limiter+circuit.jpg)

This can be used to soften the output of a rail saturated LM386 (Or any other Rail saturated Opamp circuit), by adding one more knee close to each rail. For LM386, I suppose we will have to use inverting pin, Opamp style feedback as I had posted earlier.

I feel this might be an excellent idea for this purpose.

Title: Re: LM386 softer clipping
Post by: Steben on September 28, 2021, 04:07:33 AM
Quote from: Vivek on September 28, 2021, 03:49:09 AM
Rob Strand had posted a clipper/ limiter system with diodes referenced to power supply.

(https://slideplayer.com/slide/5778979/19/images/4/Figure+%28a%29+A+popular+limiter+circuit.jpg)

This can be used to soften the output of a rail saturated LM386 (Or any other Rail saturated Opamp circuit), by adding one more knee close to each rail. For LM386, I suppose we will have to use inverting pin, Opamp style feedback as I had posted earlier.

I feel this might be an excellent idea for this purpose.

Yes. And follows power sag.
Title: Re: LM386 softer clipping
Post by: Vivek on September 28, 2021, 04:16:59 AM
YES !!!!

Follows power sag !!!

I remember your idea to put a resistor in series with power supply going to Opamp, to get power sag in the traditional way

+ your comment that LM386 has variable current draw (especially if the load impedance is low)
Title: Re: LM386 softer clipping
Post by: Clint Eastwood on February 05, 2022, 02:49:29 PM
Here is my attempt:

(https://i.postimg.cc/34S8bFyP/lm386-schem.png) (https://postimg.cc/34S8bFyP)

And here the waveform it creates:


(https://i.postimg.cc/5XdxG00N/lm386-soft.png) (https://postimg.cc/5XdxG00N)

The waveform clips asymmetrically, because the spice simulation has the output dc voltage not halfway the supply, but at 5.2 volts.
you can get softer clipping by lowering the led voltage drop,  using pairs of one green and one red led, or two red leds.
Title: Re: LM386 softer clipping
Post by: PRR on February 05, 2022, 03:59:00 PM
Quote from: Clint Eastwood on February 05, 2022, 02:49:29 PM....the spice simulation has the output dc voltage not halfway the supply, but at 5.2 volts.

If you look at the internal circuit, that is probably correct. Asymmetric clipping hardly affects the perceived loudness of a pocket radio.

Has anybody tried running on 3V supply with <4 Ohm load? Marginally beyond spec? Not as a loudspeaker driver but as an in-line flavor box? The natural curvatures are in the few-tenths-Volt range, so may stand out more at few-volt than with 9V or 12V supply.
Title: Re: LM386 softer clipping
Post by: Clint Eastwood on April 09, 2023, 07:27:01 AM
More than a year ago I posted reply #43 here, but I cheered too early. It worked fine in my simulator, but in practice it oscillated badly. So I abandonded the topic, and then a while ago ended up rereading the thread. I found the idea posted by Vivek interesting, clipping diodes referenced to the power supply. I have come up with this practical circuit:

(https://i.postimg.cc/8s4xyB9w/LM386softclip.jpg) (https://postimg.cc/8s4xyB9w)

This time the circuit has been tried and tested, and it works very well. Normally, an LM386 amp sounds a bit too harsh to my ears when cranked up, with the diode clipping you can tame it. Changing the values of R7 and R9 will alter the moment when the clipping starts, higher values make the clipping start earlier. The ratio between R8 and R3/R6 affects the softness of the clipping.
Early clipping of course means you have less clean headroom, I think I will make a switch between C3 and -in so I can turn the diode clipping on/off. Or even a dual gang pot to substitute R7 and R9.
The value of C3 also shapes the sound, lower values mean less low frequencies are clipped. I have put a Jfet buffer in front, although I  am not convinced it is really necessary. Without it, I did not hear much difference. C2 and R1 determine the amount of bass that gets into the amp, it is important to pick the right value for C2 to get the sound you like. A good upgrade would be to make a variable bass cut.
I can really recommend tinkering with this idea, the sound possibilities with different component values are endless.
Any comments/improvements are very welcome of course!




Title: Re: LM386 softer clipping
Post by: Rob Strand on April 09, 2023, 05:38:10 PM
QuoteMore than a year ago I posted reply #43 here, but I cheered too early. It worked fine in my simulator, but in practice it oscillated badly. So I abandonded the topic, and then a while ago ended up rereading the thread. I found the idea posted by Vivek interesting, clipping diodes referenced to the power supply. I have come up with this practical circuit:
The new config doesn't oscillate because the 10k + 470 ohm resistors set the gain to approx 20 and the LM386 is still stable with that gain.   Before it clips the gain is 200 and when it clips the gain drops so 20, so you get a gain switch type soft clipper.  The 10k + 33k sets the voltage where the knee is between the two gains.

The only thing that looks odd is the short on pins 1 and 8 as it will affect the DC bias at the output.  Normally you put a cap there.  For a distorter it might be OK.


It occurred to me later a large-ish cap between the LM386 output and the node where the 2x10k meet would help the clipper act symmetrically.  At the moment the DC offset from Vcc/2 at the output pushes the clipper to one side of clipping even with no signal.
Title: Re: LM386 softer clipping
Post by: Clint Eastwood on April 10, 2023, 07:58:12 AM
Hi Rob,

The datasheet shows closed loop gain should be at least 10 for stability, so R3 and R6 should be at least 10 times larger than R8.

About the capacitor between pin 1 and 8, it should be there to get half supply dc at the output. However, most LM386 guitar amp schematics  don't use a cap here, and the (deliberate?) result is asymmetrical clipping. And that sounds good to me actually.
But it is more elegant I guess to use the capacitor and get asymmetrical clipping by choosing differing values for R7 and R9. Also, that way you have a bit more clean headroom without the diode clipper.
Thank you for originally posting this idea!
Title: Re: LM386 softer clipping
Post by: Rob Strand on April 10, 2023, 06:27:01 PM
Upfront, I only mentioned those things because the LM386 has some slight quirks compared to the original circuit Vivek posted.  The slight lack of symmetry being the main one.

QuoteThe datasheet shows closed loop gain should be at least 10 for stability, so R3 and R6 should be at least 10 times larger than R8.
Yep, 10 would be a good target.  (One of the datasheets actually states the minimum stable gain.)

QuoteAbout the capacitor between pin 1 and 8, it should be there to get half supply dc at the output. However, most LM386 guitar amp schematics  don't use a cap here, and the (deliberate?) result is asymmetrical clipping. And that sounds good to me actually.
I suspect it started off by skimping parts and people found it sounded OK.   There's no rules for a distorter.

Despite what the datasheet implies when pins 1 and 8 are open (or you have a cap across them) the output doesn't quite bias at Vcc/2 anyway.  It's more like Vcc/2 + 0.7, a little above Vcc/2.  With pins 1 and 8 short the output biases at about Vcc/2 + 1.1V, so more offset.

QuoteBut it is more elegant I guess to use the capacitor and get asymmetrical clipping by choosing differing values for R7 and R9. Also, that way you have a bit more clean headroom without the diode clipper.
It's certainly possible.   I had a look at the effect of the bias offset on the soft-clipper thresholds with pins 1 and 8 shorted and it didn't shift them much.  So pins 1 and 8 is mainly affecting the overall LM386 behaviour.

FYI, it is possible to bias the LM386 at Vcc/2.   I don't think the trick is well known.  One method is a resistor from pin 1 to Vcc, perhaps around 180k.   Another is a resistor from pin 7 to ground, perhaps around 47k.     I prefer the second method but I didn't spend enough time on it to make a good judgement (and it's largely of academic interest.)   If you wanted deliberately adjust the asymmetry of the *LM386* then either of these ideas would work  - an adjustable scheme might favour the first method.

In the recent Ebow thread I made an LM386 spice model and played with the idea.  However, I know my spice model wasn't tuned to model the supply current vs Vcc or the PSRR.   I know what the problem is but need to spend time fixing it without breaking something.


You did well sticking with it by the way!
Title: Re: LM386 softer clipping
Post by: brett on April 11, 2023, 01:29:05 AM
Hi.  One of the 'problems' is that LM386 amps put out a LOT more power and have hard clipping when run from low-impedance power supplies. 

Consider that the LM386 can put out almost 1 W into 4 ohms when supplied with 9V and 0 ohms impedance. 

But if we supply it from an alkaline battery with (guessing) 10 ohms of internal resistance and there's double the resistance in the source as there is in the output. Instead of 2V of output into 4 ohms (1 W) there's barely 0.5 V into 4 ohms (0.25 W).  It only happens at full power. It's quite a lot of compression (and distortion, because it's clipping) of the output, and in my opinion, sounds really good.  (Valve amp guys would be right to think that valve-rectifiers gave 'sag', crunchy clipping and heaps of compression.  Same deal with a battery-powered LM386?).

I haven't powered my LM386 amp from an old zinc-carbon battery with high internal resistance, but I've slipped a 47 ohm resistor in the supply line.  It's so quiet that it's not a practical option. Flat out, the power will be about 0.05 W.  I have a nice valve amp that puts out just 0.2 W, but 0.05 is probably too low.  And it didn't break up in a particularly nice way.  On the other hand, a 4.7 ohm resistor cut a little power and seemed to partly 'do the trick' (very subjectively).  Pity I don't have a scope to see what's going on.

If I was set up to do it, I'd be interested to see how batteries response to intermittent loads.  Does their internal resistance stay low for a while, then rise?  So far, the battery 'simulators' designed by various people haven't attracted interest, because 1. they get used with pedals having high supply impedance (eg 10,000 ohms vs 8 ohms for an LM 386) where they clearly don't do anything and 2, they're mostly very simple (added resistance) so might not behave like batteries when used in high-current devices where batteries probably do have some effects.

Please excuse the long story.  A topic that's been on my mind for 20 years, where I've done just a little experimentation.
Title: Re: LM386 softer clipping
Post by: Rob Strand on April 11, 2023, 05:51:33 PM
QuoteIf I was set up to do it, I'd be interested to see how batteries response to intermittent loads.  Does their internal resistance stay low for a while, then rise?  So far, the battery 'simulators' designed by various people haven't attracted interest, because 1. they get used with pedals having high supply impedance (eg 10,000 ohms vs 8 ohms for an LM 386) where they clearly don't do anything and 2, they're mostly very simple (added resistance) so might not behave like batteries when used in high-current devices where batteries probably do have some effects.

The problem you mentioned is "normal" for power amplifiers but it is especially bad on 9V batteries.   Even large transformers sag to some extent.  I'm not fond using 9V for any high-power applications, they just aren't suited for it and the effective battery life is poor.   Alkalines help enormously.

A common trick for pulse loads with batteries is to put large caps across the supply rails.    This idea also works for squeezing the most battery life out of low-power applications - although for very low power applications the leakage of the cap can exceed the average drain of the circuit!     Some years back semiconductor manufacturers had applications notes showing pulse loads and the effect of adding supply caps.   IIRC for lithium button cells.

Here's one but there might be more,
https://www.ti.com/lit/wp/swra349/swra349.pdf

Title: Re: LM386 softer clipping
Post by: brett on April 12, 2023, 04:06:47 AM
Quote from: PRR on February 05, 2022, 03:59:00 PM
Has anybody tried running on 3V supply with <4 Ohm load? Marginally beyond spec? Not as a loudspeaker driver but as an in-line flavor box? The natural curvatures are in the few-tenths-Volt range, so may stand out more at few-volt than with 9V or 12V supply.

An alkaline battery has 5 to 25 ohms of internal resistance.  An LM386 only has a few ohms of emitter resistance and a 4 ohm speaker for a load.  So 4, 5 or even 6 volts of the supply might be lost when an LM386 is at max power when using a battery.

Again, I think this is part of the great tone of an LM386 driven hard, powered off a battery.  Louder, but not as great tone with a regulated power supply.

FWIW, for clipping, at the output I've added anti-parallel 1N4007 diodes to ground in series with an 8 ohm resistor. Works fine.
Title: Re: LM386 softer clipping
Post by: Clint Eastwood on April 12, 2023, 08:06:23 AM
I use a Nimh rechargeable battery, wich apparently has 1 or 2 ohms internal resistance. If i wanted to mimick the behaviour of an alkaline battery, is it enough to add a 10-20 ohm series resistor or is there more to it?
Title: Re: LM386 softer clipping
Post by: PRR on April 12, 2023, 08:32:30 PM
> is there more to it?

http://www.muzique.com/lab/batteryz.htm
Title: Re: LM386 softer clipping
Post by: Rob Strand on April 13, 2023, 12:05:10 AM
Quote from: Clint Eastwood on April 12, 2023, 08:06:23 AM
I use a Nimh rechargeable battery, wich apparently has 1 or 2 ohms internal resistance. If i wanted to mimick the behaviour of an alkaline battery, is it enough to add a 10-20 ohm series resistor or is there more to it?

The resistance varies over the life of the battery.   For a 9V alkaline it might start off around 1 to 5 ohm but as the battery is used the resistance increases.   Under normal circumstances the end-of-life resistance for a 9V alkaline might be 10 to 20 ohm.  There's no single figure but 7 ohm resistance would be something in the middle.   The common heavy duty zinc-carbon types have much a higher resistance when new.

You can do slightly better with this type of circuit but it's still an over simplification; ignore the inductor.   Where Rct+Ro is the DC resistance and Ro is the AC resistance.   The AC resistance might be say 1/7th the DC resistance.
(https://www.researchgate.net/publication/286486268/figure/fig11/AS:668708892585999@1536444032754/The-simplified-Li-ion-battery-AC-impedance-model.png)
Title: Re: LM386 softer clipping
Post by: brett on April 13, 2023, 03:20:14 AM
Rob Strand said "For a 9V alkaline it might start off around 1 to 5 ohm but as the battery is used the resistance increases."

Thanks!  I had believed it was greater.  Hence with a 47 ohm series resistor I'd reduced the voltage and power to very low levels.   4.7 ohms was better, and now it's obvious why.  Next build will be a filter cap then 2.2 ohms. At 0.1 A, that's 2.2 V "thrown away".  Seems about right.
Title: Re: LM386 softer clipping
Post by: Rob Strand on April 13, 2023, 05:54:16 AM
Quote from: brett on April 13, 2023, 03:20:14 AM
Rob Strand said "For a 9V alkaline it might start off around 1 to 5 ohm but as the battery is used the resistance increases."

Thanks!  I had believed it was greater.  Hence with a 47 ohm series resistor I'd reduced the voltage and power to very low levels.   4.7 ohms was better, and now it's obvious why.  Next build will be a filter cap then 2.2 ohms. At 0.1 A, that's 2.2 V "thrown away".  Seems about right.

For alkaline 47 ohm is would be quite high.   However for new/newish batteries there's a lot of variation.  I wouldn't flinch much if I saw 10 ohm when new and 30 ohm at end of discharge which would make the middle in the 15 ohm to 20 ohm.  If you are driving an 8 ohm speaker the effect is quite a bit stronger than my 7 ohm.   In operation you might not get to 30 ohm which brings the actual "middle" down a bit.

The results can vary depending on the battery and how the test is done.   Different loads can imply a different battery resistance.   If you base your numbers on Rbat = (Vopen - Vloaded)/Iload  you might see a different Rbat for different loads.   Using the open circuit voltage can introduce quite a bit of variation.   Under load the voltage keeps changing so at what point do you make the measurement?   Another way to measure the DC resistance is incrementally using the voltage drop between two loads, one low current and one high current, then from that infer the (estimated) open circuit voltage and resistance.     They all give different numbers for Rbat, you might see a factor of 2 variation!
Title: Re: LM386 softer clipping
Post by: Rob Strand on April 13, 2023, 11:48:27 PM
Here's some manufacturer's data and some real measurements:
(https://i.postimg.cc/cgDQh247/Duracell-9-V-Alkaline-Internal-Resistance-and-Measurements.png) (https://postimg.cc/cgDQh247)

The manufacturer gives an DC resistance plot and an AC resistance spec.  The DC resistance spans 2.2 ohm to 4.1 ohm over the discharge period.   The AC resistance is always less than the DC resistance.

The measured "new" batteries have somewhat higher DC resistance than the manufacturer's data.   The DC resistance was about 8.5 ohm and was quite consistent across three batteries.

The depleted battery has a DC resistance of 21 ohm and a lower open circuit voltage.

I've given the directly measured open circuit voltage and the estimated open circuit voltage based on fitting a line to two load currents.   The measured open circuit voltage tends to be higher then the estimated due to non-linear behaviour of the battery.

In reply #35 of this thread,
https://www.diystompboxes.com/smfforum/index.php?topic=76150
I did a similar study on an Energizer Alkaline battery.  Very similar results to my Duracell measurements.
Title: Re: LM386 softer clipping
Post by: Steben on April 14, 2023, 11:16:27 AM
Well.... isn't this reproducable with a resistor in series to the supply line of non-battery regulated source?
It will introduce some sag due tot the variable current draw of the LM386.

But will it soften the clipping?

The datasheet gives quite a soft onset of distortion. I guess this with max gain setting. The min setting probably will yield an onset more abruptly as any bigger amount of negative feedback would?
(https://www.ti.com/diagrams/custom_diagram_1_LM386.gif)
Title: Re: LM386 softer clipping
Post by: mac on April 18, 2023, 01:08:25 PM
Maybe it's a lot of work and the schematics are incomplete,
but what about a kind of "Joe Davisson's Diode Compression Discrete LM386"?

(https://www.diystompboxes.com/analogalchemy/sch/diodeopamp.gif)

Something like this ... ??

(https://i.postimg.cc/CKqPH4qX/LM386-diode-compression.png) (https://postimages.org/)

#2 can interfere with bias

mac