Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 36

Thread: How to reduce power supply noise

  1. #1
    Junior Member
    Join Date
    Sep 2020
    Location
    Oxford, UK
    Posts
    17

    How to reduce power supply noise

    Iíve been working on a Teensy 4.0-based music machine for a while, and Iím getting down to the last niggly noise issues. Iím hoping this is something people have solved before, but I havenít managed to find any Teensy-specific tips on the forum.

    Iím using the audio shield and the audio library to play WAVs from an SD card, with the 4ohm speaker output powered by a pretty standard LM386 amp circuit. My problem is that thereís a noticeable whine (around 4kHz) that appears when the Teensy is connected to the amp circuit. When the SD card is being read thereís also a lower frequency noise.

    Iíve simplified the circuit down to the minimum number of components with which I can reproduce the problem:

    Click image for larger version. 

Name:	Power noise repro circuit.jpg 
Views:	101 
Size:	69.6 KB 
ID:	23331

    Iím running the ďPlaying MusicĒ tutorial code but Iíve replaced the SDTEST2.WAV test file with a silent WAV. I can even ground the amp input and the noise continues Ė the problem is not with the audio output from the Teensy. Hereís my oscilloscope showing the 9v power rail of the amp circuit (bottom) and the amp output across the speaker terminals (top). You can hear the noise in the background:



    Do I need to start learning about ferrite beads? Iím quite used to analogue audio circuits but the digital/analog combination brings some new challenges. Any tips, advice or links to resources welcome!

    Thanks,

    Ben

  2. #2
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    1,070
    How does it sound when you run from batteries?

  3. #3
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    111
    Quote Originally Posted by ihatemornings View Post

    Do I need to start learning about ferrite beads? I’m quite used to analogue audio circuits but the digital/analog combination brings some new challenges. Any tips, advice or links to resources welcome!

    Moin Ben!

    First, you have t understand that you NEVER should run Audio Circuits directly from a non trustworhty, possibly unstabilized and unfiltered rail, especially if you have a common GND with some digital Circiutry.

    Dirty audio Vcc will lead to dirty signals as any A/C noise between your OpAms aVcc and aGND will be heard amplified on the Output, especialy when there is no signal to mask. To avoid this you have to

    a) prevent digital Noise comes bleeding to your audio part and
    b) prevent any Noise from the Power Supplys Rail comes bleeding to your audio part

    So first,for a) isolate the digital Part with a 33ĶF inductor rigt BEFORE the buffering Caps for the regulators Vin (Green Marking). C1 100nF is next to useless in this position, if you insist place it right next to your OpAmp., C3 should be as also fairly useless as Teensy has internal Caps for stabilizing, but if you want to go for it position it right next to the Teensy.

    For b) Throw in another 33ĶF Inductor for your Audio 9V aVCC Rail marked at the red position. Inserting a tiny linear Regulator to the Audios aVcc Rail would add another level of protection. Equally important is protecting your Audios GND rail, this should NOT be connected to the digital GND. You can either use the Teensys AGND Pin for this (as it is internally connected via an Inductor to dGND, or throw in another 33ĶF.

    This way you avoid a) digital noise bleeding to the supplys 9V rail and b) isolated your audio circiutry.

    Please note, that the Audio Shield is not the best Codec you can buy, and produces possibly audible noise in itself....

    Click image for larger version. 

