Pages: [1] 2   Go Down
Author Topic: Amplified Signal to Arduino Mega  (Read 2125 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I built a pair of speakers with an Adafruit neopixel LED strip (http://www.adafruit.com/products/1138) built into the baffle of each and I'm trying to figure out a good way to do lighting effects. What I had in mind was to either perform a fast fourier transform on an Arduino mega which controls the strips or do analog/hardware spectrum analysis with a chip like this: https://www.sparkfun.com/products/10468

I am using an optical signal as a source to my amp, so the only output I have to tap is the amplified output to the speakers. I've looked into using an optoisolator to safely carry a line-level signal back to the arduino, but I'm having some trouble with sourcing components and design. Does anyone have any input into what I can do to get a nice safe signal and not burn out my arduino?

Thanks,
Shep

EDIT: I'm not really looking for just a simple voltage divider circuit here, though that may work with the right values and a potentiometer. It would be ideal to not have to adjust the potentiometer for different output volumes. However, if need be, that's a possibility, I would just like to make sure I'm doing it safely.

For reference, I'm driving them with a 50W/channel amp and the speakers are right around 4 ohms impedance.
« Last Edit: October 29, 2013, 05:15:31 pm by semerson » Logged

Offline Offline
Edison Member
*
Karma: 34
Posts: 1318
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've never used the MSGEQ7, but I made a couple of lighting effects.

There are two related issues.  You need to knock-down the signal to the correct level, and you have to make darn-sure you don't damage the MSGEQ7 with excessive voltage.   I don't see a maximum input level for the MSGEQ7 on the data sheet, but I assume the limit is the 5V power supply voltage.    It has a gain of 20dB (10x) and a maximum output voltage of  4V.   That means you'll have a nominal maximum peak input of about 400mV.   

That's quite a bit of safety margin, but I still recommend a pair of protection diodes.  That's one diode from the MSGEQ7 input to 5V, that turns-on and conducts when the input exceeds 5V and a "backwards" diode from the input to ground, when the input signal goes negative.   (I believe the input-pin is biased to +2.5V, and the bias is isolated by the series capacitor.)     The 22k series resistor shown on the datasheet (along with your voltage divider) will prevent the diodes from damaging anything or distorting the audio if they happen to "kick in".

50 Watts at 4 Ohms is about 20V peak-to-peak.   Getting that down to 400mV is a 1/50 voltage divider.   It might be worthwhile to use a pot as the "bottom" resistor in your volltage divider, at least for prototyping/debugging.

Now, there is another big consideration.    You'll rarely be running the speakers at 50W.   The actual voltage level will depend on the volume control setting and on how loud the music is.    Like I said, I've never used the MSGEQ7 (or studied the code) but for my lighting effects, I program variable sensitivity into my software.   My basic approach is to take a peak reading once per second (I use peak detector circuit so my Arduino's ADC is basically only reading peaks.)   Then, I store that value in a 20-second circular buffer (take a look at the Arduino "Smoothing Example").    20 seconds seems about right for adjusting to louder/quieter songs (or loud/quiet parts of songs) without reacting too quickly or getting fouled-up by the gap between songs.   Depending on the particular lighting effect, I'll take the peak or the average from that array (buffer) and use that as my software reference.    For example, my simplest effect is to turn the lights on whenever the signal is greater than average, and off whenever it's less than average.

And for more range, I also automatically switch the hardware ADC reference between 1.1V and 5V.    If I'm on the 1.1V range and there are any "1023" readings in my buffer, I switch to the 5V reference.   If I'm on the 5V reference and there are no readings greater than 200, I'll switch to the 1.1V reference.    I make the calculation once per second every time the buffer is updated.      (Whenever the reference is changed, I have to scale-up or scale-down the existing numbers in the buffer.)   
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your very detailed response!

Good idea with the diodes -- definitely will provide some good protection. If I'm understanding correctly, you're saying to put a 5V zener diode between IN/+5V which will allow current to flow to +5V if the input voltage exceeds 5V and a diode wired backward between IN/GND which will never allow current to flow backwards to ground if the input voltage drops below 0V (which seems like it always would seeing as this is an audio signal)?

Also, I'm using the Adafruit neopixel strips in my speakers. There are a total of 124 LEDs in both speakers, 62/speaker. On adafruit's website, the stress the fact that these strips take some horsepower to run (http://www.adafruit.com/products/1138), namely the micro controller must be above 8MHz. The mega is 16MHz -- do you think this would be enough to run both two fast fourier transforms (one per channel) and drive the LEDs? If not, would two megas suffice, each running a fast fourier transform and driving 62 LEDs? Running the FFT's on the board instead of relying on the 8-frequency MSGEQ7 would open up a lot more possibilities.

It could also be possible to run the FFTs on a Raspberry Pi and let the arduino mega deal with the LEDs. I was thinking of putting a raspi in anyways to allow internet connectivity for wireless effect management/switching.

Also, adding onto software variable sensitivity -- would it be possible to implement the same thing in hardware as well using a digital potentiometer in my voltage divider? If I use this as the bottom resistor, I'd be able to write an algorithm to adjust the voltage divider on the fly so long as the 5V overvoltage protector diode can take some current when a song comes on too loud after a quiet song.

Shep
Logged

Offline Offline
Edison Member
*
Karma: 34
Posts: 1318
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If I'm understanding correctly, you're saying to put a 5V zener...
You don't need a Zener.  Take a look at the 2nd schematic on this page.  The diode to ground conducts whenever the voltage goes negative (and greater than the ~1/2V diode drop).  The diode to +5V conducts whenever the positive input voltage goes above the power supply voltage (plus the diode drop).

Quote
namely the micro controller must be above 8MHz. The mega is 16MHz -- do you think this would be enough to run both two fast fourier transforms
I've never used FFT.  I know it's mathematiclly complicated and CPU intensive.  If you don't need more than 7 bands, the MSGEQ7 is a slick solution.

In fact, I've never done anything frequency related...  All of my effects work off the volume & volume-changes (sometimes doing some crude beat detection).  Since I'm using a peak detector circuit, my software doesn't need to read/follow the audio signal...  I just need to get the loudness.  As long as I sample at about 10 samples-per-second or more, my effects will work.   I'm running faster than that, basically running the loop as fast as it will go (and usually delaying the actual lighting-changes), but CPU speed/power just isn't an issue.   The MSGEQ7 has similar advantages...  You don't need to read or analyze the audio waveform.

Quote
Also, adding onto software variable sensitivity -- would it be possible to implement the same thing in hardware as well using a digital potentiometer in my voltage divider?
Sure, you can do that.  I just found it easier to adjust the threshold/trigger points in software.  I'm using it on a volume-controlled signal, and it's working fine at high & low volumes.  There are rope lights in the ceiling of my van, and I re-wired those to do lighting effects.  I don't have access to the non-volume controlled signal without "hacking" the stereo, so the Arduino circuit is connected to the volume-controlled inputs to my power amps.  But with my "DJ lighting", where I do have access to a more-constant non-volume controlled line-level signal, I still included the same auto-adjusting software routines.   
« Last Edit: October 31, 2013, 06:04:48 pm by DVDdoug » Logged

USA
Offline Offline
Sr. Member
****
Karma: 15
Posts: 372
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This gizmo claims that it can operate as a limiter, and accommodate 60 dB on its inputs with only about 0.5 dB change on the outputs. 

http://www.onsemi.com//pub/Collateral/SA575-D.PDF

It's available in a through-hole mount for something around $5.50 from Mouser, though the through-hole version is marked "end-of-life."  If that's true, you should be able to get the a flat output response over a voltage input range of 1000.  Using the "+10 dB ~ twice as loud" rule of thumb, that's an apparent loudness range factor of 64.  That might do it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like the MSGEQ7 will be the way to go then (saves me a lot of coding hassle too). I'm pretty new to visual effects; I definitely want to do some frequency-related effects (spectrum analyzer, etc), but would loudness effects be possible through the MSGEQ7? I would think I can get absolute loudness by taking all of my frequency readings from the MSGEQ7 and summing them to get an overall loudness, correct?

This gizmo claims that it can operate as a limiter, and accommodate 60 dB on its inputs with only about 0.5 dB change on the outputs.  

http://www.onsemi.com//pub/Collateral/SA575-D.PDF

It's available in a through-hole mount for something around $5.50 from Mouser, though the through-hole version is marked "end-of-life."  If that's true, you should be able to get the a flat output response over a voltage input range of 1000.  Using the "+10 dB ~ twice as loud" rule of thumb, that's an apparent loudness range factor of 64.  That might do it.

This looks promising. I was reading elsewhere about automatic gain control amplifiers, I assume this IC's advertised automatic level control is the same thing?

I'm not sure I understand "...voltage input range of 1000." Do you mean over a range of 1000dB, 1000V, 1000x, or what? I'd like to get the signal down to 0.5V peak to peak for optimal input to the MSGEQ7. Assuming a max range of ±17V (V = sqrt[50W * 6 ohms], overcompensating the internal resistance of the speakers a little), I should then be able to use this as input to the IC. The data sheet suggests that the output deviation for ALC mode is ±0.2dB about the nominal 0dB, which is about ±1V? If this is correct,  then I should be able to do a simple voltage divider at the output to halve the output and have a safe input to the MSGEQ7.

I have drawn a schematic based on the diagram in the data sheet and attached. Does it look correct?

Thanks,
Shepard


* 2013-11-07 15.02.06.jpg (1887.98 KB, 3264x2448 - viewed 54 times.)
Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A few points that have not been covered:

1) The amp that the audio will be tapped off from, is the output driving the speaker with reference to common ground or is the amp using some kind of bridge circuit (common in lots of audio driver ics) where neither speaker lead is referenced to ground?

2) Using a compander like the SA575 will help regulate the levels and although it has a dynamic range of 60dB or so, what is the maximum input in dBm?

3) Keep in mind that bass frequencies use a lot of power to reproduce and although one might think the amp is only being run at say 10% power (5 watts), music passages with lots of bass could produce peaks of 10 or even 20 watts of output power.

I would use an audio transformer with a primary Z of around 10K connected to the amp and a secondary Z of around 600 ohms feeding a voltage divider circuit, some clamping diodes and possibly the SA575 after that.
The transformer would not only overcome the potential problem of the amps output not being referenced to ground, but the 10K:600 ohm ratio would work in stepping down the voltage as well.
A series capacitor between the amp and one leg of the primary of the transformer will act as a high pass filter to attenuate very low bass frequencies that could cause core saturation.
« Last Edit: November 07, 2013, 04:58:58 pm by UnoDueTre » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
1) The amp that the audio will be tapped off from, is the output driving the speaker with reference to common ground or is the amp using some kind of bridge circuit (common in lots of audio driver ics) where neither speaker lead is referenced to ground?

The amp I am using is a TEAC A-H01 Stereo Amplifier/DAC. I couldn't find anywhere whether it references common ground, so it would probably be safer to assume that it doesn't. Not sure if it's useful, but my speakers are based off the Overnight Sensation MTM design (https://sites.google.com/site/undefinition/overnightsensationmtm)

Quote
2) Using a compander like the SA575 will help regulate the levels and although it has a dynamic range of 60dB or so, what is the maximum input in dBm?

The data sheet for the SA575 (http://www.onsemi.com/pub_link/Collateral/SA575-D.PDF) does not mention input specifications (as far as I can tell), but the highest input they mention in ALC mode is +9dB, after which things start to get a little messy. It would not be hard to get the input voltage under this level. I couldn't find any mention of maximum input power.

Quote
3) Keep in mind that bass frequencies use a lot of power to reproduce and although one might think the amp is only being run at say 10% power (5 watts), music passages with lots of bass could produce peaks of 10 or even 20 watts of output power.

I would use an audio transformer with a primary Z of around 10K connected to the amp and a secondary Z of around 600 ohms feeding a voltage divider circuit, some clamping diodes and possibly the SA575 after that.
The transformer would not only overcome the potential problem of the amps output not being referenced to ground, but the 10K:600 ohm ratio would work in stepping down the voltage as well.
A series capacitor between the amp and one leg of the primary of the transformer will act as a high pass filter to attenuate very low bass frequencies that could cause core saturation.

I'll have to read up on audio transformers to understand exactly how they work and how to design a circuit with one.

I was under the impression that voltage was the main concern here, as the speakers are relatively low-impedance so little current will likely be flowing through the SA575 (though I'm not sure what it's input resistance is). Is it more important to pay attention to power output from the amp then? How about in reproducing the original line-level signal--since bass frequencies take more power to drive the speakers, would they be misrepresented in the tap of the speaker-level audio signal as they would have higher voltages?

Getting the voltage level down here would definitely be beneficial. Also, wouldn't using a high-pass filter to attenuate the low frequencies eventually produced an incorrect spectral analysis as the low frequencies will not be represented? I could adjust in software if needed, but the lower frequencies are definitely important for visual effects.

Thanks,
Shep
Logged

USA
Offline Offline
Sr. Member
****
Karma: 15
Posts: 372
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

... automatic gain control amplifiers, I assume this IC's advertised automatic level control is the same thing?
Same-ish.  Automatic level control, as used in the datasheet, implies that the output will be within a vary narrow range.  

Quote
"...voltage input range of 1000." Do you mean over a range of 1000dB, 1000V, 1000x, or what?
A range of 1000x.  If the datasheet's claims are accurate, you should be able to design a circuit with that will deliver a constant AC voltage at the output while the input signal varies by a factor of 1000.

Quote
I have drawn a schematic based on the diagram in the data sheet and attached. Does it look correct?
I don't know.  I'm not an expert in using the SA575.  I have an application for this IC myself, and I was hoping that you'd design and debug something, and then tell me how to use it.  I think that you're in for some experimentation.  My suggestion is to implement the circuit shown in the datasheet, and see how it performs.  Armed with that information, you'll be able to calculate how to manage the IC's output to use it as input to something else.

I'd recommend considering the output voltage of your amp to be more like sqrt(2) * sqrt(50*6), and then add a safety factor, and then protect your inputs to avoid damage from overvoltage.  The output power quoted for the amplifier is probably imprecise, and it's based on calculations that might be different from the ones that you and I would make.  After you know more, then you can hook it up to the next delicate circuit.

Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


The amp I am using is a TEAC A-H01 Stereo Amplifier/DAC. I couldn't find anywhere whether it references common ground, so it would probably be safer to assume that it doesn't. Not sure if it's useful, but my speakers are based off the Overnight Sensation MTM design (https://sites.google.com/site/undefinition/overnightsensationmtm)
No idea, so best assume no ground reference.

Quote
The data sheet for the SA575 (http://www.onsemi.com/pub_link/Collateral/SA575-D.PDF) does not mention input specifications (as far as I can tell), but the highest input they mention in ALC mode is +9dB, after which things start to get a little messy. It would not be hard to get the input voltage under this level. I couldn't find any mention of maximum input power.

Has a quick read and all I could find is maximum to any input pin (other than supply) is 8.3V

Quote

I was under the impression that voltage was the main concern here, as the speakers are relatively low-impedance so little current will likely be flowing through the SA575 (though I'm not sure what it's input resistance is).

Yes, the voltage applied to the input is the main factor.
I didn't re-read the datasheet looking for the input impedance of the 575, but a good guess is that it will be in the low to mid kilo ohm range so the current is not the issue, it's the voltage.

Quote
Is it more important to pay attention to power output from the amp then? How about in reproducing the original line-level signal--since bass frequencies take more power to drive the speakers, would they be misrepresented in the tap of the speaker-level audio signal as they would have higher voltages?

Exactly why I mentioned the high pass filter.
Since it's a very low order filter, the cut-off response will be gradual (aprox 6 dB/octave) so if you make the -3dB point around 60Hz or so, it will "slowly" attenuate frequencies below that and tend to have a leveling effect.

Quote
Also, wouldn't using a high-pass filter to attenuate the low frequencies eventually produced an incorrect spectral analysis as the low frequencies will not be represented? I could adjust in software if needed, but the lower frequencies are definitely important for visual effects.

How low do you want to display?
You need to make a trade off between possible core saturation and possible slight inacurate display of low frequencies.
this is the price to pay when tapping off from a high power point (amp output) instead of using a line level feed.
Also, how much low frequency content does music actually have?
By that I mean, how important is it if say frequencies below several tens of Hz are attenuated by several dBs?
« Last Edit: November 07, 2013, 05:40:21 pm by UnoDueTre » Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
"...voltage input range of 1000." Do you mean over a range of 1000dB, 1000V, 1000x, or what?
A range of 1000x.  If the datasheet's claims are accurate, you should be able to design a circuit with that will deliver a constant AC voltage at the output while the input signal varies by a factor of 1000.

The dynamic range may be 1000, but you still have to stay within the maximum input voltage of the chip.
that is the difference between dB and dBm.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How low do you want to display?
You need to make a trade off between possible core saturation and possible slight inacurate display of low frequencies.
this is the price to pay when tapping off from a high power point (amp output) instead of using a line level feed.
Also, how much low frequency content does music actually have?
By that I mean, how important is it if say frequencies below several tens of Hz are attenuated by several dBs?

I'm not sure what exactly the lowest frequencies are, but I would like to be able to capture bass "thumps", as those are definitely important in lighting. However, the lowest frequency the MSGEQ7 measures is 63Hz, so attenuating frequencies below ~50Hz shouldn't be a problem.

I have been reading about audio transformers, and I think I have a pretty good idea of what you were saying to do. If I'm correct, the transformer will just isolate my circuitry from the amplified signal, and in the process allow me to set a ground reference. However, I'm not sure exactly what effect the primary/secondary impedance has. I'm thinking that the voltage won't change from primary to secondary coils, but the impedance on the input will be high to prevent current from flowing to my circuit. Am I thinking about this correctly?

Here's a transformer I sourced: http://www.digikey.com/product-detail/en/107N/107N-ND/455019

Thanks,
Shep
« Last Edit: November 18, 2013, 04:36:48 pm by semerson » Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I have been reading about audio transformers, and I think I have a pretty good idea of what you were saying to do. If I'm correct, the transformer will just isolate my circuitry from the amplified signal, and in the process allow me to set a ground reference. However, I'm not sure exactly what effect the primary/secondary impedance has. I'm thinking that the voltage won't change from primary to secondary coils, but the impedance on the input will be high to prevent current from flowing to my circuit. Am I thinking about this correctly?

Pretty much.
The primary winding of the transformer connected to your amps output, i.e. your tap off point should be a relatively high impedance compared to the speakers impedance and the secondary of the transformer should have a lower impedance then the primary so in this way you will get a voltage reduction.
As you say, the transformer will also "convert" the non ground referenced outputs of the amp to a single ended output which you can now reference to your common ground.
However, all transformers have a frequency range limit and the low end is mostly set by the size of the core, the core material, the construction/geometry of the core and the number of windings.

The transformer you mentioned, has a quoted frequency range of 300Hz to 50KHz (-1.5dB points), so even allowing for a bit of tolerance spread, you are not going to get your required 63Hz low end as there will attenuation of lower frequencies and possible core saturation.
The datasheet states:

Quote
Power level ratings are maximum at lowest frequency rating, power can be increased slightly at higher frequencies.

Have a look around the net for 100V line transformers installed at each speaker on a 100V line public address/background music systems as they are cheaper and tend to have a better low end frequency response.
You would connect the 100V side to the output of your amp (in parallel with the speaker) and the 8 ohm winding would then feed your circuit.
Keep in mind that transformers are mostly inductive and will interfere with the frequency response of the amp+speaker chain, so best place a series resistor (experiment with value, probably around a few hundred ohms) feeding the primary of the transformer.
This will increase the voltage loss (might be advantageous) but will also "decouple" the inductance from the amps output.

You may find that where you live, you may not get 100V line audio systems but instead 70v line.
Either will do.




* Xfmr_Interface.jpg (38.35 KB, 673x292 - viewed 37 times.)
« Last Edit: November 18, 2013, 05:17:31 pm by UnoDueTre » Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Below is a link to the type of transformer I'm referring to:
(plenty other places sell them)

http://www.henrys.co.uk/PA/100v_line_transformers.html

The smallest one is fine.
Whichever one you decide on, first make sure about the frequency response as they are two main types of audio line transformers, those optimized for speech (you don't want those) and the other type has a greater frequency response specifically for music.

Just remember, the mere fact that you are going via a transformer (due to the amps outputs not being referenced to ground), will mean that the low end of the frequency response will always be worse than if you had a direct connection to a low level, high impedance output.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Below is a link to the type of transformer I'm referring to:
(plenty other places sell them)

http://www.henrys.co.uk/PA/100v_line_transformers.html

The smallest one is fine.
Whichever one you decide on, first make sure about the frequency response as they are two main types of audio line transformers, those optimized for speech (you don't want those) and the other type has a greater frequency response specifically for music.

Just remember, the mere fact that you are going via a transformer (due to the amps outputs not being referenced to ground), will mean that the low end of the frequency response will always be worse than if you had a direct connection to a low level, high impedance output.

Unfortunately had to pause this project for a while due to school but I'm hoping to continue now. I've sourced this transformer: http://www.parts-express.com/70v-15w-line-matching-transformer--300-039

This is the lowest frequency I could find, claiming 40Hz and up to 20KHz. Perhaps some of the bigger ones could get even lower but they're much more expensive. 40Hz should be plenty. Does this transformer look reasonable? If so, I'll order a couple and get some more components for some motivation smiley-razz

Shep
Logged

Pages: [1] 2   Go Up
Jump to: