# Lookup Tables

Details Message
Author
Marcus Smith
Posted
13-Mar-2003 21:01 GMT
Toolset
C51
Lookup Tables
Hello,
I am writing a program that has to multiply the incoming DAC data on the ADuC812 8051 by a sixth order polynomial equation. I was wondering if anyone had any information regarding using look up tables or any good sites as I have not found the internet useful.
As I have to multiply the equation by possibly 4096 steps is there a way to cut down on the possible number of values?

Thank you,
Marcus
Author
Andrew Neil
Posted
13-Mar-2003 22:52 GMT
Toolset
C51
RE: Lookup Tables
mathematically, you are trying to compute y = f(x);
a lookup table implementation simply treats this as
`y = f[x];`
You can easily compute the values for the elements of the array f (ie, the lookup table entries) using Excel or similar.
Author
Hans-Bernhard Broeker
Posted
14-Mar-2003 13:00 GMT
Toolset
C51
RE: Lookup Tables
Your usage of the word "multiply" seems strange. You don't usually multiply a number by an equation. Feels like what you actually is you want to evaluate that 6th order polynomial for each of your input values.

On an 8051, this indeed will benefit a lot from a precomputed table, if you can afford the memory space that will consume.

If you can't afford a full-size table, interpolate linearly in a smaller one. In C, using a table of 256 entries to interpolate for 4096 values:

```ix = x >> 4;
rx = x & (1 << 4 - 1);
return (  table[ix]   * (1<<4 - ix)
+ table[ix+1] *     ix     )  >> 4;
```

The '4' in there is log2(4096/256).

For more sophisticated interpolation, you may have to generate a non-evenly spaced table, and search for the right place in that before you interpolate.
Author
Andrew Neil
Posted
14-Mar-2003 13:39 GMT
Toolset
C51
RE: Lookup Tables
"For more sophisticated interpolation, you may have to generate a non-evenly spaced table, and search for the right place in that before you interpolate."

Sounds like the old "Differences" column in 4-figure log tables...
Author
Drew Davis
Posted
14-Mar-2003 18:08 GMT
Toolset
C51
RE: Lookup Tables
Depending on your equation, you also might be able to factor it into a combination of several smaller lookup tables, saving memory at the cost of more computation to combine the partial results.

##### Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.