⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pre-distoration.txt

📁 数字预失真--用于产生WCDMA 仿真信号源等程序
💻 TXT
字号:
make_pulse_with_ballast.m
% 用于产生WCDMA 仿真信号源
close all
clear all
% Make a pulse
BufferSize = 2048;
BW = 2E6; % bandwidth in Hz
Fs = 125E6; % sampling rate
N = 2048;
IF_freq = Fs / BufferSize * 256; % 15,625,000 Hz
w = chebwin(N,80);
h = fir1(N-1,BW/Fs,w);
%h = fir1(N,BW/Fs);
figure
plot(h)
title('sinc pulse');
figure
plot(20*log10(abs(fftshift(fft(h)))))
title('fft of sinc pulse');
h = h/max(h);
h = h;
z= zeros(1,BufferSize);
% create a tone
f1 = 31.25E6;
f1 = f1 - IF_freq; % we're going to shift up by IF_freq
tonei = cos(2*pi/Fs*f1*(1:BufferSize/2));
toneq = sin(2*pi/Fs*f1*(1:BufferSize/2));
win = hanning(BufferSize/3);
win1 = win(1:end/2);
win2 = win(end/2:end);
N = BufferSize/2 - length(win1) - length(win2);
win = [win1; ones(N,1); win2];
tonei = tonei.*win';
toneq = toneq.*win';
sig = [h -h tonei] + j * [h -h toneq];
% shift up by IF_freq
sigt = sig .* exp(j * 2 * pi * IF_freq * (1:length(sig)) / Fs);
I = round(32767/sqrt(2)*real(sigt));
Q = round(32767/sqrt(2)*imag(sigt));
x = I+j*Q;
figure
plot(linspace(-Fs/2, Fs/2, length(x)), 20*log10(abs(fftshift(fft(x)))));
title('fft of upconverted signal (sinc pulse and tone burst)');
grid;
figure
plot(real(x));
hold on
plot(imag(x),'r')
title('real and imaginary parts of upconverted signal');
fid = fopen('2MHz_pulse_at_15p625MHz_and_ballast_at_31p25MHz','w');
fprintf(fid,'DataType: 0 \n');
fprintf(fid,'DataLen: 2048 \n');
fprintf(fid,'TriggerPos: 0 \n');
for i = 1:length(x)
fprintf(fid,' %8d %8d \n',real(x(i)),imag(x(i)));
end
fclose(fid);
PK = max(abs(x))
avg = sqrt(mean((real(x).^2 + imag(x).^2)))
20*log10(PK/avg)
ConfigHW.m
% *********************
% * Configure Hardware
% *********************
function err_code = configHW
% Reset ISL5239 Evaluation Board
[gcConfigStruct,err_code] = GetGC_Config;
if err_code == -1
error('Hardware Error, please check ISL5239 Evaluation Board Connections\n');
end
gcConfigStruct.GC_Mask.eRstHard = 1;
gcConfigStruct.GC_Mask.eRstSoft = 1;
gcConfigStruct.eRstHard = 1;
gcConfigStruct.eRstSoft = 1;
SetGC_Config(gcConfigStruct);
gcConfigStruct.eRstHard = 0;
gcConfigStruct.eRstSoft = 0;
SetGC_Config(gcConfigStruct);
% Setup the PD
pdConfigStruct = GetPD_Config;
pdConfigStruct.PD_Mask.eTest = 1;
pdConfigStruct.eTest = 1;
pdConfigStruct.PD_Mask.eBypass = 1;
pdConfigStruct.eBypass = 0;
pdConfigStruct.PD_Mask.eMagFnSel = 1;
pdConfigStruct.eMagFnSel = 1; % linear voltage
pdConfigStruct.PD_Mask.sOffset = 1;
pdConfigStruct.sOffset = 0;
pdConfigStruct.PD_Mask.usScale = 1;
pdConfigStruct.usScale = 256;
pdConfigStruct.PD_Mask.eActiveLUT = 1;
pdConfigStruct.eActiveLUT = 0;
SetPD_Config(pdConfigStruct);
% Initialize PD LUT to a flat characteristic
lutStruct = GetPD_Table( 0 );
lutStruct.eLUT = 0;
headRoom_dB = 4;
lutStruct.astData.usLUT_DataRe = 10.^(-headRoom_dB/20)*(2^16-1) * ones(1,1024);
lutStruct.astData.sLUT_DataIm = zeros(1,1024);
lutStruct.astData.sLUT_DataDelRe = zeros(1,1024);
lutStruct.astData.sLUT_DataDelIm = zeros(1,1024);
SetPD_Table(lutStruct);
SetPD_Config(pdConfigStruct);
% Setup the conjugate CF
cfCoefTable = getCF_CoefTable;
cfCoefTable.astData.sCoefDataI = [32767 zeros(1,12)];
cfCoefTable.astData.sCoefDataQ = [-32767 zeros(1,12)];
setCF_CoefTable(cfCoefTable);
% Setup the ODC
odcConfigStruct = GetODC_Config;
odcConfigStruct.ODC_Mask.eBypass = 1;
odcConfigStruct.eBypass = 0;
odcConfigStruct.ODC_Mask.eOffsetBinary = 1;
odcConfigStruct.eOutputValType = 1;
SetODC_Config(odcConfigStruct);
find_LUT_power_ranges.m
% find the input power ranges corresponding to the LUT addresses
% column 1: "0" if address is never accessed, "1" otherwise
% column 2: beginning of range in dBFS power
% column 3: end of range in dBFS power
% column 4: LUT address (0 - 1023 decimal)%
% ranges = find_LUT_power_ranges(scale, offset, mode)
function ranges = find_LUT_power_ranges(scale, offset, mode)
k=1; %设定功率回退值
par=10.86; %设定信号功率峰值与均值比
sr=0.22;% 设定饱和点回馈值
power_sat=24.46;%设定饱和点值
lower_q_pont=power_sat-par-k;设定预失真窗口下限
upper_value=power_sat-sr;%设定预失真窗口上限
for a = 0:1023
y = find_upper_limit(a, scale, offset, mode);
if call_calc_addr(y, scale, offset, mode) ~= a % LUT entry isn't used
if
lower(a+1) = -1;
upper(a+1) = -1;
ranges(a+1, 1) = 0; % 旁路I/Q信号
else
ranges(a+1, 1) = 1; %使I/Q参与预失真运算使用LUT表项
upper(a+1) = y;
if a == 0
lower(a+1) = 0;
elseif upper(a) ~= -1
lower(a+1) = upper(a) + 1;
else
lower(a+1) = find_lower_limit(a, scale, offset, mode);
end
end
end
a=1;
full_scale_power = hex2dec('80000')^2 * 2;
ranges(:,2) = lower';
ranges(:,2) = 10*log10(ranges(:,2)/full_scale_power);
upper = ((upper/upper_value) > 1) .* full_scale_power + ((upper/upper_value) <= 1) .* upper;
ranges(:,3) = upper';
ranges(:,3) = 10*log10(ranges(:,3)/full_scale_power);
ranges(:,4) = (0:(length(ranges)-1))';
return;
% address = LUT address to find upper power limit for
% returned value is power level which maps to an address <= provided address
% not all LUT addresses are used in all modes, so returned power level may map to a different
address
function y = find_upper_limit(address, scale, offset, mode)
k = 39; % power is 40 bits wide
guess = 2^k;
while (k > 0)
k = k - 1;
a = call_calc_addr(guess, scale, offset, mode);
if (a > address)
guess = guess - 2^k;
elseif (a < address)
guess = guess + 2^k;
elseif (a == call_calc_addr(guess+1, scale, offset, mode))
guess = guess + 2^k;
end
end
y = floor(guess);
return;
% address = LUT address to find lower power limit for
% returned value is power level which maps to an address >= provided address
% not all LUT addresses are used in all modes, so returned power level may map to a different
address
function y = find_lower_limit(address, scale, offset, mode)
k = 39; % power is 40 bits wide
guess = 2^k;
while (k > 0)
k = k - 1;
a = call_calc_addr(guess, scale, offset, mode);
if (a < address)
guess = guess + 2^k;
elseif (a > address)
guess = guess - 2^k;
elseif (a == call_calc_addr(guess-1, scale, offset, mode))
guess = guess - 2^k;
end
end
y = floor(guess);
return;
function y = call_calc_addr(power, scale, offset, mode)
y = calc_addr(sqrt(power), 0, mode, scale, offset);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -