LM386 motorboating that goes away with a resistor in parallel with the bypass capacitor on pin 7












4














I'm building a simple amplifier around a LM386. The circuit I'm using is this:





The input is on pin 1 of the connector and is a square wave coming from a digital pin on a NodeMCU devboard.



When I turn the circuit on, I can hear a low frequency oscilation on the speakers (not a constant tone, but as if the speaker was turned on and off a few times a second).



I tried adding a capacitor between the signal and ground as it seemed to work in this related question but I needed a fairly big capacitor (220uF) to get any result at all, and it only decreased the volume of the noise (not to mention it is filtering my input, if I understand it correctly).



What did get rid of the noise completely was adding a 1K resistor between pin 7 and ground (in parallel with the existing capacitor):





I have no idea why this works, but it gets rid of the noise completely.



So my main question is: what is this resistor in parallel with the capacitor doing and why does this remove the noise?



I'm happy to keep this solution if it makes sense, but first I need to understand why it works.










share|improve this question









New contributor




Flávio Amieiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2




    What you describe sounds like motorboating.
    – brhans
    2 days ago










  • What sort of 9V battery are you using and do you have anything other than that 100nF C4 for supply decoupling?
    – brhans
    2 days ago






  • 2




    R2 is not a good solution - it fouls up the DC biasing internally, which limits the available undistorted audio output power. Look at DC voltage on pin 5: it should be about half the supply, near +4.5V. I'll bet its a lot lower. Try increasing C4 instead to a very large capacitor > 200uF.
    – glen_geek
    2 days ago












  • Use one of the circuits in the data sheet.
    – Leon Heller
    2 days ago










  • thank you @brhans it does sound like that. I'll edit the question to make it clearer.
    – Flávio Amieiro
    2 days ago
















4














I'm building a simple amplifier around a LM386. The circuit I'm using is this:





The input is on pin 1 of the connector and is a square wave coming from a digital pin on a NodeMCU devboard.



When I turn the circuit on, I can hear a low frequency oscilation on the speakers (not a constant tone, but as if the speaker was turned on and off a few times a second).



I tried adding a capacitor between the signal and ground as it seemed to work in this related question but I needed a fairly big capacitor (220uF) to get any result at all, and it only decreased the volume of the noise (not to mention it is filtering my input, if I understand it correctly).



What did get rid of the noise completely was adding a 1K resistor between pin 7 and ground (in parallel with the existing capacitor):





I have no idea why this works, but it gets rid of the noise completely.



So my main question is: what is this resistor in parallel with the capacitor doing and why does this remove the noise?



I'm happy to keep this solution if it makes sense, but first I need to understand why it works.










share|improve this question









New contributor




Flávio Amieiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2




    What you describe sounds like motorboating.
    – brhans
    2 days ago










  • What sort of 9V battery are you using and do you have anything other than that 100nF C4 for supply decoupling?
    – brhans
    2 days ago






  • 2




    R2 is not a good solution - it fouls up the DC biasing internally, which limits the available undistorted audio output power. Look at DC voltage on pin 5: it should be about half the supply, near +4.5V. I'll bet its a lot lower. Try increasing C4 instead to a very large capacitor > 200uF.
    – glen_geek
    2 days ago












  • Use one of the circuits in the data sheet.
    – Leon Heller
    2 days ago










  • thank you @brhans it does sound like that. I'll edit the question to make it clearer.
    – Flávio Amieiro
    2 days ago














4












4








4







I'm building a simple amplifier around a LM386. The circuit I'm using is this:





The input is on pin 1 of the connector and is a square wave coming from a digital pin on a NodeMCU devboard.



When I turn the circuit on, I can hear a low frequency oscilation on the speakers (not a constant tone, but as if the speaker was turned on and off a few times a second).



I tried adding a capacitor between the signal and ground as it seemed to work in this related question but I needed a fairly big capacitor (220uF) to get any result at all, and it only decreased the volume of the noise (not to mention it is filtering my input, if I understand it correctly).



What did get rid of the noise completely was adding a 1K resistor between pin 7 and ground (in parallel with the existing capacitor):





