You are on page 1of 76

Chapter Four

Instruction of LG PLC

Contact instructions

PLC Course

chapter four

Connection instructions

Inversion instruction
2

PLC Course

chapter four

Master control instructions

Output instructions

Step controller instructions


3

PLC Course

chapter four

END instruction

No operation instruction

Bit contact instructions


4

PLC Course

chapter four

PLC Course

chapter four

The kinds of PLC Commands Applicable Commands in LG PLC K Series : Sequence Command : Basic Commands for creating Sequence Logic Circuits. Comparison Command : Application Commands to execute the Comparison Operations. Arithmetic Command : Application Commands to execute the Arithmetic Operations. Logical Operation Command : Application Commands to execute the Logical Operations. Rotate/Shift Command : Application Commands to rotate or shift Data. Increment/Decrement : Application Commands to add or subtract 1 to the data. Conversion Command : Application Commands to change the type of Data. Transfer Command : Application Commands to copy, exchange or transfer Data between the internal devices. Timer/Counter Command : Basic Commands to use Timer and Counter. Jump/Interrupt Command : Application Commands to execute Interrupt, Call or Jump with the specified program.

Sequence Command
6

PLC Course

chapter four

NOP

No Operation

1 Step

Function : 1. This is a No Operation Command and it doesnt effect to the operation results of the program. 2. This command shows only in the Mnemonic program. Objects for NOP use : 1. For occupying the space of the command to be used later. 2. For removing Command with keeping the number of steps temporarily. Note : Optimize Program Function in Edit Menu of KGL for Windows is used for deleting all NOP Commands in the program automatically.

LOAD LOAD NOT

NO contact NC Contact

1 Step 1 Step

Function : LOAD : Starts NO ( Normally Open ) contact. Executes the ON/OFF operation of the specified device. LOAD NOT : Starts NC ( Normally Closed ) contact. Executes the converted ON/OFF operation of the specified device.

PLC Course

chapter four

AND AND NOT

Serial Connection of NO Contact Serial Connection of NC Contact

1 Step 1 Step

Function : AND : Serial connection of Normally Open Contact. Performs a logic AND between the operand and the Boolean result of The preceding command. AND NOT : Serial connection of Normally Closed Contact. Performs a logic AND NOT between the operand and the Boolean result of the preceding command.

OR

Parallel Connection of NO Contact

1 Step
8

PLC Course OR NOT Function : OR :

Parallel Connection of NC Contact

chapter four 1 Step

Parallel connection of NO contact. Performs a logic OR between the operand and the Boolean result of the preceding command.

OR NOT : Parallel connection of NC contact. Performs a logic OR NOT between the operand and the Boolean result of the preceding command.

AND LOAD

Serial Block Operation

1 Step

Function : 1. AND Operation of the result of A Block and B Block. 2. It does not have its own ladder expression and it is converted to the mnemonic program in the necessary circuit.

PLC Course

chapter four

OR LOAD

Parallel Block Operation

1 Step

Function : 1.OR Operation of the result of A Block and B Block. 2. It does not have its own ladder expression and it is converted to the mnemonic program in the necessary circuit.

10

PLC Course Example no. 1

chapter four

The motor operation (Example of LOAD, AND, OR, OUT instructions) Operation : There are three push-button switches - PB0, PB1, and PB2. When PB1 is pushed, a motor will start to rotate with a forward (clockwise) direction. It will start to rotate with a reverse (counterclockwise) direction when the PB2 is pushed. The PB0 is emergency stop switch and the motor will stop operation when the PB0 is pushed. System structure :

Program :

11

PLC Course

chapter four

NOT

Conversion Command

1 Step

Function : This command negates the Boolean result of the preceding command.

Example no. 2 Program example The following two programs perform same operation.

12

PLC Course

chapter four OUT Output the Result 1 Step

Function : The operation result up to OUT command is outputted to the specified device. Parallel circuit is available in OUT Command.

SET RST

Self holding with ON status Self holding with OFF status

1 Step 1 Step

Function : SET : When the input condition gets ON, keeps the specified device d as ON status and keeps the device d as ON status even if the input condition gets OFF. RST : When the input condition gets OFF, keeps the specified device d as ON status and keeps the device d as OFF status even if the input condition gets OFF.

D D NOT

Derivative Command Derivative Command ( Conversion )

2 Steps 2 Steps
13

PLC Course Function :

chapter four

This is a Derivative command for detecting the point the input condition is changed. When the change of the input condition is detected, the specified device( d ) becomes ON for 1 scan. D : When the input condition changes from OFF to ON, the specified device becomes ON for 1 scan. D NOT : When the input condition changes from ON to OFF, the specified device becomes ON for 1 scan.

Example no. 3

14

PLC Course The on / off toggle control (Example of D instructions) Operation :

chapter four

When the push-button PB0 is pushed, the P060 is switched on. It is switched off when the PB0 is pushed again. The P060 will repeat on / off whenever the PB0 is pushed. System structure :

Program :

Time chart :

15

PLC Course MPUSH


chapter four Push the Result Load the Pushed Result Pop the Result 1 Step 1 Step 1 Step

MLOAD MPOP

Function : Multiple branches in the ladder diagram can be drawn by this command. MPUSH shall be used with MPOP all the time.

MCS MCSCLR

Master Control Master Control Clear

1 Step 1 Step

Function : 1. When the input condition of MCS gets ON, it executes until MCSCLR which is identical to MCS number ( n ). 2. When the input condition of MCS gets OFF, it doesnt executes MCSCLR which is identical to MCS number ( n ).
16

PLC Course chapter four 3. The priority of MCS is from 0(highest priority) to 7(lowest priority) in order. 4. MCS with the higher priority is used first and MCSCLR with the lower priority is used first. 5. If a user clears the master control with the higher priority ( MCSCLR ), the ones with the lower priority are cleared. 6. If MCS number is doubled before MCSCLR is executed, It causes an error. 7. If the priority order of MCS or MCSCLR is changed, it also causes an error.

END

The end of the execution

1 Step

Function : 1. Indicates the end of the program. 2. The scan of the program starts from step 0000 again after the execution of the END Command. 3. END Command must be at the end of the program. If not, an error is occurred.

17

PLC Course

chapter four d d n n Bit LOAD Bit LOAD NOT 5 Steps 5 Steps

BLD BLDN

Function : BLD : Load the nth bit of the specified area d as the result of the current operation. BLDN : Load the reversed nth bit of the specified area d as the result of the current operation.

BAND BANDN

d d

n n

Bit AND Bit AND NOT

5 Steps 5 Steps

Function : BAND : AND the nth bit of the specified area d as the result of the current operation. BANDN : AND the reversed nth bit of the specified area d as the result of the current operation.

18

PLC Course

chapter four

BOR BORN

d d

n n

Bit OR Bit OR NOT

5 Steps 5 Steps

Function : BOR :OR the nth bit of the specified area d as the result of the current operation. BORN :OR the reversed nth bit of the specified area d as the result of the current operation.

19

PLC Course

chapter four

BOUT

Bit OUT

5 Steps

Function : Outputs the result of the current operation to the nth bit of the specified area.

BSET BRST

d d

n n

Bit Set Bit Reset

5 Steps 5 Steps

Function : BSET : BRST : Set the nth bit of the specified area d. Reset the nth bit of the specified area d.

20

PLC Course

chapter four

SET

Sxx.xx

Step Controller( Sequence Control)

2 Steps

The characteristics of the step controller : 1. Self-holding Function The current step is kept so long as there is no next command. 2. Interlock Only one step is outputted among 100 steps. Function : 1. In a same stage, when the very previous step number gets ON, the current step number becomes ON as well 2. Once the current step number is ON, it becomes self-holding status. and so, even if the input gets OFF, ON status is kept. 3. Even if many input conditions are ON at the same time, only one step number gets ON in one stage. 4. To clear all steps( Sxx.xx ) of the relevant stage, use 00 step( Sxx.00 ) of the stage.

21

PLC Course Available ranges of the stage number : PLC Type K10S1 Volatile Area S00.xx ~ S11.xx

chapter four

Nonvolatile Area S12.xx ~ S15.xx

22

PLC Course

chapter four

OUT

Sxx.xx

Step Controller( Last-in Priority )

2 Steps

