MSGEQ7 and MAX9814

First, let me say that I'm a total beginner and will probably have some obvious and clear mistakes in my design. Any help would be appreciated. I am trying to build a VU meter using a MAX9814, MSGEQ7 and Arduino Nano. In this test, I'm powering the project from the USB port of my computer.

Circuit Diagram:

I'm working on the spectrum analysis circuit and I'm seeing values of 400-600 with no sound in the room. To my untrained eye, I think I'm having an issue with the voltage divider between the MAX9814 and MSGEQ7. From what I've read, the MAX9814 outputs 2Vpp and the MSGEQ7 is expecting a 300mVpp. I tried to calculate the voltage drop and choose R1 value of 47k and since i didn't have a single 268k resistor for R4 I used a 220k and 47k in series. Did I mess up the voltage divider and allow too much voltage to enter the MSGEQ7 to measure accurately? I figure the breadboard would add a little bit of noise but usually I see people sitting at 40-50 in a quite room but my values are 10x that. Is that to be expected?

I'm also seeing overlap in the peaks when using Audacity to step through the MSGEQ7 frequencies (63hz, 160hz, 400hz, 1000hz, 2500hz, 6350hz and 16000hz). The MSGEQ7 also doesn't read the first and last frequency very well at all. The others peak out pretty well aside from the overlap.

I have 3 MSGEQ7s and they all show the same output pattern

Below is my code, a picture of the layout, and a video of the serial plotter/monitor during an Audacity sweep of frequencies played from my computer:

Code:

#define STROBEPIN         10
#define RESETPIN          6
#define MSGEQ7READPIN     A1
#define TOTALFREQUENCIES  7

uint16_t RawFrequencies[TOTALFREQUENCIES];

void PrintData()
{
  for (int FrequencyIndex = 0; FrequencyIndex < TOTALFREQUENCIES; FrequencyIndex++)
  {
    Serial.print(RawFrequencies[FrequencyIndex]);
    Serial.print(" ");
  }
  Serial.println("");
}
void GetFrequencyData()
{
  digitalWrite(RESETPIN, HIGH);
  digitalWrite(RESETPIN, LOW);
  delayMicroseconds(80);
  for (int FrequencyIndex = 0; FrequencyIndex < TOTALFREQUENCIES; FrequencyIndex++)
  {
    digitalWrite(STROBEPIN, LOW);
    delayMicroseconds(40);
    RawFrequencies[FrequencyIndex] = analogRead(MSGEQ7READPIN);
    digitalWrite(STROBEPIN, HIGH);
    delayMicroseconds(40);
  }
}

void setup()
{
  Serial.begin(9600);
  pinMode(RESETPIN, OUTPUT);
  pinMode(STROBEPIN, OUTPUT);
  digitalWrite(RESETPIN,LOW);
  digitalWrite(STROBEPIN,HIGH);
}

void loop()
{
  GetFrequencyData();
  PrintData();
  delay(200);
}

Picture of my circuit

Test Run:
MSGEQ7 and MAX9814

Great job, even for a non beginner. The only thing I see on the schematic is the lead from C2 to goes through C3 which has a ground connection. Normally we do not run connections through components on the Schematic. It gets confusing. But the Great job still holds. Give this link a try it will help you with your calculations. Voltage Divider Calculator

This doesn't look right.

WOW! that's a really good calculator! Thanks for sharing that. It's going into my bookmark bar for sure. Looks like I did mess up the voltage division. I'll have to play around with the values to get it correct. Thanks again!

I'm terrible at schematics. That's probably one of those obvious errors. Did i mix up the positive and negative here?

Is that with the exact same circuit, including the MSGEQ7 (at least with a "similar" voltage divider)?

The MAX9814 has automatic gain control (although I believe that can be disabled). With quiet sounds, it's going to turn-up the gain as high as it can go, even if it's just amplifying noise.

Electrical noise will also be amplified by the MAX9814 and USB power can be noisy.

Here's what I'd suggest -

Take the MAX9814 out of the circuit by disconnecting R1.

Now, any noise readings are coming from the MSGEQ7.

If the readings are "reasonably low", test it with some direct test-signals. Generate tones at the 7 frequencies with Audacity. Connect your soundcard or headphone output to the junction of C1 & R4 and play those tones to see if everything is working as expected.

If that looks like it's working you can try some music (or other program material) "direct".

You can test the microphone & MAX9814 by connecting it to a pair of regular "powered" computer speakers. (Of course, keep the mic away from the speakers to prevent feedback.)

