What is the fastest (I do not mean most convenient) way to scale accelerometer readings to represent radians?
Some sort of table lookup - I presume you are talking about a stationary accelerometer measuring tilt w.r.t. gravity here.
Yes that's correct. I was using a function, but it uses FP math. Of course that is not the most time efficient method of calculation, so I was wondering if there is an alternative means of execution.
Lookup table is definitely fastest, but it would have to be massive -- with 25k of memory (32K PROGMEM minus about a 7k program), that's only 29 values in each dimension (x,y,z) -- that's terrible resolution. And that's assuming the result is 1 byte, and if you want another three dimensions out of it you'll only have 2 or 3 bits per dimension. You could go for 23 values per dimension to get a two byte output, which would be 5 bytes per dimension.
You can also use Taylor series methods to approximate the trig functions.
I decided to go with a memory efficient version of the map() function:
uint8_t mapAccel (uint8_t x, uint8_t in_min, uint8_t in_max, uint8_t out_min, uint8_t out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
I scaled the values to g-force * 10.