Finding the exact peak of an sine wave

Hi

I have to do a phase delay measurement between a voltage and a current sine wave.

The current is delayed after the voltage and one way to find the phase delay is to trigger on the zero-crossing of the individual signals. However it is an inductive motor load, so at low line voltages the waveform of the current is highly distorded (un-linear zero-crossing).

So I'm looking at perhaps finding the phase by finding the exact peak of both the voltage and current sine wave. The problem with that is that the waveform is quite flat at the top (nature of the sine), so it is difficult to find the exact peak point.

My idea to combat this would be to find the peak by continously calculating the dI/dt of the current signal. So at the rising of the current I will get a time for the point of a certain dI/dt and at the falling slope of the current I will again trigger on the same dI/dt (with negative sign). So the peak is just the two triggers added and divided by two

But, is there a better way than this to finding a trigger point on a sine waveform? Anyone got experience with this?

(I have ADC, comparator and opamp available for the job including lot of computational power)

Thanks

Klaus

Reply to
Klaus Kragelund
Loading thread data ...

The standard approach is to fit a model Amp*Sin(freq*t+phase) to all the data, not just the peak and then read the phase off the model.

If your data is distorted you may need a fancier model than that.

The nice thing is you don't have to fit every cycle, if you know the frequency you can just sum values over several cycles and then fit. Less CPU time, less noise, more accuracy.

If you don't know the frequency and the waveform is distorted to hell, compute an FFT over several cycles and pick the phase off the imaginary component of the largest power peak.

--
John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
 Click to see the full signature
Reply to
John Carter

Do you mean something like phase = atan(real/imag) or something?

Bill (physics was a long time ago) Chernoff

Reply to
Bill Chernoff

Presumably the motor is driven by a voltage source? Presumably that voltage source has known characteristics? (e.g., AC mains?)

Use those characteristics (repeatability) to help you *know* where to look for the (next) zero crossing (in each waveform). I.e., don't start looking for the sample point until you

*expect* it to be coming...

You don't necessarily need to sample both waveforms at their peaks... *or* their zero crossings, etc. You can sample each waveform at whichever place is most convenient for you AS LONG AS YOU KNOW HOW THAT PLACE RELATES TO THE SAMPLING POINT OF THE OTHER WAVEFORM. (i.e., you can sample voltage at zero crossing and current at *peak* if you know that peak of voltage would have been 90 degrees later than the voltage zero crossing)

Make sure you know the characteristics of your signals FULLY before you make any assumptions about them (e.g. symmetry may not be present where expected)

Recall that d(sin)/dt = cos

Reply to
Don

Something like that.

The exact details will depend on the exact FFT routine you are using. Engineers always subtly distort the mathematics into something a mathematician will almost recognise. ;-)

Hint : Stick with the simpler accumulate data points and model fit version if you can. Just plain strains the brain less.

--
John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
 Click to see the full signature
Reply to
John Carter

Thats funny. I just did exactly that on a small project I've got here, and thought I was sooooo clever. ;-)

Bill (reinventing the wheel over and over) Chernoff

Reply to
Bill Chernoff

You are learning academic methods , not productive methods . Im very excited about productive methods . If you could excite me .......

Im a E.E. , im not the only one here , who makes stuff work ,

rather than get frustrated just measuring stuff . I measure stuff NOT with O'scopes and network analysers . An cheap RF bridge is handy , you can read the circuits you are working with . MFJ is a Chinaman in Missippippi who sells MFJ209/249 170MHZ antenna tuner , which everyone turns into RF bridge with a CAP,COIL ,RESISTOR circuit that absorbes enough RF to make the meter show 3:1 SWR .

You may see this as a high power RF bridge . There is nothing it cant read . lumped or distributed L's and C's in any order ! It works well at very low Z's and low Q's .

Since it injects a hi power sinewave , it sees reality , not just voltages and currents .

