TIA PRO1 06 Binary Operations 1
TIA PRO1 06 Binary Operations 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. Binary Operations 1
AR
and be able to apply them
... be able to carry out a program test with the “Monitor (block)” function
N
AI
TR
SI
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
6.2. Assignment
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.
NO activated
contact 1 “Yes” “No”
AR
yes
LAD: 1 LAD: 0
NC activated
no
contact 0 FBD: “No” FBD: “Yes”
0 1
not
activated yes 1 “Yes” “No”
1 0
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
FBD LAD
AND
Change the
Scan
AR
Change the
Operation
FBD
OR
Negation
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
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
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
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
FBD
AR
LAD
• 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.
AR
Process image Process image
for inputs for outputs
%IB 0 %QB 0
%IB 1 %QB 1
%IB 2 %QB 2
: :
:
User :
: program :
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
AR
Writing the process image for outputs
(PIQ) in the output modules
CPU Cycle
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")
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.
AR
OB_
Cycle
Dealt with in the chapter
Dealt with in the chapter
“Functions and
“Program Bocks”
Function Blocks”
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
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
Favorites
Frequently used elements, functions and instructions are available in the Favorites which can be
expanded individually from the Instructions catalog using drag & drop.
6.6.1. Networks
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
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
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
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
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
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
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
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
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
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
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
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
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