Hi! I am Mahanta, a final student of communication enginerring. I'm recently doing a project regarding modulation algorithms by using matlab version 6.5.
I'v built up a simple NRZI encoding algorithm2 convert the binary inputs into analog signal. Ayw, when i come2 the effort adding bit stuffing in this NRZI, I'm totally lose n don't know where2 start. Could someone pls give idea2 me how2 implement bit stuffing in matlab code?
btw, NRZI stands for Non-Return-to-Zero Inverted & bit stuffing is used2 solve the problem of loosing synchronizatin with NRZI. In bit stuffing technique, each time a series of 5 consecutive '0' bits are transmitted, a '1' bit will automatically added to force a transition.
Below is the NRZI function i've developed. my assignations are :
fs=100Hz, Rb=1bps, M=2, binary_sequence_2 = [0 0 0 0 0 0 1 1 1 0 0 1 0 1 0 0]. i've oso attached the simulation result.
function Baseband_encoding = NRZI(binary_sequence,fs, Rb)
%=================NRZI======================
%---------wave_gen----------------------
Ts = 1/fs; % Sampling period
Tb = 1/Rb; % Binary data period;
no_binary = length(binary_sequence); % Number of bits to be coded
no_sample = no_binary * Tb/Ts; % Number of samples to be
time_t = [0:(no_sample-1)] * Ts; % Sampling instances
binary_sequence = binary_sequence(:); % column vector.
%---------------rect_NRZ---------------------
out = ones(1,fs/Rb);
%---------------differiential-----------------
delay = 1;
initial = ones(delay,1);
ns = length(binary_sequence);
tmp = [initial(:); ones(ns,1)];
for n = 1:1:(ns)
tmp(n+delay) = xor(binary_sequence(n),tmp(n));
end
% --------binary to polar conversion---------
polar_sequence_2 = 2*tmp - ones(size(tmp));
%-------------output--------------------------
x = (polar_sequence_2*out)';
Baseband_encoding = x(:);