Go to Post There are 1,450 schools in my district. Needless to say not all of them have teams..yet. - Scott Carpman [more]
Home
Go Back   Chief Delphi > ChiefDelphi.com Website > Extra Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-07-2007, 21:08
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,131
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
paper: CORDIC Trigonometric Math Library

Thread created automatically to discuss a document in CD-Media.

CORDIC Trigonometric Math Library by Pat Fairbank
Reply With Quote
  #2   Spotlight this post!  
Unread 25-07-2007, 21:10
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,131
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
Re: paper: CORDIC Trigonometric Math Library

I felt like doing some programming, so I updated the CORDIC math library I posted a few years ago.

I made a few changes such as returning both the sine and cosine values instead of throwing one away (since CORDIC calculates both at once), and downgrading from 24-bit math to 16-bit math in the interest of speed. However, the biggest change is that the library is now written in PIC assembly instead of C, since I was curious to see if there was any speed advantage to be had.

I did some speed testing by calling the function as many times as possible in one Process_Data_From_Master_uP() loop before the RC crashed. The assembly implementation of the sin_cos() function took 4500 calls to crash while the C implementation took 1800 calls; the atan2_sqrt() function took 4700 and 1900, respectively. So it seems that the assembly implementation is about 2.5 times faster than the C implementation.

Any questions or comments are welcome.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com
Reply With Quote
  #3   Spotlight this post!  
Unread 22-01-2008, 22:00
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,131
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
Re: paper: CORDIC Trigonometric Math Library

I just uploaded a second revision to the trig library. There was a bug in the way the previous versions were handling the C function calls in assembly - the software stack wasn't being manipulated properly, with the result that the trig functions would work as expected when called from a function that didn't have local variables, but would return strange values when called from a function that did.

So if you're using the library and are seeing strange return values, you probably have an older version and need to update to Revision 2.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2008, 00:15
comphappy comphappy is offline
Registered User
AKA: Brennan Ashton
FRC #2605 (A2D_16)
Team Role: Leadership
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Bellingham, WA
Posts: 157
comphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to behold
Send a message via AIM to comphappy
Re: paper: CORDIC Trigonometric Math Library

EDIT: Ignore this post, I can not delete it
__________________
A2D Solving the Imaginary Error Function...

Last edited by comphappy : 09-02-2008 at 00:50. Reason: Issue turned out to be non related
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2008, 00:54
neutrino15's Avatar
neutrino15 neutrino15 is offline
plɹoʍ ollǝɥ
AKA: Jordan Perr
FRC #0694 (Stuypulse)
 
Join Date: Feb 2007
Rookie Year: 2007
Location: New York City
Posts: 162
neutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really nice
Re: paper: CORDIC Trigonometric Math Library

What is the advantage to using this vs a lookup table to the desired degree of accuracy?

How much more accurate and slow is the built in <math.h>?
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2008, 01:11
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Re: paper: CORDIC Trigonometric Math Library

Quote:
Originally Posted by neutrino15 View Post
What is the advantage to using this vs a lookup table to the desired degree of accuracy?

How much more accurate and slow is the built in <math.h>?
Well, the math.h implementation can be called ~100 times per second (speed test that was posted on CD at some point this month), and this function takes a half second for 4500 calls (a half second being the max time a loop can execute before the OI says it 'crashed')

so id say its about... 90x faster?

someone call me on this if my math is wrong.
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2008, 01:36
comphappy comphappy is offline
Registered User
AKA: Brennan Ashton
FRC #2605 (A2D_16)
Team Role: Leadership
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Bellingham, WA
Posts: 157
comphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to behold
Send a message via AIM to comphappy
Re: paper: CORDIC Trigonometric Math Library

Ok i just found out what is needed to get this code to compile with the new 3.02 or higher compiler,
you need to replace all instances of AARGB3 with the new definition of __AARGB3
you can see the reference to this naming change here:
http://ww1.microchip.com/downloads/e...03-README.html
ref (27624)
__________________
A2D Solving the Imaginary Error Function...

Last edited by comphappy : 09-02-2008 at 02:30.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming Trigonometric Functions Dan894 Programming 4 14-02-2006 20:27
Cordic functions... Zalumaskov Programming 1 13-02-2005 00:58
Trigonometric related equations nb45ti Math and Science 4 20-07-2004 18:53
White Paper Discuss: 296's CORDIC Math Library CD47-Bot Extra Discussion 5 28-04-2004 20:01
math.h library mightywombat Programming 24 17-01-2004 13:10


All times are GMT -5. The time now is 01:10.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi