LM386 - LTSpice Simulation

Discussion in 'Programmer's Corner' started by vol_, Feb 28, 2016.

  1. vol_

    Thread Starter Member

    Dec 2, 2015
    93
    3
    Hello everyone!

    I simulate a LM386 circuit in LTSpice and I'm getting almost the right output dc offset voltage (+5V), but the frequency response I get as result can't be right. The amplifier amplifies up to 0dB... I run a transient response analysis with Vin (dc offset=0V, Amplitude=50mV, f=1kHz) and an ac analysis with Vin (small ac signal of 50mV).

    I attach all the files of the circuit..

    Actually allcircuits.com has forbidden extensions, so I attach the model that i created and the test circuit schematic. The ltspice model for lm386 lays here:

    http://softsolder.com/2009/09/29/adding-a-device-to-ltspiceiv/.

    Thanks!
     
  2. eetech00

    Active Member

    Jun 8, 2013
    650
    112
    Hi

    Try this model
     
    vol_ likes this.
  3. Bordodynov

    Active Member

    May 20, 2015
    638
    188
    See error C1=0,01uF ==> C1=0.01uF. "," not "."
     
  4. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,310
    885
    That LTSpice model is derived from the original "No Frills" LM386 PSpice model I created back in 1995 and posted to the sci.electronics Usenet group. The original post (see here) contained a lot of design information, which was omitted in the version you are using. As the notes explain, the frequency response of this model deviates significantly from actual device behavior, so your results are not surprising. The notes also suggest ways to "tweak" the model to bring it into better conformance with actual LM386 behavior.
     
    thumb2, JohnInTX and tracecom like this.
  5. vol_

    Thread Starter Member

    Dec 2, 2015
    93
    3
    I am using this model. Its the same. I didnt check for minor differrences, but the have the same root for sure..
     
  6. eetech00

    Active Member

    Jun 8, 2013
    650
    112
    They are not the same.

    I couldn't get the one you were using to work correctly.
     
  7. vol_

    Thread Starter Member

    Dec 2, 2015
    93
    3
    Yes they are not the same. Thanks!
     
  8. vol_

    Thread Starter Member

    Dec 2, 2015
    93
    3
    Well, eetech00 the model you passed to me behaves much better for the frequency response of the chip (this is about the AC analysis in LTSpice), but again the results are in minus deciBells.. Why is this? Should i try to choose different reference than the ground? Or what? Is it happening?... This is a problem that also existed in the model i used before .

    Also for the Transient analysis what i dont get is that the output swing is 2V peak-to-peak, with a bias of 5V only before the output coupling capacitor. After the cap the bias voltage is 0V. This is again a prob that also existed in the model i used before. So i think something is wrong with my settings. Specially with minus dB gain results..

    I m sending screenshots of the LTSpice simulation. The bottom screens (lm386-testv01.PNG and
    lm386-testv01-graphic.PNG) are for the transient analysis and the lm386-testv01-graphic-ac_analysis.PNG is for the frequency response. For the plot image the green line is measured gnd referenced after the output coupling capacitor, the blue before the output cap and the red is for the input signal. I m also sending the file of the schematic (.asc) for the new model eetech00 sent.

    Cheers!
     
    Last edited: Mar 2, 2016
  9. vol_

    Thread Starter Member

    Dec 2, 2015
    93
    3
    And the very weird think is that the gain also has in absolute numbers its correct value. I m getting -22 dB and what i expect is 20 dB. A good result but inverted. So probably this is a good model, but smthing is wrong with my settings..

    Thankzzz
     
  10. Bordodynov

    Active Member

    May 20, 2015
    638
    188
    You do not have fixed the value of the capacitor, as I pointed out. Instead, point your comma. I calculated the your schema. It turned 24 dB and 180 degrees. I used a different symbol.

    See

    LM386-testV01new.png
     
  11. vol_

    Thread Starter Member

    Dec 2, 2015
    93
    3
    Actually, as i understand, what was wrong was the 50mV small AC signal at the input. For 1V value i got what bordodynov got as a result. But why is there such a big difference? Why LTSpice needs 1V ac small signal and 50mV ac small signal drive me to negative gain results?
     
  12. Bordodynov

    Active Member

    May 20, 2015
    638
    188
    Again=Vout/Vin , Vin=1 → Again=Vout.
     
  13. eetech00

    Active Member

    Jun 8, 2013
    650
    112
    Hi:)

    I don't know if your still interested, but I found and modified the no-frills LM386 model mentioned by OBW0549.
    I believe it correctly models the input bias current and quiescent supply current now. If your interested in testing the model, let me know.

    Also,

    I believe the built in AC analysis FRA in LTspice relies on a 1v RMS input representing 0db. If you use a different input voltage level, it messes up the results (I might be incorrect on this, but I didn't spend a lot of time trying to make it work:(). You can still do the analysis using a different input voltage, but you have to use custom graphs. There is a way to do this in transient mode but it takes a really long time to simulate.;)

    Anyhow...let me know if you would like to test the LM386 model.:cool:
     
    vol_ likes this.
  14. crutschow

    Expert

    Mar 14, 2008
    13,014
    3,234
    LTspice calculates all the dB measurement values in the AC analysis using 1V as the reference (thus 1V equals 0dB).
    Thus if you use anything other than 1V for the input, the dB gain values will be off by the dB difference between the value you used and 1V.
    Using 1V is okay, even if the amp can't tolerate 1V input for the Transient Analysis because the AC analysis assumes a linear transfer function for the amplifier, independent of the value of the AC signal voltage.
     
    vol_ likes this.
  15. eetech00

    Active Member

    Jun 8, 2013
    650
    112
    Hi

    Thanks for that clarification crutschow. I'm sure other LTspice uses have struggled performing FRA without knowing that.

    thanks
     
    vol_ likes this.
  16. dannyf

    Well-Known Member

    Sep 13, 2015
    1,811
    362
    Because your source is 50mv. 0db = 1v, so the amp's gain is 1v/50mv=20x.

    To confirm, you can click on the 50mvac source and see its "db".
     
  17. vol_

    Thread Starter Member

    Dec 2, 2015
    93
    3
    I am using the LTspice model you send me.
    I attach the picture with the simulation and the circuitry that i'll use after all.

    Actually, i just added an RC low pass filter to the noisy cricket, with its resistor choosen at 47K to attenuate the input signal a bit. The zobel network is for a 2 inch cheap chinese speaker, that it sounds really decent for the size and price. I still dont know if i like the LM386 or not.

    Thank u all!
     
Loading...