Go Down

Topic: MSGEQ7 returns same value for everything (Read 804 times) previous topic - next topic

Zwartoog

Dec 20, 2019, 11:09 pm Last Edit: Dec 20, 2019, 11:24 pm by Zwartoog Reason: Attached image
Dear forum,

I want to use the MSGEQ7 like everyone does, but I cannot get it to work. The MSGEQ7 reads a fairly constant value for each band. It is around 500 when I connect the IC to 3.3V, and runs up to 840 when I connect it to 5V. The least I would expect is that without audio, the readings should be very low (say, <100).

It does not react to audio-in, connecting/disconnecting any of the capacitors, the resistor, or the cable. Only when disconnecting the Vin the readings drop <10, and when disconnecting the analog read, all readings become completely random. These last two actions make sense of course.

I also noticed that the RESET pin on the MSGEQ7 (pin 7) reads a HIGH value (~4.6V). I read this for different MSGEQ7's I have. Is that correct? In all the coding, the RESET is configured as an output pin.


What did I try so far?
- read, wire and code according to the manual and the many how-to's around
- quadruplechecked the values of the resistors and the capacitators
- change them with others
- used different MSGEQ7. I have tried 2 from 2 different sellers (2 from a local seller, 2 from Aliexpress), 4 in total.
- different cables, breadboards. Even soldered 1 version to a PCB.
- used somewhat different timings in the code
- tried different pins on the Arduino
- tried another Arduino
- used the search function on this forum for similar problems with a solution

So, my wiring is as follows:
Pins 1 and 8 are connected by a 200 kOhm resistor
Pins 1 and 2 are connected by a 0.1 uF cap
Pin 1 is connected to 3.3V or 5V from the Arduino
Pin 2 is connected to GND
Pin 3 is connected to A0
Pin 4 is connected to D13
Pin 5 is connected to a 0.1 uF cap, which is connected to a 22 kOhm resistor, which is then connected to the line-in
Pin 6 is connected via 0.1 uF cap to GND
Pin 7 is connected to D12
Pin 8 is connected via a 33 pF cap to GND

I measured the line-in jack to ensure that the signal indeed reaches the 22 kOhm resistor, and the GND connects to GND.

See the attached image for more details. The small caps are the 0.1 uF ones, the larger one is the 33 pF.

The code:
Code: [Select]

    
int strobe = 13; // STROBE
int resetpin = 12; // RESET
int analogIn = A0;
int spectrumValues[7];

        
void setup()
{
  Serial.begin(115200);
  pinMode(resetpin, OUTPUT);
  pinMode(strobe, OUTPUT);
   pinMode(analogIn, INPUT);

  // Create an initial state for our MSGEQ7 pins
  digitalWrite (resetpin,  LOW);
  digitalWrite (strobe, LOW);
  delay        (1);

  // Reset the MSGEQ7 as per the datasheet timing diagram
  digitalWrite (resetpin,  HIGH);
  delay        (1);
  digitalWrite (resetpin,  LOW);
  digitalWrite (strobe, HIGH);
  delay        (1);
}

void GetValuesMSGEQ7() {
  // tr  - trigger reset, high for 0.1 us
  digitalWrite(resetpin, HIGH);
  // trs - reset to strobe, pause 72 us
  digitalWrite(resetpin, LOW);
  delayMicroseconds(75);
  
  for(int i=0; i < 7; i++){
    digitalWrite(strobe, LOW);  
    delayMicroseconds(40);
            
    spectrumValues[i] = analogRead(analogIn);
    digitalWrite(strobe, HIGH);
    delayMicroseconds(40);
  }
  delay(30);
}
    
void loop()
{
  GetValuesMSGEQ7();

  // Display values from the left channel on the serial monitor
  for (int i = 0; i < 7; i++)
  {
    if (spectrumValues[i] < 100) Serial.print(" ");
    if (spectrumValues[i] <  10) Serial.print(" ");
    Serial.print(spectrumValues[i]);
    Serial.print(" ");
  }

  Serial.println();

}    


The output on 5V:
Code: [Select]

839 839 839 839 839 839 839
839 839 839 840 840 839 839
840 840 840 839 839 839 839
839 839 839 839 839 839 839


The output on 3.3V:
Code: [Select]

499 499 500 499 500 500 499
499 500 500 499 499 500 499
500 499 500 500 500 500 500
499 500 499 499 499 499 499






Thanks in advance for any help! It is driving me crazy.

ps: ugh, the forum does not accept my images :(
ps2: well, succeeded in getting 1 image up by converting it back and forth to different formats  :o Image 2 shows how it is connected to the Arduino Uno, but it is already mentioned above.

DVDdoug

Note - I've never actually used the MSGEQ7.

Your reset/start sequence is wrong.

Reset & strobe should both be high together.   

Then strobe goes low.
Then reset goes low.

Then you should get a reading (for the low frequency band) on the next low-going strobe.

Run the reset/start sequence every time through the loop to re-start with the low frequency band.

Quote
I also noticed that the RESET pin on the MSGEQ7 (pin 7) reads a HIGH value (~4.6V).
That should be fine (when high), but it may be too high if you are running the MSGEQ7 at 3V.


Quote
I read this for different MSGEQ7's I have. Is that correct? In all the coding, the RESET is configured as an output pin.
The reset pin on the MSGEQ7 is an input.   It's connected to an Arduino output pin.  It's the Arduino output that determines the low (about 0V) and high (about 5V) state.

As shown on the timing diagram it just gets pulsed high during the start sequence.  It's held low most of the time (not resetting) while "working".


Grumpy_Mike

The capacitor from pin 8 to ground should be 33pF, the capacitor you have looks way too big to be that value.

Zwartoog

Note - I've never actually used the MSGEQ7.

Your reset/start sequence is wrong.

Reset & strobe should both be high together.   

Then strobe goes low.
Then reset goes low.

Then you should get a reading (for the low frequency band) on the next low-going strobe.

Run the reset/start sequence every time through the loop to re-start with the low frequency band.

Do you mean this code?
Code: [Select]

void GetValuesMSGEQ7() {
  // tr  - trigger reset, high for 0.1 us
  digitalWrite(strobe, HIGH);
  digitalWrite(resetpin, HIGH);
  delayMicroseconds(5);
  // trs - reset to strobe, pause 72 us
//  digitalWrite(resetpin, LOW);
  delayMicroseconds(75);
 
  for(int i=0; i < 7; i++){
    digitalWrite(strobe, LOW); 
    digitalWrite(resetpin, LOW);
    delayMicroseconds(40);
           
    spectrumValues[i] = analogRead(analogIn);
    digitalWrite(strobe, HIGH);
    digitalWrite(resetpin, HIGH);
    delayMicroseconds(40);
  }
  delay(30);
}


The output is still the same.


The capacitor from pin 8 to ground should be 33pF, the capacitor you have looks way too big to be that value.
It is a 500V version, measuring also gave 33 pF.

I do have a microelectronics-version of 22 pF at hand, but no change in output when I swap it for that one.


Thanks for thinking along!

Zwartoog

Coming back to this: I apparently had 4 malfunctioning ICs. I finally decided to buy a prefab breakout board (Audio Analyzer - DFRobot), and this worked out of the box!

I swapped that IC for either one of the other 4, and all gave the exact same readout as I had previously - proving that the ICs were faulty, not necessarily the circuitry.


Good MSGEQ7's are hard to get by, even if you pay the full price.

Go Up