Adjusting this schematic to remove the two 9v batteries.

Thread Starter

Bod

Joined Sep 18, 2016
317
Here's an idea - how about the LM386.

Every time I google for an LM385 amplifier circuit I get some results, but the main ones using an LM386. I do have on me. Is this a good idea?


Bod

EDIT: It looks like it won't work.
 

Reloadron

Joined Jan 15, 2015
7,892
Well alrighty then, that is what I had in mind back in post #43 or so where I wrote:
If your objective with an audio signal is just to drive a LED which changes intensity with the music volume (what we called a color organ) your audio signal out from whatever you have may be adequate less any amplification, just pass the AC Audio in but using the resistive divider on the A0 input of the Arduino.
What you are looking for is what we called a color organ which as was mentioned was a popular toy back as far as the 60s. I thought that is what you had in mind.

With that in mind I suggest you look at amplification circuits you will find with a simple Google of color organ. Early circuits drove 120 VAC or 220 VAC incandescent lamps using a simple triac circuit and filtering the input for Bass, Midrange and Treble or simply put low, medium and high frequencies. Today, as mentioned, the old classic color organ is enjoying a resurgence. Today the use of micro controllers has become popular and driving LED strings. There is no shortage of designs out there to get where you want to be, likely with parts you have laying around. I suggest you start with a simple Google of " Arduino Color organ circuits" to find something you have parts for and does what you are looking to do. You can have simple response to audio VU level to LED intensity or filter the audio to drive PWM Arduino out based on amplitude and frequency of an analog input signal.

Start with a Google of Color Organ Circuits and get a handle on what is going on and how assorted amplifiers are doing what they do. Then once you understand the applied circuits try another Google but this time add the Arduino as in "Arduino Color Organ Circuits". The key words here are "color organ".

Ron
 

Thread Starter

Bod

Joined Sep 18, 2016
317
Well alrighty then, that is what I had in mind back in post #43 or so where I wrote:


What you are looking for is what we called a color organ which as was mentioned was a popular toy back as far as the 60s. I thought that is what you had in mind.

With that in mind I suggest you look at amplification circuits you will find with a simple Google of color organ. Early circuits drove 120 VAC or 220 VAC incandescent lamps using a simple triac circuit and filtering the input for Bass, Midrange and Treble or simply put low, medium and high frequencies. Today, as mentioned, the old classic color organ is enjoying a resurgence. Today the use of micro controllers has become popular and driving LED strings. There is no shortage of designs out there to get where you want to be, likely with parts you have laying around. I suggest you start with a simple Google of " Arduino Color organ circuits" to find something you have parts for and does what you are looking to do. You can have simple response to audio VU level to LED intensity or filter the audio to drive PWM Arduino out based on amplitude and frequency of an analog input signal.

Start with a Google of Color Organ Circuits and get a handle on what is going on and how assorted amplifiers are doing what they do. Then once you understand the applied circuits try another Google but this time add the Arduino as in "Arduino Color Organ Circuits". The key words here are "color organ".

Ron
Thanks for the reply. Googling what you said, the first thing I found was this: https://www.instructables.com/id/Arduino-Color-Organ/
It comes with this schematic
FXEWP7EJ3YPTYYT.LARGE.jpg
I will try it out now.
Bod
 

BobTPH

Joined Jun 5, 2013
11,553
That circuit would be for taking a speaker level output as input.

This simple circuit will work if you use a rail-to-rail opamp like I suggested centuries ago. From a 100mV peak input it produces 0 to 5V output. which you should subtact 2.5V from to get the actual amplitude. If you want to use an LM358 with a 9V supply you would only have to change the biasing resistors to make sure there is 2.5V at the + input.

upload_2019-7-6_13-42-39.png

Bob
 

Thread Starter

Bod

Joined Sep 18, 2016
317
That circuit would be for taking a speaker level output as input.

This simple circuit will work if you use a rail-to-rail opamp like I suggested centuries ago. From a 100mV peak input it produces 0 to 5V output. which you should subtact 2.5V from to get the actual amplitude. If you want to use an LM358 with a 9V supply you would only have to change the biasing resistors to make sure there is 2.5V at the + input.

View attachment 181112

Bob
Thanks for the reply. I will spice it first to save time, then breadboard it.
 

iimagine

Joined Dec 20, 2010
512
Unfortunately, it didn't work. I will look around for others.
Arent you curious as why it doesnt work for you? Did you forget a step? Double check every wiring? That circuit is as simple as it get, testing code is straight forward. The only way to learn is to try and figure out why/how it works.
 

Thread Starter

