Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sine Table Interpolation

I want to put together a SDR system that tunes initially AM, later FM etc. The system I am planning to use to do this will have a sine lookup table for Direct Digital Synthesis (DDS). In order to tune properly I expect to need to be able to precisely control the frequency of the sine wave fed to the Mixer (multiplier in this case). I expect that linear interpolation will be close, but think a non-linear method will provide better results.

What is a good and fast interpolation method to use for sine tables. Multiplication and addition are cheap on the target system; division is costly.

Edit: I am planning on implementing constants with multiply/shift functions to normalize the constants to scaled integers. Intermediate values will use wide adds, and multiplies will use 18 or 17 bits. Floating point "pre-computation" can be used, but not on the target platform. When I say "division is costly" I mean that it has to implemented using the multipliers and a lot of code. It's not unthinkable, but should be avoided. However, true floating point IEEE methods would take a significant amount of resources on this platform, as well as a custom implementation.

Any SDR experiences would be helpful.

like image 507
NoMoreZealots Avatar asked Jul 10 '26 14:07

NoMoreZealots


2 Answers

If you don't get very good results with linear interpolation you can try the trigonometric relations.

Sum and Difference Formulas

sin(A+B)=sinA*cosB + cosA*sinB
sin(A-B)=sinA*cosB - cosA*sinB
cos(A+B)=cosA*cosB - sinA*sinB
cos(A-B)=cosA*cosB + sinA*sinB

and you can have precalculated sin and cos values for A, B ranges, ie

A range: 0, 10, 20, ... 90
B range: 0.01 ... 0.99
like image 115
Nick Dandoulakis Avatar answered Jul 14 '26 03:07

Nick Dandoulakis


table interpolation for smooth functions = ick hurl bleah. IMHO I would only use table interpolation on some really weird function, or where you absolutely needed to ensure you avoid discontinuities (note that the derivatives for interpolated tables are discontinuous though). By the time you finish doing table lookups and the required interpolation code, you could have already evaluated a polynomial or two, at least if multiplication doesn't cause you too much heartburn.

IMHO you're much better off using Chebyshev approximation for each segment (e.g. -90 to +90 degrees, or -45 to +45 degrees, and then other segments of the same width) of the sine waveform, and picking the minimum degree polynomial that reduces your error to a desired value. If the segment is small enough you could get away with a quadratic or maybe even a linear polynomial; there's tradeoffs between accuracy, and # of segments, and degree of polynomial.

See my post in this other question, it'll save you the trouble of calculating coefficients (at least if you believe my math).

(edit: in case this wasn't clear, you do the Chebyshev approximation at design-time on your favorite high-powered PC, so that at run-time you can use a dirtbag microcontroller or FPGA or whatever with a simple polynomial of degree 1-4. Don't go over degree 4 unless you know what you're doing, 3 or below would be better.)

like image 20
Jason S Avatar answered Jul 14 '26 02:07

Jason S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!