# How can I subtract one frequency from another ???

Discussion in 'Electronic Basics' started by Frank, Jan 8, 2006.

1. ### FrankGuest

Hi all,
A pretty basic question, but I seem to be having a brain block about what
approach to take for this application.

I would like to take 2 different frequencies, between lets say DC to 1000Hz,
and subtract them from one another to get the output signal frequency as the
difference between the 2 signals.

For example, 400Hz in one input, 410Hz in the 2nd input, the output will be
10Hz.

My first instinct was to use an op amp as a comparator, then I thought of a
differential amplifier, then, I stumbled across some mixer schematics, and
PLL schematics, and then some really complex filter IC's, by that time I was
well confused.

I just want this to be as simple as possible, one IC if at all possible and
some periferal passives.

Could one use an LM324 configured as a differential amp? What confuses me is
the CMMR part of it, and the fact that the differential amp seems to only
"differentiate" voltage differences, and not "frequency" differences,
however the common mode rejection will reject like frequencies from both
inputs.
I'm pretty rusty on my op amps, so I was hoping someone might be able to at
least point me in the right direction with this.

Thanks!

2. ### Andrew HolmeGuest

You were on the right lines with mixers. Apply the two input signals to a
balanced mixer, and you get output components at the sum and difference
frequencies. A mixer is a multiplier, and can be understood by thinking

2 . cos At . cos Bt = cos (A+B)t + cos (A-B)t

Given your example of 400 and 410 Hz inputs, the sum and difference outputs
would be 810 Hz and 10 Hz, and you would need a low pass filter to remove
the unwanted sum product.

3. ### FrankGuest

Thanks!

That's a great help, I really appreciate it.
So, the next question is (now that I know what "kind" of device to use) what
is the best mixer for this application.

Is this a one IC solution, or do I have to design a circuit to my
specification?
Can I use the internal mixer of a max038, an XR2206, or even a 565 PLL?

What do you suggest for a simple low cost readily avalible mixer?
Can they be designed with op amps?

Thanks!

4. ### Andrew HolmeGuest

Looking at the MAX038 datasheet, I don't see a mixer in there. The XR2206
has an amplitude modulation facility, so you could probably use that. The
NE565 contains a Gilbert Cell switching mixer, and pin 5 must be driven with
a square wave. You didn't say if your signals were sine or square. Two
square waves can simply be mixed using an XOR gate. For sine waves, you can
use a four-quadrant multiplier. I see someone in s.e.d mentioned the AD633.
I can second that recommendation. BTW you shouldn't use cross-posting.
It's better to multi-post, then everybody gets to see everybody else's
responses.

5. ### FrankGuest

