Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Real sounds or electrical noise?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Real sounds or electrical noise?

by pneumatic on Thu Jul 16, 2020 5:52 pm

My project needs to be able to detect loud noises, so I've been using Adafruit's electret microphone hooked up to a Feather M0 WiFI sampling at 10kHz. It tries to detect anomalies by looking to deviations of a few tenths of a volt. The background variation when quiet is typically 8-10mV, but when I clap near the microphone, I get about +/- 1.5V. I actually do this using integer math to make it faster. The ADC is set to 12bits full scale (4095 max), and that should correspond to about 0.8mV per tick.

It's properly triggering on loud claps like so:
Image

But it's also registering a lot of stuff when I don't perceive any significant or sudden sounds:
Image

and I can't figure out what is causing that drop of several tenths of a volt for about 0.5-1 ms (the whole curve is about 50 ms). It happens a LOT (every second or two, including when there's nobody in the room). I'm trying to figure out if my circuit is electrically noisy, or if I'm picking up real sounds I'm not perceiving.

What I've noticed, these phantom triggers are always voltage dips, never spikes, and they're always accompanied by slight rise in the average voltage that tapers off afterward.

pneumatic
 
Posts: 176
Joined: Sun Jul 26, 2009 3:59 pm
Location: Newark, CA

Re: Real sounds or electrical noise?

by pneumatic on Fri Jul 17, 2020 1:51 am

I had almost convinced myself that they were actual sounds (like the creaking of my chair or something), when I decided to move the mic to another room, and the frequency of the readings went way up despite being in a quiet room.

This is a perfect example:
Image

If I were playing this back as an audio clip, I'm pretty sure I'd hear this as a pop in an otherwise quiet recording.

The circuit is pretty simple:

Image

pneumatic
 
Posts: 176
Joined: Sun Jul 26, 2009 3:59 pm
Location: Newark, CA

Re: Real sounds or electrical noise?

by pneumatic on Fri Jul 17, 2020 3:01 pm

I think I've fixed it.

The shield it was connected to was a DS3231 RTC featherwing that I had been using for it's 8kHz square wave, before I decided to use the M0's internal timer interrupt routines, (which turn out to be better suited to what I'm doing anyway.) So the RTC was entirely superfluous, and the A2 pin that the mic was using was right next to the square wave output, which was now putting out a 1hZ square wave. I wondered if that 1Hz wave was being capacitively coupled to the mic pin, so I ditched the RTC and wired up a protoshield with the mic, and that seems to have fixed the problem.

So, either it was the RTC, or my crappy soldering the first time had a cold solder joint, which is at least as likely.

pneumatic
 
Posts: 176
Joined: Sun Jul 26, 2009 3:59 pm
Location: Newark, CA

Re: Real sounds or electrical noise?

by adafruit_support_mike on Sun Jul 19, 2020 4:43 am

Based on your second image (with the spikes occurring at reasonably uniform intervals), capacitive coupling is a more likely suspect than a marginal solder joint.

Bad joints tend to produce popcorn noise, which looks like someone flipping a switch between two reasonably-constant voltages at random intervals. It's a side effect of the fact that electrons pass through any surface in an all-or-nothing way, but at random times. Every grain boundary in a cold joint makes a surface the electrons have to pass through, and the noise shows the random clumping.

The fact that you only got spikes going one way, and that there was a slight change after the spike that decayed exponentially (I know that curve by heart) points toward a burst of external energy that charges a capacitor, then bleeds away.

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: Real sounds or electrical noise?

by pneumatic on Sun Jul 19, 2020 10:05 pm

I realize I have redundant threads, so I'll just stay on this one for now.

Assuming that I don't have a cold solder joint, then the next most likely is ground bounce or perhaps capacitive coupling if I understand correctly. But the circuit is pretty simple:
Image

(And the blue temperature sensor isn't even in the circuit.) I don't know what could be causing either of those. I don't have many long parallel runs with the mic output except for the Vcc and GND lines that go to the AMP, and I would expect those voltages to be fairly steady. Similarly I doubt that anything is pulling enough power to cause a ground bounce. I could stick a big cap between Vcc and GND on the mic just to be sure I suppose.

(this is why I hated analog circuits in college... too fiddly)

pneumatic
 
Posts: 176
Joined: Sun Jul 26, 2009 3:59 pm
Location: Newark, CA

Re: Real sounds or electrical noise?

by pneumatic on Mon Jul 20, 2020 1:43 am

Wacko theory #625, it's the WiFi:
I got a series of dips that were strangely uniform.
Image
The first one was an anomaly, but the rest occured almost exactly at the same place in the buffer.
Image
Image
Image
Each dip occurred about 100 measurements into the packet. Now the way my code works is that if there's a big swing from the mean--either positive or negative, then the buffer gets flagged to be sent to the server, but the sending happens asynchronously. It also takes a while to construct the packet and send it.. about 10ms, or 100 readings. When the packet gets sent, I am guessing one of two things happen to cause the dip. Either:
    1) The power draw causes a ground bounce
    2) The wifi signal gets picked up by the short wire that connects the amp output to the analog pin
