0% found this document useful (0 votes)
198 views

TIA PRO1 06 Binary Operations 1

NO contacts and NC contacts represent the physical state of sensors. In a program, check symbols represent the logical state - whether a condition is true or false. A check symbol tests the signal status and results in a 1 or 0.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
198 views

TIA PRO1 06 Binary Operations 1

NO contacts and NC contacts represent the physical state of sensors. In a program, check symbols represent the logical state - whether a condition is true or false. A check symbol tests the signal status and results in a 1 or 0.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

SIMATIC TIA Portal Programming 1

Contents 6

AR
6. Binary Operations 1 ............................................................................................... 6-2
6.1. Plant Description: The Conveyor Model as Distribution Conveyor ....................................... 6-3
6.2. Assignment ........................................................................................................................... 6-4
6.2.1. Sensors and Check Symbols ................................................................................................ 6-5
6.2.2. Binary Logic Operations: AND, OR and Negation ................................................................ 6-6
6.2.3. Theory Exercise 1: Sensor and Check Symbols .................................................................. 6-7
6.2.4. Binary Logic Operations: Exclusive OR (XOR) ..................................................................... 6-8
6.3. Process Images .................................................................................................................... 6-9
6.4.
6.5.
6.6.
6.6.1.
N
Cyclic Program Execution ................................................................................................... 6-10
Linear Program ................................................................................................................... 6-11
Programming....................................................................................................................... 6-12
Networks ............................................................................................................................. 6-13
AI
6.6.2. Absolute and Symbolic Addressing .................................................................................... 6-14
6.6.3. Using a PLC Tag as an Operand ........................................................................................ 6-15
6.6.4. Renaming / Rewiring PLC Tags.......................................................................................... 6-16
6.6.5. Defining (Declaring) Tags while Programming ................................................................... 6-17
6.6.6. Closing / Saving / Rejecting a Block ................................................................................... 6-18
6.6.7. Compiling a Program .......................................................................................................... 6-19
6.6.8. Downloading a Program into the CPU ................................................................................ 6-20
TR

6.6.9. Monitoring a Block .............................................................................................................. 6-21


6.7. Exercise 2: Renaming OB "Main" ....................................................................................... 6-22
6.7.1. Exercise 3: Programming the Jog Mode ............................................................................. 6-23
6.7.2. Exercise 4: Compiling the Program, Downloading it into the CPU and Saving the Project 6-24
6.7.3. Exercise 5: Monitoring the Program ................................................................................... 6-25
SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-1
SIMATIC TIA Portal Programming 1

6. Binary Operations 1

At the end of the chapter the participant will ...

… know what an assignment is

... understand the difference between ‘real’ NC contacts and NO contacts


connected in the hardware, and programmed check symbols

… be familiar with the logic operations AND, OR and Exclusive-OR

AR
and be able to apply them

… be familiar with the process image for inputs and outputs

... understand cyclic program execution

… know what a linear program is

… be familiar with the Program Editor

… be able to rename and rewire PLC tags

... be able to carry out a program test with the “Monitor (block)” function

N
AI
TR
SI

TIA-PRO1 - Binary Operations 1


6-2 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.1. Plant Description: The Conveyor Model as Distribution Conveyor

"K_left" (%Q 3.6) "K_right" (%Q 3.5)


DI DO

%I 0.2 Jog right


"S_right"

AR
%I 0.3 Jog left
"S_left"

"OB_Cycle"

N
Conveyor Model as a Distribution Conveyor
The distribution conveyor can be jogged to the left and to the right using the switches "S_right"
(%I0.2) and "S_left" (%I0.3). If both switches are activated simultaneously, then the conveyor
AI
must not move (Lock-out!).
TR
SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-3
SIMATIC TIA Portal Programming 1

6.2. Assignment

Function Chart (FBD) Ladder Diagram (LAD)

AR
Scan for signal status 0

Assignment
N
With an assignment, the specified operand is always assigned the current result of the logic
operation (RLO) as status, that is, the logic result of the previous operation, or the result of check
AI
of the operand (as in the picture). This RLO, that is, this status remains available after the
assignment and can be assigned to a further operand or it can be further logically linked.

Scan for 0 (False)


The scan for 0, that is, the signal status FALSE is fulfilled when the operand has the signal status
‘0’.
TR
SI

TIA-PRO1 - Binary Operations 1


6-4 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.2.1. Sensors and Check Symbols

Process Interpretation in the PLC Program

The The sensor Voltage Signal Scan Scan


