Usefulness of Floating Point Math Co-Processors
Prophead100
Posts: 192
I have some floating point heavy math code on the Prop that uses a lot of trigonometry functions such as tan,atan, sin, asin, cos, acos and some basic multiplication/division and addition/substraction. It works OK with the current OBEX objects but I would like to substantially speed up some 32 bit math in SPIN and perhaps upgrade to 64 bit math in SPIN or GCC if possible so I can squeeze in more performance.
Has anyone had experience using the uM-FPU 32 or uM-FPU64 coprocessors to speed up the calculations? Do these co-processors when used with the Prop makeup for the overhead of communicating with an external chip?
Has anyone had experience using the uM-FPU 32 or uM-FPU64 coprocessors to speed up the calculations? Do these co-processors when used with the Prop makeup for the overhead of communicating with an external chip?
Comments
How much precision do you require?
And what is the application?
Duane J
I was pleasently surprised I was able to compute the IK positions of all 18 servos at 50Hz for my hexapod using F32.
If you need 64 bit math, then I think the uM-FPU64 chip would be worth using.
I think cessnapilot wrote objects for both the FPU chips.
I am also working on using a higher precision formula (+/- 0.003 degree) for a concentrating solar collector or solar observatory which requires 64 bit math. With help from Jazzed and Heater, some C code from NREL ran well on the Prop using GCC but took a couple hundred seconds with a basic configuration which would be too slower than the speed needed to track the sun in real time at that details (72 ms).
You could also use a Fixed-real approach, where a slower task does the precision calcs, and a faster one just interpolates between what are very short segments.
When I looked at the specs of these co-processors I wasn't impressed - I think they only served to reduce the ROM footprint on the microcontroller! Certainly not in the class of a 387 I believe. If they didn't have a gazillion pins an ARM FP vector co-processor would be handy (single cycle for single-precision on all but divide/sqroot, 2-cycle for double-precision...)
The uM-FPU V3.1 does have 2 analog inputs with 12 bit A/D converter I note...
Maximum Time: 0.417ms
Minimum Time: 0.377ms
Average Time: 0.414ms
Note that, all of the operations are done. IE, there is no optimization of "2 * pi": this is included on the calculations.
This uses one cog to compute without any oversight, and is 32 bit. It supports most of the functionality of F32, but not all:
If needed, you could substitute the routines that you do need (exp, ...) for ones in the list above that you do not need.
Anyway, I was planning on posting the source code for this on the forums sometime. If it looks useful to you then I can do it this weekend.
The ability to program a set of functions into the uFPU may the most effective way short of rewrite a lot of code to optimize it. The GPS parsing would definitely simplify the time and mobile location part of the equation. Perhaps, I could program it to simply output the solar variables as something that goes between the GPS and the Prop for the higher resolution/speed applications where the cost of the chip would be worth it. My only apprehension is learning another programming dialect. For routine lower precision solar tracking the Prop alone could do it at a lower cost. Thanks
SLRM - The code I am trying to optimize is the solar object ( http://obex.parallax.com/objects/807/ ) in SPIN and some NREL code in C++ (Post 15 of this thread --> http://forums.parallax.com/showthread.php?141011-Newbie-C-Syntax-Question).
Mark T. - The latency issue comes in when (a) the higher resolution tracking is needed for a high ratio solar concentrator or solar telescope, (b) where more time is needed in the code for other operations such as process control of the mechanics or (c) mobile as you suggest.