16bit Linear Interpolation full

Started by Eirik Karlsen October 31, 2004
Have just made a routine that do linear interpolation of 16bit table
entries, but I'm not fully happy with it.
The task:
10bit (16bit) ADC sensordata is linearized using a 32 entry 16bit lookup

table, but it is a bit rough
so interpolation is needed. The actual ADC range is 286-594 so the
interpolation would allow for
about 10 times better resolution (10 values between each table entry).
--
Some more information:

I'm using the following interpolation equation, it is easily implemented
in the PIC18 and it works great.
y = y0 + (((y1 - y0) / (x1 - x0))) * (x - x0)
y0 x0 is previous tableentry, y1 x1 is next tableentry, x is present
data, y is interpolated data.

The only problem is that I have to trap y0 x0 and y1 x1, and to do that
I have to keep track of the
direction the signal is moving....obviously doable but isn't there a
simpler or better way?
--
Any ideas or suggestions?
Code examples?

--
*******************************************
VISIT MY HOME PAGE:
<http://home.online.no/~eikarlse/index.htm>
LAST UPDATED: 23/08/2003
*******************************************
Regards
Eirik Karlsen



I just cracked it. Works perfect now.
 

Eirik Karlsen wrote:

Have just made a routine that do linear interpolation of 16bit table
entries, but I'm not fully happy with it.
The task:
10bit (16bit) ADC sensordata is linearized using a 32 entry 16bit lookup

table, but it is a bit  rough
so interpolation is needed. The actual ADC range is 286-594 so the
interpolation would allow for
about 10 times better resolution (10 values between each table entry).
--
Some more information:

I'm using the following interpolation equation, it is easily implemented
in the PIC18 and it works great.
y = y0 + (((y1 - y0) / (x1 - x0))) * (x - x0)
y0 x0 is previous tableentry, y1 x1 is next tableentry, x is present
data, y is interpolated data.

The only problem is that I have to trap y0 x0 and y1 x1, and to do that
I have to keep track of the
direction the signal is moving....obviously doable but isn't there a
simpler or better way?
--
Any ideas or suggestions?
Code examples?

--
*******************************************
VISIT MY HOME PAGE:
<http://home.online.no/~eikarlse/index.htm>
LAST UPDATED: 23/08/2003
*******************************************
Regards
Eirik Karlsen
 
 
 

to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
 

--
*******************************************
VISIT MY HOME PAGE:
<http://home.online.no/~eikarlse/index.htm>
LAST UPDATED: 23/08/2003
*******************************************
Regards
Eirik Karlsen
 

Attachment (not stored)
C:\DOCUME~1\ek\LOKALE~1\Temp\nsmailIL.gif
Type: image/gif

Attachment (not stored)
C:\DOCUME~1\ek\LOKALE~1\Temp\nsmail6O.gif
Type: image/gif


Excellent. I think you have the right formula, and the direction(or
signs) are already there.

Chad

--- Eirik Karlsen <> wrote:

> I just cracked it. Works perfect now. > Eirik Karlsen wrote:
>
> > Have just made a routine that do linear interpolation of 16bit
> table
> > entries, but I'm not fully happy with it.
> > The task:
> > 10bit (16bit) ADC sensordata is linearized using a 32 entry 16bit
> > lookup
> >
> > table, but it is a bit rough
> > so interpolation is needed. The actual ADC range is 286-594 so the
> > interpolation would allow for
> > about 10 times better resolution (10 values between each table
> entry).
> >
> > --
> > Some more information:
> >
> > I'm using the following interpolation equation, it is easily
> > implemented
> > in the PIC18 and it works great.
> > y = y0 + (((y1 - y0) / (x1 - x0))) * (x - x0)
> > y0 x0 is previous tableentry, y1 x1 is next tableentry, x is
> present
> > data, y is interpolated data.
> >
> > The only problem is that I have to trap y0 x0 and y1 x1, and to do
> > that
> > I have to keep track of the
> > direction the signal is moving....obviously doable but isn't there
> a
> > simpler or better way?
> > --
> > Any ideas or suggestions?
> > Code examples?
> >
> > --
> > *******************************************
> > VISIT MY HOME PAGE:
> > <http://home.online.no/~eikarlse/index.htm>
> > LAST UPDATED: 23/08/2003
> > *******************************************
> > Regards
> > Eirik Karlsen
> >
> >
> >
> >
> > to unsubscribe, go to http://www.yahoogroups.com and follow the
> > instructions
> >
> >
> >
> [click here]
>
> >
> > ---------------------------
> > Yahoo! Groups Links
> >
> > * To
> >
> --
> *******************************************
> VISIT MY HOME PAGE:
> <http://home.online.no/~eikarlse/index.htm>
> LAST UPDATED: 23/08/2003
> *******************************************
> Regards
> Eirik Karlsen


=====
My software has no bugs, only undocumented features.

__________________________________________________