Adjusting this schematic to remove the two 9v batteries.

Reloadron

Joined Jan 15, 2015
7,517
Yes - that is exactly what I am looking for. Mainly trying to use the LM358's because I have those to hand.
Then just work from a LM358 Datasheet and in the application notes page 22 Figure 41 you see a circuit. Note how the gain is calculated as Av = 1 + R2/R1. I see 1,000,000 / 100,000 = 10. If you look back at a few previous drawings we hit on you will see a few X 10 amplifiers cascaded so you get 10 X 10 = 100 for a total gain. You will also see examples where the pot is placed between two cascaded amplifiers to allow a variable gain. That is exactly what was done in this example using a LMV358.

Ron
 

BobTPH

Joined Jun 5, 2013
8,967
@BobTPH
I have rarely used spice, and I could do with some help.

Firstly, how do I add custom parts - mainly the LM358? I looked it up online but it didn't work and I got this error:
"Unknown subcircuit called in:
'xu1 n006 n004 n001 0 n005 opamp2'"

Secondly, what is the 'in' on the + side of the voltage source and the 'in' next to the 1uf cap? How do I get those and link them together? (I take it the 'out' is the same as the 'in's?)

Thanks,
Bod
You need to add a .include directive for the model.

The “in” is a label, on the toolbar it is a box with ABC in it. Labels rgat natch are connected together.

Bob
 

Thread Starter

Bod

Joined Sep 18, 2016
317
You need to add a .include directive for the model.

The “in” is a label, on the toolbar it is a box with ABC in it. Labels rgat natch are connected together.

Bob
Thanks for the reply.
I will add the labels.

As for the model - I will try and import it again.
 

Thread Starter

Bod

Joined Sep 18, 2016
317
I want to put this post on hold for now.

The reason is that I am missing components when it comes to making what has been suggested. It's mainly capacitors, so I am going to place a bulk order of them, of all different types and values. Hopefully, this will allow me to create some of the other circuits.

Thanks so far,
Bod
 

Thread Starter

Bod

Joined Sep 18, 2016
317
Wow! They came very quickly - didn't even use prime!

Just tried the circuit in post #86.
upload_2019-7-6_13-42-39.png
Unfortunately, it didn't work. The settling value (when there was no audio) was between 400 and 600. This makes it almost impossible to check whether the audio was making a difference.

Also tried the circuit in post #48.
SparkFun_OpAmp_Breakout-LMV358.png
Same problem as before. There was no definitive settling value. The image below is the Arduino output when circuits #48 & #86 were used with no audio playing.
Screen Shot 2019-07-09 at 20.05.24.png

I then went ahead and tried a half wave rectifier - following this schematic:
an001-f1.gif
It worked, but only slightly.

I am yet to try this circuit - I don't have the time right now.
audioamp_circuit.png

Bod
 

Thread Starter

Bod

Joined Sep 18, 2016
317
I didn't end up building the above circuit, but I did experiment with the LM386. I know it is designed for speakers, bet when I built this circuit:
i.png
and fed it into the Arduino, the output was very much working - it was very amplified and the Arduino output was showing me highs of almost 300. However, I believe because it is a circuit for a speaker, sometimes the negative frequencies would be cut off by the ADC. That was the only downside.
What I don't understand is why all of the circuits I built in the post above didn't work. I went back over and rebuilt them (and some other not listed there like the one in post #6) and yet they still didn't work. Number #86 has spice proof to go along with it and so I see no reason it shouldn't work. It's not that I didn't build it correctly because it's not a very hard circuit.
Same with number #48 - if the circuit didn't work, Sparkfun wouldn't be selling it! That circuit is pretty much designed for an Arduino.

Why does it work soldered on a PCB, but not on a breadboard?
 

BobaMosfet

Joined Jul 1, 2009
2,113
My LM358 eBay order came with 5 Lm358's so that's not a problem. It's just the complimentary components that go along with them. It looks like I have everything apart from the two 100pf and the one 1uf capacitor. It's whether I'm willing to get them or not because during the whole project I have acquired many components that are unnecessary, and I don't want these to go into that pile.

Bod

EDIT: I have again been looking for other schematics and found this:
View attachment 180981
It also uses two LM358's. The website calls it a 'summing opamp'. Surely I could just use one input, instead of three?
Sort your components and save them. There are no useless or 'unused' components :p - You'll find a project down the road hopefully that will likely use them. 100pf and 1uF components are common for many projects, so having extras isn't a bad idea. I've got rooms full of tens of thousands of components, and still I find I need more ... ;)
 

BobaMosfet

Joined Jul 1, 2009
2,113
I didn't end up building the above circuit, but I did experiment with the LM386. I know it is designed for speakers, bet when I built this circuit:
View attachment 181407
and fed it into the Arduino, the output was very much working - it was very amplified and the Arduino output was showing me highs of almost 300. However, I believe because it is a circuit for a speaker, sometimes the negative frequencies would be cut off by the ADC. That was the only downside.
What I don't understand is why all of the circuits I built in the post above didn't work. I went back over and rebuilt them (and some other not listed there like the one in post #6) and yet they still didn't work. Number #86 has spice proof to go along with it and so I see no reason it shouldn't work. It's not that I didn't build it correctly because it's not a very hard circuit.
Same with number #48 - if the circuit didn't work, Sparkfun wouldn't be selling it! That circuit is pretty much designed for an Arduino.

Why does it work soldered on a PCB, but not on a breadboard?
Is your breadboard faulty? They aren't perfect, some can be bad. Have you tried a different breadboard? Have you tried different jumper wires? I have projects on breadboards where I have to regularly wiggle some of the jumpers so that good contact will be made again, as it tends to degrade over time (yeah, they were cheap boards, but hey).

Sometimes, taking a sub-project to PCB is the way to go, because otherwise it takes up too much space (too many breadboards) or what not otherwise. A subj-project I did for a clock was IV-22 VFD displays (these are the world's most compact at 1" W x 1.6" T all through-hole):
IV22-4-Digit.jpg
 
Last edited:

Reloadron

Joined Jan 15, 2015
7,517
The LM386 Low Voltage Audio Power Amplifier has a fixed gain of 20 which can be expanded to about 200. As drawn your circuit has a gain of 20. Earlier I posted a few images of what happens to a negative going signal when you try to input it to an Arduino ADC pin. The Arduino ADC is a 10 bit A to D converter so 0 to 5 Volte = 0 to 1023 bits. You want the audio peaks hitting close to that. Then you can MAP the analog in to a PWM out and drive your LED circuit(s).

Ron
 

Thread Starter

Bod

Joined Sep 18, 2016
317
Sort your components and save them. There are no useless or 'unused' components :p - You'll find a project down the road hopefully that will likely use them. 100pf and 1uF components are common for many projects, so having extras isn't a bad idea. I've got rooms full of tens of thousands of components, and still I find I need more ... ;)
When I was building that it was late and I totally forgot there were conversions between pF and uF. It turns out I do have 100pF caps also known as 0.1uF caps, which I have many of!
Whoops! I read the conversion chart wrong - I don't have any 0.0001uF caps!

Is your breadboard faulty? They aren't perfect, some can be bad. Have you tried a different breadboard? Have you tried different jumper wires? I have projects on breadboards where I have to regularly wiggle some of the jumpers so that good contact will be made again, as it tends to degrade over time (yeah, they were cheap boards, but hey).

Sometimes, taking a sub-project to PCB is the way to go, because otherwise it takes up too much space (too many breadboards) or what not otherwise. A subj-project I did for a clock was IV-22 VFD displays (these are the world's most compact at 1" W x 1.6" T all through-hole):
View attachment 181410
I will try another breadboard. I don't like taking circuits to PCB before I have got them working because I see it as, one, a bit pointless because that's what breadboards are for, and two, it's fairly expensive even with companies like JLCPCB, because of shipping costs.

The LM386 Low Voltage Audio Power Amplifier has a fixed gain of 20 which can be expanded to about 200. As drawn your circuit has a gain of 20. Earlier I posted a few images of what happens to a negative going signal when you try to input it to an Arduino ADC pin.
Ron
That is the reason I didn't want to have to use an LM386 circuit because of the ADC clipping any negative voltages.
 

Audioguru

Joined Dec 20, 2007
11,248
The circuit in post #86 did not work (it always had an output reading when no audio was playing) because it has an output DC bias voltage at 2.5V and the cheap lousy old LM358 is noisy. Your Arduino was measuring the noisy +2.5V.
If you disregard the noise and capacitor-couple it into an inverting peak detector circuit I showed (the non-inverting peak detector circuit you show needs a positive and negative supply) then it will produce what you want from almost 0V to about +3.8V with an LM358 dual opamp.

Somebody in this thread explained how the Arduino can be programmed to convert the DC bias voltage to 0V, then the peak detector would not be needed.
 

Thread Starter

Bod

Joined Sep 18, 2016
317
Just retried circuit #86 on a different breadboard. I no longer have the problem described above in post #106. The circuit, even when the aux cable is connected, hovers around 510, which is almost exactly 2.5V. However, when there is audio. There is no change in the numbers, they always stay at around 510.

I was going to retry circuit #48 however I noticed something. On the schematic, it says 'LMV' not 'LM'. When I first built it, I assumed it was one of those kinds of 'identifying' letters (i.e. the LM386 can also be the LM386L). Now, before I built it again, I decided to check. It turns out the LMV358 is a rail-to-rail op-amp whereas the LM385 is only an op-amp. This is most likely the reason it didn't work.
If someone already mentioned this, sorry about that!

Bod
 

Thread Starter

Bod

Joined Sep 18, 2016
317
The circuit in post #86 did not work (it always had an output reading when no audio was playing) because it has an output DC bias voltage at 2.5V and the cheap lousy old LM358 is noisy. Your Arduino was measuring the noisy +2.5V.
If you disregard the noise and capacitor-couple it into an inverting peak detector circuit I showed (the non-inverting peak detector circuit you show needs a positive and negative supply) then it will produce what you want from almost 0V to about +3.8V with an LM358 dual opamp.

Somebody in this thread explained how the Arduino can be programmed to convert the DC bias voltage to 0V, then the peak detector would not be needed.
Sorry, didn't see your post when writing my previous one.
I will give your suggestion a go.
 

Thread Starter

Bod

Joined Sep 18, 2016
317
The circuit in post #86 did not work (it always had an output reading when no audio was playing) because it has an output DC bias voltage at 2.5V and the cheap lousy old LM358 is noisy. Your Arduino was measuring the noisy +2.5V.
If you disregard the noise and capacitor-couple it into an inverting peak detector circuit I showed (the non-inverting peak detector circuit you show needs a positive and negative supply) then it will produce what you want from almost 0V to about +3.8V with an LM358 dual opamp.

Somebody in this thread explained how the Arduino can be programmed to convert the DC bias voltage to 0V, then the peak detector would not be needed.
Just tried it out but the amplification, like other circuits, is very low. There is no noise, however.
First off, I did use a 10K pot, not a 100K pot (because I don't have one), is this making a big difference to the amplification?
Also, when you say 'capacitor-couple' it into the inverting peak detector, do I need to add another capacitor along with the one already in the circuit, or is the 100nF the coupling capacitor?

Bod
 

BobaMosfet

Joined Jul 1, 2009
2,113
I am following a guide to allow you to input sound into the Arduino (https://www.instructables.com/id/Arduino-Audio-Input/). It is a pretty simple schematic however it uses two 9v batteries in series. It is all well and good when testing, but in my actual circuit, I don't want two batteries floating around - It uses the batteries to power the Arduino (through VIN) and also to power the chip (I have the TL082).


How can I get rid of the batteries and use the Arduino's 5V supply? I have a feeling it is quite simple however I can't get my head around it. I can power the Arduino with 12V if need be.

View attachment 180453

Thanks,
Bod
@Bod - Don't waste your time with your original circuit, it's bad Whomever came up with it had not a clue how to do this, other than their use of the 10uF cap in the middle to keep the A/C and D/C sides separate. The 100K + 100K resistor series divider on the ADC input to the arduino biases any A/C that passes through the 10uF cap into the D/C realm at 2.5V.

Frankly, you don't want an OpAmp for input into your ADC. it only expects a few mA of current within a 5V range. Use a single transistor with the queue-point properly set, a BJT will do, and use that to raise your input signal current to a few mA.

And yes, using a 10K pot for your variable resistor instead of a 100K pot makes a huge difference, because the entire point of the those 2 resistors is to give you a way to variably bias the A/C input signal.
 

BobTPH

Joined Jun 5, 2013
8,967
Well,
Just retried circuit #86 on a different breadboard. I no longer have the problem described above in post #106. The circuit, even when the aux cable is connected, hovers around 510, which is almost exactly 2.5V. However, when there is audio. There is no change in the numbers, they always stay at around 510.
that is progress, the no signal output is correct. If it is wired correctly, it should go from 0 to 1023 with a 100mV input.

Instead of throwing up your hands and trying a different circuit each time your circuit does not work, how anout trying to figure out why it is not working.

Did you check the input and output voltages of the amplifier?

Did you recheck all the wiring? I think you are too quick to give up.

Bob
 

Audioguru

Joined Dec 20, 2007
11,248
You posted many amplifier circuits with an AC and DC output. The Arduino was measuring the average output voltage of half the DC supply voltage and maybe it fluctuated up and down very quickly with the audio. You need a peak detector that gives an output of 0V with no signal and a filtered output that gives +5V at maximum signal level.
The inverting peak detector needs an input coupling capacitor in series with the input resistor to block the DC from the signal source (a microphone preamp with its output swinging up and down from +2.5V?). The filtering determines how long you see the resulting voltage before it fades away.
 

Thread Starter

Bod

Joined Sep 18, 2016
317
@Bod - Don't waste your time with your original circuit, it's bad Whomever came up with it had not a clue how to do this, other than their use of the 10uF cap in the middle to keep the A/C and D/C sides separate. The 100K + 100K resistor series divider on the ADC input to the arduino biases any A/C that passes through the 10uF cap into the D/C realm at 2.5V.

Frankly, you don't want an OpAmp for input into your ADC. it only expects a few mA of current within a 5V range. Use a single transistor with the queue-point properly set, a BJT will do, and use that to raise your input signal current to a few mA.

And yes, using a 10K pot for your variable resistor instead of a 100K pot makes a huge difference, because the entire point of the those 2 resistors is to give you a way to variably bias the A/C input signal.
I think I will order myself some 100K pots.
Also, iimagine has posted a transistor-based circuit, similar to what you described. I will try it out.

Well,

that is progress, the no signal output is correct. If it is wired correctly, it should go from 0 to 1023 with a 100mV input.
Did you check the input and output voltages of the amplifier?
Did you recheck all the wiring?

Bob
The output voltages weren't very high - I don't know if I can measure the input. Here's the quote from Audioguru about my DMM:
Your no-name-brand multimeter does not say a spec for its frequency response so it probably cannot measure audio levels accurately.
EDIT: I also put the circuit into an online simulator. The graph produced matches with my most recent output. I don't have a screenshot of it, but I have drawn it.
Screen Shot 2019-07-11 at 16.34.05.png

Instead of throwing up your hands and trying a different circuit each time your circuit does not work, how anout trying to figure out why it is not working.
...I think you are too quick to give up.
That's not what I am trying to be like. I was suggested circuits that I hadn't tried and also often ways to fix others. I don't want to ignore them, so I try them out. I am happy to focus on just one circuit, but I will try others. It doesn't take long to put them together.

Thank you, I will!
 
Last edited:
Top