Go Down

Topic: MSGEQ7 not reacting to Audio (Read 868 times) previous topic - next topic

AmauryPerez

Mar 19, 2017, 08:41 pm Last Edit: Mar 19, 2017, 09:31 pm by AmauryPerez Reason: Fixing some errors
Schematic I'm following:
https://www.sparkfun.com/datasheets/Components/General/MSGEQ7.pdf

Picture of breadboard circuit:


Quick explanation of circuit:
Ignore the transistor stuff on the bottom left. That's what's going to be attached to the LED strip. (Yes, I'm aware of all the information on this sort of project on the internet, especially this forum. Yes, I've done the research and tried most resources. Yes, I still can't solve my problem.) I know I'm not supposed to put that part of the circuit in until after the MSGEQ7 is functional, but I had nothing to do whilst waiting for the MSGEQ7 to arrive.

Pin 1: Has the .1uF capacitor and then goes to ground via orange cable.

Pin 2: Straight to ground via another orange cable.

Pin 3: Goes to A0 of my Arduino MEGA.

Pin 4: Goes to PWM 4 on the Arduino.

Pin 5: Goes to an Audio Cord (Aux Cord) that was cut and the left, right, and common grounds were wrapped around a wire and then attached to the breadboard.

(I feel iffy doing this, is this a viable way of passing the audio to the breadboard?
I have one of these:
https://www.radioshack.com/products/radioshack-1-8-mono-panel-mount-audio-jack-3-pack

with another Aux cord if that's more viable.)

The Audio goes through a 22K resistor, and the .01uF capacitor to the fifth pin.

Pin 6: Has the .1uF capacitor with a wire taking it to ground.

Pin 7: Has a wire going to pin number two.

Pin 8: Two 100k resistors in series going from pin one to a 5V connection. (Supplied from the Arduino Mega. Arduino is connected to 12V power adapter.) I also have the 33pF capacitor attached to ground.

The Arduino's code is:
Code: [Select]

int analogPin = 0; // MSGEQ7 OUT
int strobePin = 4; // MSGEQ7 STROBE
int resetPin = 2; // MSGEQ7 RESET
int spectrumValue[7];

// MSGEQ7 OUT pin produces values around 50-80
// when the re is no input, so use this value to
// filter out a lot of the noise.
int filterValue = 70;

// LED pin connected to the PWM pins on the Arduino
int ledPinPower = 11;

void setup()
{
  Serial.begin(9600);
  // Read from MSGEQ7 OUT
  pinMode(analogPin, INPUT);
  // Write to MSGEQ7 STROBE and RESET
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);

  // Set analogPin's reference voltage
  analogReference(DEFAULT); // 5V

  // Set startup values for pins
  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);
}

void loop()
{
  // Set reset pin low to enable strobe
  digitalWrite(resetPin, HIGH);
  digitalWrite(resetPin, LOW);

  // Get all 7 spectrum values from the MSGEQ7
  for (int i = 0; i < 7; i++)
  {
    digitalWrite(strobePin, LOW);
    delayMicroseconds(30); // Allow output to settle

    spectrumValue[i] = analogRead(analogPin);

    // Constrain any value above 1023 or below filterValue
    spectrumValue[i] = constrain(spectrumValue[i], filterValue, 1023);


    // Remap the value to a number between 0 and 255
    spectrumValue[i] = map(spectrumValue[i], filterValue, 1023, 0, 255);

    // Remove serial stuff after debugging
    Serial.print(spectrumValue[i]);
    Serial.print(" ");
    digitalWrite(strobePin, HIGH);
  }

  Serial.println();

  // Write the PWM values to the LEDs
  analogWrite(ledPinPower, spectrumValue[4]);
}


I just bought the MSGEQ7 off of Sparkfun, so hopefully it isn't a dud. I have two more, but I want to cross off all other options before I try the next one. The audio cord is connected to my phone, but I have tried with my laptop as well.

My issue consists of the MSGEQ7 simply not responding to my audio when played. Currently, my output has a bunch of random numbers in the serial monitor. So, at-least the MSGEQ7 is outputting something.

Serial Monitor:


My goal is to have this properly reacting to Audio. My thoughts are that the issues can lie with the MSGEQ7, the Audio coming in, and possibly, hopefully not, the code.

Also, I've seen a lot of posts about op-amps and what not, but I read that the MSGEQ7 has it's own 20dB gain. Is this enough for the Audio to be input properly?

Also, yes, my capacitors are ceramic.

