0% found this document useful (0 votes)
105 views78 pages

Pmc20-E 06

Uploaded by

Juan Fresneda
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)
105 views78 pages

Pmc20-E 06

Uploaded by

Juan Fresneda
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/ 78

Programming technique Contents

Programming technique
Contents
Introduction............................................................ 3
Programming technique ......................................... 4
Operations.......................................................... 5
Operands ............................................................ 9
Operating mode of the controller....................... 10
Logic operations .................................................... 12
Operation L, LN................................................. 12
Operation A, AN................................................ 12
Operation O, ON................................................ 12
Operation =, =N ................................................. 13
Operation AB..................................................... 14
Operation OB..................................................... 14
Word operations..................................................... 21
Read and write operations.................................. 21
Word logic operations............................................ 27
Uses.................................................................... 28
Counters ................................................................. 29
Operations.......................................................... 29
Comparison operations .......................................... 31
Arithmetic .............................................................. 33
Digital timers ......................................................... 37
Operations.......................................................... 37
Shift operations (bit/digit)...................................... 41
Bit shift operations............................................. 41
Digit shift operations ......................................... 43
Shift digit to the left ........................................... 44
Digit shift to the right......................................... 45
Rotate digit to the left ........................................ 46
Rotate digit to the right ...................................... 47

11.08.93, 396.0432 System manual, page 6.1


Contents Programming technique

Block operations (Shift/Copy) ............................... 48


Block shift operations ........................................ 48
BSU (Block-shift-up)......................................... 48
BSD (Block-shift-down).................................... 51
BR (Block Reset)............................................... 51
Copy of a data block .......................................... 52
Sequential routines (Step counters) ....................... 54
Features about the step counters ........................ 54
Operations with sequential
routines (Step counters) ..................................... 55
Operations with access to the step counter
content (status)................................................... 56
Incrementing and decrementing step counters... 57
Code-conversion operations .................................. 62
Table-Look-Up operation ...................................... 64
Organisation of the table.................................... 64
Use of the Look-Up-table .................................. 64
Displaying the table ........................................... 66
Deleting the table............................................... 66
Indirect addressing............................................. 68
Instruction FIR D 03.14..................................... 68
Instruction FID D 03.14..................................... 68
Instruction SIR D 03.14..................................... 69
Instruction SID D 03.14..................................... 69
Data output............................................................. 70
Data output via the RS 232 interface ................. 70
Operation SOH; Serial out hex .......................... 71
Operation SOD; Serial out digit ........................ 72
Jump operations ..................................................... 73
Jump, conditioned by a certain being fulfilled .. 73
Unconditional jump ........................................... 74
Jump to a sub-routine......................................... 76

System manual, page 6.2 11.08.93, 396.0432


Programming technique Introduction

Introduction
This section describes the SELECONTROL® programming technique. The program
examples show how the operations work. The data registers D 15.56 ... D 15.62 are
frequently used in the examples.
The contents of these registers are shown directly by controller systems which have an
integrated LC-display. In the case of a controller having no display, the current contents
of the registers can be displayed on a terminal at any time while in the RUN mode by
means of the command VIEW, e.g. V) D 15.56.
All the other data registers can also be used for programming purposes.
Information relating specifically to the Controller, such as the address ranges can be
found in Section "Programming".

11.08.93, 396.0432 System manual, page 6.3


Programming technique Programming technique

Programming technique
The program consists of a sequence of control instructions. The format of these control
instructions for the SELECONTROL® PMC is based on the recommendations of the
DIN 19239 Standard.
A control instruction is made up as follows:

Control instruction

O peration O perand

L in e N o . D ata type A ddress

0102 L I 01.07

M odule address
C onnection term ina l

The mnemonic abbreviations used for the operands have been based on expressions in
the English language.

The instruction set used for the SELECONTROL® PMC programming technique is
made up of 70 operations in total.
Thanks to this high performance instruction set, even complex automation tasks can be
easily, quickly and clearly programmed.

System manual, page 6.4 11.08.93, 396.0432


Programming technique Programming technique

Operations
Logical operations: reading
L Load
LN Load Not
A And
AN And Not
O Or
ON Or Not
XO Exclusive-Or
XON Exclusive-Or-Not
AB And-Block
OB Or-Block

Logic operations: writing


= Then
=N Then Not
S Set
R Reset

Triggering
TRG Trigger

Data transport
FTW Fetch Word
FTB Fetch Byte
FTD Fetch Digit
STW Store Word
STB Store Byte
STD Store Digit

11.08.93, 396.0432 System manual, page 6.5


Programming technique Programming technique

Comparison operations
LT Less than
LTE Less than or equal
EQ Equal
GT Greater than
GTE Greater than or equal

Arithmetic operations
ADD Add
SUB Subtract
MUL Multiply
DIV Divide
FTR Fetch Aux.-Reg.

Timing operations
TF Timer fast (0,1s)
TS Timer slow (1,0s)

Counting operations
CU Count Up
CD Count Down

Shift/Rotate operations
SFL Shift left 1 digit to the left
SFR Shift right1 digit to the right

RTR Rotate 1 digit to the right


RTL Rotate 1 digit to the left
RBR Rotate right 1 bit to the right
RBL Rotate 1 bit to the left

System manual, page 6.6 11.08.93, 396.0432


Programming technique Programming technique

Block operations
BSU Block shift-up
BSD Block shift-down
BR Block reset
MDD Copy D-Block to D-Block
MDR Copy D-Block to R-Block
MRD Copy R-Block to D-Block
MRR Copy R-Block to R-Block

Step counters
INC Increment Step counter content +1
DEC Decrement Step counter content -1

Jump instructions
JP Jump unconditionally
JCF Jump conditionally on false
JCT Jump conditionally on true
LB Jump destination label
JS Jump to sub-routine
RET Return from sub-routine

Indirect addressing
FIR Fetch indirect R-register Read indirect R-register
FID Fetch indirect D-register Read indirect D-register
SIR Store indirect R-register Write to indirect R-register
SID Store indirect D-register Write to indirect D-register

Code conversion
BID Binary into BCD
DEB BCD into Binary

Look-Up-Table
LKP Look-Up-Table Read table

11.08.93, 396.0432 System manual, page 6.7


Programming technique Programming technique

Data output
SOH serial out hex Output data in hex-code via the serial port
SOD serial out digit Output data in ASCII-code via the serial port

Programm organization
EP End of Program
NOP No Operation

BITBUS communication
TRM Transfers a message from a PMC D-register block to a transmit mailbox
RCV Reads a message received in the receive mailbox into a PMC D-register
block

System manual, page 6.8 11.08.93, 396.0432


Programming technique Programming technique

Operands
Each operand is made up of the data type and an address.

Data types
The data types are designated as follows:

Input I
Output O
Marker M
Special-Marker M
Stepcounter S
Data Register D
Constant K
Real Register R

Inputs, Outputs and Markers: are used for logic operations.


Special markers: are used for system information and error messages.
Step counters (routines): simplify the programming of routines.
Complex routines can be simply and safely programmed
in a structured manner using these step counters.
Data registers (D-registers): are used for the programming of counters, arithmetic
operations, word operations, etc.
Constants: are used, for example, for arithmetic and comparison
operations, as default values for counters and timers and
as destination information for jump commands.
Real registers (R-registers): Operations using the data type R enable real-time
accessing of the inputs and outputs to be achieved.

Address ranges
The address ranges of the data types are shown in Section "Programming".

11.08.93, 396.0432 System manual, page 6.9


Programming technique Programming technique

Operating mode of the controller


The SELECONTROL® PMC operates cyclically (scanner principle). During the I/O
phase at the beginning of each program cycle:
• the signal statuses at the inputs are read-in and stored in the input image buffer, and
• the data that have been accumulated in the output image buffers are fed to the
outputs.
The program is then run through sequentially; one instruction being executed after
another according to the instruction list.
The data for the outputs are built-up continuously in the output image buffers.

I/O phase
R ead-in inputs
Line N o. W rite to outputs

0000 1st. instructio n

0001 2nd. instructio n

0002 3rd. instruction


U ser pro gram

0003 4th. instru ction

X XX X E nd of program (E P )

The cycle time depends on the length of the program and the nature of the command
instructions.
The 1-bit logic operations called for in the user-program are carried out in the logic-unit
(LU). The result of a logic operation is always deposited in the result register (RR). All
logic operations refer to the RR.

System manual, page 6.10 11.08.93, 396.0432


Programming technique Programming technique

The multi-bit operations are carried out by the arithmetic logic unit (ALU). A "DRIVE"
is necessary in such cases i.e. the 1-bit result register must be set to 1 (RR=1).
The result of a multi-bit operation is always deposited in the multi-bit result register
(MRR). All multi-bit operations refer to the MRR.
The influence on the result registers (RR and MRR) by the individual operations is
shown in the tables in Section "Programming".

