BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 8:24 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Questions about Floating point functions FTAN FSIN FCOS
PostPosted: Thu Jul 07, 2011 7:32 pm 
Offline
Citizen

Joined: Sun Jan 16, 2011 6:22 pm
Posts: 7
The newest manual release describes these functions and I need trig functions so I decided to play around with them.
1) They don't seem to work for angles over 90 degrees; huh??
2) How processor intensive are they? Doesn't the atom pro have a math chip?
3) Are toint and tofloat big cycle suckers?
4) is there a better way to do trig?

Thanks


Top
 Profile  
 
 Post subject: Re: Questions about Floating point functions FTAN FSIN FCOS
PostPosted: Fri Jul 08, 2011 10:53 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
1. Most of the trig functions are limited to PI/2 to -PI/2(eg 180 degrees total, +-90degrees)). You will need to rotate your angles to this range, use the function, and then adjust the result if necessary.

2. Very intensive. No the AtomPro does not have a math chip. No processor I'm aware of in this class range has a math coprocessor or FPU. The AtomPro does have hardware multiply and divides which help plus it does math in 32bit chunks which also helps. In the end it much faster than an Atom or BS2 or PicAXE or PICmicro when it comes to FP but it is still pretty slow. You will see 1k to 2k FP calculations per second when using the trig functions.

3. TOINT and TOFLOAT are not very intensive. They are basically just some bit shifts to convert from an integer to an fp to an integer. Compared to most FP functions they are blazing. :)

4. If you don't need high precision you can use the integer sin and cos functions. These are very low precision since they are 8bit integers representing the values. ANother option is creating lookup tables for specific trig functions. You can make these as small or large as you want, larger having better precision. Then it's just a matter of grabbing a value from the table(eg very fast). THe down side is for high precision you have to create large tables which a) is a pain in the ass and b) takes up flash memory you may want for your actual program.

Just as an example, I've used FP trig functions in several IK routines for hexapod robots and 5 and 6 DOF arm robots. They run very smooth and fast enough I couldn't see any significant slow down compared to integer versions done by other people.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Questions about Floating point functions FTAN FSIN FCOS
PostPosted: Fri Jul 08, 2011 2:47 pm 
Offline
Citizen

Joined: Sun Jan 16, 2011 6:22 pm
Posts: 7
Nathan -
Thanks for the useful feedback. I can live with the 1-2K FP calcs/sec and the +/-90 degree FTAN.
My project requires a .1 degree angle resolution and I've been doing it all with integer math using lookup tables and interpolation code. It uses lots of variable space and it's ugly, ugly code but in the end it works well . These FXXX and FAXXX functions will let me clean things up quite a bit and shouldn't cost me too many more cycles.


Top
 Profile  
 
 Post subject: Re: Questions about Floating point functions FTAN FSIN FCOS
PostPosted: Fri Jul 08, 2011 2:54 pm 
Offline
Master

Joined: Tue Jun 22, 2010 1:15 pm
Posts: 203
Check over on the LM website for Phoenix code, the FSIN, FTAN, FCOS routines are implemented. Also tables for SIN or TAN (I forget).

Alan KM6VV

_________________
Visit:
http://groups.yahoo.com/group/SherlineCNC/
http://tech.groups.yahoo.com/group/HexapodRobotIK/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO