Adjusting this schematic to remove the two 9v batteries.

ebeowulf17

Joined Aug 12, 2014
3,307
Alright, that's even easier then. I will look around because I might have a cap or two lying around, of the correct value.



Here's the voltages:
At full phone volume, the highest I saw was 100mV, of course, the lowest being 0mV.
The output of the amplifier was about 0.12V at max, which is way to low.

I did use an adjustable pot, but it wasn't 100K (only 10K). I have a feeling this could be why.
I did try with just a 100K resistor but that didn't change much.


I believe they are raw ADC values.


I am not using the Instructables code, just the simple analogRead() function. Which, like I quoted above, outputs a value of 0-1023 with an input 0f 0-5v.

EDIT: That means an output of 200 is probably equivalent to about a volt.

Bod
Thank you for detailed, clear answers to my questions. Remote diagnostics are nearly impossible when communication is poor, but you're doing a great job so far.

Your analog read results provide an interesting clue. If the amplifier output biasing was working properly, the signal from the amp to the ADC would be biased at roughly 2.5VDC, with an AC signal riding on top of it. With an optimized gain setting, the AC would be roughly 2.5V peak, so the actual voltages at the ADC would swing from almost 0 to almost 5, always centered around that 2.5V bias. The 2.5V bias would correspond with roughly 512 for your raw ADC value. The fact that it drops to zero with no audio instead of settling at 512 with no audio tells us that biasing isn't set up right.

I'd propose two test measurements to confirm the current situation.

1) Take DC measurements of the signal between amplifier output and ADC. With high audio levels, the DC reading may jump around a lot, but at lower levels it should settle around 2.5V. I'm guessing from your ADC readings that you'll find it settling at 0, which would confirm bias problems.

2) Create a couple voltage dividers to generate a few voltage references (or use adjustable power supply, signal generator, etc if available) and feed them to your ADC to confirm that the raw readings are scaling with input voltages as expected. 5V is ~1023, 2.5 is ~512, 1 is ~204, etc. This is just to make sure the code, analog reference voltage, etc. aren't impacting the accuracy of your readings.
 

Audioguru

Joined Dec 20, 2007
11,248
Why are people talking about biasing the opamp so that its output is AC?
Don't you want the opamp to be a DC peak detector of the AC amplitude? From 0VDC to as high as the output of the opamp can go?
 

Thread Starter

Bod

Joined Sep 18, 2016
317
Thank you for detailed, clear answers to my questions. Remote diagnostics are nearly impossible when communication is poor, but you're doing a great job so far.
Thank you!

Your analog read results provide an interesting clue. If the amplifier output biasing was working properly, the signal from the amp to the ADC would be biased at roughly 2.5VDC, with an AC signal riding on top of it. With an optimized gain setting, the AC would be roughly 2.5V peak, so the actual voltages at the ADC would swing from almost 0 to almost 5, always centered around that 2.5V bias. The 2.5V bias would correspond with roughly 512 for your raw ADC value. The fact that it drops to zero with no audio instead of settling at 512 with no audio tells us that biasing isn't set up right.
I didn't think about that, but yes, it should settle at 512. That makes a lot of sense.
If it was settling at 2.5V, in theory, even a 10K pot should still be fine.

1) Take DC measurements of the signal between amplifier output and ADC. With high audio levels, the DC reading may jump around a lot, but at lower levels it should settle around 2.5V. I'm guessing from your ADC readings that you'll find it settling at 0, which would confirm bias problems.

2) Create a couple voltage dividers to generate a few voltage references (or use adjustable power supply, signal generator, etc if available) and feed them to your ADC to confirm that the raw readings are scaling with input voltages as expected. 5V is ~1023, 2.5 is ~512, 1 is ~204, etc. This is just to make sure the code, analog reference voltage, etc. aren't impacting the accuracy of your readings.
1. Sorry but I don't quite get what you mean. Do you mind explaining it more? I did try but my readings are in mV, not even V which is why the Arduino readings are so low. It does settle at 0V/0mV when the music is off - if that helps.

2. I am using an adjustable power supply. Here are the measurements:
@5V = 1023
@4.5V = ~950
@3V = ~630
@2.5V using voltage divider = ~530
@1.5V using voltage divider = ~300
Because the values seem relatively correct, by the looks of it, nothing is impacting the readings.

Bod
 

Thread Starter

Bod

Joined Sep 18, 2016
317
Why are people talking about biasing the opamp so that its output is AC?
Don't you want the opamp to be a DC peak detector of the AC amplitude? From 0VDC to as high as the output of the opamp can go?
I mean, sure. Does it matter that much though?

Looking around at peak detectors it seems I need one for positive peaks and one for negative peaks. To only use one peak detector, do I need to have the audio signal biased to 2.5V before anyway?
 

MisterBill2

Joined Jan 23, 2018
18,180
I mean, sure. Does it matter that much though?

Looking around at peak detectors it seems I need one for positive peaks and one for negative peaks. To only use one peak detector, do I need to have the audio signal biased to 2.5V before anyway?
The initial question gave the impression that the intent was to convert an actual waveform into a digital format. The amplifier circuit shown was a reference design.
The request was to provide an amplifier circuit that could run from a single 5 volt supply. That has been provided and ignored. Never was there a request for an envelope amplitude detector.
 

Audioguru

Joined Dec 20, 2007
11,248
You probably do not need a positive peak detector and a negative peak detector because audio is usually symmetrical.
A non-inverting opamp as a peak detector needs a positive and negative power supply because the (+) input pin swings positive and negative. But the negative swing damages the input when it goes outside the 0V power supply limit of a single polarity supply.
An inverting opamp as a peak detector uses its negative feedback to cancel the signal at its (-) input pin when the signal feeding its input resistor goes negative so it works fine with a single polarity power supply. The opamp used must be one that allows its inputs to work properly at voltages as low as 0V (its negative supply voltage when the supply has only a positive polarity).

I hope you are not using a cheap multimeter to measure audio AC voltages or fast pulses from the peak detector because it is designed to measure only low frequency 50Hz and 60Hz accurately.
 

ebeowulf17

Joined Aug 12, 2014
3,307
You I hope you are not using a cheap multimeter to measure audio AC voltages or fast pulses from the peak detector because it is designed to measure only low frequency 50Hz and 60Hz accurately.
I forgot about the deliberate low pass filter behavior of most meters when I advised the thread starter to try that, so that mistake is on me. Nevertheless, the DC measurements and the Arduino ADC readings all fall in line reasonably well.

The link the thread starter initially shared recommends building an amp with 2.5V bias and feeding it into an Arduino for a variety of different projects, not just peak or envelope detection. If he wants to try those other projects, he'll need the amp, not just a rectified peak or envelope circuit. On the other hand if the goals are more limited, the rectifying circuits might be easier and require much less Arduino code for the same results.

As long as the project is focused on the biased amplifier approach, step one needs to be figuring out why the output isn't biased.
 

Thread Starter

Bod

Joined Sep 18, 2016
317
A non-inverting opamp as a peak detector needs a positive and negative power supply because the (+) input pin swings positive and negative. But the negative swing damages the input when it goes outside the 0V power supply limit of a single polarity supply.
I am trying to avoid a +- supply.

An inverting opamp as a peak detector uses its negative feedback to cancel the signal at its (-) input pin when the signal feeding its input resistor goes negative so it works fine with a single polarity power supply. The opamp used must be one that allows its inputs to work properly at voltages as low as 0V (its negative supply voltage when the supply has only a positive polarity).
I take it then that the LM358 is not suitable for this. Looking at the datasheet, the numbers suggest that the negative swing could damage it.

I hope you are not using a cheap multimeter to measure audio AC voltages or fast pulses from the peak detector because it is designed to measure only low frequency 50Hz and 60Hz accurately.
This is my DMM: http://www.neoteck.cn/index.php/2017/07/03/ntk028/ - it's not the best, but it's good enough.

EDIT: formatting
 

Audioguru

Joined Dec 20, 2007
11,248
An LM358 is fine for the peak detector circuit since its inputs work all the way down to its negative supply that can be 0V (a negative supply is not needed) when it is used as an inverting opamp, its output will also go down close to 0V. Its high level of hiss makes it poorly amplify the very low levels from a microphone and its crossover distortion makes the waveform look funny. The maximum positive output of an LM358 is about 1.5V less than its positive supply voltage when it has a high resistance load.

Your no-name-brand multimeter does not say a spec for its frequency response so it probably cannot measure audio levels accurately.
 

MisterBill2

Joined Jan 23, 2018
18,180
An LM358 is fine for the peak detector circuit since its inputs work all the way down to its negative supply that can be 0V (a negative supply is not needed) when it is used as an inverting opamp, its output will also go down close to 0V. Its high level of hiss makes it poorly amplify the very low levels from a microphone and its crossover distortion makes the waveform look funny. The maximum positive output of an LM358 is about 1.5V less than its positive supply voltage when it has a high resistance load.

Your no-name-brand multimeter does not say a spec for its frequency response so it probably cannot measure audio levels accurately.
Mostly the folks who use multimeters understand that the AC mode is primarily for power frequency measurements, and at higher frequencies and non-sinewaves the readings are relative.
 

