CL550 Software Manual
CL550 Software Manual
6. Addressing Conventions
A, B, C, D Standard arithmetical X, B, W, D, R, L
registers
I I[R] Input Image/ in I/O state
X, B, W, D, R, L
Q Q[R] Output Image/ in I/O state
X, B, W, D, R, L
M M[R] Marker X, B, W, D, R, L
SM SM[R] Special marker X, B, W, D, R, L
T T[R] Timer X (status), W (value)
C C[R] Counter X (status), W (value)
D D[R] Data word, 1st current DM X, B, W, D, R, L
DX DX[R] Data word, 1nd current DM
DB DB[R] Data buffer X, B, W, D, R, L
DF DF[R] Data field X, B, W, D, R, L
S S[R] System data range X, B, W, D, R, L
P P[R] Parameter X, B, W, D
FI FIFO max. 512 bytes
TI Time-controlled interrupt
b#www Constant X, B, W, D, R, L
DM DM[R] Data module CM DMnn ; calls 1st DM
BX DMnn ; calls 2nd DM
PM PM[R] Program module
In the above enumeration, R is replaced by X = bit, B = byte, W = word,
the register IDs A, B, C or D. D = double word, R = REAL, L = LREAL
Module list
The PCL manages the following modules:
The unused addresses are reserved for internal system functions, and
may not be changed.
Segments of the system area are used by default function modules which
make data available that is also used by other PLC program parts.
Example: Date and time.
The unassigned addresses in the system area are reserved for internal
purposes, and may not be modified.
S120
S122 Field bus type 1: PROFIBUS-DP, 2: CAN, 3: INTERBUS S
S124 I-size I/O information
S126 O-size
S128 Hardware / software version
S510
Bit Explanation
0 BMF Bus master fault
1 KSD Classified slave diagnostics
2 SD Slave diagnostics / System diagnostics
3 Reserved
4 Init Init phase: Waiting until periphery is operation-ready, or until
PLC STOP time has elapsed.
5 BmClab Bus master has switched DP bus to CLEAR status: BmClab
= [SNE - SKF - SNB] & Error_Action_Flag = 1. The timing
for the restart after the remedy of BmClab causes can be
controlled by the PLC program.
6 PgStop Programming Unit keeps DP bus in STOP state.
7 Aktiv Active ID
8 SNE One or more slaves are not reachable on the bus.
9 SKF One or more slaves report configuration errors.
10 DPS One or more slaves report static diagnostics.
11 EXD One or more slaves report extended diagnostics.
12 SNB One or more slaves not ready for cyclical data exchange.
13 SF One or more slaves report error of another type.
14 reserved
15 reserved
The bits Init, BmClab, and PgStop are not relevant to the PLC program
because, in the RUN state of the PCL, they always have the value 0..
The individual error types for the KSD are indicated in bits 8 though 13 of
the DP status word.
The KSD messages for each slave are saved in the status words range
from S256 to S351.
The SD bit in the DP status word represents the OR link of all system
diagnostics bits. Therefore, when SD = HIGH, at least one slave reports
diagnostics.
Active ID
This bit must always have a value of 1. If this is not the case, this
indicates a fatal error in the bus master software.
Bit
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
31 2523 1615 87 3 0
Byte = B
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
31 25 23 16 15 8 7 0
This addressing mode differentiates between load and transfer
instructions:
Load instruction
The source operand may be either the even-numbered (LOW) byte or the
odd-numbered (HIGH) byte. In the case of the destination operand
(register), the LOW byte is always addressed.
Examples
L B M1,A
M0
HIGH byte LOW byte
Register A
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
L B M2,A
M2
HIGH byte LOW byte
Register A
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
Transfer instruction
For the source operand, the LOW byte is addressed. The destination
operand (DEST_OPD) may be both the even-numbered (LOW) byte and
the odd-numbered (HIGH) byte.
Examples
T B A,M1
Register A
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
M0
HIGH byte LOW byte
T B A,M2
Register A
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
M2
HIGH byte LOW byte
Word = W
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
31 25 23 16 15 8 7 0
Without exception, for the Load instruction, the specified byte and its
subsequent byte are loaded into the LOW word of the Register (32-bit);
the HIGH word of the Register remains unchanged.
Without exception, for the Transfer instruction, the specified byte and its
subsequent byte are loaded into the LOW word of the Register (32-bit).
M2
HIGH byte LOW byte
Register A
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
Double word = D
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
31 25 23 16 15 8 7 0
For double word processing when loading or transferring, the base byte
address, which must be divisible by 4, is always specified.
Loading always requires the base byte and the following 3 bytes to be
loaded into the specified Register (32-bit).
Transferring always requires the base byte and the following 3 bytes from
the specified Register (32-bit) to be written to.
Examples
L D M4,A
M6 M4
HIGH byte LOW byte HIGH byte LOW byte
Register A
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
T D A,M4
Register A
HIGH word LOW word
HIGH byte LOW byte HIGH byte LOW byte
M6 M4
HIGH byte LOW byte HIGH byte LOW byte
Register A, B, C, D
31 24 23 16 15 8 7 0
HIGH byte LOW byte HIGH byte LOW byte
HIGH word LOW word
For operations that exceed the 32-bit format, the registers are combined
to form permanent register pairs.
Register pair A + B
31 24 23 16 15 8 7 0
Word 4 = HIGH word B Word 3 = LOW word B
Word 2 = HIGH word A Word 1 = LOW word A
Register pair C + D
31 24 23 16 15 8 7 0
Word 4 = HIGH word D Word 3 = LOW word D
Word 2 = HIGH word C Word 1 = LOW word C
Status bits
N O C Z
Zero
Carry
Overflow
Negative
Reading
Byte / Word / I, O, M, T, C and P for T/C, actual values apply
Double word / REAL / LREAL K, DF, DB, D, DX, SM, S
Writing
Byte / Word / A, M, P P writing, depending on assigned operand
Double word / REAL / LREAL DF, DB, D, DX, S
Register A
Register C
Register D
Example
Register A
Register B
Register C
Register D
Example
Register B
Register C
Register D Peripherals
Example
A P3 ;I7.3
A P4 ;Status of T2
A P5 ;Status of C13
= P6 ;O10.0
Direct addressing
In direct addressing, addressing limits are determined by the operand
attribute.
Operand B W D R L
M0 x x x x x
M1 x
M2 x x
M3 x
M4 x x x x
M5 x
M6 x x
M7 x
M8 x x x x x
Indirect addressing
Indirect addressing is subject to the same addressing limits as direct
addressing.
Example:
Parameterized addressing
Parameterized addressing is subject to the same addressing limits as
direct addressing.
Example:
7. Instruction List
Examples
U I0.0
U W -Name ,A
L B O0 ,B
T D C , M12
MUL W 1234 ,D
7.2 Flags
The flags are influenced by the following instruction groups:
Starting the nonremanent starting timers SP, SPE, SR and SRE requires
a positive transition of the timer start condition. However, they are started
also if the start condition, at the time of first addressing (1st PLC cycle)
equals 1.
In the case of remanent timers, the flank marker is retained, i.e., whether
a 1 will start the timer at the time of first addressing (1st PLC cycle) after
startup or restart, depends on the start condition prior to STOP or Power-
OFF.
In the case of the start time as falling delay, a 0 will not start the timer
during the initial processing. Predefining the timer start condition with 1 is
possible as early as in the startup OM, provided that the information
about remanence characteristic (see Section on Remanence
Characteristics) is considered.
The timers are decremented in the I/O state. A timeout is thus recognized
only in the I/O state, and not during the program cycle!
The timer starts immediately upon a positive transition of the timer start
condition.
Example:
Start condition
Reset condition
Start condition
Reset condition
Start condition
Reset condition
Start condition
Reset condition
Timer status + t ( + t (
Start condition
Reset condition
In advance of the reset, the required counter content is loaded into the
register being used.
The counter status for logical links depends on the counter content. For
counter contents > 0, the status is = 1 (HIGH); counter content = 0 will
have status = 0 (LOW).
Also, for reasons of compatibility, the purely logical CPL instruction was
implemented; it is used to map binary result queries also in special
markers.
The logical compare operation regards the bytes, words, or double words
to be compared as unsigned integers, i.e., as "unsigned 8", "unsigned
16", or "unsigned 32".
Examples:
# The special markers that are influenced only by the CPL instruction
will remain unaffected until the next CPL instruction.
In the event that the status of inputs is to be loaded directly from the dual-
port RAM of the bus master during the program cycle, this status must be
loaded into the image with the use of the load instruction LD before the
load instruction L is issued.
LD E[A],[B] Load I statuses into image (start address in A), byte* count in
B.
In the event that the statuses of outputs are to be sent directly to the
dual-port RAM of the bus master during the program cycle, the TD
transfer instruction will be used.
By way of illustration, a 4-bit number (nibble) is used here; the nibble data
format ("tetrade") is not supported by the controller.
0 1 1 0 positive number 6
1 0 0 1 Negation, one's complement
+ 1
1 0 1 0 Two's complement = negative number 6
1111 0000
-1 0
1110 0001
-2 +1
1101 0010
-3 +2
1100 0011
-4 +3
1011 negativ positive 0100
-5 e +4
1010 0101
-6 +5
1001 0110
-7 +6
1000 0111
-8 +7
Logical SHIFT
MSB LSB CY
SLR B,n
o( o " ( " ,( o
MSB LSB CY
SLL B,n
" + " o +0 o
0 *
,(
Arithmetical SHIFT
All bits being vacated are filled up with the contents of the MSB.
MSB LSB CY
SAR B,n
" ( " ( " ,( o
In the case of shift operations exceeding one space (n > 0), the overflow
bit is set HIGH after a "1" was shifted through CY.
Rotate RIGHT
MSB LSB CY
ROL B,n
" + " 1 o
0 ( * ,( *
Rotate RIGHT THROUGH CARRY
MSB LSB CY
RCR B,n
1 " ( " ( 1
* +--- 0
Rotate LEFT THROUGH CARRY
MSB LSB CY
RCL B,n
" + " 1 + 1
0 ( *
In the case of a rotation by more than one space, the following applies:
" The overflow bit goes HIGH when a 1 has been rotated through CY.
" The negative bit goes HIGH when the MSB contains a 1.
MSB: Bit 7 when OPA = B
MSB: Bit 15 when OPA = W
MSB: Bit 31 when OPA = D
ADC OPA C, A sg A
+
sg C
+
CY
=
sg A
HIGH DW
ADC D C, A sg A
+
sg C
+
Cy
=
sg A
SBB OPA C , A sg A
-
sg C
-
CY
=
sg A
HIGH DW
SBB W C, A sg A
-
sg C
-
CY
=
sg A
Double-word multiplication
31 0
MUL D B, A ; SRC-D sg B
x
; DEST-D sg A
=
; DEST-D A
and
; DEST-D sg B
+1
In division, the dividend always occupies the double width of the divisor.
Double-word division
63 32
DIV W C, A ; DEST-D sg B
+1
31 0
; DEST-D A
31 : 0
; SRC-D sg C
=
; DEST-D sg A: Quotient
; DEST-D B: Rest
+1
Two data formats, REAL and LREAL, are defined in accordance with
IEC1131.
When calculating with the REAL data format, inaccuracies in the decimal
range will occur sooner than with the LREAL format. If a high degree of
accuracy is required, the LREAL format should be used. The appropriate
conversion routines are available in WinSPS v2.4 with WinPanel, v1.5
and higher.
Operands
Depending on the instruction, the following may be used as floating-point
operands:
" M, S, DM, DF, D, DX
with both direct and indirect addressing.
The specified operand address must be divisible as follows: - by 4 for
REAL data format REAL
- by 8 for LREAL data format.
" K, register
" P
A PM parameter may not be used as a floating-point constant. In the
event that this is required, the constant may first be loaded into a
marker word, for example.
Instructions
The floating-point data formats and operands may be used in the
following instruction types:
" LOAD floating point value
" TRANSFER floating point value
" CONVERT
" COMPARE floating point values
" Basic arithmetic functions
" Forming absolute value
" Extracting square root
" Logarithmic functions
" Trigonometric functions
Examples:
For large numbers at high resolution the LREAL data format must be
used.
The instructions handling the four basic arithmetic functions offset the
contents of the destination register or register pair against the contents of
the SRC operand. The results are always written to the destination
register or register pair.
7.19.10 Exponentiation
Y
For exponentiation X , the following procedure is used:
" In REAL format, registers A and C are used, with register A holding
the base, and C the exponent. The result is written to register A.
" In LREAL format, register pairs AB and CD are used, with AB holding
the base, and CD the exponent. The result is written to register pair
AB.
Realisiert sind:
" Natural logarithm
" Base-10 logarithm
" Forming exponential function from base-10 (common) logarithm
Realized are:
" Sinus, with entry in radian measure
" Cosine, with entry in radian measure
" Tangent, with entry in radian measure
" Arc sine, main value
" Ant cosine, main value
" Arc tangent, main value
7.21 Local Symbol Names & Auxiliary Markers for Program Tracking
Example:
PLC program
JP End
PLC program
JP End
:
:
:
:
:
Zieln: ;Program part n
PLC program
JP End
:
:
End
PLC successor program
:
Two data modules may be kept enabled at the same time. For this
purpose the following module calls are available:
CM, BAB, BAI DMx: enables DMx as 1st DM
BX, BXB, BXI DMy: enables DMy as 2nd DM
Exception: In the event that register contents are written to or read from
FIFO buffers, the number of bytes will be defined via the operand
attribute W/BY. Accordingly, operand attribute BY = one byte; operand
attribute W = two bytes.
The FIFO buffer is flushed with the RFI (Reset FIFO) instruction.
Block transfer
Block transfers are accomplished by shifting data block of defined size, whereby
the data block may not overlap. Block transfers use only ascending addresses
(incremental).
Example 1
CM DM10 ; 1st DM
BX DM9 ; 2nd DM
L D 50,C ; Block size = 50
BLT W D20,DX40 ; Copy 50 words, from DM9/D20 up, to DM10/D40.
Example 2
L D 50,A ; DEST address offset
L D 50,B ; SRC address offset
L D 50,C ; Block size = 50
BLT D DF[B],M[A] ; Copy 50 double words, from DF50 up, to M50.
Block COMPARE
The function compares two data blocks.
When the compare condition is met, processing is stopped, and the
number of uncompared bytes/words written to register C. When using
prefix addressing, the operand addresses too are output to registers a
and B.
The zero flag goes HIGH when the compare conditions were not met
throughout the entire range.
OPP Explanation
Compare Forward operation for the following:
CFZ Equal
CFN Unequal
CFAG Arithmetical greater
CFM Arithmetical less
CFLG Logical greater
CFCY Logical less
CFCN Logical greater or equal
CFCZ Logical less or equal
Compare Backward operation for the following:
CBZ Equal
CBN Unequal
CBAG Arithmetical greater
CBM Arithmetical less
CBLG Logical greater
CBCY Logical less
CBCN Logical greater or equal
CBCZ Logical less or equal
DEST block address direct or in register A, SRC block address direct or
in register B, block size always in register C.
Example 1
CM DM10 ; 1st DM
L D 50,C ; Block size = 50
CFLG W D20,M20 ; Compare forward 50 words f. Logical Greater,
; starting at DM10/D20 with marker from M20 up.
Example 2:
L D 50,A ; DEST address offset
L D 50,B ; SRC address offset
L D 50,C ; Block size = 50
CBZ D DF[B],M[A] ; Compare backward 50 double words for Equal,
; starting at DF50 with marker from M50 up.
Block search
The function searches for a character within a data block.
When the character is found, the number of bytes/words that were not
searched is stored in register C. With the use of prefix addressing,
register A will also contain the operand address.
If the character was not found (search condition not met) throughout the
entire range, the zero flag goes HIGH.
OPP Explanation
Search Forward for character:
SFZ Equal
SFN Unequal
SFAG Arithmetical greater
SFM Arithmetical less
SFLG Logical greater
SFCY Logical less
SFCN Logical greater or equal
SFCZ Logical less or equal
Search Backward for character:
SBZ Equal
SBN Unequal
SBAG Arithmetical greater
SBM Arithmetical less
SBLG Logical greater
SBCY Logical less
SBCN Logical greater or equal
SBCZ Logical less or equal
Block start address direct or in register A, search values as constants or
in register B; block size always in register C.
Example 1
L D 50,C ; Block size = 50
SFLG B 35,M20 ; Search forward 50 bytes, starting at M20,
; for the value 35.
Example 2
CM DM10
L D 10,C ; Block size = 10
L D 50,B ; Search value
L D 20,A ; DEST address offset
SRZ D B,M[A] ; Search backward 10 bytes , starting at M20,
; for the value 50.
In the case of markers and the data field, specific areas of the defined
remanence area (Offset, Number in table below) can be specified for the
backup / loading procedures.
8. Processing Times
" WinPanel startup with fixed default cycle time. The PLC cycle time can
be preset to a fixed value. This is accomplished by means of one of
the WinPanel startup parameters, i.e., WinPanel/Zn, where n is the
value in ms. In this context, care must be taken that the actual PLC
processing time is smaller than the selected value because otherwise
the preselected cycle time will be exceeded. See Example 5.
" I/O image transfer time to bus master. The image transfer time to the
bus master handling the decentralized peripherals is approx. 1 ms.
This time value is integrated in the PLC processing time in the
following sample diagrams.
# Default setting:
System clock = 1 ms, share in Windows calc-time = 50 %. In normal
circumstances these values do not require user modification. Only
in the event that a specific application necessitates another setting
– because significantly more calc-time is required for Windows
applications – should these values be changed.
When using an integration of the MMI-MADAP and the PCL in the
same device, the following settings have produced good results:
System speed = 5 ms, Windows calc-time ratio = 50 %.
Die SPS-Zykluszeit ist als die Zeit definiert die von einem
Programmanfang bis zum nächsten vergeht.
System clock
OM1 ... ... I/O image Windows calc-time OM1 ...
PE
3 3 PLC
4 Windows
+ <75 % ( 3 3
3 3
Next PLC Next PLC
cycle cycle
A more critical controller behavior occurs when the PLC processing time
exceeds this 75% limit. In this case, all settings must be optimized.
Example 1
Preconditions:
" System clock = 2 ms
" System clock / Windows clock ratio = 3/1
" PLC processing time = 1.2 ms
+ 2 ms (
1 2 3 4 5 6 System clock
3 3 PLC
4 Windows
3 3 3 3 3
3 3 3 3 3
Next PLC Next PLC Next PLC Next PLC Next PLC
cycle cycle cycle cycle cycle
The PLC program finishes in time, and Windows is given sufficient time
for processing Windows applications.
Example 2
Preconditions:
" System clock = 2 ms
" System clock / Windows clock ratio = 3/1
" PLC processing time = 1.6 ms
+ 2 ms (
1 2 3 4 5 6 System clock
3 3 PLC
4 Windows
<25% 3 3
for 3 3
Windo Next PLC Next PLC
ws cycle cycle
The length of the PLC processing time exceeds 75% of the system clock
rate.
In this case, a stipulation takes effect stating that >25% of the system
clock rate must be provided for Windows applications. Because this is not
the case, there remains insufficient time for processing Windows
programs, and an additional pulse for Windows is inserted. In this
example, the system clock / Windows clock ratio of 1/3 has no effect.
Example 3
Preconditions:
" System clock = 2 ms
" System clock / Windows clock ratio = 3/1
" PLC processing time = 2.2 ms
+ 2 ms (
1 2 3 4 5 6 System clock
3 3 PLC
4 Windows
2 ms PLC 0.2 ms leftover 3
processing time PLC processing 3
time Next PLC cycle
+ 25 % PLC ( + 75 % Windows (
The PLC program takes longer than the selected system clock speed.
Upon conclusion of the first system cycle, Windows receives 3 cycles for
processing. The remainder of the PLC program is processed during the
5th system cycle. The next PLC cycle will start only in the 6th system
cycle. In this example, the system clock / Windows clock ratio of 3/1
takes effect.
Example 4
Preconditions:
" System clock = 2 ms
" System clock / Windows clock ratio = 3/1
" PLC processing time = 5.6 ms
+ 2 ms (
1 2 3 4 5 6 System clock
3 3 PLC
4 Windows
5.6 ms PLC processing time 3
3
Next PLC cycle
+ 75 % PLC ( + 25 % Windows (
The PLC program takes longer than the selected system clock speed.
Upon conclusion of the first system cycle, Windows receives 1 cycle for
processing. The next PLC cycle will start only in the 5th system cycle. In
this example, the system clock / Windows clock ratio of 3/1 takes effect.
Example 5
Preconditions:
" System clock = 2 ms
" System clock / Windows clock ratio = 1/1
" Fixed predefined PLC cycle time = 20 ms, WinPanel start parameter
/Z20
" Actual PLC processing time = 3.0 ms
+ 2 ms (
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 System clock
3 3 PLC
4 Windows
2 ms PLC 1 ms Windows, until predefined time has elapsed. 3
processing leftover 3
time PLC Next PLC
processi cycle
ng time
The PLC program takes longer than the selected system clock speed.
Upon conclusion of the first system cycle, Windows receives 1 system
cycle for processing. The remainder of the PLC program is processed
during the 3rd system cycle. At the end of this interval, Windows is able
to use the CPU performance until the 20 ms have elapsed. In this
example, the system clock / Windows clock ratio of 1/1 takes effect.
9. Sample Programs
nicht_fertig:
; Check DMs and write results
U DM[A] ; Check DM, indirect module attendance check
= D[B] ; If applicable, set attendance bit HIGH, ind. bit addressing.
PUSH D A ; Save DM no.
L D DM[A] ; Load DM size, indirect module length verification.
T W A,D[C] ; Write to size word, indirect double word addressing
POP D A ; Write back DM no.
; Increment address
INC D A,1 ; next DM
INC D B0.1 ; next DM attendance bit
INC D C0.2 ; next DM size word
; All 16 predefined DMs processed?
CPLA D 16,A
JPCZ nicht_fertig; Jump on less than or equal
EM
; 2. Range/area monitoring
;------------------------
Bereich_niO:
(range NOK) ; Delete markers M0-M1 and counter C0 via trigger pulse
U -RI_Anl
JPCI kein_RI
L D 0,A ; Write value 0
T W A,M0 ; ... to markers M0-M1
SC A,Z0 ; ... and T0
T D A,M4 ; ... on markers M4-M7
kein_RI:
EM
;Delete FIFO:
A -RFI ; Delete locked?
JPCI noreset
A B -log1
R B -RFI ; Lock delete sequence to prevent repeat execution of same.
noreset: