0% found this document useful (0 votes)
48 views35 pages

Course HMI Training Siemens

Uploaded by

w5npwcrrcn
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)
48 views35 pages

Course HMI Training Siemens

Uploaded by

w5npwcrrcn
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/ 35

O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Contents Page
LG

Objectives .......................................................................................................................................... 3
PN

Acquiring, Processing and Outputting Data …….............................................................................. 4


U
IV

Integer (INT, 16-Bit Integer) Data Type ........................................................................................... 5


19
D

Double Integer (DINT, 32-Bit Integer) Data Type .......................................................................... 6


9.
C
LA

REAL (Floating-point Number, 32 Bit) Data Type ........................................................................... 7


.0
C

The BCD Code for Inputting and Outputting Integers .................................................................. 8


23
W
A

Numbers Formats ….….................................................................................................................. 9


ID

Loading and Transferring Data …................................................................................................... 10


IB

Data Storage in Accumulator 1 ......................................................................................................... 11


O
H

S5 Counter Functions ……….......................................................................................................... 12


PR
O

Counters: Function Diagram .............................................................................................................. 13


PR

Exercise 1: Counting the Transported Parts (FC 18, C 18) .............................................................. 14


TI

S5 Timer Functions ……................................................................................................................. 15


so

Timers: ON Delay (SD) …………...................................................................................................... 16


ur

Exercise 2: Monitoring the Transport Functions (FC 17) ……….................................................... 17


C

Conversion Operations BCD <-> Integer ....................................................................................... 18


Comparison Operations .................................................................................................................... 19
Basic Mathematical Functions ……….......................................................................................... 20
Exercise 3: Counting the Transported Parts (FC 19) ....................................................................... 21
Exercise: Counting the Transported Parts (FC 19), Solution Hints .................................................. 22

SITRAIN ST-PRO1
Training for Industry Page 1 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Contents Page
LG

If You Want to Know More ………................................................................................................. 23


PN

Additional Exercise 4: Counting the Conveyor Belt Fault Conditions (FC17) ................................... 24
U
IV

Additional Exercise 5: Timely Lock-out of the Conveyor Motor Jogging .......................................... 25


19
D

Counters: Bit Instructions .................................................................................................................. 26


9.
C
LA

Timers: Stored ON Delay (SS) ………………................................................................................ 27


.0
C

Timers: Pulse (SP) ............................................................................................................................. 28


23
W
A

Timers: Extended Pulse (SE) ....................................................................................................... 29


ID

Timers: OFF Delay (SF) ………..................................................................................................... 30


IB

Time Formats for Traditional S5 Timers in STEP 7 ............................................................................... 31


O
H

Timers: Bit Instructions ................................................................................................................... 32


PR
O

Conversion Operations I -> DI -> REAL ........................................................................................ 33


PR

Digital Logic Operations .................................................................................................................... 34


TI

Application Example: Digital Edge Detection ……........................................................................... 35


so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 2 Digital Operations
SITRAIN
C PR
ur O

Training for Industry


so H
IB
TI
A ID
PR A
LA
O D
SI
2 IV
TR
+ U AI
W N
C LG
M
C X
M AC
+ IÓ
N

Page 3
23 PN
.0 D
9. @ EL
19 G C
O
KN N
D TE
riv N
el ID
in O
e
C
el
ay
a

Digital Operations
ST-PRO1
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Binary/Digital True logic control systems are recognizable in the fact that they exclusively
LG

Processing process binary data.


PN

The performance of today‘s control computer, as well as tasks in the data


U

processing, quality control areas, among others, has increased the importance of
IV

19

digital data processing using PLCs.


D

9.

Digital process variables can be found in all areas of open-loop control - such as in
C

connected devices for process operating and monitoring or in the control of field
LA

.0
C

devices.
23
W
A

Operating and The goal of process monitoring is to provide the operator with up-to-the-minute
ID

Monitoring information about the working machine or system quickly, concisely and clearly as
IB

well as the opportunity to intervene and control and influence the process.
2
O
H

While in the past mostly simple, that is, "dumb" input and output devices, such as 7-
PR
O

segment displays and thumbwheel buttons were used to display and enter digital
values, today "intelligent" operating and monitoring devices are frequently
PR

connected to a PLC.
A
TI

Field Devices Today as well, field devices that acquire process data or that control the process are
so

supplied directly with digital variables through field bus systems. The connection of
field devices, such as drives or weighing systems, using analog input and output
ur

modules is becoming more and more a thing of the past.


C

Formats Depending on the type of device connected, different number formats for the coding
of data are used to transmit data between device and PLC, as well as for storing
and processing data in the PLC.

SITRAIN ST-PRO1
Training for Industry Page 4 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Integer Data Type An Integer data type value is a whole number value, that is, a value without a
LG

(16-bit Integer) decimal point.


PN

SIMATIC S7 stores Integer data type values with sign in 16 bit code. This results in
U

the value range shown in the slide above. As well, SIMATIC S7 provides arithmetic
IV

19

operations for processing Integer values.


D

9.
C
LA

Decimal STEP7 uses the Decimal (not BCD!) display format to specify the constants of the
.0
C

