Tutorial: Creating a Simple Block Diagram

Learn how to create a block diagram in a model.

Creating a New Model

Create a new model .scm file.

From the ribbon, in the the Files tool group, click or, from the menu bar, select File > New.
A new modeling window opens for you to create a model.

Files for This Tutorial

SineIntegral.scm

A finished version of the model you build in this tutorial along with any files required to complete the tutorials are available from the Demo Browser: Tutorial Models > Learning the basics or at this location: <installation_directory>/Tutorial Models/Learning the basics.

Creating a Diagram

Build a diagram from the blocks located in the palettes of the System library.

  1. Select View > Palette Browser.


    The Palette Browser displays the installed library palettes.
  2. Double-click Activate > Signal Generators.
    The Palette Browser displays the blocks available in the Signal Generators palette.
  3. Select the SineWaveGenerator block, then drag and drop it into the modeling window.
    The SineWaveGenerator block is the first block in your diagram assembly.
  4. From the Palette Browser, drag and drop the following blocks into your diagram:
    • From Activate > Dynamical, drag and drop one Integral block to the right of the SineWaveGenearator block.
    • From Activate > Routing, drag and drop one Mux block to the right of the Integral block.
    • From Activate > SignalViewers, drag and drop one Scope block to the right of the Mux block.
    Your block assembly should look something like this:


  5. Hover over the output port of the SineWaveGenerator block until the cursor becomes a pointer-hand, then click:
  6. Click the input port of the Integral block:
    A link appears between the blocks:
    Tip: To connect the blocks automatically, hold the Shift key + click each block. The next available output from the first block connects to the next available input of the second block. To deselect a port, press Esc.
  7. Link the remaining blocks in the diagram as you see in the following figure. Note the bend in the link between the first two blocks. If your link is straight, create the bend by selecting the SineWaveGenerator block and moving it upward so that it is higher than the Integral block.
  8. Hold the Alt key and click the elbow of the link between the SineWaveGenerator and Integral blocks.
    A split is created in the link:
  9. Drag the link to the upper input port of the Mux block:
    Alternatively, click the upper input port of the Mux block to initiate a link, then click the destination-link elbow to create the split:
    Your completed diagram should look something like this:
  10. On the ribbon, from the Files tool group, click Save.
  11. In the Save Model As dialog, specify a directory, and for File name, enter SineIntegral_practice.
    Your diagram is saved as the model file, SineIntegral_practice.scm.

Adjusting Blocks and Links

Adjust the size of the blocks and position of the links in your diagram.

  1. To better align the link between the Mux and Scope blocks, click and hold the Scope block, and then move the block down slightly until the link becomes a straight line.
  2. Hover over the link connected to the upper input port of the Mux block until the link segment is highlighted.
  3. Hold and drag the link segment upward, and then drop the segment at a position above the Integral block.
  4. Select the vertical part of the link and move to the left so that it is not too close to the Mux block.
  5. Click and hold the point you see in the following figure. You can adjust the link route by moving a point rather than a link segment.
  6. Drag the mouse up and release it when the link route is acceptable.
  7. Select the Integral block. Hold and drag your mouse up slightly to straighten the crooked link between the Integral and Mux blocks.
  8. Select the Scope block and hover over one of its corners.
    Control points appear:
  9. To increase the size of the block, drag the control points outward.
  10. Keeping the Scope block selected, move the block up slightly to straighten the link between the Mux and Scope blocks.
  11. Click File > Save.

Deleting Blocks and Links

Delete and restore blocks and links in your diagram.

  1. On your model, select the SineWaveGenerator block.
  2. Right-click, and from the context menu, select Delete.
    The SineWaveGenerator block and the links associated with it are removed.
  3. To restore the deleted blocks and links, click Edit > Undo or press Ctrl + Z.
  4. Select the link connected to the Scope block:
  5. Right-click, and from the context menu, select Delete.
  6. To restore the deleted link, click Edit > Undo, or press Ctrl + Z.
  7. To delete multiple blocks and links at once, you can box-select a section of the diagram, and then delete and restore the section as above. From the upper left-hand corner of the diagram, click and drag downward and right to select the portion of the diagram containing the SineWaveGenerator and Integral blocks.
  8. Click outside the selecting rectangle to deselect the blocks and links.

Copying Blocks

Duplicate blocks in your diagram with the copy-and-paste or Ctrl key + drag methods.

  1. Near the upper right-hand corner of the diagram, click and drag a box downward from right to left. This selection method is called cross-selecting. Only the objects inside of the box are selected.
    A dashed line appears around the portion of the diagram that is selected.
  2. In your diagram, cross-select the SineWaveGenerator and Integral blocks. Right-click the selected box, and from the context menu, select Copy or press Ctrl+ C.
  3. To paste the copied blocks and links, right-click outside of the selection, and from the context menu, select Paste or press Ctrl+ V.
    Duplicates of the selected blocks appear in your diagram.

  4. Alternatively, to duplicate a block, select the Scope block; press and hold the Ctrl key; drag the selected Scope block to an empty area in the diagram; release the mouse, and release the Ctrl key.
    A duplicate Scope block appears:


  5. Select File > Close. Do not save the changes to the model file.

Flipping and Replacing Blocks

Position objects in your diagram with Flip and Replace options.

  1. Select File > Open SineIntegral_practice.scm.
  2. In the Palette Browser, double-click Activate, double-click MathOperations, select the Sum block and drag and drop it into the diagram.
  3. On the Sum block, right-click, and from the context menu, select Flip.
    The block flips horizontally, as if it were mirrored about a vertical axis across its center.
  4. Flip the Sum block again to restore its original orientation.
  5. To cut the block, right-click the Sum block, select Cut or press Ctrl + X.
  6. Right-click the Mux block, and from the context menu, select Paste.
    The Mux block is replaced by the Sum block that was cut in the previous step.
  7. Right-click the Sum block and from the context menu that appears, select Show Name. If the block is already showing its label, select Hide Name.

Viewing with Pan, Fit and Zoom Tools

Adjust the view of your model.

  1. At the lower left-hand corner of the modeling window, click the Fit Selected tool , or press the F key.
    The view of the diagram adjusts to fit the modeling window.
  2. Click the Fit to Zoom One tool.
    The view of the blocks in the model is adjusted so that they are the same size as those in the Palette Browser. This is the default view when a model is initially loaded.
  3. Hold and drag the middle mouse button to pan the diagram and move specific parts of it into view.