How to reduce power supply noise

Status
Not open for further replies.

ihatemornings

Active member
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:

Power noise repro circuit.jpg

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
 
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....

TheSoundOfSilence.JPG
 
Quick note - the T_4.0 doesn't have a separate AGND - so the other note to 'throw in another' would be needed.
 
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...)
 
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???

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.
 
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.
 
- 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"
 
If you just want an easy low noise teensy output solution, run toslink to an off-the-shelf DAC/amp.
 
@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.
 
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.

Teensy noise repro circuit 03.jpg

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/1xktd7ixb4l17r8/AADsAM390FTnBKCw23xiQ0bDa?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
 
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.

Teensy noise repro circuit 04.jpg

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

Teensy noise repro circuit 04 AGND.jpg

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?
 
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.
AudioNoise.JPG
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?
 
@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. :)

Teensy noise repro circuit 05.jpg

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.
 
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....
 
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:

schematic_audio4.png

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:

Teensy noise repro circuit 06.jpg
 
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...
 
@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?
 
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.
 
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?
 
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.
 
@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.
 
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.
 
Status
Not open for further replies.
Back
Top