Let me know if I missed anything, I skipped the whole hand-made schematic drawing because I'm following such a small and specific one. I'd gladly draw one, if requested. I can provide additional information if you have questions.

Thank-you for your time,
Amaury.

[EDIT]
The furthest two orange cables on the breadboard are the left channel from the audio cable and the ground for the audio cable. The audio appears to be in the wrong row from the resistor, but I can assure you this is just due to my bad camera angle! Sorry about that if it confused anyone.

[EDIT2]
I just realized that when I was working with my circuit and cleaning it up, I forgot to add the power cable to Pin one. I've thus added another wire going to the 5V supplied from the Arduino to Pin One. Both the serial monitor and picture of the circuit have been updated. Sorry for the confusion, once again!

Grumpy_Mike

Quote
Pin 5: Goes to an Audio Cord (Aux Cord) that was cut and the left, right, and common grounds were wrapped around a wire and then attached to the breadboard.
Bad idea on three counts.
1) You are shorting two outputs together, expect to damage the audio source.
2) You need a capacitor between pin 5 and the audio input.
3) You are not making a good connection like that, connections need to be soldered.

I don't think you mean that the common ground is connected to the signals but that is how it reads.

AmauryPerez

#2
Mar 19, 2017, 10:31 pm Last Edit: Mar 19, 2017, 10:58 pm by AmauryPerez
Bad idea on three counts.
1) You are shorting two outputs together, expect to damage the audio source.
2) You need a capacitor between pin 5 and the audio input.
3) You are not making a good connection like that, connections need to be soldered.

I don't think you mean that the common ground is connected to the signals but that is how it reads.

Alright, so I'll be using the audio jack from the RadioShack. My question before I try that is, there are two prongs and then the big metal backing that the audio jack clips into.

