Unwanted Noise in Microphone

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
hockeyman271
 
Posts: 1
Joined: Wed Jan 08, 2014 8:41 pm

Unwanted Noise in Microphone

Post by hockeyman271 »

Hello everyone!

For the last couple of months ive been tinkering with an LED pixel table for my house, I want to add full music integration but i keep running into this random noise when reading values from the microphone ONLY when i have the LED's running as well....

The components im using are..
  • ~Arduino Uno R3
    ~Electret Microphone Amplifier - MAX4466 with Adjustable Gain
    ~12mm Diffused Flat Digital RGB LED Pixels (99 of them)
The code below displays a VU meter on the left and right side of the table, while lighting up the box in the middle with a random color, you can see from the videos below this code that certain colors give different levels of interference. When the inner box (pixels between the VU meters) are not lit up there is 0 interference...

Code: Select all

#include "SPI.h"
#include "Adafruit_WS2801.h"

uint8_t dataPin  = 2; 
uint8_t clockPin = 3;
Adafruit_WS2801 strip = Adafruit_WS2801((uint16_t)11, (uint16_t)9, dataPin, clockPin);
const int sampleWindow = 25; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;
const int maxScale = 9;
const int redZone = 7;
int tColor = 0;
int L = 0;

void setup() 
{
   Serial.begin(9600);
   strip.begin();
   strip.show();
}

void loop()
{
   unsigned long startMillis= millis();  // Start of sample window
   unsigned int peakToPeak = 0;   // peak-to-peak level
 
   unsigned int signalMax = 0;
   unsigned int signalMin = 1024;
   while (millis() - startMillis < sampleWindow)
   {
      sample = analogRead(0); 
      if (sample < 1024)  // toss out spurious readings
      {
         if (sample > signalMax)
         {
            signalMax = sample;  // save just the max levels
         }
         else if (sample < signalMin)
         {
            signalMin = sample;  // save just the min levels
         }
      }
   }
   peakToPeak = signalMax - signalMin;
      // map 1v p-p level to the max scale of the display
   int displayPeak = map(peakToPeak, 0, 1023, 0, maxScale);
   
    visual(displayPeak);
    strip.show();
    
    // Light center of table with increasing color
    if((L+1) % 2==0)
    {
      for ( int x = 0; x < 11; x++)
      {
        for (int y = 0; y < 9; y++)
        {
          strip.setPixelColor(x, y, Wheel(tColor));
        }
      }
      tColor++;
   }
   
   L++;
}

void visual(uint16_t displayPeak)
{
   for (int i = 0; i <= maxScale; i++)
   {
      if (i >= displayPeak)  // blank these pixels
      {
         if ( i == 8)
         {
           for (int u = 0; u < 11; u++)
           {
              strip.setPixelColor(u, i, 0, 0, 0);
           }
         }
         else
         {
           strip.setPixelColor(0, i, 0, 0, 0);
           strip.setPixelColor(10, i, 0, 0, 0);
         }
      }
      else if (i < 5) // draw in green
      {
         strip.setPixelColor(0, i, 0, 255, 0);
         strip.setPixelColor(10, i, 0, 255, 0);

      }
      else if ( i > 4 & i < redZone)
      {
         strip.setPixelColor(0, i, 255, 255, 0);
         strip.setPixelColor(10, i, 255, 255, 0);
      }
      else // Red Alert!  Red Alert!
      {
          strip.setPixelColor(0, i, 255, 0, 0);
          strip.setPixelColor(10, i, 255, 0, 0);
          for(int x =0; x< 11; x++)
          {
             strip.setPixelColor(x, 8, 255, 0, 0);  
          }
      }
   }
}

/* Helper functions */

// Create a 24 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
  uint32_t c;
  c = r;
  c <<= 8;
  c |= g;
  c <<= 8;
  c |= b;
  return c;
}

//Input a value 0 to 255 to get a color value.
//The colours are a transition r - g -b - back to r
uint32_t Wheel(byte WheelPos)
{
  if (WheelPos < 85) {
   return Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if (WheelPos < 170) {
   WheelPos -= 85;
   return Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170; 
   return Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}
Here are some pics of the wiring for the arduino, remember this is still in a plug and play mode so that changes can be easily made, therefore its not pretty...
The Brain of the table
The Brain of the table
IDT-Brain.png (462.11 KiB) Viewed 243 times
I have tried shielding both the AREF wire and the Analog out wire, and i added a small capacitor between VCC and GND on the microphone, Ive tried using the 3.3v and 5v power sources on the arudino it self as well as my external power source that runs the LEDs, nothing has made the slightest difference in the noise...

Here is the table running WITHOUT the center lit up, you'll see there's no interference and the table responds just fine to the music,

https://www.youtube.com/watch?v=-SylV1rVa8w

Here is the table running with the center lit up, you can see that as certain colors fade into the middle the interference follows accordingly....

https://www.youtube.com/watch?v=DrZ2BpfmWng

Please someone help me! this has been a huge barrier for me and has kept me from advancing any further...

Thanks everyone!

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

Re: Unwanted Noise in Microphone

Post by adafruit_support_mike »

The LED data signals may be injecting some noise into the Arduino's GND rail. The ADC will see that as noise in both the AREF and signal voltages.

Try putting a 10uF cap between AREF and GND on the Arduino. Try to keep the leads as close to AREF as possible. Also try putting a cap between the ADC pin and GND at the Arduino end of the connection. Those won't really stop the noise, but they'll copy the noise on the GND line up to the AREF and signal lines.

Any voltage measurement is V.node1 - V.node2, and what you have now sounds like V.aref - (V.gnd + V.noise). If you turn that into (V.aref + V.noise) - (V.gnd + V.noise), the noise terms drop out.

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

Return to “Arduino”