1. ## CORDIC for dummies

Hey guys (and gals), way back in the SX days I got interested in CORDIC. And since Chip said the Propeller 2 would have a CORDIC engine, I thought I would create a tutorial explaining how CORDIC works.

When I started I had NO idea how the stuff worked, and it took quite a bit of experimenting until I was satisfied that I understood it. In the process I kept some notes. These notes have been expanded into this tutorial. It is still a work in progress, but I didn't want to get too far along if it doesn't make sense so far.

If you are interested in CORDIC and have a couple of minutes would you please read though this and give me your comments and suggestions.

Hopefully I'll have something worthwhile by the time the P2 comes out.

Thanks,

Bean

 I have fixed the math for the example at the end. It makes sense now.
I have updated the PDF.
I have updated the PDF again Nov 22, 2010
I have updated the PDF again Nov 23, 2010

2. ## Re: CORDIC for dummies

Bean that was some very nice explanation you wrote there, and the best of it was that it was machine/implementation agnostic. I'd complement it with some nice code, add the "bring to range" part and ship it.

Miss-spelling "Since we want to find degrees, instead of simply adding and subtraction a value"

Should be "Since we want to find degrees, instead of simply adding and subtracting a value"

great work !

3. ## Re: CORDIC for dummies

Bean,

First off, before reading this, I wasn't familiar with CORDIC at all. I think I understand it now after reading this doc, so thanks. Below are my thoughts while reading the document.

The first page is describing a binary search. In fact, the whole thing is just binary searching in different "spaces".

The last two pages use << (shift up), but shouldn't it be >> (shift down) instead? Since you are multiplying by 0.5, 0.25, 0.125, etc.. that is actually divide by 2, 4, 8, etc. Which means you want shift down, not shift up. Maybe I missed something?

Also, on the last page you say:
X = 262 (223.607 is the real radius, so we scale by 0.85346 for any points)
Is that scaling factor really valid for any input values of X,Y? Or is it just close enough to be "good enough"?

4. ## Re: CORDIC for dummies

@Roy, Yeah, you're right that should be >> instead of <<. And yes, that scale is for ANY point as long as you do the same number of loops.

One thing I thought when X=2*Y that was a 30 degree angle, but ATAN(0.5) gives 26.565 ???

Or is a 30 degree angle when the hyp is 2*X ???

Anyway I will go through all the math before I finalize it and make sure it is all correct.

I also want to make some graphs and maybe even a propeller TV demo showing the process.

Bean

5. ## Re: CORDIC for dummies

Excellent explanation of Cordic. I was aware of the technique, but not the name. I thought of it as a form of binary search. It is applicable to solving a wide range of calculations/problems.

6. ## Re: CORDIC for dummies

I have found that I have a wrong sign in the math for the final forumla and example.
I will fix them and re-post.

Bean

7. ## Re: CORDIC for dummies

Okay, I fixed the math and reposted it.

Thanks for the comments so far.

Bean

8. ## Re: CORDIC for dummies

Great post Bean

9. ## Re: CORDIC for dummies

I first encountered Cordic in Beau Schwabe's HM55B object and never did understand it even after reading several papers I found on the web. Mostly because my math education was 40 years ago. I was however able to lift it from that object and and use it in the navigation code of a robot I created even if I didn't understand it. After reading this - I get it!! -- Your paper here is clear consice and completely understandable well done!!

I humbly offer here my Trig object with thanks to both you and Beau

10. ## Re: CORDIC for dummies

Bean,

That's great, thank you.

Do you think you could do a work like that on the Fast Fourier Transform? The workings of which have avoided lodging in my brain for decades now

11. ## Re: CORDIC for dummies

Nice explanation. If also me, with my bad English, have get it that mean you have done an excellent job.

12. ## Re: CORDIC for dummies

Bean,

That makes it just too easy!

All I knew about CORDIC was that it's a way of doing math with a microcontroller.

Is anyone out there writing a PASM book? If there isn't one in the works, you should take it up. Your CORDIC tutorial was very easy to understand. I feel like I'm starting to understand PASM myself but I sure wish I had a nice tutorial to follow.

I'd be very interested in any other tutorials you create.

Thank you,

Duane Degn

13. ## Re: CORDIC for dummies

Bean,

Read the new version, and I noticed that you fixed the <<'s to be >>'s on page 6, but on page 5 it's still got them ad <<'s. Other then that, it looks great.

14. ## Re: CORDIC for dummies

Wow, Bean, very cool! Once the laity sees this, the high priests will be out of a job!

-Phil

15. ## Re: CORDIC for dummies

Roy, Thanks for catching that.

I just fixed it and added a bit of a explaination and graph on the first page. Reposted just now.

Bean

16. ## Re: CORDIC for dummies

Hi, great. Maybe you could add in the first "guessing", that this is called successive approximation and just the way a SAR-ADC is working. That would give another link. The method is also known from math to determine the zero crossing of a functions graph.

17. ## Re: CORDIC for dummies

This is excellent work. Even I could understand it.

My only comment will be to re-consider the unfortunate title.

"CORDIC for Beginners" or similar would have much less negative connotation than "dummies".

The "for dummies" series has a negative connotation from, of course, the words dummies, and from its use in media by character that demonstrate stupidity after glancing at one on the books. In real life, the "Brain Surgery for Dummies" book proved to be a total rip-off, the subject did not show any measurable improvement before expiring.

Otherwise it great.

Do you do educational stuff professionally?

18. ## Re: CORDIC for dummies

prof_braino,

Some years ago I may have had the same objection to the use of "dummies" in the title. But the "bla bla for Dummies" thing is part of the culture now and one knows what to expect when one sees it. In most part due to the series of books I guess.

Also in this case I think it fits better than other alternatives. such as "Introduction to...." or "...for beginners."

Why is that?

Well if you are a beginner there are already pages for you on wikipedia and other places.

They for beginners and are quite fine but boom, you are immediately hit in the face with matrix notation and other such things that get in the way for dummies, err I mean, the mathematically uninitiated.

This document demonstrates my long held belief that there are many brilliant but ultimately simple concepts in mathematics that almost anyone could understand if they could be presented in such a way as to avoid the blindness and confusion brought on by the symbols of mathematics itself.

For example, the way it is possible in calculus to divide zero by zero and get a meaningful result, the slope of a line.

19. ## Re: CORDIC for dummies

Bean:

awesome stuff! and I hate math ;-)

on page 6:
Continuing on, the angle would be for 0.25, turns out to be 14.03624347

I assume something like:
Continuing on, we calculate what the angle would be for 0.25, which turns out to be 14.blahblah

20. ## Re: CORDIC for dummies

I second that. I'm taking communications theory course that should be renamed 'Fourier, Fourier, and more Fourier', yet even the the textbook doesn't try to explain FFT. No matter how many times I read up on it, I just don't get it.

Originally Posted by Heater.
Bean,
Do you think you could do a work like that on the Fast Fourier Transform? The workings of which have avoided lodging in my brain for decades now