Beat Detection using an op-amp

Post here to let others know of a project you're working on.

Moderators: Chuckt, Garth, bitfogav

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Beat Detection using an op-amp

Post by bitfogav » Sun Feb 27, 2011 2:15 am

I thought I would make this new post as it might be usful for anyone looking through the forum and who might be looking for using beat detection in there project, the original post was from my DMX controller.

I like to thank Brad for his input and Graham at digital-diy.com, but I found this circuit works fine for the application I was making.

the circuit:
ElectretmicVer2.jpg
ElectretmicVer2.jpg (13.87 KiB) Viewed 27412 times
The Microphone and the Amplifier (op-amp on the left)
As you can see from the picture above, we have an electret microphone connected to the ground line, and to one end of a 10k resistor. The other end of the resistor is tied to the 5v line. when an audio sound is sensed by the micrpphone, it changes that audio signal into a voltage that emulates the tone picked up. We AC-couple the signal using a coupling capacitor. This signal will be extremely small, so we must first amplify it. I am doing that using a LM385 dual op-amp IC.

Go here for the data sheet:
http://www.national.com/ds/LM/LM158.pdf

The pull-down resistor to the right of the coupling capacitor is necessary for the operation of the non-inverting amplifier stage to work. In fact, all components in the above diagram are crutial. The way a non-inverting op-amp works, is it takes two values RA, which is the 1k resistor connected to the (-) input and ground, and RF (100k potentiometer), which is the feedback resistor, which is connected between the (-) input, and the output, and creates a voltage gain factor.
The voltage gain factor (AV) is a multiplier. Once we determine the AV, we multiply the voltage at the input by the AV, and we have our output voltage.
The 100k pot is used to vary the voltage gain. This will either increase the sensitivity or decrease the sensitivity of the circuit. The equation for AV = RF/RA in a non-inverting amplifier circuit.

The Comparator (op-amp on the right)
I wanted to turn our now amplified waveform into a 0-5VDC square wave that can be used by a I/O Pin of a microcontroller.
What im going to emply here is the comparator circuit. A comparator does exactly as you'd think. It compares voltages. If the voltage at the (-) input is higher than the voltage at the (+) input, then the output will be 0v. If the voltage at the (+) input is higher than the voltage at the (-) input, then the output will be 5v.

We have a resistor voltage divider network at the negative (-) input. This will keep a constant 1.5v at the negative input. When a loud sound is generated and amplified to a voltage higher than 1.5v, then the output will go from 0-5v until the voltage at the (+) falls below 1.5v. We only need for the output of the comparator to be high for a micro second or so, so don't worry too much about the time duration of the output of the comparator being high.



a video showing the circuit in operation:

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Beat Detection using an op-amp

Post by brad » Sun Feb 27, 2011 8:38 pm

Very helpful post with a great explanation of the circuit operation.

Thanks for sharing :D

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Beat Detection using an op-amp

Post by bitfogav » Fri Mar 04, 2011 7:44 am

Ive found using something more like this gives the circuit more detection to bass beats or low frequencies, using a low pass filter.

Electretmic Low pass rev2.jpg
Electretmic Low pass rev2.jpg (18.08 KiB) Viewed 27401 times

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Beat Detection using an op-amp

Post by brad » Sat Mar 05, 2011 12:56 pm

You could even make that a variable cap to 'fine tune' your frequency response.

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Beat Detection using an op-amp

Post by bitfogav » Sun Mar 06, 2011 8:20 am

Do they do a Variable cap with a high capacitance?.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Beat Detection using an op-amp

Post by brad » Sun Mar 06, 2011 11:51 am

Yep, you can get all sorts of values.

Perhaps you could even use a varicap diode / varactor diode?

User avatar
odessa
I practically live here!
I practically live here!
Posts: 102
Joined: Thu Sep 09, 2010 6:06 am
Location: London
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Beat Detection using an op-amp

Post by odessa » Thu Mar 31, 2011 6:46 am

Hi Guys n Gals :)

This is the design I'm using for a similar project
Beat detector.png
Beat detector.png (9.13 KiB) Viewed 27376 times
I decided to make the comparator adjustable ... Any comments or suggestions welcomed :)
(\_/)
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Beat Detection using an op-amp

Post by bitfogav » Thu Mar 31, 2011 6:56 am

I like your circuit Jay,

Thank you for posting it. I will have to make this up and compare it with my mic circuit, I like how you adjust the ref voltage on the comparator. :)


cheers Gav

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Beat Detection using an op-amp

Post by brad » Thu Mar 31, 2011 5:35 pm

What would happen if you made the schmidt trigger variable?

User avatar
odessa
I practically live here!
I practically live here!
Posts: 102
Joined: Thu Sep 09, 2010 6:06 am
Location: London
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Beat Detection using an op-amp

Post by odessa » Thu Mar 31, 2011 6:15 pm

Thats what I've done isn't it ? Or have I done something wrong :lol:
(\_/)
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Beat Detection using an op-amp

Post by brad » Fri Apr 01, 2011 7:57 am

You have a variable comparator but a fixed UTP and LTP for the schmidt trigger :)

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Beat Detection using an op-amp

Post by bitfogav » Fri Apr 01, 2011 8:14 am

brad wrote:You have a variable comparator but a fixed UTP and LTP for the schmidt trigger :)
Im guessing you mean Brad ,

The turn ON voltage is usually called the upper trigger point or UTP and the turn OFF voltage is called lower trigger point or LTP.

UTP is always greater than LTP since the voltage required to turn ON a device is more than that required to turn it OFF.

I guess if Jay(odessa) changes the 100k resistor (R3) in the circuit with a 100k pot? then it would be a variable schmidt trigger?

User avatar
odessa
I practically live here!
I practically live here!
Posts: 102
Joined: Thu Sep 09, 2010 6:06 am
Location: London
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Beat Detection using an op-amp

Post by odessa » Fri Apr 01, 2011 4:35 pm

Yes exactly. The voltage into the comparator varies depending whats coming out of the the amp.... JP3 is the socket for my electret mic. Adjusting the 100k variable sets the voltage between 0 and 2.5. The comparator is the schmit trigger so its an adjustable schmit trigger ( isnt it ? ) . It works fine :)
(\_/)
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Beat Detection using an op-amp

Post by brad » Fri Apr 01, 2011 9:10 pm

While a schmidt trigger and comparator both work on open loop gain, the schmidt trigger uses positive feedback via a voltage divider to give you two separate trigger points. and you are correct as you say LTP and UTP are lower trigger point and upper trigger point respectively.

While they are both very similar, the disadvantage of a comparator over a schmidt trigger is that they only have one trigger point which means if our signal happens to be sitting spot on the trigger point - any noise present on the signal will cause it jump over the trigger point and then under and then over etc... etc...

Separating the two trigger points essentialy gets rid of this problem. Having said that, it shouldn't really matter for this particular project.

Now that I think about it (seeing that it is a single supply opamp) do you think it would be an advantage to have a positive clamper circuit just before the input of the first opamp?

User avatar
odessa
I practically live here!
I practically live here!
Posts: 102
Joined: Thu Sep 09, 2010 6:06 am
Location: London
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Beat Detection using an op-amp

Post by odessa » Fri Apr 01, 2011 10:03 pm

Hi Brad

:lol: I'm still very new to all this. I don't know what you mean by a positive clamper circuit. But if you tell me how to make it I'll be very happy to do so and test it :)

Jay
(\_/)
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 3 guests