I have no idea why this works, but it gets rid of the noise completely.



So my main question is: what is this resistor in parallel with the capacitor doing and why does this remove the noise?



I'm happy to keep this solution if it makes sense, but first I need to understand why it works.










share|improve this question









New contributor




Flávio Amieiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm building a simple amplifier around a LM386. The circuit I'm using is this:





The input is on pin 1 of the connector and is a square wave coming from a digital pin on a NodeMCU devboard.



When I turn the circuit on, I can hear a low frequency oscilation on the speakers (not a constant tone, but as if the speaker was turned on and off a few times a second).



I tried adding a capacitor between the signal and ground as it seemed to work in this related question but I needed a fairly big capacitor (220uF) to get any result at all, and it only decreased the volume of the noise (not to mention it is filtering my input, if I understand it correctly).



What did get rid of the noise completely was adding a 1K resistor between pin 7 and ground (in parallel with the existing capacitor):





I have no idea why this works, but it gets rid of the noise completely.



So my main question is: what is this resistor in parallel with the capacitor doing and why does this remove the noise?



I'm happy to keep this solution if it makes sense, but first I need to understand why it works.







amplifier lm386






share|improve this question









New contributor




Flávio Amieiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Flávio Amieiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago





















New contributor




Flávio Amieiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Flávio Amieiro

1235




1235




New contributor




Flávio Amieiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Flávio Amieiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Flávio Amieiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2




    What you describe sounds like motorboating.
    – brhans
    2 days ago










  • What sort of 9V battery are you using and do you have anything other than that 100nF C4 for supply decoupling?
    – brhans
    2 days ago






  • 2




    R2 is not a good solution - it fouls up the DC biasing internally, which limits the available undistorted audio output power. Look at DC voltage on pin 5: it should be about half the supply, near +4.5V. I'll bet its a lot lower. Try increasing C4 instead to a very large capacitor > 200uF.
    – glen_geek
    2 days ago












  • Use one of the circuits in the data sheet.
    – Leon Heller
    2 days ago










  • thank you @brhans it does sound like that. I'll edit the question to make it clearer.
    – Flávio Amieiro
    2 days ago














  • 2




    What you describe sounds like motorboating.
    – brhans
    2 days ago










  • What sort of 9V battery are you using and do you have anything other than that 100nF C4 for supply decoupling?
    – brhans
    2 days ago






  • 2




    R2 is not a good solution - it fouls up the DC biasing internally, which limits the available undistorted audio output power. Look at DC voltage on pin 5: it should be about half the supply, near +4.5V. I'll bet its a lot lower. Try increasing C4 instead to a very large capacitor > 200uF.
    – glen_geek
    2 days ago












  • Use one of the circuits in the data sheet.
    – Leon Heller
    2 days ago










  • thank you @brhans it does sound like that. I'll edit the question to make it clearer.
    – Flávio Amieiro
    2 days ago








2




2




What you describe sounds like motorboating.
– brhans
2 days ago




What you describe sounds like motorboating.
– brhans
2 days ago












What sort of 9V battery are you using and do you have anything other than that 100nF C4 for supply decoupling?
– brhans
2 days ago




What sort of 9V battery are you using and do you have anything other than that 100nF C4 for supply decoupling?
– brhans
2 days ago




2




2




R2 is not a good solution - it fouls up the DC biasing internally, which limits the available undistorted audio output power. Look at DC voltage on pin 5: it should be about half the supply, near +4.5V. I'll bet its a lot lower. Try increasing C4 instead to a very large capacitor > 200uF.
– glen_geek
2 days ago






R2 is not a good solution - it fouls up the DC biasing internally, which limits the available undistorted audio output power. Look at DC voltage on pin 5: it should be about half the supply, near +4.5V. I'll bet its a lot lower. Try increasing C4 instead to a very large capacitor > 200uF.
– glen_geek
2 days ago














Use one of the circuits in the data sheet.
– Leon Heller
2 days ago




Use one of the circuits in the data sheet.
– Leon Heller
2 days ago












thank you @brhans it does sound like that. I'll edit the question to make it clearer.
– Flávio Amieiro
2 days ago




thank you @brhans it does sound like that. I'll edit the question to make it clearer.
– Flávio Amieiro
2 days ago










2 Answers
2






active

oldest

votes


















6














The main problem is that you have the gain of the LM386 set much too high.



By putting a capacitor (C1) between pin 1 and 8 you have set the gain to 200 times. If the input signal is coming straight from a digital pin on the processor with 3.3V output you only need a gain of 2 at most.



With a gain of 200 the LM386 is amplifying small signals coming from the digital pin to an audible level.



Even if you remove C1 the gain will still be 20 times - you will need to attenuate the signal from the processor by about 10-11 times to avoid overloading the amplifier. A 10k resistor in series with the input and a 1k resistor to ground will achieve that. Even better would be a potentiometer to adjust the volume.



Your current solution is drastically altering the biasing of the LM386 such that it is not a linear amplifier, the digital signal is still able to break through the LM386 to drive the speaker. Please see page 1 of the data sheet LM386 datasheet



If you only need to drive the speaker with a square wave then you may not even need an amplifier. For low volume just a capacitor and resistor in series driving the speaker will function (for example a 47 ohm resistor and a 10uF capacitor). The resistor is to avoid overloading the digital output with the low resistance of the speaker while the capacitor removes the DC offset since the digital output is always positive (either 0V or 3.3V).






share|improve this answer























  • Thank you for your answer! Attenuating the input and reducing the gain to 20 (by removing C1) did help a lot. I can still hear the motorboating, but it is very faint. I had tried other simpler solutions, but I didn't get the volume I need. Also, the signal is a square wave for now, for testing, but that will definitely change in the future. My main problem is that I need it to be very loud (as loud as possible), even if that comes at the expense of sound quality. Removing C1 also did noticeably reduce the volume, which I want to avoid.
    – Flávio Amieiro
    2 days ago



















1














You have 3 grounds the circuit:



the speaker ground



pins 4.3.2 ground (3 is where the 10K ohm attached to GND)



the RETURN of the 9v power
[which need to be tied together with heavy heavy wire]



and



(#4) the -pin of a 10,000 uF capacitor across the 9v power supply



You do have the 10,000uF bypass cap???






share|improve this answer





















    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("schematics", function () {
    StackExchange.schematics.init();
    });
    }, "cicuitlab");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "135"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Flávio Amieiro is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f413891%2flm386-motorboating-that-goes-away-with-a-resistor-in-parallel-with-the-bypass-ca%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    6














    The main problem is that you have the gain of the LM386 set much too high.



    By putting a capacitor (C1) between pin 1 and 8 you have set the gain to 200 times. If the input signal is coming straight from a digital pin on the processor with 3.3V output you only need a gain of 2 at most.



    With a gain of 200 the LM386 is amplifying small signals coming from the digital pin to an audible level.



    Even if you remove C1 the gain will still be 20 times - you will need to attenuate the signal from the processor by about 10-11 times to avoid overloading the amplifier. A 10k resistor in series with the input and a 1k resistor to ground will achieve that. Even better would be a potentiometer to adjust the volume.



    Your current solution is drastically altering the biasing of the LM386 such that it is not a linear amplifier, the digital signal is still able to break through the LM386 to drive the speaker. Please see page 1 of the data sheet LM386 datasheet



    If you only need to drive the speaker with a square wave then you may not even need an amplifier. For low volume just a capacitor and resistor in series driving the speaker will function (for example a 47 ohm resistor and a 10uF capacitor). The resistor is to avoid overloading the digital output with the low resistance of the speaker while the capacitor removes the DC offset since the digital output is always positive (either 0V or 3.3V).






    share|improve this answer























    • Thank you for your answer! Attenuating the input and reducing the gain to 20 (by removing C1) did help a lot. I can still hear the motorboating, but it is very faint. I had tried other simpler solutions, but I didn't get the volume I need. Also, the signal is a square wave for now, for testing, but that will definitely change in the future. My main problem is that I need it to be very loud (as loud as possible), even if that comes at the expense of sound quality. Removing C1 also did noticeably reduce the volume, which I want to avoid.
      – Flávio Amieiro
      2 days ago
















    6














    The main problem is that you have the gain of the LM386 set much too high.



    By putting a capacitor (C1) between pin 1 and 8 you have set the gain to 200 times. If the input signal is coming straight from a digital pin on the processor with 3.3V output you only need a gain of 2 at most.



    With a gain of 200 the LM386 is amplifying small signals coming from the digital pin to an audible level.



    Even if you remove C1 the gain will still be 20 times - you will need to attenuate the signal from the processor by about 10-11 times to avoid overloading the amplifier. A 10k resistor in series with the input and a 1k resistor to ground will achieve that. Even better would be a potentiometer to adjust the volume.



    Your current solution is drastically altering the biasing of the LM386 such that it is not a linear amplifier, the digital signal is still able to break through the LM386 to drive the speaker. Please see page 1 of the data sheet LM386 datasheet



    If you only need to drive the speaker with a square wave then you may not even need an amplifier. For low volume just a capacitor and resistor in series driving the speaker will function (for example a 47 ohm resistor and a 10uF capacitor). The resistor is to avoid overloading the digital output with the low resistance of the speaker while the capacitor removes the DC offset since the digital output is always positive (either 0V or 3.3V).






    share|improve this answer























    • Thank you for your answer! Attenuating the input and reducing the gain to 20 (by removing C1) did help a lot. I can still hear the motorboating, but it is very faint. I had tried other simpler solutions, but I didn't get the volume I need. Also, the signal is a square wave for now, for testing, but that will definitely change in the future. My main problem is that I need it to be very loud (as loud as possible), even if that comes at the expense of sound quality. Removing C1 also did noticeably reduce the volume, which I want to avoid.
      – Flávio Amieiro
      2 days ago














    6












    6








    6






    The main problem is that you have the gain of the LM386 set much too high.



    By putting a capacitor (C1) between pin 1 and 8 you have set the gain to 200 times. If the input signal is coming straight from a digital pin on the processor with 3.3V output you only need a gain of 2 at most.



    With a gain of 200 the LM386 is amplifying small signals coming from the digital pin to an audible level.



    Even if you remove C1 the gain will still be 20 times - you will need to attenuate the signal from the processor by about 10-11 times to avoid overloading the amplifier. A 10k resistor in series with the input and a 1k resistor to ground will achieve that. Even better would be a potentiometer to adjust the volume.



    Your current solution is drastically altering the biasing of the LM386 such that it is not a linear amplifier, the digital signal is still able to break through the LM386 to drive the speaker. Please see page 1 of the data sheet LM386 datasheet



    If you only need to drive the speaker with a square wave then you may not even need an amplifier. For low volume just a capacitor and resistor in series driving the speaker will function (for example a 47 ohm resistor and a 10uF capacitor). The resistor is to avoid overloading the digital output with the low resistance of the speaker while the capacitor removes the DC offset since the digital output is always positive (either 0V or 3.3V).






    share|improve this answer














    The main problem is that you have the gain of the LM386 set much too high.



    By putting a capacitor (C1) between pin 1 and 8 you have set the gain to 200 times. If the input signal is coming straight from a digital pin on the processor with 3.3V output you only need a gain of 2 at most.



    With a gain of 200 the LM386 is amplifying small signals coming from the digital pin to an audible level.



    Even if you remove C1 the gain will still be 20 times - you will need to attenuate the signal from the processor by about 10-11 times to avoid overloading the amplifier. A 10k resistor in series with the input and a 1k resistor to ground will achieve that. Even better would be a potentiometer to adjust the volume.



    Your current solution is drastically altering the biasing of the LM386 such that it is not a linear amplifier, the digital signal is still able to break through the LM386 to drive the speaker. Please see page 1 of the data sheet LM386 datasheet



    If you only need to drive the speaker with a square wave then you may not even need an amplifier. For low volume just a capacitor and resistor in series driving the speaker will function (for example a 47 ohm resistor and a 10uF capacitor). The resistor is to avoid overloading the digital output with the low resistance of the speaker while the capacitor removes the DC offset since the digital output is always positive (either 0V or 3.3V).







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 2 days ago

























    answered 2 days ago









    Kevin White

    12.7k11521




    12.7k11521












    • Thank you for your answer! Attenuating the input and reducing the gain to 20 (by removing C1) did help a lot. I can still hear the motorboating, but it is very faint. I had tried other simpler solutions, but I didn't get the volume I need. Also, the signal is a square wave for now, for testing, but that will definitely change in the future. My main problem is that I need it to be very loud (as loud as possible), even if that comes at the expense of sound quality. Removing C1 also did noticeably reduce the volume, which I want to avoid.
      – Flávio Amieiro
      2 days ago


















    • Thank you for your answer! Attenuating the input and reducing the gain to 20 (by removing C1) did help a lot. I can still hear the motorboating, but it is very faint. I had tried other simpler solutions, but I didn't get the volume I need. Also, the signal is a square wave for now, for testing, but that will definitely change in the future. My main problem is that I need it to be very loud (as loud as possible), even if that comes at the expense of sound quality. Removing C1 also did noticeably reduce the volume, which I want to avoid.
      – Flávio Amieiro
      2 days ago
















    Thank you for your answer! Attenuating the input and reducing the gain to 20 (by removing C1) did help a lot. I can still hear the motorboating, but it is very faint. I had tried other simpler solutions, but I didn't get the volume I need. Also, the signal is a square wave for now, for testing, but that will definitely change in the future. My main problem is that I need it to be very loud (as loud as possible), even if that comes at the expense of sound quality. Removing C1 also did noticeably reduce the volume, which I want to avoid.
    – Flávio Amieiro
    2 days ago




    Thank you for your answer! Attenuating the input and reducing the gain to 20 (by removing C1) did help a lot. I can still hear the motorboating, but it is very faint. I had tried other simpler solutions, but I didn't get the volume I need. Also, the signal is a square wave for now, for testing, but that will definitely change in the future. My main problem is that I need it to be very loud (as loud as possible), even if that comes at the expense of sound quality. Removing C1 also did noticeably reduce the volume, which I want to avoid.
    – Flávio Amieiro
    2 days ago













    1














    You have 3 grounds the circuit:



    the speaker ground



    pins 4.3.2 ground (3 is where the 10K ohm attached to GND)



    the RETURN of the 9v power
    [which need to be tied together with heavy heavy wire]



    and



    (#4) the -pin of a 10,000 uF capacitor across the 9v power supply



    You do have the 10,000uF bypass cap???






    share|improve this answer


























      1














      You have 3 grounds the circuit:



      the speaker ground



      pins 4.3.2 ground (3 is where the 10K ohm attached to GND)



      the RETURN of the 9v power
      [which need to be tied together with heavy heavy wire]



      and



      (#4) the -pin of a 10,000 uF capacitor across the 9v power supply



      You do have the 10,000uF bypass cap???






      share|improve this answer
























        1












        1








        1






        You have 3 grounds the circuit:



        the speaker ground



        pins 4.3.2 ground (3 is where the 10K ohm attached to GND)



        the RETURN of the 9v power
        [which need to be tied together with heavy heavy wire]



        and



        (#4) the -pin of a 10,000 uF capacitor across the 9v power supply



        You do have the 10,000uF bypass cap???






        share|improve this answer












        You have 3 grounds the circuit:



        the speaker ground



        pins 4.3.2 ground (3 is where the 10K ohm attached to GND)



        the RETURN of the 9v power
        [which need to be tied together with heavy heavy wire]



        and



        (#4) the -pin of a 10,000 uF capacitor across the 9v power supply



        You do have the 10,000uF bypass cap???







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        analogsystemsrf

        13.6k2716




        13.6k2716






















            Flávio Amieiro is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Flávio Amieiro is a new contributor. Be nice, and check out our Code of Conduct.













            Flávio Amieiro is a new contributor. Be nice, and check out our Code of Conduct.












            Flávio Amieiro is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Electrical Engineering Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f413891%2flm386-motorboating-that-goes-away-with-a-resistor-in-parallel-with-the-bypass-ca%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Human spaceflight

            Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

            張江高科駅