Here's a useful "DSP Trick" that is sure to come in handy one day.
A couple of weeks ago, a reader was asking if we knew where to find a spreadsheet that could generate "quick-and-dirty" (or "cheap-and-cheerful") sin and cos values.
Well, the same reader has come across a rather useful website called DSP Guru (www.DSPguru.com). On this site, he discovered an algorithm for the simultaneous parabolic approximation of sin and cos values:
As the author of the algorithm, Olli Niemitalo, says: "When you need both sin and cos at the same time, and you need them fast, and using multiplications and parabolic approximation is OK, then try this...
The advantages are that it's 'cheap' with only one or two multiplies per approximation pair and there are no discontinuities.
Possible applications are audio panning, mixing fader, maybe even real-time filter coefficient calculations and 2D/3D rotation transformations."
Now, this algorithm does require a multiplication (x*x), which is a bit of a pain, but all in all this seems like quite a useful "DSP Trick" that I'm sure will come in handy one day.
But wait, there's more, because I just spent a few minutes bouncing around the DSP Guru website, and what did I find but a spreadsheet version of the CORDIC algorithm for sin and cos values:
The CORDIC algorithm does require multiplication, but the "multiplies" can all be powers of 2. This means that they can be performed using shifts and adds in binary, which is "cool beans" whichever way you look at it...
Questions? Comments? Feel free to email me – Clive "Max" Maxfield – at firstname.lastname@example.org). And, of course, if you haven't already done so, don't forget to Sign Up for our weekly Programmable Logic DesignLine Newsletter.