A B ,OB

ZS

D A TA B IT (1bit)
LU RR
D A TA B IT (1bit) 1 bit

D R IV E
M RR D A T A W O R D (16 bit)
ALU
D A T A W O R D (16 bit)
AUXMRR

4 D IG IT

C A RR Y B O RR O W (Special m arker M 40.09)

A R IT H M E T IC E R R O R FL A G
(S pec ia l m a rk er M 40.07 )

LU = Logic-Unit
ALU = Arithmetic-Logic-Unit (activated only if drive present, RR=1)
RR = Result-Register
ZS = Intermediate memory
MRR = Multibit-Result-Register
AUXMRR = Auxiliary-Multibit-Result-Register (for arithmetic operations)

11.08.93, 396.0432 System manual, page 6.11


Logic operations Programming technique

Logic operations
Operation L, LN
A network is always opened with the following operations:
Operation
L LOAD
LN LOAD NOT

The L (Load) operation corresponds to a closing contact. The content of RR is


transferred to ZS and the status of the operand is loaded into RR.
When the L (Load) operation is used with a data register D xx.xx as the operand,
RR = 1 if the content of D = 0000.
The LN (Load Not) negation corresponds to an opening contact. With this operation,
the operand is inverted before being loaded into RR.

Operation A, AN
The A (And) operation corresponds to the series connection of a closing contact. Using
this operation, the operand and the content of RR are subjected to an AND operation
and the result is deposited in RR.
When the A operation is used with a data register D xx.xx as the operand, RR = 1 if the
content of D = 0000.
The AN (And Not) negation corresponds to the series connection of an opening contact.

Operation O, ON
The O (Or) operation corresponds to the parallel connection of a closing contact. Using
this operation, the operand and the content of RR are subjected to an OR operation and
the result is deposited in RR.
When the O operation is used with a data register D xx.xx as the operand, RR = 1 if the
content of D = 0000.
The ON (Or Not) negation corresponds to the parallel connection of an opening contact.

System manual, page 6.12 11.08.93, 396.0432


Programming technique Logic operations

Operation =, =N
The = (Then) operation has the effect of assigning a logical conclusion to an operand
(e.g. an output). The result deposited in RR is transferred to the output.
The =N (Then Not) negation corresponds to the assignment of an inverse logical result.
(Output = 1 if RR = 0).
The assignment = is always dependent on the current result of the logic operation.

Note: An operand may only be assigned with = or =N once in a


program.

Program example:
Ladder diagram: Function block diagram:
I 00.00
I 00.01
I 00.00 I 00.01 I 00.02 I 00.02
≥1
I 00.03
I 00.03
&
I 00.04
I 00.04 &

O 01.00 O 01.00

Program:
Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 O I 00.01 Or input
0002 O I 00.02 Or input
0003 A I 00.03 And input
0004 A I 00.04 And input
0005 = O 01.00 Then output
0006 EP End of program

11.08.93, 396.0432 System manual, page 6.13


Logic operations Programming technique

Operation AB
The AB (And Block) operation serves to simplify programming by replacing the need
for brackets.
The operation AB links the contents of RR with that of ZS. The result of the operation
is deposited in RR.
AB operations are used without operands. (Implicit)

Operation OB
The OB (Or Block) function serves to simplify programming by replacing brackets.
The operation OB links the contents of RR with that of ZS. The result of the operation
is deposited in RR.
The OB operation is used without operands. (Implicit)

Example:
Ladder diagram: Instruction list LI (Program):

L I 00.00 If input
I 00.00 I 00.02 A I 00.01 And input
L I 00.02 If input
I 00.01 I 00.03 A I 00.03 And input
OB Or Block
O 01.00 = O 01.00 Then output
EP End of program

System manual, page 6.14 11.08.93, 396.0432


Programming technique Logic operations

R esult
1
I 0 0.00 L I 00 .00 RR
I 0 0.00

I 0 0.01
2
I 0 0.01 R R A I 0 0.0 1 RR

4
I 0 0.02 L I 00 .02 RR ZS
I 0 0.02

I 0 0.03 5
I 0 0.03 R R A I 0 0.0 3 RR

OB
6

RR

Key to the diagram:


1 The result supplied by I 0.0 is written into RR.
2 The content of RR is ANDed together with the result from I 0.1.
The new result is written into RR.
3 As a new LOAD command has to be executed, the content of RR is transferred to the
buffer register, ZS.
4 The result supplied by I 0.2 is written into RR.
5 The content of RR is ANDed together with I 0.3 and the result of the logic operation
is written into RR.
6 The operation OB now operates on the value in the buffer register, ZS, and that in the
result register, RR, and deposits the result in RR.

11.08.93, 396.0432 System manual, page 6.15


Logic operations Programming technique

Program example with AB:

Ladder diagram: Function block diagram:


I 00.00 I 00.01
I 00.02 I 00.03
I 00.00 I 00.02
≥1 ≥1
I 00.01 I 00.03
& AB
O 01.03
O 01.03

Programm
Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 O I 00.02 Or input
0002 L I 00.01 If input
0003 O I 00.03 Or input
0004 AB And Block (Implicit)
0005 = O 01.03 Then output
0006 EP End of program

System manual, page 6.16 11.08.93, 396.0432


Programming technique Logic operations

Program example with OB:

Ladder diagram: Function block diagram:


I 00.04 I 00.06
I 00.05 I 00.07
I 00.04 I 00.06
& &
I 00.05 I 00.07
≥1 OB
O 01.07
O 01.07

Programm
Line No. Operation Operand Remark
0000 L I 00.04 If input
0001 A I 00.05 And input
0002 L I 00.06 If input
0003 A I 00.07 And input
0004 OB Oder Block
0005 = O 01.07 Then output
0006 EP End of program

11.08.93, 396.0432 System manual, page 6.17


Logic operations Programming technique

Operation XO, XON


The operations XO (EXCLUSIVE-OR) or XON (EXCLUSIVE-OR-NOT) enable the
programs to be simplified.
The operation XO makes a logic comparison for inequality. (RR new = 1 if RR and the
operand were previously unequal).
The operation XON makes a logic comparison for equality.
(RR new = 1 if RR and the operand were previously equal).

Program example (bistable FLIP-FLOP)


An output is set when a pulse is applied to an input. The next pulse to the same input
resets the output again.

Function diagram:

Input signal

O utput sign al

Program
Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 TRG M 16.00 Trigger auxiliary marker
0002 XO O 01.05 Unequal output
0003 = O 01.05 Then output
0004 EP End of program

System manual, page 6.18 11.08.93, 396.0432


Programming technique Logic operations

Operation S, R
If the result of an operation is logic 1 (RR = 1), the operand (such as an output) is set to
logic 1 by the operation S (SET) or it is reset to logic 0 by the operation R (RESET).
The combination of the S and R operations corresponds to a flip-flop (latch).
In view of the sequential program execution, the dominant operation of the two (S or R)
is always that which occurred as the last in the program sequence.
In contrast to the = operation, the operand remains set after an S operation until the right
conditions occur for an R operation.

Program example
Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 S O 01.00 Set output O 01.00
0002 L I 00.01 If input I 00.01
0003 R O 01.00 Reset output O 01.00
0004 EP End of program

11.08.93, 396.0432 System manual, page 6.19


Logic operations Programming technique

Operation TRG
The operation TRG (TRIGGER) can be used to generate pulses. A pulse is generated
from the positive-going edge of the input signal.
The pulse is formed using an auxiliary marker (M xx.xx) or an output (O xx.xx).
The length of the pulse corresponds to one program cycle (not just to the EP).

Example (positive-going edge )

Input signal (I)

Auxiliary marker

Output (pulse)
tc tc: Cycle time

Line No. Operation Operand Remark


0000 L I 00.04 If input
0001 TRG M 16.01 Auxiliary marker
0002 = O 01.00 Then output (puls)
0003 EP End of program

Example (negative-going edge)


Input signal (I)

Auxiliary marker

Output (pulse)
tc: cycle time tc

Line No. Operation Operand Remark


0000 LN I 00.05 If not input
0001 TRG M 16.02 Auxiliary marker
0002 = O 01.00 Then output (puls)
0003 EP End of program

System manual, page 6.20 11.08.93, 396.0432


Programming technique Word operations

Word operations
Besides logic operations (bit-operations), the SELECONTROL® programming
technique also supports digit, byte and word operations.

Type of operation Processing width


Bit operations 1 bit
Digit operations 4 bits
Byte operations 8 bits
Word operations 16 bits

Read and write operations


Read operations
FTW FETCH WORD Read Word
FTB FETCH BYTE Read byte
FTD FETCH DIGIT Read digit

Write operations
STW STORE WORD Write Word
STB STORE BYTE Write byte
STD STORE DIGIT Write digit

Thanks to these operations, programming of arithmetic operations, analogue value


