#### Do you have a question? Post it now! No Registration Necessary

**posted on**

- Joseph Goldburg

July 18, 2004, 5:34 am

Hi All,

I want to make an impedance measuring device from 0 to 20 KHz.

If I generate |V| at zero phase and I measure |I| at some phase theta

Then |Z| at delta phase = |V| / ( |I| theta) = |V /I| at

(- theta)

But both V(t) and I(t) are digitally sampled.

V(nT) = |V| sin (2 x Pi x nT) and I(nT) = |I| sin (2 x Pi x nT)

n = sample number etc

NOTE --- I can digitally sample V as V(nT) and I as I(nT) as a 8bit

onr 10 bit ADC conversion

Question

How do I get Z = V / I from digital samples and calculate the

magnitude and phase.

I will fix the frequency of V(t) = Sin (2 x Pi X f x t) then sample V

and I using ADC.

You thoughts would be appreciated.

Regards

Joseph

I want to make an impedance measuring device from 0 to 20 KHz.

If I generate |V| at zero phase and I measure |I| at some phase theta

Then |Z| at delta phase = |V| / ( |I| theta) = |V /I| at

(- theta)

But both V(t) and I(t) are digitally sampled.

V(nT) = |V| sin (2 x Pi x nT) and I(nT) = |I| sin (2 x Pi x nT)

n = sample number etc

NOTE --- I can digitally sample V as V(nT) and I as I(nT) as a 8bit

onr 10 bit ADC conversion

Question

How do I get Z = V / I from digital samples and calculate the

magnitude and phase.

I will fix the frequency of V(t) = Sin (2 x Pi X f x t) then sample V

and I using ADC.

You thoughts would be appreciated.

Regards

Joseph

Re: How to work Maths is the time sample domain

So far you have only got the magnitude of Z. The actual value is R +

jX. From your samples you can recover the peak values of both V and I.

You can also count the number of samples between the two waveforms

crossing zero in the same direction. This will give you the phase

relationship between them. Now do a vector calculation on I to

establish the proportion that is in phase, or at ninety degrees to the

volt age waveform and do a V/I calculation for each. These will

give you R and X for the R+jX calculation.

d

Pearce Consulting

http://www.pearce.uk.com

Re: How to work Maths is the time sample domain

Looking for zero crossings only works if you sample really fast.

If you sample V and I several times over a cycle, and demodulate them

with inphase and quadrature sine waves:

Vi = (1/N)sum(V(n)

*** cos(2***pi/M * n));

Vq = (1/N)sum(V(n)

*** sin(2***pi/M * n));

(and the same for I)

Then you can treat them like complex numbers, so

Z = ((Vi

***Ii + Vq***Iq) + j(Vq

***Ii - Vi***Iq))/(Ii^2 + Iq^2).

I'm prone to typos so you'll want to check to make sure my complex

arithmetic is all OK, and to make yourself understand it.

--

Tim Wescott

Wescott Design Services

Tim Wescott

Wescott Design Services

We've slightly trimmed the long signature. Click to see the full one.

Re: How to work Maths is the time sample domain

{... i and q method to measure impedance ...]

Since he is just going for the phase difference between the voltage and

the current he can just pick a reference at random. Whatever he picks

will add the same value to the two values he needs to subtract.

Since he is just going for the phase difference between the voltage and

the current he can just pick a reference at random. Whatever he picks

will add the same value to the two values he needs to subtract.

--

--

snipped-for-privacy@rahul.net forging knowledge

snipped-for-privacy@rahul.net forging knowledge

Re: How to work Maths is the time sample domain

On Sun, 18 Jul 2004 13:53:56 +0000 (UTC), Ken Smith

While this is true, he still needs a constant phase relationship,

which means frequency locking to the signal - which implies some sort

of decoder to generate the i and q. In hardware, you could have a

Costas loop.

d

Pearce Consulting

http://www.pearce.uk.com

While this is true, he still needs a constant phase relationship,

which means frequency locking to the signal - which implies some sort

of decoder to generate the i and q. In hardware, you could have a

Costas loop.

d

Pearce Consulting

http://www.pearce.uk.com

Re: How to work Maths is the time sample domain

I assume he is creating one of these signals so he already has the

frequency. If not then yes he needs to frequency lock. A PLL would do

