Digital Frequency Comparator

Hi guys, this is my first post so please bear with me. I have come across a problem which is stumping me so far. I have been provided two clocking inputs ranging from 0 to 6.5kHz. I do not know what frequency these operate at, and they are constantly changing. They also run at different frequencies. I have to design a circuit to compare the two inputs, and trigger off the fastest signal only. I am told it is easily done with J-K flip flops but I have been looking at flip flops and multivibrators for hours now and have not gotten any farther. Does anyone have any ideas?

Reply to
mjmcfall
Loading thread data ...

Homework ?:-)

...Jim Thompson

--
|  James E.Thompson, P.E.                           |    mens     |
|  Analog Innovations, Inc.                         |     et      |
|  Analog/Mixed-Signal ASIC\'s and Discrete Systems  |    manus    |
|  Phoenix, Arizona            Voice:(480)460-2350  |             |
|  E-mail Address at Website     Fax:(480)460-2142  |  Brass Rat  |
|       http://www.analog-innovations.com           |    1962     |
             
I love to cook with wine.      Sometimes I even put it in the food.
Reply to
Jim Thompson

Doesn't matter, although people get Brownie points for admitting it up front. But this guy claims it's his first post, so he doesn't know the rules.

If you think it's homework, give hints on how to approach the problem, not copiable solutions.

It's digital, so I am excused. (;-)

--
OOO - Own Opinions Only. Try www.jmwa.demon.co.uk and www.isce.org.uk
2006 is YMMVI- Your mileage may vary immensely.

John Woodgate, J M Woodgate and Associates, Rayleigh, Essex UK
Reply to
John Woodgate

Me too, though I seem to do a lot of non-uC stuff ;-)

I'm not sure how to do it with J-K, but the OP could use my phase-frequency detector to route the signal (see website).

But I doubt there's any such thing as an instant switch-over... it'll take a few cycles to discern the upper frequency.

...Jim Thompson

--
|  James E.Thompson, P.E.                           |    mens     |
|  Analog Innovations, Inc.                         |     et      |
|  Analog/Mixed-Signal ASIC\'s and Discrete Systems  |    manus    |
|  Phoenix, Arizona            Voice:(480)460-2350  |             |
|  E-mail Address at Website     Fax:(480)460-2142  |  Brass Rat  |
|       http://www.analog-innovations.com           |    1962     |
             
I love to cook with wine.      Sometimes I even put it in the food.
Reply to
Jim Thompson

If the signals are really clean a three-state phase detector (which is, I assume, what you're talking about) will detect the change in frequency as soon as the phase rotates through one full cycle.

You _could_ do it with J-K flip-flops if you clocked them externally, way faster than your incoming signals, I suppose.

You could also do it with one 7476, if you ignored the J, K and clock inputs and just used the set and reset pins -- but that would be cheating :).

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Posting from Google?  See http://cfaj.freeshell.org/google/

"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

If you look at the insides of a 4046 phase detector, you will get a clue.

Tam

Reply to
Tam/WB2TT

Or...

formatting link

...Jim Thompson

--
|  James E.Thompson, P.E.                           |    mens     |
|  Analog Innovations, Inc.                         |     et      |
|  Analog/Mixed-Signal ASIC\'s and Discrete Systems  |    manus    |
|  Phoenix, Arizona            Voice:(480)460-2350  |             |
|  E-mail Address at Website     Fax:(480)460-2142  |  Brass Rat  |
|       http://www.analog-innovations.com           |    1962     |
             
I love to cook with wine.      Sometimes I even put it in the food.
Reply to
Jim Thompson

And a major headache if f1 = f2. But that's life.

Have fun

Stanislaw Slack user from Ulladulla.

Reply to
Stanislaw Flatto

First off I can assure you that this is not a homework assignment, if this had come up while I was in school I probably would have been able to figure it out. But that was a while ago and it is not exactly like riding a bike...

My problem lies in the fact that I have two distinct frequencies from two different sources. Phase becomes a non-issue with different frequencies. They could range anywhere from 0 - 6.5kHz. I need to be able to determine the faster of the two without a processor, and effectively block the slower frequency while allowing the faster to carry through to the main processor. If frequency A is the fastest for

30 seconds, then B for 8ms, then back to A I need to be able to switch back and forth. Missing a few cycles is not an option as every pulse from the fastest wheel needs to be recorded.

Jim Thomps> >

Reply to
golfnut

Just an idea. Feed the two trains of pulses to two equal one shots producing logic level outputs shorter than your fastest signal. Rectify the outputs on small capacitors with decay resistor and feed them to analog amplifier. Depending what the diff in voltages is the output can control gates to pass the relevant train. The "not an option" not tested!!! The other possibility, which you excluded, if to build a logic "processor" to compare frequencies against some internal clock and control those gates from the result.