processing, communication, etc. is made into a very simple task. Input signal, too, such
as from BCD-switches can be read-in very simply.

11.08.93, 396.0432 System manual, page 6.21


Word operations Programming technique

The inputs, outputs and markers can be accessed bit, digit, byte, or word-wise, thus:

Inputs Data transfer


Outputs
Markers Bit Digit Byte Word

xx.00 xx.00 xx.00 xx.00 xx.00


xx.01 xx.01
xx.02 xx.02
xx.03 xx.03
xx.04 xx.04 xx.04
xx.05 xx.05
xx.06 xx.06
xx.07 xx.07
xx.08 xx.08 xx.08 xx.08
xx.09 xx.09
xx.10 xx.10
xx.11 xx.11
xx.12 xx.12 xx.12
xx.13 xx.13
xx.14 xx.14
xx.15 xx.15

System manual, page 6.22 11.08.93, 396.0432


Programming technique Word operations

Every individual bit is accessed in bit-operations. Bit-operations are used for logic
processing.

Examples:
Instruction Access
L I 00.01 Load (bit) I 00.01 (bit 1)
A M 17.09 And (bit) M 17.09 (bit 9)

1 digit (= 4 bits) is always accessed with digit-operations. The sub-divisions are fixed,
i.e. it is not possible to process the bits 02 ... 05 simultaneously with a digit-operation.

Examples:
Instruction Access
FTD I 03.04 Read digit I 03.04 (bit 04 ... 07)
STD O 01.12 Write digit O 01.12 (bit 12 ... 15)

1 byte (= 8 bits) is always accessed with byte-operations. The sub-divisions are fixed,
i.e. it is not possible to process the bits 04 ... 12 simultaneously with a byte-operation.

Examples:
Instructions Access
FTB I 00.08 Read byte I 00.08 (bit 08 ... 15)
STB O 01.00 Write byte O 01.00 (bit 00 ... 07)

1 word (= 16 bits) is always accessed with word-operations.

Examples:
Instruction Access
FTW O 01.00 Read Word O 01.00 (bit 00 ... 15)
STW M 16.00 Write Word M 16.00 (bit 00 ... 15)

11.08.93, 396.0432 System manual, page 6.23


Word operations Programming technique

Word operations are mainly used in conjunction with D-registers or R-registers.


The data registers accept multi-bit data (e.g. counter contents).
The registers can be accessed byte-wise or word-wise:

Register Data transfer


8 bits Byte Word

xx.00 xx.00 xx.00


xx.01 xx.01
xx.02 xx.02 xx.02
xx.03 xx.03
xx.04 xx.04 xx.04
xx.05 xx.05

xx.62 xx.62 xx.62


xx.63 xx.63

System manual, page 6.24 11.08.93, 396.0432


Programming technique Word operations

Each individual register (8-bits wide) is accessed by byte-operations.

Examples:
Instruction Access
FTB D 00.00 Load data register D 00.00 (byte 00)
FTB D 15.56 Load data register D 15.56 (byte 56)

1 word (= 2 bytes) is always accessed with word-operations.

Examples:
Instruction Access
FTW D 15.62 Load data register D 15.62 (byte 62+63)
FTW D 10.04 Load data register D 10.04 (byte 04+05)

Always address word-operations to even numbered data registers.


Word operations will only be executed when RR = 1.

Program example
The data-word at input module 00 is to be read when I 00.00 is active (RR = 1). The
binary data word is to be sent to the output module 01.

Line No. Operation Operand Remark


0000 L I 00.00 If input
0001 FTW I 00.00 Read word from module 00
0002 STW O 01.00 Write word to module 01
0003 EP End of program

Note: If the special marker M 40.00 (logic 1) is used as the drive, word operations
will be carried out continuously because RR will always = 1.

11.08.93, 396.0432 System manual, page 6.25


Word operations Programming technique

Program
Line No. Operation Operand Remark
0000 L M 40.00 If marker is logical 1
0001 FTB I 00.08 Read byte from module 00
0002 STB O 01.00 Write byte to module 01
0003 EP End of program

System manual, page 6.26 11.08.93, 396.0432


Programming technique Word logic operations

Word logic operations


A handy extension to the 1-bit logic operation is provided by the 16-bit word
operations.
These logic operations operate on the following operands:
• Data register D nn.nn
• Constant K kkkk

Instruction Syntax Data reg. Syntax Constant


AW AND WORD AW D nn.nn AW K kkkk
OW OR WORD OW D nn.nn OW K kkkk
XOW EXCLUSIV OR WORD XOW D nn.nn XOW K kkkk

Example:

MRR before:
1 1 0 0 0 0 1 1 1 0 1 0 1 1 1 1

D or K as operand
1 0 1 0 0 1 0 1 1 1 1 1 0 0 0 0

MRR after:
1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 Operation AW

1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 Operation OW

0 1 1 0 0 1 1 0 0 1 0 1 1 1 1 1 Operation XOW

The logic operations are performed between the individual corresponding bits and the
final result is placed in the multi-bit result register (MRR).

11.08.93, 396.0432 System manual, page 6.27


Word logic operations Programming technique

Uses
• Masking
(comparisons, masking and checking of bit patterns)
• Auxiliary arithmetic operations
• Supervision of input variables
(digital 16-bit values via digital or analog input modules)
• Clearing the multi-bit result register, MRR (AW K 00000)

Program example
The statuses at inputs I 00.00 ... I 00.07 have to be compared with the statuses at inputs
I 00.08 ... I 00.15.
Any differences should activate the appropriate output O 01.00 ... O 01.07.

Program
Line No. Operation Operand Remark
0000 L M 40.00 If marker = logical 1
0001 FTB I 00.00 Read byte from module 00.00
0002 STB D 15.60 Write to data register
0003 FTB I 00.08 Read byte from module 00.08
(MRR before)
0004 XOW D 15.60 EXOR (difference)
0005 STB O 01.00 Write byte to module 01
(MRR after)
0006 EP End of program

System manual, page 6.28 11.08.93, 396.0432


Programming technique Counters

Counters
Operations
Instruction
CU COUNT UP
CD COUNT DOWN

The SELECONTROL® programming technique has facilities for providing 512 4-


decade up/down counters (0000 ... 9999).
The CU and CD operations are always performed in conjunction with a data register as
the operand.
Only even-numbered data registers can be used as operands. (e.g. D 00.00, D 00.02, D
00.04 etc.)
The counters are triggered on the positive-negative-going edge of the counting signal.

The data register contains the current counter content. The data register, and therefore
the content of the corresponding counter, can be altered in the RUN mode with the
MODIFY command.
RR is set to 1 if a data register overflows during a CU operation (transition from 9999 -
> 0000). Because of this, the counters can be readily cascaded to form an arbitrarily
long chain.

Program example: 4-decade up-counter (0000 ... 9999)


Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 CU D 15.60 Count upwards
0002 EP

Program example: 4-decade down-counter (9999 ... 0000)


Line No. Operation Operand Remark
0000 L I 00.01 If input
0001 CD D 15.60 Count downwards
0002 EP End of program

11.08.93, 396.0432 System manual, page 6.29


Counters Programming technique

Program example: 8-decade up-counter (00000000 ... 99999999)


Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 CU D 15.60 Count upwards
0002 CU D 15.62 Carry
0003 EP End of program

Program example
Down-counter with preset input and output comparison at the value 0000.

Circuit Pulse diagram


Preset
Preset
FTW K 00015
Clock
I 00.00
9999
STW D 15.56 :
Counter
content
CD D 15.56 :
0000
I 00.01 D 15.56
Compare
D15.56 O 01.00 Output

Line No. Operation Operand Remark


0000 L I 00.00 If preset input
0001 FTW K 00015 Read constant
(preselect value)
0002 STW D 15.56 Write to data
register
0003 L I 00.01 If counter input
(clock)
0004 AN D 15.56 And not counter value
0000
0005 CD D 15.56 Count down data
register
0006 L D 15.56 If counter value 0000
(comparison)
0007 = O 01.00 Then Output
0008 EP End of program

System manual, page 6.30 11.08.93, 396.0432


Programming technique Comparison operations

Comparison operations
Instruction
LT LESS THAN
LTE LESS THAN OR EQUAL
EQ EQUAL
GT GREATER THAN
GTE GREATER THAN OR EQUAL

The LT/LTE operations examine the value in the multi-bit result register to see whether
it is less than (less than or equal to) the value of a constant or a data register.
The EQ operation examines the value in the multi-bit result register to see whether it is
the same as the value of a constant or a data register.
The GT/GTE operations examine the value in the multi-bit result register to see
whether it is greater than (greater than or equal to) the value of a constant or a data
register.
The comparison operations are only executed if RR = 1.
The special marker M 40.00 (logic 1) sets RR = 1 so that the comparison can be carried
out continuously.
If the conditions for the comparison are fulfilled, RR is set to 1, if not, RR is set to 0.
Besides comparisons of BCD values, it is also possible to compare hex values.

