Oversample and Predistort by harrde: Difference between revisions

From Class Wiki
Jump to navigation Jump to search
(New page: Back to my page ==Problem Statement== Make a MATLAB script to do four times oversampling and filter so as to eliminate as much as possible the effect of the D/A converter ...)
 
No edit summary
Line 6: Line 6:
==Solution==
==Solution==
MATLAB script and results:
MATLAB script and results:
<pre>
f = 10; % Sampling freq.
T = 1/f; % Sampling period
N = 10; % Number of sampling points
t=0:T:(N-1)*T;
x=sin(2*pi*t)+cos(2*pi*2*t); % Signal that is sampled
t_original = 0:.01:1;
x_original = sin(2*pi*t_original)+cos(2*pi*2*t_original);

OSample = 4; % How many times to oversampling

figure(1);
clf
plot(t_original,x_original,'r'); %Original signal sampled
hold on
stem(t,x)
xlabel('Time(s)');
ylabel('x(t)');
title('Orignal Data and Sampled Points')
hold
legend('Original Data','Sampled Points')

figure(2);
N1 = N*OSample;
X = fft(x);
X1 = (N1+N)/N*[X(1:N/2),zeros(1,N1),X(N/2+1:N)]; %This is the interpolation transfer function
x1 = ifft(X1);
t1=0:N/(N+N1)*T:(N-1/(N1+N))*T;
plot(t1,x1,'bo') %Sampled data with interpolation points
title('Sampled Data After Interpolation');
ylabel('x(t)');
xlabel('Time(s)');

%Now we will work on predistortion filter
f = linspace(-1/T,1/T,length(X1));
P = sin(pi*f*T)./(pi*f); %Transfer function of A/D distortion
figure(3)
plot(f,P) % A/D distortion transfer function
title('A/D Distortion Transfer Function');
ylabel('P(f)');
xlabel('f(Hz)');

Out_unfiltered = X1.*P;
out_unfiltered = ifft(Out_unfiltered);

Out = X1.*(1./P).*P;
out = ifft(Out);

figure(4)
clf
plot(f./10,real(out_unfiltered)) %This is the output with out filter/predistortion
title('Unfiltered Output');
ylabel('x(t)');
xlabel('time(s)');

figure(5)
clf
plot(f./10,real(out)) %This is the output with the filter
title('Filtered/Predistorted Output');
ylabel('x(t)');
xlabel('time(s)');
</pre>

[[Image:DH15_1.jpg]]
[[Image:DH15_2.jpg]]
[[Image:DH15_3.jpg]]
[[Image:DH15_4.jpg]]
[[Image:DH15_5.jpg]]

===Explanation===

Revision as of 14:46, 7 December 2007

Back to my page

Problem Statement

Make a MATLAB script to do four times oversampling and filter so as to eliminate as much as possible the effect of the D/A converter that follows the interpolating filter.

Solution

MATLAB script and results:

f = 10;             % Sampling freq.
T = 1/f;            % Sampling period
N = 10;             % Number of sampling points
t=0:T:(N-1)*T;     
x=sin(2*pi*t)+cos(2*pi*2*t);   % Signal that is sampled
t_original = 0:.01:1;
x_original = sin(2*pi*t_original)+cos(2*pi*2*t_original);

OSample = 4;                            % How many times to oversampling

figure(1);
clf
plot(t_original,x_original,'r');         %Original signal sampled
hold on
stem(t,x)
xlabel('Time(s)');
ylabel('x(t)');
title('Orignal Data and Sampled Points')
hold
legend('Original Data','Sampled Points')

figure(2);
N1 = N*OSample;
X = fft(x);
X1 = (N1+N)/N*[X(1:N/2),zeros(1,N1),X(N/2+1:N)]; %This is the interpolation transfer function
x1 = ifft(X1);
t1=0:N/(N+N1)*T:(N-1/(N1+N))*T;
plot(t1,x1,'bo')                    %Sampled data with interpolation points
title('Sampled Data After Interpolation');
ylabel('x(t)');
xlabel('Time(s)');

%Now we will work on predistortion filter
f = linspace(-1/T,1/T,length(X1));
P = sin(pi*f*T)./(pi*f);                %Transfer function of A/D distortion
figure(3)
plot(f,P)                       % A/D distortion transfer function
title('A/D Distortion Transfer Function');
ylabel('P(f)');
xlabel('f(Hz)');

Out_unfiltered = X1.*P;         
out_unfiltered = ifft(Out_unfiltered);

Out = X1.*(1./P).*P;            
out = ifft(Out);

figure(4)
clf
plot(f./10,real(out_unfiltered))      %This is the output with out filter/predistortion
title('Unfiltered Output');
ylabel('x(t)');
xlabel('time(s)');

figure(5)
clf
plot(f./10,real(out))                 %This is the output with the filter
title('Filtered/Predistorted Output');
ylabel('x(t)');
xlabel('time(s)');

DH15 1.jpg DH15 2.jpg DH15 3.jpg DH15 4.jpg DH15 5.jpg

Explanation