With room noise (and also music) the higher frequencies are usually weaker. I wouldn't expect the lowest range to be weak with room noise, but with music your speakers could be lacking bass. The direct test tones will tell you more.

What you're actually building is a "spectrum analyzer", or spectrum analyzer effect. :wink: A VU meter doesn't show frequency.

I've read a few of your posts on the MSGEQ7 specifically and you have helped me more than you know so far. Thank you for taking the time to reply to my post.

No, it was a different circuit. I just expected mine to have lower values in a quite room.

Ahhh! That makes sense, I did see some circuits with an envolope follower (I think that's the right term) to control the gain dynamically. That was a little too complex for me at this stage but I do plan to incorporate that after I get this working properly.

Good to know! Is there anyway to control for this or is that just inevitable?

I won't be able to test that right this minute but when I get home tonight, I will try these and report back! Thanks!

One question on this. Does how loud each frequency sounds to me matter? I notice that the mid frequencies are much louder, I'm guessing that's because of the way human hearing works (again, I know nothing but that's just my assumption) but does that effect the spectrum analyzer also? Is that where the AGC comes in?

Silly me. Alot of things make sense now.

You are a rockstar Doug. Thank you again.

1 Like

Did i mix up the positive and negative
[/quote] Yes but you have the IC oriented in the preferred method, +top. Signals (in Out) top town, left right. I missed the reverse polarity connections good catch.
That calculator and several others have been on my bookmarks bar for many a year. I have a folder I keep called Calc and it is in that along with all the other calculators I use.

I have an app on my Iphone called DB, it gives me the sound information, it is not perfect but it is close. I also have the app called Analyzer, it is a spectrum analyzer.

Thanks for all of your suggestions. I have updated my circuit to the following:

The changes I made:
R1 is now 330k from 47K
R4 is now 56K from 220K and R5 was removed
I did this because I think my voltage divider was misconfigured. I think I needed the higher value resistor near the MAX9814 and the lower value to ground. This brought my ambient sound readings down to the 200s instead of 400s

Troubleshooting Steps and Results:

First Step:

I removed R1 and tested the MSGEQ7 output with no input audio signal. My output was relatively low but the last 3 frequencies were distinctly higher. Not by much. Probably 10 or so. Not sure if that really matters or the reason for that. Overall, I think it was as expected.

Video of results:
R1 Removed MSGEQ7 Output

Second Step:

I didn't have a headphone cable that was made for doing something like this but I bought a set of cheap headphones and took them apart to see what wire was used for the left channel(not sure if it was required to use the left channel but I commonly read about people using the left channel when doing mono). Then I connected the left channel to C1 and this was the output of the MSGEQ7 with no audio playing:
PC Connected To C1 No Audio

Then I tried running the Audacity frequency step. I noticed some strange characteristics when running that test.
63Hz - Not as steady as the others but values of 650ish
160Hz - weakest values but steady at 400ish
400Hz - Steady values of 700ish
1000Hz - Steady values of 550ish
2500Hz - Steady values of 470ish
6350Hz - Steady values of 440ish
16000Hz - Steady values of 750ish
Overall, I think it was very successful. The overlapping I saw with the MAX9814 connected is completely gone but the peaks are so much lower than the MAX9814. If I change the volume, I can move the peak, do I need to dynamically adjust the gain based on the frequency I'm polling? I'm not using a resistor to connect my computer to C1. Is that a problem? It's also strange that the louder it is for me, the lower the output from the MSGEQ7 is (except 160Hz for some reason). Is that expected?
Here is the video:
PC Connected To C1 With Frequency Steps

Third Step:

This went very well. The peaks are all kind of low still but it reacts to the music played
PC Connected To C1 With Music

I didn't get a chance to test this. I couldn't find a set a speakers around me that I could use but I'll try to test this later. I'm starting to think the problem is in the MAX9814. Does that sound right?

Final Step:
I put the MAX9814 back into the circuit with the new voltage divider and I don't get maxed out peaks anymore (maybe I'm still messing up my voltage divider? but this time in the opposite direction?) I am still seeing frequency overlap and it's hard to tell signal from noise during some frequencies.
After Voltage Divider Change

Picture Of Circuit

Am I missing anything?

This is my analysis on the output when the MAX9814 is the input signal. Tell me if I'm crazy or totally wrong:

63Hz - At this frequency, I don't think i pick up (not sure if this is the accurate phrasing) 63Hz at all

160Hz - At this frequency, I can see a defined increase in signal from the noise but still weak. It also picks up the frequencies after it.

400Hz - At this frequency, the peak is pretty similar to the output from the direct tone test. It's not as clean though. It picks up other signals as well. But it also does a better job at flattening the other frequencies.

1000Hz - At this frequency, I'm getting readings from the 2500Hz (strong) and 6360hz (weak). The 1000Hz strength is similar to the direct tone test.

2500Hz - At this frequency, I'm picking up more of the 6350Hz and a defined drop off from the 1000Hz. The 2500Hz strength is similar to the direct tone test.

6350Hz - At this frequency, I'm seeing the 6350Hz signal fall off and the 6350Hz signal picks up. It also picks up the 16000Hz signal though.

16000Hz - At this frequency, no noticeable change from the 6350Hz signal. I can see a slight drop in signal when it ends but very close to the noise.

Am I correct in my observation?

My untrained ideas for why I'm seeing this behavior:
The difference in the way the frequencies reacts during a direct tone test from the headphone jack vs the MAX9814 leads me to believe I'm messing up my voltage divider. What do you think?

Correct determination of frequencies by the MSGEQ7 chip strongly depends on the strobe frequency.
Did the STROBE signal the same in your tests?

Thanks for your reply!

Yes, my signaling remained the same across all tests. The code from my first post is the strobe signaling I used for all tests. I have previously tested different delays in the for loop of my GetFrequencyData() function as well as different delays in my loop(). I never went below 30 microseconds or above 100 microseconds in the for loop of my GetFrequencyData() function. I went as low as 50 milliseconds delay in my loop(). I settled on what you see in my first post and haven't changed it since. I always tested the computer output and MAX9814 output with the same exact code every time.

I have just tested my MAX9814 as well.
Here is, probably, a poorly drawn out schematic of what I'm going to explain below. Let me know if I get it wrong.

I bought a cheap pair of 1.5W RMS speakers Walmart Site For Speakers I Purchased. Then stripped the 3.5mm jack, connected left and right channels to the output pin of the MAX9814 breakout board through a 33uF electrolytic capacitor and connected the ground wire to the ground of the MAX9814. I got power and ground for the MAX9814 through the 5V and GND pin of my Nano. The sound was clear but had some background noise. No crackling or static sounds. Just a light hum that might have been the fan for my computer. Overall, I think the MAX9814 is working properly.

I don't know why I get such different results from the MAX9814 vs direct audio signal from my computer headphone jack. In my head I'm stuck on the voltage divider at R1 and R4 or the C1 cap value(from the schematic in my previous post). I was also thinking that I might have messed up the clock pin (8) on the MAX9814 but I haven't changed that part of the circuit through all the tests so I assumed that can't be the issue. Am I wrong? Should I be looking somewhere else outside the voltage divider?

I've been doing quite a bit of testing with different configurations. I'm getting some results but I'm not really using any theory. Just brute force. Can anyone explain the behavior I'm seeing or can point me to a video about the underlying principle? These are the results of my testing so far:

Let me show you what has worked the best and then I will get into how I arrived there.

Diagram:

Code:

#define STROBEPIN         10
#define RESETPIN          6
#define MSGEQ7READPIN     A1
#define TOTALFREQUENCIES  7

uint16_t RawFrequencies[TOTALFREQUENCIES];

void PrintData()
{
  for (int FrequencyIndex = 0; FrequencyIndex < TOTALFREQUENCIES; FrequencyIndex++)
  {
    Serial.print(RawFrequencies[FrequencyIndex]);
    Serial.print(" ");
  }
  Serial.println("");
}
void GetFrequencyData()
{
  digitalWrite(RESETPIN, HIGH);
  digitalWrite(RESETPIN, LOW);
  delayMicroseconds(80);
  for (int FrequencyIndex = 0; FrequencyIndex < TOTALFREQUENCIES; FrequencyIndex++)
  {
    digitalWrite(STROBEPIN, LOW);
    delayMicroseconds(100);
    RawFrequencies[FrequencyIndex] = analogRead(MSGEQ7READPIN);
    digitalWrite(STROBEPIN, HIGH);
    delayMicroseconds(100);
  }
}

void setup()
{
  Serial.begin(9600);
  pinMode(RESETPIN, OUTPUT);
  pinMode(STROBEPIN, OUTPUT);
  digitalWrite(RESETPIN,LOW);
  digitalWrite(STROBEPIN,HIGH);
}

void loop()
{
  GetFrequencyData();
  PrintData();
  delay(200);
}

Picture:

Changes Made:
R2- from 100k ohms to 75k ohms
C1 - from 10nF to 100nF
Code - Strobe delays in GetFrequencyData() changed from 40 microseconds to 100 microseconds.

Analysis:
I'm still completely missing the 63Hz signal. It doesn't respond to any frequency I play. I finally got some high peaks on the later frequencies and they are pretty clean. The 16000 is actually alive as well. I might be able to reduce the noise values in code but I'm not worried about code clean up until I get the configuration I want. I think I'm almost there but I can't seem to get the 63Hz signal to respond. Here's a video of my progress.

Video
175kR and 33pF on Clock Pin 100nF on Volt Divider

Test Results:

I was able to find a relationship between the clock pin's capacitance and the strength in the response to frequencies. To my untrained eyes, it seems that if I increase the capacitance (C4) of the clock pin l I can increase the strength of the higher frequencies but decrease the strength of the lower frequencies. I dont fully understand what this relationship principle is but I would love to learn about it, or be told im crazy and chasing a red harring. Below are the videos of what im talking about.

68pF (C4) on Clock Pin:
I don't see the first 2 frequencies at all but my 16000 is the strongest. When normally my 16000 is missing or very weak. It's almost like I'm moving the frequency response to the right, or I guess... higher? (not sure what's the proper terminalogy for this effect) But not in a perfect way.
175kR and 68pF on Clock Pin 100nF on Volt Divider

