How to generate BPSK signal
360 ビュー (過去 30 日間)
古いコメントを表示
Meshari Alsahli
2020 年 4 月 20 日
コメント済み: Idin Motedayen-Aval
2024 年 5 月 30 日
- Generate 1000 random binary data bits.
- Convert unipolar to bipolar in the databits.
- Modulate the bipolar bits with Binary Phase Shift Keying (BPSK).
- Multiply the baseband BPSK with a carrier fc = 100 Hz.
- The modulated BPSK signals will be transmitted through a Noiseless channel. At the receiver side demodulate the received signal by multiplying it with a carrier and passing it through a Low Pass Filter (LPF).
- Decode the BPSK signal using match filtering and sgn function.
1 件のコメント
Usama Saleem
2021 年 12 月 27 日
: Apply the concept of conversion of a double word into another word and implement it on Arduino and verify with the help of an Example.
採用された回答
MathWorks Support Team
2021 年 7 月 13 日
編集済み: MathWorks Support Team
2021 年 7 月 13 日
% Set up
% Specified parameters
M = 2; % Modulation order (BPSK)
nData = 1000; % Number of bits
Fc = 100; % Carrier frequency, Hz
% Assumed parameters
Fb = 100; % Bit (baud) rate, bps
Fs = 8*Fc; % Sampling frequency, Hz
Ts = 1/Fs; % Sample time, sec
Td = nData/Fb; % Time duration, sec
spb = Fs/Fb; % Samples per bit
fSpan = 4; % Filter span in symbols
% Visualize the spectrum of baseband BPSK & modulated carrier
specAn1 = dsp.SpectrumAnalyzer("SampleRate", Fs, "Method","Filter bank","AveragingMethod","Exponential","Title", "Pulse Shaped Baseband BPSK");
specAn2 = dsp.SpectrumAnalyzer("SampleRate", Fs, "Method","Filter bank","AveragingMethod","Exponential","Title", "BPSK Modulated Carrier");
% Transmitter
% Generate random data bits
data = randi([0 M-1],nData,1);
% Modulate and plot the data
% pskmod() effectively converts unipolar to bipolar bits and performs BPSK
% modulation
modData = real(pskmod(data,M));
% Pulse shape & upsample to match carrier's sampling rate. Pulse shaping is
% used to reduce intersymbol interference and to reduce spectral width of
% the modulated signal.
txFilter = comm.RaisedCosineTransmitFilter("FilterSpanInSymbols",fSpan,"OutputSamplesPerSymbol",spb);
txfilterOut = txFilter(modData);
specAn1(txfilterOut);
![](http://www.mathworks.com/matlabcentral/answers/uploaded_files/683703/bb64782f12485eaf351c05a1ac78938e.png)
% Multiply modulated & pulse shaped signal with carrier
sine = dsp.SineWave("Frequency",Fc,"SampleRate",Fs,"ComplexOutput",false,"SamplesPerFrame",Td/Ts);
carrier = sine();
txSignal = txfilterOut .* carrier;
specAn2((txSignal));
![](http://www.mathworks.com/matlabcentral/answers/uploaded_files/683708/cfe6b7ac5f9903c10aa58d0361406394.png)
% Receiver
% Multiply received signal with carrier
rxSignal = txSignal .* conj(carrier);
% Low pass match filter to account for pulse shaping
rxFilter = comm.RaisedCosineReceiveFilter("FilterSpanInSymbols",fSpan,"InputSamplesPerSymbol",spb,"DecimationFactor",spb);
rxFilterOut = rxFilter(rxSignal);
% Demodulate
% For BPSK, pskdemod() is equivalent to sign function
dataOut = pskdemod(rxFilterOut,M);
% Each of the tx and rx filters introduces a delay of fSpan/2 symbols, for
% a total delay of fSpan symbols (= bits for BPSK). Delay received bits by
% fDelay for accurate comparison with transmitted bits.
fDelay = fSpan;
[numErr, ber] = biterr(data(1:nData-fDelay),dataOut(fDelay+1:nData))
2 件のコメント
Jaweed Raza
2023 年 9 月 16 日
I tried running the above scripts but generated that there are errors in
specAn1 = dsp.SpectrumAnalyzer("SampleRate", Fs, "Method","Filter bank","AveragingMethod","Exponential","Title", "Pulse Shaped Baseband BPSK");
specAn2 = dsp.SpectrumAnalyzer("SampleRate", Fs, "Method","Filter bank","AveragingMethod","Exponential","Title", "BPSK Modulated Carrier");
I am not sure why these errors are generated. The lines are identical for SpecAn1 and SoecAn2. What's the difference and how do they differentiate to display the pulse and spectrum?
Idin Motedayen-Aval
2024 年 5 月 30 日
Note: dsp.SpectrumAnalyzer will be removed in a future release (it's on a deprecation path).
You can simply replace "dsp.SpectrumAnalyzer" with "spectrumAnalyzer" in the above code, and everything will work as expected.
When running the code above in the latest MATLAB release (R2024a), there are no errors (it will produce warnings if you continue to use dsp.SpectrumAnalyzer).
@Jaweed Raza, there are two lines creating two spectrum analyzer objects named specAn1 and specAn2 (when you run this code, two different spectrum analyzer windows pop up; this is how those two figures are generated).
その他の回答 (1 件)
Maadhav Akula
2020 年 4 月 23 日
You can use the follllowing system objects to perform BPSK Modulation and Demodulation:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で BPSK についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!