Go to Post Fire and smoke are great if you're into Battlebots, but we like to avoid them in FIRST competitions. - [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 16-02-2005, 01:32
the_undefined's Avatar
the_undefined the_undefined is offline
German FES
AKA: Felix Geisendörfer
#1648 (Gearbox Gangstas)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Germany
Posts: 77
the_undefined has a spectacular aura aboutthe_undefined has a spectacular aura about
Sin, Cos, Atan

Hey Guys,

I know that Trig functions on the Controller were discussed a lot and everybody is afraid of using floats and so on. But since I really need to use sin, cos, and atan in order to make our Program work I tried to figure out how to do that the best way.

I would really like to use Team 296's CORDIC Functions but I don't know how to work with 24 bit binary radians nor how to printf() these ...

What would be the easiest way for me to go and how do I Debug whatever you would suggest (if not int, char, or etc.) ...

Thanks for all Help

Felix
  #2   Spotlight this post!  
Unread 16-02-2005, 01:40
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: Sin, Cos, Atan

There are 256 binary radians (also called "brads") to a circle, just as there are 360 degrees to a circle. With this, you should be able to figure out how to convert degrees to brads. Once you have the result from the 296 CORDIC library, I would drop the 8 least significant bits (answer>>=8) and then cast that as an integer. Good luck.
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_
  #3   Spotlight this post!  
Unread 16-02-2005, 02:10
the_undefined's Avatar
the_undefined the_undefined is offline
German FES
AKA: Felix Geisendörfer
#1648 (Gearbox Gangstas)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Germany
Posts: 77
the_undefined has a spectacular aura aboutthe_undefined has a spectacular aura about
Re: Sin, Cos, Atan

Quote:
Originally Posted by jgannon
There are 256 binary radians (also called "brads") to a circle, just as there are 360 degrees to a circle. With this, you should be able to figure out how to convert degrees to brads. Once you have the result from the 296 CORDIC library, I would drop the 8 least significant bits (answer>>=8) and then cast that as an integer. Good luck.
Thanks for your Help but I still have a little problem with that:

When I test it with my function:
Quote:
sin_test(0);
sin_test(127);
sin_test(255);

void sin_test(short long value)
{
short long result; // int p_result, int p_value;

result = sin((short long)value);

result>>=8;
value>>=8;

printf("Sin of %d = %d\n", (int)result, (int)result);
}
I always get 0's back (for value and for result). I tried result>>8 instead but that always gave me value for both (for value and for result) ...

what am I doing wrong?
  #4   Spotlight this post!  
Unread 16-02-2005, 02:32
the_undefined's Avatar
the_undefined the_undefined is offline
German FES
AKA: Felix Geisendörfer
#1648 (Gearbox Gangstas)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Germany
Posts: 77
the_undefined has a spectacular aura aboutthe_undefined has a spectacular aura about
Re: Sin, Cos, Atan

Nevermind my last post I had the typcasting wrong, now it seems to work but I'm still not sure how to convert all this to Degree. What is the maximum degree that you can put into the function, does sin (2^23 / 2) = sin (360) = ? or how does it work ...
Any Idea?

PS: Thanks for your help so far I would have never guessed that : )
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
Inverse Tangent D.Viddy Programming 10 25-01-2003 22:24
Arcsin Calculation Algorithm Leo M Technical Discussion 11 05-11-2001 08:31


All times are GMT -5. The time now is 23:58.

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