Siemens PLC Programming - An Introduction To The Cause and Effect Matrix Language in TIA Portal

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Expert s [NEW] Cours e s  Pricing Re s ource s 

Using Cause and Log In

Effect Matrix
For Individuals Communit y
Get Star ted Free

The IEC 61131- 3 standard defines five


languages ​that you can use to program
PLCs. Each language has its own
interface and its own interactions in order
to meet the requirements of the different
applications that you will have to develop.
To diversify the tools at our disposal,
Siemens has created a language aimed at
simplifying programs that include a lot of
conditional interactions: The Cause and
Effect Matrix (CEM).

The CEM language offers a simple


interface in the form of a table where
each row represents a cause and columns
represent effects. You can link causes to
effects by specifying an action in the cell
where they intersect. This makes reading
programs much simpler and clearer.

This tutorial will teach you the basics of


the CEM language: How to create causes,
effects, and actions.

Prerequisites
To follow this tutorial, you will need an
installation of TIA Portal v17 - How to
Install and Get Started with Siemens TIA
Portal and S7- PLCSIM. You cannot use
any other version of TIA Portal. No other
hardware or software is required.

CEM’s working
principle
Expert s [NEW] Cours e s  Pricing Re s ource s 
Expert s [NEW] Cours e s  Pricing Re s ource s 
The Cause and Effect Matrix comes as a Log In
table where rows represent causes and
Get Star ted Free
For Individuals Communit
columns represent y
effects. You can link
one or multiple causes to one or multiple
effects by adding an action in the cells
where they intersect.

Figure 1 - Siemens PLC Programming | Cause


and Ef f ect Matrix Example Table

The CEM table above works as follows:

Cause 1 is linked to Effect 1 through


Action 1. It means that if Cause 1 is
true, Action 1 will be applied to
Effect 1.

Causes 1 and 2 are linked to Effect


2. This means that if Cause 1 is true,
Action 2 will be applied to Effect 2
OR If Cause 2 is true, Action 3 will
be applied to Effect 2.

Causes 2 and 3 are linked to effect


3 through Action 4. This means that
if Cause 2 AND Cause 3 are both
true, Action 4 will be applied to
Effect 3. In this case, action 4 is an
action group.

Let’s create a Cause and Effect Matrix.


Open TIA Portal, and create a new project
with the CPU of your choice. Then, Click
on “Add new block”.

Expert s [NEW] Cours e s  Pricing Re s ource s 


Expert s [NEW] Cours e s  Pricing Re s ource s 
Log In

Get Star ted Free


For Individuals Communit y

Figure 2 - Siemens PLC Programming |


Conf iguration of a New TIA Portal Project

CEM can only be used in Functions


Blocks (FB). You can’t use the CEM
language in Organiz ation Blocks (OB) and
Functions (FC). In the “Add new block”
window, Click on “Function block” and
select “CEM” as language.

Figure 3 - Siemens PLC Programming |


Creation of a New Function Block in TIA Portal

Once the FB is created, you should see


the CEM interface appear.

Figure 4 - Siemens PLC Programming | Cause


and Ef f ect Matrix Conf iguration Interf ace

1. Cause rows: This is where you can


create causes. Each row represents
Expert s [NEW] Cours e s  Pricing Re s ource s 
Expert s [NEW] Cours e s  Pricing Re s ource s 
a cause. You can create new causes Log In
by clicking on “Add new” or dragging
Get Star ted Free
For Individuals Communit
and dropping theycause from the
instructions section.

2. Effect columns: This is where you


can create effects. Each column
represents an Effect. You can create
new effects by clicking on “Add
new” or by dragging and dropping
the effect from the instructions
section.

3. Intersection actions: This is where


you can create actions. Each cell can
contain an action or an action group
that will affect the effect column.
You can create new causes by
clicking on “Add new” or by dragging
and dropping the cause from the
instructions section.

4. Instructions section: This section


contains all the possible cause,
effect, and action instructions you
can use in CEM.

CEM’s cause
types
Open the “Cause instructions’ folder in the
instructions section.

Expert s [NEW] Cours e s  Pricing Re s ource s 


Expert s [NEW] Cours e s  Pricing Re s ource s 
Log In

Get Star ted Free


For Individuals Communit y

Figure 5 - Siemens PLC Programming | Cause


and Ef f ect Matrix Cause Instructions
Conf iguration in TIA Portal

There are three types of causes you can


use:

Bit Logic Operations: Contains the four


simple logic operations assignment (=),
AND (&), OR (>=1), and XOR (x). These
instructions can only be used with
boolean variables.

Expert s [NEW] Cours e s  Pricing Re s ource s 


Expert s [NEW] Cours e s  Pricing Re s ource s 
Log In

Get Star ted Free


For Individuals Communit y

Figure 6 - Siemens PLC Programming | Cause


Instructions Examples - Bit Logic Operatiors

Comparator Operations: Contains all the


basic comparison instructions. You can
compare any type of variable except
booleans.

Expert s [NEW] Cours e s  Pricing Re s ource s 


Expert s [NEW] Cours e s  Pricing Re s ource s 
Log In

Get Star ted Free


For Individuals Communit y

Figure 7 - Siemens
PLC Programming | Cause
Instructions Examples -
Comparator Operations

Timer Operations: Timers work a little