Integer data type with sign and without explicit format description. The use of
23
W

constant Integer values in the Binary and Hexadecimal display formats is possible in
A

principle, but because of the poor legibility, they are more or less not suitable. For
ID

this reason, the syntax of STEP7 provides the specification of Integer values only in
IB

the decimal display format.


O
H

PR
O

Binary In a digital computer system, all values are stored in a binary-coded form. Only the
PR

digits 0 and 1 are available in the binary number system. Base 2 of this numbers
A

system results from the number of available digits. Accordingly, the value of every
TI

position of a binary number results from a power of Base 2. This is also expressed
in the format specification 2#.... .
so

Negative values are represented as binary numbers in twos complement. In this


ur

representation, the most significant bit (bit no. 15 for the Integer data type) has the
C

value - 215. Since this value is greater than the sum of all residual values, this bit
also has the sign information. That is, if this bit = 0, then the value is positive; if the
bit is = 1, then the value is negative. The conversion of a binary number into a
decimal number is made by adding the values of the positions that have a 1 (see
slide).

SITRAIN ST-PRO1
Training for Industry Page 5 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Double Integer SIMATIC S7 stores Double Integer data type values with sign as 32 bit code.
LG

(32-Bit Integer) This results in the value range shown in the slide above. As well, SIMATIC S7
PN

provides arithmetic operations for processing DINT values.


U
IV

19

Decimal STEP7 uses a decimal number (not BCD!) to specify a constant of the Double
D

Integer data type with sign and the format L# for "long" (double word, 32 bit).
9.
C

When a value smaller than -32768 or greater than 32767 is specified, the format L#
LA

.0
C

is automatically added. For negative numbers smaller than -32768, the user must
23

specify the format as L# - (for example: L# -32769). This is imperative if the value is
W
A

to be further processed arithmetically as a double integer since you would otherwise


ID

work with false values (value + sign)!


+
IB

2
O

Hexadecimal The hexadecimal numbers system provides 16 different digits (0 to 9 and


H

A to F). This results in Base 16 of this numbers system. Accordingly, the value of
PR
O

every position of a hexadecimal number results from a power of Base 16.


PR

Hexadecimal numbers are specified with the format W# for the dimension
A

(W = word = 16 bit) or DW# (DW = double word = 32 bit) and 16# for identifying the
TI

basic numbering system. The number of specifiable bits is variable from 1 to 8


whereby missing (unspecified) bits are filled with leading zero digits.
so

The digits A to F correspond to the decimal values 10 to 15. The value 15 is the last
ur

value that can be binary-coded - without sign - with 4 bits. Out of this correlation, the
C

simple conversion of a binary number into a hexadecimal number and vice versa
can be obtained. In this way, four binary bits each can easily make up one digit of a
hexadecimal number.

SITRAIN ST-PRO1
Training for Industry Page 6 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Real The previously described INT and DINT data types are used to store whole number
LG

values with sign. Accordingly, only operations that supply a whole number value as
PN

the result can be performed with these data types.


U

In cases where analog process variables such as voltage, current, and temperature
IV

19

have to be processed, it becomes necessary to use Real values (real numbers,


D

"decimal numbers"). In order to be able to represent such values, binary digits have
9.

to be defined whose value is less than 1 (power of base 2 with negative exponent).
C
LA

.0
C

23

Real Format In order to be able to form the greatest possible value range within a defined
W
A

memory capacity (for SIMATIC S7: double word, 32 bit) (see slide), you must be
ID

able to select the decimal point position. Early on, IEEE defined a format for
+

floating-point numbers. This format was laid down in IEC 61131 and was included in
IB

STEP 7. This format makes it easy to process a variable decimal point position.
O
H

In a binary coded floating-point number, a portion of the binary digits contain the
PR
O

mantissa (23 Bit) and the rest contain the exponent (8 Bit) and the sign of the
PR

floating-point number.
A

When you specify real values, you do so without specifying the format. After you
TI

enter a constant real value (for example: 0.75), the Editor automatically makes a
conversion to scientific notation (for example: 7.5000e-001).
so
ur

Application Floating-point numbers are used for "analog value processing", among others.
C

A great advantage of floating-point numbers is in the number of operations possible


with such numbers. These include, in addition to the standard operations such as:
+, -, * , / also instructions such as sin, cos, exp, ln, etc, that are used mainly in
closed-loop control algorithms.

SITRAIN ST-PRO1
Training for Industry Page 7 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Origin In the past, the specification and visualization of whole numbers was done
LG

exclusively using simple, mechanical thumbwheel buttons and digital displays.


PN

These thumbwheel buttons and digital displays were connected to the PLC‘s digital
U

input and output modules through parallel wiring.


IV

19
D

9.

BCD Code Each digit of a decimal number is encoded in four bit positions (a nibble). Four bits
C

are used because the highest decimal digit, 9, requires at least four bit positions in
LA

.0
C

binary code.
23
W
A
ID

Decimal No. BCD Code Decimal No. BCD Code


+

0 0000 6 0110
IB

1 0001 7 0111
O
H

2 0010 8 1000
PR
O

3 0011 9 1001
PR

4 0100 10 to 15 not allowed


