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

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

Should be in <math.h>.

```
#include <math.h>
double asin(double x);
float asinf(float x);
```

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.

I would try and google arcsin approximation and find one that only involves rational expressions, to limit the amount of floating point math.

There was a whitepaper on Delphi a couple years ago about CORDIC trig implementations…you should look it up.

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

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.)