Documente Academic
Documente Profesional
Documente Cultură
F1
Contents Page
Objectives .......................................................................................................................................... 3
Acquiring, Processing and Outputting Data …….............................................................................. 4
Integer (INT, 16-Bit Integer) Data Type ........................................................................................... 5
Double Integer (DINT, 32-Bit Integer) Data Type .......................................................................... 6
REAL (Floating-point Number, 32 Bit) Data Type ........................................................................... 7
The BCD Code for Inputting and Outputting Integers .................................................................. 8
Numbers Formats ….….................................................................................................................. 9
Loading and Transferring Data …................................................................................................... 10
Data Storage in Accumulator 1 ......................................................................................................... 11
S5 Counter Functions ……….......................................................................................................... 12
Counters: Function Diagram .............................................................................................................. 13
Exercise 1: Counting the Transported Parts (FC 18, C 18) .............................................................. 14
S5 Timer Functions ……................................................................................................................. 15
Timers: ON Delay (SD) …………...................................................................................................... 16
Exercise 2: Monitoring the Transport Functions (FC 17) ……….................................................... 17
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
F1
Contents Page
If You Want to Know More ………................................................................................................. 23
Additional Exercise 4: Counting the Conveyor Belt Fault Conditions (FC17) ................................... 24
Additional Exercise 5: Timely Lock-out of the Conveyor Motor Jogging .......................................... 25
Counters: Bit Instructions .................................................................................................................. 26
Timers: Stored ON Delay (SS) ………………................................................................................ 27
Timers: Pulse (SP) ............................................................................................................................. 28
Timers: Extended Pulse (SE) ....................................................................................................... 29
Timers: OFF Delay (SF) ………..................................................................................................... 30
Time Formats for Traditional S5 Timers in STEP 7............................................................................... 31
Timers: Bit Instructions ................................................................................................................... 32
Conversion Operations I -> DI -> REAL ........................................................................................ 33
Digital Logic Operations .................................................................................................................... 34
Application Example: Digital Edge Detection ……........................................................................... 35
... be familiar with the INT, DINT, REAL data types and the
BCD display
Operating 0248
Thumbwheel
+ monitoring V buttons,
processes Potentiometer,
0 8 1 5 7-segment
display
Operator Panel
DI/ AI/
DO AO
such as PROFIBUS
Binary/Digital True logic control systems are recognizable in the fact that they exclusively
Processing process binary data.
The performance of today‘s control computer, as well as tasks in the data
processing, quality control areas, among others, has increased the importance
of digital data processing using PLCs.
Digital process variables can be found in all areas of open-loop control - such
as in connected devices for process operating and monitoring or in the control
of field devices.
Operating and The goal of process monitoring is to provide the operator with up-to-the-minute
Monitoring information about the working machine or system quickly, concisely and clearly
as well as the opportunity to intervene and control and influence the process.
While in the past mostly simple, that is, "dumb" input and output devices, such
as 7-segment displays and thumbwheel buttons were used to display and enter
digital values, today "intelligent" operating and monitoring devices are
frequently connected to a PLC.
Field Devices Today as well, field devices that acquire process data or that control the
process are 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 modules is becoming more and more a thing of the
past.
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.
Display Formats:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Integer Data Type An Integer data type value is a whole number value, that is, a value without a
(16-bit Integer) decimal point.
SIMATIC S7 stores Integer data type values with sign in 16 bit code. This
results in the value range shown in the slide above. As well, SIMATIC S7
provides arithmetic operations for processing Integer values.
Decimal STEP7 uses the Decimal (not BCD!) display format to specify the constants of
the Integer data type with sign and without explicit format description. The use
of constant Integer values in the Binary and Hexadecimal display formats is
possible in principle, but because of the poor legibility, they are more or less
not suitable. For this reason, the syntax of STEP7 provides the specification of
Integer values only in the decimal display format.
Binary In a digital computer system, all values are stored in a binary-coded form. Only
the digits 0 and 1 are available in the binary number system. Base 2 of this
numbers system results from the number of available digits. Accordingly, the
value of every position of a binary number results from a power of Base 2. This
is also expressed in the format specification 2#.... .
Negative values are represented as binary numbers in twos complement. In
this representation, the most significant bit (bit no. 15 for the Integer data type)
has the 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).
Display Formats:
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Sign
positive
numbers
HEX: DW#16# 0 0 0 8 4 0 8 9
(without sign)
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Sign
negative
numbers
Double Integer SIMATIC S7 stores Double Integer data type values with sign as 32 bit code.
(32-Bit Integer) This results in the value range shown in the slide above. As well, SIMATIC S7
provides arithmetic operations for processing DINT values.
Decimal STEP7 uses a decimal number (not BCD!) to specify a constant of the Double
Integer data type with sign and the format L# for "long" (double word, 32 bit).
When a value smaller than -32768 or greater than 32767 is specified, the
format L# is automatically added. For negative numbers smaller than -32768,
the user must specify the format as L# - (for example: L# -32769). This is
imperative if the value is to be further processed arithmetically as a double
integer since you would otherwise work with false values (value + sign)!
Example: 0.75
Sign of
Real no. e = Exponent (8 Bit) f = Mantissa (23 Bit)
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27 26 25 24 23 22 21 20 2-1 2-2 2-3 2-4 ..... 2-23
Real The previously described INT and DINT data types are used to store whole
number values with sign. Accordingly, only operations that supply a whole
number value as the result can be performed with these data types.
In cases where analog process variables such as voltage, current, and
temperature have to be processed, it becomes necessary to use Real values
(real numbers, "decimal numbers"). In order to be able to represent such
values, binary digits have to be defined whose value is less than 1 (power of
base 2 with negative exponent).
Real Format In order to be able to form the greatest possible value range within a defined
memory capacity (for SIMATIC S7: double word, 32 bit) (see slide), you must
be 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 STEP 7. This format makes it easy to process a variable decimal
point position.
In a binary coded floating-point number, a portion of the binary digits contain
the mantissa (23 Bit) and the rest contain the exponent (8 Bit) and the sign of
the floating-point number.
When you specify real values, you do so without specifying the format. After
you enter a constant real value (for example: 0.75), the Editor automatically
makes a conversion to scientific notation (for example: 7.5000e-001).
Application Floating-point numbers are used for "analog value processing", among others.
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.
0 2 9 6
16 Bit: BIN.: 2# 0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0
Sign (+) 2 9 6
Sign (+) 0 0 0 0 2 9 6
32 Bit: BIN.: 2# 0 x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0
Origin In the past, the specification and visualization of whole numbers was done
exclusively using simple, mechanical thumbwheel buttons and digital displays.
These thumbwheel buttons and digital displays were connected to the PLC‘s
digital input and output modules through parallel wiring.
BCD Code Each digit of a decimal number is encoded in four bit positions (a nibble). Four
bits are used because the highest decimal digit, 9, requires at least four bit
positions in binary code.
Negative Numbers So that negative numbers can also be specified using a BCD thumbwheel
button, 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 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!
Display Formats Different display formats can be selected in both the "Monitor / Modify Variables"
and the "Monitor (Block)" test function to display variables or register contents.
Every variable can be monitored with several display format options. Depending
on the variable‘s data type, it becomes apparent that monitoring with the
appropriate display format makes more sense.
BOOL: Display a single bit
(only possible for a variable of the BOOL data type)
BIN: Display the individual bits of a variable
(makes sense for variables of the BYTE, WORD, DWORD data
types)
HEX: Display the contents of a variable as hexadecimal number (BCD)
(makes sense for variables of the BYTE, WORD, DWORD data
types)
DEC: Display the contents of a variable as decimal number (not BCD!)
with sign (makes sense for variables of the INT, DINT data types)
FLOATING_ Display the contents of a variable as floating-point number
POINT (makes sense for variables of the REAL data type)
(ACCU 1)
12345678 A1B2C3D4
MOVE (LAD/FBD) If the EN input is active, the value at input "IN" is copied to the address
specified at output "OUT". "ENO" has the same signal state as "EN".
L and T (STL) Load and transfer instructions are executed regardless of the RLO. Data is
exchanged through the accumulator ACCU1.
Standard / ACCU1 Accumulator 1 (ACCU1) is the main register in the CPU. The load instruction
writes the value from the source address right-justified into the (standard)
accumulator 1 and pads the remaining bits (32 bits in all) with "0"s.
The transfer instruction copies some or all of the contents of accumulator 1 to
the specified memory address without clearing the contents of accumulator 1
(see next page). All arithmetic and digital operations store their result in
accumulator 1.
ACCU2 When a load instruction is executed, the old contents of accumulator 1 are first
shifted to accumulator 2 and accumulator 1 is cleared (reset to "0") before the
new value is written into accumulator 1.
L MB 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 MB0
31 23 15 7 0
Load 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 MB0 MB1
L MW 0
31 23 15 7 0
T QD 4
QD 4
Transfer T QW 4
QW 4
T QB 4
QB 4
General Accumulators are auxiliary memories in the CPU for data exchange between
various addresses as well as for comparison and mathematical operations.
The S7-300 usually has two accumulators with 32 bits each and the CPU 318-2
and the S7-400 each have four accumulators also with 32 bits each.
Load The load instruction loads the contents of the specified byte, word or double
word into accumulator (ACCU) 1.
Transfer When a transfer instruction is executed, the contents of ACCU 1 are retained.
Consequently, the same information can be transferred to different
destinations. If only one byte is transferred, the eight bits farthest to the right
are used (see slide).
A I 0.4
C5 C5
CU C5
S_CUD S_CUD
I 0.4 Q 8.3 A I 0.5
CU Q
Q I 0.4 CU CD C5
A I 0.3
I 0.5
L C#5
CD CV MW 4 I 0.5 CD
S C5
I 0.3 A I 0.7
S CV_BCD QW 12 I 0.3 S CV MW 4 R C5
L C5
C#5 PV C#5 PV CV_BCD QW 12 T MW4
Q 8.3 LC C5
I 0.7
R I 0.7 R Q
Q = T QW12
A C5
= Q8.3
Counter Value A 16-bit word is reserved for each counter in the system data memory. This
word is used for storing the counter’s value (0 to 999) in binary code.
Count Up When the RLO at the "CU" input changes from "0" to "1", the counter’s current
value is incremented by 1 (upper limit = 999).
Count Down When the RLO at the "CD" input changes from "0" to "1", the counter’s current
value is decremented by 1 (lower limit = 0).
Set Counter When the RLO at the "S" input changes from "0" to "1", the counter is set to the
value at the "PV" input.
Reset Counter When the RLO at the Reset changes from "0" to "1", the counter’s value is set
to zero. If the reset condition is fulfilled (stays "high"), the counter cannot be set
and counting in either direction is not possible.
PV The preset value (0 to 999) is specified in BCD format at the "PV" input as:
• as a constant (C#...)
• a BCD format through a data interface.
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.
CU
CD
5
4
3
Count
2
1
0
Notes When the counter reaches the value 999 during count up, the counter value
stays at 999 with subsequent count up signals. Likewise, when the counter
reaches the value 0, the counter value stays at 0 with subsequent count down
signals.
If an up count and a down count signal occurs at the same time, the count
remains the same.
DI DO
I 0.0 T_System_ON Act Quantity
I 0.1 T_System_OFF L_SYSTEM Q 4.1
I 0.2 T_Jog_RIGHT L_MAN Q 4.2
I 0.3 T_Jog_LEFT L_AUTO Q 4.3 V
I 0.4 S_M/A_ModeSelect
I 0.5 T_M/A_Accept "QW_DigDisp" (QW 6)
-15V...+15V -15V...+15V
AI2 AO1
AI1 AO2
AI1 AI2
V
Function Up Till Now In AUTO mode, parts are transported from Bay 1 or Bay 2 to the Light Barrier
Bay until they pass through the light barrier. The transportation function starts
as soon as a part is placed on Bay 1 or Bay 2 and the associated bay’s
momentary contact is pressed and it ends as soon as the part has passed the
light barrier.
Task • The parts transported in AUTO mode are to be counted as soon as they
have passed through the "LB" (I 8.0) light barrier ("LB" 0 Æ 1).
• The number of transported parts (ACTUAL quantity) is to be recorded with
the S5 counter C 18 and displayed on the BCD digital display.
• The counter is to be reset when the system is switched off (Q 4.1 = "0").
What to Do 1. Program the counting of the transported parts in the block "FC_Count"
(FC18). Use the S5 counter C 18.
2. Program the call of FC 18 in OB 1.
ON Delay (SD)
T44
S_ODT
I 0.7 S BI MW0
General In control engineering, the following traditional timer functions (S5 timer
functions) have long since established themselves:
• Pulse Timer (S_PULSE or SP),
• Extended Pulse (S_PEXT or SE),
• ON Delay (S_ODT or SD),
• Stored ON Delay (S_ODTS or SS),
• OFF Delay (S_OFFDT or SF)
Memory Timers have their own reserved memory area in the CPU in which each timer
function occupies one word. To find out how many timer words and thus timer
functions are available in a CPU, please check the CPU‘s technical data.
Time Value The time value can be specified via a variable (such as MW50) or - as shown in
the slide - via a constant. The syntax for specifying a constant time value is
(can be entered with or without underscore):
S5T#aH_bM_cS_dMS e.g. S5T#1h_20m_10s
T4 T4
I 0.7 S_ODT Q8.5 S_EVERZ A I 0.7
S Q I 0.7 S BI MW0 L S5T#35s
S5T#35s TV BI MW0 S5T#35s QW12
SD T4
TV BCD
I 0.5 Q8.5 A I 0.5
R BCD QW12 I 0.5 R Q = R T4
L T4
T MW0
RLO at S
LC T4
RLO at R T QW12
A T4
Time = Q8.5
operation
Example
Start The timer starts when the RLO at the Start input "S" changes from "0" to "1".
The timer starts with the time value specified at the Time Value "TV" for as long
as the signal state at input "S" =1.
Reset When the RLO at the Reset input "R" changes from "0" to "1", the current time
value and the time base are deleted and the output "Q" is reset.
Digital Outputs The current time value can be read as a binary number at the "BI" output and
as a BCD number at the "BCD" output.
The current time value is the initial value of "TV" minus the value for the time
that has elapsed since the timer was started.
Binary Output The signal at the "Q" output changes to "1" when the timer has expired without
error and input "S" has signal state "1".
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".
Note In STEP 7, you can replace the traditional timer and counter functions with IEC
–conforming system function blocks (SFB). The use of system function blocks
is dealt with in an advanced programming course.
DI DO
I 0.0 T_System_ON
I 0.1 T_System_OFF L_SYSTEM Q 4.1
I 0.2 T_Jog_RIGHT L_MAN Q 4.2
I 0.3 T_Jog_LEFT L_AUTO Q 4.3
I 0.4 S_M/A_ModeSelect
I 0.5 T_M/A_Accept
T_Ackn L_Conv
I 1.0 _Fault _Fault Q 5.0
Task The transport functions while in AUTO mode are to be monitored. The
monitoring is to function as follows:
• If the transport function takes longer than the 6 second monitoring time (if a
part does not pass through the light barrier within 6 seconds of its start
time), then there is a fault in the system and the conveyor motor is
automatically switched off (logic in FC 16).
• A fault is displayed with a 2Hz flashing light (bit no. 3 of the CPU clock
memory byte MB 10) on the simulator LED "L_Conv_Fault" (Q 5.0)
• A fault can be acknowledged via the simulator momentary contact
"T_Ackn_Fault" (I 1.0)
• The indicator lights at Bays 1 and 2 only once more show a constant light (=
place a new part), when the fault has been acknowledged (lock-out in
FC 14)
Number Conversion
entered in BCD 0 81 5 BCD->Integer
User program
Task
with Integer
math operations
Number Conversion
displayed 0 2 4 8 BCD<-Integer
in BCD
Application Since there are no arithmetic operations for the direct processing of BCD-
coded values, these have to be converted into arithmetic data types (I, DI or R)
through format conversions.
Conversion S7-300 / 400 has a series of conversion operations available– here a few
Operations examples:
CMP You can use comparison instructions to compare the following pairs of
numerical values:
I Compare integers (on the basis of 16 bit fixed-point number)
D Compare integers (on the basis of 32 bit fixed-point number)
R Compare floating-point numbers (on 32 bit real number basis =
IEEE floating-point numbers).
If the result of the comparison is "true", then the RLO of the operation is "1",
otherwise it is "0".
The values at inputs IN1 and IN2 are compared for conformity with the
specified condition:
Arithmetic S7-300 / 400 has a series of arithmetic operations for the processing of
Operations variables of the integer (I), double integer (DI) and real (R) arithmetic data
types.
IN1 / IN2 The arithmetic calculation is applied to the values delivered to IN1 and IN2 (in
STL, the value loaded first with the value loaded second, in general: ACCU2
with ACCU1) and the result is output to OUT.
ACT=SET Acknowledgement
"L_Bay-LB" (Q 8.4) "T_Bay-LB" (I 8.4)
Function Up Till Now • The parts transported in AUTO mode are counted (with the S5 counter C18)
in FC 18 as soon as they have passed through the light barrier "LB" ("LB": 0 Æ 1)
• The number of transported parts (ACT quantity) is displayed on the BCD
digital display.
• The counter is reset when the system is switched off (Q 4.1 = "0").
New Function FC19 • The counting of the transported parts is no longer to be done with the
counter C 18,but rather by addition using MW 20.
• The SETPOINT Quantity of how many parts are to be transported can be set
using the BCD thumbwheel. When the given SETPOINT Quantity is
reached, it is displayed with the message "ACT=SET" on the conveyor
model LED "L_Bay-LB" (Q 8.4).
• As long as the message "ACT=SET" (Q 8.4) exists, the indicator lights at
Bay 1 and Bay 2 are dark (= no new part can be place on the conveyor Æ
lock-out in FC 14) and no new transport function can be started (Æ lock-out
in FC 16).
• The message "ACT=SET" can be acknowledged using the conveyor‘s
momentary contact "T_Bay-LB" (I 8.4) by resetting the actual quantity
(MW 20). Also, when the system is switched off, the ACT Quantity (MW 20)
is reset to "0".
What to Do 1. Program the new block "FC_Count_Add" (FC 19) with the new counter and
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.
MOVE
Condition
for resetting EN OUT MW 20
0 IN ENO
MW 20 IN1 OUT MW 20
1 IN2 ENO
Convert ACT quantity (MW 20) from Integer to BCD -> Result on BCD digital display (QW 6)
Convert value from thumbwheel button (IW 2) from BCD to Integer -> Store SETP quantity (Integer) in MW 22
Compare ACT (MW 20) to SETP (MW 22) -> Place comparison result on indicator light
Counting via Counting the transported parts using a memory word for each addition has,
Addition among others, the following benefits vis-à-vis counting using S5 counters:
When using an S5 counter, it is only possible to count from 0 to 999. However,
when you count using Integer addition you can count from -32768 to + 32767.
Partial Functions The complete function of the FC 19 can be broken down into the following
of the FC 19 partial functions as shown in the slide:
• NW 1: Set "Counter" to 0
means overwriting the contents of memory word MW 20, that is used as the
counter, with 0.
• NW 2: Counting via memory word
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 occurrence of the count event must be detected by edge
detection.
• NW 3: Display ACT quantity on the BCD digital display
Since the ACT quantity recorded by addition in memory word MW 20 is
stored as an Integer, a format conversion from Integer to BCD must take
place before the transfer to the BCD digital display.
• 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 setpoint quantity, the indicator
light Q 8.4 must be turned on.
Note The following pages contain either further information or are for reference to
complete a topic.
For more indepth study we offer advanced courses and self-learning mediums.
Conv
Fault
M 17.0
3
Conv
2
Fault
Counter C 17 1
0
M/A AUTO
Q 4.3
Function Up Till Now The transport functions in AUTO mode are monitored. If the transport function
takes longer than the 6 second monitoring time (if a part does not pass through
the light barrier within 6 seconds of its start time), then there is a conveyor belt
fault condition in the system and the conveyor motor is automatically switched
off (logic in FC 16).
Task: The conveyor belt fault conditions in AUTO mode are to be counted. After 3
conveyor belt fault conditions have occurred, the AUTO mode is to be switched
off for safety reasons. To start a new transport function, the fault condition must
be acknowledged (as already programmed) and the AUTO mode must be
switched on once more.
What to Do: 1. In FC 17, in a new network, program the counting of the conveyor belt fault
conditions using the S5 counter C 17 as the count down counter.
- When the "Auto" mode is switched on, the counter is set to 3 (number of
conveyor belt fault conditions until the AUTO mode is switched off)
- The counter counts down 1 every time a conveyor belt fault condition
occurs (M 17.0 = "1").
2. In FC 15 (operator mode section), program the switching off (reset) of the
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.
Jog RIGHT
I 0.2
Conv motor
RIGHT
(Q8.5)
Lock-out
RIGHT
T 15 (SF)
Jog LEFT
I 0.3
lock-out
time RIGHT
Conv motor
LEFT
(Q8.6)
Lock-out
LEFT
T 16 (SF)
The Function JoggingIn MANUAL mode (Q8.2 / Q 4.2 = ´1´), you can jog the conveyor motor to the
in FC 16 Up Till Now: RIGHT and to the LEFT using the simulator momentary contacts I 0.2 and I 0.3.
Task: In order to avoid too great a load change, it should only be possible to jog the
conveyor motor in the opposite direction after it has been jogged to the RIGHT
or to the LEFT after a lock-out time of 2 seconds (see slide). If, for example, the
motor has been jogged to the RIGHT, then it can only be jogged back to the
LEFT after the lock-out time of 2 seconds has expired.
Solution Hint: By using a "branch", you can integrate the timers in the two networks Jog
Conveyor RIGHT and Jog Conveyor LEFT as follows:
Editing a branch:
1. Select the connection where Jog condition
the branch is to be place LEFT
T 16
2. click on in the Editor toolbar
(Branch) SF
S5T#2s TV
Network 1: C5
I 0.0 SC
I 0.0 C5
A I 0.0
SC L C#20
C#20 CV
C#20 S C5
Network 2:
C5
I 0.1 C5
I 0.1 CU A I 0.1
CU
CU C5
Network 3:
I 0.2 C5 C5
A I 0.2
CD I 0.2 CD CD C5
Network 4:
C5 Q 4.0 Q 4.0
A C5
C5 = = Q 4.0
Bit Instructions All counter functions can also operate with simple bit instructions. The
similarities and differences between this method and the counter functions
discussed so far are as follows:
• Similarities:
- Setting conditions at the "SC" input
- Specification of the counter value
- RLO change at the "CU" input
- RLO change at the "CD" input
• Differences:
- It is not possible to check the current counter value since
there are no Binary (CV) or BCD (CV_BCD) outputs.
- There is no binary output Q in the graphical representation.
T4 T4 A I 0.7
I 0.7 S_ODTS Q8.5 S_ODTS L S5T#35s
S Q I 0.7 S BI MW0 SS T4
S5T#35s BI MW0 A I 0.5
TV S5T#35s TV BCD QW12
I 0.5 Q8.5 R T4
R BCD QW12 I 0.5 R Q = L T4
T MW0
LC T4
T QW12
A T4
= Q8.5
RLO at S
RLO at R
Timer
operation
Example
Start The stored-on-delay timer starts when the RLO at the "S" input changes from
"0" to "1". The timer runs, starting with the time value specified at input "TV",
and continues to run even if the signal at input "S" changes back to "0" during
that time.
If the signal at the start input changes from "0" to "1" again while the timer is
still timing down, the timer starts again from the beginning.
Reset When the RLO at reset input "R" changes from "0" to "1", the current time value
and the time base are deleted and output "Q" is reset.
Binary Output The signal state at output "Q" changes to "1" when the timer has expired
without error, regardless of whether the signal state at input "S" is still "1".
T4 T4 A I 0.7
I 0.7 S_PULSE Q8.5 S_PULSE L S5T#35s
S Q I 0.7 S BI MW0 SP T4
S5T#35s BI A I 0.5
TV MW0 S5T#35s TV BCD QW12
I 0.5 Q8.5 R T4
R BCD QW12 I 0.5 R = L T4
Q
T MW0
LC T4
T QW12
A T4
= Q8.5
RLO at S
RLO at R
Timer
operation
Example
Start The pulse timer starts when the RLO at the "S" input changes from "0" to "1".
Output "Q" is also set to "1".
T4 T4 A I 0.7
I 0.7 S_PEXT Q8.5 S_PEXT L S5T#35s
S Q MW0 SE T4
I 0.7 S BI
S5T#35s TV BI MW0 A I 0.5
S5T#35s TV BCD QW12
I 0.5 Q8.5 R T4
R BCD QW12 I 0.5 R L T4
Q =
T MW0
LC T4
T QW12
A T4
= Q8.5
RLO at S
RLO at R
Timer
operation
Example
Start The extended pulse timer starts when the RLO at the "S" input changes from
"0" to "1". Output "Q" is also set to "1".
The signal state at output "Q" remains at "1" even if the signal at the "S" input
changes back to "0".
If the signal at the start input changes from "0" to "1" again while the timer is
running, the timer is restarted.
T4 T4 A I 0.7
I 0.7 S_OFFDT Q8.5 S_OFFDT L S5T#35s
S Q I 0.7 S BI MW0 SF T4
S5T#35s BI MW0 A I 0.5
TV S5T#35s TV BCD QW12
I 0.5 Q8.5 R T4
R BCD QW12 I 0.5 R Q = L T4
T MW0
LC T4
T QW12
A T4
= Q8.5
RLO at S
RLO at R
Timer
operation
Example
Start The off-delay timer starts when the RLO at the "S" input changes from "1" to
"0". When the timer has expired, the signal state at output "Q" changes to "0".
If the signal state at the "S" input changes from "0" to "1" while the timer is
running, the timer stops. The next time the signal state at the "S" input changes
from "1" to "0", it starts again from the beginning.
Reset When the RLO at reset input "R" is "1", the current time value and the time
base are deleted and output "Q" is reset.
If both inputs (S and R) have signal states of "1", output "Q" is not set until the
dominant reset is deactivated.
Binary Output Output "Q" is activated when the RLO at the "S" input changes from "0" to "1". If
input "S" is deactivated, output "Q" continues to have signal state of "1" until the
programmed time has expired.
01 3 5 2
29 28 27 26 25 24 23 22 21 20
Accu 1 contents after “L T...” exec. X X X X X X 0 1 0 1 1 0 0 0 0 0
01 3 5 2
Time Specification Time values can be fixed and are specified as time constants. The permissible
range in which the time values are found ranges from S5T#10ms to
S5T#2h46m30s0ms.
Variable times can be specified using variables (such as memory words or data
words) containing the S5TIME data type. The user must make sure that the
appropriate time base and the number of units of time, as shown in the slide,
are stored in the variable in his program.
Time Base The time base defines the interval at which the number of units of time is to be
decremented by one unit when the timer runs. Bits 12 and 13 of the variable
must contain the time base as a binary-coded number:
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 time value. The range from 1 to 999 is possible. When there is a time
specification using a constant (S5T#...), the system automatically uses the
smallest possible time base and the number of units of time.
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.
Network 1:
T4
I 0.0 T4 I 0.0 & SD A I 0.0
SD L S5T#5s
S5T#5s TV SD T4
S5T#5s
Network 2:
T4 Q 8.0 Q 8.0
A T4
T4 & =
= Q 8.0
Network 3:
T4
I 0.1 T4 A I 0.1
R I 0.1 & R R T4
Bit Instructions All timer functions can also be started with simple bit instructions. The
similarities and differences between this method and the timer functions
discussed so far are as follows:
• Similarities:
- Start conditions at the "S" input
- Specification of the time value
- Reset conditions at the "R" input
- Signal response at output "Q"
• Differences for LAD and FBD:
- It is not possible to check the current time value (there are no "BI" and
"BCD" outputs).
F STL
I_DI
B MD14
EN OUT
D DI_R
ENO EN OUT MD26
MW12 IN L MW12
LAD ENO ITD
MD14 IN
DTR
T MD26
I_DI DI_R
EN ENO EN ENO
Application Basically, arithmetic operations can only process values of the same data type.
Therefore, there are operations with which integer values (I or DI) can be
converted into real values (R) and vice versa.
I_DI (in STL: ITD) converts a 16-bit integer (I) into a 32-bit double integer (DI)
DI_R (in STL: DTR) converts a 32-bit double integer (DI) into a floating-point number (R)
Other Conversion
Operations are discussed in one of the advanced programming courses:
- INV_I (INVI) Inverts an integer (I)
(formation of the ones complement)
- NEG_I (NEGI) Negates (sign reversal) an integer (I)
(formation of the twos complement)
- TRUNC (TRUNC) Conversion R Æ DI: cut off after decimal positions
- ROUND (RND) Conversion R Æ DI: round
- CEIL (RND+) Conversion R Æ DI: general rounding up
- FLOOR (RND-) Conversion R Æ DI: general rounding down
- INV_DI (INVD) Inverts a double integer (DI)
(formation of the ones complement)
- 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)
WXOR_W L IW 0
WOR_W
L W#16#5F2A
WAND_W
AW / OW / XOW
EN ENO
T MW10
IW0 IN1
OUT MW10 15 0
W#16#5F2A IN2
IW0 = 0 1 0 0 0 0 0 0 0 0 1 1 0 0 1 0
W#16#5F2A = 0 1 0 1 1 1 1 1 0 0 1 0 1 0 1 0
AND OR XOR
WAND_W The "AND Word" operation gates the two digital values at inputs IN1 and IN2
bit by bit in accordance with the AND truth table. The result of the AND
operation is stored at the address at output OUT.
The instruction is executed when EN = 1.
Example: Masking out the 4th decade of the thumbwheel buttons :
IW4= = 0100 0100 1100 0100
W#16#0FFF = 0000 1111 1111 1111
MW30 = 0000 0100 1100 0100
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 the address at output OUT.
The instruction is executed when EN = 1.
Example: Setting bit 0 in MW32 :
MW32 = 0100 0010 0110 1010
W#16#0001 = 0000 0000 0000 0001
MW32 = 0100 0010 0110 1011
WXOR_W The "Exclusive OR Word" operation gates the two digital values at inputs IN1
and IN2 bit by bit in accordance with the XOR truth table. The result of the OR
operation 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
General The program example displayed in the slide implements a logic for detecting a
signal change of 16 binary digits (edge detection for 16 bit) using digital word
instructions.
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 pattern (MW 220) with the new signal states (IW 0).
Network 2 If only the 1 Æ changes are to be detected, a digital AND operation of the
change pattern with the old signal states is to be carried out.
Network 3 Save the old states so that the signal state change can be detected.