Communications System Simulation Using Simulink
Communications System Simulation Using Simulink
Contents
1 2 Abstract ........................................................................................................................1 Theory ..........................................................................................................................1 2.1 Basic analog channel...............................................................................................1 2.2 Basic digital channel ...............................................................................................1 2.3 Symbol Error Ratio ................................................................................................3 3 4 Simulink introduction ..................................................................................................3 Block descriptions.........................................................................................................5 4.1 Analog transmission system....................................................................................6 4.1.1 Transmission channel ...........................................................................................6 4.1.1.1 Random signal generator..............................................................................6 4.1.1.2 AWGN channel............................................................................................7 4.1.1.3 Error rate calculation ....................................................................................8 4.1.1.4 Goto & From blocks.....................................................................................9 4.1.1.5 Mux block..................................................................................................10 4.1.2 Measurement tools section..................................................................................10 4.1.2.1 Display.......................................................................................................11 4.1.2.2 Time scope.................................................................................................11 4.2 Digital transmission system ..................................................................................13 4.2.1 Transmission channel .........................................................................................13 4.2.1.1 Bernoulli random binary generator .............................................................13 4.2.1.2 Binary channel ...........................................................................................14 4.3 Other blocks ..........................................................................................................15 4.3.1 Block info ..........................................................................................................15 4.3.2 Block underlining, highlighting ..........................................................................15 5 The system basics .......................................................................................................16 5.1 The system setup parameters ...............................................................................17 5.1.1 Initial commands ................................................................................................17 5.2 The signals flow.....................................................................................................17 5.3 Transmission analyses ..........................................................................................19 5.3.1 Channel influence on transmission quality..........................................................19 5.3.2 Channel influence on transmitted signal..............................................................20
2 Theory
All electronic elements communicate between each other. Such communication can be divided into two main types: analog digital Different transmission schemes can be applied in different stages of every system, depending on the electronic architecture. Additionally, there are no systems that can exist without distortions. In general, wherever electronics is used, the noise degrades transmission quality.
The conclusion can then be drawn that it is enough to perform logical sum modulo2 (XOR) between the binary data and a binary error signal (Table 1) instead of summing the binary data with analog noise. This is equivalent to perform a modulo 2 summation that changes transmitted information to the opposite value whenever the error signal is equal to 1. Simulink includes a binary error channel, which is the best choice for binary transmission analysis.
Table 1. The binary channel effect.
Information Signal 1 0 1 0
Error signal 1 1 0 0
Result 0 1 1 0
BER[%] =
(2).
3 Simulink introduction
To start Simulink you have to run Matlab and execute <Simulink> command in Matlab command window(Fig.1) or click simulink icon on the Toolbar.
Fig.1. Starting Simulink from the Matlab command window A Simulink window appears. You can use a particular block by dragging it into the model window (see Fig.3). Before running the simulation you have to set the simulation parameters by selecting Parameters from Simulation menu in the Model window (fig.2).
Fig.2 Accessing the parameter dialog box. The parameter dialog box consists of three pages (fig.4): Solver Workspace I/O Diagnostics The Solver page allows you to: set the simulation start and stop parameters choose solver algorithm and specify its parameters select output options
The Workspace I/O page allows you to: direct simulation output to workspace variables get input and initial states from the workspace The Diagnostics tab allows you to: select desired action for many types of events or conditions that can be encountered during simulation All tabs are clearly described in the Simulink help text (click the HELP button, fig.4).
4 Block descriptions
The system introduces two, basic transmission schemes and allows the user to choose which one to analyze: Transmission over an AWGN channel (fig.5), Transmission over a binary channel (fig.6.).
Mean, Variance By default, the produced sequence has a mean value of 0 and a variance of 1, although you can vary these parameters by changing particular values in the input data fields. Initial seed The Random Signal Generator generates normally distributed random numbers. The Seed is reset to the specified value each time the simulation starts. Sample time The sample time defines the time interval between samples. This parameter is set to 1 in the main model mask definition in section Initial commands. 4.1.1.2 AWGN channel The AWGN Channel block can be used with either real or complex valued input signals. When the input signal is real, this block adds real Gaussian noise and produces a real output signal. When the input signal is complex, this block generates complex Gaussian noise and produces a complex output signal. Mode There are three modes defined in the model mask, which can be used during simulation (fig.8): Signal to noise ratio Variance from mask Variance from port
Fig.8. AWGN channel mask In this manual Signal to noise ratio is to be specified. Thus, variance is calculated from the following parameters: Es/No, the ratio of energy per symbol to noise energy The input signal power The symbol period
Other modes are not important in this system, thus their description will be omitted. ES/N0 (dB) SNR parameter is to be specified in decibels (1): 10log10(ES/N0) (1)
4.1.1.3 Error rate calculation The Error Rate Calculation block compares the transmitted signal with its distorted, received version. By default, the model from the library calculates the error rate by dividing the total number of data elements that are not equal by the total number of received data samples. In case of the AWGN channel, there are no equal samples, since additive noise distorts each fragment of the transmitted signal. In order to simulate a real receiver with a soft decision system1, the Error Rate Calculation model, needs some insignificant modifications to allow the user to specify the maximal difference between transmitted and received signals that is not recognized as an error. To perform such system modification do the following: first it is necessary to select the Error Rate Calculation block, then choose BREAK LIBRARY LINK form EDIT menu. Under the mask several models appears (Fig.9). The modification was applied in the Determine Symbols in Error block. The specified maximal difference between the transmitted and received data that does not generate an error was changed from 0 to the threshold variable (Fig.10). The parameter value is inherited from the main model mask. Also, to pass the threshold value from outside the model, the subsystem mask needs to be insignificantly modified (Fig.11).
Each sample is compared with the range [a:b], if it is included in this region the received sample is assumed to be the ideal value e.g. defined as a+b/2. When a hard decision is analyzed the range is replaced with a finite set of possible values.
Fig.10. Determining Symbols in the Error subsystem. The Threshold value is defined to be constant in the main system mask in the Initial commands section.
Fig.11. Error Rate Calculation mask (left - before, right - after). Due to the added Error checking threshold parameter, the Threshold value will be passed inside the subsystem. The data produced at the output of the Error Rate Calculation block is a vector whose entries correspond to: The error rate The number of error events The total number of input events 4.1.1.4 Goto & From blocks The Goto block passes its input to its corresponding From block. The input can be a realor complex-valued signal or a vector of any data type. From and Goto blocks allow you to pass a signal from one block to another without actually connecting them. The Goto block can pass its input signal to more than one From block, although the From block can only receive a signal from one Goto block.
Fig.12. Goto & From block dialog boxes. Tag, Goto tag The two blocks: Goto and From, can be considered as physically connected if their Tag and Goto tag names, specified in the parameter entry field (Fig.12), are the same. Tag visibility The Tag visibility parameter determines how the location of the From blocks that access the signal is limited: local, the default, means that the From and Goto blocks using the tag must be in the same subsystem. A local tag name is enclosed in square brackets ([]). scoped means that the From and Goto blocks using the same tag must be in the same subsystem or in any subsystem below the Goto Tag Visibility block in the model hierarchy. A scoped tag name is enclosed in braces ({}). global means that the From and Goto blocks using the same tag can be anywhere in the model. 4.1.1.5 Mux block Multiplexes Number of inputs signals (fig.13).
4.1.2.1 Display The display presents the value of its input. If the input is a vector, vector length values are displayed (fig.14).
Fig.14. Display setup mask. 4.1.2.2 Time scope the scope block displays its input plotted against the simulation time. The number of inputs is equal to the number of separate plots with a common time range. Block inherits the sample time from the incoming signal, but decimation can be changed in the block properties dialog box, increasing the time interval between plotted samples. The scope provides a set of toolbar buttons that enable the user to: zoom in / zoom out on the displayed data display all the data inputs to the Scope preserve axes settings from one simulation to the next limit displayed data, and save data to the workspace The toolbar buttons are labeled in the figure 4. It shows the Scope window as it appears when you open the standard Scope block by double clicking on its icon.
Fig.15. Standard Time Scope window. Auto-scale The Auto-scale toolbar button automatically scales both axes to display all the stored simulation data.
Properties
Properties allow the user to: change axes limits set the number of axes set time range,tick labels set sampling parameters set saving options Save Axes settings
The Save axes settings toolbar button enables the user to store the current x- and y-axis settings so they can be applied to the next simulation. Some more detailed information about the Time scope can be found in the Help displayed by clicking the Help button on the Properties dialog box.
General Parameters The user can set the axes parameters, time range, tick labels, and can also choose the floating scope in the General tab. Number of axes Sets the number of separate plots. If floating scope is selected, only one plot can be displayed, regardless of the value of the number of axes parameter. Floating scope A floating Scope selection allows the user to display the signals carried on one or more lines without an actual connection to the measurement tool. To use the floating scope during simulation and display the signals carried in a single line, select the line. Hold down the Shift key while clicking on another line to select multiple lines. Note that all the signals will be presented in a single plot. A model can contain more than one floating Scope, although generally, it is not useful to have more than one floating Scope in a window because they will display the same signals. If you plan to use a floating scope during simulation, you should disable buffer reuse. See Disable optimized I/O storage in Matlab/Help for more information.
Fig. 17. Binary generator setup mask. Probability of zero When set to 0.5 the same average number of ones and zeros occur in a particular time range.
Seed Defines the generator initial state. Sample time Defines the time interval between transmitted binary symbols. 4.2.1.2 Binary channel Binary signals transmitted over the channel are to be distorted by the logically additive binary error signal, generated in the channel subsystem. The noise signal in the channel is generated from the random integer signal with a Poisson distribution, converted to binary form by saturation. The user is required to set the basic model parameters, depicted in figure 18. The top output of the model outputs transmitted, distorted signal, while the second output port outputs the error signal.
Fig.18. Binary channel setup mask. Error probability The error probability parameter is inherited from the main model mask, and is defined by the user before starting the simulation. Input vector length In this system the input signal is a scalar, thus this parameter should be set to 1. Seed Defines the initial state of the noise generator. Sample time Should be equal to the time interval between binary symbols in the input signal, in order to correctly simulate the channels influence on the transmitted signal.
Fig.19. Model info definition dialog box. The block allows the user to type in the information text and perform text alignment. Additionally, the block frame can be removed. To change font properties select the model and choose FONT from FORMAT menu.
Fig.20. Two subsystems with mask defined to remove the plotted icon. The displaying is performed in accordance with the alphabetic order. E.g. model named a is displayed on the top of the model named b, etc (fig.21).
Fig.22. The systems setup dialog boxes. The main mask (fig.22), allows user to set basic parameters of the two models introducing basic analog and digital transmission. The analog channel requires the signal to noise ratio in decibels to be specified, while the digital channel only accepts an error probability ratio in the range from 0 to 1.
In digital systems is it equivalent to the time duration between the bits to be transmitted.
Fig.24. Analog system mask definition with initialization parameter setup. Generated binary/analog signals are transmitted over a binary/AWGN channel, where both of them are distorted due to the channel noise (fig.25, fig.26).
Fig.26. Digital transmission channel. Next, both transmitted and received signals are compared in the Error Rate Calculation block. Obtained transmission statistics are presented using the display in the Measurement tools section.
1,E+00
SER
1,E-01
Fig.27. Symbol error ratio verses SNR parameter; analog signal transmitted over AWGN channel.
Fig.29. Transmitted vs. received signal in the digital transmission system. Channel error signal is summed modulo 2 with the information signal.