I want to use MSGEQ7 as a Spectrum analyzer. I am using an Arduino Uno to control the IC.
It does not matter if I have connected the aux pin to an output or not, readings received from the IC are always at max.
I have built the exact same circuit provided in the datasheet. I made a small PCB for the spectrum analyzer IC for my convenience.
This is the circuit that I built. Seems like there is no mistake in the circuit. Please let me know if there are any.
Connections to Arduino Uno:-
| My PCB | Arduino Uno | ** |
|---|---|---|
| VCC | 5V | |
| GND | GND | |
| STROBE | D3 | |
| RESET | D5 | |
| OUTPUT | A5 | * |
(Also tried STROBE -> 2, RESET -> 4)
Practical:- VCC = 4V, GND = 0V, RESET OFF = 2.7V, STROBE ON = 3.9V, STROBE OFF = 0V
The first issue I figured out was that the IC was not in Power ON state. (Checked by Multimeter). When I shorted the capacitor (C4) at the GND, IC got power. Arduino was giving 4.0V VCC but that's fine for the IC.
It took a while for me to realize my second mistake. I looked carefully at the waveforms given in the datasheet for reading output. I did not use RESET and STROBE as mentioned in the datasheet. I checked the STROBE output generated by the Arduino Uno, it was not in sync.
I was checking output by Serial Print with 9600 as Baud rate which affected the STROBE.
Since Uno only has 16Mhz Crystal, I could not produce 100 nano seconds delay for RESET. Insted I kept it at 10 uSec. STROBE is just like in the datasheet. ON-->18 uSec, OFF-->54 uSec hence completing 72 uSec duty cycle. (Practically delay is longer by 2 or 3 uSec)
This whole time I kept getting output above 800 on all 7 bands regardless of Aux connection. When I disconnected the Output pin and A5, the output dropped down bellow 100 but not complete zero. Sometimes it went zero but was not constant.
To avoid the STROBE waveform problem, I removed print and just added 7 LEDs. When Output is connected to Arduino, All LEDs turn ON and remain ON, they only turn off if Output is completely disconnected, even then one or LEDs stay ON.
Changing volume did not make any difference, Play and Pause also gave the same output. I got my hands on a sound card where I could just change the gain but that did not make any difference what so ever.
This is the code I am using:-
int strobePin = 3;
int resetPin = 5;
int outPin = A5;
int OutputLevel[7];
int i = 0;
int j = 0;
void setup()
{
pinMode (strobePin, OUTPUT);
pinMode (resetPin, OUTPUT);
pinMode (outPin, INPUT);
//Initial stage
digitalWrite (resetPin, LOW);
digitalWrite (strobePin, LOW);
delay(100);
//Start Both
digitalWrite (resetPin, HIGH);
digitalWrite (strobePin, HIGH);
delayMicroseconds(10);
//END RESET
digitalWrite (resetPin, LOW);
delayMicroseconds(8);
digitalWrite (strobePin, LOW);
delayMicroseconds(54);
//After 18 uSec STROBE ON
digitalWrite (strobePin, HIGH);
delayMicroseconds(18);
digitalWrite (strobePin, LOW);
}
void loop()
{
i = 0;
j = 0;
for(i = 0; i < 7; i++)
{
OutputLevel[i] = analogRead(outPin);
delayMicroseconds(54);
digitalWrite(strobePin, HIGH);
delayMicroseconds(18);
digitalWrite(strobePin, LOW);
}
/* for(j = 0; j < 7; j++)
{
//Controlling LEDs on OUTPUT LEVEL
}
*/
}
The basic code seems to work for other people, Why am I getting MAX output constantly?
What am I doing wrong? Is there a problem with the circuit or the code?
Should I not get zero when AUX is not connected? If yes, should it remain zero till I play something or will it change instantly as I connect AUX to a laptop or phone?
Is Arduino Uno a bad choice for this project? If yes, what would you recommend?
My best guess is that the issue can be solved with a simpler code.
I have a 48Mhz crystal that can replace the one on Uno, will it make any difference? I also have more ICs, so I know that the IC was not damaged anywhere.
I can't guaranteed the following code will work as I don't have a MSGEQ7 to test it. But I want to point out that you interprets the timing diagram wrongly.
Here is the code that based on the timing diagram.