MSGEQ7 diagnostics

Hello all,

I am trying to replicate what this fellow is doing:

and got the msgeq7, audio jacks, capacitors, resistors....etc.

I put it together like this only minus the LED's

http://www.n00bsys0p.co.uk/sites/default/files/MSGEQ7_bb.png

I found some decent looking code that appears all over my searches, however, when I run it it gives all 0's to start then after about 10-15 seconds appears to count down erratically from 999 sometimes jumping back up. I've sent three different sources of audio through the jacks I have and other than some component being bad I don't know what else to do. Everyone else seems to have a design that works well almost immediately. Any advice on diagnosing my issue?

Here is the code I've been running:

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();
}

Here is a copy/paste from the serial monitor. This starts after 24 seconds worth of 0's:

0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
883 882 885 884 885 885 885
883 883 885 883 884 884 882
881 883 882 882 883 884 882
881 881 881 879 883 882 881
880 881 881 878 880 881 880
879 880 881 881 880 882 879
878 879 877 878 878 878 877
877 878 878 877 879 877 880
877 877 877 876 878 876 874
876 876 873 878 874 875 875
875 875 874 874 874 875 873
875 873 873 872 873 871 873
872 872 872 873 873 873 873
871 872 873 869 870 872 872
870 872 870 869 868 872 869
868 869 870 870 868 869 871
868 869 870 868 869 867 866
867 868 868 867 867 869 866
866 866 865 866 865 864 866
866 866 867 863 866 865 865
863 864 864 865 865 863 865
863 866 864 863 860 865 864
862 863 863 862 862 862 862
862 859 861 859 860 860 860
861 860 860 860 860 860 862
860 861 859 860 858 860 858
859 857 857 859 859 857 858
857 858 860 856 857 858 857
856 857 858 857 857 857 855
856 854 853 856 854 856 855
855 853 856 855 854 854 854
855 851 853 853 855 852 852
852 852 854 852 851 851 854
850 852 850 853 852 851 851
850 851 852 849 849 851 851
852 849 848 849 850 848 848
848 847 849 848 850 851 849
847 848 846 846 846 846 847
846 848 848 848 845 848 846
848 844 847 845 845 844 844
844 845 842 842 842 844 844
843 843 843 843 842 843 841
843 844 843 842 842 843 842
839 840 841 841 842 839 840
839 841 842 839 838 840 839
839 839 838 839 838 839 839
838 838 839 838 839 837 838
837 836 838 836 837 836 837
838 837 834 837 836 836 834
835 835 834 836 833 833 833

Somebody's posted results that look like that before... You might search the forum for MSGEQ7 to see if you can find it (unless it was you! :smiley: ). Maybe they found the solution... Maybe there's a problem with the sample code...

I've never used the MSGEQ7, but I understand the concept of how it works and it's tough to troubleshoot! :frowning: It's tough to figure-out if you have a hardware or software problem, especially without an oscilloscope...

One thing you can do is disconnect the analog connection. Then connect the Arduino analog input to +5V. All of your readings should then be ~1023. Connect the input to ground and the readings should be ~0. (I haven't studied the code in detail, but I'm assuming those numbers are raw ADC readings.) That won't tell you a whole lot if it works, but if it doesn't work it tells you your software is fouled-up.

If you have a multimeter, you should be able to "blast" the MSGEQ7 with a strong audio signal (music or white noise to cover all of the frequency bands) and you should read something coming out of the MSGEQ7's "analog" output.. . You should get a DC voltage that jumps-around a lot. With no signal, that output should remain around 0V.

As an overall system test, you can also feed it a test-tone of a know frequency. (You can generate test-tone files with an audio editor such as Audacity.) But, that's probably just going to confirm that the thing is not working...

If you had a digital oscilloscope, you could sync to the reset or clock (strobe) signals and then with a test-tone you should see a stepped-sequenced signal with a higher level for the frequency-band centered around the test-tone. With a 'scope you could also check to see if the reset & strobe signals are there and if they appear to be timed approximately right.

P.S.

 // comment out/remove the serial stuff to go faster

That could be a BIG part of the problem!

The MSGEQ7 works by timing... If you don't strobe or read at the right time, everything is going to be fouled-up... You'd have to capture the readings into an array (or as individual variables), then take a pause to "print" them out.

And, you might have to run it for awhile before "capturing" the data, or calculate moving averages, etc., because the datasheet says:

The multiplexor read rate is also the output decay time control. Each read decays that channel by approximately 10%

Thank you sir. I have access to an O-scope so I am probably going to try that this this weekend when I have the time. So if I understand correctly I need to ensure that the strobe and read are sync'd up correctly? Once I have done that I look at the code and possibly modify it?

Hope you have a good day and thank you again :slight_smile: I'm going to double check and see if I can find that other person on the forum with my same results. I didn't find them earlier, but worth checking.

Thank you sir. I have access to an O-scope

So... They way the MSGEQ7 works (at least conceptually) is this:

An audio signal comes-into 7 bandpass filters.

The output of each filter is rectified to DC and filtered-smoothed (or maybe peak-detected).

Those 7 DC voltages go into a multiplexer that passes-through one at a time to the MSGEQ7's output pin.

If you read the output pin at exactly the right time, you can read the voltage for each frequency band.

So, if you look at the output with a 'scope you should see a stair-step waveform with 7 steps, where the height of each one corresponds to the amplitude of the sound in the associated frequency band.

A digital 'scope should work better than an analog 'scope for an unusual waveform like this, which I think has a relatively low repetition rate. But, an analog 'scope should give you useful information.

I would recommend constant test-tones so the stair-steps don't jump-around "randomly".

How would I ensure I read the output at the correct time? Would I put a longer delay on the output?

I have a Digilent Electronics Explorer board with a 40MHz scope on it. Hopefully this weekend I can get the scope on it and see what is going on and where the problem exists.

Any chance it would help if I played with this portion of the code?

delayMicroseconds(30); // to allow the output to settle

Thanks again