Automatic gain control for LM386 amp based on source volume

Discussion in 'The Projects Forum' started by Predrag Beočanin, Mar 20, 2016.

  1. Predrag Beočanin

    Thread Starter New Member

    Mar 20, 2016
    8
    1
    Hello,

    I'm trying to build a VU meter, or a VU tower. As of right now, I have LM386 wired to LM3914 in the usual way. The both have a 10k potentiometer, one for fine tuning LM3914, and another for volume control of LM386. Here's the issue: the LEDs are working fine when source audio volume (PC, in this case) is at 80%. If it's 100%, all of them light up and pulse, but not go up and down, like they are supposed to. I can tune this with the potentiometer on the LM386. If the source audio volume is 40%, only the first few LEDs light up, and I can control this as well with the potentiometer on LM386. However, there is no setting that makes LEDs work fine on both 40% and 100%, which got me thinking I may need an automatic potentiometer of some sort, or anything else that may solve this problem for me? I'm open for any ideas, as long as they don't require interaction each time the volume is changed. I understand that below 30% source audio volume, the LEDs simply don't work, and they can't, but I need something to regulate the volume based on source volume, so I can "simulate" the way they work when source is at 80%.

    In case anyone needs this, here are the schematics used for both:

    LM386 http://cdn.instructables.com/FDW/YM1V/GD2JJSYJ/FDWYM1VGD2JJSYJ.MEDIUM.jpg
    LM3914 http://i.stack.imgur.com/4RpJ0.png

    That's the layout, except instead of connecting LM386 to speakers, it's output is connected to LM3914.

    Thank you for taking time to read this,
    Have a great day!
     
  2. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,998
    745
    Your lm3914 circuit is wrong, pins 4, 6 are the lower and upper limits, pin 8 is the ref adj also sets the led current, and pin7 is ref out, look at the datasheet.
     
  3. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,544
    1,251
    It sounds like you want the LEDs to display relative volume rather than absolute volume. You can google 'agc schematic' and get lots of ideas about how to do this.

    Beware - *many* circuits on Instructables are incorrect.

    ak
     
    dannyf likes this.
  4. #12

    Expert

    Nov 30, 2010
    16,334
    6,820
    Maybe like this:
     
  5. Predrag Beočanin

    Thread Starter New Member

    Mar 20, 2016
    8
    1

    @Dodgydave you're right, I had it wired differently, but I just dropped the wrong schematic here. Thank you

    @AnalogKid Awesome! I didn't know the AGC name, so I didn't know what to search for. Mostly, I use instructables for ideas, never to carbon copy work from there

    @#12 would you have an idea what to put instead of J176? Both electronics shops in my town never even heard of it, let alone offer a replacement?

    Thanks a bunch for the help guys,
    Have a great day!
     
    Dodgydave likes this.
  6. #12

    Expert

    Nov 30, 2010
    16,334
    6,820
    Not right off the top of my head, but I can tell you its a pretty sloppy IDss range from 2ma to 25ma and the cutoff voltage is -4V.
    j-fets aren't as mysterious as they seem after you play with a few. I'd say, just pick a p type j-fet with IDss of at least 2ma and check the cutoff voltage.
    There's almost no DC voltage applied to it and the schematic requirement is that you have a positive supply just about large enough to turn the j-fet off.
    I have only worked with n-type j-fets because I started when you basically couldn't buy a suitable p-type.
     
  7. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,998
    745
    Try a Bs250 pfet
     
  8. #12

    Expert

    Nov 30, 2010
    16,334
    6,820
    I don't think so. The bs250 is an enhancement mode transistor. J-fets are depletion mode.
    But the idea of using a mosfet is interesting.
     
  9. Predrag Beočanin

    Thread Starter New Member

    Mar 20, 2016
    8
    1
    Hello,

    Of course, the bs250 is readily available for almost free >.> As of right now, I have the lm386 set to boost like mad, and a 10k trimmer to set the top limit. Not the best solution, but it works. I'm going to surf through the two shops tomorrow asking them if they have a P-type JFET. If not, I guess the trimmer + decent amplification will have to do the trick.

    Thanks a lot for the help, I'll keep you updated
    Have a great day!
     
  10. ian field

    Distinguished Member

    Oct 27, 2012
    4,415
    784
    AFAIK: the LM3915 with logarithmic response was the usual thing to use for audio work.

    An alternative to the LM386 is the TDA7052 BTL amplifier - the type with A suffix has DC volume control and isn't too difficult to rig for AGC.

    You can use the BTL amp single ended, but at reduced power output.
     
  11. Predrag Beočanin

    Thread Starter New Member

    Mar 20, 2016
    8
    1
    Hey Ian,

    I'm actually open for any suggestions, but it would be nice to keep in mind limited availability of products here and my very limited knowledge. For comparisons sake, I'd know how to hook up the AGC setup posted by #12, if I could find a P-type JFET. As long as it's not super expensive or supercomplicated, I'm open for suggestions!

    Thank you so much for the help,
    Have a great day!
     
  12. Predrag Beočanin

    Thread Starter New Member

    Mar 20, 2016
    8
    1
    Hey Ian,

    [​IMG]
    Is this literally all it takes? I could use LM7805 or something to tune 12v to 5 for the TDA, and add all this parts and that's it?

    Thanks,
    Have a great day!
     
  13. ian field

    Distinguished Member

    Oct 27, 2012
    4,415
    784
    Why drop the supply down to 5V? - The TDA7052A will work better than most audio chips at such low voltage, but its upper limit is higher than 12V.
     
  14. Predrag Beočanin

    Thread Starter New Member

    Mar 20, 2016
    8
    1
    Hey Ian,

    Oh that's awesome! Well if I can do agc with so little parts and 12v which I already have, I'm definitely making the switch. LM386 started shorting my circuit for some reason, and nothing has changed, so the TDA sounds like a dream.

    Thank you,
    Have great day!
     
  15. ian field

    Distinguished Member

    Oct 27, 2012
    4,415
    784
    The maximum is 18V - 12V leaves a good safety margin.

    The LM386 varies with version - with some its 15V, some types can take 22V.
     
  16. Predrag Beočanin

    Thread Starter New Member

    Mar 20, 2016
    8
    1
    Hey Ian,

    The whole circuit is ran by 12, so it should be fine. I'm having some trouble figuring out the components on the schematic I linked tho. There's a unmarked diode there, a "garden variety npn transistor" and an unmarked capacitor. Got the slightest clue what I may want to put there?

    Thanks,
    Have a great day!
     
  17. recklessrog

    Member

    May 23, 2013
    338
    102
    I have used an almost identical circuit in a mind sync generator I built. I had to use a 220k pre-set variable resistor for what is shown as R8 on this schematic due to the differences in J-fet's.
     
  18. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,544
    1,251
    Diode: 1N914, 1N4148
    Transistor: 2N2222, 2N3904, 2N4401

    ak
     
  19. Predrag Beočanin

    Thread Starter New Member

    Mar 20, 2016
    8
    1
    Hey ak,

    Perfect, thanks a bunch!

    Have a great day!
     
  20. dannyf

    Well-Known Member

    Sep 13, 2015
    1,825
    364
    The behavior you described is the correct behavior.

    To avoid that, you can try to wire the lm3914 to the line in signal, before the lm386s volume control. If the line in doesn't have enough swing, put an amplifier to it.
     
Loading...