The characteristics of the step controller : 1. Self-holding Function The current step is kept so long as there is no next command. 2. Interlock Only one step is outputted among 100 steps. Function : 1. In a same stage, when the very previous step number gets ON, the current step number becomes ON as well 2. Once the current step number is ON, it becomes self-holding status. and so, even if the input gets OFF, ON status is kept. 3. Even if many input conditions are ON at the same time, only one step number gets ON in one stage. 4. To clear all steps( Sxx.xx ) of the relevant stage, use 00 step( Sxx.00 ) of the stage.

23

PLC Course

chapter four

24

PLC Course The sequential control ( example of SET Sxx.xx instruction) : 1. Operation : -

chapter four

This program shows briefly an example of sequential control by using SET Sxx.xx instruction. In this example, there are 4 processes and each process is performed in sequence. The process 2 starts after the process 1 ended, and process 3 starts after the process 2 finished. When the process 4 is completed, the process 1 will start again

25

PLC Course

chapter four

The circuit with common line (Example of MCS, MCSCLR instructions) : The below relay circuit can not be programmed into PLC program directly. Therefore, it should be programmed with master control. ( MCS and MCSCLR instructions )

26

PLC Course

chapter four

Timer/Counter Command
Timer instructions :

27

PLC Course

chapter four On-delay timer

TON

Functions :

A timer consists of timer contact, current value, and setting value. The current value will start to increase when the input condition turns on. It will increase by 1 at every 0.1 or 0.01 sec until it reaches to the setting value The timer contact will be switched on when the current value reaches to the The timer contact and current value is cleared when the input condition turns

or input condition turns off.

setting value.

off or RST instruction is executed. Program Example : The T097 (0.01 sec timer) will turn on 20 seconds later until the P020 is switched on.

28

PLC Course

chapter four

Example no. 1
A flickering lamp (example of TON instruction) Operation : By using two timers, a lamp flickers periodically while the P020 is on. System diagram :

Program :

29

PLC Course TOFF

chapter four Off-delay timer

Functions :

A timer consists of timer contact, current value, and setting value. When the input condition turns on, the current value will be set as the setting When the input condition turns off, the current value will decrease by 1 at The timer contact will be switched off when the current value reaches to 0. When the input condition turns off or RST instruction is executed, the timer

value and the timer contact will turn on.

every 0.1 or 0.01 sec until it reaches to 0 or input condition turns off.

contact will turn off and the current value will be cleared as 0. Program Example : The T000 (0.1 sec timer) will turn off 5 seconds later until the P020 is switched off.

30

PLC Course

chapter four

Example no. 2
A conveyer control (example of TOFF instruction) Operation : Operate three conveyers (A, B, C) in sequence by using TOFF timers. (Start : A B C, Stop : C B A) System diagram :

Time chart :

31

PLC Course Program :

chapter four

TMR

Integrating timer

Functions :

The current value will increase by 1 while the input condition is on.
When the current value reached to the setting value, the timer contact turns on.

Even if the input condition is off, the current value is not cleared. If uses a timer of retentive data area, the timer will keep the current value When the RST instruction is executed, the timer contact and current value will

while the CPU is powered off.

be cleared as 0.

32

PLC Course Program example :

chapter four

Example no. 3
An alarm of drill replacement (example of TMR instruction) Operation : The total usage time of the drill of a machining center is counted by PLC. If the total usage time exceeds the lifetime of drill (100 hours), the PLC outputs an alarm signal to notice that a replacement of drill is required. System diagram :

33

PLC Course

chapter four

Program :

34

PLC Course TMON

chapter four Monostable timer

Functions :

When the input condition turns on, the current value will be set as the setting The timer contact turns on when the input condition turns on. When the input condition turns off, the current value will decrease by 1 at

value and starts to decrease.

every 0.1 or 0.01 sec until it reaches to 0 and the timer contact will be switched off when the current value reaches to 0. While a timer is operating, on/off changed of input condition is ignored. When the RST instruction is executed, the timer contact will turn off and the current value will be cleared as 0. Program Example :

TRTG

Retrigerrable timer

35

PLC Course

chapter four

Functions :

When the input condition turns on, the current value will be set as the setting The timer contact turns on when the input condition is switched on. The current value will decrease by 1 at every 0.1 or 0.01sec until it reaches to 0 If the input condition turns on again during timer operation, the current value When the RST instruction is executed, the timer contact will turn off and the current value will be cleared as 0.

