Translate

Saturday 23 March 2013

Still problems on the interpolation

I love DSP but I'm bad at it!


It looks like I'm a bad SW designer... 
I'm still not sure I understood how to interpolate a raw data from the FPGA buffer to the screen.
In the picture below I have in yellow the raw data from the FPGA, and in red the interpolated data using the sinc(x) algorithm.
Now how you can see, there is nothing that suggest why I should have all that ringing.


In order to show the problem even better I have zoomed the image(see below): in red I still have the interpolated data, while in yellow I have the raw data.
From the raw data, I can see some small ringing that for some reason get amplified in red when I interpolate .
For example if you look at that negative edge... it doesn't look right isn't it? 


the above GUI is written using Lazarus . The function that create the interpolated data is :


function sinc_interpolation(buff: TCH_BUFF; Fsample: float; t: float): float;
var
  i: integer;
  sum: float = 0;
  x_nt: float;
  Ts: float = 0;

begin

 {
  x(t) = sum [ Xn sinc(pi/T(t-nT))] sum all the n...
  }

  Ts := 1 / FSample;  // sample time
  sum := 0;
  for i := 1 to BUF_SIZE - 2 do // remember to fix the bug inside the FPGA
  begin
    x_nt := buff[i] * sinc((t - i * Ts) / Ts);
    sum := sum + x_nt;
  end;
  Result := Sum;

end;  
When I call that function I set:
 Fsample = 100000000.0; (100 MHz)
t = time I want to diplay on the screen ( I start to calculate t  starting from the middle of the buffer)
and buff is the buffer from the FPGA

Do you think the code  above is correct?
any comment is welcome.



1 comment: