Main Content

Find Delay for Encoded and Filtered Signal

Determine the delay for a convolutionally encoded and filtered link. Use the delay to accurately determine the number of bit errors.

Create a QPSK modulator and demodulator pair. Specify the objects to operate on bits.

qpskmod = comm.QPSKModulator(BitInput=true);
qpskdemod = comm.QPSKDemodulator(BitOutput=true);

Create a raised cosine transmit and receive filter pair.

txfilt = comm.RaisedCosineTransmitFilter;
rxfilt = comm.RaisedCosineReceiveFilter;

Create a convolutional encoder and Viterbi decoder pair.

convEnc = comm.ConvolutionalEncoder;
vitDec = comm.ViterbiDecoder(InputFormat='Hard');

Generate random binary data. Convolutionally encode the data.

txData = randi([0 1],1000,1);
encData = convEnc(txData);

Modulate the encoded data. Pass the modulated data through the raised cosine transmit filter.

modSig = qpskmod(encData);
txSig = txfilt(modSig);

Pass the filtered signal through an AWGN channel.

rxSig = awgn(txSig,20,'measured');

Filter and then demodulate the received signal.

filtSig = rxfilt(rxSig);
demodSig = qpskdemod(filtSig);

Decode the demodulated data.

rxData = vitDec(demodSig);

Find the delay between the transmitted and received binary data by using the finddelay function.

td = finddelay(txData,rxData)
td = 44

Confirm that the computed delay matches the expected delay, which is equal to the sum of the group delay of the matched filters and the traceback depth of the Viterbi decoder.

tdexpected = ( ...
    txfilt.FilterSpanInSymbols + rxfilt.FilterSpanInSymbols)/2 + ...
ans = logical

Calculate the number of bit errors by discarding the last td bits from the transmitted sequence and discarding the first td bits from the received sequence.

numErrors = biterr(txData(1:end-td),rxData(td+1:end))
numErrors = 0