10pF (C4) on Clock Pin:
This is the only time I get the 63Hz to show up at all but it comes in when I play the 160Hz frequency and its very weak. I also seem to kill the 16000 Hz signal completely. It's almost like I'm moving the frequency response to the left or, I guess... lower? but not in a perfect way.
175kR and 10pF on Clock Pin 100nF on Volt Divider

When I adjust resistance (R2 and R3) up or down on the clock pin It just mixes the frequencies and I can't really discern a pattern. It's not random but I'm not able to decipher it. I can post those test runs also if you want.

Any insights or advise on how to get my 63Hz to respond?

I dont know how but I totally missed this. Sorry! I will definitely check these apps out. Do you think I could use those to test against my circuit? Do they output sin waves also? Are they on the google play store also? (Android user here)

Depends on what you are after. Those apps use the built in microphone in the phone. I have had those apps for many years. They have been upgraded a few times but they wee well worth the buck I think I spend for them.

This is a quite low frequency. I don't know if the small mic in the module can pick it up properly.
If you have an oscilloscope you could check the signal at the output of the MAX9814 module, to see how it looks for each frequency.

Then you could also check the mic signal directly.
In the back of the module, right side, there is a capacitor that comes from from the mic positive terminal and goes to the IC mic-in pin. You could check the signal there, between the cap and the IC.
This way you can discard problems with the mic range or levels at these freqs, or with the module.