sensor is ... present status for signal status “1” for signal status “0”
Is a ... at input? at
input Symbol / Result of Symbol / Result of
Instruction check Instruction check

NO activated
contact 1 “Yes” “No”

AR
yes
LAD: 1 LAD: 0

not “NO contact” “NC contact”


no
activated 0 “No” “Yes”
0 1

NC activated
no
contact 0 FBD: “No” FBD: “Yes”
0 1

not
activated yes 1 “Yes” “No”
1 0

Sensors of the Process


N
The use of normally open or normally closed contacts for the sensors in a controlled process
depends on the safety regulations for that process. Normally closed contacts are always used for
AI
limit switches and safety switches, so that dangerous situations do not arise if a wire break occurs
in the sensor circuit. Normally closed contacts are also used for switching off machinery for the
same reason.
All scans can be programmed for signal status, that is, Status '0' and '1' regardless of whether a
hardware NO contact or hardware NC contact is connected in the process.

Check Symbols of the Program


TR

In LAD, a symbol with the name "NO contact" is used for scanning for signal status "1" and a
symbol with the name "NC contact" to scan for signal status "0". It makes no difference whether
the process signal "1" is supplied by an activated NO contact or a non-activated NC contact.
In FBD, the scan of a signal for signal status "1" is indicated simply by an input (line). The scan
for signal status "0" is implemented through a negation (visible by a circle at the input).
The scan for signal status "1" delivers the result of check "1" when the scanned operand has
signal status "1".
The scan for signal status "0" delivers the result of check "1" when the scanned operand has
SI

signal status "0".

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-5
SIMATIC TIA Portal Programming 1

6.2.2. Binary Logic Operations: AND, OR and Negation

FBD LAD
AND

Change the
Scan

AR
Change the
Operation
FBD
OR

Negation

AND and OR Logic Operations


N
With the AND and OR logic operations, basically all binary operands can be scanned, even
outputs. Instead of individual operands, the results of other logic operations can also be further
AI
logically linked. Also, the logic operations can also be combined.

AND Logic Operation


For an AND logic operation, the result of logic operation (RLO) = '1',
when all input signals have Status '1'.
TR

OR Logic Operation
For an OR logic operation, the result of logic operation (RLO) = '1', when at least one input signal
has Status '1'.

Negation (NOT)
The NOT instruction inverts the result of logic operation (RLO).
If, in the example shown, the RLO of the OR logic operation = '1', the NOT instruction inverts it to
RLO '0' and the output is assigned the Status "0".
If the RLO of the OR logic operation = '0', the NOT instruction inverts it to RLO '1' and the output
SI

is assigned the Status "1".

TIA-PRO1 - Binary Operations 1


6-6 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.2.3. Theory Exercise 1: Sensor and Check Symbols

Task: In all three examples, the light should be on when S1 is activated and S2 is not activated!

Hardware

S1 S2 S1 S2 S1 S2

E 1.0
%I 1.0 E
%I1.1
1.1 E 1.0
%I 1.0 E %I
1.11.1 E 1.0
%I 1.0 E%I1.1
1.1
Automation system Automation system Automation system
%Q 4.0 %Q 4.0 %Q 4.0

Light Light Light

AR
Software
%I 1.0 %I 1.1 %Q 4.0 %I 1.0 %I 1.1 %Q 4.0 %I 1.0 %I 1.1 %Q 4.0

LAD

& & &


%I 1.0 %I 1.0 %I 1.0
FBD
%I 1.1 %Q 4.0 %I 1.1 %Q 4.0 %I 1.1 %Q 4.0

Task
N
In FBD, complete the logic symbols, and, in LAD correct the check symbols so that the required
function is fulfilled.
AI
Note
The terms - "NO contact" and "NC contact" - have different meanings depending on whether they
are used in the process-hardware-context or as check symbols in the software.
TR
SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-7
SIMATIC TIA Portal Programming 1

6.2.4. Binary Logic Operations: Exclusive OR (XOR)

FBD

AR
LAD

XOR Logic Operation


N
With the XOR logic operation, basically all binary operands can be scanned, even outputs.
Instead of individual operands, the results of other logic operations can also be further logically
AI
linked. Also, the logic operations can also be combined.
All inputs of the logic operations can be programmed as scan for signal status or Status '0' and
'1', regardless of whether a hardware NO contact or NC contact is connected in the process.
• For an XOR logic operation with 2 inputs, the result of logic operation (RLO)
= '1', when the result of check of one and only one of the two input signals is 'TRUE'
TR

