Guy on Simulink

Simulink & Model-Based Design

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the Original version of the page.

Sum Block: Round or Rectangular? 7

Posted by Guy Rouleau,

Working in technical support, I see a lot of Simulink models from users. I have realized that many users do not know how to, or do not take the time to configure the ports of the Sum block.

For example, when I see things like this, it makes my eyes hurt a little:

Unusual configurations of the Sum block

Here are a few tips to format the Sum block to make your models easier to understand.

Round Sum block

When you drag the Sum block from the Simulink Library Browser, its Icon Shape is set to Round, and it has one input port on the left and one on the bottom:

Default configuration of the Sum block

When the Sum block Icon Shape is set to Round, the ports are spread evenly from top to bottom and the vertical bar "|" can be used to skip one position. For example, if we want to add a port on top of the block, we can modify the list of signs:

3 ports configuration of the Sum block

Rectangular Sum block

If you change the Icon Shape property of the default Sum block to Rectangular, the block will look like the following:

Rectangular configuration of the Sum block

Personally, I can not think of a good reason for skipping a port in Rectangular shape. So I almost always remove the "|" when I change the shape to Rectangular.

Rectangular configuration of the Sum block

Sum of Elements

One way I like to use the Sum block is to sum all the elements of a vector or matrix:

Sum of elements configuration of the Sum block

For matrices, the Sum block can also be configured to Sum only over one specific dimension:

Sum of elements configuration of the Sum block

Round or Rectangular?

One question remains: When should the Sum block be Round and when should it be Rectangular?

There is no absolute rule, but personally I like to use the Rectangular shape when implementing equations that flow from left to right, without obvious feedback. For example:

When to use configuration of the Sum block

I keep the Round shape for when I want to make it obvious that there is a feedback involved:

When to use Round configuration of the Sum block

Now it's your turn

Please share with us if you have rules or guidelines on the format of your blocks by leaving a comment here.

7 CommentsOldest to Newest

Paul replied on : 1 of 7
Yes it's pretty silly to still be including two separate blocks in the library when there is no functional difference between them. It can even be confusing to new users. Back in the day, I used to think the round block should be used for continuous applications and the square block for discrete. Really, they should be combines, and the visual preference relegated to being a simple mask parameter...
Ryan replied on : 2 of 7
Great post. Whenever I receive a model with a square sum for a control system I have to change them over to circular. Nothing technically wrong, but I like the relationship between circular summing junctions and control system diagrams.
Guy Rouleau replied on : 3 of 7
@Paul, Having multiple instances of the same block with different settings is something relatively common in the Simulink Library Browser. For many users, it seems to make it easier to find what they are looking for. For example: - The Math section of the library contains 4 instances of the Sum block: Sum, Add, Subtract and Sum of Elements. It also contains 3 instances of the Product block: Product, Divide and Product of Elements - Resettable Delay and Variable Integer Delay are both instances of the generic Delay block. - Lookup Tables blocks: 1-D, 2-D and N-D are the same block with different settings. - Vector Concatenate and Matrix Concatenate
Paul replied on : 4 of 7
@Guy These duplicate blocks should be removed in a future release IMHO. It's just not good practice to have different blocks doing the same thing when the variations could be achieved with mask settings. If you are concerned with people still looking for the old blocks, there are many solutions to this. For example, I often use the search field to say find an "add block". You could update the search terms so that "sum" also gives the "add" block result. Other more complex solutions exist, such as retaining the original blocks, but having them immediately convert to the "add" block on placement in the model... Ultimately, I there should not be multiple blocks for the same function. And any time you are using historical convention to justify something concerns me! It means you are being held back in progress...
Issopui replied on : 5 of 7
Hello guys, I'm very sorry for my comment which may not be related to the topic but it is related to simulink blockset. I am working on a small project using computer vision sytem toolbox. I have 3 images which I need to convert to grayscale and then subtract image2 from image one do the binary thresholding and finanlly the AND logic gate to find the final position. My question is "Which blockset should I use to subtract two grayscale images?" I have tried the subtract blockset from math operation but my output image look exactly like the one I got after thresholding. Please guys help me being trying for weeks now. What is the proper blockset to be used for two grayscale subtraction? I'm sorry for my long message. Wish u guys will me Thanks in Advance Issopui
Leigh Boyd replied on : 6 of 7
I always use round summing blocks, not only because its more conventional for control systems but I prefer the different shape of the symbols to easily pick out what they do. I like to be able to add an offset to a value, for example by adding from above, or subtracting from below, where the primary signal still flows from left to right. In negative feedback loops, I loop back and subtract from below as expected in the field. We have many debates about it around the office, but my colleagues don't have a control systems background... The biggest advantage is that you can easily see when you have "format -> show block names" turned off that its a summing block.
Arun replied on : 7 of 7
in add block two different outputs 200,100,then i set unit 8,and if i enable saturate on integer overflow ,then what will be the output.