Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 36 ยท Blocks and Models

Simulink Sources, Sinks and Math Blocks: Step, Sum, Gain and More

A tour of the most used Simulink blocks: Constant, Step, Ramp, Sine Wave, Pulse Generator, Sum, Gain, Product, Abs, Saturation, Scope, Display and Terminator, with parameters.

Almost every model is built from a few dozen blocks. They fall into three groups: sources create signals, sinks consume or display them, and everything in between transforms them. Knowing the most common blocks, their default parameters and their quirks lets you build models quickly and read other people's diagrams.

Simulink is not available on this site. The descriptions below follow the real blocks (block names are those in the Library Browser); a Python stand-in at the end reproduces the signal generators so you can see their shapes as numbers.

Sources

A source has no input ports. Common ones live in the Sources library.

Block Output Key parameters (defaults)
Constant Fixed value Constant value 1
Step Jumps from one value to another at a time Step time 1, Initial value 0, Final value 1
Ramp Starts to rise linearly at a time Slope 1, Start time 0, Initial output 0
Sine Wave A sin(w t + p) + b Amplitude 1, Bias 0, Frequency 1 rad/s, Phase 0
Pulse Generator Rectangular wave Amplitude 1, Period 10 (seconds), Duty cycle 50 (%), Phase delay 0
Clock Current simulation time none
Repeating Sequence Repeats a table of points Time values and output values
Signal Builder / Signal Editor Designed test inputs Interactive waveform editing
From Workspace Data from MATLAB Variable such as [t u]
Band-Limited White Noise Random noise Noise power, sample time, seed

Time-based sources have a Sample time parameter: 0 means continuous, a positive number gives a discrete signal held between samples.

Sinks

A sink has inputs but no outputs.

  • Scope and Floating Scope: plot signals against time.
  • Display: shows the current numeric value on the block face.
  • To Workspace, To File: log data (see Logging and Inspecting Results).
  • XY Graph: plots one signal against another (e.g. a phase portrait).
  • Out1 (Outport): sends a signal out of a model or subsystem.
  • Terminator: swallows an unused output so Simulink does not warn.
  • Stop Simulation: ends the run when its input is nonzero.
  • Assertion: stops or warns when its input is zero (used in test models).

Every output port should go somewhere. Connect leftover signals to a Terminator (and unused inputs to a Ground block) to keep your model free of warnings.

Math operations

The Math Operations library holds most of what you need to calculate.

Block What it does
Sum Adds or subtracts. The List of signs is a string such as `
Add, Subtract Sum variants with fixed signs
Gain Multiplies by a constant: y = K*u; matrix gains use Multiplication options
Product Multiplies or divides inputs: signs like */
Abs Absolute value
Sign -1, 0 or 1
Math Function exp, log, pow, sqrt, mod...
Trigonometric Function sin, cos, tan, atan2...
MinMax Minimum or maximum of inputs
Rounding Function floor, ceil, round, fix
Bias Adds a constant
Dot Product Vector dot product

Saturation (Discontinuities library) limits a signal between Upper limit and Lower limit. It shows up in nearly every controller, because real actuators have limits.

Three block roles

Sources Create signals
Math and logic Transform signals
Sinks Show or save signals

Every model follows this flow.

1 / 2

Building an expression

Suppose you want y = 2*(r - x) + 1. In Simulink that is a Sum block with signs +- taking r and x, then a Gain of 2, then a Bias block of 1 (or a Sum block with a Constant). Reading the diagram left to right mirrors the algebra.

Tips:

  • Rotate or flip blocks with Ctrl+R and Ctrl+I so signals flow left to right and feedback comes back along the bottom.
  • Resize a Gain block to show its value; a triangle shows K by default. The name of a workspace variable is allowed there, such as Kp.
  • In a Sum block, a round shape shows signs; rectangular shape shows the list of signs as text. The round shape is the usual control-diagram style.

See the shapes

Python Stand-in: source blocks as number generators (Python)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Stand-in: y = 2*(r - x) + 1 with Saturation (Python)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Pitfalls

  • A Step block with Step time equal to the start time has no visible jump: the output starts at the final value. Use a positive step time to see the edge.
  • Gain parameters are evaluated as MATLAB expressions: 2*pi*50 and Kp both work.
  • Product with / divides by the second input and can produce Inf or NaN at zero; guard against it.
  • The Display block only shows the value at the end of the run or at the current step in debug; use a Scope for history.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which block gives you the current simulation time as a signal?

    The Clock block outputs the simulation time.
  2. 2. What should you attach to an output port that you do not use?

    A Terminator absorbs an unconnected output and removes warnings; Ground is for unconnected inputs.
  3. 3. A Sum block has the list of signs |+-. What does it compute for inputs a and b?

    The first sign applies to the first input (+) and the second to the second input (-): a - b.
  4. 4. Which block limits a signal between two bounds?

    Saturation clips the signal to an upper and lower limit.
  5. 5. A Pulse Generator has Period 10 and Duty cycle 30. How long is it high in each period?

    30% of a 10-second period is 3 seconds.

Summary

  • Sources create signals, math blocks transform them and sinks display or store them.
  • Know the defaults: Step time 1, Sine frequency 1 rad/s, Pulse period 10 s with 50% duty.
  • Sum signs and Product operators decide how inputs combine; Saturation models real limits.
  • Terminate unused outputs and ground unused inputs.

Next: Block Parameters and Workspace Variables