Log in

View Full Version : HELP: How do i make Arcsin in MPLAB


Tottanka
14-02-2007, 11:20
Hey
An important question for our team:
How do i make arcsin in MPlab, not using a 1 to 180 loop checking every angle and finding the closest one to the value i need?

thanks, the Black Knights

Shinigami2057
14-02-2007, 11:57
Should be in <math.h>.


#include <math.h>

double asin(double x);
float asinf(float x);

efoote868
14-02-2007, 12:18
you could make a lookup table... a large array usually can do the trick. It'll save you the processing power from not using a double, but it'll eat up memory pretty quickly.

Guy Davidson
14-02-2007, 12:28
I would try and google arcsin approximation and find one that only involves rational expressions, to limit the amount of floating point math.

Jared Russell
14-02-2007, 17:48
There was a whitepaper on Delphi a couple years ago about CORDIC trig implementations...you should look it up.

Cheezmeister
15-02-2007, 15:22
Should be in <math.h>.


#include <math.h>

double asin(double x);
float asinf(float x);


You don't know how long we were pulling our hair out last year because it couldn't parse "arcsin(x)" (not to mention me repeatedly telling others that "1/sin(x)" would NOT do it) ;D

aaeamdar
15-02-2007, 15:33
You don't know how long we were pulling our hair out last year because it couldn't parse "arcsin(x)" (not to mention me repeatedly telling others that "1/sin(x)" would NOT do it) ;D

This is humerous, but likely the result of what I am informed is another case of poor american practice (or practise). arcsin is usually written sin^(-1), and this can cause confusions, since x^(-1) would in fact equal 1/x. However, in the case of sin^(-1) (and other inverse trig operations), it just means arcsin.

I could be wrong about the fact that it's american in origin, but I imagine that's the root of your problem.

Paul

fallen751
15-02-2007, 15:39
If your range of data is within a pretty reasonable small area like (0, pi/2) you could try doing a fifth or sixth degree taylor polynominal instead - it might help with the processing power. then again, if your not performing many other calculations the arctanx function should work fine. (remember it returns radians.)