YET ANOTHER... sound from a guitar output to power LEDS question

Ok.. I think I finally understand @DVDdoug Bias circuit.

Even if it meant I had to get through the first 3 volumes and 35 chapters of https://www.allaboutcircuits.com/textbook/ :slight_smile:

Tested on Falstad

The 2 resistors across the DC voltage create a voltage divider providing 2.5V output.
When we add the AC sound signal (in parallel?), this biases the AC voltage increasing its sine wave so that it should always be above zero V
The capacitor is put in place so that the DC voltage can not feed back into the sound source?

Is that about right?

Would we need to limit the output to never be above 5V?
What is the affect of decreasing the resistors?
If I test in the simulation above, decreasing the resistors to 1k, actually seems to decrease the max export voltage?

If I use a 1u cap, the max output voltage decreases? but so does the min, pushing it into negative values. using a 10u cap does the opposite? but the amplitude of the voltage is lower with a 1u.

I realise understanding whats going on is not needed to complete this :wink: But I was interested in finding out.

A short answer is that the cap blocks the DC voltages from passing through it. The charge on the cap plate on the signal side is electrostatically coupled to the other plate so that as the signal changes the charge on its plate, electrons are attracted or repelled on the other plate. It "looks" like DC voltage is blocked and AC voltage passes through the cap.
The cap is a coupling cap and the circuit is a type of interstage RC coupling.
There is more to this because of the AC characteristics of RC circuits.

I know herbschwarz has pretty much covered it, but I'll throw my rudimentary understanding in the ring too:

When we add the AC sound signal (in parallel?), this biases the AC voltage increasing its sine wave so that it should always be above zero V

That sounds generally right. In your falstad circuit, your AC source was set to go between +2.5V and -2.5V. That's 5V "peak to peak". (Note that your guitar audio source will be much less than this, maybe 1V peak to peak?)

The capacitor doesn't let current flow through it. In this case, it's sort of an "elastic membrane" for electricity: you can poke a bit of charge in one side and it will push some out the other side, but you can only pack in so much charge, before the metaphorical membrane is too stretched. At this point the "elastic" only wants to pull back to where it was, and kick out all the charge you put it, sending it back the way it came. Of course it can only do this, if it can suck some charge back in on the opposite side, to fill the "vacuum" you created there.

In this way, the charges on either side can push and pull through the "elastic membrane", without actually touching each other. If the capacitor was already balanced with 24V on the left side and 0V on the right hand side, the 24V could increase to 25V, and the 0V would only know that 1V had been "shoved out" on the right side.

This is what allows you to bias the voltage. The guitar is happily putting out it's audio signal at say +0.5V to -0.5V. The Arduino side, having been stable at 2.5V, is now feeling that pull of 0.5V up, and 0.5V down, so it will be rising to less than 3V, and falling to somewhere above 2V.

What is the affect of decreasing the resistors?

Think maybe that you're mixing the hot tap and the cold tap in the shower. If the hot tap is all the way open, the hot water is just blasting out. If you turn on the cold tap a little ways, it will make no real difference to the temperature; there is just so much hot water flowing. Now imagine you turn the hot tap back to a trickle; you can turn the cold tap just a little, and cause a big impact on the temperature of the water.

The resistors here are sort of your hot tap: the more resistance, the more the hot tap is shut. Your "cold tap" audio signal will be able to really impact the temperature. If instead you have low resistance on your "hot tap" 2.5V source, it's just POURING out, and turning the "cold tap" audio signal on and off a bit will only cause a small change in temperature.

but the amplitude of the voltage is lower with a 1u.

Whereas your "hot tap's" flow is being limited by the resistors, there is no resistor on your "cold tap" audio signal. It does however have the "rubber glove elastic membrane" capacitor in series.

If you were trying to mix a DC signal here, it wouldn't work, because the membrane would just stretch to it's limit and stop. Because you are instead putting an alternating current up against the membrane, it will quite happily push and pull. It doesn't stretch the membrane to it's limit, it just dumps a little charge in there and then pulls in back out in the other direction.

At least that's what it does when the capacitor is big enough. Say you've got a really small, taut piece of elastic. It can't be stretched as much; you can only put a tiny amount of charge it one side before it hits it's limit. If the capacitor is small, it fills up with charge so fast that even the alternating current signal can't push and pull properly. The AC signal just wants to fill the capacitor up with change for half a wave, then it wants to pull it out again, but it can't even manage this.

Maybe the capacitor is tiny, maybe the voltage is really high, or maybe the frequency is really low, pushing and pulling for a long time in each direction before alternating. Any of these could cause the capacitor to fill up and start to limit the passage of the AC signal.

I believe that this special sort of "resistance to AC signals" has it's own term, "Impedance", but this is straying into territory that I'm a bit wobbly on.

The interplay between the resistors and the impedance of your capacitor are what is defining how strong your audio signal is (peak to peak voltage), and its DC offset (the middle point of your biased wave).

Would we need to limit the output to never be above 5V?

With a large AC signal you would, however I don't see how this will be a particular issue when working with the small voltages here.

You shouldn't go above your 5V supply, but I believe that, in a pinch, the input pins will tolerate an extra 0.5V. Even if you somehow put together a circuit that put the +0.5V of the audio signal on-top of the 5V power supply, it probably wouldn't cause a meltdown. If you're unsure, double check it in falstad.

Apologies if I've gotten any part of this information dead wrong, I ain't got nun that book lernin.

Thats @herbschwarz and @toddnz

That all makes a lot of sense, and I love the analogies :slight_smile:
I also caved in this afternoon and asked my wife to explain some things to me.. dont laugh.. but she has a PHD in Physics, though she hasn't touched electronics and circuits since her 4th in varsity... hmm 20 or so years ago :rofl:
She did give me a glare, but we both ended up spending about 2 hours playing with Falstad and she slowly remember most of the math and she was able to show me just WHY its doing what it does.

Of course.. now i'm out of favours until after the summer break.

On another note.. my MSGEQ7 chips arrived.. but I am not getting anything off them :frowning: I ordered them from https://www.gotronic.fr/ . They stated they were sparkfun chips, and have a serial number of 2131-RoHS. I just hope I haven't been hit with the plague of bad luck that almost every other post on this forum has with them.

That doesn't sound encouraging..

I am not getting anything off them :frowning:

How are you testing them out? Do you think you could send us a picture or a diagram of your set-up?

I'm away at the moment and should be home sat night or sunday, and will post as soon as I am back. I've also ordered an array of different caps/resistors to be sure, and they should arrive at my house tomorrow

Hi all..

Ok.. so I've also realised that the datasheets for this thing are different depending on which one you download?

From this link Improving the MSGEQ7 audio input circuit it matches the one from https://www.sparkfun.com/datasheets/Components/General/MSGEQ7.pdf

BUT.. when I download it.. Its in greek.. or something?

So I was using the details from https://mix-sig.com/images/datasheets/MSGEQ7.pdf

The one from MSI, has 3 x 0.1uF caps, 200k and 22K Resistors
The one from The link above has 2 x 0,1uF caps, 1 x 0.01 uF caps 200k and 22K Resistors

How.. why.. is the point to confuses us newbies so much that we rather give up and dont bother :wink:

Anyway.., I have redone it now as follows based on the link from the forums here.. and this is what it looks like:



I dont have any LED"s here yet.. but this my code I was using that I have copied to test this.

#include <Adafruit_NeoPixel.h> 
#include "WS2812_Definitions.h"

#define LEDDATA 9
#define LED_COUNT 64

Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, LEDDATA, NEO_GRB + NEO_KHZ800);

int StrobePin = 4;
int ResetPin = 7;
int ReadPin = A0;

float analogVal;

void setup()
{
  leds.begin();  // Call this to start up the LED strip.
  clearLEDs();   // This function, defined below, turns all LEDs off...
  leds.show();   // ...but the LEDs don't actually update until you call this.
  pinMode(StrobePin, OUTPUT);
  pinMode(ResetPin, OUTPUT);
  pinMode(ReadPin, INPUT);
  digitalWrite(StrobePin, LOW);
  digitalWrite(ResetPin, LOW);
  Reset(); //reset multiplexer 

  // Chris
  Serial.begin(9600);

}

void loop()
{
  Serial.print("A0:");
  Serial.println(A0);


	int sensitivity = 149;
	StepStrobe();
	analogVal = map(analogRead(ReadPin), 60, 1023, sensitivity, 1);
	Bass(MAROON, analogVal);
	
	StepStrobe();
	analogVal = map(analogRead(ReadPin), 60, 1023, sensitivity, 1);
	Bass1(DARKRED, analogVal);
	
	StepStrobe();
	analogVal = map(analogRead(ReadPin), 60, 1023, sensitivity, 1);
	Midrange(SIENNA, analogVal);
	
	StepStrobe();
	analogVal = map(analogRead(ReadPin), 60, 1023, sensitivity, 1);
	Midrange1(OLIVE, analogVal);
	
	StepStrobe();
	analogVal = map(analogRead(ReadPin), 60, 1023, sensitivity, 1);
	Midrange2(LIME, analogVal);
	
	StepStrobe();
	analogVal = map(analogRead(ReadPin), 60, 1023, sensitivity, 1);
	Highs(MIDNIGHTBLUE, analogVal);
	
	StepStrobe();
	analogVal = map(analogRead(ReadPin), 60, 1023, sensitivity, 1);
	Highs1(INDIGO, analogVal);
}

void clearLEDs()
{
  for (int i=0; i<LED_COUNT; i++)
  {
    leds.setPixelColor(i, 0);
  }
}

void Bass(unsigned long color , byte brightness)
{
	int i = 0;
	
	byte red = (color & 0xFF0000) >> 16;
	byte green = (color & 0x00FF00) >> 8;
	byte blue = (color & 0x0000FF);
	
	while(i <= LED_COUNT)
	{
		leds.setPixelColor(i, red/(brightness), green/(brightness), blue/(brightness));
		i = i + 7;
	}
	
	leds.show();
}

void Bass1(unsigned long color , byte brightness)
{
	int i = 1;
	
	byte red = (color & 0xFF0000) >> 16;
	byte green = (color & 0x00FF00) >> 8;
	byte blue = (color & 0x0000FF);
	
	while(i <= LED_COUNT)
	{
		leds.setPixelColor(i, red/(brightness), green/(brightness), blue/(brightness));
		i = i + 7;
	}
	
	leds.show();
}

void Midrange(unsigned long color , byte brightness)
{
	int i = 2;
	
	byte red = (color & 0xFF0000) >> 16;
	byte green = (color & 0x00FF00) >> 8;
	byte blue = (color & 0x0000FF);
	
	while(i <= LED_COUNT)
	{
		leds.setPixelColor(i, red/(brightness), green/(brightness), blue/(brightness));
		i = i + 7;
	}
}

void Midrange1(unsigned long color , byte brightness)
{
	int i = 3;
	
	byte red = (color & 0xFF0000) >> 16;
	byte green = (color & 0x00FF00) >> 8;
	byte blue = (color & 0x0000FF);
	
	while(i <= LED_COUNT)
	{
		leds.setPixelColor(i, red/(brightness), green/(brightness), blue/(brightness));
		i = i + 7;
	}
}

void Midrange2(unsigned long color , byte brightness)
{
	int i = 4;
	
	byte red = (color & 0xFF0000) >> 16;
	byte green = (color & 0x00FF00) >> 8;
	byte blue = (color & 0x0000FF);
	
	while(i <= LED_COUNT)
	{
		leds.setPixelColor(i, red/(brightness), green/(brightness), blue/(brightness));
		i = i + 7;
	}
}

void Highs(unsigned long color , byte brightness)
{
	int i = 5;
	
	byte red = (color & 0xFF0000) >> 16;
	byte green = (color & 0x00FF00) >> 8;
	byte blue = (color & 0x0000FF);
	
	while(i <= LED_COUNT)
	{
		leds.setPixelColor(i, red/(brightness), green/(brightness), blue/(brightness));
		i = i + 7;
	}
}