Program example
The output O 01.00 has to be set if the counter status D 15.60 reaches or exceeds the
value 5.
Program
Line No. Operation Operand Remark
0000 L I 00.00 If counter input
0001 CU D 15.60 Count upwards data
register
0002 L M 40.00 If marker = logical 1
0003 FTW D 15.60 Read data register
0004 GTE K 00005 Compare whether
content
of D 15.60 > 5
0005 = O 01.00 Then output
0006 EP End of program
11.08.93, 396.0432 System manual, page 6.31
Comparison operations Programming technique

The EQ (EQUAL) operation can be cascaded to compare values that are greater than 4-
bits wide. If the first comparison condition is fulfilled (RR = 1), then the second
comparison is also carried out. The output is set to active if both sets of conditions are
fulfilled.

Program example
Output O 01.00 has to be activated when the data registers contain the BCD value of
53,974,298.
Program
Line No. Operation Operand Remark
0000 L M 40.00 If marker = logical 1
0001 FTW D 15.60 Read data register
0002 EQ K 04298 Examine whether
content
of D 15.60 = 4298
0003 FTW D 15.62 Read data register
0004 EQ K 05397 Examine whether
content
of D 15.62 = 5397
0005 = O 01.00 Then output
0006 (EP)

Check program
Line No. Operation Operand Remark
0006 L I 00.00 If input
0007 FTW K 05397 Read constant
0008 STW D 15.62 Write in data
register
0009 L I 00.01 If input
0010 FTW K 04305 Read constant
0011 STW D 15.60 Write in data
register
0012 L I 00.03 If input
0013 CD D 15.60 Count down
0014 L I 00.04 If input
0015 CU D 15.60 Count up
0016 EP End of program

System manual, page 6.32 11.08.93, 396.0432


Programming technique Arithmetic

Arithmetic
The SELECONTROL® programming technique is capable of performing the four basic
mathematical operations with 4-digit operands:
Instruction
ADD Addition
SUB Subtraction
MUL Multiplication
DIV Division

A constant (K kkkkk) or a data register (D nn.nn) serves as the operand. All the
operations refer to the integer value in the first quadrant (whole positive values).
The arithmetic operations are only executed if RR = 1.
As long RR = 1, the arithmetic operations will be carried out during every program
cycle.
For this reason, the TRG (TRIGGER) operation is used in the following program
example.

Program example (addition)


Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 TRG M 16.00 Trigger auxiliary
marker
0002 FTW D 15.60 Read data register
0003 ADD K 01234 Add constant
0004 STW D 15.60 Write to data
register
0005 EP End of program

The special marker, M 40.09 (carry/borrow), is set if the result of an addition is greater
than 9999 or the result of a subtraction is less than 0000. This special marker retains its
status until the next mathematical operation is performed.
Addition and subtraction are performed with arbitrary values. Any carry or borrow sets
the special marker M 40.09.

11.08.93, 396.0432 System manual, page 6.33


Arithmetic Programming technique

Program example (Addition with carry)


The constant 5111 has to be added to the value in the data register D 15.60. The carry
amount is to be written into data register D 15.62.
Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 TRG M 16.00 Trigger auxiliary
marker
0002 FTW D 15.60 Read data register
0003 ADD K 05111 Add constant
0004 STW D 15.60 Write to data
register
0005 A M 40.09 And special marker
carry
0006 FTW D 15.62 Read data register
0007 ADD K 00001 Add constant (carry)
0008 STW D 15.62 Write to data
register
0009 EP End of program

Program example (Subtraction with borrow)


The constant 7501 has to subtracted from the value 27500 each time the input I 00.00 is
activated.
Line No. Operation Operand Remark
0000 L I 00.04 Preset if input
0001 FTW K 07500 Read constant
0002 STW D 15.60 Write to data
register
0003 FTW K 00002 Read constant
0004 STW D 15.62 Write to data
register
0005 L I 00.00 If input
0006 TRG M 16.00 Trigger auxiliary
marker
0007 FTW D 15.60 Read data register
0008 SUB K 07501 Subtract constant
0009 STW D 15.60 Write to data
register
0010 A M 40.09 And special marker
borrow
0011 FTW D 15.62 Read data register
0012 SUB K 00001 Subtract constant
System manual, page 6.34 11.08.93, 396.0432
Programming technique Arithmetic

0013 STW D 15.62 Write to data


register
0014 EP End of program

Program example (Multiplication)


Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 FTW K 00021 Read constant
0002 MUL K 00022 Multiply by constant
0003 STW D 15.60 Write to data
register
0004 EP End of program

Program example (Multiplication with a result over 9999)


If the result of a multiplication is greater than 9999, the most significant figures are
written into the AUX-MRR (an auxiliary register). The AUX-MRR can be read with the
FTR FETCH AUXILIARY REGISTER operation and then it can be further processed.

Line No. Operation Operand Remark


0000 L I 00.00 If input
0001 FTW K 02100 Read constant
0002 MUL K 00222 Multiply by constant
0003 STW D 15.60 Write to data
register
0004 FTR Read auxiliary register
0005 STW D 15.62 Write to data
register
0006 EP End of program

11.08.93, 396.0432 System manual, page 6.35


Arithmetic Programming technique

Program example (Division)


The special marker M 40.07 (arithmetic error) is set if one of the operands is outside the
BCD range or if the divisor is 0000 (zero).

Line No. Operation Operand Remark


0000 L I 00.00 If input
0001 TRG M 16.00 Trigger auxiliary
marker
0002 FTW K 07654 Read constant
0003 DIV K 00200 Divide constant
0004 STW D 15.60 Write to data
register
0005 FTR Read auxiliary register
(rest)
0006 STW D 15.56 Write to data
register
0007 EP End of program

The value 38 is deposited in data register D 15.60 after the program has been executed.
The remainder (54) is deposited in data register D 15.56.
If the two figures in a division operation are not divisible, the remainder is placed in the
AUX-MRR.

System manual, page 6.36 11.08.93, 396.0432


Programming technique Digital timers

Digital timers
Operations
Instruction
TF TIMER FAST (0,1s clock)
TS TIMER SLOW (1,0s clock)

The SELECONTROL® programming technique enables up to 512 digital timers to be


programmed.
The operations TF (TIMER FAST) and TS (TIMER SLOW) always have to be used
together with a data register as the operand. Only even-numbered data registers can be
used as operands.
The data register is loaded with the appropriate default value upon arrival of each
positive-negative-going edge of the input (Drive) signal. A further positive-negative-
going edge at the input during a timed period causes the data register to be re-loaded
with the default value (time-reset).
The data register is decremented with the 0.1s clock in a TF operation and with the 1.0s
clock in a TS operation. Decrementing ceases as soon as the data register reaches the
value 0000.
Decrementing carries on down to 0000 even if the input conditions are no longer
fulfilled or if a jump is made over that part of the program.
The data register contains the non-elapsed time. The content of the data register, and
therefore the remaining time, can be altered in the RUN mode with the MODIFY
command.
The precision of the digital time delays is:

• +0,0s for TF (0,1s clock)


-0,1s

• +0,0s for TS (1,0s clock)


-1,0s

11.08.93, 396.0432 System manual, page 6.37


Digital timers Programming technique

Programming example: Switch-on delay

Circuit Pulse diagram


Input
FTW K 00095
TF D 15.60 0095
I 00.00 Current
value
0000
9.5 s 9.5 s
D 15.60 O 01.00

Output

Line No. Operation Operand Remark


0000 L I 00.00 If input
0001 FTW K 00095 Read constant (preselec. val.)
0002 TF D 15.60 Decr. with 0.1s pulses
0003 A D 15.60 And data register value 0000
(time = elapsed)
0004 = O 01.00 Then output
0005 EP End of program

System manual, page 6.38 11.08.93, 396.0432


Programming technique Digital timers

Programming example: Switch-off delay


An output has to go to logic 1 when an input is switched on and stay at that value until
the required delay time has elapsed.

Circuit Pulse diagram

FTW K 00011 Input


TF D 15.62
I 00.01
t=11 s t=11 s

I 00.01 O 01.01

Output
D 15.62

Line No. Operation Operand Remark


0000 L I 00.01 If input
0001 FTW K 000.11 Read constant (pres. val.)
0002 STW D 15.62 Write constant to D-register
0003 LN I 00.01 If not input
0004 FTW D 15.62 Read data register
0005 TS D 15.62 Decr. with 1,0s clock
0006 AN D 15.62 And data register
0007 O I 00.01 If input
0008 = O 01.01 Then output
0009 EP End of program

Digital timers can also be formed by using special markers (time rate) together with
counters:
Special marker M 40.02 (0,1s rate)
Special marker M 40.03 (1,0s rate)
Special marker M 40.04 (0,01s rate)

11.08.93, 396.0432 System manual, page 6.39