Name:	TheSoundOfSilence.JPG 
Views:	119 
Size:	73.3 KB 
ID:	23334

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,069
    Quick note - the T_4.0 doesn't have a separate AGND - so the other note to 'throw in another' would be needed.

  5. #5
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    111
    Ferrite beads additionally would supress any HF noise, but have no impact in audible range.

  6. #6
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,224
    isolate the digital Part with a 33ĶF inductor rigt BEFORE the buffering Caps
    Inductance is measured in henries, not farads... 33ĶH perhaps?

    If you drive audio amp from a switch-mode supply (not recommended), then make sure its one with an
    ultrasonic switching frequency (and beware the sort than reduce frequency on light load...)

  7. #7
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    111
    Quote Originally Posted by MarkT View Post
    Inductance is measured in henries, not farads... 33ĶH perhaps?
    Right! NEED * MORE * COFFEE and tried to edit Post #3. I wasnt aware that this options runs out after some Time???

    Quote Originally Posted by MarkT View Post
    If you drive audio amp from a switch-mode supply (not recommended), then make sure its one with an
    ultrasonic switching frequency (and beware the sort than reduce frequency on light load...)
    Most recent (branded) PSUs work just fine, only the cheapest ones (hence the ones with older designs....) may still have these Problems. Personally i use Meanwell PSUs to power my Modular Synths wherever possible without any hassle whatsoever. But thats only for the last 7+ years.

  8. #8
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    323
    I've created a very low-noise Teensy Audio Shield so I can assure you it can be done. Take a look here for full details, including the schematic: TGA Pro

    For starters with PJRC Audio Board, you must turn off the HPF on the SGTL5000 codec. It's the loudest source of noise by far.

    You need a number of things in place to have low-noise clean analog audio when working with digital circuits
    - you must use a decent enough CODEC to start with, suitable for audio music applications, not just super low power ones designed for cell phones.
    - you must use an audio grade op-amp as the codec preamp, TL072, NE5532, any OPA*, etc.
    - You must generate a separate supply just for the analog stuff using filtering and an LDO.
    - You must use audio-grade components in the analog signal path. This means audio grade resistors and electrolytics/film caps in the main signal path. No ceramics as they introduce nonlinear distortion (and not the good kind of distortion).
    - you must have careful PCB routing to keep digital signals away from analog signals, otherwise the digital noise easily couples into the analog signals.
    - you must have good shielding around any high impedance traces carrying analog signals.

  9. #9
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,224
    Quote Originally Posted by Blackaddr View Post
    - you must use an audio grade op-amp as the codec preamp, TL072, NE5532, any OPA*, etc.
    I'd say should use, not must use
    For low voltage circuitry many old style opamps are bad news as they require dual rail supplies - a modern
    true rail-to-rail audio spec'd opamp is a better choice as only a 5V supply is needed. For instance OPA1671, AD8656

    To be audio spec'd the voltage and current noise specs will be given and be low, the distortion should be low
    (0.003% or less is great), and the power consumption will be 4mA per amp or so (ie avoid low power chips).

    - You must use audio-grade components in the analog signal path. This means audio grade resistors and electrolytics/film caps in the main signal path. No ceramics as they introduce nonlinear distortion (and not the good kind of distortion).
    "Audio grade" is essentially meaningless. Metal film resistors(*) and PP or PPS film caps are great. Any electrolytics in the signal
    path should have large values so they have negligible ac voltage across them (then they can't distort). The only sort of ceramics
    you should use are NP0 / C0G, as they are linear (the others are indeed very non-linear). And to dispell a common myth there is no
    good kind of distortion.

    BTW supply decoupling caps are not in the signal path, normal practice applies for these.

    (*) For surface mount this is called "thin film"

  10. #10
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    1,070
    If you just want an easy low noise teensy output solution, run toslink to an off-the-shelf DAC/amp.

  11. #11
    Junior Member
    Join Date
    Sep 2020
    Location
    Oxford, UK
    Posts
    17
    @jonr @fdaniels @MarkT @Blackaddr thanks for the tips! That all makes a lot of sense. Iíll make some tweaks to the circuit and see how I get on.

  12. #12
    Junior Member
    Join Date
    Sep 2020
    Location
    Oxford, UK
    Posts
    17
    Iíve made some progress! A few steps forward, a few steps back.

    I bought some 33uH inductors and added them to the circuit as @fdaniels suggested. They reduced the power supply whine a little. Then I did a lot of reading and checked out various teensy DAC schematics. I can see that (as @Blackaddr outlined) you can really go to town on the hifi audio output. I might end up there one day, but for a start Iíd just like to get a reasonable sound out of the audio board. I realise itís not going to be hifi, but I think my circuit should be a lot less noisy than it currently is.

    Hereís what Iím working with at the moment. Iíve switched out the amp for a simple jack out for testing purposes, Iíve added a couple of buffers and a mixer from my actual circuit and rethought the ground structure.

    Click image for larger version. 

Name:	Teensy noise repro circuit 03.jpg 
Views:	63 
Size:	81.1 KB 
ID:	23430

    Iím still getting a lot of noise, and Iím trying to narrow down the causes. Iíve recorded some audio samples (playing the SimpleDrum example sketch) from various points in the circuit: at the Teensy line out, after the buffer, after the mixer (with Teensy AGND as ground) and across the terminals of the output jack:

    https://www.dropbox.com/sh/1xktd7ixb...23xiQ0bDa?dl=0

    Itís clear that thereís plenty of noise at the Teensy line out, and the rest of the circuit is amplifying it to various degrees. The final MP3 in the Dropbox is another sketch, playing 4 RAW loops from the SD card. Thatís what Iím trying to eventually do, and the noise is overwhelming!

    So, my questions:
    1. Does the grounding look correct? Could I improve it? Does grounding the buffers to AGND make sense?
    2. Is that amount of noise normal for the Teensy audio shield line out?
    3. Are SD card reads known to be super noisy, and if so is there a fix?

    Thanks in advance! I appreciate the advice, Iím learning as much as I can, and itís great to have somewhere to turn when I run out of ideas...

    Ben

  13. #13
    Junior Member
    Join Date
    Sep 2020
    Location
    Oxford, UK
    Posts
    17
    Quick experiment Ė I donít think this is the correct approach, but it does eliminate the noise and maybe that would be helpful in diagnosing the problem.

    I grounded the mixer to the Teensy audio boardís line out ground pin (AGND in the diagram) and most of the noise disappeared. I guess this eliminates a possible ground loop, and it also demonstrates (to me) that the noise can indeed be reduced.

    Click image for larger version. 

Name:	Teensy noise repro circuit 04.jpg 
Views:	73 
Size:	81.1 KB 
ID:	23431

    This is the pin Iím talking about (highlighted in yellow):

    Click image for larger version. 

Name:	Teensy noise repro circuit 04 AGND.jpg 
Views:	27 
Size:	43.6 KB 
ID:	23432

    Revised questions:
    1. Does the grounding look correct? Could I improve it?
    2. Is is legitimate to ground all the analog audio circuitry to the line out ground pin on the audio board?
    3. If I were to add an amp circuit (as in #1) after the mixer, could I ground that to the same spot or am I barking up the wrong tree?

  14. #14
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    111
    You still have the Inductor L1 on the wrong place - theres no uses protecting the input of the Linear regulater, you should protect your analog circuitry which still ist directly connected to your (apparently noisy) PSU.
    Click image for larger version. 

Name:	AudioNoise.JPG 
Views:	59 
Size:	97.6 KB 
ID:	23435
    As said before you have to use either another Inductor OR the AGND for the analog circuitry to isolate noise from the digital ground rail. Since you did so most of the noise disappeared....

    BTW: this is not a "ground loop" problem, since everything on your Breadboard runs from the same GND, either from your PSU or from USB. Since you power it (according to your schematics) from a +9V PSU, the only possible "ground loop" are the USB connector (you did cut the trace didnt you?" or the connection to an external Audio Device.

    BTW2: This is a rather unusual output circuit design. Mind you explain why you chose this one?

  15. #15
    Junior Member
    Join Date
    Sep 2020
    Location
    Oxford, UK
    Posts
    17
    @fdaniels thanks for the pointer on the inductor position Ė I think I misunderstood your earlier recommendation. This makes much more sense.

    Hereís the full circuit that Iím tinkering with. One of the Teensy outputs is fed through a delay circuit (with the delay controlled by the Teensy using a digital pot), then the two signals are mixed for mono output. All of the pieces work well in isolation, but itís a fun puzzle connecting them all together. Iím a musician and programmer by day and repaired a fair few 60s organs. This is my first digital/analog circuit and thereís a bit of a learning curve here. Thanks for your patience.

    Click image for larger version. 

Name:	Teensy noise repro circuit 05.jpg 
Views:	66 
Size:	123.4 KB 
ID:	23437

    Iíve tried here to indicate exactly how my current circuit is connected. All of the AGND labels are connected (star ground style) to the Teensyís AGND pin. I went a little overboard with the inductors Ė I donít think theyíre doing any harm but thought Iíd better show them here in case they are causing trouble. As marked, the delay and digital pot circuits are not connected and the DELAY_IN is connected directly to DELAY_OUT.

    I have the whole circuit up to the mixer working with a minimum of noise (by grounding all the analog circuitry to AGND on the Teensy as mentioned and monitoring the LINE_OUT jack). But when I reconnect the amp circuit (also grounded to AGND) the noise comes back with a vengeance. The noise (loud digital noise, as before) occurs whether or not I have USB attached (the trace is cut!) and whether or not the output is routed through the line out jack or the speaker.

    Is there something obviously wrong with the way the amp circuit is wired? Now that the digital and analog grounds are isolated (I think?) Iím confused as to how the digital noise finds its way to the output.

  16. #16
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    111
    First, i never have seen a JFET in a simple Buffer, where a simple TL07x could have been used. Maybe you change this to a more standard approach.

    And id trash the whole hardware delay thing and use the audio librarys software AudieEffectDelay, which would eliminate the use of buffers as a nice side effect.

    BTW it would have been nice to see the whole diagram at the beginning, as your selection already implies the Noise couldnt come from the PT2399 circuitry or the unusual JFTE Buffers. Which well could be. But we never saw it....

  17. #17
    Junior Member
    Join Date
    Sep 2020
    Location
    Oxford, UK
    Posts
    17
    First, i never have seen a JFET in a simple Buffer, where a simple TL07x could have been used. Maybe you change this to a more standard approach.
    The JFET buffer is quite common in guitar pedals (this sort of thing), but a TL07x buffer makes sense too (and should be better quality). Iíve swapped the buffers out for TL071s Ė they work fine but the noise is still the same.

    And id trash the whole hardware delay thing and use the audio librarys software AudieEffectDelay, which would eliminate the use of buffers as a nice side effect.
    That would definitely simplify things, but the hardware delay is 90% of the sound Iím going for with this device so Iím afraid that part is non-negotiable!

    BTW it would have been nice to see the whole diagram at the beginning, as your selection already implies the Noise couldnt come from the PT2399 circuitry or the unusual JFTE Buffers. Which well could be. But we never saw it....
    Sorry Ė I was trying to simplify the question but posting the whole circuit probably would have been more helpful. The first schematic I shared did represent the circuit I was testing though, so at that point the noise definitely wasnít coming from the PT2399 or the buffers. As it stands now, the PT2399 circuit isnít connected at all and the JFET buffers have been replace with TL071s.

    ---

    Hereís an interesting discovery: the line out ground pin that Iíve been using as my isolated analog ground (marked AGND on the Teensy audioshield symbol Ė quite misleading!) seems to be connected directly to ground on the Teensy audio board Ė no inductor! The resistance from that pin to any of the other ground pins reads around 0.3ohms on a multimeter:

    Click image for larger version. 

Name:	schematic_audio4.png 
Views:	31 
Size:	48.0 KB 
ID:	23459

    I guess thatís what @defragster was referring to back in #4. And that would definitely explain how the digital noise is making its way into the analog circuit!

    So maybe Iím back to square one Ė whatís the correct/best way to connect the grounds? Hereís the updated circuit as it stands on my bench right now, with TL071 buffers and the delay circuit removed:

    Click image for larger version. 

Name:	Teensy noise repro circuit 06.jpg 
Views:	39 
Size:	98.4 KB 
ID:	23460

  18. #18
    Junior Member
    Join Date
    Sep 2020
    Location
    Oxford, UK
    Posts
    17
    I came across this post that sounds like a very similar problem to mine, and it made me wonder whether my skimpy breadboard cables were not giving me a clear enough ground connection. I swapped all the ground wires out for thicker wires soldered to the pins and it did reduce the general noise level somewhat, but the digital noise didnít magically disappear.

    I tried adding a 33uH inductor between the Teensy ground pin and the analog circuit grounds, but that gives me a completely distorted signal so Iím not sure whatís going on there.

    Iíve ordered a bag of 1:1 audio transformers (the chap in that forum post used a ground isolator device to solve, or at least bypass, his problem). Letís see if that helps! Iím sure Iím missing something...

  19. #19
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    111
    Have you ever tried to run it from a 9V Battery to rule out the noise is coming from your PSU?

  20. #20
    Junior Member
    Join Date
    Sep 2020
    Location
    Oxford, UK
    Posts
    17
    @fdaniels good question! I had tried that a while back, but not recently. Running the circuit from a 9V does indeed eliminate the noise.

    So... I need to filter the power supply?

  21. #21
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    323
    Ground loops tend to pick up 60Hz hum from the mains, lighting, nearby refrigerators, etc. They are less likely to pick up digital interference. Digital interference is picked up by analog wires running too close without shielding to digital circuits. And/or, digital rails have tons of noise on them from the switching currents of the digital circuits they feed. Insufficient filtering, isolation/shielding and ground/power plane design on the PCB can allow digital interference to get into the analog signals.

    That said, these typically are needed to turn "a little noisy" into "dead silent". If your circuit is more than "a little noisy", if it's "objectionably noisy" it is often more a circuit design problem, or a wiring problem where a component is technically not "in the design" due to poor connection, or accidentally wired to the wrong spot.

  22. #22
    Junior Member
    Join Date
    Sep 2020
    Location
    Oxford, UK
    Posts
    17
    Swapping the power supply for a better one (a Korg 9V PSU instead of a random cheapo) eliminates almost all of the noise. Gah.

    If I wanted to make the circuit more resilient to cheapo power supplies by adding some filtering/isolation, is there a standard design to start with? @Blackaddr the power corner in your TGA schematic seems pretty comprehensive, and my “capacitor across the +/- supply” approach seems pretty naÔve. Would a synth module or guitar pedal for example require or expect a good quality power supply, or would it usually be able to deal with noisy ones?

    It’s not quite what I was planning, but would it help to use a 12V supply and regulate it down to 9V?

  23. #23
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    111
    Just get a better PSU. Compensating for crappy PSU is not worthwile the effort as a proper PSU costs next to nothing more than a bad one. When your Circuit is silent with a normal, not superfancy PSU its up to the user to meet the usual standrad, not yours bothering everyone with a complicated compensation for the worst case.

  24. #24
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    323
    Quote Originally Posted by ihatemornings View Post
    @Blackaddr the power corner in your TGA schematic seems pretty comprehensive, and my “capacitor across the +/- supply” approach seems pretty naÔve. Would a synth module or guitar pedal for example require or expect a good quality power supply, or would it usually be able to deal with noisy ones?

    It’s not quite what I was planning, but would it help to use a 12V supply and regulate it down to 9V?
    Most guitar pedals don't need to have resilient power supplies because most have no digital circuits inside them. When powered by batteries, you get lowest PSU noise because batteries have no noise really. When you power an analog pedal with 9VDC, the power adapter is either transformer based with noise filtering designed to eliminate the 60 Hz AC component, OR if they are a digital switching supply (noisy as hell) they have comprehensive filtering designed around the frequency of of the switching supply (varies from a few hundred Hz to a few KHz, right smack in the key audio frequencies).

    If you don't want to custom build that much filtering, the next trick is to pass a the digitally switching power through a linear voltage regular. This will inherently remove most of the noise, bu the input to the regulator must be higher than it's output. So generally, switching regulators create power for digital circuits, and linear (LDO) regulators create power suitable for analog circuits.

    Designing a robust, low noise power supply for a guitar application is complicated, as you see in the TGA Pro schematic. The design challenge with the Teensy when targeting guitar applications like the TGA Pro is:

    How do I create
    - a clean, 3.3V analog supply for the CODEC
    - and a clean 9V supply for the preamp so I don't clip my input signal (if coming from another 9V guitar pedal or active pickups)
    - and make sure the signal fed into the CODEC doesn't exceed 3.3V and damage the codec (attenuate it cleanly when necessary)
    - and generate a digital supply greater than 9V (say 12V) so i can use a 9V LDO
    - and do ALL of this using only the 3.3V or 5V coming from the Teensy.

    And once you've done all that correctly, if you don't have a PCB with properly shielded tracks and good ground plane design, you still get the digital circuits coupling into the analog! Agh!

    Hence why I create the TGA Pro. If you want something that is low-noise and very high quality, you really need a lot more stuff, carefully routed on a PCB. Learning how to do this makes you spend all your time becoming an electrical engineer and very little time programming your Teensy and making audio and music! Obviously as DIYers, it's up to us where we spend our frustration and where we receive our enjoyment.

  25. #25
    Junior Member
    Join Date
    Sep 2020
    Location
    Oxford, UK
    Posts
    17
    Easy as that, eh? Hats off to you, sir.

    Iíll go with a decent 9V PSU for now and iron out the finer audio details then see how much more energy I have for power supply design.

    Thanks everyone for the help! Iíve learned a lot. Iíll post some details of the project once itís up and running.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •