Go to Post But then again, no one's robot ever is fully working to how they want it before the first tournamant. - #1Transgirl1140 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-02-2006, 15:45
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,069
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
speed of math.h trig functions?

Hi,

I've always been a proponent of using your own integer-valued CORDIC/table/Taylor series trig functions on the PIC because of the lack of a hardware FPU. I've always been told it's much faster.

The question that is now on my mind is, how much faster? I've noticed a lot of teams this year using the math.h trig functions, floating-points and all.

Has anyone any empirical evidence of the speed difference between the two methods? I might as well use math.h if the difference is small (plus, there would be only a couple of calls per 26ms).
  #2   Spotlight this post!  
Unread 06-02-2006, 15:30
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,069
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: speed of math.h trig functions?

nobody?
  #3   Spotlight this post!  
Unread 06-02-2006, 15:45
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: speed of math.h trig functions?

I don't have specific timing numbers, but considering that each time I go through the user_routine event loop our team's code currently calls

sin() four times
cos() four times
atan2() twice
asin() twice
acos() twice
sqrt() four times

and it runs without problems and without taking up sufficient code space, so I decided it wasn't worth messing with CORDIC functions and called the floating point routines "fast enough".

If I have a chance I'll set up a test loop to compare the methods, but it hasn't been a priority.
  #4   Spotlight this post!  
Unread 06-02-2006, 15:52
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: speed of math.h trig functions?

Jared,

I remember from an earlier version of the compiler (2.2?) that the compiler library source code had estimates of the number of clock cycles for a particular operation to complete. I don't see this information in the current compiler, but I do remember that a floating point multiply/divide statement took an average of 1835 instruction clock cycles (a floating point addition/subtraction was 80). Assuming this information is still semi-valid, you can take a look at the source code for the trig routines in the "C:\mcc18\src\traditional\stdclib" directory to get an estimate of how many of these operations there are for a particular trig routine. Sorry I can't give you any more info than that.

Mike
  #5   Spotlight this post!  
Unread 07-02-2006, 07:13
Denz's Avatar
Denz Denz is offline
Registered User
FRC #0772 (Sabre Bytes Robotics)
Team Role: Programmer
 
Join Date: Jan 2006
Location: LaSalle, Ont, Canada
Posts: 66
Denz is on a distinguished road
Send a message via MSN to Denz
Re: speed of math.h trig functions?

Our is going to be using a squareroot function as well as a tan function. Doesn't slow down too much as of now.
How much do floating point values affect the code though? We used alot of those in finding an accurate distance from the wall.
__________________
www.sabrerobotics.com
Closed Thread


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
Trig functions and type conversion kaszeta Programming 6 14-01-2006 23:34
Math.h header file lacking functions amateurrobotguy Programming 1 26-02-2005 16:25
Math.h and Functions and Variables amateurrobotguy Programming 1 26-02-2005 03:19
Updated: Serial Port Driver Code Kevin Watson Programming 4 05-02-2005 18:39
PID control loops - closed loop feedback KenWittlief Technical Discussion 56 26-04-2004 21:27


All times are GMT -5. The time now is 04:45.

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