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

📄 dpwb.m

📁 本程序是关于PSK ASK的调制编码程序
💻 M
📖 第 1 页 / 共 2 页
字号:
subplot(2,2,4); plot(f,20*log10(MYDIFF));xlabel('FREQUENCY');ylabel('20LOG10=DB');
grid on;
%axis([0 15e9 -200 5]);


%plots for correlated pulses(yc)
figure(2)
subplot(2,2,1); plot(t,yc);xlabel('TIME');ylabel('AMPLITUDE');
title('Receiver correlator output-no LPF');
grid on;
%axis([-1e-9,27e-9 -1 1]);
subplot(2,2,2); plot(f,MYC);xlabel('FREQUENCY');ylabel('AMPLITUDE');
grid on;
%axis([0 7e9 0 .025]);%zoom in/out
subplot(2,2,3); plot(f,20*log10(MYC));xlabel('FREQUENCY');ylabel('20LOG10=DB');
grid on;
%axis([0 20e9 -120 0]);

%===========================================================
%CORRELATION RECEIVER COMPARATOR[ADC](before lowpass filter)
%===========================================================
pt=.1e-8%sets level where threshhold device comparator triggers
H=5;%(volts)
L=0;%(volts)
LEN=length(yc);
for ii=1:LEN;
    if yc(ii)>=pt;%correlated output(yc) going above pt threshold setting
        pv(ii)=H;%pulse voltage
    else;
        pv(ii)=L;
    end;
end ;
po=pv;%pulse out=pulse voltage
%figure(3)
subplot(2,2,4);plot(t,po);
axis([-1e-9 27e-9 -1 6])
title('Comparator output');xlabel('FREQUENCY');ylabel('VOLTAGE');
grid on;
%===================================================
%SETUP and INFO
%===================================================
%Check axis settings on plots.
%Change t=-1e-9:1/Fs:(xxxx) to 1e-9 or proper value for viewing
%Press F5 or run.
%With waveform in plot 2,2,1(Figure 1), set pulse width to
%.5e-9(tail to tail).
%Change t=-1e-9:1/Fs:(xxx) to something like 46e-9.Zoom out. I would
%comment in all plot axis and use them for zooming in and out.
%Press F5 and observe waveforms. Print or observe waveforms to compare with next set of
%wave forms.
%===================================================================
%  CORRELATION RECEIVER LOW PASS FILTER(INTEGRATOR)
%=======================================================================
rc=.5e-9;%time constant
ht=(1/rc).*exp(-t/rc);%impulse response
ycfo=filter(yc,1,ht)/Fs;%use this instead of ycfo=conv(yc,ht)/Fs for proper dimension.
%The #=1 allows this. The LPF RC time constant(integrates over this time).
%Theory states that it should be set to the pulse width but should be set
%to a value that gives the best error free operation at the highest noise
%levels. Different filter types(butterworth,etc) may give different
%results.
%The 3DB or 1/2 power bandwidth on the RC LPF is f=1/(2*pi*RC). The noise
%bandwith is f=1/(4*rc).
yn=filter(noise,1,ht)/Fs;%looks at filtered noise only(Figure 4)

%new FFT for filtered correlated pulses(ycfo) 
NFFYCFO=2.^(ceil(log(length(ycfo))/log(2)));
FFTYCFO=fft(ycfo,NFFYCFO);%pad with zeros
NumUniquePts=ceil((NFFYCFO+1)/2); 
FFTYCFO=FFTYCFO(1:NumUniquePts);
MYCFO=abs(FFTYCFO);
MYCFO=MYCFO*2;
MYCFO(1)=MYCFO(1)/2;
MYCFO(length(MYCFO))=MYCFO(length(MYCFO))/2;
MYCFO=MYCFO/length(ycfo);
f=(0:NumUniquePts-1)*2*Fn/NFFYCFO;

%new FFT for filtered noise(yn)
NFFYN=2.^(ceil(log(length(yn))/log(2)));
FFTYN=fft(yn,NFFYN);%pad with zeros
NumUniquePts=ceil((NFFYN+1)/2); 
FFTYN=FFTYN(1:NumUniquePts);
MYN=abs(FFTYN);
MYN=MYN*2;
MYN(1)=MYN(1)/2;
MYN(length(MYN))=MYN(length(MYN))/2;
MYN=MYN/length(yn);
f=(0:NumUniquePts-1)*2*Fn/NFFYN;

