You are on page 1of 14

Jump and Call Cont’

 For Mitsubishi, the jump instruction is


denoted by conditional jump (CJP) and
the place to which the jump occurs is
denoted by end of jump (EJP)
 Jump occurs if there is input X400,
resulting to the rungs involving X401
and X403 being ignored. The program
continues with the rungs following the
end-jump instruction EJP 700.
 For Allen-Bradley, the jump take place
from the jump instruction (JMP) to the
label instruction (LBL)

Jumps within jumps


 If condition for jump instruction 1 is
realized, the program jumps to rung 8
 If condition is not met, the program
continues to rung 3
 If condition for jump instruction 2 is
realized, the program jumps to rung 6
 If the condition is not met, the
program continues through the rungs

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 1


Jump and Call Cont’
Subroutines
 Subroutines are small programs to perform specific tasks that can be called for
use in larger programs
 They can be called repetitively to perform specific tasks without having to be
written out in full in the larger program

 Subroutine is similar to OBs and FCs


for the Siemens system
 Examples of subroutine usage include
the following
– Loading and executing a specific
recipe when needed
– Initializing a system startup
– Performing a common calculation at
different points in a program
– Updating alarms and displays
– Updating communication data
protocol parameters

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 2


Jump and Call Cont’/ Timers
 For Mitsubishi PLC: If input 1 occurs, the subroutine P is called then executed
 Instruction SRET indicate its end and the point at which the program return to
the main program
 For Allen-Bradley, subroutines are called by using a jump-to-subroutine (JSR)
instruction
 The start of instruction is indicated by SBR
 The end and point of return to the main program is indicated by RET

Timers
Used for control operations that need to be timed. Timers count seconds or fraction
of seconds using the internal CPU clock

Types of timers (S7-1200)


 ON-delay (TON)
 ON-delay retentive (TONR)
 OFF-delay (TOF)
 Pulse (TP)

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 3


TON, TOF, and TONR parameters
Time instruction accumulated value uses:
 M (2 words, 16 bits) memory area
 D (Double word, 32 bit) memory area
 L (Long, 64 bits) memory area
Parameters Declaration Data Type Memory Description
area
IN Input BOOL I,Q,M,D,L Duration of the
ON delay
PT Input TIME I,Q,M,D,L, The value of the
or constant PT parameter
must be positive
Q Output BOOL I,Q,M,D,L Output that is
set when the
time PT expires
ET Output TIME I,Q,M,D,L Elapsed
time/Current
time value

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 4


ON-DELAY Timers (TONs)

If the input (IN) is TRUE:


 The timer accumulated value with tag
name T_0_Acc will increment
 When timer accumulated value is equal
to the predefined preset value with tag
name T_0_PRE, the output Q will
change status to ON, and the timer will
stop timing
 If the timer enable is lost before the
prespecified preset time, the Q output
will not turn ON
 The timer output will turn OFF once the
input goes OFF

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 5


OFF-DELAY Timers (TOFs)

Delays the falling edge of the output Q by


predefined period of preset time (PT).
If the input (IN) is TRUE:
 The output Q is set true
 When input turns OFF, the timer start
timing
 It resets the output Q when the timer
accumulated value ET with tag name
T_0_Acc is equal to the timer preset
value PT with assigned tag name
T_0_PRE.

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 6


ON-DELAY Retentive Timers (TONRs)

 The TONR work exactly the same as the


ON-DELAY timer except that the
accumulated value is retained while the
timer instruction is inactive.
 To reset the accumulated value to zero,
a positive pulse-input instruction is
required at the reset input (R)

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 7


Counters

Types of Counters (S7-1200)


 Count up (CTU)
 Count down (CTD)
 Count up and count down counter (CTUD)
Basic parameters for CTU, CTD, and CTUD

Parameters Data Type Description


CU, CD BOOL Count up or count down, by one count
R(CTU, CTUD) BOOL Reset count value to zero
LOAD (CTU, CTUD) BOOL Load control for preset value
PV SINT, INT, DINT, Preset count value
USINT, UINT,
UDINT
Q,QU BOOL True if CV>=PV
QD BOOL True if CV<=0
CV SINT, INT, DINT, Current count value
USINT, UINT,
UDINT

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 9


Count Up Counters (CTU)
The main function is to increment the
current value each time the input to the
counter transition from 0 to 1
 If the current count value (CV) is
equal to the preset value (PV), the
output Q is set
 When reset input (R) is TRUE, the
accumulated value reset to 0
 Counter preset input can be defined
as a tag name or a constant value
 Counter preset input can be defined
as a tag name or a constant value

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 10


Count Down Counters (CTD)
The main function is to decrement the
current value (CV) each time the input
to the counter transition from 0 to 1
 If the current count value (CV) is
set to the value of the PV parameter
when the signal state at the LD
input changes to 1
 As long as the LOAD input has
signal state 1, the signal state at
the CTD input has no effect on the
instruction

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 11


Special Timing Instruction
Pulse Generation/Pulse Timer (TP)  A pulse timer (TP) generate a pulse
with a preset width time
 If the rung input is TRUE, the output
Q is set TRUE for the period
identified by the preset value PT, tag
name T_PRE.

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 12


Special Timing Instruction
One-shot operations
The one-shot instruction (scan operand for positive or negative signal edge in
Siemens PLCs) is designed to detect a positive or a negative signal edge
-|P|- Scan operand for positive -|N|- Scan Operand for Negative
signal edge signal edge

 The scan operand for a positive  The scan operand for a negative
signal edge instruction compares signal edge instruction compares
the current signal state of the current signal state of
OPERAND_1 with the signal state of OPERAND_1 with the signal state of
the previous scan stored in edge the previous scan stored in edge
memory bit M17.0, tag named memory bit M17.1, tag named
OPERAND_2 OPERAND_2
 If the instruction detects a change  If the instruction detects a change
between the two operands, a between the two operands, a
positive rising edge is produced for negative fallen edge is produced for
only one scan only one scan
Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 13
Sequential and Combinational Logic Instructions
Set-Reset Flip-Flop Instruction Set-output Instruction (S): Set 1 Bit

 if the preceding logic for the same


network is TRUE (power flows to the S
coil); then S is activated
 The set-reset (SR) flip-flop logic is
 When the preceding network input
(power flow to the coil) is FALSE, then
used to describe and document the S maintains the active status
LATCH and UNLATCH relay functions
in the PLC
 S remains active until a reset action is
executed
 When PB1 is pushed, it sets S to 1, Reset-out instruction (R): Reset 1 Bit
and R is reset
 This will cause PL to turn ON, as
indicated by the shaded circle
 To turn the PL OFF, PB2 should be  If the preceding logic for the same
activated/pressed network is TRUE (power flows to the R
coil); then R is activated, which resets
the S coil

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 14


Sequential and Combinational Logic Instructions
Set-Out (R) Instruction Cont‘ Negative Edge Instruction
 When the preceding rung input Negative edge
(power flow to the coil) is FALSE,
--------|N|---------
then S maintains the inactive status
 The state of this contact is TRUE for
one scan when a negative transition
(ON to OFF) is detected on the
Positive Edge Instruction
assigned negative edge bit INPUT
 Power flows in the network for one
program scan from the time where
edge is triggered
 The state of this contact is TRUE for
one scan when a positive transition
(OFF to ON) is detected on the
assigned positive edge bit INPUT
 Power flows in the network for one
program scan from the time where
a positive edge is triggered

Dr.-Ing. Jackson G. Njiri EMT 2549 L-5: Timers, counters 15

You might also like