Bod

Joined Sep 18, 2016
317
Arent you curious as why it doesnt work for you? Did you forget a step? Double check every wiring? That circuit is as simple as it get, testing code is straight forward. The only way to learn is to try and figure out why/how it works.
I believe it could be my connections to the pot.

It probably didn't "work" because he is taking a 100mV input and the circuit has no gain.

Bob
This could also be the reason.

It's such a simple circuit, so if the one provided by Bob doesn't work as intended, I will go back to this one and try it out.
 

BobTPH

Joined Jun 5, 2013
11,553
If you get it to "work" it will give you a range of 471 to 553 counts on your ADC.

My circuit, with the gain of 25 will give you 0 to 1023 counts for a 100mV signal.

Bob
 

Thread Starter

Bod

Joined Sep 18, 2016
317
If you get it to "work" it will give you a range of 471 to 553 counts on your ADC.

My circuit, with the gain of 25 will give you 0 to 1023 counts for a 100mV signal.

Bob
Do you know what the settling value will be?
 

Thread Starter

Bod

Joined Sep 18, 2016
317
@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
 

Audioguru

Joined Dec 20, 2007
11,248
The kid in the video has a chaser circuit driving a strip of LEDs and he is changing the colors by using an audio spectrum analyser circuit. His circuit works poorly at low levels because his peak detector uses a transistor that does nothing until the amplitude is high.

I agree that your circuit needs another non-inverting opamp (the second opamp in the LM358) so that the output is a much lower impedance.

An opamp has gain when it has TWO resistors at its (-) input.

I think your arithmetic is not correct when selecting resistor and capacitor values. See here:
 

Attachments

Audioguru

Joined Dec 20, 2007
11,248
I finally looked at the Instructables Color Organ project. The Arduino has a "threshold" setting so that there is no output with no signal and so that a rectifier is not needed. The detector is an average, not peak type.
The color outputs were not bright with high levels and dim with low levels, instead they were simply on and off.
 

Thread Starter

Bod

Joined Sep 18, 2016
317
The kid in the video has a chaser circuit driving a strip of LEDs and he is changing the colors by using an audio spectrum analyser circuit. His circuit works poorly at low levels because his peak detector uses a transistor that does nothing until the amplitude is high.

I agree that your circuit needs another non-inverting opamp (the second opamp in the LM358) so that the output is a much lower impedance.

An opamp has gain when it has TWO resistors at its (-) input.

I think your arithmetic is not correct when selecting resistor and capacitor values. See here:
Thanks for the reply.
Unfortunately, my component supply is very limited at the moment (it's very annoying) and I don't have everything I need for it. If what I am building now doesn't work, I will order some capacitors and try out your circuit.

Bod
 

iimagine

Joined Dec 20, 2010
512
Best approach is using just 1/2 of the waveform, since you are just detecting freq and amplitude to light the LED. This is better because now your voltage per scaling step is much higher thus, more accurate. There is no need for a peak detector circuit, since that can be done in your code
Something like this:

upload_2019-7-6_17-9-29.png
 

Reloadron

Joined Jan 15, 2015
7,892
It probably didn't "work" because he is taking a 100mV input and the circuit has no gain.

Bob
That would be it. You need to get a low level signal amplified a little. You also need to get it into a usable range for the Arduino. Below are two images of a 1 KHz signal running into an Arduino Analon Input.

Arduino In1.png
Vertical gain is 2 V/Div. The signal is a sine wave. Note the negative peaks are clipped. This is because, as we covered before, the Arduino ADC requires a 0 volt to a max of 5 volt input.

The next image is the same signal but with a DC Offset.
Arduino In2.png
With the about 2 VDC Offset my sine wave now looks good and is no longer clipped. This is what you want.

Any number of amplifier designs will work. The idea is you want amplification and you want an offset so your Arduino is not clipping the negative peaks as in the first image.

Ron
 

Thread Starter

Bod

Joined Sep 18, 2016
317
Best approach is using just 1/2 of the waveform, since you are just detecting freq and amplitude to light the LED. This is better because now your voltage per scaling step is much higher thus, more accurate. There is no need for a peak detector circuit, since that can be done in your code
Something like this:

View attachment 181130
I think this is what MrChips was stating in post #28.
Also, it looks like your audio signal is being clipped - is that true?
 

Thread Starter

Bod

Joined Sep 18, 2016
317
The idea is you want amplification and you want an offset so your Arduino is not clipping the negative peaks as in the first image.
Ron
Yes - that is exactly what I am looking for. Mainly trying to use the LM358's because I have those to hand.
 
Top