value and starts to decrease.

and the timer contact will be switched off when the current value reaches to 0.

will reset as the setting value and re-start to decreasing from the setting value.

Program example :

Example no. 4
The fault of conveyer detecting circuit (example of TRTG instruction)

36

PLC Course Operation :

chapter four

Detect the fault of conveyer by check that a product is passed within a specified period or not. System diagram :

Program :

Counter instructions :

37

PLC Course

chapter four

CTU

Up counter

38

PLC Course

chapter four

Functions :

Whenever a rising edged is detected at the count pulse input, the current value The initial current value is 0 and when the current value is reached to the After the counter contact turns on, the current value keeps increasing until its maximum value. (65535) When the reset signal is switched on, the counter contact and current value is cleared as 0.

is increased by 1

setting value, the counter contact turns on.

Program example : Whenever the P030 is changed from off to on, the current value of C010 is increased by 1. The P031 is reset condition.

CTD

Down counter

39

PLC Course

chapter four

Functions :

Whenever the rising edge is detected from counter pulse input, the current The initial current value is the setting value, and when the current value When the reset signal turns on, the counter contact is switched off and the

value is decreased by 1.

reached to 0, the counter contact is switched on.

current value is reset as the setting value. Program example : Whenever the P000 is changed from off to on, the current value of C010 is decreased by 1. The P0002 is reset condition.

40

PLC Course CTUD

chapter four Up-down counter

Functions :

Whenever a rising edged is detected from up count input, the current value is increased by 1. The current value is decreased by 1 whenever a rising edge is detected at the The initial current value is 0. The counter contact turns on when the current value is same or greater than When the reset signal turns on, the counter contact and current value is

down count input.

the setting value.

cleared as 0.

Program example : The P0000 is up count input, and the P0001 is down count input. The P0002 is reset signal.

41

PLC Course

chapter four

Example no. 5
A control circuit for motor operation (example of CTUD instruction) Operation : There are 4 motors controlled by PLC. Whenever the push-button PB1 is pressed, the numbers of operating motor is increased by 1. The PB2 decreases the numbers of operating motor whenever it is pressed. If the PB1 is pushed when 4 motors are operating, all motors will stop their operation. System diagram :

42

PLC Course

chapter four

Program : Try to do this program.

CTR

Ring counter

Functions : Whenever a rising edge is detected at the count pulse input, the current value is increased by 1.

43

PLC Course chapter four If the current value is reached to the setting value, the counter contact is switched on. Then the counter contact and current value will be cleared as 0 when the next rising edge is applied to the count pulse input. When the reset signal turns on, the counter contact and current value will be cleared as 0. Program example : The P030 is count pulse input and when the current value is same as the setting value, the counter contact is switched on. When the P030 is switched on 11th time, the counter contact (P060) is off and the current value is cleared as 0.

Transfer Command

MOV MOVP DMOV DMOVP

5 5 5/7 5/7

Data Copy Data Copy ( Pulse ) Data Copy ( Double ) Data Copy ( Double & Pulse )

It use for transfer Data from the specified device s and copied to the destination device d.

44

PLC Course

chapter four 5 5 5/7 5/7 Complement Data Copy Complement Data Copy ( Pulse ) Complement Data Copy ( Double ) Complement Data Copy ( Double & Pulse )

CMOV CMOVP DCMOV DCMOVP

Transfers 1s complement of data in the specified device s to the destination device d, that is, the converted data in the device s is stored in the device d.

GMOV GMOVP

7 7

Group Data Copy Group Data Copy ( Pulse )

Copies data as much as n ( number of words ) from the leading area of the specified device s to the leading device d as much as n .

45

PLC Course FMOV FMOVP

chapter four 7 7 Multiple Data Copy Multiple Data Copy ( Pulse )

Copies data in the specified device s to the destination device d as much as n (number of words).

BMOV BMOVP

7 7

Bit Data Copy Bit Data Copy ( Pulse )

Copies the specified number of bits(c.n) from the start bit(c.s) of device s to the start bit(c.d) from the device d as much as the specified number of bits(c.n).

46

PLC Course

chapter four