this for him and the error in the phase detector would drop out.

Based on what was implied elsewhere, I think he has a micro that can do

the locking if needed.

--

--

snipped-for-privacy@rahul.net forging knowledge

snipped-for-privacy@rahul.net forging knowledge

Re: How to work Maths is the time sample domain

You'd have to average a

___lot___of crossings -- my method will get you an

answer in one cycle who's accuracy is only dependent on system noise.

The source of the i and q references is the same timebase he's using to

generate his V.

--

Tim Wescott

Wescott Design Services

Tim Wescott

Wescott Design Services

We've slightly trimmed the long signature. Click to see the full one.

Re: How to work Maths is the time sample domain

I read in sci.electronics.design that Tim Wescott

Jul 2004:

... which would be possible only if you define M, N and n.

*com>) about 'How to work Maths is the time sample domain', on Sat, 17*Jul 2004:

... which would be possible only if you define M, N and n.

--

Regards, John Woodgate, OOO - Own Opinions Only.

The good news is that nothing is compulsory.

Regards, John Woodgate, OOO - Own Opinions Only.

The good news is that nothing is compulsory.

We've slightly trimmed the long signature. Click to see the full one.

Re: How to work Maths is the time sample domain

Actually it's only possible if

___Joseph___defines M, N and n.

___I'm___just

going to give cheap advise.

M is the number of samples in a cycle (conventional wisdom says 3 or

more, but could be anything that builds you up a complete picture of the

wave).

N is the number of samples in a vector (should end on a cycle, so than

N*M is an integer).

n is the particular sample in the vector.

--

Tim Wescott

Wescott Design Services

Tim Wescott

Wescott Design Services

We've slightly trimmed the long signature. Click to see the full one.

Re: How to work Maths is the time sample domain

Since the waveforms are sampled only with 8..10 bits, my guess is that

10..20 samples/cycle should be enough. Close to the zero crossing of a

sine wave, the waveform can be approximated with a straight line,

quite accurately within +/-5 degrees, but I guess that even within

the +/-30 degree range the approximation would be acceptable in this

case.

Take the last sample below zero and first sample above zero and draw a

straight line between these two points and calculate were the line

crosses the zero line between the sampling point. This will give the

___fractional___sampling period after the first sample.

This way the phase shift between the current and voltage can be

measured to within a few degrees even with 10..20 samples/cycle.

Assuming the sampling frequency is not synchronised with the

measurement signal, the sampling points around the zero crossing do

not always hit the same spots, thus averaging several measurements

should improve the resolution.

Calculating the phase shift between the positive going current and

voltage transitions and then separately between negative going

transitions may help to detect any DC bias in the measurement system.

Paul

Re: How to work Maths is the time sample domain

On Sun, 18 Jul 2004 15:34:02 +1000, "Joseph Goldburg"

The easy way to do this is to generate a sine wave (applied voltage)

at frequency F, and take adc (current) samples at 4F. Call a set of 4

sequential samples a,b,c, and d. Then let

I = a-c is the angle-zero (in-phase, "I") p-p value

Q = b-d is the 90 degree (quadrature, "Q") p-p value.

You can take a lot of samples and average; this washes out both noise

and any DC offset, and extends the effective precision of your ADC.

(Or, equivalently, make the stimulus F the current source and sample

resulting voltage at 4F.)

Then just do a little trig.

John

The easy way to do this is to generate a sine wave (applied voltage)

at frequency F, and take adc (current) samples at 4F. Call a set of 4

sequential samples a,b,c, and d. Then let

I = a-c is the angle-zero (in-phase, "I") p-p value

Q = b-d is the 90 degree (quadrature, "Q") p-p value.

You can take a lot of samples and average; this washes out both noise

and any DC offset, and extends the effective precision of your ADC.

(Or, equivalently, make the stimulus F the current source and sample

resulting voltage at 4F.)

Then just do a little trig.

John

#### Site Timeline

- » Reverse current into a lithium battery
- — Next thread in » Embedded Programming

- » ICD2 USB Drivers (MicroChip)
- — Previous thread in » Embedded Programming

- » FreeRTOS memory footprint reduction at build time
- — Newest thread in » Embedded Programming

- » Re: Ronzio amplificatore
- — The site's Newest Thread. Posted in » Electronics Hobby (Italian)