void Highs1(unsigned long color , byte brightness)
{
	int i = 6;
	
	byte red = (color & 0xFF0000) >> 16;
	byte green = (color & 0x00FF00) >> 8;
	byte blue = (color & 0x0000FF);
	
	while(i <= LED_COUNT)
	{
		leds.setPixelColor(i, red/(brightness), green/(brightness), blue/(brightness));
		i = i + 7;
	}
}

void StepStrobe()
{
	digitalWrite(StrobePin, HIGH);
	digitalWrite(StrobePin, LOW);
	delayMicroseconds(30);
}

void Reset()
{
	digitalWrite(ResetPin, HIGH);
	digitalWrite(ResetPin, LOW);
	delayMicroseconds(30);
}

But all I get on the serial port is:

19:35:18.249 -> A0:14
19:35:18.249 -> A0:14
19:35:18.249 -> A0:14
19:35:18.249 -> A0:14
19:35:18.282 -> A0:14
19:35:18.282 -> A0:14
19:35:18.282 -> A0:14
19:35:18.282 -> A0:14

And yet.. if I rebuild it as I had before, with out the MSGEQ7.. it works..

At this point.. i'm thinking of throwing them out the window.. and just going with what works :wink:

BUT.. when I download it.. Its in greek.. or something?

It really does look like just some sort of strange formatting issue to me. It appears to still be written in English, but using similar Greek letters?

The mix-sig one is dated 2022, so I'd work off that one, although I don't think it would make too much difference either way right now, as far as that circuit diagram.

Without looking at the code, I think you might need to redesign your circuit. I think you have missed a capacitor on Pin 4, but more importantly, from what I can see in the images, it looks like you might not be using the breadboard correctly.

This diagram shows the internal connections of a standard breadboard. Some of your components looks like they might be placed in such a way that they are bypassed.

Also, at a glance:

  Serial.print("A0:");
  Serial.println(A0);

Once you get the circuit wired up, you're going to hit a problem here.

Your serial monitor is giving "14" because, internally, A0 is actually 14: the input one after 13. Serial.println(A0) is just printing the pin number.

Instead go for something like :

Serial.println( analogRead(A0) );

So.. back to the drawing board. (or breadboard)

and I think you are right.. I actually realised last night that something was wrong, when i noticed part of the breadboard had no power on one side of the chip... Still not sure what.. But stripped it all down and decided to go to bed and try again today.

After some more searching to day, I used the code from HERE and the examples from Fritzing and I ended up with this:


and NOW.. I do get a reading :wink:

I also bought a this module yesterday, and that works quick and easy! I tried to look if there is a difference and the pre-built module appears to have a greater range?

IE:
From my circuit:

vs, from the module

Not sure if Iwant to attempt to replicate their schematic :wink:

Looks like you're on the right track!

It also looks like they're using a 10nF capacitor on the Audio Input rather than the 100nF you're using, which might be the source of the difference?

So.. its been more than more than a week since the MSEGQ7 chips arrived, and I finally worked out what was wrong.

When the chips arrived, they came with this new breadboard I had ordered as shown [above](https://europe1.discourse-cdn.com/arduino/original/4X/b/6/8/b681b80d8fcdfde75769dcf819076e7ad809dff8.jpeg above.)

I had given up on the MSGEQ7, and currently have built a system that uses the prebuilt analyser as well as my own bias circuit (because my kid asked for them both), which I can change with a DPDT switch that I already have in the guitar. (busy working on the PCB design)

Tonight I was trying something else, and ran into the same problem I mentioned above with:

i noticed part of the breadboard had no power on one side of the chip... Still not sure what.. But stripped it all down and decided to go to bed and try again today.

And it turns out.. on the new breadboard, the rails do NOT go straight across, and are split in the middle so there is no connection to the one side.... I quickly rebuilt my MSGEQ7 circuit... and I get the SAME output as on the pre-built...

I'm going to go sit in a corner now and rock myself to sleep

Real life and work got in the way of me having fun.. but this is what I have finally come up with

Now to solder it all in a proto board, but I thought I would ask if anyone sees anything glaringly wrong?

Its finally all in.. Thank you all for the help and for sitting through all my newbie questions

https://www.youtube.com/shorts/_cnS4R3WJIQ