snowman815
Member
Edit 5/27/14 5:10 pm PST: Thank you for all of the responses, I've increased the size of the serial monitor screen shots to make them more legible and added the code I'm using at the bottom of the post. Also, to clarify, each column in the serial monitor corresponds to a frequency band of the audio signal, low on the left, high on the right, ranging from ~120hz to 24khz (I think, can't remember exactly) Thanks again!
Hello all,
I'm using MSGEQ7 audio spectrum analyzer ICs to turn a strip of LEDs into a audio spectrum visualizer. I had originally designed this project to use an arduino UNO but due to other aspects of the project I switched to using a Teensy 3.1 for this portion. Switching back is not an option.
The hardware is pretty simple, I'm using a MAX4466 electret microphone with adjustable gain, input voltage from 3-5v (5v recommended, though I've had better results in all cases with 3.3v input). The output from the microphone goes to the MSGEQ7, 3-5v input (5v recommended) which breaks the audio signal into 7 analog signals, one for each frequency band. Those signals are then read by the controller and mapped to brightness values on the LED strip.
To get additional frequency bands I'm using 5 MSGEQ7's total with their clocks shifted by various capacitors and resistors to give me a total of 35 bands. I built this on a homemade double sided circuit board (probably not relevant but I'm proud of it so I'll post it below).
When using the UNO I powered the microphone with 3.3v, the MSGEQ7s with 5v, and was able to read all of the analog outputs with acceptable levels of noise without any fuss. BUT, now that I've migrated to Teensy, I run into a problem (about problem number 300 on this project).
I've tried many combinations of input voltages to the devices and using the analog or digital ground for either the microphone or the analyzer or both. I've also tried using a voltage divider to bring the signal from the MSGEQ7s down to the 0 - 3.3v range.
I've tried:
Microphone............MSGEQ7s...........AGND/GND...................OTHER.....................................................Result
5v........................5v........................GND........................n/a...................................................Unacceptable noise
3.3v......................5v.......................GND........................n/a...................................................Unacceptable noise
5v........................3.3v.....................GND........................n/a...................................................Unacceptable noise
3.3v......................3.3v.....................GND........................n/a...................................................Unacceptable noise
5v........................5v........................AGND ......................n/a...................................................Unacceptable noise
3.3v......................5v.......................AGND.......................n/a...................................................Unacceptable noise
5v........................3.3v.....................AGND.......................n/a...................................................Unacceptable noise
3.3v......................3.3v.....................AGND.......................n/a...................................................Unacceptable noise
5v........................5v........................GND........................Voltage divider 47k & 91k.......................Unacceptable noise
3.3v......................5v.......................GND........................Voltage divider 47k & 91k.......................Unacceptable noise
5v........................5v........................AGND......................Voltage divider 47k & 91k.......................Unacceptable noise
3.3v......................5v.......................AGND......................Voltage divider 47k & 91k....................... Unacceptable noise
Here's what my values look like in the serial monitor in a few different setups. (they're legible on my screen, let me know if they aren't on yours):
UNO, microphone: 3.3v, MSGEQ7s: 5v.
Teensy 3.1, microphone: 3.3v, MSGEQ7s: 5v.
Teensy 3.1, microphone: 3.3v, MSGEQ7s: 5v w/voltage divider.
The other options I'm looking at are:
A) Use an op-amp to shift the voltage levels down (I'm not familiar with using op-amps for anything so this would take some additional learning on my part)
B) Use an external ADC to read the signals then read the data from the external ADC via i2c to get my values. I am a little worried that getting 35 values this way and displaying them in as near to real time as possible on 288 LEDs might be an issue, but I don't know of any way to calculate that risk without just trying it.
I don't understand why the Teensy would be getting so much more noise even with the signals brought down to the proper range. The teensy isn't just fundamentally noisier is it? Could it have something to do with the resolution of the Teensy's ADC vs. the UNOs ADC? I can't help but think that I'm just missing something about the Teensy that differs from an Arduino UNO. I'm completely self taught when it comes to electronics other than my basic electrical knowledge from being an electrician so ignorance is VERY possibly the root of the problem here.
I don't think my code is relevant in this case since I don't have any issues with it but it is available if anyone thinks it could help.
And of course, thank you very much for taking the time to look at this and know that your help will be greatly appreciated.
Here is the code I'm using below:
Hello all,
I'm using MSGEQ7 audio spectrum analyzer ICs to turn a strip of LEDs into a audio spectrum visualizer. I had originally designed this project to use an arduino UNO but due to other aspects of the project I switched to using a Teensy 3.1 for this portion. Switching back is not an option.
The hardware is pretty simple, I'm using a MAX4466 electret microphone with adjustable gain, input voltage from 3-5v (5v recommended, though I've had better results in all cases with 3.3v input). The output from the microphone goes to the MSGEQ7, 3-5v input (5v recommended) which breaks the audio signal into 7 analog signals, one for each frequency band. Those signals are then read by the controller and mapped to brightness values on the LED strip.
To get additional frequency bands I'm using 5 MSGEQ7's total with their clocks shifted by various capacitors and resistors to give me a total of 35 bands. I built this on a homemade double sided circuit board (probably not relevant but I'm proud of it so I'll post it below).
When using the UNO I powered the microphone with 3.3v, the MSGEQ7s with 5v, and was able to read all of the analog outputs with acceptable levels of noise without any fuss. BUT, now that I've migrated to Teensy, I run into a problem (about problem number 300 on this project).
I've tried many combinations of input voltages to the devices and using the analog or digital ground for either the microphone or the analyzer or both. I've also tried using a voltage divider to bring the signal from the MSGEQ7s down to the 0 - 3.3v range.
I've tried:
Microphone............MSGEQ7s...........AGND/GND...................OTHER.....................................................Result
5v........................5v........................GND........................n/a...................................................Unacceptable noise
3.3v......................5v.......................GND........................n/a...................................................Unacceptable noise
5v........................3.3v.....................GND........................n/a...................................................Unacceptable noise
3.3v......................3.3v.....................GND........................n/a...................................................Unacceptable noise
5v........................5v........................AGND ......................n/a...................................................Unacceptable noise
3.3v......................5v.......................AGND.......................n/a...................................................Unacceptable noise
5v........................3.3v.....................AGND.......................n/a...................................................Unacceptable noise
3.3v......................3.3v.....................AGND.......................n/a...................................................Unacceptable noise
5v........................5v........................GND........................Voltage divider 47k & 91k.......................Unacceptable noise
3.3v......................5v.......................GND........................Voltage divider 47k & 91k.......................Unacceptable noise
5v........................5v........................AGND......................Voltage divider 47k & 91k.......................Unacceptable noise
3.3v......................5v.......................AGND......................Voltage divider 47k & 91k....................... Unacceptable noise
Here's what my values look like in the serial monitor in a few different setups. (they're legible on my screen, let me know if they aren't on yours):
UNO, microphone: 3.3v, MSGEQ7s: 5v.
Teensy 3.1, microphone: 3.3v, MSGEQ7s: 5v.
Teensy 3.1, microphone: 3.3v, MSGEQ7s: 5v w/voltage divider.
The other options I'm looking at are:
A) Use an op-amp to shift the voltage levels down (I'm not familiar with using op-amps for anything so this would take some additional learning on my part)
B) Use an external ADC to read the signals then read the data from the external ADC via i2c to get my values. I am a little worried that getting 35 values this way and displaying them in as near to real time as possible on 288 LEDs might be an issue, but I don't know of any way to calculate that risk without just trying it.
I don't understand why the Teensy would be getting so much more noise even with the signals brought down to the proper range. The teensy isn't just fundamentally noisier is it? Could it have something to do with the resolution of the Teensy's ADC vs. the UNOs ADC? I can't help but think that I'm just missing something about the Teensy that differs from an Arduino UNO. I'm completely self taught when it comes to electronics other than my basic electrical knowledge from being an electrician so ignorance is VERY possibly the root of the problem here.
I don't think my code is relevant in this case since I don't have any issues with it but it is available if anyone thinks it could help.
And of course, thank you very much for taking the time to look at this and know that your help will be greatly appreciated.
Here is the code I'm using below:
Code:
int analogPins[5] = {
0, 1, 2, 3, 4}; // MSGEQ7 OUT 3
int strobePin = 2; // MSGEQ7 STROBE 4
int resetPin = 4; // MSGEQ7 RESET 7
int spectrumValue[35];
// MSGEQ7 OUT pin produces values around 50-80
// when there is no input, so use this value to
// filter out a lot of the chaff.
int filterValue = 94;
void setup()
{
Serial.begin(115200);
// Read from MSGEQ7 OUT
for (int i = 0; i <5; i++)
{
pinMode(analogPins[i], INPUT);
}
// Write to MSGEQ7 STROBE and RESET
pinMode(strobePin, OUTPUT);
pinMode(resetPin, OUTPUT);
// Set startup values for pins
digitalWrite(resetPin, LOW);
digitalWrite(strobePin, HIGH);
}
void loop()
{
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);
for ( int i = 0; i < 7; i++)
{
digitalWrite(strobePin, LOW);
delayMicroseconds(30); // Allow output to settle
for (int j = 0; j < 5; j++)
{
spectrumValue[(i*5)+j] = analogRead(analogPins[j]);
spectrumValue[(i*5)+j] = constrain(spectrumValue[(i*5)+j], filterValue, 1023);
spectrumValue[(i*5)+j] = map(spectrumValue[(i*5)+j], filterValue, 1023, 0, 255);
Serial.print(spectrumValue[(i*5)+j]);
if (spectrumValue[(i*5)+j] < 10)
{
Serial.print(" ");
}
else if ((spectrumValue[(i*5)+j] < 100))
{
Serial.print(" ");
}
else
{
Serial.print(" ");
}
}
digitalWrite(strobePin, HIGH);
}
Serial.println(" ");
}
Last edited: