Extras: Simulink Basics Tutorial Block Libraries
Extras: Simulink Basics Tutorial Block Libraries
MODELING
ANALYSIS
CONTROL
Extras:SimulinkBasicsTutorial
BlockLibraries
Contents
PID
CommonlyUsedBlocks
ROOTLOCUS
FREQUENCY
STATESPACE
DIGITAL
Continuous
Discontinuities
Discrete
LogicandBitOperations
MathOperations
Sinks
SIMULINK
Sources
MODELING
canbebuild.TheseblocksarearrangedinBlockLibrarieswhich
areaccessedinthemainSimulinkwindowshownbelow
EachiconinthemainSimulinkwindowcanbedoubleclickedto
bring up the corresponding block library. Blocks in each library
canthenbedraggedintoamodelwindowtobuildamodel.
CommonlyUsedBlocks
CommonlyUsedBlocksareusedtolistalotofblockswhichare
usuallyused.DoubleclickontheCommonlyUsedBlocksiconin
the main Simulink windows to bring up the Commonly Used
window.
window.
BusCreator
TheBusCreatorblockcombinesasetofsignalsintoabus.
BusSelector
TheBusSelectorblockoutputsaspecifiedsubsetoftheelements
ofthebusatitsinput.Theblockcanoutputthespecifiedelements
asseparatesignalsorasanewbus.
Constant
TheConstantblockgeneratesarealorcomplexconstantvalue.
Theconstantoutputvalueisdisplayedinthemiddleoftheblock,
withadefaultvalueof1.
In order to examine these blocks, create a new model window
(select New from the File menu in the Simulink window or hit
Ctrl+N).
Tousethisblock,dragitfromtheCommonlyUsedBlockswindow
intoyournewmodelwindow.
Tochangetheconstantoutputvalue,doubleclickontheblockin
yourmodelwindowtobringupthefollowingdialogbox.
Changetheconstantvaluefieldfrom1tosomeothervalue,say,5,
and close the dialog box. Your model window will reflect the
updatebydisplayinga5inthemiddleoftheconstantblock.
DataTypeConversion
TheDataTypeConversionblockconvertsaninputsignalofany
SimulinkdatatypetothedatatypeyouspecifyfortheOutputdata
type parameter. The input can be any real or complexvalued
signal.
Demux,Mux
TheMux(Multiplexer)blockisusedtocombinetwoormorescalar
signals into a single vector signal. Similarly, a Demux
(Demultiplexer) block breaks a vector signal into scalar signal
components.Thenumberofvectorcomponentsmustbespecified
ineachcase.ForanexampleoftheuseofaMuxblockseethe
BusSuspensionModelinginSimulinkexample.
DiscreteTimeIntegrator
This is the discrete time approximation of a continuoustime
integrator.Theapproximationmethodcanbespecifiedaswellas
theinitialconditionandsaturationlimits.
Gain
TheGainblockmultipliestheinputbyaconstantvalue(gain).The
inputandthegaincaneachbeascalar,vector,ormatrix.
Ground
The Ground block connects to blocks whose input ports do not
connecttootherblocks.
In1
Inportblocksarethelinksfromoutsideasystemintothesystem.
Integrator
The output of the Integrator is the integral of the input. An initial
conditioncanbespecified,aswellassaturationlimits.Thisblock
isveryusefulformodelingsystemsinSimulink.
LogicalOperator
The Logical Operator block performs the specified logical
operationonitsinputs.AninputvalueisTRUE(1)ifitisnonzero
andFALSE(0)ifitiszero.
Out1
Outportblocksarethelinksfromasystemtoadestinationoutside
thesystem.
Product
Bydefault,theProductblockoutputstheresultofmultiplyingtwo
inputs: two scalars, a scalar and a nonscalar, or two nonscalars
thathavethesamedimensions.
RelationalOperator
By default, the Relational Operator block compares two inputs
usingtheRelationaloperatorparameterthatyouspecify.Thefirst
inputcorrespondstothetopinputportandthesecondinputtothe
bottominputport.
Saturation
TheSaturationblockimposesupperandlowerlimitsonaninput
signal.
Scope
TheScopeblockdisplaysinputssignalswithrespecttosimulation
time.
Subsystem
A Subsystem block represents a subsystem of the system that
contains it. The Subsystem block can represent a virtual
subsystemoranonvirtualsubsystem.
Sum
TheSumblockperformsadditionorsubtractiononitsinputs.This
block can add or subtract scalar, vector, or matrix inputs. It can
alsocollapsetheelementsofasignal.
Switch
The Switch block passes through the first input or the third input
basedonthevalueofthesecondinput.Thefirstandthirdinputs
arecalleddatainputs.Thesecondinputiscalledthecontrolinput.
Terminator
UsetheTerminatorblocktocapblockswhoseoutputportsdonot
connecttootherblocks.
UnitDelay
The Unit Delay block holds and delays its input by the sample
periodyouspecify.Thisblockisequivalenttothez1discretetime
operator.
VectorConcatenate
The Concatenate block concatenates the signals at its inputs to
create an output signal whose elements reside in contiguous
locationsinmemory.
Continuous
Continuous Blocks are elements of continuoustime dynamic
systems. Doubleclick on the Continuous icon in the main
SimulinkwindowtobringuptheContinuouswindow.
Derivative
Theoutputisequaltothederivativeoftheinput.
IntegratorLimited
TheIntegratorLimitedblockisidenticaltotheIntegratorblockwith
theexceptionthattheoutputoftheblockislimitedbasedonthe
upperandlowersaturationlimits.
Integrator,SecondOrder,Integrator,SecondOrderLimited
The SecondOrder Integrator block and the SecondOrder
Integrator Limited block solve the secondorder initial value
problem
PIDController
The PID Controller block output is a weighted sum of the input
signal, the integral of the input signal, and the derivative of the
input signal. The weights are the proportional, integral, and
derivativegainparameters.
PIDController(2DOF)
The PID Controller (2DOF) block generates an output signal
based on the difference between a reference signal and a
measuredsystemoutput.
StateSpace
A, B, C, and D matrices can be specified to create a LTI state
space system. Inputs and outputs may be vector signals
dependingonthesizesofthematrices.
TransferFunction
Numerator and denominator polynomials can be specified to
createastandardSISOLTIsystemtransferfunction.
TransportDelay
TheTransportDelayblockdelaystheinputbyaspecifiedamount
oftime.Youcanusethisblocktosimulateatimedelay.Theinput
tothisblockshouldbeacontinuoussignal.
VariableTimeDelay,VariableTransportDelay
TheVariableTransportDelayandVariableTimeDelayappearas
two blocks in the Simulink block library. However, they are the
sameSimulinkblockwithdifferentsettingsofaSelectdelaytype
parameter. Use this parameter to specify the mode in which the
blockoperates.
ZeroPole
The ZeroPole block models a system that you define with the
zeros,poles,andgainofaLaplacedomaintransferfunction.This
blockcanmodelsingleinputsingleoutput(SISO)andsingleinput
multipleoutput(SIMO)systems.
Discontinuities
Discontinuities Blocks are elements of discontinuoustime
dynamic systems. Most of these have specialpurpose
applications and will not be used in the tutorials. Only the most
relevant Discontinuities blocks will be discussed here. Double
click on the Discontinuities icon in the main Simulink window to
bringuptheDiscontinuitieswindow.
Backlash
The Backlash block implements a system in which a change in
input causes an equal change in output. . However, when the
inputchangesdirection,aninitialchangeininputhasnoeffecton
theoutput.
Coulomb&ViscousFriction
TheCoulombandViscousFrictionblockmodelsCoulomb(static)
andviscous(dynamic)friction.Theblockmodelsadiscontinuityat
zeroandalineargainotherwise.
DeadZone
The Dead Zone block generates zero output within a specified
region,calleditsdeadzone.
DeadZoneDynamic
TheDeadZoneDynamicblockdynamicallyboundstherangeof
theinputsignal,providingaregionofzerooutput.
HitCrossing
The Hit Crossing block detects when the input reaches the Hit
crossingoffsetparametervalueinthedirectionspecifiedbytheHit
crossingdirectionproperty.
Quantizer
The Quantizer block passes its input signal through a stairstep
function so that many neighboring points on the input axis are
mappedtoonepointontheoutputaxis.
RateLimiter
The Rate Limiter block limits the first derivative of the signal
passingthroughit.Theoutputchangesnofasterthanthespecified
limit.
RateLimiterDynamic
TheRateLimiterDynamicblocklimitstherisingandfallingratesof
thesignal.
Relay
TheRelayblockallowsitsoutputtoswitchbetweentwospecified
values. When the relay is on, it remains on until the input drops
belowthevalueoftheSwitchoffpointparameter.Whentherelay
isoff,itremainsoffuntiltheinputexceedsthevalueoftheSwitch
on point parameter. The block accepts one input and generates
oneoutput.
SaturationDynamic
TheSaturationDynamicblockboundstherangeofaninputsignal
toupperandlowersaturationvalues.
WrapToZero
TheWrapToZeroblocksetstheoutputtozerowhentheinputis
abovetheThresholdvalue.However,theblockoutputstheinput
whentheinputislessthanorequaltotheThreshold.
Discrete
DiscreteBlocksareelementsofdiscretetimedynamicsystems.
DoubleclickontheDiscreteiconinthemainSimulinkwindowto
bringuptheDiscretewindow.
Delay
TheDelayblockdelaysaninputuaccordingtotheDelaylength
parameter,whichyouspecifyonthedialogbox,oradelaylength
thatasignalsuppliestothedinputport.
Difference
The Difference block outputs the current input value minus the
previousinputvalue.
DiscreteDerivative
The Discrete Derivative block computes an optionally scaled
discretetimederivative.
DiscreteFilter
This is a discretetime filter in rational function form. Vectors
containingcoefficientsofthepolynomialsinz^1arespecified.
DiscreteFIRFilter
TheDiscreteFIRFilterblockindependentlyfilterseachchannelof
theinputsignalwiththespecifieddigitalFIRfilter.Theblockcan
implement static filters with fixed coefficients, as well as time
varyingfilterswithcoefficientsthatchangeovertime.
DiscreteStateSpace
Thisisadiscretetimedynamicsysteminstatespaceform.A,B,C,
andDmatricescanbespecified,aswellasinitialconditions.
DiscreteTransferFcn
ThisisthestandardformofaSISOLTIdiscretetimesystem.The
transfer function polynomials are represented as coefficient
vectorsintermsofz.
DiscreteZeroPole
A discretetime transfer function can be represented as list of z
planepolesandzeros.Thegaincanalsobespecified.
FirstOrderHold
The FirstOrder Hold block implements a firstorder sampleand
hold that operates at the specified sampling interval. This block
has little value in practical applications and is included primarily
foracademicpurposes.
Memory
The Memory block holds and delays its input by one integration
timestep.Thisblockacceptsandoutputscontinuoussignals.The
block accepts one input and generates one output. Each signal
canbescalarorvector.
TappedDelay
TheTappedDelayblockdelaysaninputbythespecifiednumber
ofsampleperiodsandoutputsallthedelayedversions.Usethis
block to discretize a signal in time or resample a signal at a
differentrate.
TransferFcnFirstOrder
TheTransferFcnFirstOrderblockimplementsadiscretetimefirst
order transfer function of the input. The transfer function has a
unityDCgain.
TransferFcnLeadorLag
The Transfer Fcn Lead or Lag block implements a discretetime
lead or lag compensator of the input. The instantaneous gain of
the compensator is one, and the DC gain is equal to (1z)/(1p),
wherezisthezeroandpisthepoleofthecompensator.
TransferFcnRealZero
The Transfer Fcn Real Zero block implements a discretetime
transferfunctionthathasarealzeroandeffectivelynopole.
ZeroOrderHold
The ZeroOrder Hold block holds its input for the sample period
The ZeroOrder Hold block holds its input for the sample period
you specify. The block accepts one input and generates one
output.Eachsignalcanbescalarorvector.
LogicandBitOperations
LogicandBitOperationsBlocksareusedtoperformlogicand
bitoperations.DoubleclickontheLogicandBitOperationsicon
in the main Simulink window to bring up the Logic and Bit
Operationswindow.
BitClear
TheBitClearblocksetsthespecifiedbit,givenbyitsindex,ofthe
storedintegertozero.
BitSet
TheBitSetblocksetsthespecifiedbitofthestoredintegertoone.
BitwiseOperator
TheBitwiseOperatorblockperformsthebitwiseoperationthatyou
specifyononeormoreoperands.
CombinatorialLogic
TheCombinatorialLogicblockimplementsastandardtruthtable
for modeling programmable logic arrays (PLAs), logic circuits,
decisiontables,andotherBooleanexpressions.
CompareToConstant
The Compare To Constant block compares an input signal to a
constant.
CompareToZero
TheCompareToZeroblockcomparesaninputsignaltozero.
DetectChange
TheDetectChangeblockdeterminesifaninputdoesnotequalits
previousvalue.
DetectDecrease
The Detect Decrease block determines if an input is strictly less
thanitspreviousvalue.
DetectFallNegative
TheDetectFallNegativeblockdeterminesiftheinputislessthan
zero,anditspreviousvaluewasgreaterthanorequaltozero.
DetectFallNonpositive
The Detect Fall Nonpositive block determines if the input is less
than or equal to zero, and its previous value was greater than
zero.
DetectIncrease
TheDetectIncreaseblockdeterminesifaninputisstrictlygreater
thanitspreviousvalue.
DetectRiseNonnegative
The Detect Rise Nonnegative block determines if the input is
greaterthanorequaltozero,anditspreviousvaluewaslessthan
zero.
DetectRisePositive
The Detect Rise Positive block determines if the input is strictly
positive,anditspreviousvaluewasnonpositive.
ExtractBits
TheExtractBitsblockallowsyoutooutputacontiguousselection
ofbitsfromthestoredintegervalueoftheinputsignal.
IntervalTest
The Interval Test block outputs TRUE if the input is between the
valuesspecifiedbytheLowerlimitandUpperlimitparameters.
IntervalTestDynamic
The Interval Test Dynamic block outputs TRUE if the input is
between the values of the external signals up and lo. The block
outputsFALSEiftheinputisoutsidethosevalues.Theoutputof
theblockwhentheinputisequaltothesignaluporthesignallois
determined by whether the boxes next to Interval closed on left
andIntervalclosedonrightareselectedinthedialogbox.
ShiftArithmetic
TheShiftArithmeticblockcanshiftthebitsorthebinarypointofan
inputsignal,orboth.
MathOperations
Math Operations Blocks are used to Perform math operations.
Doubleclick on the Math Operations icon in the main Simulink
windowtobringuptheMathOperationswindow.
Abs
TheAbsblockoutputstheabsolutevalueoftheinput.
AlgebraicConstraint
The Algebraic Constraint block constrains the input signal f(z) to
zeroandoutputsanalgebraicstatez.
Assignment
TheAssignmentblockassignsvaluestospecifiedelementsofthe
signal.
Bias
TheBiasblockaddsabias,oroffset,totheinputsignalaccording
to
$Y=U+bias$
(1)
whereUistheblockinputandYistheoutput.
ComplextoMagnitudeAngle
TheComplextoMagnitudeAngleblockacceptsacomplexvalued
signaloftypedoubleorsingle.
ComplextoRealImage
TheComplextoRealImagblockacceptsacomplexvaluedsignal
ofanydatatypethatSimulinksupports,includingfixedpointdata
types.
Divide
TheDivideblockoutputstheresultofdividingitsfirstinputbyits
second.
DotProduct
Theoutputisequaltothedotproductoftwovectorsignals.
Find
The Find block locates all nonzero elements of the input signal
andreturnsthelinearindicesofthoseelements.
MagnitudeAngletoComplex
The MagnitudeAngle to Complex block converts magnitude and
phaseangleinputstoacomplexoutput.
MathFunction
The Math Function block performs numerous common
mathematicalfunctions.
MinMax
The MinMax block outputs either the minimum or the maximum
elementorelementsoftheinputs.
MinMaxRunningResettable
The MinMax Running Resettable block outputs the minimum or
maximumofallpastinputsu.
PermuteDimensions
Theblockreorderstheelementsoftheinputsignalsothattheyare
intheorderyouspecifyintheOrderparameter.
intheorderyouspecifyintheOrderparameter.
Polynomial
You define a set of polynomial coefficients in the form that the
MATLAB polyval command accepts. The block evaluates P(u) at
eachtimestepfortheinputu.
Product
The output is equal to the product of the inputs. The number of
inputscanbespecified.
ProductofElements
TheProductofElementsblockinputsonescalar,vector,ormatrix.
RealImagtoComplex
The RealImag to Complex block converts real and/or imaginary
inputstoacomplexvaluedoutputsignal.
Reshape
TheReshapeblockchangesthedimensionalityoftheinputsignal
to a dimensionality that you specify, using the block's Output
dimensionalityparameter.
RoundingFunction
The Rounding Function block applies a rounding function to the
inputsignaltoproducetheoutputsignal.
SineWaveFunction
ThisblockisthesameastheSineWaveblockthatappearsinthe
Sourceslibrary.
SliderGain
Thismultipliestheinputbyascalarconstantwhichisspecifiedby
movingaslideronthescreenasshownbelow.Thelimitsof the
slidercanbespecified.
Squeeze
Squeeze
The Squeeze block removes singleton dimensions from its
multidimensionalinputsignal.
Sum,Add,Subtract,SumofElements
TheSumblockperformsadditionorsubtractiononitsinputs.This
block can add or subtract scalar, vector, or matrix inputs. It can
alsocollapsetheelementsofasignal.
VectorConcatenate,MatrixConcatenate
The Concatenate block concatenates the signals at its inputs to
create an output signal whose elements reside in contiguous
locationsinmemory.
Sinks
SinkBlocksareusedtodisplayoroutputsignals.Doubleclickon
theSinksiconinthemainSimulinkwindowtobringuptheSinks
window.
Noticethatallofthesinkblockshaveinputsandnooutputs.Most
haveasingleinput.
Display
The Display Sink Block is a digital readout of a signal at the
currentsimulationtime.
Scope
TheScopeSinkBlockwasdescribedearlier.Itisusedtodisplaya
signalasafunctionoftime.
StopSimulation
Thisisaspecialcontrolblockwhichistriggeredtostopthecurrent
simulationwhenitsinputisnonzero.
ToFile
The To File Sink Block saves a signal to a .mat file in the same
way that the From File Source Block reads from a file. The
samplingtimecanbespecified,butisnotnecessary.
ToWorkspace
The To Workspace Sink Block stores a signal in a specified
workspacevariable.UnliketheToFileSinkBlock,thetimeisnot
savedinthevariable,andmustbestoredseparately.
XYGraph
The XY Graph Sink Block plots one signal against another. It is
usefulforphaseplaneplots,etc.
Sources
SourceBlocksareusedtogeneratesignals.Doubleclickonthe
Sources icon in the main Simulink window to bring up the
Sourceswindow.
Notice that all of the source blocks have a single output and no
inputs.Whileparametersineachoftheseblocksinthelibrarycan
bemodifiedbydoubleclickingtheblock,itisbesttonotmodifythe
blocksuntiltheyhavebeencopiedintoamodelwindow.
BandLimitedWhiteNoise
TheBandLimitedWhiteNoiseSourceBlockgeneratesarandom
signalwhichchangesataspecifiedsampleperiod.Thestrength
signalwhichchangesataspecifiedsampleperiod.Thestrength
ofthesignalandarandomnumberseedcanalsobespecified.
ChirpSignal
The Chirp Signal Source Block generates a sinusoidal signal
which scans over a range of frequencies. The initial and final
frequencies as well as the scan time can be specified. The
amplitudeisalways1,andthechirpsignalrepeatsitselfaftereach
frequencyscan.
Clock
The Clock Source Block generates a signal equal to the current
time in the simulation. This is useful when the output of a
simulationisexportedtoMATLABbutoccursatuneventimesteps.
The clock's output reflects the times at which the other signals
outputsoccur.
CounterFreeRunning
The Counter FreeRunning block counts up until reaching the
maximumvalue,
$2^{Nbits}1$ , where Nbits is the number of bits. Then the
counteroverflowstozeroandbeginscountingupagain.
CounterLimited
TheCounterLimitedblockcountsupuntilthespecifiedupperlimit
is reached. Then the counter wraps back to zero, and restarts
countingup.
DigitalClock
The Digital Clock Source Block generates a strictly periodic time
signalataspecifiedsamplinginterval.
EnumeratedConstant
TheEnumeratedConstantblockoutputsascalar,array,ormatrix
ofenumeratedvalues.
FromFile
The From File Source Block outputs a signal taken from a
specified .mat file. A matrix saved in MATLAB as a .mat file will
becomeasignalwherethefirstrowofthematrixspecifiesthetime
values.ThisissimilartotheRepeatingSequenceSourceBlock.
FromWorkspace
TheAmplitudeandFrequencycanbechangedinthisdialogbox,
aswellasthetypeofwaveform.Tochangethewaveform,clickon
theWaveformfieldtobringupalistofpossiblewaveforms.
Thedesiredwaveformcanbeselectedfromthislist.
SineWave
TheSineWaveSourceBlockgeneratesasinusoidalsignal.The
AmplitudeandFrequencycanbespecified,aswellasthePhase
(unlike the Signal Generator). There is a fourth parameter, the
SampleTime,whichcanbeusedtoforcetheSineWaveSourceto
operateindiscretetimemode.
Step
As described earlier, the Step Source Block generates a step
function. The initial and final values can be specified, as well as
thesteptime.
UniformRandomNumber
The Uniform Random Number block generates uniformly
distributedrandomnumbersoveranintervalthatyouspecify.
PublishedwithMATLAB7.14
AllcontentslicensedunderaCreativeCommonsAttributionShareAlike4.0International