Have fun

Stanislaw Slack user from Ulladulla.

Reply to
Stanislaw Flatto

One of the phase detectors in the 4046 is frequency sensitive. I have run it open loop with two different frequencies going in.

Tam

Reply to
Tam/WB2TT

Hello Tim,

Or do it the brute force way. Run two fast counters and have each clock the time elapsing between consecutive rising edges, then latch these two values. Run the output of the two latches into a magnitude comparator and have that throw a (digital) mux onto the clock that had the lowest count. The system must be able to handle runts or it would need some nifty "transition extender".

--
Regards, Joerg

http://www.analogconsultants.com
Reply to
Joerg

Hello John,

Nah, us analog guys have to come up with an analog answer here. Like running each clock into an integrate&hold that is sampled at hold and then reset. Follow that with an LM339 and a gate or mux that selects the right clock. Then hollow out a big old digital chip from underneath, one where nobody recognizes the part number anymore, glue it all in there, connect to some pins, solder onto a board and declare it "digilog" :-)))

--
Regards, Joerg

http://www.analogconsultants.com
Reply to
Joerg

[snip]

I think you're deluding yourself if you think it can be done without being off by ±1 count.

However this might come close...

PRECISION F-to-V converter for each input

OpAmp structure selects highest voltage (trivial)

Pipe this highest voltage to a PRECISION V-to-F

...Jim Thompson

--
|  James E.Thompson, P.E.                           |    mens     |
|  Analog Innovations, Inc.                         |     et      |
|  Analog/Mixed-Signal ASIC\'s and Discrete Systems  |    manus    |
|  Phoenix, Arizona            Voice:(480)460-2350  |             |
|  E-mail Address at Website     Fax:(480)460-2142  |  Brass Rat  |
|       http://www.analog-innovations.com           |    1962     |
             
I love to cook with wine.      Sometimes I even put it in the food.
Reply to
Jim Thompson

I think it could be done with digital logic running at a few MHz clock rate, though at the cost of aligning the output to a clock period and then delaying it by a a period or two. One would measure each frequency and then determine if any given input pulse is faster than the frequency of the other chanel, gating it through (delayed a resampling clock period or two) if it is. How each frequency determining engine should be filtered against jitter is an interesting question. And of course the output will have outrageous jitter everytime it switches the selected chanel, since the phases don't match.

Maybe it's time to ask about the application?

Reply to
cs_posting

Thanks for all the input today. I believe the quick and easy solution to my problem would be to run the two signals through a pair of F to V converters. The resulting voltages could then be run through a voltage comparator, the output of which could drive a transistor to allow the faster original signal through to the microprocessor. If the signals switched and #2 was faster than #1, the other transistor take over and signal #2 would become the new clocking input to our pic.

Thanks again to Jim Thompson for the winning entry!

Regards golfnut

cs snipped-for-privacy@hotmail.com wrote:

Reply to
golfnut

Aren't those going to lag the frequency by a bit? How is this going to work if you can't miss even one pulse?

--
Ben Jackson AD7GD

http://www.ben.com/
Reply to
Ben Jackson

In message , dated Thu, 10 Aug 2006, golfnut writes

Frequency to voltage converter on each signal, and 2-input comparator fed from the converter outputs. Three chips. Maybe 3/4 of one if you used two sections of a quad comparator to make your own F-V converters.

I think that's possible, but I haven't worked out exactly how; you basically need to make a monostable triggered by the incoming signal. Pulse-counter technique; RC integrating the output of the mono gives you a voltage proportional to repetition rate.

--
OOO - Own Opinions Only. Try www.jmwa.demon.co.uk and www.isce.org.uk
2006 is YMMVI- Your mileage may vary immensely.

John Woodgate, J M Woodgate and Associates, Rayleigh, Essex UK
Reply to
John Woodgate

Keep in mind a wide-range F-to-V converter will either have an adequate integrating output-filter and be very slow, which has been stated to be unacceptable, or it will have a high ripple voltage, especially at low frequencies, defeating your ability to accurately determine the relative frequencies.

If a quasi-analog approach is desired, I suggest a pair of cycle- by-cycle period-measuring integrators, each with a sample-hold to grab the value just before each cycle's reset, and a comparator. This could be made to work over a say 500:1 frequency range, and could make a new accurate decision for each one of two cycles.

--
 Thanks,
    - Win
Reply to
Winfield Hill
[.... faster signal ...]

I think a circuit very like that is exactly what is needed. He needs some sort of that counts up for signal A and down for signal B.

You want to detect that you got two edges on A before the next one on B.

It could take many cycles. If the frequencies differ only a little, the circuit has to wait till the phase slides around till there are two edges of one in one cycle of the other.

--
--
kensmith@rahul.net   forging knowledge
Reply to
Ken Smith

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.