Lec99 - CORDIC algorithm

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ส.ค. 2024
  • Lec99 - CORDIC algorithm

ความคิดเห็น • 36

  • @Chris-hf2sl
    @Chris-hf2sl 26 วันที่ผ่านมา

    I've designed and built a TTL computer (no microprocessor inside) and I'm now writing a maths package for it using 96 bit fixed point arithmetic. Amongst the things I want to add are trig functions. I've watched several videos on the CORDIC algorithm, and all explain the rotation using matrices very well, but then leave out the final vital step of choosing angles whose tan is a negative power of 2. This video explains everything sufficiently well for me to now be able to implement it in my assembler code.
    As a first step, I spent a couple of hours implementing the algorithm in Excel. It works very well and typically gives results very close to the values that Excel gives if you simply ask Excel to compute the cos or sin of the chosen angle directly. By 'very close', I mean that the error is typically 10^-8 after about a dozen iterations, falling to 10^-12 or better after 35 iterations.
    The one problem that I encountered is with the Excel 'sign()' function that I used to determine whether to add or subtract successive angles. If the error is zero, the sign() function returns 0 instead of either +1 or -1. This messes up the matrix multiplication leading to an erroneous result. At first, I thought the solution would be to stop the iteration immediately, but that doesn't work because the product of all the cos values assumes a full set of iterations, and if you stop the iterations early, the 'constant' multiplier needs to be different.
    The solution appears to be to add a very small error to the initial angle value. For example, when computing cos(45) or sin(45), instead, compute cos(45.000000000001) or sin(45.0000000000001). Everything then works fine and the resultant error in the result is lost in the noise.

  • @cleansebob1
    @cleansebob1 4 ปีที่แล้ว +6

    This is the best explanation of CORDIC that I have ever seen! On an electronic "blue-line", no less!!!

  • @L1ffs
    @L1ffs 4 ปีที่แล้ว +6

    Finally a comprehensive explanation about CORDIC... thanks (from Brazil). :)

  • @yum33333
    @yum33333 4 ปีที่แล้ว +17

    0:00 - 7:00 = explanation of non-CORDIC methods
    7:00 - 20:00 = polar binary search
    29:00 = wow, right shifts
    34:50 = precompute

  • @joshuacoppersmith
    @joshuacoppersmith 4 ปีที่แล้ว +4

    Thank you! An excellent review of an algorithm. Much appreciated.

  • @sudarshanonkar123
    @sudarshanonkar123 3 ปีที่แล้ว +1

    By far the best CORDIC explanation found anywhere on internet

  • @mehdiAbderezai
    @mehdiAbderezai 4 ปีที่แล้ว +5

    Your explanation was better than the one provided at UCLA. namaste

  • @javiercabrera8539
    @javiercabrera8539 ปีที่แล้ว

    You did a great job, I got it even for someone who is new to this. Thank you so much.

  • @zozeme9218
    @zozeme9218 4 ปีที่แล้ว +2

    Clear and understandable explanation. Thank you!

  • @piyushsarangi730
    @piyushsarangi730 8 หลายเดือนก่อน

    One of the best explanations on this topic. Thank you sir.

  • @zaitarh
    @zaitarh 3 ปีที่แล้ว +1

    Very good explanation of CORDIC! Well presented and easy to understand. Thank you!
    (Thinking of perhaps using this on an old computer without mul/div instructions and with very little ram (so no room for large lookup tables))

  • @johnwilson3918
    @johnwilson3918 4 ปีที่แล้ว

    Thank you very much. The cumulative product of COS values comes to ~0.6072593408 (assuming you're using the angles which give you powers of two for the TAN components). Since you are using these particular TAN values to use shift operations, isn't the fact you're left with a final (single) multiply , disappointing?
    You can express the product of the COS values by a sum of powers of two. This way you still only use shifts and adds (with sign comparisons).
    In Python terms -
    og = 0.6072529350088814
    tol = 0.0001 #3 dp
    print("Overall Cos Gain",og, "Tolerance required",tol)
    for i in range(0,128):
    m = 1.0 / (1 1) + (Xn >> 4) + (Xn >> 5) + (Xn >> 7) + (Xn >> 8) + (Xn >> 10) + (Xn >> 11) + (Xn >> 12)
    Yg = (Yn >> 1) + (Yn >> 4) + (Yn >> 5) + (Yn >> 7) + (Yn >> 8) + (Yn >> 10) + (Yn >> 11) + (Yn >> 12)
    This all seems a bit ugly - so if anyone has any ideas how to improve on this - please give me a shout!

    • @cleansebob1
      @cleansebob1 4 ปีที่แล้ว +1

      I don't see where what you are calling the "final" multiply exists. You start with the precomputed COS value, and either multiply it by 1, or divide it by a power of 2 (shift). What am I missing?

    • @johnwilson3918
      @johnwilson3918 4 ปีที่แล้ว

      ​@@cleansebob1 Yes - Thanks Bob. I had previously left similar posts on other CORDIC videos - but I forgot to add a comment to my original post that I made here.
      When I was going through this process to code in Python (and later Verilog), I was starting the CORDIC iteration process with a UNIT Vector - (eg. (1,0), (-1,0), (0,1) ..) and went through the rotations. So the 'final multiply' I was referring to was the cumulative product of all the COS values. (COS(ATAN))
      It dawned on me a day or so after making this post - that you could avoid the final 'cumulative COS' multiplication by starting with a Vector which has a magnitude which is the inverse of the 'gain' - (~0.607 if you're going through 16+ iterations). So depending on which quadrant your angle is in - you would start with some Vector like (0, -0.607), (0.607, 0), (0, 0.607) etc and go through the 'pseudo rotation' process (the one with just shifts and adds). Since you've missed the COS multiplies in the 'real' Rotation transformation - your starting Vector eventual converge to get a 'gain' of 1/0.607. Meaning that your non unit vector will eventually transform into a unit vector - at the required angle (so long as you went through sufficient number of iterations). Of course the explanation in this video - does tell you to start with an appropriate Vector and go through the appropriate number of iterations so that you end up with SINE and COSINE values. Something I originally missed!
      I now have a working Python and Verilog code which gives accurate SINE and COSINE to 6dp. I'm using it to generate FM audio waves on an iCE40UP5k. I'll put it up on github sometime.

    • @anonymousinfinido2540
      @anonymousinfinido2540 10 หลายเดือนก่อน

      Do you have it on GitHub?

  • @sarangabora4489
    @sarangabora4489 4 ปีที่แล้ว +1

    steps to find the angle given coordinates 15:30
    to rotate a vector by a given angle 21:50
    strength reduction 26:18
    iterations using strength reduction 30:47

  • @qwertykeyboard5901
    @qwertykeyboard5901 3 ปีที่แล้ว +3

    My brain hurts

  • @MJALI96
    @MJALI96 2 ปีที่แล้ว +1

    This algorithm seems to output the angle. So, given an (x,y), we can use this algorithm to find the corresponding angle. But, how can one use this algorithm to find the (x,y) when given sin(angle) or cos(angle)?

    • @Chris-hf2sl
      @Chris-hf2sl 27 วันที่ผ่านมา

      You can use it either way. If you have an angle, 𝚹, and want cos(𝚹) or sin(𝚹), then start with atan(45), which is 1, then either add or subtract atan(26.565...), which is 0.5 etc. Eventually, you home into the desired angle and the final X and Y coordinates are the cosine and sine values (after multiplying by a constant). Alternatively, run the process backwards to work out asin() and acos().

  • @tharunkumar6823
    @tharunkumar6823 3 ปีที่แล้ว +1

    very good explianation

  • @Ali-wf9ef
    @Ali-wf9ef 3 ปีที่แล้ว

    what a great lesson video. thanks

  • @komodowaran_2700
    @komodowaran_2700 4 ปีที่แล้ว +2

    Thank you dude

  • @RenegadeFury
    @RenegadeFury ปีที่แล้ว

    Awesome video, still watching. Unfortunately, I've forgotten all math.
    But at 14:40, how are you getting y' = xsin(45) + ysin(45)
    I thought it would be y' = xsin(45) + ycos(45)

  • @Dennis-er8xc
    @Dennis-er8xc ปีที่แล้ว

    Thanks a lot for help with this. 🤓

  • @AhmedAdel-kg1qu
    @AhmedAdel-kg1qu ปีที่แล้ว

    wooooooooooooooow great work

  • @jasonb111222
    @jasonb111222 3 ปีที่แล้ว

    How were the inverse tangents of ratios 1/2, 1/(2^2),...etc determined originally though I wonder? Just accurate measurements or some series?

  • @Koospa
    @Koospa 3 ปีที่แล้ว

    Great explanation, thank you

  • @xiaoqiang_ca
    @xiaoqiang_ca 3 ปีที่แล้ว

    Good presentation, do you mind sharing the name of the app you are using to take notes?

  • @mohamedtarek3534
    @mohamedtarek3534 ปีที่แล้ว

    You are international bro♥️

  • @jacksonh2083
    @jacksonh2083 2 ปีที่แล้ว

    15:15 (Just marking it for later, it’s the point up to which I’ve watched - it isn’t a special, or important time stamp, so you can click on it if you want, but idk why you would.)

  • @pallabmandal4104
    @pallabmandal4104 3 ปีที่แล้ว

    What is the name of this lecture series?

  • @fabriziodanilo9018
    @fabriziodanilo9018 4 ปีที่แล้ว

    Thank you! What's the pen software being used on this video?