XCHG XCHGP DXCHG DXCHGP

5 5 5 5

Data Exchange Data Exchange ( Pulse ) Data Exchange ( Double ) Data Exchange ( Double & Pulse )

Exchanges the data in the device d1 with the data in the device d2.

Note that : When the instruction end with ( P ) it mean that the instruction is executed once at every rising edge of the input . When the instruction end without ( P ) it mean that the instruction is executed every scan of the input .

47

PLC Course

chapter four

Mov instruction

Movp instruction

Conversion Command

BCD BCDP DBCD DBCDP

Converts binary data into BCD data Converts binary data into BCD data ( Pulse ) Converts binary data into BCD data ( Double ) Converts binary data into BCD data ( Double &

Pulse )

1) Functions

48

PLC Course chapter four BCD : Converts binary data (0 to 9999) of the device specified at [ S ] into BCD format and transfers the result to the device specified at [ D ].

2) Program example : While P020 is on, convert the binary data of D001 and transfer the result to the P05 word.

49

PLC Course

chapter four

Displaying the current value of counter (example of BCD, BMOV instructions)


1.

Operation There is a warehouse and numbers of product incoming /

outgoing are counted by light switches. The current stock of inside of

50

PLC Course chapter four warehouse is displayed by a digital indicator. When the stock of inside of warehouse reaches to 30, the incoming 2. conveyer will be stopped.

Comparison Command

Command LOAD= LOAD<> LOAD>= LOAD<= LOAD> LOAD< LOADD=


LOADD<> LOADD>= LOADD<=

Step No. 5 5 5 5 5 5 5/7/9


5/7/9 5/7/9 5/7/9

Function LOAD Comparison Result(=) LOAD Comparison Result ( <> ) LOAD Comparison Result ( >= ) LOAD Comparison Result ( <= ) LOAD Comparison Result ( > ) LOAD Comparison Result ( < ) LOAD Comparison Result ( = ) ( Double )
LOAD Comparison Result ( <> ) ( Double ) LOAD Comparison Result ( >= ) ( Double ) LOAD Comparison Result ( <= ) ( Double )

LOADD> LOADD<

5/7/9 5/7/9

LOAD Comparison Result ( > ) ( Double ) LOAD Comparison Result ( < ) ( Double )

If the result of comparison of s1 and s2 is satisfied with the condition, the result gets ON. If not, the result gets OFF.

51

PLC Course

chapter four

AND= AND<> AND>= AND<= AND> AND< ANDD= ANDD<> ANDD>= ANDD<= ANDD> ANDD<

5 5 5 5 5 5 5/7/9 5/7/9 5/7/9 5/7/9 5/7/9 5/7/9

AND Comparison Result ( = ) AND Comparison Result ( <> ) AND Comparison Result ( >= ) AND Comparison Result ( <= ) AND Comparison Result ( > ) AND Comparison Result ( < ) AND Comparison Result ( = ) ( Double ) AND Comparison Result ( <> ) ( Double ) AND Comparison Result ( >= ) ( Double ) AND Comparison Result ( <= ) ( Double ) AND Comparison Result ( > ) ( Double ) AND Comparison Result ( < ) ( Double )

If the result of comparison between s1and s2 is satisfied with the condition, the result gets ON and performs AND operation with currently calculated result. If not, the result gets OFF and performs AND operation with currently calculated result.

52

PLC Course

chapter four

OR= OR<> OR>= OR<= OR> OR< ORD= ORD<> ORD>= ORD<= ORD> ORD>

5 5 5 5 5 5 5/7/9 5/7/9 5/7/9 5/7/9 5/7/9 5/7/9

OR Comparison Result ( = ) OR Comparison Result ( <> ) OR Comparison Result ( >= ) OR Comparison Result ( <= ) OR Comparison Result ( > ) OR Comparison Result ( < ) OR Comparison Result ( = ) ( Double ) OR Comparison Result ( <> ) ( Double ) OR Comparison Result ( >= ) ( Double ) OR Comparison Result ( <= ) ( Double ) OR Comparison Result ( > ) ( Double ) OR Comparison Result ( < ) ( Double )

If the result of comparison between s1and s2 is satisfied with the condition, the result gets ON and performs OR operation with currently calculated result. If not, the result gets OFF and performs OR operation with currently calculated result.