• For an XOR logic operation with more than 2 operands, the RLO...
= '1', when the number of the result of checks of the inputs that result in 'TRUE' are uneven
= '0', when the number of the result of checks of the inputs that result in 'TRUE' are even.

XOR in the LAD Programming Language


In the LAD programming language, there is no explicit XOR logic operation. It must be generated
by programming the discrete instructions shown in the picture above.
SI

TIA-PRO1 - Binary Operations 1


6-8 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.3. Process Images

AR
Process image Process image
for inputs for outputs
%IB 0 %QB 0
%IB 1 %QB 1
%IB 2 %QB 2
: :
:
User :
: program :

CPU memory area


CPU memory area

Process Images
N
For the storage of all digital input and output states, the CPU has reserved memory areas: the
process image for inputs (PII) and the process image for outputs (PIQ). During program
AI
execution, the CPU accesses these memory areas exclusively. It does not access the digital input
and output modules directly.

PII
The Process Image for Inputs (PII) is the memory area in which the statuses of all digital inputs
are stored. At the beginning of the cycle, the digital input modules read-in to the PII. When an
TR

input is linked, the status of this input stored in the PII is linked. This status cannot change within
a cycle since the PII is only updated or read-in at the beginning of a cycle. This guarantees that
when there are multiple scans of the input in one cycle, the same result is always supplied.

PIQ
The Process Image for Outputs (PIQ) is the memory area in which the statuses of all digital
outputs are stored. The PIQ is output to the digital output modules at the beginning of the cycle
before the process image for inputs is updated. Outputs can be assigned as well as scanned in
the program.
SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-9
SIMATIC TIA Portal Programming 1

6.4. Cyclic Program Execution

• Startup program: Call and execution of the


Startup-OBs (once, after PowerON, for example)

Start of the cycle monitoring time


Output
module

AR
Writing the process image for outputs
(PIQ) in the output modules
CPU Cycle

Reading the input statuses from the input modules


and saving the statuses in the process image (PII)

Call and execution of the Program cycle OBs Input


module
(possible interruption by the call of other OBs for events,
such as, time-of-day interrupt, hardware interrupts etc.)

Restart
N
When you switch on or switch from STOP --> RUN, the CPU carries out a complete restart
whereby the programmed Startup-OBs are executed. During restart, the operating system deletes
AI
all non-retentive memory bits and, after the Startup-OBs have been executed, it starts the cycle
monitoring time. (The Startup-OBs are dealt with in the chapter "Organization Blocks")

Cyclic Program Execution


Cyclic program execution occurs in an endless loop. After the execution of a program cycle is
completed, the execution of the next cycle occurs automatically. In every program cycle, the CPU
TR

carries out the following steps.


• Transfer the output statuses from the process image for outputs to the output modules.
• Scan the statuses of the input signals and update the process image for inputs.
• Execute the instructions of the user program. This happens mainly with the process images,
not with the input and output modules directly.

Cycle Time and Cycle Monitoring Time


The time that the CPU requires for the execution of the complete program cycle, is the cycle time
SI

which is monitored for time by the CPU operating system. If the cycle time exceeds the cycle
monitoring time defined in the CPU properties (Chapter Devices and Networks), the "Time-
Error-Interrupt-OB" is called. If this is not configured or if the cycle monitoring time is double, the
CPU goes into the STOP state.

Using the Process Image or Deselecting it for Individual Modules


In the properties of the modules you can select whether the input values are to be automatically
adopted in the PII or whether the output values are to be automatically written with values from
the PIQ (at the beginning of the cycle), only if a certain OB is executed or never.

TIA-PRO1 - Binary Operations 1


6-10 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.5. Linear Program

Linear Program Block-structured Program Structured Program

AR
OB_
Cycle
Dealt with in the chapter
Dealt with in the chapter
“Functions and
“Program Bocks”
Function Blocks”

All instructions are found


in one block (in a
“Program cycle OB”)

Linear Program
N
The entire program is found in one continuous program block (Program cycle OB) which is
automatically called by the system. This model resembles a hard-wired relay control that was
AI
replaced by an automation system (programmable logic controller). The CPU processes the
individual instructions one after the other.
TR
SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-11
SIMATIC TIA Portal Programming 1

6.6. Programming

Display Favorites
On/Off

AR
Add additional
input

Open Block
N
In the Program blocks folder, there is a Program-Cycle-OB that can be opened with a double-click
in the instruction section.
AI
Programming
The instructions within a block can be programmed as follows:
• using drag & drop from the Favorites or the Instructions catalog to anywhere in the program
• by first selecting the location in the program and then double-clicking on the desired
TR

instruction in the Favorites or the Instructions catalog


• by selecting (highlighting) the location in the program and the relevant shortcut (for
information on the possible shortcuts see Options > Settings > Keyboard shortcuts)
Operands can be inserted as follows:
• by entering the absolute or symbolic address
• using drag & drop from the Details view when the relevant tag table is selected (highlighted)
in the Project tree
SI

Favorites
Frequently used elements, functions and instructions are available in the Favorites which can be
expanded individually from the Instructions catalog using drag & drop.

TIA-PRO1 - Binary Operations 1


6-12 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.6.1. Networks

Insert / Delete Open / Close


new network all networks

Free comments Network Comments


On / Off
On / Off
Show the tag
information

AR
On / Off

Networks
N
A block can be divided into individual networks which make it easier to follow and gives you a
better understanding of the program.
AI
Each network can be given a network label and a comment. Within the networks, the individual
instructions can be clarified with instruction comments and the comments of the tags/variables
used can be displayed via the "Tag information" button.
TR
SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-13
SIMATIC TIA Portal Programming 1

6.6.2. Absolute and Symbolic Addressing

AR
Absolute and Symbolic Addressing
N
All global tags/variables (such as, inputs, outputs, memory bits) have both an absolute and a
symbolic address. You can define which is to be displayed or with which is to be programmed
AI
(see picture).
When you use a symbolic address (for example, "K_left") which has not yet been assigned an
absolute address, you can save the block but you cannot compile it and download it into the
controller.
When you use an absolute address (for example, %M16.2), it is automatically assigned a
symbolic default address (for example, "Tag_1") which you can change (later on).
TR

Properties
If a block or the PLC tag table is open in the working area and a tag is selected (highlighted)
there, then all details are displayed in the "Properties" tab in the Inspector window.
SI

TIA-PRO1 - Binary Operations 1


6-14 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.6.3. Using a PLC Tag as an Operand

Automatic
symbol selection

AR
Using a Tag as Operand
N
During programming, the name of the tag or the address can be entered. When the symbolic
name or the address is input, the Autocompletion automatically appears from which you can
AI
select the tag. Furthermore, you can use the Details view to adopt the tag using drag & drop.

Autocompletion
When operands are selected, after the first letter of the symbolic operand name has been
entered, a selection of all the operands whose name start with the entered letter and are of the
corresponding data type is displayed. All the operands that are valid for this block are displayed.
TR

These are all global tags (also those that are declared in data blocks), local variables (temporary
and static) as well as the parameters of the block.

You can also filter directly according to the type of tag, as required:
• Begin with # to only select from local tags of the current block interface,
• Begin with " to only have global tags displayed,
• Begin with % to have all tags filtered according to absolute addresses displayed,
SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-15
SIMATIC TIA Portal Programming 1

6.6.4. Renaming / Rewiring PLC Tags

A R
Renaming and Rewiring Tags

IN
Tags can be renamed or rewired as shown in the picture using the Blocks Editor. The changes

A
are immediately adopted in the PLC tag table and affect the entire program.
• Renaming and rewiring can also be done directly in the PLC tag table.
• Rename:
Change the tag name, while the absolute address remains unchanged.

R
• Rewire:
Change the associated absolute address, while the name remains unchanged.

IT
S
TIA-PRO1 - Binary Operations 1
6-16 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.6.5. Defining (Declaring) Tags while Programming

AR
N
Defining (Declaring) Tags while Programming
If unknown tags are used during programming, they can be defined later-on via the context menu
of the network.
AI
In the “Define tag” dialog, the [Local Temp] temporary memory area (Section) is always
suggested. When you change the area, the next free address is suggested.

Advantage:
In the dialog that appears, only addresses which have not been used so far are suggested. In this
way errors are avoided, for example, such as the use of bits which belong to an already used
TR

word (overlapping accesses).


SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-17
SIMATIC TIA Portal Programming 1

6.6.6. Closing / Saving / Rejecting a Block

CLOSE project and with that the block


(save or reject all changes)

SAVE project and with that


the block
(all changes !!)

AR
CLOSE the block
(no saving, no rejection)

Closing a Block
By clicking on the
N
symbol in the title bar, the block is merely closed. Changes are neither
rejected nor are they saved on the hard drive!
AI
Saving a Block
By using "Save project" the entire project, and with that also the block, is saved on the hard drive.
All changes made to the project are saved.
TR