If it's #2, then that would explain why it's not consistent.... the wire changes orientation and that causes it to pick up the signal differently. It also reminds me of the other thing about working with analog circruits (especially RF), and that is keep your wires short or they'll pick up random stuff. I'll try making the wires much shorter and see if that helps.
If it's #1 I'm not sure what I can do, other than a filter cap maybe?

pneumatic
 
Posts: 176
Joined: Sun Jul 26, 2009 3:59 pm
Location: Newark, CA

Re: Real sounds or electrical noise?

by pneumatic on Mon Jul 20, 2020 2:58 am

So far, using (much) shorter wires seems to have done the trick. I basically just mounted the microphone boards straight to a small strip of header on the protoboard wing, and the only wire needed was about 1 inch long for the output line.

Update: Well.. it's better, but once I cranked up the sensitivity to where I would like it to be, I'm getting phantom triggers again. :-/

pneumatic
 
Posts: 176
Joined: Sun Jul 26, 2009 3:59 pm
Location: Newark, CA

Re: Real sounds or electrical noise?

by pneumatic on Tue Jul 21, 2020 2:22 pm

I added a big honkin' (1000 microfarad) filter cap between 3.3v and gnd:
Image
And if anything it made the problem worse.

Any other ideas?

pneumatic
 
Posts: 176
Joined: Sun Jul 26, 2009 3:59 pm
Location: Newark, CA

Re: Real sounds or electrical noise?

by adafruit_support_mike on Wed Jul 22, 2020 10:49 pm

Your theory about Wifi sounds reasonable. That's an EMF source, and the protoboard's traces are right over the antenna.

Try using a couple runs of twisted pair for the connections between the Feather and the mic: one pair carrying 3V and GND, and the other connected to the mic's output and GND. For the mic pair, use a GND pin as close to the analog input as possible, and only make the GND connection on the Feather side. That will give the best cancellation of induced EMF as seen at the analog input.

If you're only interested in the amplitude, you might want to try a simple peak detector:

peak detector.png
peak detector.png (49.77 KiB) Viewed 28 times

You can scale the capacitor to minimize any EMF spikes, if that's what they are, then choose a resistor that drains the cap quickly enough to catch the next peak.

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: Real sounds or electrical noise?

by pneumatic on Thu Jul 23, 2020 1:53 am

Thanks for the reply. I'll try to use a twisted pair for the mic out, but for the power I'm just using the power rails on the proto board like so:
Image

The peak detector is intriguing, but I worry it will affect the timing differently on different boards since they'll each have their own RC time constant for the peak detector. My project is more sensitive to timing vs. intensity. I need to keep 4 microphones (and their microcontrollers) agreeing on when the sound happened to withing a few hundred microseconds. I've got two of them agreeing to within about 300 microseconds using a modified NTP clients, and I hope to get better with a little more tuning and tweaking. I'm trying to do sound triangulation similarly to the way GPS does triangulation with the timing from satellites, except with sound. My calculations say that every millisecond of timing error corresponds to about 1 degree of directional error with the baselines I can manage at home. I'm trying to keep my timing errors small enough that I can get 0.2 to 0.3 degree resolution.

In a future revision I may try to use the LoRa versions and increase my baseline to hundreds of meters, rather than the 20 I can get in my back yard.

pneumatic
 
Posts: 176
Joined: Sun Jul 26, 2009 3:59 pm
Location: Newark, CA

Re: Real sounds or electrical noise?

by pneumatic on Thu Jul 23, 2020 7:58 pm

Well... That didn't work either, and again may have made the problem worse.
Image

I'm getting 20-30 buffers of spurious readings per second, out of a possible 50 (number of buffers I fill per second). I may have to just fix this is software, but it's going to be ugly.

pneumatic
 
Posts: 176
Joined: Sun Jul 26, 2009 3:59 pm
Location: Newark, CA

Re: Real sounds or electrical noise?

by adafruit_support_mike on Sun Jul 26, 2020 2:22 am

Hrm.. what happens if you move the mic and protoboard well away from the Feather, and make the connection between them with twisted pair?

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Re: Real sounds or electrical noise?

by pneumatic on Sun Jul 26, 2020 3:03 am

Hmm.. maybe I'll give that a try if I get ambitious.

For now I solved it in software (only triggering on positive swings rather than negative, since all the real events seem to have both.)

It's still happening, as you can see in this test of my curve matching algorithm:
Image

See the downward spikes on the purple and green traces toward the middle? At least it doesn't appear to be affecting my algorithm.

pneumatic
 
Posts: 176
Joined: Sun Jul 26, 2009 3:59 pm
Location: Newark, CA

Re: Real sounds or electrical noise?

by adafruit_support_mike on Sun Jul 26, 2020 3:31 am

You can approximate the diode peak detector in software by keeping a maximum value that decays over time:

Code: Select all | TOGGLE FULL SIZE
    MAX = ( MAX <= reading ) ? reading : (19 * MAX) / 20;
That will catch positive spikes and ignore negative ones.

adafruit_support_mike
 
Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.