4
\$\begingroup\$

I am using a Raspberry Pi 3B to output music to an audio amplifier board. Without the Pi connected, there is no noise from the amplifier. Once the Pi is connected (but not outputing any music yet), there is loud crackling and humming which is associated with the activity on the Pi.

BTW I am a (retired) digital engineer and my analogue experience goes back to university.

I am using a "brick" power supply (J1) which outputs 20V. This feeds the amplifier directly. There is a separate buck/boost DC-DC converter (J2) which generates 5V from the 20V for the Pi. Here is a diagram of the wiring: enter image description here

The amplifier board uses a TPA3116D2 audio amplifier IC.

The (partial) schematic for the Pi can be seen here. The audio output is generated on the Pi by a PWM which is buffered using a separate 3V3 supply, then filtered before output to the 3.5mm jack socket. Unfortunately the Pi schematic doesn't show how the 3V3 supply is derived from the 5V input.

If I power the Pi directly from a standard USB charger (with the amplifier still supplied by the power supply), there is no such noise and it sounds pretty good.

I can think of three potential problem areas with my design:

  1. The noise is being generated by the power supply. The amplifier has a good PSRR so can cope with this noise but the DC-DC converter is essentially passing it through. The Pi then passes the noise onto the 3V3 supply.
  2. The noise is being generated by the DC-DC converter which the Pi is passing through.
  3. All the wiring is generating ground noise.

Is there a more likely source of my issue? Which is the most likely area for me to investigate further? Any suggestions on what I can do to remove this noise?

All help gratefully received.

\$\endgroup\$
7
  • \$\begingroup\$ Are you sure that the 20-5V DC-DC converter is a Buck (non-isolated) converter? Which paths in the audio stream are AC coupled? How did you connect to the RINP/RINN of the audio amp chip? \$\endgroup\$
    – Mattman944
    Commented Apr 3, 2021 at 10:16
  • \$\begingroup\$ Details of J2 (DC-DC) are definitely needed. \$\endgroup\$
    – Andy aka
    Commented Apr 3, 2021 at 10:26
  • \$\begingroup\$ I bought the converter from Banggood: banggood.com/…. Not much detail I'm afraid, but the output is definitely not isolated. \$\endgroup\$
    – WhyNine
    Commented Apr 3, 2021 at 11:26
  • \$\begingroup\$ The amplifier also came from Banggood: banggood.com/…. The amplifier is hidden beneath a heatsink so I can't see the pins and check the wiring. The board has separate inputs labelled IN+/IN-/GND which suggests that they are wiring the balanced signals to the amp. \$\endgroup\$
    – WhyNine
    Commented Apr 3, 2021 at 11:29
  • \$\begingroup\$ Since it works when you power the Rpi separately, the easiest solution is to replace the 20V to 5V converter with an isolated converter. \$\endgroup\$
    – Mattman944
    Commented Apr 3, 2021 at 22:10

3 Answers 3

3
\$\begingroup\$

My best guess is this: -

enter image description here

The DC-DC converter is producing common mode noise on its output power feed to the RaPi. That CM noise will be referenced to 0 volts on the amplifier power port and, the amplifier is unable to cope with that CM noise applied to its differential inputs. To prove this, if you grab hold of an audio transformer and feed the RaPi signal via it to the left or right channel of the amplifier, the noise should reduce significantly.

If this doesn't work, then at least you've ruled out one suspicious mechanism that might have been the problem.

\$\endgroup\$
7
  • \$\begingroup\$ I have just checked and the input and output grounds on the DC-DC converter (pins 3 and 4 on J2) are connected together. Does this change your analysis? \$\endgroup\$
    – WhyNine
    Commented Apr 3, 2021 at 10:42
  • \$\begingroup\$ It might but it's still worth a try with the audio transformer because the apparently joined connection may be via an inductor. Details of J2 required please @WhyNine \$\endgroup\$
    – Andy aka
    Commented Apr 3, 2021 at 10:49
  • \$\begingroup\$ Also. if you can ground the RaPi to the USB power connection (without carrying power from the USB) it may also stop the noise (and reveal more information). \$\endgroup\$
    – Andy aka
    Commented Apr 3, 2021 at 10:56
  • \$\begingroup\$ I only connected the power and ground in the USB cable to the DC-DC converter board Should I also connect to ground the bare wires in the cable (which are connected to the shield on the USB connector)? I also tried using the IN+/IN- pins of the amplifier instead of the 3.5mm jack (the amplifier has multiple inputs) but it made no difference to the noise. I don't have an audio transformer to hand so that will be more difficult to try (basically it will take longer). \$\endgroup\$
    – WhyNine
    Commented Apr 3, 2021 at 11:06
  • \$\begingroup\$ @WhyNine just connect ground from the current noisy set-up to the USB port that provides power - just ground or 0 volts and nothing else. \$\endgroup\$
    – Andy aka
    Commented Apr 3, 2021 at 11:08
2
\$\begingroup\$

If you use a PWM to output an analog value, its high level is the CPU's power supply voltage, and its low voltage is the CPU's ground. The former will fluctuate according to CPU power consumption and voltage regulator transient response. It is not possible to keep a voltage exactly constant on a load that draws randomly variable current.

When the Pi outputs silence, I assume the PWM is set at 50%, so its output value contains half the power supply noise, and half the ground noise. Although it could be argued that the noise on GND transfers to VCC through decoupling caps, so you get 100% of the ground noise all the time.

