Arduino Forum

Using Arduino => Audio => Topic started by: darylbeattie on Feb 04, 2017, 10:26 pm

Title: MSGEQ7 graphic equalizer IC output is always "0"
Post by: darylbeattie on Feb 04, 2017, 10:26 pm
Inspired by this project (http://www.instructables.com/id/Blinking-LEDs-to-the-Frequency-of-Musi/?ALLSTEPS), I've decided to tweak it to work with a programmable WS2812b LED strip. However, before I can even get to the LED strip, I'm having issues with the MSGEQ7 graphic equalizer IC.

No matter what I do I am always getting "0" values from the MSGEQ7.

I am on my second MSGEQ7 chip; I still haven't ruled out the chip itself as I've heard people have had issues with them.

My circuit looks like this:

(http://tpiwwp.com/out.php/i10978_led-spectrum-analyzer-1-bb.png)

I've tried various alterations like independent power, separating grounding, using resistors or not for the stereo input, 10k resistor between pin1 and ground for stereo input, slightly different capacitors, removing the 1000uF capacitor, etc. I've tried many code changes such as messing with the reset and strobe pin highs/lows, not resetting the EQ7 every time, changing/adding microsecond delays in various places, etc.

That purple wire-connection I add/remove as needed to test the input to the EQ7.

Here's a photo of my setup:  (sorry for the long wires, colors don't match diagram)

(http://tpiwwp.com/out.php/i10979_circuit-photo.jpg)

The input is a stereo plug connected to either an android phone or iphone, tested at various volume levels.

You can completely ignore the LED strip part; most of the time I don't have it hooked up. Though in the picture above it is hooked up.

Here's my code:

Code: [Select]
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 6

int analogPin = 0; // MSGEQ7 OUT
int analogPin2 = 5; // MSGEQ7 IN for debugging.
int strobePin = 2; // MSGEQ7 STROBE
int resetPin = 4; // MSGEQ7 RESET
int spectrumValue[7];
 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
 
void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'

  Serial.begin(9600);

  // Write to MSGEQ7 STROBE and RESET
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);
 
  // Set analogPin's reference voltage
  analogReference(DEFAULT); // 5V
}
 
void loop() {
  // Set reset pin low to enable strobe
  digitalWrite(resetPin, HIGH);
  digitalWrite(resetPin, LOW); // HIGH to LOW resets the MSGEQ7.
 
  // Get all 7 spectrum values from the MSGEQ7
  for (int i = 0; i < 7; i++) {
    digitalWrite(strobePin, HIGH);
    digitalWrite(strobePin, LOW); // HIGH to LOW enables EQ7 output.
    delayMicroseconds(30); // Allow output to settle
 
    spectrumValue[i] = analogRead(analogPin);

    Serial.print(spectrumValue[i]);
    Serial.print(" ");
  }

  Serial.print(" - ");
  Serial.print(analogRead(analogPin2)); // Debug the input value to the EQ7.
  Serial.println();
 
  // Write the PWM values to the LEDs
  /* // Entirely commented out for now.
  uint32_t c = strip.Color(255, 0, 0, 0); // Just red for now...
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
  }
  strip.show();
  */
}


And my output always looks like this:

Code: [Select]
0 0 0 0 0 0 0  - 163
0 0 0 0 0 0 0  - 162
0 0 0 0 0 0 0  - 173
0 0 0 0 0 0 0  - 165
0 0 0 0 0 0 0  - 162
0 0 0 0 0 0 0  - 164
0 0 0 0 0 0 0  - 164
0 0 0 0 0 0 0  - 160
0 0 0 0 0 0 0  - 157
0 0 0 0 0 0 0  - 151
0 0 0 0 0 0 0  - 182
0 0 0 0 0 0 0  - 106


And that just goes on forever...

Does anyone have any idea what could be going wrong here? I've tried so many things, and now I'm out of ideas!
Title: Re: MSGEQ7 graphic equalizer IC output is always "0"
Post by: GypsumFantastic on Feb 11, 2017, 01:21 pm
Are you putting 5V into the barrel jack? That needs 7-12V I think.

EDIT: Also, disconnect the LED strip altogether until you have the MSGEQ7 working - those things can draw quite a bit of current.
Title: Re: MSGEQ7 graphic equalizer IC output is always "0"
Post by: Grumpy_Mike on Feb 11, 2017, 06:26 pm
Quote
My circuit looks like this:
It might well look like that, but that is useless for us to see if it will work. What is needed is a schematic, not a poxy layout diagram.
Title: Re: MSGEQ7 graphic equalizer IC output is always "0"
Post by: darylbeattie on Feb 11, 2017, 11:11 pm
@GypsumFantastic:
I tried using the USB power supply or the 5V barrel-jack, or both. Ok, I'll look into getting a 7-12V jack. I bet that'll help more later on when I also have to power the LED strip.

And yes; I disconnect the LED strip altogether when testing the MSGEQ7. Just in the pic I have the data wired up (but not power).
Title: Re: MSGEQ7 graphic equalizer IC output is always "0"
Post by: wilson3682 on Feb 12, 2017, 06:44 pm
Looking at the circuit, I don't see the 200k resistor on pin 8 msgeq7.

(https://cdn.instructables.com/F2G/WWWK/HXII0TEJ/F2GWWWKHXII0TEJ.MEDIUM.jpg)
Title: Re: MSGEQ7 graphic equalizer IC output is always "0"
Post by: Grumpy_Mike on Feb 13, 2017, 12:06 am
Well it won't work without that. Changing the value of that resistor slightly shifts the absolute frequency of the bands. I found that a 220K was closer to what they should be, but it all depends on the actual value of the 33pF capacitor, and capacitors do not have a very tight tolerance unless you spend a lot of money on them.
Title: Re: MSGEQ7 graphic equalizer IC output is always "0"
Post by: darylbeattie on Feb 16, 2017, 07:59 pm
Looking at the circuit, I don't see the 200k resistor on pin 8 msgeq7.
Wow! Good catch!!!

That was it. It's because the original project I referenced (https://cdn.instructables.com/ORIG/F5N/Y7KF/HO238R1V/F5NY7KFHO238R1V.png) had an error in it and I ended up copying that error into my project. :(

Even though I checked the same manufacturer's datasheet (http://www.mix-sig.com/images/datasheets/MSGEQ7.pdf) I totally missed the "200" versus "22" difference. I must have read it half a dozen times and just didn't see it.

Thanks!!
Title: Re: MSGEQ7 graphic equalizer IC output is always "0"
Post by: Grumpy_Mike on Feb 16, 2017, 08:02 pm
Quote
It's because the original project I referenced had an error in it
Yes but the original project carried a warning, it had the words instructables in the URL. What this means is that the page it leads to has a 99% chance of being crap. Never use this site for trying to learn something unless you know a hell of a lot more than the writer.
Title: Re: MSGEQ7 graphic equalizer IC output is always "0"
Post by: polymorph on Feb 16, 2017, 08:41 pm
Instructables needs technical editors so badly... more so even than Make: Magazine.
Title: Re: MSGEQ7 graphic equalizer IC output is always "0"
Post by: Grumpy_Mike on Feb 16, 2017, 08:56 pm
As does "Hackster.io", too many simple errors getting through.