(https://www.radioshack.com/products/radioshack-1-4-mono-panel-mount-audio-jack-2-pack)

Which is left, right, and common?

I'm sorry if this sounds simple, I've been confused and haven't been able to find an answer if the metal back is negative or not.

[EDIT]
FYI, I didn't connect all three to one individual wire. My apologies for the confusing explanation. Each one was connected to an individual wire that I placed on the breadboard. I'm switching to the audio jack because you were correct that they provide better connections.

Grumpy_Mike

What is your actual circuit? That link just links to the data sheet. How are you connecting it to the Arduino?

Pin 6 should be connected to the audio's common ground, with Pin 2 to the Arduino's ground.

Quote
Which is left, right, and common?
The big metal one connects the tip and the common ground is the lowest ( closest to the chassis mounting ).
If you only have one chip you should combine the audio by connecting then together through a 1K resistor on each channel.

The problem with you photo is you can't tell which way round the chip is.

AmauryPerez

What is your actual circuit? That link just links to the data sheet. How are you connecting it to the Arduino?

Pin 6 should be connected to the audio's common ground, with Pin 2 to the Arduino's ground.
The big metal one connects the tip and the common ground is the lowest ( closest to the chassis mounting ).
If you only have one chip you should combine the audio by connecting then together through a 1K resistor on each channel.

The problem with you photo is you can't tell which way round the chip is.
The chip connects to the Arduino multiple ways.
Pin three goes A0 on the Arduino. Pin four goes to PWM 4 on the Arduino. Pin seven goes to two on the Arduino.

I believe that should be correct if pin three is out, four is strobe, and seven is reset.

I have a ground from the Arduino connected to the breadboard, where all the grounds from the Audio + MSGEQ7 are being led to.


Quote
The big metal one connects the tip and the common ground is the lowest ( closest to the chassis mounting ).
If you only have one chip you should combine the audio by connecting then together through a 1K resistor on each channel.
I went ahead and tried this set-up,

You said that the big one connects to the tip.
I looked up a picture that says the tip is left.
You said that the common ground is the lowest one.
I checked and saw the lower one, so that's ground.
That only leaves right left, which the picture says should be the other clip.

After trying this, it worked!

I'm currently having another issue with powering the LEDs, the circuit I had does not seem to be working as I wanted it to. Basically, I'm looking to design a circuit to use an NPN transistor as a variable resistor that drops 12V to 0V if the PWM of the Arduino is 0V (or 5V is need be) and goes 12V for the opposite.

If you have any ideas, please let me know!

Besides that, thank-you so much!

Grumpy_Mike

Quote
I'm looking to design a circuit to use an NPN transistor as a variable resistor that drops 12V to 0V if the PWM of the Arduino is 0V (or 5V is need be) and goes 12V for the opposite.
Again we need to see a schematic, but on the face of it that is not how you dim LEDs in a strip. If you were to design such a circuit the transistor would burn up if you had a large number of LEDs.

So how many LEDs?
Schematic about how you want to control them please.

Normally you dim a strip by applying PWM to a transistor or FET.

AmauryPerez

Again we need to see a schematic, but on the face of it that is not how you dim LEDs in a strip. If you were to design such a circuit the transistor would burn up if you had a large number of LEDs.

So how many LEDs?
Schematic about how you want to control them please.

Normally you dim a strip by applying PWM to a transistor or FET.
My apologies, I didn't have a schematic, so I created one on both Fritzing for a visual picture of what I'm doing and other software to show you the schematic.

Fritzing Screenshot:




Schematic Screenshot:

(Created on PartSim, didn't have time to use software like LTSpice)
P.S: The ground to the right, labeled PWM 11, is not a ground pin but the PWM 11 pin on the Arduino. PartSim wouldn't allow me to create a wire without leading it somewhere.

This schematic works in dimming the lights, but it seems to be dimming the lights only when the numbers on the MSGEQ7 spike. Currently, that's the inverse of my goal. I wish for the lights to stay at a certain dimness, and spike when the numbers on the MSGEQ7 spike. Is this something fixable with the code? (I would assume so, but just making sure) Or does the goal require a circuit change?

The product link:
Amazon Link


I couldn't find the datasheet for that specific RGB strip, but I found a datasheet that includes the schematic of the RGB strips. Let me know if this provides what you need.
Datasheet

Just to clear any confusion, I'd like to restate my goal.

Currently, the function of the LED strip is to drop in brightness if the MSGEQ7 spikes. This means that if no music is playing, the LEDs are on. If music is playing, the LEDs are indeed pulsing, but they are dimming to the spikes, not becoming brighter due to the spikes.

My intended function includes:
I want to have the LEDs idle at a certain brightness if no music is playing. Once the music is playing, I want the LEDs to become dim. Note, this is not the same brightness as if no music were playing. Once the LEDs become dimmer, I want that dimness to act as a sort of baseline for when the music becomes "quiet" in-between songs, if there's no beat going on, etc. Once the MSGEQ7 begins to spike, I want the lights to get brighter.

I apologize if I'm over-explaining this.
Here's a video of a project with similar desired functions:
Youtube Link
The beat detection isn't as smooth as I'd like it to be, but the same logic is applied. Beat spikes, so does brightness.

If you have any other questions let me know, I'd be glad to answer them.

Furthermore, I'd like to say thank-you for your help thus far.

Thanks,
Amaury

Grumpy_Mike

Quote
I want to have the LEDs idle at a certain brightness if no music is playing.
You do that very simply in software, it is not something you should consider in software.
Suppose you have an 8 bit value you want to apply to the PWM you use:-
Code: [Select]

analogWrite(pin,value); // for increasing value = increasing brightness
or
analogWrite(pin,255-value); // for increasing value = decreasing brightness


There is no way that schematic can work if you have truly wired it up like that.
You need the PWM pin to connect to a 1K resistor with the other end connected to the base of the transistor. Then the collector connects to the LED -ve, with the emitter to ground of both the Arduino and the 12V supply. ( that last bit is all that is right with your circuit ).

DVDdoug

#8
Mar 20, 2017, 06:56 pm Last Edit: Mar 20, 2017, 07:13 pm by DVDdoug
Your transistor is wired wrong...

Here is a driver circuit.   The LED goes in place of the solenoid, and you can leave-out the diode.    (That's assuming you've got a 12V LED strip.)

In a transistor the (usually larger) collector-emitter current is controlled/switched by the (usually smaller) base-emitter current.   So your load goes in series with the emitter or collector and you can think of the base as the "input". 

And because of the way transistors work, the load usually goes between positive supply voltage and the collector of an NPN transistor (so we are switching the ground/low connection).

Quote
I know I'm not supposed to put that part of the circuit in until after the MSGEQ7 is functional, but I had nothing to do whilst waiting for the MSGEQ7 to arrive.
It doesn't matter what you do first, but you should do one thing at a time and if you're going to build the LED circuit first you should test & debug it (with a simple blink or dim program) before adding the MSGEQ7.   (And, you can test your blink/dim program with a regular LED & resistor before connecting the transistor & LED strip.)

AmauryPerez

#9
Mar 20, 2017, 08:38 pm Last Edit: Mar 20, 2017, 08:52 pm by AmauryPerez
In response to both of you,

I've constructed another circuit, if you can review provide feedback, I'd gladly appreciate it.



Quote
The LED goes in place of the solenoid, and you can leave-out the diode.    (That's assuming you've got a 12V LED strip.)
I just realized that although I've been working with a 12V power supply, I plan to move it to 24V. (Longer LED strips) Would I have to add the diode between the power supply and the positive side of the LED

Grumpy_Mike

#10
Mar 20, 2017, 09:32 pm Last Edit: Mar 20, 2017, 09:33 pm by Grumpy_Mike
That circuit will short out the 12V supply and the transistor will melt.

Quote
Would I have to add the diode between the power supply and the positive side of the LED
No.

AmauryPerez

#11
Mar 21, 2017, 02:15 am Last Edit: Mar 21, 2017, 03:05 am by AmauryPerez
That circuit will short out the 12V supply and the transistor will melt.
I'm confused as to where the 12V power supply connects in. Both schematics don't really help me determine where to put the positive of the 12V supply. Could you possibly guide me with this? Furthermore, I don't think I've chosen the right transistor in the schematic. I've been using a MOSFET.

[EDIT]
My latest attempt, I've been testing them out with the PartSim simulator. I don't think this is one is correct either but I'd like to post progress.


P.S: This is the datasheet for the transistor I'm using.
http://datasheetz.com/data/Discrete%20Semiconductor%20Products/MOSFETs%20-%20Single/785-1147-6-datasheetz.html

DVDdoug

No.   In both circuits you have the transistor/MOSFET directly between +12V and ground.   When the transistor/MOSFET turns-on, current flows directly through the transistor/MOSFET, essentially shorting-out the power supply, and "pulling" down the power supply voltage to (nearly) zero and drawing excess current.   That can fry the power supply and/or the transistor/MOSFET.

The LED is also connected directly between 12V and ground, so it's always on (at least until the transistor/MOSFET shorts-out the power supply).

The LED needs to be in series with the transistor/MOSFET, so that any current that goes through the LED has to go through the transistor/MOSFET too.    With the two devices in series,  when the transistor/MOSFET turns off no current flows through it so no current can flow through the LED either.

...I gave you a link to a driver circuit.   Did you miss that?

Grumpy_Mike

Read reply #7 again and ask about what you don't understand.

AmauryPerez

#14
Mar 21, 2017, 04:27 pm Last Edit: Mar 21, 2017, 06:42 pm by AmauryPerez
I'm going to post my logic throughout following your instructions, in hopes that one of you can catch my mistake.

Mike,
Quote
There is no way that schematic can work if you have truly wired it up like that.
You need the PWM pin to connect to a 1K resistor with the other end connected to the base of the transistor. Then the collector connects to the LED -ve, with the emitter to ground of both the Arduino and the 12V supply. ( that last bit is all that is right with your circuit ).
You used terms like base, emitter, collector, etc. I have a MOSFET. This means that I'm working with gate, drain, and source, correct?

I attached PWM channel to a 1k resistor and then to the gate (Left pin, facing forward) of the MOSFET.
You stated that the collector connects to the LED -ve. This means that the LED -ve is connected to the drain of the MOSFET. Got it. Finally, you said the emitter goes to the ground of the Arduino and the 12V supply.

I now have a MOSFET with a PWM connected to a resistor that leads to the gate. The negative side of the LED goes to the drain. The source goes to ground which leads to a ground pin on the Arduino.

Where I lay confused:
Where does the positive of the LED go? Where does the positive of the power supply go? You've only stated where the negatives go.

DVDdoug,

I did see your circuit, but I have roughly the same problem with your circuit as well.

Quote
The LED goes in place of the solenoid, and you can leave-out the diode.    (That's assuming you've got a 12V LED strip.)
Looking at the picture you posted,
You said the SOLENOID was replaced by the LED. I'm assuming this is L1 on the circuit?

This leaves me with,

The gate of the MOSFET connected to the PWM with a resistor between.

The drain of the MOSFET is connected to the LED (Both positive and negative are connected, with negative facing the MOSFET) and the LED leads to the positive of the 12V.

The source of the MOSFET leads to the Arduino Ground Pin.

Am I missing something? I feel like it's the placement of the LED. Should the negative of the LED be on the other side of the transistor?

Thanks again for your help.

[EDIT]
Posting the schematic where I'm currently at.


[EDIT2]

The schematic posted above seems to be working.
If it's the correct circuit, I have a question.

Does the voltage that the RGB strip receives the controller of the brightness?
Or am i supposed to be doing what I'm doing to the colors of the RGB strip, and not the power?
I don't know if that makes sense, let me know if you have any questions.

Go Up