Reloadron

Joined Jan 15, 2015
7,501
Just as a matter of clarity I think your objective here is to pass an audio signal into the analog input of an Arduino. Once this is done, then what's the plan? Earlier I mentioned having a LED pulse to the audio in to the Arduino, would that be correct?

Ron
 

djsfantasi

Joined Apr 11, 2010
9,156
Just as a matter of clarity I think your objective here is to pass an audio signal into the analog input of an Arduino. Once this is done, then what's the plan? Earlier I mentioned having a LED pulse to the audio in to the Arduino, would that be correct?

Ron
Ron,

I don’t think so. The closest the TS came to describe what he is going to do was “an adjust the LEDs in turn” in this post. Implied in this statement was that there are multiple LEDs. If I were to make a guess that’s as valid as yours, I’d say he was making a digital VU Meter.

dj
 

Reloadron

Joined Jan 15, 2015
7,501
Ron,

I don’t think so. The closest the TS came to describe what he is going to do was “an adjust the LEDs in turn” in this post. Implied in this statement was that there are multiple LEDs. If I were to make a guess that’s as valid as yours, I’d say he was making a digital VU Meter.

dj
Well alrighty then. Not sure what LEDs in turn is all about but maybe as you called it. A VU meter?

Ron
 

Thread Starter

Bod

Joined Sep 18, 2016
317
An LM358 is fine for the peak detector circuit since its inputs work all the way down to its negative supply that can be 0V (a negative supply is not needed) when it is used as an inverting opamp, its output will also go down close to 0V. Its high level of hiss makes it poorly amplify the very low levels from a microphone and its crossover distortion makes the waveform look funny. The maximum positive output of an LM358 is about 1.5V less than its positive supply voltage when it has a high resistance load.

Your no-name-brand multimeter does not say a spec for its frequency response so it probably cannot measure audio levels accurately.
Cool. I will for peak detectors and try some out.

Ron,

I don’t think so. The closest the TS came to describe what he is going to do was “an adjust the LEDs in turn” in this post. Implied in this statement was that there are multiple LEDs. If I were to make a guess that’s as valid as yours, I’d say he was making a digital VU Meter.

dj
Yeah pretty much. Possibly not the same kind of effects - more like this:

Bod
 

Thread Starter

Bod

Joined Sep 18, 2016
317
I have just tried this peak detector:
YSf4AEC.png
But again, like all the others, the output is such a small voltage.
 

MisterBill2

Joined Jan 23, 2018
18,180
"audio Visualizer" is a new name for the "color organ" circuits that were such a fad back in the late sixties. There have been hundreds of published circuits and none of them needed a processor. If the intended goal is an LED VU (Volume unit) meter there are several IC devices dedicated to that function available, each one being far better than an arduino system, both in accuracy, cost, power consumption, and size, and they are all far less complex.
I am amazed that the fad is returning now, almost 50 years later.
The peak detector circuits shown in post #77 are unity gain circuits, so the output will be at most a bit less than the inputs. and with the 100K ohm output resistor they will not do very well feeding a low impedance load. Adding a 10K ohm resistor in series with the connection to the inverting input will increase the gain a bit.
 
Last edited:

Thread Starter

Bod

Joined Sep 18, 2016
317
"audio Visualizer" is a new name for the "color organ" circuits that were such a fad back in the late sixties. There have been hundreds of published circuits and none of them needed a processor. If the intended goal is an LED VU (Volume unit) meter there are several IC devices dedicated to that function available, each one being far better than an arduino system, both in accuracy, cost, power consumption, and size, and they are all far less complex.
I am amazed that the fad is returning now, almost 50 years later.
The peak detector circuits shown in post #77 are unity gain circuits, so the output will be at most a bit less than the inputs. and with the 100K ohm output resistor they will not do very well feeding a low impedance load. Adding a 10K ohm resistor in series with the connection to the inverting input will increase the gain a bit.
I will try out the 10K.
The reason I am using the Arduino is that I have other LED strip effects programmed on there, which activate when there is no music. I bet there are ICs out there that do this job, but I find it much easier with an Arduino mainly because I have the stuff, and have more knowledge in Arduino than a random LED driver chip.
 

MisterBill2

Joined Jan 23, 2018
18,180
I will try out the 10K.
The reason I am using the Arduino is that I have other LED strip effects programmed on there, which activate when there is no music. I bet there are ICs out there that do this job, but I find it much easier with an Arduino mainly because I have the stuff, and have more knowledge in Arduino than a random LED driver chip.
Thanks for the explanation. Also, now we know a bit more about the application, which does not require precision.
 
Top