Connect with us

How to work Maths is the time sample domain

Discussion in 'Electronic Design' started by Joseph Goldburg, Jul 18, 2004.

Scroll to continue with content
  1. 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


    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.

  2. Don Pearce

    Don Pearce Guest

    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.

    Pearce Consulting
  3. Tim Wescott

    Tim Wescott Guest

    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.
  4. Don Pearce

    Don Pearce Guest

    Alternatively, you average out the v-crossing intervals and i-crossing
    intervals to get a mean phase shift.
    What is the source of your i and q references?

    Pearce Consulting
  5. Hi Tim,

    Is this called quadrature dection?

    I would like to understand the maths behind this - can you name the
    algorith you are using.

  6. I read in that Tim Wescott
    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.
  7. 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

    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.

  8. Ken Smith

    Ken Smith Guest

    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.
  9. Don Pearce

    Don Pearce Guest

    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.

    Pearce Consulting
  10. Ken Smith

    Ken Smith Guest

    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.
  11. Tim Wescott

    Tim Wescott Guest

    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.
  12. Tim Wescott

    Tim Wescott Guest

    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

    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.
  13. John Larkin

    John Larkin Guest

    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.

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day