I think it was the best tool i ever bought , for it freed me up . I no longer had to analyse the circuit for the test equipment i had to search for .

BTW you will learn faster if you are a HAM radio operator . Even though we are being flooded with females and Luddites who have no interest in Ham radio except as a better form of Citizens band . The 70's were best when everyone had respect for those who improved their abilities , but today its too many opportunists , "teachers" , Luddites .... dont want to study anything but how to get a govt job and a badge . Can you make this work ? No but i have a college degree . ( a red flag to a factory owner ....)

I got my first job for i had a novice Ham lic . The intervu went well for half hour , next i informed him , he lit up , smiled and we spent the next 2 hours in a chit chat of how interesting radio , antennas is . Tom Brown was forced to hire diplomas . He had trouble selling his OpAmps if he barred Luddites . They forced him to hire a polite Jap kid who laid a single chip oscillator IC on me for production eng' tests . Silver Mica caps ? 10 microfarad ? This kid developed a sinewave osc that needed Silver Micas !! It was a flop . This is what ALL schools teach . Business is NOT your job , you are an engineer . But an engineer who cant sell his pdt is NOT and engineer ....

My interest is in making cheaper and avail , the switch mode pow supplies . The Chineese have produced a copy for the PC that is reliable and very low cost . Bu the future is single drive NPN , 'blocking" or core saturation oscillators . There are no problems , they nix the timing problem dead band , freq control .... They need nothing but a LM431 and an OPTO ! This ckt is far more fault tolerant ! I want to make a 5 kilo watt MIG welder , 100% duty cycle . They run very cool , hi eff' and i can parallel them to very wide arrays . I can use 200 MicroHen cup cores ( BG Micro , $.30 , 80 watt ?) But all flour' lites do require push/pull to keep one side from burning more than the other . The ones i got in Thailand use curent xfrmr to drive bases . If the load draws no current , the bases are not driven . A Flour lite will glow ( maybe microamps ) easier than it will do full output . Its very non-linear . When you up volt , it reaches an breakover point and you need a ballast . CompactFlour are not better than

48 inch tubes . And 96" tubes use a ballast without starters nor fillaments . They simply loose couple the secondary and drive it to high voltage . So why dont we do same for 48" tubes ? 96" tubes are indoor only , they can't create enoug heat in the tube to start the "knee". The knee is a very effecient but hi power factor output . below the knee , you wont get good output for the $$ . BTW 130VAC incand bulbs were used for life . They lasted but fact is light output drops at a very hi rate as voltage is dropped . They were very hi cost to operate ....But the life was longer !! ? Thats why i gobbled up the Harbor fright $.78 500 W Halogens ! I'll run those 130 VAC bulbs as heaters that need not insulation . The ni-crome in your toaster can make you jump and burn these can't electrocute you , only burn your pizza .. Another interesting ....... RVers use 117VAC , but their alternator can be rewired to make 3 kilowatts of it . Using SCR's you can generate better waveforms than a sinewave inverter ! But dont run roof airs with it , roof airs need lose 50% right off . Air MUST be engine driven . Pelteir diodes are worst performance , Ammonia absorp is the highest . But it depends on your fuel . It fuel is a problem , a linear motor driven box like Norcold ? used to make , is a better effeciency ... Its the written law that kills Ammonia absorp refrig . America used to make ALL its ice for ice boxes , til the govt figured its cronies would make more $$ with a more complicate system . Faraday bent a piece of glass in an inverted V and created frost in seconds using a burner . Farmers long ago could heat a steel aparatus on their coal stoves and cool it ( condense the Ammonia ) then drop it into an insulated "ice" box .. It froze stuff ! It would make ice cubes ! People want to use non-CFC's in their cars A/C . Butane/ Propane can never be a problem for 300 million people would have to purposely vent their cars A/C every week to make a difference , so much butane leaks out world wide . Just charge with Butane and the same R12 oil , next charge tiny bit of Propane , til pressure reads what your old R12 did . Cost si so low you no longer need to evacuate system for TBshoot . You simply charge , Leak ,charge ,Leak ,charge Leak There is NO air in your system . I once removed 95% of my R12 to prove a bet , then sucked it back in . Cool the can , never run cars pump more than 15 seconds at a time