%plots for filtered correlated pulses(ycfo)
figure(3)
subplot(2,2,1); plot(t,ycfo);xlabel('TIME');ylabel('AMPLITUDE');
title('Receiver filtered correlator output');
grid on;
%axis([-1e-9,27e-9 -1 1]);
subplot(2,2,2); plot(f,MYCFO);xlabel('FREQUENCY');ylabel('AMPLITUDE');
grid on;
%axis([0 5e9 0 .35]);%zoom in/out
subplot(2,2,3); plot(f,20*log10(MYCFO));xlabel('FREQUENCY');ylabel('20LOG10=DB');
grid on;
%axis([0 20e9 -120 0]);

%=========================================================
%  CORRELATION RECEIVER COMPARATOR[ADC](after low pass filter)
%=========================================================
pt1=1.7e-8%sets level where threshhold device comparator triggers
H=5;%(volts)
L=0;%(volts)
LEN=length(ycfo);
for ii=1:LEN;
    if ycfo(ii)>=pt1;%correlated output(ycfo) going above pt threshold setting
        pv1(ii)=H;%pulse voltage
    else;
        pv1(ii)=L;
    end;
end ;
po1=pv1;%pulse out=pulse voltage

subplot(2,2,4);plot(t,po1);xlabel('FREQUENCY');ylabel('VOLTAGE');
axis([-1e-9 50e-9 -1 6]);
title('Comparator output (filtered) 1001101');
grid on;

%plots for filtered noise(yn) and impulse response of filter
figure(4)
subplot(2,2,1);plot(t,yn);xlabel('TIME');ylabel('AMPLITUDE');
title('Receiver filtered noise output');
grid on;
%axis([-1e-9,27e-9 -1 1]);
subplot(2,2,2); plot(f,MYN);xlabel('FREQUENCY');ylabel('AMPLITUDE');
grid on;
%axis([0 5e9 0 .25]);%zoom in/out
subplot(2,2,3); plot(f,20*log10(MYN));xlabel('FREQUENCY');ylabel('20LOG10=DB');
grid on;
%axis([0 20e9 -120 0]);
subplot(2,2,4);plot(t,ht);xlabel('TIME');ylabel('AMPLITUDE');
title('Filter impulse response(ht)');
grid on;
%axis([0,1e-9 0 1]);

%=========================================================
%BER CALCULATIONS
%=========================================================

%I'm going to calibrate the noise generator and roughly determine the Eb/No or SNR in DB
%that allows the system to operate almost error free(1e-3) in a noise environment.
%This value of Eb/No is the number in DB that can be used in link
%calculations. The calibration is required because in an actual TX-RX the received
%voltage into the correlation receiver at the mixer will be in the low millivolt
%region due to the FCC spectral mask at -41.3dBm/MHz and low transmitter power.
%It will not be the 2 volt peak-peak BPSK used here and must be recalibrated if
%different than 2 volt peak-peak.
 
%The Eb/No value in DB is calculated as follows. Doing numerous runs by hand and
%observing the LPF comparator output in figure 4, determine the proper
%setting of the comparator threshold setting, RC filter time constant and
%level of multiplier in the AWGN noise generator that gives almost error
%free operation. This will be considered Eb/No in DB.For DPSK theory this value is ~9DB for BER of 1e-3. 
%For a SNR of 9 DB, 20*LOG10(ratio of Vsigp-p/Vnoisep-p=9DB=20*LOG(0.6e-3/0.213e-3) 
%You can try a different calibration method if you don't think
%this is correct. Remember to recalibrate for new pulse widths and amplitude changes
%into the mixer and pay attention to axis settings. There are a few to keep track of.

 
%I did some preliminary link caculations with this set up and determined that approx 0.6mv p-p
%would be present on the mixer input at Eb/No=9DB.
%========================================================
%FCC spectral mask -41.3dBm/MHz+10LOG10(~4000)=~-5dBm(aver TX power Pt)
%antenna gains 0DBi(50 ohms)
%lna 20DB gain
%NF 10 DB
%distance 1 meter
%(PL)path loss~45DB
%200Mbit rate(Rb)
%BW~318Mhz 3DB BW(LPF)(RC=.5e-9)
%Pn(receiver noise level)=KTB=-114dBm+NF+10log10(Rb)=-114dBm+10DB+23DB=-81dBm
%3DB to 10DB spread of pulse ~3 to 6GHz(use 4GHz)
%pw=.5e-9 fifth derevative
%fc=~7Ghz
%Eb/No=9DB(1e-3)
%power received(Pr)@ant=-5dBm-45DB(PL)=-50dBm over ~4GHz.
%Link margin=Pr-Pn-Eb/No
%Link margin@ 1 meter=-50dBm-(-81dBm)-(9DB)=22DB 
%Emixerp-p=sqrt(1e-5mw*50)=2.23e-2mvrms*1.41=0.03mvpeak*20DB(lna)gain=0.3mvpeak or 0.6mvp-p



⌨️ 快捷键说明

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