53

PLC Course

chapter four

CMP CMPP DCMP DCMPP

5 5 5/7/9 5/7/9

Data Comparison Data Comparison ( Pulse ) Data Comparison ( Double ) Data Comparison ( Double & Pulse )

Compares the data of s1 and s2 and sets the relevant flag among 6 relays .

54

PLC Course

chapter four

Comparing circuit (example of CMP instruction)


1. Operation There is a up-down counter C000. P030 is up-count input, and P031 is down-count input. If the current value of timer is 0 ~ 9, P060 turns on. If the current value is 10 ~ 19, P061 will be on. P062 will turn on when 20 ~ 29, P063 will turn on when 30 ~ 39, and P064 will be on when the current value is 40 or larger.

55

PLC Course

chapter four

TCMP TCMPP DTCMP DTCMPP

5 5 7/9 7/9

Table Comparison Table Comparison ( Pulse ) Table Comparison ( Double ) Table Comparison ( Double & Pulse )

1- Compares the data in the specified device s1 with each data of table (16 words) which starts with s2 and the result is outputted to each bit (16bits) of the specified device d. 2- If the result is identical, the bit data gets 1 , if not, gets 0 .

56

PLC Course

chapter four

Arithmetic Command

ADD ADDP DADD DADDP

7 7 7/9/11 7/9/11

Binary Addition Binary Addition ( Pulse ) Binary Addition ( Double ) Binary Addition ( Double & Pulse )

Adds two words data specified as s1 and s2 and stores the result in the specified device d.

SUB SUBP DSUB DSUBP

7 7 7/9/11 7/9/11

Binary Subtraction Binary Subtraction ( Pulse ) Binary Subtraction ( Double ) Binary Subtraction ( Double & Pulse )

Subtracts the word data in the specified device s2 from the word data in the specified device s1 and stores the result in the specified device d.

57

PLC Course

chapter four 7 7 7/9/11 7/9/11 Binary Multiplication Binary Multiplication ( Pulse ) Binary Multiplication ( Double ) Binary Multiplication ( Double & Pulse )

MUL MULP DMUL DMULP

1- Multiplies two word data specified as s1 and s2 and stores the result in the specified device d and d+1. 2- The lower 4 digit data of the result is stored in the device d and the higher 4 digit data is stored in the device d+1.

DIV DIVP DDIV DDIVP


1-

7 7 7/9/11 7/9/11

Binary Division Binary Division ( Pulse ) Binary Division ( Double ) Binary Division ( Double & Pulse )

Divides the word data in the specified device s1 by the word data in the

specified device s2 and stores the result in the specified device d and d+1. 2device d+1. The quotient is stored in the device d and the remainder is stored in the

58

PLC Course

chapter four

NEG NEGP

3 3

Negative Negative ( Pulse ) Negative ( Double ) Negative ( Double & Pulse ) to -

DNEG 3 DNEGP 3

Changes the sign of the data in the specified device d, i.e. changes + and to + .

59

PLC Course

chapter four

Increment/Decrement Command

INC INCP DINC DINCP

3 3 3 3

Increment by one Increment by one ( Pulse ) Increment by one ( Double ) Increment by one ( Double & Pulse )

Adds 1 to the data of the specified device d and stores the result in the device d.

DEC DECP DDEC DDECP

3 3 3 3

Decrement by one Decrement by one ( Pulse ) Decrement by one ( Double ) Decrement by one ( Double & Pulse )

Subtracts 1 to the data of the specified device d and stores the result in the device d.

60

PLC Course

chapter four

Logical Operation Command


WAND WANDP DWAND


DWANDP

7 7 7/9/11

Word Data AND Operation Word Data AND Operation ( Pulse ) Word Data AND Operation ( Double )

7/9/11 Word Data AND Operation ( Double & Pulse )

After executing AND operation for each bit data of s1 and s2, the result is saved in the device d for each bit data. This table shows the result of AND operation for each bit data.

61

PLC Course

chapter four 7 7 7/9/11 7/9/11 Word Data OR Operation Word Data OR Operation ( Pulse ) Word Data OR Operation ( Double ) Word Data OR Operation ( Double & Pulse )

WOR WORP DWOR DWORP

