Connect with us

MPS430 cordicPWM sine wave generator

Discussion in 'Electronic Design' started by miso, Dec 13, 2012.

Scroll to continue with content
  1. miso

    miso Guest

  2. Guest

    Not really getting what the CORDIC was used for..doesn't the MPS430 store literals in memory?
     
  3. miso

    miso Guest

    I'm sure there is some cordic description on line, but I can describe it
    reasonably well from memory. The cordic has a table of sines and
    cosines. It essentially goes from 90 deg, 45 deg, 22.5 deg etc in
    decreasing powers of two. I say essentially because what you do is
    pretend the circle has a power of two number of degrees, i.e.256
    degrees, 512, etc. This makes the algorithm easier to program.

    The cordic takes the angle in question and uses a successive
    approximation scheme to drive it to zero. That is, if you were looking
    for the sine or cosine of 50 degrees, your first step would be to
    subtract 45 degrees, which is a value in your table. You keep this up
    until you have driven it to zero as best as you can. the accumulators
    will contain the sine and cosine of the initial angle.

    Now you could generate a sine wave with stored samples of the signal,
    but that isn't very flexible. To generate a sine wave with a cordic, you
    accumulate phase. That is you pick a phase step size which represents
    the fraction of a sine wave that you are going to use in the
    approximation. Say you wanted 1 degree steps. Then you would feed the
    cordic 1, 2, 3, etc. Now if you set up your pretend circle to have 256
    degrees in it, then the phase accumulator will always return to zero and
    the sequence would continue. So your phase input is a digital sawtooth
    signal.

    But you could have picked the phase interval to be some number which
    won't return to zero. Say you picked 3 degree steps. Then the sequence
    would go 0,3,6...255, 2,5,8, etc. This allows for more flexibility in
    generating the sine wave relative to the clock.

    I haven't looked at code yet, but that should be how it is written, with
    some foo I left out. As you do the successive approximation scheme, you
    are basically rotating a vector from the initial starting point to zero.
    The cordic causes the vector to expand, so you need to seed the cordic
    with a scaled version of the vector. I 'd have to dig up a book to
    explain this is detail, but it is well documented.

    So the person I presume picked or let the user input a phase step, then
    creates the sine and cosine on the fly. Those values are then generated
    with a PWM type DAC. You get the sine and cosine at the same time. This
    means you have a quadrature phase available if need be.

    There is a PHd. dissertation at Stanford that is the bible of cordic
    processing. The authors name (first or maybe last) is Ahmed, but if you
    search Stanford library on line, you would find the dissertation. It is
    or was in the Terman library, or perhaps Green. It was way better than
    what you find in most signal processing books. At least 90% of PHd
    dissertations aren't worth the paper they are printed on, but we built
    multi-millions of chips using schemes out of that dissertation back in
    the day.

    Most DSP books will cover generation of sine and cosine with the
    cordic, but Ahmed's dissertation covered the transcendental functions.
    So you could linearize thermocouples with it, etc. Or as I stated in the
    other post, take the arcsine and do a FSK demod.
     
  4. Guest

    Thanks for taking the time with that lengthy explanation. Wiki has a sufficiently good article on it, an easy read http://en.wikipedia.org/wiki/CORDIC

    Your TI link states he does 100KHz PWM, but they can't mean that literally.They must mean the PWM counter is being clocked at 100KHz where it's preloaded with the amplitude computed by CORDIC on the fly. CORDIC then makes sense when he's using a very large number of phase samples way in excess of the onboard RAM.
     
  5. Jon Kirwan

    Jon Kirwan Guest

    On Thu, 13 Dec 2012 20:27:46 -0800 (PST),
    I think it was putting out 60Hz, if I remember correctly what
    I read there.

    Jon
     
  6. Well, it's an interesting exercise.. it's done in FPGAs when you need
    a lot of time resolution, but for a 64-point sine wave with fixed
    phase, all you need is 16 words of lookup table.


    Best regards,
    Spehro Pefhany
     
  7. I was suggesting folding it in quarters.. you go forward through the
    table to pi/2, backwards to pi, then repeat with the sign flipped.
    That's probably what you meant anyway.
    We are doing more like 24bits with tens of thousands of samples per
    cycle, and very finely adjusted phase differences between generated
    signals. The CORDIC (COordinate Rotation DIgital Computer) algorithm
    is a reasonable choice for that. It is the algorithm used to calculate
    trig functions in your HP35.
     
  8. miso

    miso Guest

    You simply don't get it. You can change the frequency on the fly with
    the cordic without changing the sample rate. You simply change the phase
    step.
     
  9. Guest

    Sixteen very small words.
     
  10. Jasen Betts

    Jasen Betts Guest

    That doesn't make cordic special, the same can be, and is done with other DDS
    methods.
     
  11. miso

    miso Guest

    The cordic is easily the most flexible method for transcendental
    function computations. I've been through the math library at Stanford
    looking for easy algorithms to do such computation. There are faster
    schemes, but the cordic is the easiest. It is an indispensable tool. It
    is way more valuable than just sine/cosine computation. It was the heart
    of many m-ary DPSK demod schemes we integrated.

    You can be sloppy on board level designs, but you need to be efficient
    in chips, especially mixed-mode where the transistors are not fine geometry.
     
  12. josephkk

    josephkk Guest

    By a bit, it predates the old 8087 math coprocessor.

    ?-)
     
  13. josephkk

    josephkk Guest

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

-