Rejecting a Block
It is possible to reject block changes using the function Undo or by closing the entire project
without saving. All changes made in the project are rejected.
SI

TIA-PRO1 - Binary Operations 1


6-18 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.6.7. Compiling a Program

AR
N
Program Compilation
A delta compilation is always carried out via the "Compile" button, that is, only the changes to the
object selected (highlighted) in the Project tree are compiled. By selecting the Program blocks
AI
folder, all modified objects (blocks) within the folder are compiled.
Via the context menu in the Project tree, you can select whether only changes or the entire
software is to be compiled.
The status of the compilation is displayed in the Inspector window "Info -> Compile". If errors
occurred during compilation, you can jump directly from the error entry to the error location by
double-clicking on it.
TR

Note:
The menu items Software (rebuild all) and Software (rebuild all blocks) currently have the same
meaning.
Software (reset memory reserve) is not yet relevant in this chapter.
SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-19
SIMATIC TIA Portal Programming 1

6.6.8. Downloading a Program into the CPU

AR
Downloading a Program:
N
Program (Software) includes the blocks of the user program. The first time you download, they
are completely loaded. In subsequent downloads, only the software changes are loaded.
AI
However, all changes are always downloaded, that is, the offline program and the online program
are always the same after the download.

Note:
In the context menu of the device (CPU) there is also the menu item “Software (all)” in which all
blocks are loaded even if these have already been downloaded to the CPU. You have to make
TR

sure, however, that the CPU is stopped in this case.


SI

TIA-PRO1 - Binary Operations 1


6-20 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.6.9. Monitoring a Block

Monitor Block
On / Off

AR
Monitor
N
The test function Monitor is used to track the program execution within a block. The statuses or
contents of the operands used in the block at the time of program execution are displayed on the
AI
monitor.
You can only monitor if there is an online connection to the CPU and the offline program is
identical to the online program.
In test mode, the statuses of the operands and LAD / FBD elements are represented by different
colors.
TR

Examples:
• Status fulfilled  "Element is represented with a green color"
• Status not fulfilled  "Element is represented with a blue color"
SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-21
SIMATIC TIA Portal Programming 1

6.7. Exercise 2: Renaming OB "Main"

AR
1xR

Task
N
You are to rename the Organization block.
AI
What to Do
1. Open the "Program blocks" folder.
2. Open the context menu of the block "Main" by right-clicking on it.
3. Select the menu item "Rename".
TR

4. Give the block the symbolic name "Program Cycle"


5. Save your project.
SI

TIA-PRO1 - Binary Operations 1


6-22 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.7.1. Exercise 3: Programming the Jog Mode

AR
Task
N
You are to program the Jog mode of the conveyor as shown in the picture.
AI
What to Do
1. Open the OB "Program Cycle".
2. Program an AND logic operation by dragging it from the Favorites into the network using drag
& drop.
3. Program an Assignment (RLO Negation) by dragging it from the "Basic instructions" Task
TR

Card to an input of the AND logic operation using drag & drop.
4. At the first input of the AND logic operation enter the input "S_right" (%I0.2) as operand (you
can enter the symbol as well as the absolute address). Do the same for "S_left" (%I0.3).
5. In the Project tree, select (do not open!) the tag table "Conveyor" and drag the tag "K_right"
(%Q3.5) from the "Details view" as operand above the assignment.
6. Give the network a title.
7. Add a new network and their program an appropriate logic operation for jogging the conveyor
to the left.
SI

8. Close the Organization block.


9. Save your project.

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-23
SIMATIC TIA Portal Programming 1

6.7.2. Exercise 4: Compiling the Program, Downloading it into the CPU and
Saving the Project

3. Save project
2. Download program

1. Compile program

AR
Task
N
You are to compile and download the program and save the project.
AI
What to Do
1. Select the "Program blocks" folder.
2. Compile your program with the "Compile" button in the toolbar.
3. Download your program with the "Download" button in the toolbar.
TR

4. Save your project.


SI

TIA-PRO1 - Binary Operations 1


6-24 Training Document, V16.00.00
SIMATIC TIA Portal Programming 1

6.7.3. Exercise 5: Monitoring the Program

Monitor Block
On / Off

AR
Task
You are to monitor the program online.
N
AI
What to Do
1. Open the OB "Program Cycle".
2. Monitor the block (the program) with the "Monitor On/Off" button.
3. Activate the switches "S_left" and "S_right" on your training case.
TR
SI

TIA-PRO1 - Binary Operations 1


Training Document, V16.00.00 6-25

You might also like