# Peak value

• posted

Hi, I think my question got buried in the discussion so I am putting my question out there again. Please be patient.

I am attaching two new drawings to show what I want. I do not know about accuracy but i would as say as much as accurate as possible.

I want to sample the peak value of the sine wave by using ADC (sampling rate 200ksps). I want to sample the peak value of the sine wave at the rising edge or the falling edge of the square wave that you can see in the diagram. The edges will trigger the ADC and ADC will sample that edge. The ADC can not sample the negative values as shown in the diagram. I did not mention the circuitry that can add offset to the input signal and make it all positive.

The questions are

1. Is there any way other than RC circuit to get the peak sample of the sine wave at the rising and falling edge?
2. Whats the difference between in this case between using the High pass and low pass filter?
3. How a PLL can help in this case?
5. I tested the suggested high pass filter using the 220pF and
7.6kOhm resistor and found that the edge is occuring at the right spot in pspice than the low pass filter.

Thanks John

• posted

I think that at last I understand what you are trying to do but you need to answer some more questions before I could offer any solution.

How much does the frequency of the '200kHz' sine wave vary How much does the amplitude vary and how fast How pure is the 200kHz sine wave - ie how much 400kHz, 600kHz etc Do you need to catch every single positve and negative peak or would every

16th (or 8th or 32nd) one be OK

Michael Kellett

• posted

What is eluding you?

The suggested "hi-pass" is actually a differentiator and 7.6K should be 75 to 82 Ohms, NOT K! ...Jim Thompson

```--
| James E.Thompson, CTO                            |    mens     |
• posted

to

y

Hi,

The frequency of the sine wave will stay 100KHz (10usec). I do not know exactly how much will it be varying but I guess we can design for the error of +/- 0.001usec from its original value. I do not know how much the amplitude be varying, I would say +/- 0.0001 volts. How fast , I do not know. You can assume some realistic value. If you advice how to design the system around these values than later I will take the error values into account when I get the true values later.

It is pure 100KHz sine wave. I do need to catch every single positive and negative peak.

Thanks

john

• posted

=A0 =A0 ...Jim Thompson

=A0 =A0| =A0 =A0mens =A0 =A0 |

=A0 | =A0 =A0 et =A0 =A0 =A0|

=A0|

=A0 =A0 =A0 |

=A0=A0=A0=A0=A0=A0=A0(480)460-2350=A0=A0=A0=A0=A0=A0end_of_the_skype_highli= ghting=A0Fax: Available upon request | =A0Brass Rat =A0|

quoted text -

Hi,

I tried the circuit with your values in pspice and found that the circuit is not detecting the peak positive and neagtive sine values at the rising and falling edge of the square wave. So, I played with the R and C values and found the 220pF and 7.6kohm got the edges right where I wanted. But I sitll do not know that its a good solution. Any advice on choosing the ADC too.

Thanks John

• posted

Tons of them, but most are more complicated. Why don't you want to use an RC circuit? If it's complication, you're barking up the wrong tree.

A low-pass filter will have a much less noisy output, but will really only find the peak for a repetitive sine wave over a narrow frequency range. A high-pass filter will, in theory, find the peak perfectly every time. In reality it'll be very noise sensitive and may well find lots and lots of "peaks" that you're not interested.

_If_ you're trying to sample the peaks of a repetitive wave at steady frequency, and _if_ it is symmetrical about the peaks, then a PLL will average out tons of noise. It satisfies the exceedingly vague "no RC circuit" requirement, but since you've never (that I've seen) elaborated on _why_ you don't want an RC circuit I have no idea if it'd be better or worse.

You have given absolutely positively not enough information. I'd suggest starting another thread for that.

Add in a noise source, and see how you like it.

```--
Tim Wescott
Wescott Design Services```
• posted

If, as I think, you are generating the sine wave, why do you need to derive its peak time from the signal itself?

And if, as I think, you are intending to make an RLC meter, why do you want to measure the peak?

John

• posted

Hi,

I want to measure the peak because I want to control the peak to peak sine wave amplitde using PWM. So, if the peak changes the micro will use the PWM to control the voltage and keep it stable at the peak that I mention in the diagram.

John

• posted

d text -

hi,

what info you need to advice regarding choosing the ADC. I have following info.,

1. peak to peak voltage 2volts.
2. frequency 100khz
3 monotonic sine wave.

Thanks John

• posted

Now it gets easy - if you are generating the sine wave from some PWM thing then you can arrange to sample synchronously at at least three times the sine wave frequency. Since it is a sine wave the average, RMS and peak are all related so if you know one then you know all the others. To get the RMS just square, sum and take the square root of the three or more samples. If you just want to control the peak amplitude you can control the sum of the squares of the samples. So long as your samples are equally spaced (in time), the same number per sine wave cycle and at least three samples per cycle it doesn't matter where in the sine wave you sample.

Michael Kellett

• posted

text -

```--
Tim Wescott
Wescott Design Services```
• posted

You've either...

(1) Messed up and didn't connect per my drawing.

(2) Don't realize that U1 is a comparator.

Post or send your PSpice files. ...Jim Thompson

```--
| James E.Thompson, CTO                            |    mens     |
• posted