let it cool . Remaining is 5% gas which is maybe .1% total ?

Reply to
werty

You are learning academic methods , not productive methods . Im very excited about productive methods . If you could excite me .......

Im a E.E. , im not the only one here , who makes stuff work ,

rather than get frustrated just measuring stuff . I measure stuff NOT with O'scopes and network analysers . An cheap RF bridge is handy , you can read the circuits you are working with . MFJ is a Chinaman in Missippippi who sells MFJ209/249 170MHZ antenna tuner , which everyone turns into RF bridge with a CAP,COIL ,RESISTOR circuit that absorbes enough RF to make the meter show 3:1 SWR .

You may see this as a high power RF bridge . There is nothing it cant read . lumped or distributed L's and C's in any order ! It works well at very low Z's and low Q's .

Since it injects a hi power sinewave , it sees reality , not just voltages and currents .

I think it was the best tool i ever bought , for it freed me up . I no longer had to analyse the circuit for the test equipment i had to search for .

BTW you will learn faster if you are a HAM radio operator . Even though we are being flooded with females and Luddites who have no interest in Ham radio except as a better form of Citizens band . The 70's were best when everyone had respect for those who improved their abilities , but today its too many opportunists , "teachers" , Luddites .... dont want to study anything but how to get a govt job and a badge . Can you make this work ? No but i have a college degree . ( a red flag to a factory owner ....)

I got my first job for i had a novice Ham lic . The intervu went well for half hour , next i informed him , he lit up , smiled and we spent the next 2 hours in a chit chat of how interesting radio , antennas is . Tom Brown was forced to hire diplomas . He had trouble selling his OpAmps if he barred Luddites . They forced him to hire a polite Jap kid who laid a single chip oscillator IC on me for production eng' tests . Silver Mica caps ? 10 microfarad ? This kid developed a sinewave osc that needed Silver Micas !! It was a flop . This is what ALL schools teach . Business is NOT your job , you are an engineer . But an engineer who cant sell his pdt is NOT and engineer ....

My interest is in making cheaper and avail , the switch mode pow supplies . The Chineese have produced a copy for the PC that is reliable and very low cost . Bu the future is single drive NPN , 'blocking" or core saturation oscillators . There are no problems , they nix the timing problem dead band , freq control .... They need nothing but a LM431 and an OPTO ! This ckt is far more fault tolerant ! I want to make a 5 kilo watt MIG welder , 100% duty cycle . They run very cool , hi eff' and i can parallel them to very wide arrays . I can use 200 MicroHen cup cores ( BG Micro , $.30 , 80 watt ?) But all flour' lites do require push/pull to keep one side from burning more than the other . The ones i got in Thailand use curent xfrmr to drive bases . If the load draws no current , the bases are not driven . A Flour lite will glow ( maybe microamps ) easier than it will do full output . Its very non-linear . When you up volt , it reaches an breakover point and you need a ballast . CompactFlour are not better than

