%**************************************************************************
% DIGITAL COMMUNICATION SYSTEM
% BPSK MODEL
%**************************************************************************
%IMORTANT VARIABLES USED
%t - Modeled system time
%fm - Main frequency of message signal
%harm - Frequency components of the message signal
%amp - Amplitude of the corresonding harmonic frequency component
%sampling_rate - System sampling rate . Default rate is 20 samples per cycle of maximum freqency component
%range - Range of the time sampling is done . Default range is 2 cycles of minimum frequncy component
%msg - Message signal to be trasnmitted
%minamp - Minimum amplitude that can be used in this model
%n_sample - Number of samples per cycle of the message signal
%fs - Sampling frequency for sampling the message signal
%msamp - Sampled version of the message signale with sampling frequency fs
%no_of_levels - Number of quantization levels
%quantile - Quantile interval
%code - Representation levels
%mq - Quantization output of sampled message signal
%mq1 - Sampled version of quantized sample message signal
%bits - Binary sequence of sampled quantized signal (output of ADC)
%fc - Carrier signal frequency
%nsamp - System Samples per cycle of carrier signal
%ncyc - Number of cycles of carrier signal for one bit interval
%tb - Bit interval
%t_tran - Total transmission time , in order to find diffrence between already existing time variable 't' see Note-1
%mod_sig - BPSK modulated carrier signal
%tran_sig - Siganl after transmission through AWGN channel , so that Awg noise is added with the original transmitted signal
%f_freq - Frequency range used for visualising FFT of the signal
%f_tran - Noise added transmitted signal representation in frequency domain
%f_rece - Received signal after removing noise ,in frequency domain
%dec_data - Binaray data extracted from BPSK modulated carrier signal
%mq_rece - Decoded sampled quantized message signal data calculated from extracted binary sequence
%f_out - Reconstruted signal in frequency domain after filtering
%out - Reconstruted signal from the received signal ,in time domain i.e, output of the receiver
%gain - gain of the amplifier expressed in ratio not in db
%
%ABBREVATIONS
%ADC - Analog to Digital Convertor
% Converts analog signal to digital signal
%AWGN - Anti-White Gaussian Noise
% A channel model with zero mean noise , commonly used channel model .
%DAC - Digital to Analog Convertor
% Converts digital signal to analog signal
%Rx - Receiver
%Tx - Transmitter
%*****************************-TRANSMITTER-********************************
clear all;
clc;
%MESSAGE SIGNAL PARAMETERS
fm=1e3; %Main frequency of message signal
harm=[ 1 0.5 2 1 ]; %Frequency components of the message signal
%In this model the message signal is represented by fourier sine series
amp=[ 1 2 3 1 ]; %Amplitude of the corresonding harmonic frequency component
sampling_rate=1/(20*max(fm*harm)); %System sampling rate . Default rate is 20 samples per cycle of maximum freqency component
range=2/min(fm*harm); %Range of the time sampling is done . Default range is 2 cycles of minimum frequncy component
t=0:sampling_rate:range; %System timing
%MESSAGE SIGNAL
msg=zeros(size(t));
for k=1:length(harm)
msg=msg+amp(k)*sin(2*pi*harm(k)*fm*t);
end
minamp=min(msg); %Minimum amplitude that can be used in this model . Normally ,it need to be kept as a global constant
%But for flexibility of program it is made here as variable depending on message signal value
%SAMPLING
n_sample=5;
fs=n_sample*max(harm*fm); %Sampling ferqency .
msamp=zeros(size(msg));
msamp(1:1/(fs*sampling_rate):length(t))=msg(1:1/(sampling_rate*fs):length(t)); %Sampled output signal
figure(1);plot(t,msg); grid on
hold on
stem(t,msamp);
xlabel('time');ylabel('Message signal,Sampled signal and Quantized signal');
title('MESSAGE SIGNAL , SAMPLED MESSAGE SIGNAL AND QUANTIZED SIGNAL');
legend('Message signal','Sampled Signal','Quantized Signal');
%QUANTIZATION
no_of_levels=4; %Number of quantization levels
quantile=(max(msamp)-min(msamp))/(no_of_levels); %Quantile interval
code=min(msamp):quantile:max(msamp); %Representation levels
mq=zeros(size(msamp));
for k=1:length(code)
values=(( msamp>(code(k)-quantile/2) & msamp<(code(k)+quantile/2)));
mq(values)=round(code(k)); %Quantization output of sampled message signal
end
clear values;
stem(t,mq,'r*');grid on
legend('Message signal','Sampled Signal','Quantized Signal');
%ENCODING
if min(mq)>=0
minamp=0;
end
mq1=mq-round(minamp); %Shifting negative values to postive side for conversion to binary and sampling
%quantized message signal
bits=de2bi(mq1(1:1/(fs*sampling_rate):length(mq)),4,'left-msb')';
bits=bits(:)'; %ADC - Generating binary sequence of sampled quantized signal
figure(5);stem(bits,'*r');hold on;
legend('Bit sequence in Transmitter','Bit sequence in Receiver');
%PASS BAND MODULATION (BPSK)
fc=1e6; %Carrier signal frequency
nsamp=10; %System Samples per cycle of carrier signal
ncyc=2; %Number of cycles of carrier signal for one bit interval
tb=0:1/(nsamp*fc):ncyc/fc; %Bit interval
t_tran=0:1/(nsamp*fc):(ncyc*length(bits))/fc+(length(bits)-1)/(nsamp*fc); %Total transmission time
mod_sig=zeros(size(t_tran));
l=1;
for k=1:length(tb):length(mod_sig)
if(bits(l)==1)
mod_sig(k:k+length(tb)-1)=cos(2*pi*fc*tb); %Phase Modulation of carrier for repesenting binary symbol one
else
mod_sig(k:k+length(tb)-1)=-cos(2*pi*fc*tb); %Phase Modulation of carrier for repesenting binary symbol zero
end
l=l+1;
end
%**********************AWGN-CHANNEL****************************************
tran_sig=awgn(mod_sig,10); %Transmisson of modulated carrier signal through AWGN channel
figure(2);plot(t_tran,mod_sig,'.-b',t_tran,tran_sig,'r');
axis([0 3*ncyc/fc -2 2]);
xlabel('time');ylabel('Tx signal and Tx signal with noise');
title('TRANSMITTED SIGNAL AND NOISE A
BPSK.rar_BPSK/QPSK_QPSK_QPSK ber analysis
版权申诉
94 浏览量
2022-09-19
21:16:15
上传
评论
收藏 4KB RAR 举报
钱亚锋
- 粉丝: 88
- 资源: 1万+
最新资源
- 蓝zapro.apk
- chromedriver-linux64.zip
- 基于Python和PyTorch框架完成的一个手写数字识别实验源码(带MINIST手写数字数据集)+详细注释(高分项目)
- 基于Matlab在MNIST数据集上利用CNN完成手写体数字识别任务,并实现单层CNN反向传播算法+源代码+文档说明(高分项目)
- NVIDIA驱动、CUDA和Pytorch及其依赖
- html动态爱心代码一(附源码)
- c40539bc-071a-486c-9d52-9d0c18d62dac 4.html
- 基于物理的非视域成像(NLOS)算法,利用了nerf+python源码+文档说明
- yuluer知更鸟.7z(1).001
- python课程设计-基于tensorflow实现的图文生成程序,数据集flickr30k-images+源代码+文档说明+截图
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