Hi,
What is cross posting? I'm kinda new to newsgroups, I"m assuming you mean
posting in another group as well as this one?
Sorry ;(

A bit more info on the application, the input will be either sound such as
music, (well within the human hearing range) or pure tones (sine waves).
I will be squaring up the output with an LM339 comparitor to drive a logic
level input IGBT.
If the 565 needs a square in, I could figure something out, but would rather
have the input to the comparitor reasonably "preserved".

Thanks again, and sorry if I've ruffled any feathers.

6. ### FrankGuest

Hi,
What is cross posting? I'm kinda new to newsgroups, I"m assuming you mean
posting in another group as well as this one?
Sorry ;(

A bit more info on the application, the input will be either sound such as
music, (well within the human hearing range) or pure tones (sine waves).
I will be squaring up the output with an LM339 comparitor to drive a logic
level input IGBT.
If the 565 needs a square in, I could figure something out, but would rather
have the input to the comparitor reasonably "preserved".

Thanks again, and sorry if I've ruffled any feathers.

7. ### Sjouke BurryGuest

Maybe just an XOR gate? Follow it by a low pass filter.

8. ### JamieGuest

LM1496 chip maybe?

9. ### Bob MastaGuest

doom! In general, if you multiply (a better term than "mix" at audio
frequencies, where "mix" almost always means "linear sum") one sine
wave by another you will get only sum and difference frequencies in
the output. If you are interested in only the difference frequency,
you would need to filter out the sum frequency. This is a non-trivial
problem for the frequency ranges you mention.

But on top of that, you mention that one input will be a sound
such as music. But music is (typically!) composed of many
different frequencies sounding at the same time (multiple
instruments, chords, harmonics, etc). So there is no hope of
getting a single difference frequency (difference with what?).

Perhaps with more details we can suggest a workable
solution, or at least save you a disheartening failure!

Best regards,

Bob Masta

D A Q A R T A
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Home of DaqGen, the FREEWARE signal generator

10. ### jgreimerGuest

If you're going to be using pure tones and can amplify them enough so
they're clipped to resemble square waves, by far your best and simplest
solution is to use a D flip flop as the mixer. Don't use TTL logic for this
and shunt excess signal voltage to ground and the positive supply with
diodes. The advantage of a D flip flop is that it produces only the
difference frequency so there's no need to filter the output. Input one
signal on the D input and the other on the C input. You can take the output
at either Q or Q bar. If you send music to it however, you're going to get
a strange output waveform.

- jgreimer

11. ### JeffMGuest

BTW you shouldn't use cross-posting.
Andrew said the right thing but he reversed the terms.
..
..
Here's another No-No for you: **Top-posting.**
Notice how I have a SMALL amount of the previous post included?
Notice how it is ABOVE the subsequent parts of the discussion?

Do likewise: trim as appropriate and BOTTOM-post.

12. ### TechnicianGuest

Hi all,
have been so many suggestions with so many approaches, it has left me more
confused than ever, especially since a couple of them did not work.

What I'm going to settle on it using an AD633 mixer IC, as it seems very
simple to use as far as peripheral components are concerned anyway.
Being inexperienced with this type of electronics (audio) I've never
configured a mixer before, so forgive me if my questions sound borderline
rediculouse for one who supposedly knows something about electronics.

That said, I would like to know how to input a 600Hz sine wave to one input,
and a 610Hz sine wave to another input, to get an output of 10Hz on one of
the pins, this being the difference of the 2 input frequencies.
I would like the output frequency to always be the difference of whatever 2
input frequencies are inputed, inputs will never exceed 1KHz.

It was previously mentioned that this mixer IC would give me the sum and the
difference of the 2 input frequencies. What I am not clear on is if the
difference and sum frequencies will appear on 2 different output pins, or in
the same output wave on one pin which needs to be filtered with a low pass
filter such as a butterworth filter.

I have a couple AD633, and the data sheet, but I just cannot seem to grasp
it's mathematics in order to get a firm idea of how to configure this.
Any help would be appreciated.

Thanks!

13. ### Bob MastaGuest

The AD633 is a multiplier, which can form the product of
two input signals. The product of two sinusoids is another
pair of sinusoids at frequencies that are the sum and
difference of the originals. If your inputs are 600 and 610 Hz,
the product will contain components at 1210 and 10 Hz.
If you only want the 10 Hz component, you will need to
apply a filter to the output.

But note that if the inputs are complex signals, like
speech or music, the output will contain components
at all the individual sum and difference frequencies.
This can lead to a hopeless mess that filtering will
not resolve.

What are you really trying to accomplish here?
If you will explain your overall goals, perhaps we can
come up with a workable approach.

Best regards,

Bob Masta

D A Q A R T A
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Home of DaqGen, the FREEWARE signal generator

15. ### TechnicianGuest

Thanks,
Which inputs do I use on the AD633, X1 and X2, or Y1 and Y2? (I will be
inputting a left and right channel to be subtracted from one another)
Also, can you recommend a schematic using an LM324 for the low pass filter?
I tried a couple right out of a textbook but they did not seem to roll off
anything over the 50Hz I configured it for. (Meaning I want only frequencies
of below 50Hz to appear at the output)
Thanks again!

16. ### John Jardine.Guest

Can't see most of this thread but suggest this 50Hz filter.
Has a fast roll off, with a nice notch at the 600Hz point, (where there be
lurking nasties)
The drawing needs viewing in a fixed space font, such as Courier
100n
||
.-----||-----o----------.
| || | |
| | |\| |
| '----|-\ |
___ ___ | ___ | >--o-o OUT
o -|___|---o---|___|---o---|___|----o----|+/
IN 100k | 100k 100k | |/| LM324
| || |
o-----------||-----------o
| || |
| 68p |
--- ---
--- 47n --- 10n
| |
GND GND

(created by AACircuit v1.28 beta 10/06/04 www.tech-chat.de)

17. ### XtrchessrealGuest

Cool Ascii tool

I just downloaded this. I hope it works in english but if not it is
still a great tool for people who need help on-line.

Thanks for the link to it!

X

18. ### Bob MonsenGuest

Please, post replies inline, after the text you are replying to. Thanks.

The AD633 has differential inputs, so it gives you the
instantaneous value of (X1-X2)*(Y1-Y2)/10. Look at figure 3. If you want
to add a DC offset to the mix, put a voltage on Z. Otherwise, ground it.

Note that this is a differential thingy, so you need both +Vcc and -Vee
power supplies. You can, however, couple it so that you won't need to do
this. You can do this as follows (8-lead DIP package):

Vcc---------o----o--------o--------.
| | | |
1k 1k .----------. |
1uF | | | 8 | | |\
|| | | | | | | \
inA o---||-o----)---|1 A 7|--)--[10k]----o----|+ \
|| | | | D | | | | ---o--- out
| | | 6 | 100k 160nF--- .-|- / |
|| | | | 3 | | --- | | / |
inB o---||-)----o---|3 3 2,4|--o----. | | |/ |
|| | | | &6 | | | | | |
1uF | | | 5 | | | | o--90k---'
1k 1k '----------' 100k --- 1uF | |
| | | | --- | 10k
| | | | | | |
| | | | | | --- 1uF
| | | | | | ---
| | | | | | |
GND --------o----o--------o--------o-----------o--'
GND

