Project Report - s3.amazonaws.com

advertisement
ECE 342 Hardware Project
Project Report
Carl Reed
12-11-13
Introduction
The purpose of this project is to observe the transmission and receipt of data via radio
transmission. Our group used two USRP (Universal Software Radio Peripheral) devices; one
to modulate and transmit data bits, one to receive and demodulate. We then calculated the
error ratio of bits and error ratio of human language characters. The error rate represents the
amount of mistransmitted bits or characters, divided by the total amount of transmitted bits or
characters.
Synchronizing transmitter and receiver:
Knowing which transmitted bit is supposed to match which received bit can be a challenge.
There are a few ways to synchronize bit streams. One can either insert a special sequence of
bits, called a flag sequence, before the message, or use a bit header. The contents of stuff.m
are listed below. This MATLAB script aids with the bit stuffing method. A user may input any
sequence of 0’s and 1’s, if a flag sequence is found (‘1 0 0 0 0 0 0 1’), a 1 is stuffed into the
sequence so the receiver will not register that part of the message as a flag sequence. Before
the receiver converts binary to decimal (or anything else), it can “destuff” any stuffed bits. The
MATLAB script destuff.m is shown below. It will perform such a destuffing operation on any
sequence of bits.
stuff.m:
%This script performs bit stuffing
%Since the flag bits are 10000001, we assume '1' stuffing:
% 10000001 found in the message becomes
% 100000101
%
^
%msg variable is created to store the input from the user.
msg = input('Please input binary bit stream: ')
%Input sample:
%[0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 1]
%
^ ^ ^ ^ ^ ^ ^ ^
%
flag sequence
[M,N] = size(msg);
%stuffed variable counts bits stuffed into input message.
stuffed = 0;
for i = 1:N-7
%Take the number of added bits into account.
j = i+stuffed;
%Do bits i through i+7 match flag pattern?
if msg(j)==1 && msg(j+1)==0 && msg(j+2)==0 && msg(j+3)==0 && msg(j+4)==0 &&
msg(j+5)==0 && msg(j+6)==0 && msg(j+7)==1
%then recreate msg with stuffed bit msg(j+6)
msg = [msg(1:j+5) 1 msg(j+6:end)];
stuffed = stuffed + 1;
end
end
%Display the number of bits destuffed and the output message
stuffed
msg
%Output sample:
%[0 1 0 0 0 1 0 0 0 0 0 1 0 1 1 1 0 1]
%
^ ^ ^ ^ ^ ^ O ^ ^
%
stuffed flag
destuff.m:
%This script performs destuffing
%Since the flag bits are 10000001, we assume '1' stuffing:
% 10000001 found in the message becomes
% 100000101
%
^
%msg variable is created to store the input from the user.
msg = input('Please input binary bit stream: ')
%Input sample:
%[0 1 0 0 0 1 0 0 0 0 0 1 0 1 1 1 0 1]
%
^ ^ ^ ^ ^ ^ ^ ^ ^
%
stuffed flag
-Let's destuff it!
[M,N] = size(msg);
%destuffed counts bits destuffed from input message.
destuffed = 0;
for i = 1:N-8
%Take destuffed bits into account
j = i - destuffed;
%Do bits i through i+8 match stuffed flag pattern?
if msg(j)==1 && msg(j+1)==0 && msg(j+2)==0 && msg(j+3)==0 && msg(j+4)==0 &&
msg(j+5)==0 && msg(j+6)==1 && msg(j+7)==0 && msg(j+8)==1
%then recreate msg, excluding stuffed bit msg(j+6)
msg = [msg(1:j+5) msg(j+7:end)];
destuffed = destuffed + 1;
end
end
%Display the number of bits destuffed and the output message
destuffed
msg
%Output sample:
%[0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 1]
%
^ ^ ^ ^ ^ ^X^ ^
%
destuffed flag
Experiment
For our experiment, we used a sequence of 40 bits as a header. Our transmitter continually
transmitted header-message-header-message data for 100 seconds. We used a string pattern
matching functions in MATLAB to then synchronize bits from the transmitter with the received
data. We repeated this five times, at increasing power levels.To calculate our error rates:
Err rate = 1 - (Number of incorrect bits/characters) / (total number of bits/characters)
Error rates:
Conclusion
As expected, the human language error rate is proportional to the bit rate error. In fact, the
human language error rates are close to 8 times as high as the bit rate error. This is logical, as
each human-language encoded character is made up of 8 bits; if any of the bits of one character
are incorrect, the character will be incorrect.
However, we expected the error rates to decrease as power was increased. Increasing the
power should make the signal stronger, and mistransmitted bits more rare. The 3rd and 4th
samples do not reflect this. Local interference or slight changes in the controlled variables-antennae angle, distance, etc—could be the cause for the unexpected rise in error rate.
Download