Digital timers Programming technique

Programming example: Switch-on delay of 9.5s with down-counter

Line No. Operation Operand Remark


0000 LN I 00.00 If not input
0001 O M 40.01 (1. cycle)
0002 FTW K 00095 Read constant
0003 STW D 15.60 and write to data register
0004 L I 00.00 If input
0005 A M 40.02 And rate 0,1s
0006 AN D 15.60 And counter > 0
0007 CD D 15.60 Count down
0008 L D 15.60 If data register = 0000
0009 = O 01.00 Then output
0010 EP End of program

The time delay can be interrupted by interrupting the input signal (I 00.00).

System manual, page 6.40 11.08.93, 396.0432


Programming technique Shift operations (bit/digit)

Shift operations (bit/digit)


The SELECONTROL® programming technique supports both bit and digit (multi-bit)
shift operations.

Bit shift operations


Instruction
RBL ROTATE BIT LEFT
RBR ROTATE BIT RIGHT

A data register or a marker word serves as the operand.


Either a shift or a rotate function is carried out by this command depending on the
programming (see example).
As a result, the content of the special marker M 40.05 is written into the LSB and then
the MSB is written into the special marker. The MRR is not changed. The instruction is
only carried out if RR = 1.

RBL MSB high byte low byte LSB


M 40.05 Bit 15 D xx.yy (Word) Bit 0
or
M xx.00 (Word)

RBR MSB high byte low byte LSB


Bit 15 D xx.yy (Word) Bit 0 M 40.05
or
M xx.00 (Word)

This method enables rotate as well as shift instructions to be cascaded.


(by using M 16.00 ... M 23.00 and D 00.00 ... D15.62 up to 7808 bits!)

11.08.93, 396.0432 System manual, page 6.41


Shift operations (bit/digit) Programming technique

Program example (Bit-shift operations to the left)

Line No. Operation Operand Remark


0000 L I 00.00 Load input
0001 = M 40.05 Assign value to special marker
0002 L I 00.01 If input shift
0003 TRG M 16.00 Trigger auxiliary marker
0004 RBL D 00.00 Shift M 40.05 into LSB and
MSB into M 40.05
0005 L M 40.00 Drive (RR = 1)
0006 FTW D 00.00 Read data register D 00.00
0007 STW O 01.00 Write D 00.00 into
output module
0008 EP End of program

Program example (Shift operation to the right)


Continuation of above program
Line No. Operation Operand Remark
0008 L I 00.07 If input shift
0009 TRG M 16.01 Trigger auxiliary marker
0010 RBR D 00.00 Shift M 40.05 into MSB and
LSB into M 40.05
0011 L M 40.00 Drive (RR = 1)
0012 FTW D 00.00 Read data register D 00.00
0013 STW O 01.00 Write D 00.00 into
output module
0014 EP

System manual, page 6.42 11.08.93, 396.0432


Programming technique Shift operations (bit/digit)

Digit shift operations


The multi-bit shift operations affect the multi-bit result register (MRR) directly. They
have the effect of moving the contents of the MRR by 1 digit to the left or right
respectively. The operation is only executed if RR = 1.
Instruction
SFL SHIFT LEFT Moves contents to the left by 1 digit
SFR SHIFT RIGHT Moves contents to the right by 1 digit
RTL ROTATE LEFT Rotates contents to the left by 1 digit
RTR ROTATE RIGHT Rotates contents to the right by 1 digit

Uses:
• Data manipulations of all kinds,
(e.g. multiplication or division of values by 10, 100 or 1000)
• Formatting the contents of registers
• Operations with masks
(in conjunction with AW (AND WORD) and OW (OR WORD))

11.08.93, 396.0432 System manual, page 6.43


Shift operations (bit/digit) Programming technique

Shift digit to the left


The operation SFL has the effect of moving the contents of the multi-bit result register
(MRR) by 1 digit to the left. It should be noted that the most significant digit (103) will
be lost.

Digit in MRR
4 7 8 3 Status of MRR before an SFL operation

7 8 3 0 Status of MRR after an SFL operation

Program example
The content of data register D 15.60 is to be shifted by two places to the left and the
result stored in register D 15.56.

Line No. Operation Operand Remark


0000 L I 00.00 If input
0001 AN M 16.00 Inhibit marker
0002 FTW D 15.60 Load data register
0003 SFL Shift by 1 digit left
0004 SFL Shift by 1 digit left
0005 STW D 15.56 Store in data register
0006 S M 16.00 Set inhibit marker
0007 EP End of program

Check on the example:


An arbitrary value (e.g. 5678) is loaded into the data register D 15.60 in the RUN-
MONITOR mode. (Instruction: M)D15.60 K5678)
If input I 00.00 is activated, the value shown for the content of register D 15.56 would
be 7800.

System manual, page 6.44 11.08.93, 396.0432


Programming technique Shift operations (bit/digit)

Digit shift to the right


This operation has the identical effect as SFL except that the shift is to the right.

Digit in MRR
4 7 8 3 Status of MRR before an SFR operation

0 4 7 8 Status of MRR after an SFR operation

The most or least significant digit is lost after each SFL or SFR operation respectively!

11.08.93, 396.0432 System manual, page 6.45


Shift operations (bit/digit) Programming technique

Rotate digit to the left


This operation has the effect of rotating the contents of the MRR by 1 digit to the left.
This shifts the most significant digit to the position previously occupied by the least
significant digit, thus:

Digit in MRR
4 7 8 3 Status of MRR before an RTL

7 8 3 4 Status of MRR after an RTL

Program example
The contents of data register D 15.60 have to be rotated by 1 position to the left and the
result stored in register S 15.56.

Line No. Operation Operand Remark


0000 L I 00.00 If input
0001 AN M 16.00 Inhibit marker
0002 FTW D 15.60 Read data register
0003 RTL Rotate by 1 digit left
0004 STW D 15.56 Store in data register
0005 S M 16.00 Set inhibit marker
0006 EP End of program

Check on the example:


An arbitrary value (e.g. 5678) is loaded into the data register D 15.60 in the RUN mode.
(Instruction: M)D15.60 K5678)
If input I 00.00 is activated, the value shown for the content of the data register would
be 6785.

System manual, page 6.46 11.08.93, 396.0432


Programming technique Shift operations (bit/digit)

Rotate digit to the right


This operation has the identical effect as RTL except that the rotation is to the right:

D ig it in M R R
4 7 8 3 S ta tu s of M R R be fo re a n R T R

3 4 7 8 S ta tus o f M R R after a n R T R

11.08.93, 396.0432 System manual, page 6.47


Block operations (Shift/Copy) Programming technique

Block operations (Shift/Copy)


The SELECONTROL® programming technique supports block-shift and block-copy
operations.

Block shift operations


Instruction
BSU Block-Shift-Up
BSD Block-Shift-Down
BR Block-Reset

The operations BSU and BSD shift a data block of 64 bytes (32 words) by one word
unit (i.e. by 2 bytes or 16 bits).
The effect of these operations is to move the contents of the MRR into the first word of
the defined block while the last word of the defined block is transferred to the MRR or
vice-versa.
The operations only operate on data register blocks and are only executed if RR = 1.

BSU (Block-shift-up)

D 0 9.63 D 09.62
D 0 9.61 D 09.60

B S U D 09.00

D 0 9.03 D 09.02
D 0 9.01 D 09.00

M ulti-bit-result
M RR
register

System manual, page 6.48 11.08.93, 396.0432


Programming technique Block operations (Shift/Copy)

The operations can be cascaded so that whole block groups can be shifted.

D 1 5.63 D 15.62

D 1 5.01 D 1 5.00

B S U D 14.00
B S U D 15.00

D 14.63 D 14.62

D 14.01 D 14.00

M RR

Uses:
Setting up FIFO data register blocks (First In/First Out) for the chronological-sequential
storage or output of data.

Typical applications
• Cyclic processing of incoming external data.
(binary or hexadecimal as well as BCD values)
• Chronological storage of addresses in sorting tasks.

11.08.93, 396.0432 System manual, page 6.49


Block operations (Shift/Copy) Programming technique

Program example
The value 3579 has to be continuously shifted through the data register block
D 15.00 ... D 15.62, at a 1-second clock rate (i.e. a round-shift) :

Line No. Operation Operand Remark


0000 L I 00.00 If input
0001 A M 40.03 And Marker 1,0s clock
0002 TRG M 16.00 Trigger auxiliary marker
0003 FTW D 15.62 Read data register in MRR
0004 BSU D 15.00 Block-shift upwards
0005 EP End of program

Check on the program


Preset the data register, D 15.56, to K 3579 in the RUN- mode.
Instruction: M)D15.60 K3579
If input I 00.00 is activated, the value of 3579 will be moved through the defined data
register block D 15.00. The individual data registers can be displayed with the View
command V).

System manual, page 6.50 11.08.93, 396.0432