5 0101
A
TI
so

Negative Numbers So that negative numbers can also be specified using a BCD thumbwheel button,
ur

STEP 7 codes the sign in the most significant bit of the most significant digit (see
slide). A sign bit = 0 indicates a positive number. A sign bit = 1 indicates a negative
C

number.
STEP 7 recognizes 16-bit-coded (sign + 3 digits) and 32-bit-coded (sign + 7 digits)
BCD numbers.
Data Formats There is no data format for specifying BCD-coded values in STEP 7. You can,
however, specify the decimal number whose BCD code is to be given, as a HEX
number. The binary code of the HEX number and that of the BCD-coded decimal
number is identical.
As you can see in the slide, the DEC data format is not suitable for specifying BCD
coded numbers!

SITRAIN ST-PRO1
Training for Industry Page 8 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

Display Formats Different display formats can be selected in both the "Monitor / Modify Variables" and
SI

the "Monitor (Block)" test function to display variables or register contents.


LG

PN

Every variable can be monitored with several display format options. Depending on
U

the variable‘s data type, it becomes apparent that monitoring with the appropriate
IV

display format makes more sense.


+

19

BOOL: Display a single bit


D

9.

(only possible for a variable of the BOOL data type)


C
LA

.0

BIN: Display the individual bits of a variable


C

23

(makes sense for variables of the BYTE, WORD, DWORD data types)
W
A

HEX: Display the contents of a variable as hexadecimal number (BCD)


ID

(makes sense for variables of the BYTE, WORD, DWORD data types)
IB

DEC: Display the contents of a variable as decimal number (not BCD!)


O

with sign (makes sense for variables of the INT, DINT data types)
H

PR
O

FLOATING_ Display the contents of a variable as floating-point number


POINT (makes sense for variables of the REAL data type)
PR

A
TI

Addressing The SIMATIC S7 memory is universally byte-oriented. Accordingly, memory


word MW 20, for example, contains the memory bytes MB 20 (high byte) and MB 21
so

(low byte, see slide), the memory double-word MD 80, the memory bytes MB 80, 81,
82 and 83.
ur

With absolute accesses to variables (such as, with L MD 80), you must make sure
C

that the dimension of the access (here MD...) as well as the address (always equal to
the address of the high byte, here 80) is correct. Through an inadvertent "accessing
in between", an invalid value would be loaded (such as, with L MW 83, see slide).
Such errors can be avoided with the symbolic addressing of variables (here L
"MD_DINT").

SITRAIN ST-PRO1
Training for Industry Page 9 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

MOVE (LAD/FBD) If the EN input is active, the value at input "IN" is copied to the address specified at
LG

output "OUT". "ENO" has the same signal state as "EN".


PN
U
IV

L and T (STL) Load and transfer instructions are executed regardless of the RLO. Data is
+

19

exchanged through the accumulator ACCU1.


D

9.
C
LA

.0
C

Standard / ACCU1 Accumulator 1 (ACCU1) is the main register in the CPU. The load instruction writes
23
W

the value from the source address right-justified into the (standard) accumulator 1
A

and pads the remaining bits (32 bits in all) with "0"s.
ID

The transfer instruction copies some or all of the contents of accumulator 1 to the
IB

specified memory address without clearing the contents of accumulator 1 (see next
O
H

page). All arithmetic and digital operations store their result in accumulator 1.
PR
O
PR

ACCU2 When a load instruction is executed, the old contents of accumulator 1 are first
A

shifted to accumulator 2 and accumulator 1 is cleared (reset to "0") before the new
TI

value is written into accumulator 1.


so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 10 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

General Accumulators are auxiliary memories in the CPU for data exchange between
LG

various addresses as well as for comparison and mathematical operations.


PN

The S7-300 usually has two accumulators with 32 bits each and the CPU 318-2 and
U

the S7-400 each have four accumulators also with 32 bits each.
IV

19
D

Load The load instruction loads the contents of the specified byte, word or double word
9.

into accumulator (ACCU) 1.


C
LA

.0
C

23

Transfer When a transfer instruction is executed, the contents of ACCU 1 are retained.
W
A

Consequently, the same information can be transferred to different destinations. If


ID

only one byte is transferred, the eight bits farthest to the right are used (see slide).
+
IB

2
O
H

PR
O
PR

A
TI
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 11 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Counter Value A 16-bit word is reserved for each counter in the system data memory. This word is
LG

used for storing the counter’s value (0 to 999) in binary code.


PN
U

Count Up When the RLO at the "CU" input changes from "0" to "1", the counter’s current value
IV

19

is incremented by 1 (upper limit = 999).


D

9.
C
LA

.0

Count Down When the RLO at the "CD" input changes from "0" to "1", the counter’s current value
C

is decremented by 1 (lower limit = 0).


23
W
A
ID

Set Counter When the RLO at the "S" input changes from "0" to "1", the counter is set to the
+
IB

value at the "PV" input.


2
O
H

PR

Reset Counter When the RLO at the Reset changes from "0" to "1", the counter’s value is set to
O

zero. If the reset condition is fulfilled (stays "high"), the counter cannot be set and
PR

counting in either direction is not possible.


A
TI

