I have built an variable frequency AC induction motor drive controlled by three Arduinos the program(s) do all kinds of things! but seeing how its an hysteresis drive the step time needs to change which requires an inverse Sin originally I had tried to do this online using Maclaurin series but due to all the other things that also need to happen this proved too much so I decided to go with a lookup table pre calculated at boot up
The great news is it now works much better than I expected it to! the bad news is the error from the seriously truncated series however this error only means a faster cycle it doesnt affect the performance just a faster frequency than commanded
So I need to get rid of the series (I don’t need it as I’m offline now) and just do a direct inverse sin which is the reason for the thread!
How can I change my code below and do an inverse sine?
I have read this
double asin ( double __x )
The asin() function computes the principal value of the arc sine of __x. The returned value is in the range [-pi/2, pi/2] radians. A domain error occurs for arguments not in the range [-1, +1].
But I dont understand how to use it!
Heres my code
index = 30;
for(index=30; index<= 30+ NUM/2; index++)
{
X_NEW = ((index-30)/(30));
INV_SIN = X_NEW + (0.166666666*pow(X_NEW, 3)) +(0.075*pow(X_NEW, 5))+
(0.059523809*pow(X_NEW, 7)) +(0.060763888*pow(X_NEW, 9));
T_NEW = (1000000)*(INV_SIN/OMEGA);
INDEX_TIME [index] = T_NEW;
}