Graphic Equalizer Display Filter - MSGEQ7

Thread Starter

gerases

Joined Oct 29, 2012
177
Hello,

I'm trying to test the audio filter chip. According to the data sheet,
the capacitors should be 0.01nF (for the audio input pin) 0.1nF. I use Audacity
to generate tones of varying frequency (63Hz, etc).

0.01 and 0.1 capacitors don't seem to work at all. Elsewhere in various
tutorials I found 100nF and 10nF used instead. With them I do see better
results. But, the main problem now is that when I generate, say, a 63Hz
signal through Audacity the adjacent frequencies react as well. And...
the more I crank up the volume the more adjacent frequencies are
affected -- and the higher the readings are. I thought the loudness of
the signal would be irrelevant for this chip? I.e., I thought it would
react only to the frequency.

Do I need a function generator or something like Audacity should work for a test?

Below is the program I found in a tutorial. A variation of it seems to
be used by everybody. As you can see it prints a value for each of the
seven frequencies through the console.

Thanks!
Sergei

#include "Arduino.h"
#include "Servo.h"
void setup();
void loop();

int analogPin = 0; // read from multiplexer using analog input 0
int strobePin = 2; // strobe is attached to digital pin 2
int resetPin = 3; // reset is attached to digital pin 3
int spectrumValue[7]; // to hold a2d values

void setup()
{
Serial.begin(9600);
pinMode(analogPin, INPUT);
pinMode(strobePin, OUTPUT);
pinMode(resetPin, OUTPUT);
analogReference(DEFAULT);

digitalWrite(resetPin, LOW);
digitalWrite(strobePin, HIGH);

Serial.println("MSGEQ7 test by J Skoba");
}

void loop()
{
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);

for (int i = 0; i < 7; i++)
{
digitalWrite(strobePin, LOW);
delayMicroseconds(30); // to allow the output to settle
spectrumValue = analogRead(analogPin);

// comment out/remove the serial stuff to go faster
// - its just here for show
if (spectrumValue < 10)
{
Serial.print(" ");
Serial.print(spectrumValue);
}
else if (spectrumValue < 100 )
{
Serial.print(" ");
Serial.print(spectrumValue);
}
else
{
Serial.print(" ");
Serial.print(spectrumValue);
}

digitalWrite(strobePin, HIGH);
}
Serial.println();
}
 

crutschow

Joined Mar 14, 2008
24,396
The data sheet shows a 0.01μF (10nF) not a 0.01nF capacitor at the input.

The circuit has a series of switched-capacitor filters to generate the various outputs. No filter is perfect so there will always be some response generated in adjacent outputs for a given large signal input at one frequency. Normally that's not a problem for audio applications.
 

Thread Starter

gerases

Joined Oct 29, 2012
177
The data sheet shows a 0.01μF (10nF) not a 0.01nF capacitor at the input.
I totally made a fool of myself. Yes, of course, I see my mistake now.

The circuit has a series of switched-capacitor filters to generate the various outputs. No filter is perfect so there will always be some response generated in adjacent outputs for a given large signal input at one frequency. Normally that's not a problem for audio applications.
Yes, but if you look here: http://nuewire.com/info-archive/msgeq7-by-j-skoba/, you will see that if the frequency in question is for example 400Hz, then the numbers will be around 800-900 for that channel and about 150 for the adjacent channels. In my case, it's more like 900 and 800.

The datasheet from the manufacturer is here:

http://www.mix-sig.com/datasheets/MSGEQ7.pdf

As you can see, here 100nF caps are used throughout, but that didn't help much. I.e., adjacent channels are still too high.
 
Last edited:

thatoneguy

Joined Feb 19, 2009
6,359
What are your adjacent channel levels if given a signal at one of the center points, say, 1kHz?

The Q factor for the IC is 6, so each "bucket" will have a -3dB bandwidth of 0.25 Octaves (pretty narrow).
 

Thread Starter

gerases

Joined Oct 29, 2012
177
This mystery has been solved I think. The problem was and I verified this with an oscilloscope, that as the input audio amplitude increases above 0.5V peak-to-peak, the target frequency "bleeds" into the adjacent frequencies. The more the voltage the more the bleeding. The datasheet actually mentions 100mV test conditions (it doesn't say what the maximum value is). My laptop audio out goes all the way to 2.6V if I remember correctly.

Bottom line: if the input is limited to 0.5V, it's pretty accurate.

Question #1: how do I give a max of 0.5 to that pin no matter what the volume on my laptop is?

Question #2: My laptop, which is an old beast I bought off eBay, produces quite a bit of high-frequency noise, which affected the operation of the chip. What's the best way to get rid of it? A capacitor? Or is there something really effective?

Question #3: Ironically I bought the chip thinking I would build a color organ based on it. But now I'm thinking it's not the best idea because breaking audio into seven frequencies and blinking the leds (light bulbs in the future) will just show you that -- frequency content, not the beat/rhythm of the music. For the rhythm I think I need the amplitude + frequency. Wouldn't you agree? So for example if the signal's amplitude is above a certain threshold, I would pwm-flash a group of LEDs.

It seems that other people are using that chip alone for a color organ and I don't think by itself it reflects what's going on in a song beat wise. So, I think I need to both split the signal into frequencies and amplify the signal for amplitude analysis. What do you think?
 

crutschow

Joined Mar 14, 2008
24,396
#1: You can use a resistive divider to reduce the maximum voltage to 0.5V. To reduce 2.6V to 0.5V, for example, you could use a 21kΩ resistor in series with a 4.99kΩ resistor to ground (or other combination with the same ratio).

#2: You can use a simple high pass filter (series capacitor with resistor to ground) to reduce the low frequency components. The roll-off frequency is f= 1/(2\(\pi\)RC). The capacitor could be in series with the resistive divider from #1. R would be the sum of the two resistors.

#3: The outputs of the chip are proportional to the amplitude of that frequency, so the low frequency outputs should give you a beat for the low frequency content.
 

Thread Starter

gerases

Joined Oct 29, 2012
177
#1: You can use a resistive divider to reduce the maximum voltage to 0.5V. To reduce 2.6V to 0.5V, for example, you could use a 21kΩ resistor in series with a 4.99kΩ resistor to ground (or other combination with the same ratio)
Yes, I thought about a resistive divider, but I don't know what my volume will be set at. Maybe a zener diode or something like that?

#2: You can use a simple high pass filter (series capacitor with resistor to ground) to reduce the low frequency components. The roll-off frequency is f= 1/(2RC). The capacitor could be in series with the resistive divider from #1. R would be the sum of the two resistors.
A little confused about reducing low frequencies. Wouldn't I want to reduce high frequencies instead to get rid of the noise?

By the way, I always wondered why there has to be a resistor in a high/low pass RC filter. Is that to protect the power supply in case the resistance of the capacitor goes very low?

#3: The outputs of the chip are proportional to the amplitude of that frequency, so the low frequency outputs should give you a beat for the low frequency content.
Oh yeah, come to think of it, it must be true. Thank you.
 

crutschow

Joined Mar 14, 2008
24,396
Yes, I thought about a resistive divider, but I don't know what my volume will be set at. Maybe a zener diode or something like that?

A little confused about reducing low frequencies. Wouldn't I want to reduce high frequencies instead to get rid of the noise?

By the way, I always wondered why there has to be a resistor in a high/low pass RC filter. Is that to protect the power supply in case the resistance of the capacitor goes very low?

Oh yeah, come to think of it, it must be true. Thank you.
A zener diode will clip the signals producing high frequency distortion, which would cause the high frequency LEDs to light more.

Yes somehow I read your post backwards. You need a series resistor with a capacitor to ground (or across the resistor to ground) to give a low-pass filter, reducing the high frequencies.

The resistor is what determines the roll-off frequency of the filter. If its just a capacitor then it will react with any resistance already in the circuit to form an arbitrary roll-off frequency. Generally you want a specific, known roll-off frequency so frequencies outside the rolloff aren't affected. It has nothing to do with the power supply.
 

Thread Starter

gerases

Joined Oct 29, 2012
177
The resistor is what determines the roll-off frequency of the filter. If its just a capacitor then it will react with any resistance already in the circuit to form an arbitrary roll-off frequency. Generally you want a specific, known roll-off frequency so frequencies outside the rolloff aren't affected. It has nothing to do with the power supply.
I see. Awesome. Now, is there a better way to keep 0.5 volts peak-to-peak no matter what -- of course the supply must be at least 0.5?
 

crutschow

Joined Mar 14, 2008
24,396
If you want to keep a constant 0.5V when the input is varying, then you can use an AGC (automatic gain control) amplifier. But that would be a somewhat complex circuit. Can't you just adjust the volume control to what you need?
 

Thread Starter

gerases

Joined Oct 29, 2012
177
If you want to keep a constant 0.5V when the input is varying, then you can use an AGC (automatic gain control) amplifier. But that would be a somewhat complex circuit. Can't you just adjust the volume control to what you need?
Yes, I sure can and probably will for now. Just curious about various scenarios. You've been very helpful. Thanks so much. Especially about the simple fact that the beat is contained in the lower frequencies. I tried it yesterday and it worked much better. A little more adjustment and hopefully I'll be out of the woods.

Another mistake I made is forget about a pull down resistor on the analog "in" pin on my Arduino. I'm clearly shouldn't be in charge of the GPL lab :D

Slightly off topic, a question about my oscilloscope. When I have no input connected to the problem and I just touch the positive end of the probe, it shows me a sine wave of some crazy frequency and 240 mV peak-to-peak. Same about touching it with something metal. Is that normal? Can I adjust it somehow not to be so "sensitive"?
 

MrChips

Joined Oct 2, 2009
20,293
You can use an automatic gain control (AGC), compandor or log circuit. They are not that difficult.
Slightly off topic, a question about my oscilloscope. When I have no input connected to the problem and I just touch the positive end of the probe, it shows me a sine wave of some crazy frequency and 240 mV peak-to-peak. Same about touching it with something metal. Is that normal? Can I adjust it somehow not to be so "sensitive"?
Measure the frequency and you will find it is at AC line frequency.
Your body or anything conductive is an antenna. There is 60Hz (or 50Hz) noise everywhere. This is normal. No point in trying to correct this. It is actually a useful method of checking that your probe/scope is working.
 

Thread Starter

gerases

Joined Oct 29, 2012
177
Measure the frequency and you will find it is at AC line frequency.
Your body or anything conductive is an antenna. There is 60Hz (or 50Hz) noise everywhere. This is normal. No point in trying to correct this. It is actually a useful method of checking that your probe/scope is working.
Wow, didn't know. Thanks much for the info. I think it was 60Hz! Problem is I don't know if I'm getting audio or not :( How do I know it's just noise and not signal?
 

MrChips

Joined Oct 2, 2009
20,293
AC mains frequency (60Hz noise) is the number one enemy of any low level detection system.
It's like a weed. If you want it then its ok. If you don't want it, it is noise.

One way to avoid it is to operate off batteries in the middle of nowhere far away from power lines.
 

crutschow

Joined Mar 14, 2008
24,396
AC mains frequency (60Hz noise) is the number one enemy of any low level detection system.
It's like a weed. If you want it then its ok. If you don't want it, it is noise.

One way to avoid it is to operate off batteries in the middle of nowhere far away from power lines.
Or do the test in a screen room. ;)
 

Thread Starter

gerases

Joined Oct 29, 2012
177
Yes, I forgot there are single-chip audio circuits that perform those functions such as this, which should be fairly easy to incorporate.
Great chip. Will take a look into it!

A couple more questions if you don't mind.

1) The datasheet has both audio channels combined on the input of that chip but Sparkfun's board seems to have two chips, one for each input.

2) What's the best way to implement a pass through audio connector so I can hear what's playing? I put another audio connector on the board and jumped the signal from the first into the second, but there seems to be a little bit of noise added as a result. Am I missing something crucial?
 

crutschow

Joined Mar 14, 2008
24,396
Great chip. Will take a look into it!

A couple more questions if you don't mind.

1) The datasheet has both audio channels combined on the input of that chip but Sparkfun's board seems to have two chips, one for each input.

2) What's the best way to implement a pass through audio connector so I can hear what's playing? I put another audio connector on the board and jumped the signal from the first into the second, but there seems to be a little bit of noise added as a result. Am I missing something crucial?
1) It depends upon whether you want a separate display for each channel or not.

2) Jumpering as you indicated should work. What type of noise?
 
Top