Reducing the Error Rate Using a Hamming Code
Reducing the Error Rate Using a Hamming Code
O!ecti"e
O!ecti"e: to reduce the error rate in Channel Noise Model by using a Hamming: to reduce the error rate in Channel Noise Model by using a Hamming code.
code. Too#s
Too#s: MAT: MATLAB, Simulink, LAB, Simulink, Communications Blockset.Communications Blockset. $ro
$rocecedudurere:: A.
A. StStarart t MAMATTLALAB B by by dodoububleleclclicickiking ng ththe e MAMATTLALAB B icicon on or or go go to to !s!statartrt" " anandd !#r
!#rogrogram"am", , thethen n searsearch ch $or $or the the MAMATTLAB LAB #ro#rogragram m $ol$older der and and thethen n cliclick ck thethe !MATLAB".
!MATLAB". B
B.. TTyy##e e iinn simulink simulink toto o#en a ne% %indo%. Click on the !Communicationso#en a ne% %indo%. Click on the !Communications
Blockset", it %ill o#en all sublibraries o$ communications. Blockset", it %ill o#en all sublibraries o$ communications.
C%Bui#ding the Hamming Code Mode# C%Bui#ding the Hamming Code Mode# &
&.. TTyy##ee channeldocchanneldoc at the MAT at the MATLAB #rom#t to o#en the cLAB #rom#t to o#en the channel noise model. Thenhannel noise model. Then
sa'e the model as my(hamming in the directory %here you kee# your %ork $iles. sa'e the model as my(hamming in the directory %here you kee# your %ork $iles. ).
). *rag th*rag the $olloe $ollo%ing t%%ing t%o Commo Communicatiunications Bloons Blockset blckset blocks $roocks $rom the Simm the Simulinkulink Library Bro%ser into the model %indo%:
Library Bro%ser into the model %indo%:
•
• Hamming +ncoder block, $rom the Block sublibrary o$ the +rror *etectionHamming +ncoder block, $rom the Block sublibrary o$ the +rror *etection
and Correction library and Correction library
•
• Hamming *ecoder block, $rom the Block sublibrary o$ the +rror *etectionHamming *ecoder block, $rom the Block sublibrary o$ the +rror *etection
and Correction library and Correction library .
. Click thClick the right be right border oorder o$ the mod$ the model and drael and drag it to the rig it to the right to %ght to %iden thiden the modele model %indo%.
%indo%.
Reducing the Error Rate Using a Hamming Code Reducing the Error Rate Using a Hamming Code ECCE Communication Lab
. Mo'e the Binary Symmetric Channel block, the +rror /ate Calculation block, and the *is#lay block to the right by clicking and dragging. This creates more s#ace bet%een the Binary Symmetric Channel block and the blocks ne0t to it. The model
should no% look like the $ollo%ing $igure.
1. Click the Hamming +ncoder block and drag it on to# o$ the line bet%een the
Bernoulli Binary 2enerator block and the Binary Symmetric Channel block, to the right o$ the branch #oint, as sho%n in the $ollo%ing $igure. Then release the mouse button. The Hamming +ncoder block should automatically connect to the line
$rom the Bernoulli Binary 2enerator block to the Binary Symmetric Channel block.
3. Click the Hamming *ecoder block and drag it on to# o$ the line bet%een the Binary Symmetric Channel block and the +rror /ate Calculation block. &% 'etting $arameters in the Hamming Code Mode#
*oubleclick the Bernoulli Binary 2enerator block and make the $ollo%ing changes to the #arameter settings in the block4s dialog bo0, as sho%n in the $ollo%ing $igure:
*% Running the Hamming Code Mode#
To run the model, select Simulation 8 Start. The model terminates a$ter &99 errors occur. The error rate, dis#layed in the to# %indo% o$ the *is#lay block, is
a##ro0imately .99&.
+% Ans,er -o##o,ing .uestions
&. Change the nitial seed #arameters in the model or run a simulation $or a
di$$erent length o$ time. ;hat is the error rate dis#layed in the to# %indo% o$ the *is#lay block<
). ;hy the error rate is al%ays a##ro0imately 9.99& %hen the channel error is 9.9&< . Change the channel error #robability to 9.9), 9.9=. ;hat is the error rate a$ter
the Hamming decoding< Com#are your simulation results and theoretical results. . Ho% to obtain a lo%er error rate $or the same #robability o$ error<
/Optiona#0 ,hen )ou ha"e -inished a## ao"e steps1
Disp#a)ing 2rame 'i3es
5ou can dis#lay the si>es o$ data $rames in di$$erent #arts o$ the model by selecting Signal dimensions $rom the -ort?signal dis#lays submenu o$ the 6ormat menu at the to# o$ the model %indo%. This is sho%n in the $ollo%ing $igure. The line leading out o$ the Bernoulli Binary 2enerator block is labeled @0&, indicating that its out#ut consists o$ column 'ectors o$ si>e . Because the Hamming +ncoder block uses a @, code, it con'erts $rames o$ si>e into $rames o$ si>e , so its out#ut is labeled @0&.
Adding a 'cope to the Mode#
To dis#lay the channel errors #roduced by the Binary Symmetric Channel block, add a Sco#e block to the model. This is a good %ay to see %hether your model is
$unctioning correctly. The e0am#le sho%n in the $ollo%ing $igure sho%s %here to insert the Sco#e block into the model.
Reducing the Error Rate Using a Hamming Code
'etting $arameters in the E4panded Mode#
Make the $ollo%ing changes to the #arameters $or the blocks you added to the model. Error Rate Ca#cu#ation B#ock
*oubleclick the +rror /ate Calculation block and clear the bo0 ne0t to Sto# simulation in the block4s dialog bo0.
'cope B#ock
The Sco#e block dis#lays the channel errors and uncorrected errors. To con$igure the block,
• *oubleclick the block to o#en the sco#e, i$ it is not already o#en. • Click the -arameters button on the toolbar.
• Set Time range to 1999. • Click the *ata history tab.
• Ty#e 9999 in the Limit data #oints to last $ield, and click D.
• ;iden the sco#e %indo% until it is roughly three times as %ide as it is high.
5ou can do this by clicking the right border o$ the %indo% and dragging the border to the right, %hile #ressing the mouse button.
Re#ationa# Operator
Set /elational #erator to EF in the block4s dialog bo0. The /elational #erator block com#ares the transmitted signal, coming $rom the Bernoulli /andom 2enerator block, %ith the recei'ed signal, coming $rom the Hamming *ecoder block. The block
out#uts a 9 %hen the t%o signals agree and a & %hen they disagree. Oser"ing Channe# Errors ,ith the 'cope
;hen you run the model, the Sco#e block dis#lays the error data. At the end o$ each 1999 time ste#s, the sco#e a##ears as sho%n in the $ollo%ing $igure. The sco#e then clears the dis#layed data and dis#lays the ne0t 1999 data #oints.
Sco#e %ith Model /unning
The u##er sco#e sho%s the channel errors generated by the Binary Symmetric Channel block. The lo%er sco#e sho%s errors that are not corrected by channel coding.
Click the Sto# button on the toolbar at the to# o$ the model %indo% to sto# the sco#e. To >oom in on the sco#e so that you can see indi'idual errors, $irst click the middle magni$ying glass button at the to# le$t o$ the Sco#e %indo%. Then click one o$ the lines in the lo%er sco#e. This >ooms in hori>ontally on the line. Continue clicking the lines in the lo%er sco#e until the hori>ontal scale is $ine enough to detect indi'idual errors. A ty#ical e0am#le o$ %hat you might see is sho%n in the $igure belo%.
Gooming n on the Sco#e
Reducing the Error Rate Using a Hamming Code
The %ider rectangular #ulse in the middle o$ the u##er sco#e re#resents t%o &s. These t%o errors, %hich occur in a single code%ord, are not corrected. This accounts $or the uncorrected errors in the lo%er sco#e. The narro%er rectangular #ulse to the right o$ the u##er sco#e re#resents a single error, %hich is corrected.
;hen you are done obser'ing the errors, select Simulation 8 Sto#.
E4p#ain ho, to send the error data to the MATLAB ,orkspace -or more detai#ed ana#)sis%