Another topic, could be that C1 is attenuating the signal at some frequencies, with the input impedance or R4. You could also check that with an oscilloscope, at the MSGEQ7 input.

You could try to increase C1, to 1uF or 10uF, to see there is a difference. If the capacitor is there just to remove the DC biass, then a higher value should be fine.

By the way, this is just convention and good practices, but try to point all GND's down (and R4), and all VCC pointing up. So, power goes top-down.
And regarding the signal you did it very well, from left to right.
It makes easier reading the schematic.

Thank you for your response!

I don't have an oscilloscope but I've been looking for a reason to buy one. Do you have any suggestions or material I could reference for how to purchase the right one?

Does that have any impact on the high end? Do you know of any resources I could read on this effect?

I haven't had the time to work on it over the weekend but I'm hoping to get a few hours tonight to test some things. I didn't have a 1uF non polarized capacitor. I tried an electrolytic capacitor but it made a high pitch noise when I powered it on. I assumed the electrolytic capacitor didn't like the AC output of the MAX9814? I ordered some higher value ceramic caps and should be able to see how this works out

Ahh, that makes sense. I'll do that from now on. Thank you!

For this kind of projects even a very basic one would help. You could check the signal at different points, otherwise you basically have to guess based in the outputs.

Depends on the budget, but nowadays an entry level scope very decent is not so expensive, or not as expensive as it use to be in the past.
Siglent, Rigol, keysight... have good entry level scopes in the range 250€-400€. Or even cheaper FNIRSI or Hantek. Just avoid these small kits of 40€.

Check some reviews, what to compare: bandwidth, sample rate, etc.