Bit Logic Instructions Overview
Bit Logic Instructions Overview
Description
Bit logic instructions work with two digits, 1 and 0. These two digits form the base
of a number system called the binary system. The two digits 1 and 0 are called
binary digits or bits. In the world of contacts and coils, a 1 indicates activated or
energized, and a 0 indicates not activated or not energized.
The bit logic instructions interpret signal states of 1 and 0 and combine them
according to Boolean logic. These combinations produce a result of 1 or 0 that is
called the “result of logic operation” (RLO).
The logic operations that are triggered by the bit logic instructions perform a variety
of functions.
There are bit logic instructions to perform the following functions:
---| |--- Normally Open Contact (Address)
---| / |--- Normally Closed Contact (Address)
---(SAVE) Save RLO into BR Memory
XOR Bit Exclusive OR
---( ) Output Coil
---( # )--- Midline Output
---|NOT|--- Invert Power Flow
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 1 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<address>
---| |---
Description
---| |--- (Normally Open Contact) is closed when the bit value stored at the specified
<address> is equal to "1". When the contact is closed, ladder rail power flows
across the contact and the result of logic operation (RLO) = "1".
Otherwise, if the signal state at the specified <address> is "0", the contact is open.
When the contact is open, power does not flow across the contact and the result of
logic operation (RLO) = "0".
When used in series, ---| |--- is linked to the RLO bit by AND logic. When used in
parallel, it is linked to the RLO by OR logic.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - X X X 1
Example
I 0.0 I 0.1
I 0.2
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 2 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<address>
---| / |---
Description
---| / |--- (Normally Closed Contact) is closed when the bit value stored at the
specified <address> is equal to "0". When the contact is closed, ladder rail power
flows across the contact and the result of logic operation (RLO) = "1".
Otherwise, if the signal state at the specified <address> is "1", the contact is
opened. When the contact is opened, power does not flow across the contact and
the result of logic operation (RLO) = "0".
When used in series, ---| / |--- is linked to the RLO bit by AND logic. When used in
parallel, it is linked to the RLO by OR logic.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - X X X 1
Example
I 0.0 I 0.1
I 0.2
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 3 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbols
<address1> <address2>
<address1> <address2>
Description
XOR (Bit Exclusive OR) creates an RLO of "1" if the signal state of the two
specified bits is different.
Example
I 0.0 I 0.1
The output Q4.0 is "1" if (I0.0 = "0" AND I0.1 = "1") OR (I0.0 = "1" AND I0.1 = "0").
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 4 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
---|NOT|---
Description
---|NOT|--- (Invert Power Flow) negates the RLO bit.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - - 1 X -
Example
I 0.0 Q 4.0
NOT
I 0.1 I 0.2
The signal state of output Q4.0 is "0" if one of the following conditions exists:
The signal state is "1" at input I0.0
Or the signal state is "1" at inputs I0.1 and I0.2.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 5 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<address>
---( )
Description
---( ) (Output Coil) works like a coil in a relay logic diagram. If there is power flow to
the coil (RLO = 1), the bit at location <address> is set to "1". If there is no power flow
to the coil (RLO = 0), the bit at location <address> is set to "0". An output coil can
only be placed at the right end of a ladder rung. Multiple output elements (max.
16) are possible (see example). A negated output can be created by using the ---
|NOT|--- (invert power flow) element.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 X - 0
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 6 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
The signal state of output Q4.0 is "1" if one of the following conditions exists:
The signal state is "1" at inputs I0.0 AND I0.1
OR the signal state is "0" at input I0.2.
The signal state of output Q4.1 is "1" if one of the following conditions exists:
The signal state is "1" at inputs I0.0 AND I0.1
OR the signal state is "0" at input I0.2 AND "1" at input I0.3
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 7 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<address>
---( # )---
Description
---( # )--- (Midline Output) is an intermediate assigning element which saves the
RLO bit (power flow status) to a specified <address>. The midline output element
saves the logical result of the preceding branch elements. In series with other
contacts, ---( # )--- is inserted like a contact. A ---( # )--- element may never be
connected to the power rail or directly after a branch connection or at the end of a
branch. A negated ---( # )--- can be created by using the ---|NOT|--- (invert power
flow) element.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 X - 1
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 8 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
I 1.0 I 1.1 M 0.0 I 2.2 I 1.3 M 1.1 M 2.2 Q 4.0
I 1.0 I 1.1
M 0.0 has the RLO
I 1.0 I 1.1 I 2.2 I 1.3
Symbol
<address>
---( R )
Description
---( R ) (Reset Coil) is executed only if the RLO of the preceding instructions is "1"
(power flows to the coil). If power flows to the coil (RLO is "1"), the specified
<address> of the element is reset to "0". A RLO of "0" (no power flow to the coil)
has no effect and the state of the element's specified address remains unchanged.
The <address> may also be a timer (T no.) whose timer value is reset to "0" or a
counter (C no.) whose counter value is reset to "0".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 9 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 X - 0
Example
Network 1
I 0.2
Network 2
I 0.3 T1
R
Network 3
I 0.4 C1
R
The signal state of output Q4.0 is reset to "0" if one of the following conditions
exists:
The signal state is "1" at inputs I0.0 and I0.1
Or the signal state is "0" at input I0.2.
If the RLO is "0", the signal state of output Q4.0 remains unchanged.
The signal state of timer T1 is only reset if:
the signal state is "1" at input I0.3.
The signal state of counter C1 is only reset if:
the signal state is "1" at input I0.4.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 10 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<address>
---( S )
Description
---( S ) (Set Coil) is executed only if the RLO of the preceding instructions is "1"
(power flows to the coil). If the RLO is "1" the specified <address> of the element is
set to "1".
An RLO = 0 has no effect and the current state of the element's specified address
remains unchanged.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 X - 0
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 11 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
I 0.0 I 0.1 Q 4.0
S
I 0.2
The signal state of output Q4.0 is "1" if one of the following conditions exists:
The signal state is "1" at inputs I0.0 and I0.1
Or the signal state is "0" at input I0.2.
If the RLO is "0", the signal state of output Q4.0 remains unchanged.
Symbol
<address>
RS
S Q
R
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 12 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Description
RS (Reset-Set Flip Flop) is reset if the signal state is "1" at the R input, and "0" at the
S input. Otherwise, if the signal state is "0" at the R input and "1" at the S input, the
flip flop is set. If the RLO is "1" at both inputs, the order is of primary importance. The
RS flip flop executes first the reset instruction then the set instruction at the specified
<address>, so that this address remains set for the remainder of program scanning.
The S (Set) and R (Reset) instructions are executed only when the RLO is "1".
RLO "0" has no effect on these instructions and the address specified in the
instruction remains unchanged.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - x x x 1
Example
M 0.0 Q 4.0
I 0.0
RS
R Q
I 0.1
S
If the signal state is "1" at input I0.0 and "0" at I0.1, memory bit M0.0 is set and output
Q4.0 is "0". Otherwise, if the signal state at input I0.0 is "0" and at I0.1 is "1", memory
bit M0.0 is reset and output Q4.0 is "1". If both signal states are "0", nothing is
changed. If both signal states are "1", the set instruction dominates because of the
order; M0.0 is set and Q4.0 is "1".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 13 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<address>
SR
S Q
R
Description
SR (Set-Reset Flip Flop) is set if the signal state is "1" at the S input, and "0" at the R
input. Otherwise, if the signal state is "0" at the S input and "1" at the R input, the flip
flop is reset. If the RLO is "1" at both inputs, the order is of primary importance. The
SR flip flop executes first the set instruction then the reset instruction at the specified
<address>, so that this address remains reset for the remainder of program
scanning.
The S (Set) and R (Reset) instructions are executed only when the RLO is "1".
RLO "0" has no effect on these instructions and the address specified in the
instruction remains unchanged.
Status word
BR CC1 CC0 OV OS OR STA RLO /FC
writes: - - - - - x x x 1
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 14 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
M 0.0 Q 4.0
I 0.0
SR
S Q
I 0.1
R
If the signal state is "1" at input I0.0 and "0" at I0.1, memory bit M0.0 is set and output
Q4.0 is "1". Otherwise, if the signal state at input I0.0 is "0" and at I0.1 is "1", memory
bit M0.0 is reset and output Q4.0 is "0". If both signal states are "0", nothing is
changed. If both signal states are "1", the reset instruction dominates because of the
order; M0.0 is reset and Q4.0 is "0".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 15 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<address>
---( N )
Description
---( N )--- (Negative RLO Edge Detection) detects a signal change in the address
from "1" to "0" and displays it as RLO = "1" after the instruction. The current signal
state in the RLO is compared with the signal state of the address, the edge memory
bit. If the signal state of the address is "1" and the RLO was "0" before the
instruction, the RLO will be "1" (pulse) after this instruction, and "0" in all other cases.
The RLO prior to the instruction is stored in the address.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 x x 1
Example
I 0.2
The edge memory bit M0.0 saves the old RLO state. When there is a signal
change at the RLO from "1" to "0", the program jumps to label CAS1.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 16 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<address>
---( P )---
Description
---( P )--- (Positive RLO Edge Detection) detects a signal change in the address from
"0" to "1" and displays it as RLO = "1" after the instruction. The current signal state in
the RLO is compared with the signal state of the address, the edge memory bit. If the
signal state of the address is "0" and the RLO was "1" before the instruction, the
RLO will be "1" (pulse) after this instruction, and "0" in all other cases. The RLO prior
to the instruction is stored in the address.
Status word
BR CC1 CC0 OV OS OR STA RLO /FC
writes: - - - - - 0 X X 1
Example
The edge memory bit M0.0 saves the old RLO state. When there is a signal
change at the RLO from "0" to "1", the program jumps to label CAS1.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 17 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
---( SAVE )
Description
---(SAVE) (Save RLO into BR Memory) saves the RLO to the BR bit of the status
word. The first check bit /FC is not reset. For this reason, the status of the BR bit is
included in the AND logic operation in the next network.
For the instruction "SAVE" (LAD, FBD, STL), the following applies and not the
recommended use specified in the manual and online help:
We do not recommend that you use SAVE and then check the BR bit in the same
block or in subordinate blocks, because the BR bit can be modified by many
instructions occurring inbetween. It is advisable to use the SAVE instruction before
exiting a block, since the ENO output (= BR bit) is then set to the value of the RLO
bit and you can then check for errors in the block.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: X - - - - - - - -
Example
I 0.0 I 0.1
SAVE
I 0.2
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 18 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<address1>
NEG
Q
<address2> M_BIT
Description
NEG (Address Negative Edge Detection) compares the signal state of <address1>
with the signal state from the previous scan, which is stored in <address2>. If the
current RLO state is "1" and the previous state was "0" (detection of rising edge), the
RLO bit will be "1" after this instruction.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: x - - - - x 1 x 1
Example
I 0.3
I 0.0 I 0.1 I 0.2 NEG I 0.4 Q 4.0
Q ( )
M 0.0 M_BIT
The signal state at output Q4.0 is "1" if the following conditions exist:
The signal state is "1" at inputs I0.0 and I0.1 and I0.2
And there is a negative edge at input I0.3
And the signal state is "1" at input I0.4
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 19 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<address1>
POS
Q
<address2> M_BIT
Description
POS (Address Positive Edge Detection) compares the signal state of <address1>
with the signal state from the previous scan, which is stored in <address2>. If the
current RLO state is "1" and the previous state was "0" (detection of rising edge),
the RLO bit will be "1" after this instruction.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: x - - - - x 1 x 1
Example
I 0.3
I 0.0 I 0.1 I 0.2 POS I 0.4 Q 4.0
Q ( )
M 0.0 M_BIT
The signal state at output Q4.0 is "1" if the following conditions exist:
The signal state is "1" at inputs I0.0 and I0.1 and I0.2
And there is a positive edge at input I0.3
And the signal state is "1" at input I0.4
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 20 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Description
For the Immediate Read function, a network of symbols must be created as shown
in the example below.
For time-critical applications, the current state of a digital input may be read faster
than the normal case of once per OB1 scan cycle. An Immediate Read gets the state
of a digital input from an input module at the time the Immediate Read rung is
scanned. Otherwise, you must wait for the end of the next OB1 scan cycle when the I
memory area is updated with the P memory state.
To perform an immediate read of an input (or inputs) from an input module, use the
peripheral input (PI) memory area instead of the input (I) memory area. The
peripheral input memory area can be read as a byte, a word, or a double word.
Therefore, a single digital input cannot be read via a contact (bit) element.
To conditionally pass voltage depending on the status of an immediate input:
1. A word of PI memory that contains the input data of concern is read by the
CPU.
2. The word of PI memory is then ANDed with a constant that yields a non-zero
result if the input bit is on ("1").
3. The accumulator is tested for non-zero condition.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 21 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
Ladder Network with Immediate Read of Peripheral Input I1.1
* MWx has to be specified in order to be able to store the network. x may be any
permitted number.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 22 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Description
For the Immediate Write function, a network of symbols must be created as shown in
the example below.
For time-critical applications, the current state of a digital output may have to be sent
to an output module faster than the normal case of once at the end of the OB1 scan
cycle. An Immediate Write writes to a digital output to a input module at the time the
Immediate Write rung is scanned. Otherwise, you must wait for the end of the next
OB1 scan cycle when the Q memory area is updated with the P memory state.
To perform an immediate write of an output (or outputs) to an output module, use
the peripheral output (PQ) memory area instead of the output (Q) memory area. The
peripheral output memory area can be read as a byte, a word, or a double word.
Therefore, a single digital output cannot be updated via a coil element. To write the
state of a digital output to an output module immediately, a byte, word, or double
word of Q memory that contains the relevant bit is conditionally copied to the
corresponding PQ memory (direct output module addresses).
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 23 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
Ladder network equivalent of Immediate Write to peripheral digital output
module 5, channel 1.
The bit states of the addressed output Q byte (QB5) are either modified or left
unchanged. Q5.1 is assigned the signal state of I0.1 in network 1. QB5 is copied to
the corresponding direct peripheral output memory area (PQB5).
The word PIW1 contains the immediate status of I1.1. PIW1 is ANDed with
W#16#0002. The result is not equal to zero if I1.1 (second bit) in PB1 is true ("1").
The contact A<>0 passes voltage if the result of the WAND_W instruction is not
equal to zero.
Network 1
I 0.1 Q 5.1
Network 2
MOVE
EN ENO
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 24 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
2 Move Instructions
2.1 MOVE Assign a Value
Symbol
MOVE
EN ENO
IN OUT
Description
MOVE (Assign a Value) is activated by the Enable EN Input. The value specified at
the IN input is copied to the address specified at the OUT output. ENO has the same
logic state as EN. MOVE can copy only BYTE, WORD, or DWORD data objects.
User-defined data types like arrays or structures have to be copied with
the system function "BLKMOVE" (SFC 20).
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: 1 - - - - 0 1 1 1
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 25 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Note
When moving a value to a data type of a different length, higher-value bytes are
truncated as necessary or filled up with zeros:
Example: Double Word 1111 1111 0000 1111 1111 0000 0101 0101
Move Result
to a double word: 1111 1111 0000 1111 1111 0000 0101 0101
to a byte: 0101 0101
to a word: 1111 0000 0101 0101
Example
The instruction is executed if I0.0 is "1". The content of MW10 is copied to data
word 12 of the currently open DB.
Q4.0 is "1" if the instruction is executed.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 26 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
3 Timer Instructions
Description
You can find information for setting and selecting the correct time under "Location
of a Timer in Memory and Components of a Timer".
The following timer instructions are available:
S_PULSE Pulse S5 Timer
S_PEXT Extended Pulse S5 Timer
S_ODT On-Delay S5 Timer
S_ODTS Retentive On-Delay S5 Timer
S_OFFDT Off-Delay S5 Timer
---( SP ) Pulse Timer Coil
---( SE ) Extended Pulse Timer Coil
---( SD ) On-Delay Timer Coil
---( SS ) Retentive On-Delay Timer Coil
---( SA ) Off-Delay Timer Coil
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 27 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Area in Memory
Timers have an area reserved for them in the memory of your CPU. This memory
area reserves one 16-bit word for each timer address. The ladderlogic instruction
set supports 256 timers. Please refer to your CPU’s technical information to
establish the number of timer words available.
The following functions have access to the timer memory area:
Timer instructions
Updating of timer words by means of clock timing. This function of your CPU in
the RUN mode decrements a given time value by one unit at the interval
designated by the time base until the time value is equal to zero.
Time Value
Bits 0 through 9 of the timer word contain the time value in binary code. The time
value specifies a number of units. Time updating decrements the time value by one
unit at an interval designated by the time base. Decrementing continues until the time
value is equal to zero. You can load a time value into the low word of accumulator 1
in binary, hexadecimal, or binary coded decimal (BCD) format.
You can pre-load a time value using either of the following formats:
W#16#wxyz
- Where w = the time base (that is, the time interval or resolution)
- Where xyz = the time value in binary coded decimal format
S5T#aH_bM_cS_dMS
- Where H = hours, M = minutes, S = seconds, and MS = milliseconds;
a, b, c, d are defined by the user.
- The time base is selected automatically, and the value is rounded to the
next lower number with that time base.
The maximum time value that you can enter is 9,990 seconds, or 2H_46M_30S.
S5TIME#4S = 4 seconds
s5t#2h_15m = 2 hours and 15 minutes
S5T#1H_12M_18S = 1 hour, 12 minutes, and 18 seconds
Time Base
Bits 12 and 13 of the timer word contain the time base in binary code. The time
base defines the interval at which the time value is decremented by one unit. The
smallest time base is 10 ms; the largest is 10 s.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 28 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Values that exceed 2h46m30s are not accepted. A value whose resolution is too
high for the range limits (for example, 2h10ms) is truncated down to a valid
resolution. The general format for S5TIME has limits to range and resolution as
shown below:
Resolution Range
0.01 second 10MS to 9S_990MS
0.1 second 100MS to 1M_39S_900MS
1 second 1S to 16M_39S
10 seconds 10S to 2H_46M_30S
1 2 7
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 29 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
I 0.0
Q 4.0 S_PULSE
Q 4.0 S_PEXT
Q 4.0 S_ODT
Q 4.0 S_ODTS
Q 4.0 S_OFFDT
t
Timer Description
S_PULSE The maximum time that the output signal remains at 1 is the
Pulse timer same as the programmed time value t. The output signal stays
at 1 for a shorter period if the input signal changes to 0.
S_PEXT The output signal remains at 1 for the programmed length of
Extended pulse timer time, regardless of how long the input signal stays at 1.
S_ODT The output signal changes to 1 only when the programmed time
On-delay timer has elapsed and the input signal is still 1.
S_ODTS The output signal changes from 0 to 1 only when the
Retentive on-delay timer programmed time has elapsed, regardless of how long the input
signal stays at 1.
S_OFFDT The output signal changes to 1 when the input signal changes to
Off-delay timer 1 or while the timer is running. The time is started when the input
signal changes from 1 to 0.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 30 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
T no. T-Nr.
S_PULSE S_IMPULS
S Q S Q
TV BI TW DUAL
R BCD R DEZ
Description
S_PULSE (Pulse S5 Timer) starts the specified timer if there is a positive edge at the
start (S) input. A signal change is always necessary in order to enable a timer. The
timer runs as long as the signal state at input S is "1", the longest period, however, is
the time value specified by input TV. The signal state at output Q is "1" as long as
the timer is running. If there is a change from "1" to "0" at the S input before the time
interval has elapsed the timer will be stopped. In this case the signal state at output
Q is "0".
The timer is reset when the timer reset (R) input changes from "0" to "1" while the
timer is running. The current time and the time base are also set to zero. Logic "1"
at the timer's R input has no effect if the timer is not running.
The current time value can be scanned at the outputs BI and BCD. The time value
at BI is binary coded, at BCD it is BCD coded. The current time value is the initial TV
value minus the time elapsed since the timer was started.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 31 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Timing Diagram
Pulse timer characteristics:
t t t
RLO at S input
RLO at R input
Timer running
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - x x x 1
Example
T5
I 0.0 S_PULSE S Q 4.0
Q
I 0.1 S5TIME#2S TV BI
R BCD
If the signal state of input I0.0 changes from "0" to "1" (positive edge in RLO), the
timer T5 will be started. The timer will continue to run for the specified time of two
seconds (2 s) as long as I0.0 is "1". If the signal state of I0.0 changes from "1" to
"0" before the timer has expired the timer will be stopped. If the signal state of input
I0.1 changes from "0" to "1" while the timer is running, the time is reset.
The output Q4.0 is logic "1" as long as the timer is running and "0" if the time has
elapsed or was reset.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 32 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
T no. T-Nr.
S_PEXT S_VIMP
S Q S Q
TV BI TW DUAL
R BCD R DEZ
Description
S_PEXT (Extended Pulse S5 Timer) starts the specified timer if there is a positive
edge at the start (S) input. A signal change is always necessary in order to enable a
timer. The timer runs for the preset time interval specified at input TV even if the
signal state at the S input changes to "0" before the time interval has elapsed. The
signal state at output Q is "1" as long as the timer is running. The timer will be
restarted ("re-triggered") with the preset time value if the signal state at input S
changes from "0" to "1" while the timer is running.
The timer is reset if the reset (R) input changes from "0" to "1" while the timer is
running. The current time and the time base are set to zero.
The current time value can be scanned at the outputs BI and BCD. The time value at
BI is binary coded, at BCD is BCD coded. The current time value is the initial TV
value minus the time elapsed since the timer was started.
See also "Location of a Timer in Memory and Components of a Timer".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 33 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Timing Diagram
Extended pulse timer characteristics:
t t t t
RLO at S input
RLO at R input
Timer running
Scan for "1"
Scan for "0"
t = Programmed time
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - x x x 1
Example
T5
I 0.0 S_PEXT Q 4.0
S Q
S5TIME#2S TV BI
I 0.1
R BCD
If the signal state of input I0.0 changes from "0" to "1" (positive edge in RLO), the
timer T5 will be started. The timer will continue to run for the specified time of two
seconds (2 s) without being affected by a negative edge at input S. If the signal
state of I0.0 changes from "0" to "1" before the timer has expired the timer will be
re-triggered. The output Q4.0 is logic "1" as long as the timer is running.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 34 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
T no. T-Nr.
S_ODT S_EVERZ
S Q S Q
TV BI TW DUAL
R BCD R DEZ
Description
S_ODT (On-Delay S5 Timer) starts the specified timer if there is a positive edge at
the start (S) input. A signal change is always necessary in order to enable a timer.
The timer runs for the time interval specified at input TV as long as the signal state at
input S is positive. The signal state at output Q is "1" when the timer has elapsed
without error and the signal state at the S input is still "1". When the signal state at
input S changes from "1" to "0" while the timer is running, the timer is stopped. In this
case the signal state of output Q is "0".
The timer is reset if the reset (R) input changes from "0" to "1" while the timer is
running. The current time and the time base are set to zero. The signal state at output
Q is then "0". The timer is also reset if there is a logic "1" at the R input while the
timer is not running and the RLO at input S is "1".
The current time value can be scanned at the outputs BI and BCD. The time value at
BI is binary coded, at BCD is BCD coded. The current time value is the initial TV
value minus the time elapsed since the timer was started.
See also "Location of a Timer in Memory and Components of a Timer".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 35 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Timing Diagram
On-Delay timer characteristics:
t t t
RLO at S input
RLO at R input
Timer running
Scan for "1"
Scan for "0"
t = Programmed time
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - x x x 1
Example
T5
I 0.0 S_ODT Q 4.0
S Q
I 0.1 S5TIME#2S TV BI
R BCD
If the signal state of I0.0 changes from "0" to "1" (positive edge in RLO), the timer
T5 will be started. If the time of two seconds elapses and the signal state at input
I0.0 is still "1", the output Q4.0 will be "1". If the signal state of I0.0 changes from
"1" to "0", the timer is stopped and Q4.0 will be "0" (if the signal state of I0.1 changes
from "0" to "1", the time is reset regardless of whether the timer is running or not).
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 36 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
T no. T-Nr.
S_ODTS S_SEVERZ
S Q S Q
TV BI TW DUAL
R BCD R DEZ
Description
S_ODTS (Retentive On-Delay S5 Timer) starts the specified timer if there is a
positive edge at the start (S) input. A signal change is always necessary in order to
enable a timer. The timer runs for the time interval specified at input TV even if the
signal state at input S changes to "0" before the time interval has elapsed. The signal
state at output Q is "1" when the timer has elapsed without regard to the signal state
at input S. The timer will be restarted (re-triggered) with the specified time if the
signal state at input S changes from "0" to "1" while the timer is running. The timer is
reset if the reset (R) input changes from "0" to "1" without regard to the RLO at the S
input. The signal state at output Q is then "0".
The current time value can be scanned at the outputs BI and BCD. The time value
at BI is binary coded, at BCD it is BCD coded. The current time value is the initial TV
value minus the time elapsed since the timer was started.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 37 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Timing Diagram
Retentive On-Delay timer characteristics:
t t t t
RLO at S input
RLO at R input
Timer running
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - x x x 1
Example
T5
I 0.0 S_ODTS Q 4.0
S Q
S5TIME#2S TV BI
I 0.1
R BCD
If the signal state of I0.0 changes from "0" to "1" (positive edge in RLO), the timer T5
will be started. The timer runs without regard to a signal change at I0.0 from "1" to
"0". If the signal state at I0.0 changes from "0" to "1" before the timer has expired,
the timer will be re-triggered. The output Q4.0 will be "1" if the timer elapsed. (If the
signal state of input I0.1 changes from "0" to "1", the time will be reset irrespective of
the RLO at S.)
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 38 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
T no. T-Nr.
S_OFFDT S_AVERZ
S Q S Q
TV BI TW DUAL
R BCD R DEZ
Description
S_OFFDT (Off-Delay S5 Timer) starts the specified timer if there is a negative edge
at the start (S) input. A signal change is always necessary in order to enable a
timer. The signal state at output Q is "1" if the signal state at the S input is "1" or
while the timer is running. The timer is reset when the signal state at input S goes
from "0" to "1" while the timer is running. The timer is not restarted until the signal
state at input S changes again from "1" to "0".
The timer is reset when the reset (R) input changes from "0" to "1" while the timer is
running.
The current time value can be scanned at the outputs BI and BCD. The time value
at BI is binary coded, at BCD it is BCD coded. The current time value is the initial TV
value minus the time elapsed since the timer was started.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 39 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Timing Diagram
Off-Delay timer characteristics:
t t t
RLO at S input
RLO at R input
Timer running
Scan for "1"
Scan for "0"
t = Programmed time
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - x x x 1
Example
T5
I 0.0 S_OFFDT S Q 4.0
Q
S5TIME#2S TV BI
I 0.1
R BCD
If the signal state of I0.0 changes from "1" to "0", the timer is started.
Q4.0 is "1" when I0.0 is "1" or the timer is running. (if the signal state at I0.1
changes from "0" to "1" while the time is running, the timer is reset).
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 40 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
<T no..> <T no.>
---( SP ) ---( SI )
<time value> <time value>
Description
---( SP ) (Pulse Timer Coil) starts the specified timer with the <time value> when
there is a positive edge on the RLO state. The timer continues to run for the
specified time interval as long as the RLO remains positive ("1"). The signal state of
the counter is ”1” as long as the timer is running. If there is a change from "1" to
"0" in the RLO before the time value has elapsed, the timer will stop. In this case, a
scan for "1" always produces the result "0".
See also "Location of a Timer in Memory and Components of a Timer" and
S_PULSE (Pulse S5 Timer).
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 - - 0
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 41 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
Network 1
I 0.0 T5
SP
S5T#2S
Network 2
T5 Q 4.0
Network 3
I 0.1 T5
R
If the signal state of input I0.0 changes from "0" to "1" (positive edge in RLO), the
timer T5 is started. The timer continues to run with the specified time of two seconds
as long as the signal state of input I0.0 is "1". If the signal state of input I0.0 changes
from "1" to "0" before the specified time has elapsed, the timer stops. The signal
state of output Q4.0 is "1" as long as the timer is running. A signal state change from
"0" to "1" at input I0.1 will reset timer T5 which stops the timer and clears the
remaining portion of the time value to "0".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 42 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
<T no.> <T no>
---( SE ) ---( SV )
<time value> <time value>
Description
---( SE ) (Extended Pulse Timer Coil) starts the specified timer with the specified
<time value> when there is a positive edge on the RLO state. The timer continues to
run for the specified time interval even if the RLO changes to "0" before the timer has
expired. The signal state of the counter is ”1” as long as the timer is running. The
timer will be restarted (re-triggered) with the specified time value if the RLO changes
from "0" to "1" while the timer is running.
See also "Location of a Timer in Memory and Components of a Timer" and
S_PEXT (Extended Pulse S5 Timer).
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 - - 0
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 43 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
Network 1
I 0.0 T5
SE
S5T#2S
Network 2
T5 Q A.0
Network 3
I 0.1 T5
R
If the signal state of input I0.0 changes from "0" to "1" (positive edge in RLO), the
timer T5 is started. The timer continues to run without regard to a negative edge of
the RLO. If the signal state of I0.0 changes from "0" to "1" before the timer has
expired, the timer is re-triggered.
The signal state of output Q4.0 is "1" as long as the timer is running. A signal state
change from "0" to "1" at input I0.1 will reset timer T5 which stops the timer and
clears the remaining portion of the time value to "0".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 44 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
<T no.> <T no.>
---( SD ) ---( SE )
<time value> <time value>
Description
---( SD ) (On Delay Timer Coil) starts the specified timer with the <time value> if
there is a positive edge on the RLO state. The signal state of the timer is "1" when
the <time value> has elapsed without error and the RLO is still "1". When the RLO
changes from "1" to "0" while the timer is running, the timer is reset. In this case, a
scan for "1" always produces the result "0".
See also "Location of a Timer in Memory and Components of a Timer" and S_ODT
(On-Delay S5 Timer).
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 - - 0
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 45 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
Network 1
I 0.0 T5
SD
S5T#2S
Network 2
T5 Q A.0
Network 3
I 0.1 T5
R
If the signal state of input I0.0 changes from "0" to "1" (positive edge in RLO), the
timer T5 is started. If the time elapses and the signal state of input I0.0 is still "1",
the signal state of output Q4.0 will be "1".
If the signal state of input I0.0 changes from "1" to "0", the timer remains idle and the
signal state of output Q4.0 will be "0". A signal state change from "0" to "1" at input
I0.1 will reset timer T5 which stops the timer and clears the remaining portion of the
time value to "0".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 46 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
<T no.> <T no.>
---( SS ) ---( SS )
<time value> <time value>
Description
---( SS ) (Retentive On-Delay Timer Coil) starts the specified timer if there is a
positive edge on the RLO state. The signal state of the timer is "1" if the time value
has elapsed. A restart of the timer is only possible if it is reset explicitly. Only a reset
causes the signal state of the timer to be set to "0".
The timer restarts with the specified time value if the RLO changes from "0" to "1"
while the timer is running.
See also "Location of a Timer in Memory and Components of a Timer" and
S_ODTS (Retentive On-Delay S5 Timer).
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 - - 0
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 47 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
Network 1
I 0.0 T5
SS
S5T#2S
Network 2
T5 Q A.0
Network 3
I 0.1 T5
R
If the signal state of input I0.0 changes from "0" to "1" (positive edge in RLO), the
timer T5 is started. If the signal state of input I0.0 changes from "0" to "1" before
the timer has expired, the timer is re-triggered. The output Q4.0 will be "1" if the
timer elapsed. A signal state "1" at input I0.1 will reset timer T5, which stops the
timer and clears the remaining portion of the time value to "0".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 48 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
<T no.> <T no.>
---( SF ) ---( SA )
<time value> <time value>
Description
---( SF ) (Off-Delay Timer Coil) starts the specified timer if there is a negative edge
on the RLO state. The timer is "1" when the RLO is "1" or as long as the timer is
running during the <time value> interval. The timer is reset when the RLO goes
from "0" to "1" while the timer is running. The timer is always restarted when the
RLO changes from "1" to "0".
See also "Location of a Timer in Memory and Components of a Timer" and
S_OFFDT (Off-Delay S5 Timer).
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 - - 0
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 49 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
Network 1
I 0.0 T5
SF
S5T#2S
Network 2
T5 Q A.0
Network 3
I 0.1 T5
R
If the signal state of input I0.0 changes from "1" to "0" the timer is started.
The signal state of output Q4.0 is "1" when input I0.0 is "1" or the timer is running.
A signal state change from "0" to "1" at input I0.1 will reset timer T5 which stops the
timer and clears the remaining portion of the time value to "0".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 50 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
4 Counter Instructions
4.1 Overview of Counter Instructions
Area in Memory
Counters have an area reserved for them in the memory of your CPU. This memory
area reserves one 16-bit word for each counter address. The ladder logic instruction
set supports 256 counters.
The counter instructions are the only functions that have access to the counter
memory area.
Count Value
Bits 0 through 9 of the counter word contain the count value in binary code. The
count value is moved to the counter word when a counter is set. The range of the
count value is 0 to 999.
You can vary the count value within this range by using the following counter
instructions:
S_CUD Up-Down Counter
S_CD Down Counter
S_CU Up Counter
---( SC ) Set Counter Coil
---( CU ) Up Counter Coil
---( CD ) Down Counter Coil
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 51 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
15 14 13 12 11 10 9 7
8 6 5
4 3 2 1 0
0 0 0 0
1 0 1
0 0 1 1 1
irrelevant 1 2 7
15 14 13 12 11 10 9 7
8 6 5
4 3 2 1 0
0 0 1 1 1 1 1 1
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 52 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
C no. Z no.
S_CUD ZAEHLER
CU Q ZV Q
CD ZR
S CV S DUAL
PV CV_BCD ZW DEZ
R R
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 53 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Description
S_CUD (Up-Down Counter) is preset with the value at input PV if there is a positive
edge at input S. If there is a 1 at input R, the counter is reset and the count is set to
zero. The counter is incremented by one if the signal state at input CU changes from
"0" to "1" and the value of the counter is less than "999". The counter is decremented
by one if there is a positive edge at input CD and the value of the counter is greater
than "0".
If there is a positive edge at both count inputs, both instructions are executed and
the count value remains unchanged.
If the counter is set and if RLO = 1 at the inputs CU/CD, the counter will count
accordingly in the next scan cycle, even if there was no change from a positive to a
negative edge or viceversa.
The signal state at output Q is "1" if the count is greater than zero and "0" if the
count is equal to zero.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - x x x 1
Note
Avoid to use a counter at several program points (risk of counting errors).
Example
C10
S_CUD
I 0.0 Q 4.0
CU Q
I 0.1
CD
I 0.2
S CV
I 0.3 MW10 PV CV_BCD
R
If I0.2 changes from "0" to "1", the counter is preset with the value of MW10. If the
signal state of I0.0 changes from "0" to "1", the value of counter C10 will be
incremented by one - except when the value of C10 is equal than "999". If I0.1
changes from "0" to "1", C10 is decremented by one - except when the value of C10
is equal to "0". Q4.0 is "1" if C10 is not equal to zero.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 54 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
C no. Z no.
S_CU Z_VORW
CU Q ZV Q
S S
PV CV ZW DUAL
CV_BCD DEZ
R R
Description
S_CU (Up Counter) is preset with the value at input PV if there is a positive edge at
input S.
The counter is reset if there is a "1" at input R and the count value is then set to
zero.
The counter is incremented by one if the signal state at input CU changes from "0"
to "1" and the value of the counter is less than "999".
If the counter is set and if RLO = 1 at the inputs CU, the counter will count
accordingly in the next scan cycle, even if there was no change from a positive to a
negative edge or viceversa.
The signal state at output Q is "1" if the count is greater than zero and "0" if the
count is equal to zero.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 55 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - x x x 1
Note
Avoid to use a counter at several program points (risk of counting errors).
Example
C10
S_CU
I 0.0 Q 4.0
CU Q
I 0.2
S
MW10 PV CV
I 0.3
R CV_BCD
If I0.2 changes from "0" to "1", the counter is preset with the value of MW10. If the
signal state of I0.0 changes from "0" to "1", the value of counter C10 will be
incremented by one - unless the value of C10 is equal to "999". Q4.0 is "1" if C10 is
not equal to zero.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 56 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
C no. Z no.
S_CD Z_RUECK
CD Q ZR Q
S S
PV CV ZW DUAL
CV_BCD DEZ
R R
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 57 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - x x x 1
Note
Avoid to use a counter at several program points (risk of counting errors).
Example
C10
C_CD
I 0.0 Q 4.0
CD Q
I 0.2
S
MW10 PV CV
I 0.3
R CV_BCD
If I0.2 changes from "0" to "1", the counter is preset with the value of MW10. If the
signal state of I0.0 changes from "0" to "1", the value of counter C10 will be
decremented by one - unless the value of C10 is equal to "0". Q4.0 is "1" if C10 is
not equal to zero.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 58 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
<C no.> <Z no.>
---( SC ) ---( SZ )
<preset value> <preset value>
Description
---( SC ) (Set Counter Value) executes only if there is a positive edge in RLO. At
that time, the preset value transferred into the specified counter.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: x - - - - 0 x - 0
Example
C5
I 0.0
SC
C#100
The counter C5 is preset with the value of 100 if there is a positive edge at input
I0.0 (change from "0" to "1"). If there is no positive edge, the value of counter C5
remains unchanged.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 59 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
<C no.> <Z no.>
---( CU ) ---( ZV )
Description
---( CU ) (Up Counter Coil) increments the value of the specified counter by one if
there is a positive edge in the RLO and the value of the counter is less than "999". If
there is no positive edge in the RLO or the counter already has the value "999", the
value of the counter will be unchanged.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 - - 0
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 60 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
Network 1
I 0.0 C10
SC
C#100
Network 2
I 0.1 C10
CU
Network 3
I 0.2 C10
R
If the signal state of input I0.0 changes from "0" to "1" (positive edge in RLO), the
preset value of 100 is loaded to counter C10.
If the signal state of input I0.1 changes from "0" to "1" (positive edge in RLO),
counter C10 count value will be incremented by one unless the value of C10 is
equal to "999". If there is no positive edge in RLO, the value of C10 will be
unchanged.
If the signal state of I0.2 is "1", the counter C10 is reset to "0".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 61 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
English German
<C no.> <Z no.>
---( CD ) ---( ZD )
Description
---( CD ) (Down Counter Coil) decrements the value of the specified counter by
one, if there is a positive edge in the RLO state and the value of the counter is
more than "0". If there is no positive edge in the RLO or the counter has already
the value "0", the value of the counter will be unchanged.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - - 0 - - 0
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 62 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
Network 1
I 0.0 Z10
SC
C#100
Network 2
I 0.1 C10
CU
Network 3
C10 Q 4.0 "0" count value
detector
Network 4
I 0.2 C10
R
If the signal state of input I0.0 changes from "0" to "1" (positive edge in RLO), the
preset value of 100 is loaded to counter C10.
If the signal state of input I0.1 changes from "0" to "1" (positive edge in RLO),
counter C10 count value will be decremented by one unless the value of C10 is
equal to "0". If there is no positive edge in RLO, the value of C10 will be
unchanged.
If the count value = 0, then Q4.0 is turned on.
If the signal state of input I0.2 is "1", the counter C10 is reset to "0".
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 63 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
5 Comparison Instructions
Description
IN1 and IN2 are compared according to the type of comparison you choose:
== IN1 is equal to IN2
<> IN1 is not equal to IN2
> IN1 is greater than IN2
< IN1 is less than IN2
>= IN1 is greater than or equal to IN2
<= IN1 is less than or equal to IN2
If the comparison is true, the RLO of the function is "1". It is linked to the RLO of a
rung network by AND if the compare element is used in series, or by OR if the box is
used in parallel.
The following comparison instructions are available:
CMP I Compare Integer
CMP D Compare Double Integer
CMP R Compare Real
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 64 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Description
CMP I (Compare Integer) can be used like a normal contact. It can be located at
any position where a normal contact could be placed. IN1 and IN2 are compared
according to the type of comparison you choose.
If the comparison is true, the RLO of the function is "1". It is linked to the RLO of
the whole rung by AND if the box is used in series, or by OR if the box is used in
parallel.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: x x x 0 - 0 x x 1
Example
I 0.0 I 0.1 CMP Q 4.0
>= I S
MW0 IN1
MW2 IN2
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 65 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Description
CMP D (Compare Double Integer) can be used like a normal contact. It can be
located at any position where a normal contact could be placed. IN1 and IN2 are
compared according to the type of comparison you choose.
If the comparison is true, the RLO of the function is "1". It is linked to the RLO of a
rung network by AND if the compare element is used in series, or by OR if the box is
used in parallel.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: x x x 0 - 0 x x 1
Example
I 0.0 I 0.1 CMP I 0.2 Q 4.0
>= D S
MD0 IN1
MD4 IN2
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 66 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbols
CMP CMP CMP
== R >R >= R
IN1 IN1 IN1
IN2 IN2 IN2
Description
CMP R (Compare Real) can be used like a normal contact. It can be located at
any position where a normal contact could be placed. IN1 and IN2 are compared
according to the type of comparison you choose.
If the comparison is true, the RLO of the function is "1". It is linked to the RLO of
the whole rung by AND if the box is used in series, or by OR if the box is used in
parallel.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: x x x x x 0 x x 1
Example
I 0.0 I 0.1 CMP I 0.2 Q 4.0
>= R S
MD0 IN1
MD4 IN2
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 67 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Description
The following program control instructions are available:
---(CALL) Call FC SFC from Coil (without Parameters)
CALL_FB Call FB from Box
CALL_FC Call FC from Box
CALL_SFB Call System FB from Box
CALL_SFC Call System FC from Box
Call Multiple Instance
Call Block from a Library
Important Notes on Using MCR Functions
---(MCR<) Master Control Relay On
---(MCR>) Master Control Relay Off
---(MCRA) Master Control Relay Activate
---(MCRD) Master Control Relay Deactivate
RET Return
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 68 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<FC/SFC no.>
---( CALL )
Description
---(Call) (Call FC or SFC without Parameters) is used to call a function (FC) or
system function (SFC) that has no passed parameters. A call is only executed if
RLO is "1" at the CALL coil. If ---(Call) is executed,
The return address of the calling block is stored,
The previous local data area is replaced by the current local data area,
The MA bit (active MCR bit) is shifted to the B stack,
A new local data area for the called function is created.
After this, program processing continues in the called FC or SFC.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
Unconditional: writes: - - - - 0 0 1 - 0
Conditional: writes: - - - - 0 0 1 1 0
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 69 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
.
.
. DB10
OPN
.
.
.
MCRA
.
.
. FC10
CALL
I 0.0 Q 4.0
.
.
.
MCRD
.
.
. I 0.1 FC11
CALL
The Ladder rungs shown above are program sections from a function block written
by a user. In this FB, DB10 is opened and MCR functionality is activated. If the
unconditional call of FC10 is executed, the following occurs:
The return address of the calling FB plus selection data for DB10 and for the
instance data block for the calling FB are saved. The MA bit, set to "1" in the MCRA
instruction, is pushed to the B stack and then set to "0" for the called block
(FC10). Program processing continues in FC10. If MCR functionality is required by
FC10, it must be re-activated within FC10. When FC10 is finished, program
processing returns to the calling FB. The MA bit is restored, DB10 and the instance
data block for the user-written FB become the current DBs again, regardless of which
DBs FC10 has used. The program continues with the next rung by assigning the
logic state of I0.0 to output Q4.0. The call of FC11 is a conditional call. It is only
executed if I0.1 is "1". If it is executed, the process of passing program control to and
returning from FC11 is the same as was described for FC10.
Note
After returning to the calling block, the previously open DB is not always open
again. Please make sure you read the note in the README file.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 70 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<DB no.>
FB no.
EN ENO
The symbol depends on the FB (whether it has parameters and how many of
them). It must have the EN, ENO, and the name or number of the FB.
Description
CALL_FB (Call a Function Block from a Box) executed if EN is "1". If CALL_FB is
executed,
The return address of the calling block is stored,
The selection data for the two current data blocks (DB and instance DB) are
stored,
The previous local data area is replaced by the current local data area,
The MA bit (active MCR bit) is shifted to the B stack,
A new local data area for the called function block is created.
After this, program processing continues within the called function block. The BR
bit is scanned in order to find out the ENO. The user has to assign the required
state (error evaluation) to the BR bit in the called block using ---(SAVE).
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
Unconditional: writes: x - - - 0 0 x x x
Conditional: writes: - - - - 0 0 x x x
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 71 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
.
.
. DB10
OPN
.
.
.
MCRA
.
DB11
.
FB11 Q 4.0
.
. EN ENO
.
. DB10
OPN
The Ladder rungs shown above are program sections from a function block written
by a user. In this FB, DB10 is opened and MCR functionality is activated. If the
unconditional call of FB11 is executed, the following occurs:
The return address of the calling FB plus selection data for DB10 and for the
instance data block for the calling FB are saved. The MA bit, set to "1" in the MCRA
instruction, is pushed to the B stack and then set to "0" for the called block
(FB11). Program processing continues in FB11. If MCR functionality is required by
FB11, it must be re-activated within FB11. The state of the RLO must be saved in the
BR bit by the instruction ---(SAVE) in order to be able to evaluate errors in the calling
FB. When FB11 is finished, program processing returns to the calling FB. The MA bit
is restored and the instance data block of the user-written FB is opened again. If the
FB11 is processed correctly, ENO = "1" and therefore Q4.0 = "1".
Note
When opening an FB or SFB, the number of the previously opened DB is lost. The
required DB has to be reopened.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 72 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
FC no.
EN ENO
The symbol depends on the FC (whether it has parameters and how many of
them). It must have EN, ENO, and the name or number of the FC.
Description
CALL_FC (Call a Function from a Box) is used to call a function (FC). The call is
executed if EN is "1". If CALL_FC is executed,
The return address of the calling block is stored,
The previous local data area is replaced by the current local data area,
The MA bit (active MCR bit) is shifted to the B stack,
A new local data area for the called function is created.
After this, program processing continues in the called function.
The BR bit is scanned in order to find out the ENO. The user has to assign the
required state (error evaluation) to the BR bit in the called block using ---(SAVE). If
you call a function and the variable declaration table of the called block has IN,
OUT, and IN_OUT declarations, these variables are added in the program for the
calling block as a list of formal parameters.
When calling the function, you must assign actual parameters to the formal
parameters at the call location. Any initial values in the function declaration have
no significance.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
Unconditional: writes: x - - - 0 0 x x x
Conditional: writes: - - - - 0 0 x x x
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 73 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
.
.
. DB10
OPN
.
.
.
MCRA
.
.
FC10 FC11 Q 4.0
.
EN ENO
. EN ENO
.
.
The Ladder rungs shown above are program sections from a function block written
by a user. In this FB, DB10 is opened and MCR functionality is activated. If the
unconditional call of FC10 is executed, the following occurs:
The return address of the calling FB plus selection data for DB10 and for the
instance data block for the calling FB are saved. The MA bit, set to "1" in the MCRA
instruction, is pushed to the B stack and then set to "0" for the called block
(FC10). Program processing continues in FC10. If MCR functionality is required by
FC10, it must be re-activated within FC10. The state of the RLO must be saved in
the BR bit by the instruction ---(SAVE) in order to be able to evaluate errors in the
calling FB. When FC10 is finished, program processing returns to the calling FB.
The MA bit is restored. After execution of FC10, program processing is continued in
the calling FB depending on the ENO:
ENO = "1" FC11 is processed
ENO = "0" processing starts in the next network
If FC11 is also processed correctly, ENO = "1" and therefore Q4.0 = "1".
Note
After returning to the calling block, the previously open DB is not always open
again. Please make sure you read the note in the README file.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 74 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
<DB no.>
SFB no.
EN ENO
The symbol depends on the SFB (whether it has parameters and how many of
them). It must have the EN, ENO, and the name or number of the SFB.
Description
CALL_SFB (Call a System Function Block from a Box) is executed if EN is "1". If
CALL_SFB is executed,
The return address of the calling block is stored,
The selection data for the two current data blocks (DB and instance DB) are
stored,
The previous local data area is replaced by the current local data area,
The MA bit (active MCR bit) is shifted to the B stack,
A new local data area for the called system function block is created. Program
processing then continues in the called SFB. ENO is "1" if the SFB was called (EN
= "1") and no error occurs.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
Unconditional: writes: x - - - 0 0 x x x
Conditional: writes: - - - - 0 0 x x x
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 75 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
.
.
. DB10
OPN
.
.
.
MCRA
.
. DB 8
. SFB 8 Q 4.0
EN ENO
M11.0 REQ DONE READY
ID ERROR M10.0
R_ID STATUS
CODE
SD_1
DW12
SD_2
DW14
SD_3
DW16
SD_4
DB10
OPN
The Ladder rungs shown above are program sections from a function block written
by a user. In this FB, DB10 is opened and MCR functionality is activated. If the
unconditional call of SFB8 is executed, the following occurs:
The return address of the calling FB plus selection data for DB10 and for the
instance data block for the calling FB are saved. The MA bit, set to "1" in the MCRA
instruction, is pushed to the B stack and then set to "0" for the called block
(SFB8). Program processing continues in SFB8. When SFB8 is finished, program
processing returns to the calling FB. The MA bit is restored and the instance data
block of the user-written FB becomes the current instance DB. If the SFB8 is
processed correctly, ENO = "1" and therefore Q4.0 = "1".
Note
When opening an FB or SFB, the number of the previously opened DB is lost. The
required DB has to be reopened.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 76 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
SFC no.
EN ENO
The symbol depends on the SFC (whether it has parameters and how many of
them). It must have EN, ENO, and the name or number of the SFC.
Description
CALL_SFC (Call a System Function from a Box) is used to call an SFC. The call is
executed if EN is "1". If CALL_SFC is executed,
The return address of the calling block is stored,
The previous local data area is replaced by the current local data area,
The MA bit (active MCR bit) is shifted to the B stack,
A new local data area for the called system function is created.
After this, program processing continues in the called SFC. ENO is "1" if the SFC
was called (EN = "1") and no error occurs.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
Unconditional: writes: x - - - 0 0 x x x
Conditional: writes: - - - - 0 0 x x x
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 77 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Example
.
.
. DB10
OPN
.
.
.
MCRA
.
.
. SFC20 Q 4.0
EN ENO
DBDW12 SRCBLK RET_VAL MW10
. DSTBLK
[Link]
.
.
The Ladder rungs shown above are program sections from a function block written
by a user. In this FB, DB10 is opened and MCR functionality is activated. If the
unconditional call of SFC20 is executed, the following occurs:
The return address of the calling FB plus selection data for DB10 and for the
instance data block for the calling FB are saved. The MA bit, set to "1" in the MCRA
instruction, is pushed to the B stack and then set to "0" for the called block
(SFC20). Program processing continues in SFC20. When SFC20 is finished,
program processing returns to the calling FB. The MA bit is restored.
After processing the SFC20, the program is continued in the calling FB depending
on the ENO:
ENO = "1" Q4.0 = "1"
ENO = "0" Q4.0 = "0"
Note
After returning to the calling block, the previously open DB is not always open
again. Please make sure you read the note in the README file.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 78 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Symbol
#Variable
name
EN ENO
Description
A multiple instance is created by declaring a static variable with the data type of a
function block. Only multiple instances that have already been declared are included
in the program element catalog. The symbol for a multiple instance varies depending
on whether and how many parameters are present. EN, ENO and the variable name
are always present.
Status word
BR CC 1 CC 0 OV OS OR STA RLO /FC
writes: - - - - 0 0 x x x
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 79 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 80 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 82 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 83 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
8 Programming Examples
8.1 Example: Bit Logic Instructions
Sensor S5
S1 O Start S3 O Start
S2 O Stop S4 O Stop
MOTOR_ON
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 84 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
S1
I 1.1 Q 4.0
S
S3
I 1.3
Network 2: Pressing either stop switch or opening the normally closed contact at
the end of the belt turns the motor off.
S2
I 1.2 Q 4.0
R
S4
I 1.4
S5
I 1.5
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 85 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 86 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
LEFT
Q 4.1
R
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 87 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Ladder Logic Program to Generate a Clock Pulse (pulse duty factor 1:1)
Network 1: If the signal state of timer T1 is 0, load the time value 250 ms into T1
and start T1 as an extended-pulse timer.
M0.2 T1
SE
S5T#250MS
T1 M0.2
M0.2 M001
JMP
Network 4: When the timer T1 expires, the memory word 100 is incremented by 1.
ADD_I
EN ENO
MW100 IN1 OUT MW100
1 IN2
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 88 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Network 5: The MOVE instruction allows you to output the different clock
frequencies at outputs Q12.0 through Q13.7.
M001
MOVE
EN ENO
MW100 IN OUT AW12
Signal Check
A signal check of timer T1 produces the following result of logic operation (RLO) for
opener M0.2.
1
0
250 ms
As soon as the time runs out, the timer is restarted. Because of this, the signal
check made by ––| / |–– M0.2 produces a signal state of 1 only briefly.
The negated (inverted) RLO:
1
0
250 ms
Every 250 ms the RLO bit is 0. The jump is ignored and the contents of memory
word MW100 is incremented by 1.
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 89 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Scan Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Time Value
Cycle in ms
0 0 0 0 0 0 0 0 0 250
1 0 0 0 0 0 0 0 1 250
2 0 0 0 0 0 0 1 0 250
3 0 0 0 0 0 0 1 1 250
4 0 0 0 0 0 1 0 0 250
5 0 0 0 0 0 1 0 1 250
6 0 0 0 0 0 1 1 0 250
7 0 0 0 0 0 1 1 1 250
8 0 0 0 0 1 0 0 0 250
9 0 0 0 0 1 0 0 1 250
10 0 0 0 0 1 0 1 0 250
11 0 0 0 0 1 0 1 1 250
12 0 0 0 0 1 1 0 0 250
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 90 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Display Panel
Storage area Storage area Storage area Storage area Storage area
empty not empty 50% full 90% full Filled to capacity
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 91 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Ladder Logic Program that Activates the Indicator Lamps on the Display Panel
Network 1: Counter C1 counts up at each signal change from “0” to “1” at input CU
and counts down at each signal change from “0” to “1” at input CD. With a signal
change from “0” to ”1” at input S, the counter value is set to the value PV. A signal
change from “0” to “1” at input R resets the counter value to “0”. MW200 contains the
current counter value of C1. Q12.1 indicates “storage area not empty”.
C1
Q 12.1
I 12.0 S_CUD
CU Q
I 12.1
CD
I 12.2
S
C#10 PV CV MW210
I 12.3
R CV_BCD MW200
Q 12.1 Q 12.1
Network 3: If 50 is less than or equal to the counter value (in other words if the
current counter value is greater than or equal to 50), the indicator lamp for “storage
area 50% full” is lit.
CMP Q 15.2
<= 1
50 IN1
MW210 IN2
Network 4: Network 4: If the counter value is greater than or equal to 90, the
indicator lamp for “storage area 90% full” is lit.
Q 15.3
CMP
>= 1
MW210
IN1
90
IN2
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 92 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Network 5: If the counter value is greater than or equal to 100, the indicator lamp
for “storage area full” is lit.
CMP Q 15.4
>= 1
MW210 IN1
100 IN2
DB1
OPN
Network 2: Input word IW0 is added to shared data word DBW3 (data block must be
defined and opened) and the sum is loaded into memory word MW100. MW100 is
then multiplied by 15 and the answer stored in memory word MW102. MW102 is
divided by MW0 with the result stored in MW4.
DBW3 IN2 OUT MW100 15 IN2 OUT MW102 MW0 IN2 OUT MW4
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 93 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
Heating an Oven
The operator of the oven starts the oven heating by pushing the start push button.
The operator can set the length of time for heating by using the thumbwheel
switches shown in the figure. The value that the operator sets indicates seconds in
binary coded decimal (BCD) format.
Oven
4 4 4
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 94 of 95
Trainee Handout Centre for Electronics Test Engineering, Kolkata
T1 Q 4.0
Network 2: If the timer is running, the Return instruction ends the processing here.
T1
RET
Network 3: Mask input bits I 0.4 through I 0.7 (that is, reset them to 0). These bits of
the thumbwheel inputs are not used. The 16 bits of the thumbwheel inputs are
combined with W#16#0FFF according to the (Word) And Word instruction. The
result is loaded into memory word MW1. In order to set the time base of seconds,
the preset value is combined with W#16#2000 according to the (Word) Or Word
instruction, setting bit 13 to 1 and resetting bit 12 to 0.
WAND_W WOR_W
EN ENO EN ENO
Network 4: Start timer T 1 as an extended pulse timer if the start push button is
pressed, loading as a preset value memory word MW2 (derived from the logic
above).
I 0.7 T1
SE
MW2
Ladder Program Course No. Prepared by Approved by Doc. No. Issue No. Rev. Dt. of Issue Page
Instruction AUT/XXX TH/791 1 A 1.9.2005 95 of 95