Speaker Noise w/ Feather M4 Express

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
TRGPAndrew
 
Posts: 19
Joined: Mon Mar 26, 2018 6:10 pm

Speaker Noise w/ Feather M4 Express

Post by TRGPAndrew »

I've been working on a Ray Gun prop for years now and I've used several board configurations and features.

Demo Video: https://youtu.be/4OR4rFsO9XE

Everything I've done has worked on a technical level, but not without some consequences.
The most notable of these consequences is noise in the speaker when idle and during playback.

I've decided to tackle this issue more directly and I'm hoping you can provide some insight.

I stripped down the setup as much as I can and I'm still getting noise above the usual static level.

Setup:

Feather M4 Express (CircuitPython 5.3.0* Bootloader 3.10.0)
PAM8302A - Class D Mono Amplifier
4Ohm 3W Speaker 40mm
1200mAh 3.7V Lipo Battery
SPDT Momentary Limit Switch w/ Roller (Trigger)

*I've run into a number of issues with CP 6.x, so I'm sticking with CP 5.3.0 for now

Code:

Code: Select all

#  Audio Only Code 5/4/21
import board
import audioio
from audioio import WaveFile
import digitalio
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn, AnalogOut

audio = audioio.AudioOut(board.A0)
shoot = audioio.WaveFile(open("RayGunPew.wav", "rb"))

trigger = DigitalInOut(board.D11)
trigger.direction = Direction.INPUT
trigger.pull = Pull.UP

#  Main loop
while True:
    
    if not trigger.value and not audio.playing:
        audio.play(shoot)
Before audio is triggered, there is no excess noise. Once it is triggered, the noise level increases and, when other components like LEDs are present, it can cause distortion in the audio being played. I have tried a smaller 8Ohm 0.5W speaker with the same result.

Potential Solutions:

Is there a better way to invoke audio playback that might fix this issue? For example, in the Prop-Maker Lightsaber, the audio files are read in a subfunction rather than globally in the "setup" before the main loop.

Is there a version of the Feather that is designed for audio playback that might be more suitable?

Is there a better amplifier I could try?

Is there a protocol within CircuitPython that could "clean" the signal going out of A0 like you would do with a digital input pullup?

It seems like the board and circuits attached to it might be creating interference in the signal from A0 to the amp. Are there techniques to insulate the audio signal before it is amplified?

I understand this might be a lot to digest, but I tried to make things as clear and straightforward as possible.

Any help would be greatly appreciated.

Thanks.

User avatar
hollowmyth
 
Posts: 6
Joined: Thu Apr 08, 2021 2:47 pm

Re: Speaker Noise w/ Feather M4 Express

Post by hollowmyth »

We're running into this issue while doing the lightsaber build. Did you ever find a fix?

User avatar
TRGPAndrew
 
Posts: 19
Joined: Mon Mar 26, 2018 6:10 pm

Re: Speaker Noise w/ Feather M4 Express

Post by TRGPAndrew »

hollowmyth wrote:We're running into this issue while doing the lightsaber build. Did you ever find a fix?
I haven't received a reply from Adafruit yet, but for your case I would recommend trying the Feather M0 Express in place of the M4 and see what happens. I have a version of my Ray Gun that uses an M0 and the noise is almost gone on a fully charged battery. That being said, I'm hopeful that there is a solution that can solve this problem for all instances of speaker noise regardless of the microcontroller.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Speaker Noise w/ Feather M4 Express

Post by adafruit_support_mike »

The audio noise could be a side-effect of noise on the supply rails.

Try adding a large capacitor (at least 100uF) between the positive and negative supply rails and see if that helps.

User avatar
TRGPAndrew
 
Posts: 19
Joined: Mon Mar 26, 2018 6:10 pm

Re: Speaker Noise w/ Feather M4 Express

Post by TRGPAndrew »

adafruit_support_mike wrote:The audio noise could be a side-effect of noise on the supply rails.

Try adding a large capacitor (at least 100uF) between the positive and negative supply rails and see if that helps.
I've tried decoupling capacitors at various locations in the circuit. Can you be more specific about where you think they would be most effective?

Also, I have tried a 100uF capacitor and it has completed muted playback in certain configurations.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Speaker Noise w/ Feather M4 Express

Post by adafruit_support_mike »

Put the capacitor as close as possible to the point where power enters the board. The VBUS and GND pins will work.

The purpose of the capacitor is to absorb voltage spikes from the power supply, and the sooner you can get rid of them, the better.

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”