How to generate wireless O-QPSK modulated signal in Matlab?
9 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I am trying to create a small simulation where I would need to transmit a wireless signal from one wireless node to another and then transmit one more message back to node 1. Considering this is LR-WPAN device, the IEEE standard is 802.15.4 and signal supposed to be O-QPSK modulated. I use the in-built function which is
lrwpan.PHYGeneratorOQPSK (message, spc, '2450 MHz');
I defined a message
myself according to MPDU format. However when I transfer my waveform into frequecy domain, my signal does not look wireless and have a drastical drop of amplitude every 400 Hz, so I am not sure if it is a normal thing or no. I also added AWGN noise to my signal and visualized the corresponding plots. I was wondering if someone can look at my plots and my code and confirm if my plots are fine and I do everything correct. Here is my code to generate two wireless signals:
clc,clear
spc = 4; % symbols per chip
%mesage length is 18 bytes
message1_2 = [1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ...
0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ...
0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 ...
0 0 1 1 1 0 1 0 0 0 1 0 0 1 0 0]';
message2_1 = [1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ...
0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ...
0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 ...
1 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0]';
% % O-QPSK PHY, 2450 MHz
waveform = lrwpan.PHYGeneratorOQPSK(message, spc, '2450 MHz');
SNR1 = -300;
waveform1 = lrwpan.PHYGeneratorOQPSK(message1_2, spc, '2450 MHz');
waveform2 = lrwpan.PHYGeneratorOQPSK(message2_1, spc, '2450 MHz');
waveform1 = std(waveform1)/std(waveform1)*(sqrt(10^(SNR1/10)))*waveform1; %% increase signal1 transmission power
waveform2 = std(waveform2)/std(waveform2)*(sqrt(10^(SNR1/10)))*waveform2; %% increase signal2 transmission power
%Calculate Number of FFT points
l = length(waveform1);
NFFT = 2.^nextpow2(l);
%take FFT of original signal
wavesignal1 = abs(fft(waveform1,NFFT)); %signal1
wavesignal2 = abs(fft(waveform2,NFFT)); %signal2
SNR= 35; % average SNR for wireless sensor networks application
%applying white gaussian noise to both signals
S = RandStream('mt19937ar','Seed',5489);
%received signals
received_at_node2= awgn(waveform1, SNR, 'measured', S);
reset(S);
received_at_node1 = awgn(waveform2, SNR, 'measured', S);
reset(S);
%take FFT of received signal with noise
wave_fft_signal1 = abs(fft(received_at_node2,NFFT));
wave_fft_signal2 = abs(fft(received_at_node1,NFFT));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%SIGNAL PLOTS%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %signal 1 Dbm Spectrum plot
%
%
%
% %original signal 1
XdB1 = 10*log10(wavesignal1);
subplot(2,2,1);
plot(f,XdB1(1:NFFT));
title('Wireless Signal 1 without Noise');
xlabel('Frequency (Hz)');
ylabel('|signal 1| (dBm)');
%
%
% %noisy signal 1
XdB1_n = 10*log10(wave_fft_signal1);
xdB1_f = 10*log10(filtered1);
subplot(2,2,2);
plot(f,XdB1_n(1:NFFT));
title('Wireless Signal 1 with AWGN applied');
xlabel('Frequency (Hz)');
ylabel('|signal 1| (dBm)');
%
% %signal 2 Power Spectrum plot
%
%
%
%original signal 2
XdB2 = 10*log10(wavesignal2);
subplot(2,2,3);
plot(f,XdB2(1:NFFT),'color','black');
title('Wireless Signal 2 without Noise');
xlabel('Frequency (Hz)');
ylabel('|signal 1| (dBm)');
%
%
%
% %noisy signal 2
XdB2_n = 10*log10(wave_fft_signal2);
subplot(2,2,4);
plot(f,XdB2_n(1:NFFT),'color','black');
title('Wireless Signal 2 with AWGN noise Applied');
xlabel('Frequency (Hz)');
ylabel('|signal 2| (dBm)');
I've read some articles related to wireless signal simulation and this is how usually their plots looks like:

whereas my plots are as follows:

So, my question is what am I doing wrong and how to bring it to the visual form that was depicted above? Do I have to center it around 2.4 Ghz? If yes , how to do it? And again, why the amplitude goes down so much every ~500 Hz?
1 个评论
Victor Hugo Lázaro Lopes
2019-6-7
Hi,
i'm have the same question.
I'm tried your code, and compare to comm.QPSK Modulator.
The number of generated signal samples are differences. Did you see it?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!