After executing OR operation for each bit data of device s1 and s2, the result is saved in the device d for each bit data. This table shows the result of OR operation for each bit data.

62

PLC Course WXOR WXORP DWXOR DWXORP Pulse )


chapter four 7 7 7/9/11 7/9/11 Word Data Exclusive OR Operation Word Data Exclusive OR Operation ( Pulse ) Word Data Exclusive OR Operation ( Double ) Word Data Exclusive OR Operation ( Double &

After executing XOR operation for each bit data of s1 and s2, the result is saved in the device d for each bit data. This table shows the result of XOR operation for each bit data. Bit data of S1 Bit data of S2 Operation result XOR : Exclusive OR 1 1 0 1 0 1 0 1 1 0 0 0

63

PLC Course

chapter four

WXNR WXNRP DWXNR DWXNRP Pulse )


7 7 7/9/11 7/9/11

Word Data Exclusive NOR Operation Word Data Exclusive NOR Operation ( Pulse ) Word Data Exclusive NOR Operation ( Double ) Word Data Exclusive NOR Operation ( Double &

After executing XNOR operation for each bit data of s1 and s2, the result is saved in the device d for each bit data. This table shows the result of XNOR operation for each bit data. Bit data of S1 Bit data of S2 Operation result XNOR : Exclusive NOR 1 1 1 1 0 0 0 1 0 0 0 1

64

PLC Course

chapter four

Rotate/Shift Command

ROL ROLP DROL DROLP

3 3 3 3

Rotate Left Rotate Left ( Pulse ) Rotate Left ( Double ) Rotate Left ( Double & Pulse )

1. Rotates the bit data in the specified device d to the left by one bit. 2. The data of the last output bit( MSB ) is stored in the carry flag and the LSB as below.

65

PLC Course

chapter four

ROR RORP DROR DRORP

3 3 3 3

Rotate Right Rotate Right ( Pulse ) Rotate Right( Double ) Rotate Right ( Double & Pulse )

1. Rotates the bit data in the specified device d to the right by one bit. 2. The data of the LSB is stored in the carry flag and the MSB as below .

66

PLC Course

chapter four

RCL RCLP DRCL DRCLP

3 3 3 3

Rotate Left with Carry Rotate Left with Carry ( Pulse ) Rotate Left with Carry ( Double ) Rotate Left with Carry ( Double & Pulse )

1. Rotates the bit data in the specified device d to the left by one bit. 2. The data of the last output bit( MSB ) is stored in the carry flag and the data of the carry flag is shifted to the LSB as below .

67

PLC Course

chapter four

RCR RCRP DRCR DRCRP

3 3 3 3

Rotate Right with Carry Rotate Right with Carry ( Pulse ) Rotate Right with Carry ( Double ) Rotate Right with Carry ( Double & Pulse )

1. Rotates the bit data in the specified device d to the right by one bit. 2. The data of the LSB is stored in the carry flag and the carry flag is shifted to the LSB as below.

68

PLC Course

chapter four

BSFT BSFTP

5 5

Bit Shift Bit Shift ( Pulse )

1. Shifts a bit one by one from the start device s to the end device e. 2. The direction of bit shift is determined by the order of the specified device. If s is greater than e, the bit shift is to the right and if s is less than e, the bit shift is to the left. 3. After the shift, the start device is filled with 0 .

WSFT WSFTP

5 5

Word Shift Word Shift ( Pulse )

1. Shift the word data one by one from the start device s to the end device e. 2. The direction of data shift is determined by the order of the specified device. If s is greater than e, the bit shift is to the right and if s is less than e, the bit shift is to the left. 3. After the data shift, the start device is filled with h0000 .
69

PLC Course

chapter four

SR

Shift Register

1. Shifts the bit data one by one as much as n from the start device d. 2. The shift is occurred when the C( Clock ) gets ON in the rising edge 3. The shifting direction is determined by the input condition D( Direction ), that is, When the input condition C goes from low to high, If D gets ON, the direction is to the right and if D gets OFF, the direction is to the left. 4. After shifting the area, the blanked bit( most left or right ) is filled with the input condition I( Input data ). 5. When R( Reset ) gets ON, All devices as much as n from the start device d are cleared.

70

PLC Course

chapter four

Jump/Interrupt Command

JMP JME

1/3 1

Jump End of Jump

1. If the input condition of [ JMP n ] gets ON, the operation jumps to [ JME n ] and all instructions between [ JMP n ] and [ JME n ] are not executed. 2. [ JMP n ] is matched with [ JME n ] which the number n is same each other. 3. This command is applicable for the emergency. 4. [ JMP 0 ] can be used repeatedly.

71

PLC Course

chapter four 3 1 3 Start of FOR ~ NEXT Loop End of FOR ~ NEXT Loop Break of FOR ~ NEXT Loop

FOR NEXT BREAK

1. In Run mode, [ FOR n ] Command executes the program between [ FOR n ] and [ NEXT ] as much as n, the next step of [ NEXT ] command is executed. 2. [ FOR ~ NEXT ] loop can be used and nested up to 5 times within the same program. 3. When END or RET Command is executed between [ FOR ~ NEXT ] loop, or [ NEXT ] Command is executed before [ FOR n ] Command, the loop is not executed. 4. JMP n ~ JME n ] Command is executed within the same [ FOR ~ NEXT ] loop and [ FOR ~ NEXT ] within [ JMP n ~ JME n ] is ignored. 5. to finish [ FOR ~ NEXT ] loop, use [ BREAK ] Command.]

