Detecting the peak value

Jul 29, 2010 100 Replies

I gather that the OP wants a "transition" at the peak.

"It's beginning to sound a lot like..." homework :-) ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | Spice is like a sports car... Performance only as good as the person behind the wheel.

Maybe it's related to previous query? That's why I like to get an idea of where and why these things wanted. Difficult to offer specific help when an adjacent whatsit might be capable of doing half the job, or something.

Grant.

Disable the down input to the counter so it can only count "up". The A/D will follow the signal up, and then stay there; at the peak. If the counter only has a clock and direction, connect the counters "direction" to the count enable and the direction input to "up".

Possibly. That's why I broached the all-pass 90° shift as another method. ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | Spice is like a sports car... Performance only as good as the person behind the wheel.

--- Clever devil! :-)

I don't know why, but a tracking ADC didn't even come to mind until you mentioned it.

Old-timer's disease setting in maybe. :-(

Anyways, what I was thinking about was more like a counter chain gated by a dflop clocked by a zero-crossing detector to get the period of the AC signal, then taking that quantity, shifting it one bit toward the LSB and counting it down to zero, using the same clock that drove the up-counter to get a half-period which would correspond to the location of the peak when the counter got to zero.

Needs a little more thought to make sure both halves of the AC signal would be used to generate a continuous output in quadrature with the input, but I'm waiting for the OP to come back with his accuracy requirements before I put much more time into it.

Nice thing about this circuit (if it's done right) is that, like a tracking ADC, it'll track the input and make edges which will follow the variations in its period.

On the other hand, If he wants to use an ADC and he wants be able to place the edges with an accuracy of one degree at the peaks he'll need a 14 bit ADC, since if:

E (sin 90°) = 1V

then E (sin 89°) = 0.99985V

and

DV = 0.00015V,

which is 1.5 parts in 10000.

The best you can do with a 13 bit ADC is 1 part in 8192, so that won't work, but 14 bits is 1 part in 16384, so that will.

For 1° resolution he'll need to sample 360 times in one cycle which comes out to 36Ms/s, which is certainly doable:

formatting link

Hi,

The accuracy requirements are as follows

  1. The frequency of the sine wave is 100 kHz. +/- 3us
2 The amplitude is 2 volts peak to peak, it should be accurately measured at +/- 1.9 volts. Its not a home work. :)

Thanks

John

What's wrong with an RC?

Actually, and RC doesn't approach the required 90 degree lead or lag unless the time constant is huge, and then the signal is approaching zero. If your signal frequency is fairly steady, an R-L-C can do a lot better.

Try this:

in-------R------L---+------------comparator+ | | C | +------------comparator- | | gnd

Pick the R-C to give, say, 70 degrees of lag at 100 KHz. Pick the L to add phase lag until the comparator switches just at the signal peaks, compensating for comparator delay while you're at it. R can be partly trimpot for fine tuning. This will preserve a healthy fraction of the original signal amplitude.

I've also done this as

in-------C----------+------------comparator+ | | R | L | small | offset---comparator- | | gnd

as a fast constant-fraction discriminator, with an ecl comparator, instead of the usual delay-line thing.

John

Then what's wrong with my suggestion... you don't like capacitors and want to spend more money ?:-) ...Jim Thompson

-- | James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at

formatting link
| 1962 |

Spice is like a sports car... Performance only as good as the person behind the wheel.

You're not sampling fast enough.

john1987 is invited to do the math.

A differentiator finds peaks just fine as previously demonstrated, and a 90° all-pass is also trivial, without an inductor, also as previously demonstrated. ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | Spice is like a sports car... Performance only as good as the person behind the wheel.

That sounds like a job for a window comparator. All these peak detector gizmos are assuming you don't know the actual amplitude.

Cheers

Phil Hobbs

Dr Philip C D Hobbs Principal ElectroOptical Innovations 55 Orchard Rd Briarcliff Manor NY 10510 845-480-2058 hobbs at electrooptical dot net http://electrooptical.net

(1) Differentiator + Comparator: NO (2) All-pass + Comparator: NO (3) Tracking ADC/Counter: NO

How does a window detector find "peak"? It can find zero-crossings just ducky, but not "peak"... unless you "know actual amplitude" :-) ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | Spice is like a sports car... Performance only as good as the person behind the wheel.

(Could you please include context in your replies? This is USENET.)

Why are you dead set against the RC circuit?

Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html

Detecting peaks requires memory of past history of the wave, which means (in an analog circuit) than you need a capacitor or an inductor. So, sure you can get rid of the cap -- if you don't mind having an inductor in there.

People keep asking you questions like "is your frequency stable", trying to find ways to make you happy, and you keep responding with "I don't even want to put up with a capacitor in my circuit".

What are you really trying to do, and what are your real constraints? What's the matter with a cruddy capacitor?

Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html

If it's really a sine wave you could square it up and lock to it with a

4046 or other PLL.

Why the objection to the cap? Nothing that you can replace the RC network with is going to be smaller, but there are lots of options that are far bigger.

Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html

Trying to find actual end-use intent is one of the bigger problems everywhere. Vagueness drives me nuts.

Reminds me, in the early '60's, an Admiral comes to Moto and we get in a closed meeting, only those with secret clearance allowed.

This SOB rambles and rambles and rambles... for several hours.

I'm taking notes.

All of a sudden I say, "You're trying to do... TOP SECRET" :-)

After he got over his white faced shock. I showed a simple PLL solution. ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | Spice is like a sports car... Performance only as good as the person behind the wheel.

Very good solution! An analog phase detector would give you the 90° phase shift, thus the "transitions on peaks" the OP wants.

More capacitors than the differentiator, or all-pass, though :-)

...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | Spice is like a sports car... Performance only as good as the person behind the wheel.

Nope. Just do random time sampling using a simple microcontroller. As long as the S&H can handle 100kHz it's fine. Keep in mind that today's microcontrollers are 32 bit, run at >50MHz and have hardware multipliers and dividers.

Failure does not prove something is impossible, failure simply indicates you are not using the right tools... nico@nctdevpuntnl (punt=.) --------------------------------------------------------------

Clever indeed. Are you working for Elektor these days? :-)

Failure does not prove something is impossible, failure simply indicates you are not using the right tools... nico@nctdevpuntnl (punt=.) --------------------------------------------------------------

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required