If you want to get good noise floor, you can use a balanced output, with two PWMs, one being inverted, and a differential opamp doing the substraction. On a noise floor measurement though, which is done at zero output, both PWMs are at 50% so they contain the same noise from VCC which is substracted by the differential opamp, and this gives good results, which is why it is a popular solution.

Of course, in actual use, it is garbage, because if you output a signal, then the amount of time each PWM stays at VCC will change, which means they will no longer contain the same amount of VCC noise that can be substracted, but a different amount, which is proportional to on-time of both signals. After substracting, output noise has not been suppressed, but simply made proportional to output signal value. But it gives a nice "noise floor" graph at zero output.

Additionally, you have a ground loop, and the Pi's supply current, which depends on load, flows in this loop, which adds some extra noise on top.

If you insist on using PWM, you can pass it through a logic gate like a 74HC, powered from a stable voltage. Then the logic gate's output logic level 1 will no longer be the noisy Pi internal VCC, but its own VCC. Definitely not hi-fi, but still better.

Basically, you need a real DAC. There are plenty of those available for a Pi.

An excellent way to not have ground loops is to use an amp with a bluetooth input, and a bluetooth dongle on your Pi. DAC is included in the amp, so less work.

Another way is an amp with a balanced input (ie, differential). This will not break the bank, most cheap Class-D modules do. You also need a DAC with a balanced output, most DAC chips do, if you get a DAC for the Pi that does not, and it uses a DAC chip that does, just remove the opamp that does the differential to single ended conversion.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for your analysis. I was aware of the problem with the PWM output but the Pi schematic shows that this output is already buffered using a separate 3V3 supply (although its not clear how clean that is). As I stated in my explanation, if I use a separate USB PSU for the Pi, I don't get any of this noise, which suggests that it isn't the PWM circuit itself that's the problem. However I was wondering about ground loops. The amplifier IC does have balanced inputs so I will try to investigate how the 3.5mm socket signal is wired up to it. \$\endgroup\$
    – WhyNine
    Commented Apr 3, 2021 at 10:30
  • \$\begingroup\$ See my connect to the Answer from @Andy aka. I tried using the IN+/IN- pins on the amplifier instead of the 3.5mm jack input (the amplifier has 3 inputs) but it made no difference to the noise. \$\endgroup\$
    – WhyNine
    Commented Apr 3, 2021 at 11:08
2
\$\begingroup\$

This is already said at least twice by others. Here's my version of the refrain:

Signal needs 2 wires: The hot and the ground. You have several ground connections between the computer and the amp. The ground side signal current is distributed through all of them. The signal has no way to use the one and only wanted wire.

Unfortunately also the computer electronics supply current pulses, the pulses that the amp takes (it's not an old fashioned linear class AB amp) and the current peaks that the buck power supply takes when the switch is on use same ground wiring, they also do not choose the shortest path. Because all wires have inductance and resistance those unwanted current peaks and pulses generate a noise voltage which is directly summed to your signal voltage.

That is how ground loops spoil signals.

Break the ground loop as you have already tried: Have a separate properly isolated power supply for the computer or alternatively get - as already suggested - an audio transformer.

In theory balanced signal connection could fix this but I guess there's no balancing. If I read the linked ad images wrong and the balancing exists, it's probably made with opamp which works unpredictably at high frequency pulse signals. Some lowpass filtering is needed. An audio transformer makes the connection quite surely balanced.

ADD: User supercat presented in his comment an idea: Feed the audio as high frequency PWM signal through galvanic isolation and convert it to audio in the amp side of the isolation. The idea sounds good because the PWM to audio converter probably needs only few milliwatts of power. Designing it properly is totally another problem. I suggest a high speed opto-coupler as the foundation. Some low-frequency component free coding is needed if the isolation uses transformer. Read the comments.

\$\endgroup\$
8
  • \$\begingroup\$ I wonder if it would be helpful to capacitively-couple the PWM signal and pass it through a high-frequency transformer, convert the transformer output back to a full-strength PWM signal, and filter that? \$\endgroup\$
    – supercat
    Commented Apr 3, 2021 at 20:29
  • \$\begingroup\$ That can work. Fast optocoupler also could do the trick and be cheaper. But one hitch exist: The conversion from high frequency PWM to audio must happen without a need of new noise makers such as another buck converter. \$\endgroup\$
    – user136077
    Commented Apr 3, 2021 at 20:35
  • \$\begingroup\$ If the PWM ratio doesn't go too close to 0% or 100%, the transformer that's used to carry signal could also be used to carry the small amount of power necessary to power the circuitry that cleans up the PWM and filters it, without any ground connection between the input and output. \$\endgroup\$
    – supercat
    Commented Apr 3, 2021 at 20:42
  • \$\begingroup\$ That's well possible, because the signal cannot be a long time in its peak value. One thing is quite sure: The amp probably is a heavy duty electricity polluter, too, so using the same supply as the amp needs special precautions. But it's probably not impossible. \$\endgroup\$
    – user136077
    Commented Apr 3, 2021 at 20:50
  • \$\begingroup\$ If the demodulator shares a ground with the output amplifier, that's the best scenario one can hope for. If the amplifier generates lots of ground noise relative to any ground used in the outside world, but its input is referenced to the same noisy ground, the amplifier should act upon the difference between its input and that noisy ground, yielding a clean signal. \$\endgroup\$
    – supercat
    Commented Apr 3, 2021 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.