Programming technique Block operations (Shift/Copy)

BSD (Block-shift-down)
The BSD operation has the effect of shifting the data register block downwards i.e. in
the direction of decreasing line-number values.

D 1 0.63 D 10.62
D 1 0.61 D 10.60

B S D D 10.00

D 1 0.03 D 10.02
D 1 0.01 D 10.00

M RR

BR (Block Reset)
This operation sets all the values in the defined data register block to 0000. It is only
executed if RR = 1.

Effect:
All the data registers in the block from D 15.00 to D 15.63 will be reset to 0000.

11.08.93, 396.0432 System manual, page 6.51


Block operations (Shift/Copy) Programming technique

Copy of a data block


These operations are used, for example, during communications.
Instruction: copies:
MDD D-register block to D-register block
MDR D-register block to R-register block
MRD R-register block to D-register block
MRR R-register block to R-register block

The commands enable any block from a D or R register to be copied to any other D or
R register.
The command is not executed if RR = 0 or the command is jumped over by a jump
command.
The following diagram shows how the command works:
63 63

nn
M DD
M DR
bb M RD
M RR

copy

yy

00 00
D (R ) aa D (R ) xx

The parameters are defined in the following D-registers:


Register Definition
D 15.50 Source address (in the form aabb)
D 15.52 Destination address (in the form xxyy)
D 15.54 Block size in bytes (nn = 01 ... 64).

System manual, page 6.52 11.08.93, 396.0432


Programming technique Block operations (Shift/Copy)

An arithmetic error flag is set and the command is not executed if any of these
parameters is a pseudotetrade (A ... F) or is not within the given range.
This flag is also set if the sum of (bb+nn) or (yy+nn) exceeds 64.
Since all the parameters are defined during the running period (RUN-mode), the values
can therefore also be calculated. The blocks are hence addressed in an indirect way (-->
very high flexibility).

Program example
A 1-byte block has to be copied when the input I 00.00 is activated.
Source address is the value from constant K 01556 (Register D 15.56)
Destination address is the value from constant K 01560 (Register D 15.60)
The command MDD is to be used since the source and destination addresses define the
D-register.

Line No. Operation Operand Remark


0000 L M 40.00 If Marker log. 1
0001 FTW K 01556 Read source address
0002 STW D 15.50 Write source address into
data register D 15.50
0003 FTW K 01560 Read target address
0004 STW D 15.52 Write target address into
data register D 15.52
0005 FTW K 00001 Read block size (1 byte)
0006 STW D 15.54 Write block size into
data register D 15.54
0007 L I 00.00 If input
0008 MDD Copy block content from
address K 01556 to
address K 01560
0009 EP End of program

Program check
In the RUN-mode, preset the data register D 15.56 to the constant K 98.
Instruction: M) D 1556 K 98

11.08.93, 396.0432 System manual, page 6.53


Sequential routines (Step counters) Programming technique

Sequential routines (Step counters)


The SELECONTROL® programming technique supports the programming of
sequential routines (step counters). Use of sequential routines (step counters) enables
complex sequences to be simply and safely programmed in a structured manner.

Features about the step counters


• Each process step taken by the machine or plant under control is associated with a
step in the sequential routine.
• The next programmed step can only be implemented when the previous one has been
fully completed.
• The structure of the program is completely free. Arbitrary forwards and backwards
jumps may be made and parallel portions of the program are permissible.
• The operational security is considerably improved through the use of sequential
routines (step counters) without having to program in complicated interlocks.
• Programming with sequential routines considerably simplifies the writing of
programs, commissioning and machine/process diagnoses.
• The advantage of sequential routines lies in the fact that the individual steps into
which the process has been broken down can be handled as sub-programs.
• Only 1 step at a time is ever set in a sequential routine.
• When a new step is set the previous one is automatically reset. No R (RESET) has to
be programmed.
• Several sequential routines (step counters) are available for the running of parallel
programs.

System manual, page 6.54 11.08.93, 396.0432


Programming technique Sequential routines (Step counters)

Operations with sequential routines (Step counters)


Operations for interrogating the step counter content and for setting a specific step
count (logical operations).
Instruction Negation
L S nn.kk If step counter (SZ) LN S nn.kk
A S nn.kk And step counter AN S nn.kk
O S nn.kk Or step counter ON S nn.kk
S S nn.kk Set step counter

Program example
Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 O I 00.01 Or input
0002 A S 05.00 And SZ 05 to step 00
0003 S S 05.01 Set SZ 05 to step 01
0004 L I 00.05 If input
0005 A S 05.01 And SZ 05 to step 01
0006 S S 05.99 Set SZ 05 to step 99
0007 EP End of program

11.08.93, 396.0432 System manual, page 6.55


Sequential routines (Step counters) Programming technique

Operations with access to the step counter content


(status)
Instruction Remark
FTB S nn.00 The content of step counter nn is read into the MRR-register.
STB S nn.00 The step counter nn is set to the step (i.e. value) that is in the MRR register.

Program example
The content of the step counter for sequence 07 is to be read and the value obtained is to
be written into data register D 15.60.
Example 1:
Line No. Operation Operand Remark
0000 L M 40.00 Special marker logical 1
0001 FTB S 07.00 Read step counter 07
0002 STB D 15.60 Write data register
0003 EP

Example 2:
The step counter is set to the value that is contained by the data register 15.56.

Line No. Operation Operand Remark


0000 L I 00.00 If input
0001 FTB D 15.56 Read data register
0002 STB S 00.00 Set SZ 00 to step (value),
that is in the data register
0003 EP End of program

System manual, page 6.56 11.08.93, 396.0432


Programming technique Sequential routines (Step counters)

Incrementing and decrementing step counters


Instruction Remark
INC S nn.00 Increments the step counter
DEC S nn.00 Decrements the step counter

The operations INC and DEC increase and decrease the step counter content by 1
respectively.

Program example:
The display shows the steps 0 ... 10 at 1s intervals.
Line No. Operation Operand Remark
0000 L M 40.03 If clock = 1.0s
0001 TRG M 16.00 Trigger auxiliary marker
0002 INC S 07.00 Increments SC 07
0003 L S 07.11 If SC 07 is at step 11
0004 S S 07.00 Set SC 07 to step 00
0005 EP End of program

Note: INC, DEC are not triggered.

11.08.93, 396.0432 System manual, page 6.57


Sequential routines (Step counters) Programming technique

Programming example: Simple movement with two cylinders


The following example can be easily converted into a program by means of a path-time
diagram.
Mechanical configuration

I 00 .0 4

Cylinder 1
I 00 .0 1 I 00 .0 2

I 00 .0 3
O 01 .0 0

Cylinder 2
I 00 .0 0
O 0 1 .0 1
Start

Path-time diagram

I 00 .0 0
I 00 .0 1
I 00 .0 3 I 0 0 .0 2 I 0 0 .0 4 5 se c I 00 .0 3 I 0 0 .0 1

O 0 1 .0 0
t

O 0 1 .0 1

System manual, page 6.58 11.08.93, 396.0432


Programming technique Sequential routines (Step counters)

Explanation of program step 1:


If the start conditions are fulfilled and the step "Initial position" is active, then set the
step "Cylinder 1 forwards".
Line No. Operation Operand Remark
0000 L I 00.00 Start button
0001 A I 00.01 Limit switch cyl. 1, rear
0002 A I 00.03 Limit switch cyl. 2, rear
0003 A S 00.00 Initial position
0004 S S 00.01 Cylinder 1 forwards

Explanation of program step 2:


If cylinder 1 is at the front limit switch and the step "Cylinder 1 forwards" is active,
then set the step "Cylinder 2 forwards".
Line No. Operation Operand Remark
0005 L I 00.02 Limit switch, front
0006 A S 00.01 Cylinder 1 forwards
0007 S S 00.02 Cylinder 2 forwards

Explanation of program step 3:


If cylinder 2 is at the front limit switch and the step "Cylinder 2 forwards" is active,
then set the step "Wait".
Line No. Operation Operand Remark
0008 L I 00.04 Limit switch, front
0009 A S 00.02 Cylinder 2, front
0010 S S 00.03 Wait

Explanation of program step 4:


If the pause has elapsed and the step "Wait" is active, then set the step "Cylinder 2
return".
Line No. Operation Operand Remark
0011 L M 16.00 Pause elapsed
0012 A S 00.03 Wait
0013 S S 00.04 Cylinder 2 return

11.08.93, 396.0432 System manual, page 6.59


Sequential routines (Step counters) Programming technique

Explanation of program step 5:


If cylinder 2 is at the rear limit switch and the step "Cylinder 2 return" is active, then set
the step "Cylinder 1 return".
Line No. Operation Operand Remark
0014 L I 00.03 Limit switch, rear
0015 A S00.04 Cylinder 2 return
0016 S S 00.05 Cylinder 1 return

Explanation of program step 6:


