Beat Detection using an op-amp
Moderators: Chuckt, Garth, bitfogav
Beat Detection using an op-amp
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: 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:
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: 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:
- brad
- 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
Very helpful post with a great explanation of the circuit operation.
Thanks for sharing
Thanks for sharing

Re: Beat Detection using an op-amp
Ive found using something more like this gives the circuit more detection to bass beats or low frequencies, using a low pass filter.
- brad
- 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
You could even make that a variable cap to 'fine tune' your frequency response.
Re: Beat Detection using an op-amp
Do they do a Variable cap with a high capacitance?.
- brad
- 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
Yep, you can get all sorts of values.
Perhaps you could even use a varicap diode / varactor diode?
Perhaps you could even use a varicap diode / varactor diode?
- odessa
- 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
Hi Guys n Gals
This is the design I'm using for a similar project
I decided to make the comparator adjustable ... Any comments or suggestions welcomed

This is the design I'm using for a similar project
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.
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.
Re: Beat Detection using an op-amp
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
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
- brad
- 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
What would happen if you made the schmidt trigger variable?
- odessa
- 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
Thats what I've done isn't it ? Or have I done something wrong 

(\_/)
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.
- brad
- 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
You have a variable comparator but a fixed UTP and LTP for the schmidt trigger 

Re: Beat Detection using an op-amp
Im guessing you mean Brad ,brad wrote:You have a variable comparator but a fixed UTP and LTP for the schmidt trigger
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?
- odessa
- 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
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.
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.
- brad
- 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
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?
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?
- odessa
- 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
Hi Brad
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


Jay
(\_/)
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.
Who is online
Users browsing this forum: No registered users and 3 guests