ON OFF Keying matlab code | ON OFF Keying modulation matlab source code

This page of MATLAB source code covers ON OFF Keying matlab code. The output plots and mathematical equations of ON OFF Keying modulation matlab code are mentioned.

Introduction:
As mentioned OOK stands for ON OFF KEYING (OOK). It is digital modulation technique in which amplitude of carrier signal varies according to digital binary stream. In OOK modulation, carrier signal with certain amplitude is transmitted when binary logic-1 is present and no carrier transmission takes place when binary logic-0 is present.

OOK modulation

The figure-1 depicts OOK modulation waveforms at inputs and output. Refer difference between OOK vs FSK vs ASK>>.

ON OFF Keying matlab code

clear all																						
close all
tic
x = [1 0 0 0 0 0 0];
l = length(x);
sp = input('The Speed of Transmission for the Data');
d = input('The Number of data points you want to transmit');
lq = input('The number of times you want to transmit the data');
filat = input('Do you want to use a filter in this transmisssion, if yes press 1');
duty = input('What is the duty Ratio you want to use for the RZ pulse, must be less than 1');
i = 0;
while (j < (2^l - 1))
y = xor(x(6),x(7));
temp = [y,x];
x = temp;
j = length(x);
end
data(1:d) = zeros;
while(i<d)
dgen(i+1:i+j) = x;
i = length(dgen);
if (i>d)
data(1:d) = dgen(1:d);
clear dgen temp
t = (1/(32*sp))*(1:1:(32*d));
end
end
% Pulse Generation
% NRZ, RZ
nr(1:32) = ones;
rz(1:32) = zeros;
lo = nearest(duty*32);
rz(1:lo) = ones;
data2 = kron(data,nr);
data3 = kron(data,rz);
subplot(2,1,1),plot(t,data2);hold
grid minor
subplot(2,1,2),plot(t,data3);hold
grid minor
datt2(1:d) = zeros;
datt3(1:d) = zeros;
if (filat == 1)
[B,A] = besself(5,0.8*10^9*2*pi);
[NUMd,DENd] = bilinear(B,A, 32*10^9);
datat2 = filter(NUMd,DENd,data2);
datat3 = filter(NUMd,DENd,data3);
else
datat2 = data2;
datat3 = data3;
end
subplot(2,1,1),plot(t,datat2,'-r');
grid minor
subplot(2,1,2),plot(t,datat3,'-r');
grid minor
h = waitbar(0,'Error Computation');
BER1(1:lq,1:10) = zeros;
BER2(1:lq,1:10) = zeros;
for rep = 1:lq
for SNR = 1:10;
Pn2 =(sum(datat2.^2)/(length(datat2)))* 1*10^(-SNR/20);
Pn3 =(sum(datat3.^2)/(length(datat3)))* 1*10^(-SNR/20);
dat2 = datat2+(Pn2*randn(1,length(datat2)));
dat3 = datat3+(Pn3*randn(1,length(datat3)));
j = 0;
i =1;
lent = length(datat2);
while(j<=lent-1)
if(dat2(j+16)<0.5)
datt2(i) = 0;
else
datt2(i) =1;
end
if(dat3(j+nearest(lo/2))<0.5)
datt3(i) = 0;
else
datt3(i) =1;
end
j = j+ 32;
i = i+1;
end
BER1(rep,SNR) = mean(data~=datt2)/length(data);
BER2(rep,SNR) = mean(data~=datt3)/length(data);
waitbar((SNR+((rep-1)*10))/(10*lq),h);
end

end
close(h)
BER1x = sum(BER1(1:lq,:))/lq;
BER2x = sum(BER2(1:lq,:))/lq;
figure(2),semilogy(BER1x);
hold
semilogy(BER2x,'-r');
toc

Input and Output of ON OFF Keying modulation matlab source code

Run the downloaded ONOFFKEyingModulation.m file after unzipping the folder. and provide input as follows.

ON OFF Keying matlab code input

After the input is given press "ENTER" key, you will get output matlab images as below.

ON OFF-Keying matlab code output1
ON OFF-Keying matlab code output2

DOWNLOAD ON OFF Keying matlab code .m file

Download ON OFF Keying Modulation rar file containing matlab file>>.


Useful Links to MATLAB codes

Refer following as well as links mentioned on left side panel for useful MATLAB codes.
OFDM Preamble generation  Time off estimation corr  Freq off estimation corr  channel estimation  11a WLAN channel  PN sequence generation  OFDMA Tx Rx  AES DES  carrier aggregation  CCDF  FIR Filter  IIR Filter  Low Pass FIR  Viterbi decoder  CRC8 CRC32 

RF and Wireless tutorials

WLAN  802.11ac  802.11ad  wimax  Zigbee  z-wave  GSM  LTE  UMTS  Bluetooth  UWB  IoT  satellite  Antenna  RADAR