PV The preset value (0 to 999) is specified in BCD format at the "PV" input as:
so

• as a constant (C#...)
ur

• a BCD format through a data interface.


C

CV / CV_BCD The counter value can be loaded into the accumulator at the binary output as an
Integer value (CV) or at the decimal output as a BCD number (CV_BCD) and then
transferred from there to other addresses.

Q The signal state of the counter can be checked at output "Q":


• Counter value n: =0  Q=0
• Counter value n: 1<= n <= 999  Q = 1

SITRAIN ST-PRO1
Training for Industry Page 12 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Notes When the counter reaches the value 999 during count up, the counter value stays at
LG

999 with subsequent count up signals. Likewise, when the counter reaches the
PN

value 0, the counter value stays at 0 with subsequent count down signals.
U
IV

19

If an up count and a down count signal occurs at the same time, the count remains
the same.
D

9.
C
LA

.0
C

23
W
A
ID

+
IB

2
O
H

PR
O
PR

A
TI
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 13 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Function Up Till Now In AUTO mode, parts are transported from Bay 1 or Bay 2 to the Light Barrier Bay
LG

until they pass through the light barrier. The transportation function starts as soon
PN

as a part is placed on Bay 1 or Bay 2 and the associated bay’s momentary contact
U

is pressed and it ends as soon as the part has passed the light barrier.
IV

19
D

Task • The parts transported in AUTO mode are to be counted as soon as they have
9.

passed through the "LB" (I 8.0) light barrier ("LB" 0  1).


C
LA

.0
C

• The number of transported parts (ACTUAL quantity) is to be recorded with


23
W
A

the S5 counter C 18 and displayed on the BCD digital display.


ID

• The counter is to be reset when the system is switched off (Q 4.1 = "0").
+
IB

2
O
H

What to Do 1. Program the counting of the transported parts in the block "FC_Count" (FC18).
PR
O

Use the S5 counter C 18.


PR

2. Program the call of FC 18 in OB 1.


A
TI
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 14 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

LG

PN

General In control engineering, the following traditional timer functions (S5 timer functions)
have long since established themselves:
U

• Pulse Timer (S_PULSE or SP),


IV

19

• Extended Pulse (S_PEXT or SE),


D

9.

• ON Delay (S_ODT or SD),


C
LA

.0
C

• Stored ON Delay (S_ODTS or SS),


23
W

• OFF Delay (S_OFFDT or SF)


A
ID

Memory Timers have their own reserved memory area in the CPU in which each timer
IB

function occupies one word. To find out how many timer words and thus timer
O
H

functions are available in a CPU, please check the CPU‘s technical data.
PR
O
PR

Time Value The time value can be specified via a variable (such as MW50) or - as shown in the
A

slide - via a constant. The syntax for specifying a constant time value is (can be
TI

entered with or without underscore):


so

S5T#aH_bM_cS_dMS e.g. S5T#1h_20m_10s


ur

Minimum Time Value S5T#10ms


C

Maximum Time Value S5T#2h_46m_30s

SITRAIN ST-PRO1
Training for Industry Page 15 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Start The timer starts when the RLO at the Start input "S" changes from "0" to "1". The
LG

timer starts with the time value specified at the Time Value "TV" for as long as the
PN

signal state at input "S" =1.


U
IV

19

Reset When the RLO at the Reset input "R" changes from "0" to "1", the current time value
D

and the time base are deleted and the output "Q" is reset.
9.
C
LA

.0
C

Digital Outputs The current time value can be read as a binary number at the "BI" output and as a
23

BCD number at the "BCD" output.


W
A

The current time value is the initial value of "TV" minus the value for the time that
ID

has elapsed since the timer was started.


IB

2
O
H

Binary Output The signal at the "Q" output changes to "1" when the timer has expired without error
PR
O

and input "S" has signal state "1".


PR

If the signal state at the "S" input changes from "1" to "0" before the timer has
expired, the timer stops running and output "Q" has a signal state "0".
A
TI

Note In STEP 7, you can replace the traditional timer and counter functions with IEC –
so

conforming system function blocks (SFB). The use of system function blocks is
dealt with in an advanced programming course.
ur
C

SITRAIN ST-PRO1
Training for Industry Page 16 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Task The transport functions while in AUTO mode are to be monitored. The monitoring
LG

is to function as follows:
PN
U

• If the transport function takes longer than the 6 second monitoring time (if a
IV

part does not pass through the light barrier within 6 seconds of its start time),
+

19

then there is a fault in the system and the conveyor motor is automatically
D

9.

switched off (logic in FC 16).


C
LA

.0

• A fault is displayed with a 2Hz flashing light (bit no. 3 of the CPU clock memory
C

23

byte MB 10) on the simulator LED "L_Conv_Fault" (Q 5.0)


W
A

• A fault can be acknowledged via the simulator momentary contact


ID

"T_Ackn_Fault" (I 1.0)
IB

• The indicator lights at Bays 1 and 2 only once more show a constant light (=
O
H

place a new part), when the fault has been acknowledged (lock-out in
PR
O

FC 14)
PR

What to Do: 1. Program the described monitoring function in FC 17


TI

- For the (timely) monitoring, use the S5 timer T 17 as ON Delay (SD)


so

- When a fault exists, set the memory bit M 17.0 in order to be able to
ur

further interlock it in FC 14 and FC 16


C

2. Program the call of FC 17 in OB 1


3. Program the required lock-outs in FC 14 and the switching off of the
conveyor motor in FC16
4. Download the modified blocks into the CPU and test the function

SITRAIN ST-PRO1
Training for Industry Page 17 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Application Since there are no arithmetic operations for the direct processing of BCD-coded
LG

values, these have to be converted into arithmetic data types (I, DI or R) through
PN

format conversions.
U
IV

19

Conversion S7-300 / 400 has a series of conversion operations available– here a few
D

Operations examples:
9.
C
LA

.0

BCD_I (in STL: BTI)


C

23

converts a 3-digit BCD number (+/- 999) into a 16-bit integer


W
A

I_BCD (in STL: ITB)


ID

converts a 16-bit integer (+/- 999) ) into a 3-digit BCD number


+
IB

Inputs and Outputs of the LAD/FBD Elements:


O
H

PR

EN The execution of the conversion operation can be determined as follows via the EN
O

input:
PR

EN is not connected: the conversion is always (regardless of the RLO) executed


A

Logic operation at EN is fulfilled (RLO = 1): the conversion is executed


TI

Logic operation at EN is not fulfilled (RLO = 0): the conversion is not executed
so

IN The value delivered to IN is converted and the result is output to OUT.


ur
C

ENO / OUT ENO = 0 because RLO=0 at EN input  OUT not written


The variable delivered to OUT is not written, that is, it keeps its original value
ENO = 0 because error occurred  OUT contains invalid value
The variable delivered to OUT is overwritten with an invalid value
ENO = 1 (instruction was executed without error): OUT contains result
The variable delivered to OUT is overwritten with the result

SITRAIN ST-PRO1
Training for Industry Page 18 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

CMP You can use comparison instructions to compare the following pairs of numerical
LG

values:
PN

I Compare integers (on the basis of 16 bit fixed-point number)


U

D Compare integers (on the basis of 32 bit fixed-point number)


IV

19

R Compare floating-point numbers (on 32 bit real number basis =


D

9.

IEEE floating-point numbers).


C
LA

.0

If the result of the comparison is "true", then the RLO of the operation is "1",
C

23

otherwise it is "0".
W
A

The values at inputs IN1 and IN2 are compared for conformity with the specified
ID

condition:
+
IB

2
O
H

== IN1 is equal to IN2


PR
O

<> IN1 is not equal to IN2


PR

> IN1 is greater than IN2


A

< IN1 is less than IN2


TI

>= IN1 is greater than or equal to IN2


so

<= IN1 is less than or equal to IN2.


ur
C

SITRAIN ST-PRO1
Training for Industry Page 19 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Arithmetic S7-300 / 400 has a series of arithmetic operations for the processing of
LG

Operations variables of the integer (I), double integer (DI) and real (R) arithmetic data types.
PN
U

Inputs and Outputs of the LAD/FBD Elements:


IV

19

EN The execution of the operation can be determined as follows via the EN input:
D

9.

EN is not connected: the operation is always (regardless of the RLO) executed


C
LA

.0

Logic operation at EN is fulfilled (RLO = 1): the operation is executed


C

23

Logic operation at EN is not fulfilled (RLO = 0): the operation is not executed
W
A
ID

IN1 / IN2 The arithmetic calculation is applied to the values delivered to IN1 and IN2 (in STL,
IB

the value loaded first with the value loaded second, in general: ACCU2 with
2
O

ACCU1) and the result is output to OUT.


H

PR
O

ENO / OUT ENO = 0 because RLO=0 at EN input  OUT not written


PR

The variable delivered to OUT is not written, that is, it keeps its original value
A

ENO = 0 because error occurred  OUT contains invalid value


TI

The variable delivered to OUT is overwritten with an invalid value


so

ENO = 1 (instruction was executed without error): OUT contains result


The variable delivered to OUT is overwritten with the result
ur
C

SITRAIN ST-PRO1
Training for Industry Page 20 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

Function Up Till Now • The parts transported in AUTO mode are counted (with the S5 counter C18)
SI

in FC 18 as soon as they have passed through the light barrier "LB" ("LB": 0  1)
LG

PN

• The number of transported parts (ACT quantity) is displayed on the BCD


U

digital display.
IV

19

• The counter is reset when the system is switched off (Q 4.1 = "0").
D

9.

New Function FC19 • The counting of the transported parts is no longer to be done with the counter
C
LA

.0

C 18, but rather by addition using MW 20.


C

23
W

• The SETPOINT Quantity of how many parts are to be transported can be set
A

using the BCD thumbwheel. When the given SETPOINT Quantity is reached, it
ID

is displayed with the message "ACT=SET" on the conveyor model LED


IB

"L_Bay-LB" (Q 8.4).
2
O

• As long as the message "ACT=SET" (Q 8.4) exists, the indicator lights at Bay 1
H

and Bay 2 are dark (= no new part can be place on the conveyor  lock-out in
PR
O

FC 14) and no new transport function can be started ( lock-out in FC 16).


PR

• The message "ACT=SET" can be acknowledged using the conveyor‘s


A

momentary contact "T_Bay-LB" (I 8.4) by resetting the actual quantity


TI

(MW 20). Also, when the system is switched off, the ACT Quantity (MW 20) is
reset to "0".
so
ur

What to Do 1. Program the new block "FC_Count_Add" (FC 19) with the new counter and
C

comparison functions
2. In OB1, call the new FC 19 instead of the old FC 18
3. In the blocks "FC_Signal" (FC 14) and "FC_ConvMotor" (FC 16), program the
appropriate lock-outs

Note When you set the SETPOINT Quantity, the CPU occasionally goes into the
STOP state because the BCD thumbwheel "bounces" when you change the
numbers or it delivers invalid values.

SITRAIN ST-PRO1
Training for Industry Page 21 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Counting via Counting the transported parts using a memory word for each addition has,
LG

Addition among others, the following benefits vis-à-vis counting using S5 counters:
PN
U

When using an S5 counter, it is only possible to count from 0 to 999. However,


IV

when you count using Integer addition you can count from -32768 to + 32767.
+

19
D

9.

Partial Functions The complete function of the FC 19 can be broken down into the following
C
LA

.0

of the FC 19 partial functions as shown in the slide:


C

23
W

• NW 1: Set "Counter" to 0
A
ID

means overwriting the contents of memory word MW 20, that is used as the
+

counter, with 0.
IB

• NW 2: Counting via memory word


O
H

PR
O

means increasing the contents of the memory word by 1 (with addition) every
time the count event occurs (not as long as the count event itself exists!). The
PR

occurrence of the count event must be detected by edge detection.


A
TI

• NW 3: Display ACT quantity on the BCD digital display


Since the ACT quantity recorded by addition in memory word MW 20 is
so

stored as an Integer, a format conversion from Integer to BCD must take place
ur

before the transfer to the BCD digital display.


C

• NW 4: Read in SETP quantity and convert from BCD to Integer


The SETP quantity read in from the BCD thumbwheel must be converted from
BCD to Integer. Use memory word MW 22 to store the conversion result.
• NW 5: ACT-SETP comparison, Conveyor indicator light Q 8.4
The ACT quantity (MW 20) is compared to the converted SETP quantity
(MW 22). If the actual quantity is equal to the set point quantity, the indicator
light Q 8.4 must be turned on.

SITRAIN ST-PRO1
Training for Industry Page 22 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Note The following pages contain either further information or are for reference to
LG

complete a topic.
PN

For more indepth study we offer advanced courses and self-learning mediums.
U
IV

19
D

9.
C
LA

.0
C

23
W
A
ID

+
IB

2
O
H

PR
O
PR

A
TI
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 23 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Function Up Till Now The transport functions in AUTO mode are monitored. If the transport function takes
LG

longer than the 6 second monitoring time (if a part does not pass through the light
PN

barrier within 6 seconds of its start time), then there is a conveyor belt fault
U

condition in the system and the conveyor motor is automatically switched off (logic
IV

19

in FC 16).
D

9.
C
LA

.0

Task: The conveyor belt fault conditions in AUTO mode are to be counted. After 3
C

conveyor belt fault conditions have occurred, the AUTO mode is to be switched off
23
W
A

for safety reasons. To start a new transport function, the fault condition must be
ID

acknowledged (as already programmed) and the AUTO mode must be switched on
+

once more.
IB

2
O
H

PR

What to Do: 1. In FC 17, in a new network, program the counting of the conveyor belt fault
O

conditions using the S5 counter C 17 as the count down counter.


PR

- When the "Auto" mode is switched on, the counter is set to 3 (number of
A
TI

conveyor belt fault conditions until the AUTO mode is switched off)
- The counter counts down 1 every time a conveyor belt fault condition
so

occurs (M 17.0 = "1").


ur

2. In FC 15 (operator mode section), program the switching off (reset) of the


C

AUTO mode after three conveyor belt fault conditions.


The AUTO mode must switch off when the counter C 17 has counted down
from 3 to 0 or when its binary state changes from 1  0. In FC 15 "FC_Mode",
use the bit memory M 15.7 as auxiliary bit memory to record the negative edge
of C 17.

SITRAIN ST-PRO1
Training for Industry Page 24 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

The Function JoggingIn MANUAL mode (Q8.2 / Q 4.2 = ´1´), you can jog the conveyor motor to the
LG

in FC 16 Up Till Now: RIGHT and to the LEFT using the simulator momentary contacts I 0.2 and I 0.3.
PN
U

Task: In order to avoid too great a load change, it should only be possible to jog the
IV

19

conveyor motor in the opposite direction after it has been jogged to the RIGHT or to
D

9.

the LEFT after a lock-out time of 2 seconds (see slide). If, for example, the motor
C
LA

has been jogged to the RIGHT, then it can only be jogged back to the LEFT after
.0
C

the lock-out time of 2 seconds has expired.


23
W
A
ID

What to Do: 1. In FC 16 program the S5 timers T 15 and T 16 as the lock-out timers RIGHT and
+

LEFT as OFF Delay (SF). Start T 15 when the jog condition RIGHT is fulfilled
IB

and T 16 when the jog condition LEFT is fulfilled.


O
H

PR

2. Interlock the timer states to the jog conditions. The jog condition RIGHT may
O

only be fulfilled when the lock-out time LEFT is no longer running


PR

(T 16 = ´0´) and vice versa.


A
TI

3. Save the modified FC 16 and download it in the CPU


4. Check the modified function "Jog Conveyor" on the conveyor model
so
ur

Solution Hint: By using a "branch", you can integrate the timers in the two networks Jog Conveyor
C

RIGHT and Jog Conveyor LEFT as follows:

Editing a branch:
1. Select the connection where
the branch is to be place Jog condition
LEFT
2. click on in the Editor toolbar
T 16
(Branch) SF

S5T#2s TV

SITRAIN ST-PRO1
Training for Industry Page 25 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Bit Instructions All counter functions can also operate with simple bit instructions. The similarities
LG

and differences between this method and the counter functions discussed so far are
PN

as follows:
U

• Similarities:
IV

19

- Setting conditions at the "SC" input


D

9.

- Specification of the counter value


C
LA

.0

- RLO change at the "CU" input


C

23

- RLO change at the "CD" input


W
A

• Differences:
ID

- It is not possible to check the current counter value since


IB

there are no Binary (CV) or BCD (CV_BCD) outputs.


O
H

- There is no binary output Q in the graphical representation.


PR
O
PR

Note IEC-compliant counters can also be implemented in STEP 7. The use of system
A

function blocks for implementing IEC counters is dealt with in an advanced


TI

programming course.
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 26 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Start The stored-on-delay timer starts when the RLO at the "S" input changes from "0" to
LG

"1". The timer runs, starting with the time value specified at input "TV", and
PN

continues to run even if the signal at input "S" changes back to "0" during that time.
U
IV

If the signal at the start input changes from "0" to "1" again while the timer is still
+

19

timing down, the timer starts again from the beginning.


D

9.
C
LA

.0

Reset When the RLO at reset input "R" changes from "0" to "1", the current time value and
C

23

the time base are deleted and output "Q" is reset.


W
A
ID

Binary Output The signal state at output "Q" changes to "1" when the timer has expired without
IB

error, regardless of whether the signal state at input "S" is still "1".
O
H

PR
O
PR

A
TI
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 27 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Start The pulse timer starts when the RLO at the "S" input changes from "0" to "1". Output
LG

"Q" is also set to "1".


PN
U
IV

Reset Output "Q" is reset when:


+

19

• the timer has expired, or


D

9.

• the start "S" signal changes from "1" to "0", or


C
LA

.0

• the reset input "R" has a signal state of "1".


C

23
W
A
ID

+
IB

2
O
H

PR
O
PR

A
TI
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 28 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Start The extended pulse timer starts when the RLO at the "S" input changes from "0" to
LG

"1". Output "Q" is also set to "1".


PN

The signal state at output "Q" remains at "1" even if the signal at the "S" input
U

changes back to "0".


IV

19

If the signal at the start input changes from "0" to "1" again while the timer is
D

9.

running, the timer is restarted.


C
LA

.0
C

23

Reset Output "Q" is reset when:


W
A

• the timer has expired, or


ID

• the reset input "R" has a signal state of "1".


IB

2
O
H

PR
O
PR

A
TI
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 29 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Start The off-delay timer starts when the RLO at the "S" input changes from "1" to "0".
LG

When the timer has expired, the signal state at output "Q" changes to "0".
PN
U

If the signal state at the "S" input changes from "0" to "1" while the timer is running,
IV

the timer stops. The next time the signal state at the "S" input changes from "1" to
+

19

"0", it starts again from the beginning.


D

9.
C
LA

.0

Reset When the RLO at reset input "R" is "1", the current time value and the time base are
C

23

deleted and output "Q" is reset.


W
A

If both inputs (S and R) have signal states of "1", output "Q" is not set until the
ID

dominant reset is deactivated.


IB

2
O
H

Binary Output Output "Q" is activated when the RLO at the "S" input changes from "0" to "1". If
PR
O

input "S" is deactivated, output "Q" continues to have signal state of "1" until the
PR

programmed time has expired.


A
TI
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 30 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Time Specification Time values can be fixed and are specified as time constants. The permissible
LG

range in which the time values are found ranges from S5T#10ms to
PN

S5T#2h46m30s0ms.
U

Variable times can be specified using variables (such as memory words or data
IV

19

words) containing the S5TIME data type. The user must make sure that the
D

appropriate time base and the number of units of time, as shown in the slide, are
9.

stored in the variable in his program.


C
LA

.0
C

Time Base The time base defines the interval at which the number of units of time is to be
23

decremented by one unit when the timer runs. Bits 12 and 13 of the variable must
W
A

contain the time base as a binary-coded number:


ID

+
IB

Time base 0 (bit 13 = 0, bit 12 = 0) = 10 ms


2
O
H

Time base 1 (bit 13 = 0, bit 12 = 1) = 100ms


PR
O

Time base 2 (bit 13 = 1, bit 12 = 0) = 1s


PR