The first cap blocks DC, and the 1k resistors keep the input biased at
1/2 Vcc. The input cap and resistors form a lowpass filter with a
center frequency (fc) of about 80Hz. Sadly, this scheme couples the power
supply into the output, defeating the carefully constructed power supply
ripple rejection in the chip. Sigh. Putting a 1uF and 10nF cap between the
supplies near the resistors may help.

The multiplier output is put into a simple lowpass filter, which has an fc
of 100Hz. This should filter the unwanted 1210Hz result, leaving the
desired 10Hz output. It also has some gain to compensate for the 10x
attenuation of the multiplier. Experiment with the value for the
appropriate gain. If you find you are getting too much crap on the output,
you can use a better filter (google for sallen-key). You can also adjust
the values of the 160nF cap. An LM324 would be an ok choice for this. Use
1% resistors, or match them by hand using a sensitive DMM.

(I haven't built or tested this circuit, so YMMV...

--
Regards,
Bob Monsen

"To suppose that the eye, with all its inimitable contrivances for
amounts of light, and for the correction of spherical and chromatic
aberration, could have been formed by natural selection, seems, I
freely confess, absurd in the highest possible degree. Yet reason
tells me, that if numerous gradations from a perfect and complex eye
to one very imperfect and simple, each grade being useful to its
possessor, can be shown to exist; if further, the eye does vary ever
so slightly, and the variations be inherited, which is certainly the
case; and if variation or modification in the organ be ever useful to
an animal under changing conditions of life, then the difficulty of
believing that a perfect and complex eye could be formed by natural
selection, though insuperable by our imagination, can hardly be
considered real"
-- Charles Darwin

19. ### Don BoweyGuest

You are going to use X(n) for one input and Y(n) for the other. Use X1 & X2
if you want X to have a balanced input, and use Y1 & Y2 if you want Y to
have a balance input. Read the notes and you will see that if you do not
want balanced inputs, you can drive X1 with X2 grounded. Same with the Y
input.

I don't have my handbook formulas handy, but OP Amp filters have always
worked well for me when I've used precision values, I'll see what I can
find.

Don

(snip)