differently. You must associate them with
a bit logic or comparison instruction. The
timer will be applied to its associated
instruction. For example, if the result of a
cause is 1, the OnDelay timer will wait for
the entered time to elapse before actually
setting the output of the cause to 1. The
reverse is true for the OffDelay. And the
Pulse timer will activate the cause output
for the entered time.

Expert s [NEW] Cours e s  Pricing Re s ource s 


Expert s [NEW] Cours e s  Pricing Re s ource s 
Log In

Get Star ted Free


For Individuals Communit y

Figure 8 - Siemens
PLC Programming | Cause
Instructions Examples -
Timer Operations

CEM's effect
types
Open the “Effect instructions’ folder in the
instructions section.

Expert s [NEW] Cours e s  Pricing Re s ource s 


Expert s [NEW] Cours e s  Pricing Re s ource s 
Log In

Get Star ted Free


For Individuals Communit y

Figure 9 - Siemens PLC Programming | Ef f ect


Instructions

There are three instructions you can use:

Assignment (=): If the associated


action is activated, the output(s) of
the effect will be set to 1. In the
other case, the output(s) will be set
to 0.

Set (S): If the associated action is


activated, the output(s) of the effect
will be set to 1 permanently.

Reset (R): If the associated action


is activated, the output(s) of the

Expert s [NEW] Cours e s  Pricing Re s ource s 


Expert s [NEW] Cours e s  Pricing Re s ource s 
effect will be set to 0 permanently. Log In

Get Star ted Free


For Individuals Communit y

Figure 10 -
Siemens
PLC Programming
| Ef f ect
Instructions
Examples -
A ssignment, Set,
and Reset Ef f ect
Instructions

CEM's action
types
There are two types of actions:

Simple actions: Associate one


cause with one effect. If the cause
is true, this type of action can
assign (N), set (S), or reset (R) the
effect.

Action groups: Associate multiple


causes with one effect. If the
selected causes are all true, this
type of action can assign (N), set
(S), or reset (R) the effect.

To create a simple action, drag and drop


the desired instruction (N, S, or R) from
the instructions section or double- click on
the cell and define the type of action
instruction.

Expert s [NEW] Cours e s  Pricing Re s ource s 


Expert s [NEW] Cours e s  Pricing Re s ource s 
Log In

Get Star ted Free


For Individuals Communit y

Figure 11 - Siemens PLC Programming |


Creating a New Intersection A ction in
TIA Portal

To create an action group, double- click on


the concerned cells and define both the
action instruction and the action group.
Then, in the “Configure action group”
section, you can select how many causes
are in the group.

First, create an action group for one of the


concerned causes.

Figure 12 - Siemens PLC Programming |


Creating a New A ction Group

Then, for the other causes, repeat the


same action but instead of creating a new
group, select the one already created.

Expert s [NEW] Cours e s  Pricing Re s ource s 


Expert s [NEW] Cours e s  Pricing Re s ource s 
Log In

Get Star ted Free


For Individuals Communit y

Figure 13 - Siemens PLC Programming |


A dding New Intersection A ctions to the A ction
Group

Testing a CEM
program
Let’s consider the following CEM
program:

Figure 14 - Siemens PLC Programming |


Testing a CEM Program Developed in
TIA Portal

Cause 1 assigns the state of Tag_ 1


to output 1. If Tag_ 1 is true, output 1
is set to 1. If not, it’s set to 0. Also,
it has an R action to reset the 2 out
of 2 set action of effect 2.

Cause 2 and 3 are associated with a


2 out of 2 action group that sets
Expert s [NEW] Cours e s  Pricing Re s ource s 
Expert s [NEW] Cours e s  Pricing Re s ource s 
output 2 to 1. If (Tag_ 2 & Tag_ 3) and Log In
(Tag_ 4 >= 10) are true, Output 2 is
Get Star ted Free
For Individuals Communit yto 1.
set permanently

Cause 1 resets output 2. If Tag_ 1 is


true, Output 2 is set to 0
permanently.

Then, call the CEM FB in the main program


(OB1) and edit the inputs and outputs as
follows:

Figure 15 - Siemens
PLC Programming | Using a
CEM Block in TIA Portal

Load this program into PLCSim or an


actual PLC. Once done, activate the
monitoring on both the main program and
the CEM block. You can use a watch table
or a sim table to modify the state of the
tags.

Figure 16 - Siemens PLC Programming | Using


a CEM Block in TIA Portal

The state of cause 1 (Tag_ 1) is assigned


to effect 1 (Assignment to Output 1) and
Expert s [NEW] Cours e s  Pricing Re s ource s 
Expert s [NEW] Cours e s  Pricing Re s ource s 
effect 3 (Resetting Output 2). Log In

Get Star ted Free


For Individuals Communit y

Figure 17 - Siemens PLC Programming | Using


a CEM Block in TIA Portal - Testing Case 2 and
Cause 3 Ef f ect 1

When both Cause 2 (Tag_ 2 & Tag3) and


Cause 3 (Tag_ 4 >= 10) are true, this sets
the 2S action to 1 permanently. This will
activate effect 2 and set Output 2 to 1
permanently.

Figure 18 - Siemens PLC Programming | Using


a CEM Block in TIA Portal - Testing Case 1 and
Ef f ect 3

Then, you can set Tag_ 1 (cause 1) to 1 to


reset both the 2S action group and Output
2.

Conclusion on
Cause and Effect
Matrix
In this tutorial, you learned the basics of
the CEM language. The main attraction
Expert s [NEW] Cours e s  Pricing Re s ource s 

You might also like