# analog waveform comparison. I don't know where to start..

#### jr102893

Joined Jan 18, 2011
15
How would i make an analog circuit that can produce an output signal upon the intersection(where they are of = voltage) of 2 waveforms

#### SgtWookie

Joined Jul 17, 2007
22,230
You would use a comparator. If one signal is higher than the other, the output will be in one state (high or low), if that signal then goes lower than the other input, the output will go to the other state.

A Wiki entry on comparators: http://en.wikipedia.org/wiki/Comparator
Rob Paisley's page on comparator circuits: http://home.cogeco.ca/~rpaisley4/Comparators.html

It is frequent that people will use operational amplifiers aka opamps as comparators. While this does work, it's like using a hammer to install screws.

Comparators are not internally compensated, while opamps usually are. Comparators are usually much faster than opamps.

#### thatoneguy

Joined Feb 19, 2009
6,359
What will the frequency of the two signals be? Keep that in mind when choosing a comparator. 1/f is period, so you will want a comparator faster than the shortest period/highest frequency.

#### wayneh

Joined Sep 9, 2010
17,405
How would i make an analog circuit that can produce an output signal upon the intersection(where they are of = voltage) of 2 waveforms
Are you wanting the output to be proportional to the difference? The comparator approach is a thumbs up or thumbs down, 0 or 1, essentially digital output. If you need proportionality, you'll need op amps. A difference amplifier. You need to provide more detail for anyone to help you further.

#### jr102893

Joined Jan 18, 2011
15

The actual goal of my project is to allow strobing triggered by the circuit to light up a a speaker in a slowly oscillating pattern (lets say a sign wave that cycles every 2 seconds) theoretically if i triggered the strobe every time the two waveforms are at = voltage i should be able to produce this effect regardless of the audio being played. I have no doubt that the early attempts will fail but this the goal would look pretty neat...

#### wayneh

Joined Sep 9, 2010
17,405
Well, the two signals are equal when they're both off, so that might be a problem. And audio signals are at high enough frequencies that you'll probably be triggering several times per second, almost continuously.

You might want to look at a window comparator setup. A window comparator triggers when a voltage falls within a window. You can set the min and max for the window. And you could set different windows for the two audio streams.

#### jr102893

Joined Jan 18, 2011
15
for the first test the audio will all be at a permanent amplitude as to prevent the need to adjust the comparison wave levels(the comparison wave is at a constant frequency) so that it never falls outside of the maximum audio volume(later on i hope to compensate for volume though that might require use of digital programing as analog may be to slow and it may need to have a slight delay so the comparison wave can be adjusted before the sound is produced)
and as the comparison waveform will be very slow(again something like one cycle every 2 seconds) it will trigger on every peak of the audio (possibly multiple thousands of times per second(depending on the limits of the electronic components i may have to try a different method to get this effect))
{keeping in mind that the audio wave theoretically represents the position of the cone at that moment in time}
here is my mock up just to illustrate. the audio wave would be at a much higher frequency compared to the comparison wave than drawn

(not sure if the photo will work) heres a link too ( https://sites.google.com/site/picksightjr102893/pics/winterferance%20pattern.gif?attredirects=0 )

I am somewhat new to electrical engineering and have no formal training of any kind so my main question here is, Is this possible? and if so any additional ideas that could help me as i fiddle with this idea for the next few weeks would be helpful.

Last edited:

#### wayneh

Joined Sep 9, 2010
17,405
... my main question here is, Is this possible?
Maybe not. What will be producing the low Hz wave? To most audio, that looks like DC and won't be passed through most pieces of audio equipment.

But assuming you could, what's the point of triggering so many times a second? You won't be able to see it. You'd get much the same effect from a peak detector set to a low level, so that triggering is frequent. You need to trigger no more than ~10Hz or so, to be perceived as individual flashes.

I'm guessing you want to trigger the strobe but have it appear "random", not synchronized to the beat or the peaks? What would you really like to accomplish? What is the desired connection of the sound you're hearing and the effect you're seeing?

Oh wait, maybe I just got it. This would automatically vary the strobe effect, so that sometimes it's triggered almost continuously even at low volume and sometimes it only triggers at high volume. Is that what you're looking for? You might want to learn about the "control" pin on a 555 timer.

#### SgtWookie

Joined Jul 17, 2007
22,230

I didn't read your original problem statement closely enough. If you want the output to indicate just when the two signals are equal (within a small range) you need what is called a "window comparator" or "voltage window detector".

If you go to Rob Paisley's page, and search for "Voltage Window Detector Circuit", you will find one; it's about 1/2 the way down the page.

I'm not quite certain what you're expecting to see as a result of this kind of circuit - but your output will be brightest with higher frequency sounds, or things like cymbal crashes or drum hits.

#### jr102893

Joined Jan 18, 2011
15
It seams to me like no one is visualizing the goal of this circuit.
It is meant to produce a constant stroboscopic effect on the speaker cone making it appear to oscillate in and out slowly. I know this effect can be produced by playing a constant tone and flashing a strobe at a slight variance to the frequency being played on the speaker but the goal of my project is to produce the same effect regardless of the audio being played, which theoretically could be accomplished by the above idea.

#### thatoneguy

Joined Feb 19, 2009
6,359
If you wanted the speaker cone to look like it was moving slowly, say the orange line above, the strobe would be triggered on each intersection and would work.

The more difficult part then becomes recharging the strobe fast enough.

#### SgtWookie

Joined Jul 17, 2007
22,230
Here's an example circuit.
See the attached circuit and simulation. I simply used a pair of sine waves as input; one 0.5Hz and one 100Hz.

#### Attachments

• 132.7 KB Views: 22

#### SgtWookie

Joined Jul 17, 2007
22,230
Here's the same simulation, but the 100Hz In signal was reduced to 20Hz so you can see the output transitions more clearly.

#### Attachments

• 108.8 KB Views: 34

#### thatoneguy

Joined Feb 19, 2009
6,359
Here's the same simulation, but the 100Hz In signal was reduced to 20Hz so you can see the output transitions more clearly.

That could still work if it were driving an LED for the strobe, rather than a full Xenon strobe, just a bright 1W or so LED focused at the cone. It'd be a cool effect.

#### SgtWookie

Joined Jul 17, 2007
22,230
Yes, it would be a cool effect.

Of course, the LM393/LM2903 comparators are only rated to sink 6mA worst case, so you'd need to use a MOSFET to drive the LED; and the MOSFET itself would need a driver.

#### wayneh

Joined Sep 9, 2010
17,405
It seams to me like no one is visualizing the goal of this circuit.
It is meant to produce a constant stroboscopic effect on the speaker cone making it appear to oscillate in and out slowly.
Critical information, thanks for making it clear. Next time, put it in your first post to get higher quality responses, like the circuit proposed.

#### SgtWookie

Joined Jul 17, 2007
22,230
Just kind of thinking out loud here...

In the simulation, I deliberately showed the hi/low "window" going outside the voltage limits of the audio signal; as you can see, there will be no stroboscopic effect when this occurs.

In order to reduce/avoid the "dark times", it might be necessary to add a peak or envelope detector circuit, and multiply the threshold wave by the peak/envelope. Audio that has been processed using compression techniques will likely exhibit fewer "dark times" than unprocessed audio.