Crikey! See why we insist on definition of end function.

Comparator with +1V reference. Use comparator output to pump-up/pump-down PWM control... whatever that might be ;-) ...Jim Thompson

```--
| James E.Thompson, CTO                            |    mens     |
• posted

If that's all you're doing, why not just use a precision rectifier? Search for it -- some semi company will have an app note about how to use one of their op-amps to make it all work.

```--
Tim Wescott
Wescott Design Services```
• posted

Or, if you're doing this in a micro, just measure the sine wave at four arbitrary points in the waveform and calculate the mean squared value -- that'll be a constant no matter what the phase relationship is, as long as it stays a nice clean sine.

```--
Tim Wescott
Wescott Design Services```
• posted

d text -

Hi, What I understood is as follows

I do not need RC circuit to find the peak of the sine wave because I am generating the sine wave using a PWM generating microcontroller. So,micro will generate the sine wave and also calculate the mean squared value but the confusion is that it will read back the sien wave using ADC and I still do need to tell ADC when to sample and what to sample. So, I guess I do need the peak value of the sine wave and then again I do need the RC circuit.

John

• posted

text -

Find the sum

(sin(theta))^2 + (sin(theta + pi/2))^2 + (sin(theta + pi))^2 + sin(theta

- pi/2)^2.

Then tell me how that depends on theta.

_Then_ tell me that you need a phase reference to measure the amplitude of a sine wave, with a straight face.

```--
Tim Wescott
Wescott Design Services```
• posted

Assume the comparator is HIGH when the input is below reference.

Just to elaborate on this, a +/- 2V signal will excite such a comparator to a duty cycle of 2/3, so you'd run the comparator's averaged output voltage into the ADC and if it's over (2/3 * Vout) the PWM is set too low.

Another way is (assuming the CPU speed supports it) to make a timed determination at the phase =3D 30 degree time, if the comparator is high the amplitude is too low... that approach will constantly dither the setpoint, of course, and inject jitter in the process.

• posted

e
s

ou

t
r

--

g

ted text -

d text -

Hi, What I understood is as follows

I do not need RC circuit to find the peak of the sine wave because I am generating the sine wave using a PWM generating microcontroller. So,micro will generate the sine wave and also calculate the mean squared value but the confusion is that it will read back the sien wave using ADC and I still do need to tell ADC when to sample and what to sample. So, I guess I do need the peak value of the sine wave and then again I do need the RC circuit.

If you confirm that I am on the right track that it will be easier for me to proceed.

Thanks John

• posted

text -

text -

If you compute the mean squared value then you don't have to be lined up with the peak of the sine wave. I've told you this already, you don't seem to want to believe it. When you reiterated your obsession with lining your measurements to the peak of the sine wave, I gave you an exercise that -- had you done it -- would have shown you that you don't need to line your measurements up to the peak of the sine wave.

No one. No one at all. Ever, anywhere, can help you if you don't listen.

```--
Tim Wescott
Wescott Design Services```

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.