microsoftwarecontrol wrote: > there should be much faster math solution, with enough accuracy, for > this equation I just realized I copied the equation incorrectly in the previous post. The part inside the square root has to be divided by Vo, not multiplied by it. The correct equation is: T1 = SQRT(K * (Vo - Vin) / Vo) The subtract, multiply, and divide aren't too bad. A dsPIC can do the subtract and multiply in single cycles and the divide in 18 cycles. The square root takes a software loop, and therefore dominates. Unrolling the loop should yield a little gain. Square roots don't lend themselves well to series expansion of the type a dsPIC can compute faster than it can to the loops. I had this running on a very early 30F2010 that could only go 1/3 of its design speed and still had a switching frequency of 25KHz. That means with a real 30F2010, 75KHz switching speed should be attainable with the same code. I was trying to prove the concept, and 25KHz was fine for that. Some tweaking is warranted in a real application. What optimizations specifically do you suggest? ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist