# Comparing two signals

Thread Starter

#### Bdelcoig

Joined Apr 18, 2018
3
Hi,

I have a project where I have two oscillators. One reference oscillator and one detection oscillator. I'm looking for a way to output a 5V constant output when the two frequencies are in the same range.

Any help would be appreciated

#### ericgibbs

Joined Jan 29, 2010
11,643
hi Bd,
Welcome AAC.
What range of frequencies are you covering and what are their amplitudes.?
E

Thread Starter

#### Bdelcoig

Joined Apr 18, 2018
3
Hi Eric,
Thanks for the quick reaction.
The frequency is 400khZ (sine) on the reference oscillator , we have an amplitude of 5V

#### ericgibbs

Joined Jan 29, 2010
11,643
hi B,
Sorry, more questions.
Have the two sine waves got to be in same phase.? ie: no phase shift.

More information will help members to suggest circuit idea's,

E

Thread Starter

#### Bdelcoig

Joined Apr 18, 2018
3
Hi.
Here you have the circuit diagram. The inductance on the detection circuit reacts to magnetic field changes and this changes the frequency. So they don't have the exact same frequency.

We basically want to output a 5V continuous signal when the two oscillators have approx the same frequency.

#### Attachments

• 61.8 KB Views: 21

#### Alec_t

Joined Sep 17, 2013
11,813
A phase-lock-loop IC might fit the bill, or even a simple XOR circuit or a beat-frequency detector.

#### danadak

Joined Mar 10, 2018
4,057
What are you doing with the signal that shows the two frequencies are
equal ? Are the amplitudes of the frequencies relatively fixed ?

A CD4046 PLL chip, adapting the phase detector in it, might work.

Two BP filters with comparators on output.

Embedded CPU measuring freq with counters and comparing measured
values to be within a windowed range. This approach could allow you to
average over many cycles the measurement to aid in eliminating jitter/noise
of the freqs being examined. See attached.

Regards, Dana.

#### Attachments

• 240.7 KB Views: 8
Last edited:

#### MisterBill2

Joined Jan 23, 2018
7,749
A phase-lock-loop IC might fit the bill, or even a simple XOR circuit or a beat-frequency detector.
INDEED! A 4046 PLL IC, using the complex phase detector would then produce smaller and smaller correction pulses as the frequencies became closer. Then, feeding that correction signal through a low pass filter and into a window comparator will give a logic high when the signal is stable. Likewise, an exclusive OR gate fed into a low pass filter would provide a similar signal.
Any frequency mixer for the two frequencies will tend towards a zero frequency output as the two approach. But you will also need to block the sum frequency, which will also appear.That is what will make creating the low pass filter a bit more tedious.

#### Bordodynov

Joined May 20, 2015
2,745
See

#### danadak

Joined Mar 10, 2018
4,057
Interesting problem. If you use digital F cntr approach, you have the
latency from gate period.

But then in PLL case you have latency due to LPF.

In either case you can tradeoff -

1) Latency for ripple in PLL case
2) Latency for resolution in F cntr case

Might be possible to use reciprocal counter approach and get an answer in
1 400 KHz period, 2.5 uS......just a thought.

Regards, Dana.

Last edited:

#### crutschow

Joined Mar 14, 2008
26,057
What is the Red trace?
It looks like it should be V(out) but the plot says the blue trace is V(out).

#### crutschow

Joined Mar 14, 2008
26,057
Do you want an indication of which frequency is higher?

#### MrChips

Joined Oct 2, 2009
22,555
Many possibilities:

XOR gate
D-type flip-flop
NE567 or LM567 Tone decoder
CD4046 PLL

#### AnalogKid

Joined Aug 1, 2013
8,824
Looks like a basic traffic light detector, or some other large metal mass system. If so, consider a tracking detector stage.

ak

#### crutschow

Joined Mar 14, 2008
26,057

#### -live wire-

Joined Dec 22, 2017
912
Idea: heavy filter for each signal --> op amp for each filtered output --> in series but reverse so voltages are subtracted --> comparator where if greater than a certain value output is low.

Just a suggestion. This requires that the average voltage of the signals is the same. Adjust the op amps if they are not. Maybe add also a buffer to eliminate unwanted oscillation. An inveting schmitt trigger is what you want as your comparator on the output.

Essentially it detects a significant difference in frequencies by converting the frequencies to voltages proportional to the freq. This may not be the best design, but it should work.

#### AnalogKid

Joined Aug 1, 2013
8,824
The reference oscillator is micro
I have a project where I have two oscillators. One reference oscillator and one detection oscillator. I'm looking for a way to output a 5V constant output when the two frequencies are in the same range.
Pass both signals through identical networks tuned to resonate at the osc freq. When the detection osc is pulled off freq, its output will drop relative to the reference osc. In fact, you can eliminate the reference ose and just slope detect (frequency-to-voltage converter) the detection osc.

ak

#### crutschow

Joined Mar 14, 2008
26,057
Perhaps this could be could be done effectively with a microprocessor.
You count each frequency for a short period and then subtract the two counts.
That will give you the frequency difference, and when it's "approximately the same frequency", a 5V digital output signal is generated.

Last edited:

#### Bordodynov

Joined May 20, 2015
2,745
I am sorry

#### Bordodynov

Joined May 20, 2015
2,745
What is the Red trace?
It looks like it should be V(out) but the plot says the blue trace is V(out).
A red trace is when the frequencies coincide (=). Truth is the best case, when the phase shift between the reference signal and the signal being studied is zero. The real signal must be multiplied by Cos(fi). I did such a detector in the form of a chip (for fixed audio frequencies). The bandwidth of that asynchronous filter (my chip) was less than 0.1Hz.
Using my model library you can model my file.

#### Attachments

• 2.9 KB Views: 1
Similar threads