48 inch tubes . And 96" tubes use a ballast without starters nor fillaments . They simply loose couple the secondary and drive it to high voltage . So why dont we do same for 48" tubes ? 96" tubes are indoor only , they can't create enoug heat in the tube to start the "knee". The knee is a very effecient but hi power factor output . below the knee , you wont get good output for the $$ . BTW 130VAC incand bulbs were used for life . They lasted but fact is light output drops at a very hi rate as voltage is dropped . They were very hi cost to operate ....But the life was longer !! ? Thats why i gobbled up the Harbor fright $.78 500 W Halogens ! I'll run those 130 VAC bulbs as heaters that need not insulation . The ni-crome in your toaster can make you jump and burn these can't electrocute you , only burn your pizza .. Another interesting ....... RVers use 117VAC , but their alternator can be rewired to make 3 kilowatts of it . Using SCR's you can generate better waveforms than a sinewave inverter ! But dont run roof airs with it , roof airs need lose 50% right off . Air MUST be engine driven . Pelteir diodes are worst performance , Ammonia absorp is the highest . But it depends on your fuel . It fuel is a problem , a linear motor driven box like Norcold ? used to make , is a better effeciency ... Its the written law that kills Ammonia absorp refrig . America used to make ALL its ice for ice boxes , til the govt figured its cronies would make more $$ with a more complicate system . Faraday bent a piece of glass in an inverted V and created frost in seconds using a burner . Farmers long ago could heat a steel aparatus on their coal stoves and cool it ( condense the Ammonia ) then drop it into an insulated "ice" box .. It froze stuff ! It would make ice cubes ! People want to use non-CFC's in their cars A/C . Butane/ Propane can never be a problem for 300 million people would have to purposely vent their cars A/C every week to make a difference , so much butane leaks out world wide . Just charge with Butane and the same R12 oil , next charge tiny bit of Propane , til pressure reads what your old R12 did . Cost si so low you no longer need to evacuate system for TBshoot . You simply charge , Leak ,charge ,Leak ,charge Leak There is NO air in your system . I once removed 95% of my R12 to prove a bet , then sucked it back in . Cool the can , never run cars pump more than 15 seconds at a time

let it cool . Remaining is 5% gas which is maybe .1% total ?

Reply to
werty

You did not say _why_ you want to know the phase difference ?

Do you just want to calculate the actual power by multiplying the apparent power by the cosine of the phase difference ? While this is OK for pure sine waves, it does not make very much sense, if the waveforms are badly distorted, e.g. when feeding a simple power supply.

An other way of finding the actual power is to multiply the instantaneous voltage with instantaneous current and average this over at least one mains cycle.

There was a similar discussion in this newsgroup in last May with the subject "ADC/DAC for 50-400Hz 3-phase?".

Paul

Reply to
Paul Keinanen

Yes - it is a voltage source (230Vac 50Hz) - and the load is a asyncronous motor. I use the phase delay and peak currents to detect if the motor is loaded or not

A plot of the voltage and current waveforms are at:

formatting link

The yellow and blue traces are the current and voltage respectively

The left column plots are loaded and the right column plots are un-loaded The top row is 200Vac, next row 230Vac (nominal) and the last row is

260Vac

The problem is that the phase delay and peak currents are influenced by the ac voltage applied to the motor. When the voltage is low, the no-load waveform is distorded and the phase delay is difficult to find (top right plot)

When the voltage is high (bottom right plot) the phase delay is shown clearly, but then the ratio of the loaded/non-loaded peak currents are almost 1 (bad)

So the current design measures the zero-crossing phase delay and the ratio of peak currents and multiplies these two numbers to get a number that indicates loaded/non-loaded state.

But I would like to measure only the phase delay of the peak voltages and currents. The problem is the waveform is heavily distorded at low voltages - so I need an algoritm to "clean" up the current waveform to find the correct peak. I only have about 200bytes of RAM, so could this be done - and do you have an example?

An alternative method knowing the waverform would be to find the peaks and measuring between the 75% peak points of both waveforms. A better method?

Regards

Klaus

Reply to
Klaus Kragelund

Klaus Kragelund skrev:

Perhaps a cross-correlation between 100samples of voltage and

100samples of current? ??
Reply to
Klaus Kragelund

The waveforms are not too bad - maybe you could do the old-fashioned slow Fourier with the fundamental frequency only, for both the sine and cosine component, and resolve the phase from the corresponding result components.

--
Tauno Voipio
tauno voipio (at) iki fi
 Click to see the full signature
Reply to
Tauno Voipio

Hello Klaus,