Time base 3 (bit 13 = 1, bit 12 = 1) = 10s


A
TI

Units of Time The number of units of time must be specified as a BCD-coded number. When the
number of units of time are multiplied by the time base, this results in the desired
so

time value. The range from 1 to 999 is possible. When there is a time specification
ur

using a constant (S5T#...), the system automatically uses the smallest possible time
base and the number of units of time.
C

L / BI At output "BI" or with the instruction "L T..." , the residual time value (number of
units of time) of the timer is queried as an integer without time base.

LC / BCD At output "BCD" or with the instruction "LC T..." , the residual time value (number
of units of time) of the timer is queried as a BCD-coded number with the time base
in Bit 12 and 13.

SITRAIN ST-PRO1
Training for Industry Page 31 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Bit Instructions All timer functions can also be started with simple bit instructions. The similarities
LG

and differences between this method and the timer functions discussed so far are
PN

as follows:
U

• Similarities:
IV

19

- Start conditions at the "S" input


D

9.

- Specification of the time value


C
LA

.0

- Reset conditions at the "R" input


C

23

- Signal response at output "Q"


W
A

• Differences for LAD and FBD:


ID

- It is not possible to check the current time value (there are no "BI" and
IB

"BCD" outputs).
O
H

PR
O
PR

A
TI
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 32 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

Application Basically, arithmetic operations can only process values of the same data type.
LG

Therefore, there are operations with which integer values (I or DI) can be converted
PN

into real values (R) and vice versa.


U
IV

19

I_DI (in STL: ITD) converts a 16-bit integer (I) into a 32-bit double integer (DI)
D

9.
C

DI_R (in STL: DTR) converts a 32-bit double integer (DI) into a floating-point number (R)
LA

.0
C

23
W

Other Conversion
A

Operations are discussed in one of the advanced programming courses:


ID

- INV_I (INVI) Inverts an integer (I)


IB

(formation of the ones complement)


O
H

- NEG_I (NEGI) Negates (sign reversal) an integer (I)


PR
O

(formation of the twos complement)


PR

- TRUNC (TRUNC) Conversion R  DI: cut off after decimal positions


A

- ROUND (RND) Conversion R  DI: round


TI

- CEIL (RND+) Conversion R  DI: general rounding up


so

- FLOOR (RND-) Conversion R  DI: general rounding down


ur

- INV_DI (INVD) Inverts a double integer (DI)


(formation of the ones complement)
C

- NEG_DI (NEGD) Negates (sign reversal) a double integer (DI)


(formation of the twos complement)
- NEG_R / NEGR Negates (sign reversal) a floating-point number (R)

SITRAIN ST-PRO1
Training for Industry Page 33 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

WAND_W The "AND Word" operation gates the two digital values at inputs IN1 and IN2 bit by
LG

bit in accordance with the AND truth table. The result of the AND operation is stored
PN

at the address at output OUT.


U

The instruction is executed when EN = 1.


IV

19

Example: Masking out the 4th decade of the thumbwheel buttons :


D

9.

IW4= = 0100 0100 1100 0100


C

W#16#0FFF = 0000 1111 1111 1111


LA

.0
C

MW30 = 0000 0100 1100 0100


23
W
A
ID

WOR_W The "OR Word" operation gates the two digital values at inputs IN1 and IN2 bit by
+

bit in accordance with the OR truth table. The result of the OR operation is stored at
IB

the address at output OUT.


O
H

The instruction is executed when EN = 1.


PR
O

Example: Setting bit 0 in MW32 :


PR

MW32 = 0100 0010 0110 1010


A

W#16#0001 = 0000 0000 0000 0001


TI

MW32 = 0100 0010 0110 1011


so

WXOR_W The "Exclusive OR Word" operation gates the two digital values at inputs IN1 and
ur

IN2 bit by bit in accordance with the XOR truth table. The result of the OR operation
C

is stored at the address at output OUT. The result of the XOR operation is stored at
the address at output OUT.
The instruction is executed when EN=1.
Example: detecting signal changes in IW0 :
IW0 = 0100 0100 1100 1010
MW28 = 0110 0010 1011 1001
MW24 = 0010 0110 0111 0011

SITRAIN ST-PRO1
Training for Industry Page 34 Digital Operations
O

a
ID

ay
N

el
TE

C
N

e
O

in
C

el
riv
X

EL
M

D
D
N

KN
N
AI

G
TR

AC

@
SI

General The program example displayed in the slide implements a logic for detecting a
LG

signal change of 16 binary digits (edge detection for 16 bit) using digital word
PN

instructions.
U
IV

19

Network 1 For the detection of a positive edge detection, that is, the detection of a signal
change from 0  1, it suffices to carry out a digital AND operation of the change
D

9.

pattern (MW 220) with the new signal states (IW 0).
C
LA

.0
C

23

Network 2 If only the 1  changes are to be detected, a digital AND operation of the change
W
A

pattern with the old signal states is to be carried out.


ID

+
IB

Network 3 Save the old states so that the signal state change can be detected.
2
O
H

PR
O
PR

A
TI
so
ur
C

SITRAIN ST-PRO1
Training for Industry Page 35 Digital Operations

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy