Matlab realizes MSK modulation and demodulation

tags: Communication  matlab

1. Requirements

Draw the information generated by the MSK signal, the comparison diagram of the I-channel and Q-channel signals, and the comparison diagram of the information recovery demodulated at the receiving end.

2. Design

1. MSK modulation

2. MSK demodulation

Three, the code

clear all;clc;
N=20;  
T=1;   
fc=10; 
Fs=100;   
bitstream=randi([0,1],1,N);  
bitstream1=2*bitstream-1;  
b0=1;
for i=1:N
    encode_output(i)=b0*bitstream1(i);
    b0=encode_output(i);
end
I=[];Q=[];
for i=1:N
    if mod(i,2)~=0
        I=[I,encode_output(i)];
    else
        Q=[Q,encode_output(i)];
    end
end 
bit_data=[];
for i=1:N
    bit_data=[bit_data,encode_output(i)*ones(1,T*Fs)];
end
 I_data=[];Q_data=[];base_wave=-T:1/Fs:T-1/Fs;
for i=1:N/2
    I_data=[I_data,I(i)*cos(pi*base_wave/(2*T))];
    Q_data=[Q_data,Q(i)*cos(pi*base_wave/(2*T))];
end
% Q delay
number_delay=length(base_wave)/2;
Q_data1=[zeros(1,number_delay),Q_data(1:length(Q_data)-number_delay)];
% plot
figure();
t=0:1/Fs:N*T-1/Fs;
subplot(3,1,1)
plot(t,bit_data);legend('Bitstream')
subplot(3,1,2)
plot(t,I_data);legend('I Bitstream')
subplot(3,1,3)
plot(t,Q_data1);legend('Q Bitstream')
% carrier signal 
bit_t=0:1/Fs:N*T-1/Fs;
I_carrier=cos(2*pi*fc*bit_t);
Q_carrier=cos(2*pi*fc*bit_t+pi/2);
% transmit signal
MSK_signal=I_data.*I_carrier+Q_data1.*Q_carrier;
 
snr=1;  
MSK_receive=awgn(MSK_signal,snr);
% demodulate 
I_output=MSK_receive.*I_carrier;
 
Hd=myfilter;
I_filter_ouput=filter(Hd,I_output);
Q_output=MSK_receive.*Q_carrier;
Q_filter_ouput=filter(Hd,Q_output);
 
for i=1:N/2
    if I_filter_ouput((2*i-1)*number_delay)>0
        I_recover(i)=1;
    else
        I_recover(i)=-1;
    end
    if Q_filter_ouput(2*i*number_delay)>0
        Q_recover(i)=1;
    else
        Q_recover(i)=-1;
    end
end
bit_recover=[];
for i=1:N
    if mod(i,2)~=0
        bit_recover=[bit_recover,I_recover((i-1)/2+1)];
    else
        bit_recover=[bit_recover,Q_recover(i/2)];
    end
end
 
% decode
for i=1:N
    if i==1
        bit_recover1(i)=bit_recover(i);
    else
        bit_recover1(i)=bit_recover(i)*bit_recover(i-1);
    end
end
recover_data=[];
for i=1:N
    recover_data=[recover_data,bit_recover1(i)*ones(1,T*Fs)];
end
 
% plot 
figure();
t=0:1/Fs:N*T-1/Fs;
bit_stream=[];
for i=1:N
    bit_stream=[bit_stream,bitstream1(i)*ones(1,T*Fs)];
end
subplot(2,1,2)
plot(t,bit_stream);legend('original Bitstream')
subplot(2,1,1)
plot(t,recover_data);legend('recover Bitstream')

Fourth, the result





myfilter is a function designed and generated by calling the filter designer through the matlab command line

V. Conclusion

In MSK modulation and demodulation, the generated and received signals can be restored, that is, the modulated I, Q and MSK signals can be restored to the original signal after demodulation. Although the filter design is different, it still does not affect the final result.

Intelligent Recommendation

MSK modulation and demodulation (matlab, detailed introduction to the design of simulation schemes, results and conclusions, personal summary experience, complete code and comments)

MSK modem directory 1. Simulation requirements Second, the detailed design of the simulation program 3. Simulation results and conclusions 4. Summary and experience Five, simulation code 1. Simulation...

Matlab realizes the time series and sampling frequency of the modulation and demodulation model

How does matlab generate time series? (1) In matlab, the signal length/sampling frequency is the time. (2) If you want to get a short period of time, you can consider dividing the signal length, and t...

C++ realizes QAM16 modulation and demodulation

QAM16 modem Briefly explain that QAM16 modulation is the use of QPSK and 4ASK together. Compared with separate QPSK and 4ASK, it can improve the efficiency of spectrum utilization. There is no wavefor...

Based on Matlab----16QAM modulation and demodulation

Based on Matlab----16QAM modulation and demodulation 1. Title 2. Simulation requirements Three, the main code 3.1, 16QAM modulation 3.2, 16QAM demodulation 3.3, all code 4. Simulation results 1. Title...

MATLAB program: 8PSK modulation and demodulation

BPSK/QPSK modulation and demodulation refer to this blog: This article gives the 8PSK modulation and demodulation matlab code according to the author's ideas. (Naming not modified) For the principle o...

More Recommendation

FM modulation and demodulation Matlab code

Problem description To be completed. . . . . It's too late, it's early in the morning, tomorrow will be the whole day....

4PAM modulation and demodulation (MATLAB implementation)

Experimental principle This is a line encoding using pulse amplitude modulation technology. The PAM4 signal has four voltages, each of which corresponds to logic bits 00, 01, 10, and 11, respectively....

Matlab-MSK modulation and demodulation of the information generated by MSK signals, the comparison chart of I channel and Q channel signals, the comparison chart of demodulated information recovery at the receiving end, the comparison chart of I channel, Q channel carrier signal and the filtered signal

The environment of this blog is Matlab2018, and there may be some discrepancies in different software versions and need to be modified slightly. MSK modulation and demodulation Simulation requirements...

Python realizes BPSK modulation signal demodulation

As we all know, the toolbox of signal processing in matlab is very powerful, but because of some real-time requirements for deep learning, bloggers have to go to python, the following is a complete te...

Digital communication-MSK modulation and demodulation, the relationship between bit error rate and signal-to-noise ratio under Viterbi decoding

Preface A MATLAB simulation for msk modulation and demodulation under digital communication, and the use of Viterbi algorithm to achieve Viterbi decoding. Through Viterbi decoding to achieve some pers...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top