Your waveform link timed out for me so I can only take a shot in the dark at it: Don already suggested using a level other than zero or peak. What if you roughly measured the peak voltage and then triggered a timer at, say, 70% and on the rising slope? Run the timer all the way through the peak and stop it when the falling slope also transitions through the

70% point. The peak will be at half the timer result, provided there are no serious distortions up there. If there are you may have to push the thresholds to 90% or higher.

Wish I had that as well. My current app has to make do with around 10 MIPS. But I am thankful for that, considering the number of MIPS my father had to design around.

Comparator: Check the offset. In case you have to push your thresholds into the flatter portions you might want to do at least two measurements, alternating the comparator inputs and thus averaging out its offset.

--
Regards, Joerg

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

Generate a reference sine and cosine in real-time and form the sum of sin * A/D values and cos * A/D values. Periodically take these accumulators and form Y / X where Y = sum of A/D values * sines and X = sum of A/D values * cosines. The phase angle is arctan of Y / X. I think this can be done using only a little RAM. If the waveform is mostly a sine wave then you don't have to use very many samples per cycle. Measuring the 75% point as you mentioned before is probably equivalent to doing this quadrature demodulation with about 4 samples per cycle. In that case you don't need a large trig table. Just vaues every 45 degrees will do.

Robert Scott Ypsilanti, Michigan

Reply to
Robert Scott

Hi Klaus,

I suggest that you insert a 50Hz bandpass filter in front of a zero-crossing detector.

Then you have a stable signal to the phasedetector.

Regards Jens

"Klaus Kragelund" skrev i en meddelelse news: snipped-for-privacy@m73g2000cwd.googlegroups.com...

-------------------------------------------------------------------------------- Jeg beskyttes af den gratis SPAMfighter til privatbrugere. Den har indtil videre sparet mig for at få 1553 spam-mails Betalende brugere får ikke denne besked i deres e-mails. Hent en gratis SPAMfighter her.

Reply to
Jens Gydesen

Good suggestion. If I use the same filter for the voltage the phase delay will be the same

What about a Goertzel routine?

Thanks

Klaus

Reply to
Klaus Kragelund

Please note that the phase behaviour of a bandpass filter is pretty wild near the passband middle. This leads to a requirement of very good matching of the two filters or you're lost.

--
Tauno Voipio
tauno voipio (at) iki fi
 Click to see the full signature
Reply to
Tauno Voipio

Hello Tauno, Hello Klaus,

Sounds reasonable since there seem to be lots of MIPS available. Else I'd do a WDF bandpass but that means a lot of assembler. Well, a few hundred lines at least.

If the same algorithm is used for both that should be fine. Of course, I wouldn't use an elliptic filter structure here ;-)

--
Regards, Joerg

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

... Well, actually you don't. Because you immediately modified this statement to say that at least one of them is not in fact a sine wave:

That also renders the term "phase delay" questionable. As soon as you have something else than a pure sine wave, "phase" becomes a less than well-defined concept.

To put it more directly: for practical considerations, a sine wave doesn't have a peak point to be found.

If we can assume that you know the frequency beforehand, and "a lot of computational power" is to be taken at face value, the answer would be obvious: compute the delayed correlation of the two signals, and maximum-fit the result:

max(d in 0..1: sum(t = 0..N*F/f: I(t) * U(t-d))

(f is the input frequency, F is the sampling rate, N is the number of input cylcles to sum over). As a somewhat rougher guess, one might compute that sum for d=0 and d = F/(4*f) and compute the most likely value of 'd' from the atan2() of the results.

If the assumption is that you're only interested in the sine component of the signals, you can convolute both inputs with cos(t) and sin(t), atan2() to build the phase angles relative to the sampling interval, and subtract them to find the delay.

--
tHans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

maximum fit is out of my vocalibrary (not a DSP guy).

sum(t = 0..N*F/f: I(t) * U(t-d)) is the cross correlation., but max()?

Regards

Klaus

Reply to
Klaus Kragelund

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.