72

PLC Course CALL CALLP SBRT RET

chapter four 1/3 1/3 1/3 1/3 Call Subroutine Call Subroutine ( Pulse ) Start from Subroutine Return from Subroutine

1. The subroutine program between [ SBRT n ] and [ RET ] command is executed by calling of [ CALL n ] or [ CALLP n ] command. 2. Same subroutine can be called several times within the program. 3. The position of subroutine program shall be after END Command. 4. When n exceeds the available range or only [ CALL n ] or [ CALLP n ] Command is existed, or only [ SBRT n ] or [ RET ] Command is existed, the processing error is occurred. 5. It is possible to call another subroutine in a subroutine max. 64 times of the nested subroutine calling is available.

73

PLC Course EI DI EI n DI n [ EI ] [ EI n ]

chapter four 1 1 1 1 Enable Interrupt Disable Interrupt Enable Interrupt ( not used in K500, K1000) Disable Interrupt ( not used in K500, K1000)

1. Makes TDI ( Time Driven Interrupt ) and PDI ( Process Driven Interrupt ) operation possible . 2. Interrupt program set by the parameter can be executed after this command is executed. 3. In case of K3, K4, K5 and K4E, when n is used, the interrupt specified as n is only allowable. When n is not used, i.e., when [ EI ] command is used, all interrupts set in the parameter are enabled. 4. When PLC mode is changed to Run mode, all interrupts are disabled. So, to use interrupt, [ EI ] or [ EI n ] command shall be executed. [ DI ] [ DI n ] 1.Stops TDI ( Time Driven Interrupt ) and ( PDI : Process Driven Interrupt ) operation. 2. The interrupt program can not be executed after this instruction is executed. 3. when n is used, only the interrupt specified as n is disabled. When n is not used, i.e., when [ DI ] command is used, all interrupts set by the parameter are disabled.

74

PLC Course

chapter four

TDINT INT IRET

1 1 1

Time Driven Interrupt External Interrupt Return from Interrupt

1. Indicates the start of TDI ( Time Driven Interrupt ) routine. 2. The program after the command is executed only when TDI is occurred.. 3. In case of K500 and K1000, the period of occurring interrupt is ranged from 5 msec to 10 sec. The start of the interrupt program is indicated by TDINT and its end is indicated by IRET Command. 4. In case of K3, K4 and K5, the period of occurring interrupt is ranged from 10 m sec to 60 sec. For the TDI from 0 to 5 or 0 to 13, the start of the interrupt is indicated by [ TDINT n ] ( n: 0 ~ 5 or 0 ~ 13 ) and the end is indicated by IRET Command. 5. The execution time of TDI program has to be set shorter than the interrupt period. 6. TDI is not occurred during the execution of the application command. 7. The interrupt program shall be in after END Command.
75

PLC Course

chapter four

8. To use TDI Command, the parameter, the parameter for the TDI has to be set correctly.

76

You might also like