If cylinder is at the rear limit switch and the step "Cylinder 1 return" is active, then set
the step "Initial position".
Line No. Operation Operand Remark
0017 L I 00.01 Limit switch, rear
0018 A S 00.05 Cylinder 1 return
0019 S S 00.00 Initial position

Explanation of program step 7:


Start the pause period in step "Wait".
Line No. Operation Operand Remark
0020 L S 00.03 Wait
0021 FTW K 0050 5 sec. pause
0022 TF D 15.60 Aux. register for pause
0023 A D 15.60 Aux. register for pause
0024 = M 16.00 Pause elapsed

Explanation of program step 8:


Activation of cylinder 1.
Line No. Operation Operand Remark
0025 L S 00.01 Cylinder 1 forwards
0026 O S 00.02 Cylinder 2 forwards
0027 O S 00.03 Wait
0028 O S 00.04 Cylinder 2 return
0029 = O 01.00 One-way valve, cylinder 1

System manual, page 6.60 11.08.93, 396.0432


Programming technique Sequential routines (Step counters)

Explanation of program step 9:


Activation of cylinder 2.
Line No. Operation Operand Remark
0030 L S 00.02 Cylinder 2 forwards
0031 O S 00.03 Wait
0032 = O 01.01 One-way valve, cylinder 2
0033 EP End of program

11.08.93, 396.0432 System manual, page 6.61


Code-conversion operations Programming technique

Code-conversion operations
Instruction Remark
BID Binary into BCD
DEB Decimal into Binary

These operations operate on the multi-bit result register MRR and are only executed if
RR = 1.
The value read from the MRR is put back into the MRR after being converted.

MRR before
0 0 0 1 1 0 0 1 0 1 1 0 1 1 1 1 MRR
BID
MRR after
0 1 1 0 0 1 0 1 0 0 0 1 0 0 0 1 MRR

Uses:
BID: Conversion of binary values (for example, from analog input modules) into
decimal values for further processing with arithmetic functions.
DEB: Conversion of decimal values into binary values for output purposes (for
example, via output modules) or to binary-based peripherals.

Program examples:
Conversion from binary into decimal form
Line No. Operation Operand Remark
0000 L M 40.00 If special marker = logical 1
0001 FTB I 00.00 Read input module 00.00
0002 BID Convert binary into digital
0003 STB D 15.60 Display (decimal)
0004 STB O 01.00 Output decimal
0005 EP End of program

System manual, page 6.62 11.08.93, 396.0432


Programming technique Code-conversion operations

Conversion decimal into binary


Line No. Operation Operand Remark
0000 L M 40.00 If special marker = logical 1
0001 FTB I 00.00 Read input (BCD)
0002 STB D 15.60 Display (decimal)
0003 DEB Convert decimal into binary
0004 STB O 01.00 Output (binary)
0005 EP End of program

Note: The special marker, M 40.07 (arithmetic error), is set if the decimal
equivalent exceeds the value of 9999 as a result of a code changing operation.

11.08.93, 396.0432 System manual, page 6.63


Table-Look-Up operation Programming technique

Table-Look-Up operation
The LKP operation provides a simple and fast means of accessing a table having 256
freely assignable places for 2-digit values.
The operation is executed if RR = 1

Organisation of the table


Table address
00 ... 07 00 00 00 00 00 00 00 00
08 ... 0F 00 00 00 00 00 00 00 00
10 ... 17 00 00 00 00 34 00 00 00 Address 14, Value 34
18 ... 1F 00 00 00 00 00 00 00 00
20 ... 27 00 00 00 00 00 00 00 00
28 ... 2F 00 00 79 00 00 00 00 00 Address 2A, Value 79
30 ... 37 00 00 00 00 00 00 00 00
38 ... 3F 00 00 00 00 00 00 00 00
-- ... -- -- -- -- -- -- -- -- --
-- ... -- -- -- -- -- -- -- -- --
-- ... -- -- -- -- -- -- -- -- --
E0 ... E7 00 00 00 00 00 00 00 00
E8 ... EF 00 8F 00 00 00 00 00 00 Address E9, Value 8F
F0 ... F7 00 00 00 00 00 00 00 00
F8 ... FF 00 00 00 00 00 00 00 00

System manual, page 6.64 11.08.93, 396.0432


Programming technique Table-Look-Up operation

Use of the Look-Up-table


• Code changing of 8-bit (2-digit) values such as BCD into 7-segment code or BCD
into Grey-code, etc.
• Simple transformation of, for instance, non-linear functions.

Operational manner of the LKP operation


The two lowest digits in the MRR contain the table addresses before the operation.
After the operation, the two lowest digits of the MRR contain the value from the table.

Table
MRR before LKP
n n 2 1
Table addresses nn nn nn nn
20 ... 27
nn 75 nn nn

n n 7 5
MRR after LKP

The table addresses (e.g. such as 21 in the above example) can originate from data
registers, step counters or input modules.

Example:
FTB S 12.00 The current step in step counter number 12 supplies the address
for the table.

11.08.93, 396.0432 System manual, page 6.65


Table-Look-Up operation Programming technique

Filling the table


The table can be filled in the PROGRAMMING mode via the programming terminal or
from the SELECONTROL® CAP programming system.

Instruction
T) XX.nn

Example: T) 1A.43 cause:

Table
00 ... 07 nn nn nn nn
08 ... 0F nn nn nn nn
10 ... 17 nn nn nn nn
Table- address 1A 18 ... 1F nn nn 43 nn
20 ... 27 nn nn nn nn

Displaying the table


The operating command H) in the PROGRAMMING mode has the effect of causing a
listing of the contents of the table to be displayed on the programming system.

Deleting the table


The operating command N)1234 clears the whole program and deletes the contents of
the table.

System manual, page 6.66 11.08.93, 396.0432


Programming technique Table-Look-Up operation

Program example
Table-Values:

9
8
7
6
5
4
3
2
1
0 Counter values
0 1 2 3 4 5 6 7 8 9 10 Register D 15.60

Task:
'Follow' the shape shown above at 1 second intervals, using a step counter and with the
aid of the look-up table.
Display: Counter via reg. D 15.60, table-value via reg. D 15.56.

Solution:
Data register D 15.60 is incremented by 1 up to a content of 9 at 1s intervals. The
values in data register D 15.60 represent the addresses in the table where the
corresponding values 0, 1, 3, 6, 8 and 9 are stored.
Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 A M 40.03 And marker rate 1s
0002 CU D 15.60 Count upwards
0003 L M 40.00 Drive (RR = 1)
0004 FTW D 15.60 Load data register
0005 GT K 00009 Compare whether content
of D 15.60 is greater than 9
0006 R D 15.60 Reset D-register
0007 L I 00.00 If input
0008 FTW D 15.60 Read data register
0009 DEB Code conversion
0010 LKP Read the Look-Up-Table
0011 STW D 15.56 Display table value
0012 EP End of program

11.08.93, 396.0432 System manual, page 6.67


Table-Look-Up operation Programming technique

Indirect addressing
Instruction Remark
FIR D nn.mm Fetch Indirect R-Register
FID D nn.mm Fetch Indirect D-Register
SIR D nn.mm Store Indirect R-Register
SID D nn.mm Store Indirect D-Register

The data register D nn.mm is used as a pointer. The content of the D-register is
therefore the address.
The command is only executed if RR = 1.
Indirect fetch and store instructions are always word-orientated. The pointer works in a
word-orientated way, too (16-bit address).
The diagrams below explain the functions of these instructions:

Instruction FIR D 03.14


Assume the value 0204 is present in the data register D 03.14. The contents of the R-
register R 03.14 will hence be read with the instruction FIR D 03.14. The data read
from R 02.04 (e.g. 9AB0) is then deposited in the MRR.

D 03.20 R 02.06 Fetch !


D 03.18 R 02.04 9 ABO 9 ABO
D 03.16 R 02.02 MRR
D 03.14 0204 R 02.00
Pointer

Instruction FID D 03.14


Assume the value 1560 is present in the data register D 03.14. The contents of the D-
register D 15.60 will hence be read with the instruction FID D 03.14. The data read
from D 15.60 (e.g. 2391) is then deposited in the MRR.

D 03.20 D 15.62 Fetch !


D 03.18 D 15.60 2391 2391
D 03.16 D 15.58 MRR
D 03.14 1560 D 15.56
Pointer

System manual, page 6.68 11.08.93, 396.0432


Programming technique Table-Look-Up operation

Instruction SIR D 03.14


Assume the value 0204 is present in the data register D 03.14. The R-register R 03.14
will hence be written to with the instruction SIR D 03.14. The data read from the MRR
(e.g. 9AB0) is then deposited in R 02.04.

D 03.20 R 02.06 Store !


D 03.18 R 02.04 9 ABO 9 ABO
D 03.16 R 02.02 MRR
D 03.14 0204 R 02.00
Pointer

Instruction SID D 03.14


