Go to Post The worst that happens is we try our best and lose. And there's no shame in that. - pfreivald [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-05-2007, 19:13
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
trig

does anybody know the trigonometry code? is there a math.h file in mplab?
__________________


  #2   Spotlight this post!  
Unread 03-05-2007, 19:16
seanl's Avatar
seanl seanl is offline
"The Everything person"
FRC #0867 (Absolute Value)
Team Role: Leadership
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Arcadia, CA
Posts: 267
seanl will become famous soon enoughseanl will become famous soon enough
Re: trig

im not sure but did you try
#inculde<math.h>
at the top
__________________
, Sean

TEAM 867
-electrical
-pneumatics
-programming



2008 Autodesk Visualization Grand Prize Winner
  #3   Spotlight this post!  
Unread 03-05-2007, 19:21
lukevanoort lukevanoort is offline
in between teams
AKA: Luke Van Oort
no team
 
Join Date: Oct 2005
Rookie Year: 2005
Location: Waterloo, ON, Canada
Posts: 1,873
lukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond repute
Send a message via AIM to lukevanoort
Re: trig

Yes, there is a math.h. However, use it with caution, the RC is notorious for bogging down on complex mathematics, especially floating point operations. A good workaround is the trig lookup tables in stored in the microcontroller's eeprom, which Kevin Watson has already written code to do. (linked to here)
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain
  #4   Spotlight this post!  
Unread 07-05-2007, 13:13
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
Re: trig

the only problem is that kevin's code only does sine and cosine. we need inverse tangent, though. any suggestions? and does anyone have the functions created to do this?
__________________


  #5   Spotlight this post!  
Unread 07-05-2007, 13:58
Stephen Kowski's Avatar
Stephen Kowski Stephen Kowski is offline
BSEE, MSEE, JD
AKA: employed
no team
Team Role: Alumni
 
Join Date: Jun 2001
Rookie Year: 2000
Location: Saint Petersburg, FL
Posts: 1,144
Stephen Kowski has a reputation beyond reputeStephen Kowski has a reputation beyond reputeStephen Kowski has a reputation beyond reputeStephen Kowski has a reputation beyond reputeStephen Kowski has a reputation beyond reputeStephen Kowski has a reputation beyond reputeStephen Kowski has a reputation beyond reputeStephen Kowski has a reputation beyond reputeStephen Kowski has a reputation beyond reputeStephen Kowski has a reputation beyond reputeStephen Kowski has a reputation beyond repute
Send a message via AIM to Stephen Kowski
Re: trig

there used to be some code floating around for it that was develop by a team a few years back to be able to do floating point math.....kinda.....ill see if i can find it again, or maybe some nice person will post a link

[EDIT] found it http://www.chiefdelphi.com/media/papers/1575 [/EDIT]

hope it helps....i don't like to mess with trig on this hardware, but this made life a little easier....

Last edited by Stephen Kowski : 07-05-2007 at 14:02.
  #6   Spotlight this post!  
Unread 07-05-2007, 14:28
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
Re: trig

thank you thank you thank you....thats EXACTLY whal i was looking for!!!!!!!!
__________________


  #7   Spotlight this post!  
Unread 07-05-2007, 16:15
newton418's Avatar
newton418 newton418 is offline
Registered User
AKA: Ryan Newton
FRC #0418 (Purple Haze)
Team Role: Driver
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Austin, Texas
Posts: 58
newton418 is a name known to allnewton418 is a name known to allnewton418 is a name known to allnewton418 is a name known to allnewton418 is a name known to allnewton418 is a name known to all
Re: trig

You can also approximation trig functions using a finite number of terms from the Taylor series.

For instance, arctan(x) is approximately equal to X - X^3/3 + X^5/5 - X^7/7
When -1<X<1

I'm not a coder, so I don't know what you’re trying to do, but from what I do understand about code, a Taylor series approximation should be fairly easy to implement.
__________________
Team 418 Purple Haze
http://www.lasarobotics.org/
  #8   Spotlight this post!  
Unread 07-05-2007, 16:39
lukevanoort lukevanoort is offline
in between teams
AKA: Luke Van Oort
no team
 
Join Date: Oct 2005
Rookie Year: 2005
Location: Waterloo, ON, Canada
Posts: 1,873
lukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond repute
Send a message via AIM to lukevanoort
Re: trig

Quote:
Originally Posted by newton418 View Post
You can also approximation trig functions using a finite number of terms from the Taylor series.

For instance, arctan(x) is approximately equal to X - X^3/3 + X^5/5 - X^7/7
When -1<X<1

I'm not a coder, so I don't know what you’re trying to do, but from what I do understand about code, a Taylor series approximation should be fairly easy to implement.
Just to elaborate for those who haven't had second semester Calculus (BC Calc), a Taylor series is a mathematical construct that consists of a sequence of terms (often infinitely long), the sum of which approaches, know as converging at, a value equal to the value of the function used to generate the series. Taylor series are "centered" at a value and the points for which they converge to the correct number surround this value, in the above example, the series is centered at x=0 and the Taylor series converges from -1<x<1. Anyway, Taylor series allow you to use relatively simple polynomials to calculate rather difficult problems, like sin(.3245212432) to almost degree of accuracy that you desire, simply by varying the number of terms. This is actually how your calculator calculates trig functions, as it is rather hard to do straight up.
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain
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 Lookup Table michniewski Programming 6 23-02-2007 20:57
Trig problems revolution1737 Programming 8 19-02-2006 01:09
No Trig? The Lucas Programming 1 15-01-2004 04:07
Trig archiver 2001 4 23-06-2002 23:14
Inverse Trig K. Skontrianos Programming 6 13-03-2002 23:27


All times are GMT -5. The time now is 00:20.

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