cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Anonymous
Not applicable
6,584 Views

Linear interpolation block implementation

Jump to solution

I would like to know what are my choices (if any) in implementing a linear interpolation block using the Xilinx blockset.  Basically, I have a start and end-value of interpolation (x1,y1) and (x2,y2) respectively.  I also know the number of data points between the first and seconds set of coordinates.  I would like to draw a straight line between these 2 points by filling all the samples that lie between them.  Just to be clear, I do not want a "zero-order hold" approach where I hold the last value, but I want to draw a straight line between the points.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Adventurer
Adventurer
7,627 Views
Registered: ‎08-20-2007

u are correct (x2-x1) is a constant value and it is equal to sampling rate of the system (e.g. 1/50ksps = 20us).  If this number is fixed, how do you avoid a division step? 

In this case instead of division you will use multiplication by constant e.g. 1/20µS=50000

 

For example (e.g. x1=2,y1=3,x2=8,y2=27), the equation just equals y2....3+((27-3)/(8-2))*(8-2) = 27.  How does this equation relate to finding the points to interpolate. 

 

If we need to find value for x=6, then

Si(6)=3+((27-3)/(8-2))*(6-2)=19 - that's interpolation.

 

View solution in original post

3 Replies
Highlighted
Xilinx Employee
Xilinx Employee
6,558 Views
Registered: ‎02-09-2009

Hi,

 

Certainly, you can implement this interpolation using the Xilinx Blockset. For linear interpolation between (x1,y1) and (x2,y2) you should have an exation that looks like the following:

 

Si(x) = y1 + ((y2 - y1) / (x2 - x1)) * (x - x1)

 

where x is the x-axis point between the two coordinates that you are trying to calculate the new Si(x) coordinate for.

 

You can then break this down into the individual add/ subtract and multiply blocks that are available in the Xilinx Blockset. For a straight forward implementation, it would appear that you would need three subtractions, a division, and a multiplication block. However, often the x2 - x1 will be a constant. For example, this might be the difference between two points in a look-up table, so it will always be one. If the x2 - x1 is constant, then there is no need for a division and the linear interpolation becomes a very simple subtract and multiply implementation.

 

For an even more consise implementation, a DSP48 block in Xilinx FPGAs can be used to perform both the subtraction and multiplication. The newer DSP48s have pre-add/subtract which can implement subtraction, a multiplier, and a post-add/subtract so it is possible to do linear interpolation using a single DSP48.

 

Cheers,

Elliot

Highlighted
Anonymous
Not applicable
6,548 Views

Hello Elliot and thanks for responding to my post.

 

1) You are correct (x2-x1) is a constant value and it is equal to sampling rate of the system (e.g. 1/50ksps = 20us).  If this number is fixed, how do you avoid a division step?  It seems to me that whether this value is constant or changing, even with a look-up table, I would still have to perform the divide operation, please explain how you avoid this step by either using the basic blocks or the DSP48 block.

 

2) Your equation is a bit confusing to me. For example (e.g. x1=2,y1=3,x2=8,y2=27), the equation just equals y2....3+((27-3)/(8-2))*(8-2) = 27.  How does this equation relate to finding the points to interpolate.  I think this is taking into account that I have only 2 points and that I want to interpolate between those 2 points, in my case, I might have 30 points to interpolate between two known x,y coordinates. Does your proposed method still apply?  It seems that I would need to use a FIFO block or other memory device to store the value of these interpolated points and then concatenate the original waveform with the interpolated sections, what do you think? It doesnt seem like I would be able to do this with simple add,sub,mult,div blocks.

 

In any case, my email address is: eduardo.m.rey@philips.com, if you would prefer to discuss this over the phone since this is rather verbose topic, my work phone is 407-455-6189.

0 Kudos
Highlighted
Adventurer
Adventurer
7,628 Views
Registered: ‎08-20-2007

u are correct (x2-x1) is a constant value and it is equal to sampling rate of the system (e.g. 1/50ksps = 20us).  If this number is fixed, how do you avoid a division step? 

In this case instead of division you will use multiplication by constant e.g. 1/20µS=50000

 

For example (e.g. x1=2,y1=3,x2=8,y2=27), the equation just equals y2....3+((27-3)/(8-2))*(8-2) = 27.  How does this equation relate to finding the points to interpolate. 

 

If we need to find value for x=6, then

Si(6)=3+((27-3)/(8-2))*(6-2)=19 - that's interpolation.

 

View solution in original post