From: whit3rd on
On Aug 3, 9:35 am, Tim Wescott <t...(a)seemywebsite.com> wrote:

> 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.

Err... but the 'mean squared value' with statistical weight equal at
all times is what is a good measure of the sinewave. With an
ADC that samples at a short time interval, you get 'sum squared
value' according to the statistical weight of a series of delta-
functions.
It might eventually converge to the same value as the desired
function, but it only works in one cycle time if your ADC
measurements are all taken at carefully selected times
(no jitter allowed, no sample-time error relative to the
phase of the sinewave).

The four-sample example was a correct Nyquist-limited
sampling for the frequency of interest, and would work fine.
But, it requires a 4x sample clock synchronized to the sinewave,
which is not easy with a modest microprocessor ADC
at 200 kHz.
From: Michael Kellett on

"whit3rd" <whit3rd(a)gmail.com> wrote in message
news:9890b1c9-a798-4814-8524-c51726fd7582(a)u26g2000yqu.googlegroups.com...
On Aug 3, 9:35 am, Tim Wescott <t...(a)seemywebsite.com> wrote:

> 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.

> Err... but the 'mean squared value' with statistical weight equal at
> all times is what is a good measure of the sinewave. With an
> ADC that samples at a short time interval, you get 'sum squared
> value' according to the statistical weight of a series of delta-
> functions.
> It might eventually converge to the same value as the desired
> function, but it only works in one cycle time if your ADC
> measurements are all taken at carefully selected times
> (no jitter allowed, no sample-time error relative to the
> phase of the sinewave).

> The four-sample example was a correct Nyquist-limited
> sampling for the frequency of interest, and would work fine.
> But, it requires a 4x sample clock synchronized to the sinewave,
> which is not easy with a modest microprocessor ADC
> at 200 kHz.

Actually you only need 3 samples per sine wave period. You could set this up
quite easily using the ADC and timers on an STM32F103xxxx. The OP has not
explained how he generates the sine wave from a PWM signal - which might
have some influence on how easily the ADC sample clock can be generated.
My feeling is that increasing the ADC sampling rate from 200kHz to 300kHz
will be a lot cheaper and more reliable than an analogue method.
From the response to Tim's suggestions I'm not sure the OP understands the
sampling maths at all.

Michael Kellett


From: JosephKK on
On Tue, 3 Aug 2010 09:18:32 -0700 (PDT), john1987
<conphiloso(a)hotmail.com> wrote:

>On Aug 2, 4:31�pm, Tim Wescott <t...(a)seemywebsite.com> wrote:
>> On 08/02/2010 01:09 PM, raza tauseef wrote:
>>
>>
>>
>>
>>
>> > On Aug 2, 1:28 pm, Tim Wescott<t...(a)seemywebsite.com> �wrote:
>> >> On 08/02/2010 08:57 AM, john1987 wrote:
>>
>> >>> On Aug 2, 11:49 am, John Larkin
>> >>> <jjlar...(a)highNOTlandTHIStechnologyPART.com> � �wrote:
>> >>>> On Mon, 2 Aug 2010 07:24:24 -0700 (PDT), john1987
>>
>> >>>> <conphil...(a)hotmail.com> � �wrote:
>> >>>>> 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.
>>
>> >>>>> First link is as follows
>> >>>>>http://img828.imageshack.us/i/scan0001j.jpg/
>>
>> >>>>> Second link is as follows
>>
>> >>>>>http://img299.imageshack.us/i/scan0002db.jpg/
>>
>> >>>>> 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?
>> >>>>> 4. Any advice about choosing the right ADC?
>> >>>>> 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
>>
>> >>>> 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- Hide quoted text -
>>
>> >>>> - Show quoted text -
>>
>> >>> 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.
>>
>> >> 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 Serviceshttp://www.wescottdesign.com
>>
>> >> Do you need to implement control loops in software?
>> >> "Applied Control Theory for Embedded Systems" was written for you.
>> >> See details athttp://www.wescottdesign.com/actfes/actfes.html-Hide quoted text -
>>
>> >> - Show quoted 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.
>>
>> 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 Serviceshttp://www.wescottdesign.com
>>
>> Do you need to implement control loops in software?
>> "Applied Control Theory for Embedded Systems" was written for you.
>> See details athttp://www.wescottdesign.com/actfes/actfes.html- Hide quoted text -
>>
>> - Show quoted 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
>

Excuse me, but are you saying that you are programming the uC that is
generating the sine wave (PWM) and you still do not know when the peak
occurs??
From: Jim Thompson on
On Sun, 08 Aug 2010 15:30:31 -0700,
"JosephKK"<quiettechblue(a)yahoo.com> wrote:

>On Tue, 3 Aug 2010 09:18:32 -0700 (PDT), john1987
><conphiloso(a)hotmail.com> wrote:
>
>>On Aug 2, 4:31�pm, Tim Wescott <t...(a)seemywebsite.com> wrote:
>>> On 08/02/2010 01:09 PM, raza tauseef wrote:
>>>
>>>
>>>
>>>
>>>
>>> > On Aug 2, 1:28 pm, Tim Wescott<t...(a)seemywebsite.com> �wrote:
>>> >> On 08/02/2010 08:57 AM, john1987 wrote:
>>>
>>> >>> On Aug 2, 11:49 am, John Larkin
>>> >>> <jjlar...(a)highNOTlandTHIStechnologyPART.com> � �wrote:
>>> >>>> On Mon, 2 Aug 2010 07:24:24 -0700 (PDT), john1987
>>>
>>> >>>> <conphil...(a)hotmail.com> � �wrote:
>>> >>>>> 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.
>>>
>>> >>>>> First link is as follows
>>> >>>>>http://img828.imageshack.us/i/scan0001j.jpg/
>>>
>>> >>>>> Second link is as follows
>>>
>>> >>>>>http://img299.imageshack.us/i/scan0002db.jpg/
>>>
>>> >>>>> 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?
>>> >>>>> 4. Any advice about choosing the right ADC?
>>> >>>>> 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
>>>
>>> >>>> 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- Hide quoted text -
>>>
>>> >>>> - Show quoted text -
>>>
>>> >>> 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.
>>>
>>> >> 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 Serviceshttp://www.wescottdesign.com
>>>
>>> >> Do you need to implement control loops in software?
>>> >> "Applied Control Theory for Embedded Systems" was written for you.
>>> >> See details athttp://www.wescottdesign.com/actfes/actfes.html-Hide quoted text -
>>>
>>> >> - Show quoted 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.
>>>
>>> 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 Serviceshttp://www.wescottdesign.com
>>>
>>> Do you need to implement control loops in software?
>>> "Applied Control Theory for Embedded Systems" was written for you.
>>> See details athttp://www.wescottdesign.com/actfes/actfes.html- Hide quoted text -
>>>
>>> - Show quoted 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
>>
>
>Excuse me, but are you saying that you are programming the uC that is
>generating the sine wave (PWM) and you still do not know when the peak
>occurs??

Yes. That's when I quit the game :-)

...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.