Assume the value 1560 is present in the data register D 03.14. The data register D 15.60
will hence be written to with the instruction SID D 03.14. The data read from the MRR
(e.g. 2391) is then deposited in D 15.60.

D 03.20 D 15.62 Store !


D 03.18 D 15.60 2391 2391
D 03.16 D 15.58 MRR
D 03.14 1560 D 15.56
Pointer

The result register RR is not changed.


All D-registers (D 00.00 ... D 15.62) can be used as pointers.

11.08.93, 396.0432 System manual, page 6.69


Data output Programming technique

Data output
Data output via the RS 232 interface
The SELECONTROL® programming technique supports the output of data via the
RS 232C (V24) interface under software control.

Instruction: Remark:
SOH Serial out hex Output in hexadecimal form
SOD Serial out digit Output as ASCII characters

Data is written to the output buffer (FIFO) from the multi-bit result register (MRR) with
the operations SOH and SOD.
The output buffer can store a maximum of 256 characters.
One character is automatically transferred to the interface after each program cycle in
the I/O phase.
The commands are only executed if RR = 1.

The RR is affected by the execution of the commands as follows:


• RR = 1 : if the transfer to the output buffer was successful
• RR = 0 : if the transfer to the buffer was unsuccessful
(e.g. if the output buffer was full)

System manual, page 6.70 11.08.93, 396.0432


Programming technique Data output

Operation SOH; Serial out hex


The SOH operation reads the lower byte (bits 0 ... 7) out of the MRR and writes the
corresponding hex value (00...FF) into the output buffer.
The SOH operation is used to output letters (texts).

Program example
The character "A" should be presented on a display.
The ASCII table quotes a hex value of 41 for the character "A".
See ASCII table in appendix.

Line No. Operation Operand Remark


0000 L I 00.00 If input
0001 TRG M 16.00 Trigger auxiliary marker
0002 FTB 00041 Read constant 41
0003 SOH Output hex 41
0004 EP End of program

11.08.93, 396.0432 System manual, page 6.71


Data output Programming technique

Operation SOD; Serial out digit


The SOD operation reads the lower digit (bits 0 ... 4) out of the MRR and automatically
converts the content (0 ... F) into the hex value for the corresponding ASCII character.
The SOD operation is used to output the contents of data registers (e.g. counter
contents).

Program example
The contents of the data register D 15.60 should be output to an ASCII terminal every
second.

Line No. Operation Operand Remark


0000 L M 40.03 If clock = 1.0s
0001 TRG M 16.00 Trigger aux. marker
0002 FTW D 15.60 Read D in MRR (e.g. 4321)
0003 RTL Rotate left (MRR: 3214)
0004 SOD Output (4)
0005 RTL Rotate left (MRR: 2143)
0006 SOD Output (3)
0007 RTL Rotate left (MRR:1432)
0008 SOD Output (2)
0009 RTL Rotate left (MRR:4321)
0010 SOD Output (1)
0011 EP End of program

Since the display is written from left to right, the most significant digit has to be output
first.

System manual, page 6.72 11.08.93, 396.0432


Programming technique Jump operations

Jump operations
This possibilities of the SELECONTROL® programming technique enables freely
programmable PMC sequential routines to be prepared with arbitrary jumps backwards
and forwards.
The jump operations which follow are additional aids to program construction which
make it possible to skip parts of the program.

Instruction Remark
JP Jump unconditionally
JCT Jump conditionally on true
JCF Jump conditionally on false
LB LABEL (jump destination)
JS Jump to sub-routine
RET Return (from jump address)

The jump operations affect the cycle time; lengthening or shortening it as the case
might be.

Jump, conditioned by a certain being fulfilled


Instruction Remark
JCT Jump conditionally on true

The jump is executed only if the condition is fulfilled (RR = 1).


The jump is given by a label LB K 000kk (K 00 ... 99).

Example:
Line No. Operation Operand Remark
xxxx JCT K 000kk Jump to label LB K 000kk
(if condition is fulfilled)
Skipped program part
yyyy LB K 000kk Jump address label LB K 000kk

11.08.93, 396.0432 System manual, page 6.73


Jump operations Programming technique

Jump, conditioned by a state not being fulfilled


Instruction Remark
JCF Jump conditionally on false

The jump is executed if the condition is not fulfilled (RR = 0.)


The Jump address is given by a label LB K 000kk (K 00...99)
Maximum number of labels (LB): 100 (K 00000 ... 00099)

Unconditional jump
Instruction Remark
JP Unconditional jump

This jump is made, irrespective of the result of the preceding logic operation, to a jump
address given by a label (LB) in the program.

Example:
Line No. Operation Operand Remark
xxxx JP K 000kk Jump to label LB K 000kk
---- -- - -----
---- -- - ----- Skipped program part
---- -- - -----
yyyy LB K 000kk Jump address label LB K 000kk

System manual, page 6.74 11.08.93, 396.0432


Programming technique Jump operations

Program example:
A subsequent part of the program has to be skipped if the input I 00.00 has been
activated.
Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 JCT K 00027 Jump program part till label 27
0002 L M 40.03 If clock 1.0 sec.
0003 CU D 15.56 Count up
0004 L I 00.00 If input
0005 = O 01.00 Then output
0006 LB K 00027 Label (jump mark) 27
0007 EP End of program

Logic operations in the jumped part of the program are executed and RR is changed.
Multi-bit operations are not executed and neither are the instructions =, =N, S, STW,
STB, STD, etc.

Only forward jumps can be made with the JP, JCT and JCF commands. Backward
jumps would conflict with the scanner principle. If the jump destination (label) is not
given at all, or is not given before the jump instruction, the following part of the
program up to the EP will be jumped.

Note: • Jump routines affect the program cycle time.


• EP (end of program) and RET (end of sub-routine) instructions cannot
be skipped.

11.08.93, 396.0432 System manual, page 6.75


Jump operations Programming technique

Nesting and over-lapping of jumps as well as common jump destinations (label LB) are
generally permissible for various jumps.

Line No. Nesting Over-lapping Common jump destination


wwww JCT K 1 JCT K 1 JCT K 1
---- --- - - --- - - --- - -
---- --- - - --- - - --- - -
---- --- - - --- - - --- - -
xxxx JCF K 2 JP K 2 JP K 1
---- --- - - --- - - --- - -
---- --- - - --- - - --- - -
---- --- - - --- - - --- - -
yyyy LB K 2 LB K 1 JCF K 1
---- --- - - --- - - --- - -
---- --- - - --- - - --- - -
---- --- - - --- - - --- - -
zzzz LB K 1 LB K 2 LB K 1

Jump to a sub-routine
Instruction: Remark
JS Jump to a sub-routine

Note: Basically, only one sub-routine can be included.


The JS instruction has the effect of causing a jump to be made to the line
number 0000.
• The start of a sub-routine is always 0000.
• The end of the sub-routine is indicated by a RET (return)
instruction.
• RET causes a jump to be made to the next program line following
that from which the JS (Jump Sub-routine) operation was started.

System manual, page 6.76 11.08.93, 396.0432


Programming technique Jump operations

Example:
Line No. Operation Remark

0000 XX Start of sub-routine


---- ---
---- ---
Sub-routine ---
---- ---
---- ---
xxxx RET End of sub-routine
---- ---
---- ---
yyyy JS First jump to subroutine
---- ---
---- ---
zzzz JS Second jump to sub-routine

The sub-routine can be called any number of times. The cycle time will, however, be
extended.
Time-critical processes can be controlled by means of the sub- routine command. The
sub-routine acts as a fast scanner within the main scanner i.e. it is a short program that
can be called at the critical moment.

11.08.93, 396.0432 System manual, page 6.77


Jump operations Programming technique

Program example:
Line No. Operation Operand Remark
0000 L I 00.00 If input
0001 AN M 16.00 And Not marker
0002 FTW D 15.60 Read data register
0003 ADD K 00001 Add constant
0004 STW D 15.60 Write to data register
0005 RET End of sub-routine
0006 NOP
0007 JS Jump to sub-routine
0008 NOP
0009 JS Jump to sub-routine
0010 NOP
0011 L I 00.00 If input
0012 AN M 16.00 And not marker
0013 FTW D 15.56 Read data register
0014 ADD K 00001 Add constant
0015 STW D 15.56 Write to data register
0016 S M 16.00 Set inhibiting marker
0017 EP End of program

Once the input I 00.00 has been activated the sub-routine (lines 0000 ... 0005) will be
executed three times after which the data register D 15.60 will have the value 3.
After the last part of the program (lines 0006 ... 0017) has been executed, the value in
register D 15.56 will be 1 and the inhibiting marker M 16.00 will be set.
The operations FTW, ADD and STW will not be executed in any following program
cycles.

Note: The RET (return) instruction cannot be skipped.

System manual, page 6.78 11.08.93, 396.0432

You might also like