Masterk Instructions Programming
Masterk Instructions Programming
User’s Manual
MASTER-K
Instructions & Programming
LG Industrial Systems
Chapter 1 Introduction
1 Introductions
1.1 Introductions
The chapter 1 ‘Introduction’ will provide brief information about the features, functions, and operation of
1.2 Features
Realize the lightning processing speed at 0.2 with dedicate arithmetic processor.
b) Enhanced self-diagnostic functions :
With detailed self-diagnostic error codes, the cause of error can be identified easily.
c) Debugging operation
1) The I/O (P) and data (D) registers may differ for each series. Please refer the memory map of each
series at the chapter 2.2 before convert a program for other MASTER-K series.
2) Some instructions are not supported by all series. Please refer the instruction table of appendix 9.
1-1
Chapter 2 Functions
2.4.4 Setting the mode of CPU (RUN / STOP) when an error is occurred .. 2-14
2 Functions
Basic 30
Numbers of
Instructions
Application 226
P0000 ~ P001F
P (I/O relay) P0000 ~ P005F (96 points)
(32 points)
M0000 ~ M015F
M (Auxiliary relay) M0000 ~ M031F (512 points)
(256 points)
K0000 ~ K007F
K (Keep relay) K0000 ~ K015F (256 points)
(128 points)
L0000 ~ L007F
L (Link relay) L0000 ~ L015F (256 points)
(128 points)
F0000 ~ F015F
F (Special relay) F0000 ~ K015F (256 points)
(256 points)
T000 ~ T031
100ms T000 ~ T095 (96 points)
(32 points)
T (Timer relay)
T032 ~ T047
10ms T096 ~ T127 (32 points)
(16 points)
C000 ~ C015
C (Counter relay) C000 ~ C127 (128 points)
(16 points)
S00.00 ~ S15.99
S (Step controller) S00.00~ S31.99 (32100 steps)
(16100 steps)
D0000 ~ D0063
D (Data register) D0000 ~ D0255 (256 words)
(64 words)
Special functions Real time clock, High speed counter, RS-485 communication
2-1
Chapter 2. Functions
Basic 30
Numbers of
Instructions
Application 226 228
1. Signed instruction
16 bit : − 32768 ~ 32767
32 bit : − 2147483648 ~ 2147483647
The range of integer
2. Unsigned instruction
16 bit : 00000 ~ 65535
32 bit : 00000000 ~ 4295967295
Special functions Real time clock, RUN mode editing, Forced I/O control
2-2
Chapter 2. Functions
2.2.1 K10S1
0 ~ F 0000 ~ FFFF
P00 D000
I/O relay Data Register Parameter setting area
(32 points) “P” Word
P01 (64 words)
T000 S00
Timer relay (100ms) Step Controller
2-3
Chapter 2. Functions
0 ~ F 0000 ~ FFFF
P00 D000
I/O relay Data Register Parameter setting area
(96 points) “P” Word
P05 (256 words)
T000 S00
Timer relay (100ms) Step Controller
2-4
Chapter 2. Functions
0 ~ F 0000 ~ FFFF
P00 D0000
I/O relay Data Register Parameter setting area
(See the remark) “P” “D” Word
P ✼✼1 D ✼✼✼ 2
T000 S00
Timer relay (100ms) Step Controller
64 points “T”
T255 Remark
C000
Counter relay P✼✼1 D✼✼✼✼2 D✼✼✼✼3
256 points MK1000S P63 (1,024 pts) D9500 D9999
“C”
C255
MK300S P31 (512 pts)
D4500 D4999
MK200S P15 (256 pts)
2-5
Chapter 2. Functions
The input devices hold ON/OFF data sent from external devices (e.g. pushbuttons, select
switches, limit switches, digital switches, etc.) to input module. Input data is used by the
program as contact data (NO1 and NC contacts) and as the source data for basic and
application instructions.
The output devices are used to output operation results of the program from the output module
to external devices (e.g. solenoids, magnetic switches, signal lamps, digital indicators). Only NO
The redundant P devices that are not connected to external devices can be used in the same
P0000 P0020
( ) P0000
P0001 Input
P0001 P0020 P0021
( ) P0002
P0002 P0023
( )
P0021
P0020
P0021
P0020 P0021 P0024 Output
P0023
( )
P0024
The input signals are stored in batch in the input data memory before execution of each scan.
The data in the input data memory is used for execution of the sequence program operation.
The operation results are output by each result to the output data memory. The data in the
output data memory is output in batch to the output modules after execution of the END
instruction. Please make sure that there is no conflict of input and output in the user program
because the MASTER-K series uses a P area for input and output in common.
1
NO : Normally Open contact, NC : Normally Closed contact
2-6
Chapter 2. Functions
< Figure 2. Flow of input / output data in the refresh mode >
Write
Output P
Write Output
Read Data memory
module
CPU module
- Input refresh
Input data is read ( ) in batch from the input module before execution of step 0 and stored
in the input data memory.
Input data is read ( ) from the input data memory and used for execution of the sequence
program.
Output data is read ( ) from the output data memory and used for execution of the
sequence program.
Data ( ) in the output data memory is output in batch to the output module after execution
of the END instruction.
external devices. All M area except designated as latched area will be cleared as 0 when the
PLC is switched on or turned to RUN mode. With K200S / K300S / K1000S, a user can change
2-7
Chapter 2. Functions
is switched on or turned to RUN mode. The K area can be cleared by following methods;
same as M area if no link module is mounted on the PLC system. With K200S / K300S /
K1000S, it is possible to change the range of latch area by parameter setting. For the detail
usage of L area, please refer the list of link relay at appendix and the computer link user’s
manual.
If the OUT instruction is used, the S area functions as last-in priority. Otherwise, it functions as
When the CPU is switched on or turned to RUN mode, the S area will be initialized as first step
OUT S00.02 In the same group, the last-in condition has the
priority to run.
OUT S00.29
OUT S00.61
SET S00.03
SET S00.04
2-8
Chapter 2. Functions
the timer instructions (TON, TOFF, TMR, TMON, TRTG). The maximum timer setting value is
hFFFF by hexadecimal or 65535 by decimal. The following figure shows the types and timing
Timer
instruction
Timer Timing
Description Time chart
instruction method
Input
condition OFF Delay timer
TOFF OFF Delay Decrement t
Timer
output t =setting value
Input Accumulation
condition timer
Accumulation t = t1 + t2
TMR ON Delay Increment
t1 t2
Timer
output t =setting value
Timer
output t =setting value
Input
condition Retriggerable timer
TRTG Retriggerable Decrement t
Timer
output t =setting value
2-9
Chapter 2. Functions
the input signal is switched from off to on. MASTER-K series have 4 counter instructions such
as CTU, CTD, CTUD, and CTR. The maximum counter setting value is hFFFF ( = 65535). The
Count Pulse
U CXX CXXX
R <S> XXXX
Reset signal
Up Count Pulse
CTU Increment 1 Setting
Counter value
Elapsed value
Counter output
Reset signal
Counter output
Reset signal
Increase pulse
Up/Down Increment /
CTUD 2 Decrease pulse
Counter Decrement Setting
Elapsed value value
Counter output
Reset signal
Count Pulse
Ring
CTR Increment 1 Setting
counter
Elapsed value value
Counter output
2-10
Chapter 2. Functions
The data resister number designated by the double-word instruction holds the lower 16 bits and
Example)
D51 D50
h1234 h5678
The D area except latched area assigned by parameter setting will be cleared as 0 when the
with ‘#’ symbol points the real address of data register at which the result of operation is stored.
If #D is used with a double-word instruction, the lower 16 bits will stored at the data resister
number designated by the contained value of #D, and higher 16 bits will stored at the data
resister number + 1.
Example)
D0000 h7893
D1000
Remark
If the value of data register assigned at # D exceeds the physical address range of D area, the operation error
flag(F110) will be set and the relevant instruction will be ignored.
2-11
Chapter 2. Functions
the type of CPU. See the list of special registers at the appendix and be careful when use those
2-12
Chapter 2. Functions
The default value of watch dog timer is 200msec. The watch dog timer of K10S1, K10S, K30S,
By setting the 100msec timer area, the 10msec timer area is automatically set as the rest of
area.
The latch area designated by parameter setting will hold the result of operation when the CPU is
The latch area of K10S1/K10S/K30S/K60S is fixed and can not be changed. Please refer the
2-13
Chapter 2. Functions
2.4.4 Setting the mode of CPU (RUN / STOP) when an error is occurred
(Applicable to K200S / K300S / K1000S only)
When a non-critical error such as fuse blown or operation error, the CPU will keep running or
stop operation according to the parameter setting. See the following table for details.
* = Default setting
RUN
Error type Description Mode Error flag
LED
BCD error
The result of BCD conversion is
exceeds the specified range (9999 or
Operation RUN * / ON * / F110
99999999)
Error STOP OFF F115
Over range error
One or more operands exceed the
specified device range.
The F110 bit is updated after each instruction is completed. Therefore, even an operation error
was occurred, the F110 will be cleared if the next instruction is completed normally. In other
hand, the F115 will be set when an operation error occurs and keep the on status until user
K10S1
2
K3P-07AS
3
K3P-07BS / K3P-07CS
2-14
Chapter 2. Functions
The block type models of MASTER-K series include the high speed counter function in the main
module. When the ‘HSCNT’ instruction is used, the high speed counter parameters should be
set with KGL-WIN or KLD-150S. Refer the 5.22.1 ‘HSCNT’ instruction part.
Each of interrupts has a priority level. If two or more interrupts occur at the same time, the CPU
will process the interrupt that has higher priority. Priority levels are described by numbers, and
TDI is the interrupt that occurs periodically. The period of interrupt can be set with parameters
PDI is the interrupt that occurs when an input of interrupt module was turned on.
The I/O number is allocated automatically by CPU module according to the actual status of
module. However, user can reserve I/O number allocation with parameter setting, then it makes
1) User can assign the type of module (input, output, or special module) and I/O occupation
2) If the reserved I/O number is larger than the I/O number of actual module, the redundant
reserved I/O points are used as internal relay. Otherwise, the redundant actual I/O points are
disabled.
3) Non-reserved slots occupy I/O points as the I/O points of actual module, and special
2-15
Chapter 2. Functions
No
000 010 030 040 050 060 070 080 090
parameter
~00F ~02F ~03F ~04F ~05F ~06F ~07F ~08F ~10F
setting
*2) The upper 16 pts (P030 ~ P03F) are used as internal relay.
*3) Since the slot is reserved as empty, the input module is disabled.
With this parameter setting, user can decide that the result of operation will be output to external
The K200S series has no interrupt module. Therefore, user can assign an input module as interrupt
input module and input signals applied to this module will be handled as external interrupt input.
2-16
Chapter 2. Functions
Input refresh
Step : 0000
Step : 0001
Operation :
: 1 Scan
END
Self-diagnosis
Output refresh
The CPU refreshes input data, then executes the sequence program stored in the internal
memory, beginning with step 0 to the END instruction. After executing the END instruction, the
CPU performs self-diagnosis and refreshes output data, and then returns to input refresh.
Remark
Scan : The series of steps from step 0 to the next step 0 is called a scan. Therefore, a scan time of the CPU is
calculated as a total of the processing time of the sequence program (step 0 to END) and the internal
2-17
Chapter 2. Functions
MASTER-K series has 4 operation modes as shown below. The arrow indicates that mode
change is available.
RUN Program
mode mode
Pause Debug
mode mode
memory area
Execution of
sequence program
I/O refresh
2-18
Chapter 2. Functions
Self-diagnosis
I/O refresh
- Program read / write / monitor can be performed in program mode. External wiring check is also
Self-diagnosis
- Stops the operation of CPU, but keep the status of output and internal memory.
Stop operation
Self-diagnosis
I/O refresh
2-19
Chapter 2. Functions
When an interrupt occurs, the CPU module will stop the current operation and execute the
corresponding interrupt routine. After finish the interrupt routine, the CPU resume the sequence
MASTER-K series provides 2 types of interrupt. The TDI (Time driven interrupt) occurs with the
constant period, and PDI (Process driven interrupt) occurs with the status of external input.
Before to use interrupt function in sequence program, the parameter setting should be done
properly. (See 2.4.6 for parameter setting) Then the corresponding interrupt routine should be
written after END instruction. (Refer chapter 4 for details) If interrupt routines are not matched with
parameter settings, an error occurs and the operation of CPU will be stopped.
To execute an interrupt routine, use the EI instruction to enable the corresponding interrupt. The
interrupt routine is not executed if an interrupt factor occurs before execution of an EI instruction.
Once an interrupt is enabled with EI instruction, it keeps the enabled status until DI instruction is
executed to disable the interrupt. When a CPU is turned to RUN mode, all interrupts are disabled
by default.
When multiple interrupt factors occur simultaneously, interrupt routines are executed according to
the priority given to the each interrupts. If an interrupt factor that has higher priority occurs while
other interrupt that has lower priority are executing, the interrupt routine of lower priority will be
stopped and the interrupt of higher priority will be executed first. The following figure shows how a
1 Program starts
1
Main Program
2 2 Interrupt 2 occurs
routine 2
2-20
Chapter 2. Functions
1) Parameter setting
Remark
a) Period is the interval of time driven interrupt occurring. It is variable from 10msec to 60000msec (60sec) by
100msec unit.
b) The priority is also used as the number of interrupt. To enable/disable the TDI5 interrupt with priority level 2, for
example, use EI/DI instruction as ‘EI 5’/ ‘DI5’.
2-21
Chapter 2. Functions
TDI occurs periodically with the constant interval assigned in parameter setting. The interrupt
routine of TDI starts with the TDINT instruction and ends with the IRET instruction.
When multiple interrupt factors occur simultaneously, interrupt routines are executed according
to the priority given to the each interrupt. If an interrupt factor has higher priority occurs while
other interrupt has lower priority are executing, the interrupt routine of lower priority will be
stopped and the interrupt of higher priority will be executed first. Otherwise, two interrupts are
executed consequently.
The maximum numbers of TDI for K200S / 300S / 1000S are shown as following table. See the
400msec
200msec 200msec
A B C B A B B A B C
2-22
Chapter 2. Functions
PDI occurs when the input status of interrupt module is changed from OFF to ON or from ON to
OFF. (Select by DIP switch setting) Since K200S does not have interrupt module, PDI will occur
when the input assigned as interrupt input by parameter setting is changed from OFF to ON.
The execution order of multiple interrupts is similar as TDI. The following figure shows an
1
Main Program
2
PDI 0
9
PDI 1
5
Interrupt routine 0 6
PDI 2
Interrupt routine 1 7
2 4 6
3
Interrupt routine 2 4
8
1 Program starts
2 Interrupt 2 occurs
2-23
Chapter 2. Functions
Since the RTC function is optional function, not all MASTER-K series support this function.
Please refer the Catalog and CPU manual for applicable models.
Clock operation by the RTC function is continued with a battery or super capacitor when the
1) Clock data
Clock data is the data comprised of year, month, day, hour, minute, second, and date.
2) Precision
2-24
Chapter 2. Functions
The first one is using a handy loader (KLD-150S) or graphic loader (KGL-WIN). For detailed
The second one is write sequence program. By switching a special bit on, user can replace
the current RTC data with the preset data stored in a specified memory area. The followings
M310 (RTC data change bit) : When the M310 bit is switched on, the new data in D249 ~
D252 will be moved to L12 ~ L15. After data is moved, M310 has to be switched off
immediately because current data will be updated every scan while M310 is on.
<Example program>
P000
[ MOV h9900 D0249 ] :1999
Start switch
[ MOV h1701 D0250 ] :January 17th
[ MOV h1100 D0251 ] :11h Sunday.
[ MOV h2453 D0252 ] :53m 24s
[ D M310 ] :Changing enable
Other Program
Remark
a) The RTC data has not been set by factory default. Before using RTC function, write a correct RTC data to
b) If unreasonable RTC data is written to the CPU, the RTC operation can not be executed normally.
Example : 13 (month) 32 (day)
2-25
Chapter 2. Functions
To read / write RTC data of K200S / K300S / K1000S is similar as K10S / K30S / K60S. The
only difference is memory address of current / preset RTC data. See the following table.
When the M1904 bit is switched on, the new data in D4990 ~ D4993 (D9990 ~ D9993) will be
moved to F53 ~ F56. After data is moved, M1904 has to be switched off immediately
because current data will be updated every scan while M1904 is on.
Other Program
2-26
Chapter 2. Functions
It is possible to output a designated data regardless of the result of operation. This function is
useful to check operation of the output modules and wiring between the output modules and
external devices.
a) Write the forced I/O data (h8721) to the corresponding data word. P10 is matched to the
D4810 word.
<D4810 word>
F E D C B A 9 8 7 6 5 4 3 2 1 0
1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 1
b) Write the forced I/O address (All bit = hFFFF) to the corresponding address word. Write
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
F E D C B A 9 8 7 6 5 4 3 2 1 0
P P P P P P P P P P P P P P P P
F E D C B A 9 8 7 6 5 4 3 2 1 0
1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 1
2-27
Chapter 2. Functions
a) Write the forced I/O data (h0001) to the corresponding data word. P10 is matched to the
D9807 word.
<D9807 word>
F E D C B A 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
b) Write the forced I/O address (last bit = h0001) to the corresponding address word. Write
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
F E D C B A 9 8 7 6 5 4 3 2 1 0
P P P P P P P P P P P P P P P P
F E D C B A 9 8 7 6 5 4 3 2 1 0
P P P P P P P P P P P P P P P 1
User can insert, delete, or change instructions of program while the CPU is running. This
function is useful to debugging or test-operation. Please refer the user’s manual of KLD-150S or
Remark
The program edit in RUN mode can not be performed for the following instructions – JMP, JME, CALL, SBRT,
FOR, and NEXT instructions. Moreover, the program that has very long scan time (longer than 2 seconds) can
2-28
Chapter 2. Functions
2.6.5 Self-diagnosis
The watch dog timer is an internal timer of a PLC to detect the error of hardware and a
sequence program. The default value is set as 200msec, and it is changeable with parameter
setting. (K200S / K300S / K1000S only) Refer 2.4.1 for details on the parameter setting.
The CPU resets the watch dog timer before step 0 is executed (after the END processing is
finished). When the END instruction has not been executed within the set value due to an error
occurred in the PLC or the long scan time of a sequence program, the watch dog timer will
times out. When a watch dog timer error is occurred, all outputs of the PLC are turned OFF, and
the ERR LED of the CPU will flashes. (RUN LED will be turned OFF) Therefore, when use FOR
~ NEXT or CALL instruction, insert WDT instruction to reset the watch dog timer.
If one or more I/O modules are mounted/dismounted while the PLC is powered, the
corresponding bit (F0040 ~ F0050 : 32 bits) will be switched on. If a module is mounted
P C
W P
R U
Slot No : 0 1 2 3 4 5 6 7
MSB LSB
F004
(word) 1 1 1
MSB LSB
F005
1 1 1
(word)
Error occurred at slot 31
When the voltage of the battery for back-up the memory IC of CPU are lower than the minimum
back-up voltage, the BAT LED of CPU module will be turned on.
2-29
Chapter 2. Functions
instruction. The skipped instructions are processed as NOP instruction. Max. 128 JMP-JME can be
JMP 000
LOAD P0000
Process
as ‘NOP’
OUT P001
JME 000
2) The JMP n instruction should be matched only one JME n instruction. The duplication of JME is not
JMP 001
JME 001
Error No Error
3) The JMP n instruction without corresponding JME n instruction (stand-alone JMP n) will cause
program error. If only JME or JMP is inside of a loop (subroutine, FOR~NEXT block, or interrupt
routine), an operation error will occur when the JMP instruction is enabled.
END
JME 005
NEXT
2-30
Chapter 2. Functions
1) CALL n, CALLP n :
The CALL(P) instruction executes the subroutine program specified by the pointer ‘n’. Multiple
2) SBRT / RET
SBRT instruction shows the start of subroutine program, and RET shows the end. Those two
LOAD P000
END
RET : Error (Stand Alone)
LOAD P042
END
LOAD P010
CALL 30
END
SBRT 30 : Error (No RET)
2-31
Chapter 2. Functions
The MCS n instruction starts a master control sequence. Each MCS instructions are followed by
a number (n) that shows the priority of the master control. The range of n is 0 ~ 7.
MCS 0 : High
↕
MCS 7 : LOW
executed, all master controls that have lower priority are cleared automatically.
MCS 0
MCS 1
When use master control, it should start from the highest priority level and end from the lowest
priority level. The MCS n and MCSCLR n instructions should be in pairs. Otherwise, a program
error occurs.
2-32
Chapter 2. Functions
FOR and NEXT instructions should be in pairs, and each pairs should be start by FOR
If there is a stand-alone FOR or NEXT instruction or the nesting level exceeds 6, a program
LOAD P000
FOR 1 : No error (3 level nesting)
FOR 2
FOR 3
NEXT
NEXT
NEXT
END
LOAD P001
FOR 20
NEXT
NEXT : Error (Stand-alone NEXT)
END
LOAD P002
FOR 20
2-33
Chapter 2. Functions
1)If there is no END in a sequence program, a program error occurs and CPU stops operation.
LOAD P012
JMP 10
2)If there is no RET in a subroutine program, a program error occurs and CPU stops operation.
END
SBRT
LOAD P000
: Missing RET
OUT P010
If a memory device is used as an output of operation two or more times, a dual coil error occurs.
Because this is not a serious error, it does not make the CPU stop.
LOAD P0000
OUT M000
2-34
Chapter 2. Functions
The F110 is updated after each instruction is executed. However, the executed instruction is not
related to any error (such as the LOAD instruction), it keeps the previous value. In other hand,
the F115 keeps the on status after it was switched on at once. To clear the F115 flag, execute
the CLE instruction. The following table shows an example of F110 and F115 operation.
INC D0 No OFF ON
2-35
Chapter 2. Functions
2-36
Chapter 2. Functions
Code
Error type Message CPU Description Corrective action
(F006)
Internal The operating system ROM or other Contact the nearest
System error h0001 Stop
system error H/W is defective. LG representative
OS ROM OS ROM Contact the nearest
h0002 Stop The internal system ROM is defective.
error error LG representative
OS RAM OS RAM Contact the nearest
h0003 Stop The internal system RAM is defective.
error error LG representative
Data RAM Data RAM The RAM at which a data is stored is Contact the nearest
h0004 Stop
Error error defective. LG representative
Program The RAM at which a program is Contact the nearest
Error h0005 Stop
RAM error stored is defective. LG representative
Gate array Contact the nearest
G/A error h0006 Stop The gate array of CPU is defective.
error LG representative
Sub rack
Sub power The expansion rack is power off or Check the expansion
power down h0007 Stop
error defective. rack is powered.
error
Power off and restart
the CPU. If error still
OS WDT OS WDT The CPU operation time (not the scan
h0008 Stop occurs, contact the
time out error error time) is too long.
nearest LG
representative
Shared RAM Common Contact the nearest
h0009 Stop Shared RAM interface error
error RAM error LG representative
Fuse break Run The fuse used in output module is Check the fuse and
I/O fuse error h000A
error (Stop) blown. replace it.
Instruction OP code CPU meets an instruction can not be Contact the nearest
h000B Stop
code error error decoded during executing program. LG representative
Check the flash
Flash User memory CPU can not access the internal flash
H000C Stop memory and replace it
Memory error error memory
if necessary.
① Power off -
① Mount or dismount a module while
Remount module –
the PLC is powered. A module is
Power on
I/O slot error I/O slot error h0010 Stop mounted improperly.
② Replace the I/O
② I/O module or expansion cable is
module or expansion
defective.
cable
I/O points exceed the maximum limit
Maximum I/O
Max I/O over h0011 Stop points (Fmm mounting numbers over Replace I/O unit
over
error, ∙∙∙)
Special Card Special I/F Error occurred during special card Contact the nearest
h0012 Stop
I/F error error interface LG representative
Fmm 0 I/F Fmm 0 I/F Contact the nearest
h0013 Stop Fmm 0 I/F error
error error LG representative
Fmm 1 I/F Fmm 1 I/F Contact the nearest
h0014 Stop Fmm 1 I/F error
error error LG representative
Fmm 2 I/F Fmm 2 I/F Contact the nearest
h0015 Stop Fmm 2 I/F error
error error LG representative
Fmm 3 I/F Fmm 3 I/F Contact the nearest
h0016 Stop Fmm 3 I/F error
error error LG representative
Parameter Parameter When the parameter is wrong or has Change parameter
h0020 Stop
error error incorrect checksum. setting
2-37
Chapter 2. Functions
2-38
Chapter 3 Instructions
3 Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
A
OR LOAD - B - Parallel connection of blocks 4 8
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
Remark
Applicable CPU type : = All CPUs ; = K10S1 / K10S / K30S / K60S ; = K200S / K300S / K1000S
3-1
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
Mnemonic Function
Ladder symbol Contents of processing CPU Page
symbol No.
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
3-2
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
Input
TOFF - TOFF Txxx v - t 4 – 29
Output
Timer relay No. t = setting value
3-3
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
↑
Setting value Output
Reset
Counter relay No.
Count ↓ Count
Pulse
Pulse
D CTD C xxx
CTD - Reset - Current Setting 4 – 38
v value value
R <S>
↑
Output
Setting value
Reset
Counter relay No.
Up ↓ Up
Pulse Pulse
U CTUD C xxx
Down Down
Pulse Pulse
CTUD - 4 – 39
D Current
Reset value Setting
R <S> v value
↑
Setting value Output
Reset
Counter relay No.
Count ↓
Pulse Count
D CTR C xxx Pulse
CTR -
Reset
4 – 41
Current
R <S> v value
↑
Setting value Output
3-4
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
16 bits
5-1
MOVP 081 MOVP S D [ S ] [ D ]
32 bits
5-1
DMOVP 083 DMOVP S D [ S + 1, S ] [ D + 1, D ]
5-3
DCMOVP 087 DCMOVP S D [ S + 1, S ] [ D + 1, D ]
S Group move D
GMOV 090 GMOV S D n
16 bits
5-5
GMOVP 091 n
GMOVP S D n
Filling move D
FMOV S D n
FMOV 092
16 bits
S
5-7
n
FMOVP 093 FMOVP S D n
BMOV S D Cw
BMOV 100 Bit move
n bit
5-9
BMOVP 101 BMOVP S D Cw (See the 5-9 page for detail usage)
3-5
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
16 bits
Binary BCD 5-11
BCDP 061 BCDP S D [ S ] [ D ]
32 bits
Binary BCD 5-11
DBCDP 063 S D [ S + 1, S ] [ D + 1, D ]
DBCDP
16 bits
BCD Binary 5-14
BINP 065 BINP S D [ S ] [ D ]
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
5-16
CMPP 051 CMPP S1 S2 Result is indicated by F120 ~ F125
S2]
5-16
DCMPP 053 DCMPP S1 S2 Result is indicated by F120 ~ F125
S2
5-19
TCMPP 055 TCMPP S1 S2 D
Result(16bits) is stored at D
5-19
DTCMPP 057 DTCMPP S1 S2 D Result(32 bits) is stored at [ D+1,
D]
3-6
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
16 bits
The input condition is switched on
AND= 094 = S1 S2 5-22
when [S1] = [S2]
OR= 188 = S1 S2 5-23
16 bits
AND> 096 > S1 S2 when [S1] > [S2] (Signed 5-22
comparison)
OR> 196 > S1 S2 5-23
3-7
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
32 bits
The input condition is switched on
ANDD= 095 = S1 S2 5-22
when [S1+1, S1] = [S2+1, S2]
ORD= 189 = S1 S2 5-23
32 bits
when [S1+1, S1] > [S2+1, S2]
ANDD> 097 > S1 S2 5-22
(Signed comparison)
ORD> 197 > S1 S2 5-23
32 bits
when [S1+1, S1] < [S2+1, S2]
ANDD< 099 < S1 S2 5-22
(Signed comparison)
ORD< 199 < S1 S2 5-23
3-8
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
16 bits
5-24
INCP 021 INCP D [ D ] +1 [ D ]
32 bits
5-24
DINCP 023 DINCP D [ D +1, D ] +1 [ D +1, D ]
16 bits
5-26
DECP 025 DECP D [ D ] -1 [ D]
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
Carry 15 D 0
ROL 020 ROL D
16 bits
5-28
ROLP 021 ROLP D
1 bit rotate to left
15 D 0 Carry
ROR 034 ROR D
16 bits
5-30
RORP 035 RORP D
1 bit rotate to right
Carry 15 D 0
RCL 040 RCL D
16 bits
5-32
RCLP 041 RCLP D
1 bit rotate to left include carry
15 D 0 Carry
RCR 044 RCR D
16 bits
5-34
RCRP 045 RCRP D
1 bit rotate to right include carry
3-9
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
Carry 15 D +1 0 15 D 0
DROL 022 DROL D
32 bits
5-28
DROLP 023 DROLP D
1 bit rotate to left
15 D +1 0 15 D 0 Carry
DROR 036 DROR D
32 bits
5-30
DRORP 037 DRORP D
1 bit rotate to right
Carry 15 D +1 0 15 D 0
DRCL 042 DRCL D
32 bits
5-32
DRCLP 043 DRCLP D
1 bit rotate to left include carry
15 D +1 0 15 D 0 Carry
DRCR 046 DRCR D
32 bits
5-34
DRCRP 047 DRCRP D
1 bit rotate to right include carry
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
S1 S2
S1 S2
0
S1-S2 bits
S1 S2
S1 S2
S1-S2 words
0
WSFT 070 WSFT S1 S2
5-38
WSFTP 071 WSFTP S1 S2 S2 S1
S2 S1
0
D +n D
16 bits
SR SR D n 5-40
3-10
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
16 bits
[ D1 ] [ D2 ] 5-42
XCHP 103 XCHP D1 D2
32 bits
[ D1+1, D1 ] [ D2+1, D2 ] 5-42
DXCHP 105 DXCHP D1 D2
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
ADD S1 S2 D
ADD 110
16 bits
[ S1 ] + [ S2 ] [D] 5-44
ADDP 111 ADDP S1 S2 D
5-44
DADDP 113 DADDP S1 S2 D [D+1, D]
[ S1 ] - [ S2 ] [D] 5-46
SUBP 115 SUBP S1 S2 D
5-46
DSUBP 117 DSUBP S1 S2 D [D+1, D]
5-48
MULP 121 MULP S1 S2 D [D+1] : High word, [D] : Low word
5-48
DMULP 123 DMULP S1 S2 D [D+3,D+2] = Higher 2 words
3-11
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
[ S1 ][ S2 ] [D]
DIV 124 DIV S1 S2 D
16 bits
[D+1] = Remainder 5-50
DIVP 125 DIVP S1 S2 D
[D] = Quotient
32 bits
5-50
DDIVP 127 DDIVP S1 S2 D [D+3, D+2] = Remainder
[D+1, D] = Quotient
[ S1 ] [ S2 ] [ D+1, D ]
MULSP 073 MULSP S1 S2 D
[D+1] : High word, [D] : Low word
[D+3,D+2,D+1,D]
DMULSP 077 DMULSP S1 S2 D
[D+3,D+2] = Higher 2 words
DIVSP 089 DIVSP S1 S2 D [D+1] = Remainder
[D] = Quotient
[D+1, D] = Quotient
3-12
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
ADDB S1 S2 D
ADDB 130 BCD addition
16 bits
5-52
ADDBP 131 ADDBP S1 S2 D [ S1 ] + [ S2 ] [D]
32 bits
5-52
DADDBP 133 DADDBP S1 S2 D [S1+1,S1]+[S2+1,S2] [D+1,D]
16 bits
5-54
SUBBP 135 SUBBP S1 S2 D [ S1 ] - [ S2 ] [D]
5-54
DSUBBP 137 DSUBBP S1 S2 D [S1+1,S1]-[S2+1,S2] [D+1,D]
BCD multiplication
MULB 140 MULB S1 S2 D
16 bits
[ S1 ] [ S2 ] [ D+1, D ] 5-56
MULBP 141 MULBP S1 S2 D
[D+1] : High word, [D] : Low word
BCD multiplication
[D+3,D+2,D+1,D] 5-56
DMULBP 143 DMULBP S1 S2 D
[D+3,D+2] = Higher 2 words
BCD division
5-58
DIVBP 145 DIVBP S1 S2 D [D+1] = Remainder
[D] = Quotient
BCD division
[D+1, D] = Quotient
3-13
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
16 bits
[ S1 ] AND [ S2 ] [D] 5-60
WANDP 131 WANDP S1 S2 D
32 bits
5-60
DWANDP 133 DWANDP S1 S2 D [D+1,D]
16 bits
[ S1 ] OR [ S2 ] [D] 5-62
WORP 155 WANDP S1 S2 D
5-62
DWORP 157 DWANDP S1 S2 D [D+1,D]
5-64
DWXORP 163 DWXORP S1 S2 D [D+1,D]
WXNR S1 S2 D
WXNR 164
[ S1 ] XNR [ S2 ] [D] 5-66
WXNRP 165 WXNRP S1 S2 D
3-14
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
16 bits
5-68
SEGP 175 SEGP S D Cw [S] [D]
decoding
16 bits
5-73
BSUMP 171 Quantity
DBINP S D of 1
5-73
Quantity
DBSUMP 173 DBINP S D of 1
5-75
n
S D n [S] [D]
DECO 178 DECO 0
n bits
5-77
DECOP 179 n bits
DECOP S D n Decode
[S+n] 5-79
FILRP 181 FILRP S D n
[D]
File table read
[S]
DFILR S D n
DFILR 182 [S+n]
32 bits
[S+n+1] 5-79
DFILRP 183 DFILRP S D n
[D]
[D+1]
3-15
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
File table write
[S]
FILW 184 FILW S D n
16 bits
[S+n] 5-81
FILWP 185 FILWP S D n
[D]
File table write
[S]
DFILW S D n
DFILW 186 [S+n]
32 bits
[S+n+1] 5-81
DFILWP 187 DFILWP S D n
[D]
[D+1]
4bits When
[S] n=3
DIS S D n
DIS 194
16 bits
[D] 5-83
DISP 195 DISP S D n [D+1]
[D+2]
All 0 4bits
4bits
[S]
S D n [S+1]
UNI 192 UNI
32 bits
[S+2]
5-85
UNIP 193 UNIP S D n
When
n=3 [D]
4bits
5-87
IORFP 201 IORFP D1 D2 from[D1] to [D2] ( [D1] < [D2] )
3-16
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
SBRT n
SBRT 016 Start of a subroutine
RET 004 RET End of subroutine
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
FOR n
FOR 206 Executes the sequence program
5-100
NEXT 207 NEXT between FOR and NEXT n times
3-17
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
STC
STC 002 Set the carry flag
5-102
CLC 003 CLC Clear the carry flag
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
Establish a communication
CONN 246 CONN n1 st D SS
channel
3-18
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
EI n
EI 236 Enable an interrupt
5-119
DI 239 DI n Disable an interrupt
EI
EI 221 Enable all interrupts
5-119
DI 222 DI Disable all interrupts
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
3-19
Chapter 3. Instructions
Unit
CPU
Mnemonic Function
Ladder symbol Contents of processing Page
symbol No.
3-20
Chapter 4 Basic instructions
4 Basic instructions
LOAD
LOAD NOT
OUT
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer (F110) (F111) (F112)
LOAD
LOAD NOT S O O O O O O O O
1
OUT D O O O O* O
LOAD S OUT D
LOAD NOT S
* Available only when do not use computer link module or data link module
1) LOAD S
a) Functions
Starts a NO contact.
Draw the on/off data of the specified device ( S ) and use the data as an operation result.
2) LOAD NOT S
a) Functions
Starts a NC contact.
Draw the on/off data of the specified device ( S ) and use the data as an operation result.
3) OUT D
a) Functions
Several OUT instructions can be used in parallel with one operation result.
4-1
Chapter 4. Basic instructions
4) Program example
When the input condition (P020) is switched on, the P060 and P061 will be switched on and the
P062 will be switched off.
[ Program ]
P020
( P060 )
( P061 )
LOAD
P020
( P063 )
[ Time chart ]
P020
P060
P061
P063
4-2
Chapter 4. Basic instructions
AND
AND NOT
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer (F110) (F111) (F112)
AND
AND NOT S O O O O O O O O 1
( )
AND S
( )
AND NOT S
1) AND
a) Functions
Read the on/off data of the specified device ( S ), performs the AND operation of that data and
the previous operation result, and use it as a new operation result.
2) AND NOT
a) Functions
Read the on/off data of the specified device ( S ), performs the AND operation of that data and
the previous operation result, and use it as a new operation result.
3) Program example
The P061 contact will be switched on when the P020 and P021 are on and the P022 is off.
4-3
Chapter 4. Basic instructions
OR
OR NOT
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer (F110) (F111) (F112)
OR
OR NOT S O O O O O O O O 1
( )
OR S
OR NOT S
1) OR
a) Functions
Draw the on/off data of the specified device ( S ), performs the OR operation of that data and the
previous operation result, and use it as a new operation result.
2) OR NOT
a) Functions
Draw the on/off data of the specified device ( S ), performs the OR operation of that data and the
previous operation result, and use it as a new operation result.
3) Program example
The P061 contact will switched on when the one of P020 and P021 is on.
P020
( P061 )
P021
S
OR
4-4
Chapter 4. Basic instructions
1. 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.
2. System structure
Digital input Digital output
module module
[ P03 ] [ P06 ]
<Stop> PB0 0 0
1 1
<Forward> PB1
2 2
<Reverse> PB2
3 3
Motor
Reverse rotation
Forward rotation
3. Program
4-5
Chapter 4. Basic instructions
AND LOAD
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
AND LOAD 1
AND LOAD
( )
Block A Block B
1) Functions
Performs the AND operation of block A and block B, and uses it as an operation result.
2) Program example
[ Program ]
P022
AND LOAD
[ Time chart ]
P020
P022
P026
P060
4-6
Chapter 4. Basic instructions
There are two methods to connect several blocks in serial. See the following example.
[ Ladder program ]
[ END ]
[ Mnemonic program ]
The AND LOAD instruction can be used consecutively up to 7 times (8 block). When connect more than 9
blocks in serial, write a mnemonic program such as the example [ A ]. If you use KGL-WIN software and
write program in ladder mode, the KGL-WIN software will convert the ladder program into mnemonic
program [ A ] automatically.
4-7
Chapter 4. Basic instructions
4.2.2 OR LOAD
OR LOAD
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
OR LOAD 1
Block A
( )
Block A
1) Functions
Performs the OR operation of block A and block B, and uses it as an operation result.
2) Program example
[ Program ]
[ Time chart ]
P020
P024
P025
P060
P061
4-8
Chapter 4. Basic instructions
There are two methods to connect several blocks in parallel. See the following example.
[ Ladder program ]
M000 M001
( P060 )
M002 M003
M004 M005
M006 M007
M008 M009
[ END ]
[ Mnemonic program ]
The OR LOAD instruction can be used consecutively up to 7 times (8 block). When connect more than 9
blocks in parallel, write a mnemonic program such as the example [ A ]. If you use KGL-WIN software and
write program in ladder mode, the KGL-WIN software will convert the ladder program into mnemonic
program [ A ] automatically.
4-9
Chapter 4. Basic instructions
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
MPUSH
MLOAD 1
MPOP
MPUSH
MLOAD
MPOP
1) Functions
a) MPUSH : Stores the operation result (On/Off) immediately preceding the MPUSH instruction.
b) MLOAD : Reads the operation result stored by the MPUSH instruction and resume the operation with
c) MPOP : Reads the operation result stored by the MPUSH instruction and resumes the operation with
that operation result, starting at the next step. Then clears the operation result stored by the MPUSH
instruction.
d) The MPUSH instruction can be used up to 8 times consecutively. If a MLOAD instruction is used in
4-10
Chapter 4. Basic instructions
2) Program example
[ Ladder program ]
P020 P021 P022 P023 P024 P060
00000 ( )
P025 P061
( )
P026 P062
( )
P027 P063
( )
P028 P064
( )
P029 P065
( )
P02A P066
( )
00027 [ END ]
[ Mnemonic program ]
STEP INSTRUCTION
4-11
Chapter 4. Basic instructions
4.3.1 NOT
NOT
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
NOT 1
NOT
( )
1) Functions
2) Program example
Program A
P020 P021 P022 P023 P024
( P060 )
Program B
P020
( P060 )
P021
P022
P023
P024
4-12
Chapter 4. Basic instructions
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
MCS
MCSCLR O 1
MCS n - n (Nesting) : up to 7
MCSCLR n
1) Functions
When the On/Off command of MCS instruction is switched on, the sequence program between the
MCS instruction and the MCSCLR instruction that has same n of the MCS instruction is executed.
Each MCS instructions are followed by a number (n) that shows the priority of master control. 0 is
the highest priority, and 7 is lowest priority. The MCS instruction should be used in order of priority
level.
The MCSCLR instruction shows the end of master control. When a MCSCLR n instruction is
executed, all master control that has lower priority than ‘n’ are ended automatically.
4-13
Chapter 4. Basic instructions
2) Program example
Use 2 master control blocks (MCS 0 and MCS 1), and they are cleared with MCSCLR 0 instruction. The
P030
0000 [ MCS 0 ]
P031
0002 ( P060 ) MCS 0 block
P032
0004 ( P061 )
P033
0006 [ MCS 1 ]
M0001
0008 ( P062 ) MCS 1 block
M0002
0010 ( P063 )
0012 [ MCSCLR 0 ]
0013 [ END ]
Remark
1. Scanning between the MCS and MCSCLR instructions is executed even when the On/Off
command for the MCS instruction is off. Therefore, scan time does not become shorter.
2. When On/Off command for the MCS instruction is off, the operation result of MCS to MCSCLR is
as indicated below.
The timer output contact turns off and the current value
TIMER
becomes 0.
The counter output contact turns off but the current value
COUNTER
holds the present value.
OUT All turns off
3. If an instruction which does not need a contact instruction immediately before it (FOR, NEXT, EI,
DI, etc.) is contained in the MCS ~ MCSCLR block, the CPU executes the instruction regardless of
the status of the On/Off command for the MCS instruction.
4-14
Chapter 4. Basic instructions
The below relay circuit can not be programmed into PLC program directly. Therefore, it should be
[ Relay circuit ]
Manual Automatic
operation operation
P020 P021
P022
P026
P027
P061
P020 P021
[ MCS 0 ]
P022
( M010 ) Manual
P026 P027 circuit
( M011 )
[ MCSCLR 0 ]
P021 P020
[ MCS 1 ]
P024 P023
( M020 ) Automatic
P027 P029 circuit
( M021 )
[ MCSCLR 0 ]
M010 P061
( P060 )
M020
M011 P060
( P061 ) Common
M02 circuit
P061
[ END ]
4-15
Chapter 4. Basic instructions
4.5.1 OUT
OUT
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
OUT D O O O O* 2
* Available only when do not use computer link module or data link module
1) Functions
2) Program example
- Program that turn the P020 on when the M000 or M001 is turn on.
M000
P020
M001
4-16
Chapter 4. Basic instructions
4.5.2 D
D FUN (017) D
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
D D O O O O* 2
* Available only when do not use computer link module or data link module
1) Functions
The D instruction turns on the specified device for one scan when the input condition of D
instruction is turned on.
2) Program example
When the P032 is switched on, the M002 is turned on for one scan.
[ Program ]
P032
[ D M002 ]
M002
( P060 )
P060
[ Time chart ]
P032
→ ←
1scan On
M002
P060
4-17
Chapter 4. Basic instructions
1. Operation
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.
2. System structure
1 1
2 2
3 .
. .
. .
. .
. .
3. Program
P000
0000 [ D M000 ]
P060 M000
0003 ( P060 )
P060 M000
0009
[ END ]
4. Time chart
P000
P060
4-18
Chapter 4. Basic instructions
4.5.3 D NOT
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
D NOT D O O O O* 2
* Available only when do not use computer link module or data link module
1) Functions
The D instruction turns on the specified device for one scan when the input condition of D
instruction is turned on.
2) Program example
When the P033 is switched off, the M003 is turned on for one scan.
[ Program ]
P033
[ D M003 ]
M003
( P060 )
P060
[ Time chart ]
P033
→ ←
1scan On
M003
P060
4-19
Chapter 4. Basic instructions
4.5.4 SET
SET
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
SET D O O O O* O 1
SET D
* Available only when do not use computer link module or data link module
1) Functions
When the input condition of SET instruction turns on, the specified device is switched on.
The turned-on device remains on even if the input condition of SET instruction is turned off. The
device can be switched off by the RST instruction.
D
2) Program example
When the input condition P020 turns on, the P060 and P061 is turned on by OUT and SET
instruction.
[ Program ]
P020
( P060 )
P020
[ SET P061 ]
[ Time chart ]
P020
P060
P061
4-20
Chapter 4. Basic instructions
4.5.5 RST
RST
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
RST D O O O O* O 1
RST D
* Available only when do not use computer link module or data link module
1) Functions
When the input condition of RST instruction turns on, the specified device is changed as described
Device Status
M, P, K, L The specified bit is turned off.
T The timer output is turned off and current value is cleared as 0
2) Program example
Set the P061 with the P020 and reset the P061 with the P021.
[ Program ]
P020
( P060 )
P020
[ ]
↔
SET P061
P021
[ RST P061 ]
[ Time chart ]
P020
P021
P060
P061
4-21
Chapter 4. Basic instructions
1. The difference of I/O relay (P) and keep relay (K) with the OUT instruction
The following program shows the difference of P area and K area. Both of P060 and K000 have self-
locking circuit, and the operation of two contact is same. However, when the power is switched off and
turned on again (power failure), operations of P and K are different as shown below.
Power Power
PB0 PB1 failure recovery
PB0 ↓ ↓
( P060 )
P060 PB1
Self-locking Non-volatile
during power off
2. The difference of I/O relay (P) and keep relay (K) with the SET/RST instruction
The SET instruction makes turn a specified device on and keep the on status until the RST instruction is
executed. However, the P and K area operate differently when a power failure occurred.
Power Power
PB0 failure recovery
[ SET P060 ] PB0 ↓ ↓
4-22
Chapter 4. Basic instructions
SET S
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
SET S D O 2
The Sxx.xx contact will turn on when the previous step of same group and the input condition is on.
Once a Sxx.xx is switched on, it keeps on state until the next step turns on or the step controller
group is initialized. (The Sxx.00 is switched on)
Even if multiple input condition turn on, only one step controller is switched on.
The Sxx.00 is initialization step and the Sxx.xx group will be initialized by switching on the Sxx.00.
When the CPU is turned to RUN mode, the Sxx.00 is set by default.
2) Program example
P030
[ Program ] 0000 SET S01.01
P031
0003 SET S01.02
P032
0006 SET S01.03
P033
0009 SET S01.04
P034
Reset 0012 SET S01.00
P030
[ Time chart ]
P031
P032
P033
P034
4-23
Chapter 4. Basic instructions
1. Operation
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,
2. Program
Start
SET S01.01 Start process 1
End of process 1
SET S01.02 Start process 2
End of process 2
SET S01.03 Start process 3
End of process 3
SET S01.04 Start process 4
End of process 4
SET S01.00 Initialize step controller
S00.01
Process 1 Perform the process 1 and turn
S00.03
Process 3 Perform the process 3 and turn
S00.04
Process 4 Perform the process 4 and turn
[ END ]
4-24
Chapter 4. Basic instructions
OUT S
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
OUT S D O 2
( Sxx.xx ) S xx.xx
Step No. (00 ~ 99)
* K10S1 : 0 ~ 15
K10S / K30S / K60S : 0 ~ 31 Group (00 ~ 99*)
K200S / K300S / K1000S : 0 ~ 99
1) Function
When the input condition turns on, the specified step controller is switched on and keep the on
status until other step controller of same group turns on.
Only one step controller turns on even if multiple input conditions turn on. At this time, the last
turned on step controller has the highest priority.
The Sxx.00 is initialization step and the Sxx.xx group will be initialized by switching on the Sxx.00.
When the CPU is turned to RUN mode, the Sxx.00 is set by default.
2) Program example
P020
[ Program ] ( S02.01 )
P021
( S02.23 )
P022
( S02.98 )
P023
( S02.04 )
P024
Reset ( S02.00 )
4-25
Chapter 4. Basic instructions
4.7.1 END
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
END 1
( )
( )
[ END ]
1) Functions
The END instruction indicates the end of sequence program. When the CPU meet the END
instruction, it stops the execution of sequence program and perform the END process.
All instructions after END instruction except subroutines and interrupt routine are ignored and not
executed.
Input refresh
1scan
Self diagnosis
Output refresh
4-26
Chapter 4. Basic instructions
4.8.1 NOP
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
NOP 1
1) Functions
This is a no operation instruction and has no effect on the previous operation result.
2) Program example
4-27
Chapter 4. Basic instructions
4.9.1 TON
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
Txxx O
TON 3
V O O
TON Txxx V
1) Functions
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 or input condition turns off.
The timer contact will be switched on when the current value reaches to the setting value.
The timer contact and current value is cleared when the input condition turns off or RST instruction
is executed.
2) Program example
The T097 (0.01 sec timer) will turn on 20 seconds later until the P020 is switched on.
P020
[Program]
[ TON T097 00200 ]
T097
( P065 )
P021
[ RST T097 ]
[Time chart]
P020
← t = 20sec →
T097
( Increase )
4-28
Chapter 4. Basic instructions
1. Operation
By using two timers, a lamp flickers periodically while the P020 is on.
2. System diagram
1 1
Program
2 2
3 3
. .
. .
. .
. .
. .
F F
3. Program
[Ladder program]
P020 T001
[ TON T000 00005 ] Set a Off time (0.5sec)
T000
[ TON T001 00006 ] Set a On time (0.6 sec)
[Time chart]
P020
T0 T1
4-29
Chapter 4. Basic instructions
4.9.2 TOFF
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
Txxx O
TOFF 3
V O O
TOFF Txxx V
1) Functions
When the input condition turns on, the current value will be set as the setting value and the timer
contact will turn on.
When the input condition turns off, the current value will decrease by 1 at every 0.1 or 0.01 sec
until it reaches to 0 or input condition turns off.
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 contact will turn off and
the current value will be cleared as 0.
2) Program example
The T000 (0.1 sec timer) will turn off 5 seconds later until the P020 is switched off.
[Program] P020
[ TOFF T097 00200 ]
T000
( P065 )
P022
[ RST T000 ]
[Time chart]
P020
← t = 5sec →
T000
( Decrease )
4-30
Chapter 4. Basic instructions
1. Operation
Operate three conveyers (A, B, C) in sequence by using TOFF timers.
(Start : A – B – C, Stop : C – B – A)
2. System diagram
Program
2 →
C 3 3 MC2
. .
B
. .
A . .
. .
. .
M2 M1 M0
F F
Motor 2 Motor 1 Motor 0
3. Program
P020
0000 [ TOFF T010 00100 ] Set the off delay time of conveyer A
T010 (10sec)
0004 ( P060 )
P020 Set the on delay time of conveyer B
0006 [ TON T000 00050 ] (5sec)
T000
0010 [ TOFF T011 00050 ] Set the off delay time of conveyer B
T011 (5sec)
0014 ( P062 )
T011
P020
0017 [ TON T001 00100 ] Set the on delay time of conveyer C
T001 (5sec)
P020
0021 ( P062 )
0024 [ END ]
[Time chart]
On/Off (P020)
T010
A (P060) T10
B(P061) T000
T11
C(P062) T011
T001
4-31
Chapter 4. Basic instructions
4.9.3 TMR
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
Txxx O
TMR 3
V O O
TMR Txxx V
1) 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 while the CPU is powered off.
When the RST instruction is executed, the timer contact and current value will be cleared as 0.
2) Program example
[Program] P020
[ TMR T096 300 ]
T096
( P061 )
P023
[ RST T096 ]
[Time chart]
P023
P020
Setting value
T096 t 1= 20
t 2= 10
t = t1+t2
P061
4-32
Chapter 4. Basic instructions
1. 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.
2. System diagram
Drill 0 0 L
Program
Sensor 1 1
Alarm
2 2 lamp
. .
Motor . .
Completion . .
of replacement . .
. .
. .
F F
I/O Description
P020 Detect of drill down
P021 Replacement completion
P060 Turn on an alarm lamp
T000 Timer for the lifetime of drill
3. Program
P020
[ TMR T000 36000 ] 1 hour timer
T000
[ RST T096 ]
T000
U CTU C000 Counter
C000
R <s> 00100 (1hour100 = 100hours)
C000 P021
( P060 )
P060
4-33
Chapter 4. Basic instructions
4.9.4 TMON
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
Txxx O
TMON 3
V O O
TMON Txxx V
1) Functions
When the input condition turns on, the current value will be set as the setting value and starts to
decrease. 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 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.
When the RST instruction is executed, the timer contact will turn off and the current value will be
cleared as 0.
2) program example
P020
[Program]
[ TMON T000 00100 ]
T000
( P061 )
P023
[ RST T000 ]
[Time chart]
P023
P020
Setting value
T000
← Setting time ( t ) →
P061
4-34
Chapter 4. Basic instructions
1. Operation
A input signal from limit switch has chattering noise. By using TMON instruction, a stabilized
2. System diagram
Input module
The limit switch output P02
with low speed of cart
0 Stabilized signal
Moving direction (a fixed period)
Cart 1
2
.
L.S The limit switch output .
with high speed of cart .
T
.
.
.
F
I/O Description
P020 Limit switch output
M0020 Stabilized signal of P020
T000 Chattering prevention timer
3. Program
P020
[ TMON T000 0002 ] Even if P020 trembles after P020
T000 turns on in a moment, M0020
( M0020 ) keeps its on state for 0.2 second.
4-35
Chapter 4. Basic instructions
4.9.5 TRTG
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
Txxx O
TRTG 3
V O O
TRTG Txxx V
1) Functions
When the input condition turns on, the current value will be set as the setting value and starts to
decrease. 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 and the timer
contact will be switched off when the current value reaches to 0.
If the input condition turns on again during timer operation, the current value will reset as the
setting value and re-start to decreasing from the setting value.
When the RST instruction is executed, the timer contact will turn off and the current value will be
cleared as 0.
2) Program example
[Program]
P020
[ TRTG T096 50 ]
T096
( P065 )
P023
[ RST T096 ]
[Time chart]
t=5sec
P020
t
P065
4-36
Chapter 4. Basic instructions
1. Operation
Detect the fault of conveyer by check that a product is passed within a specified period or not.
2. System diagram
Detector 0
Conveyer 2
.
.
.
.
.
.
F
3. Program
P020
[ TRTG T005 00200 ] If there is no product passing during 20
T005 seconds, the timer turns off and M100 is
( M100 ) switched off.
During normal operation, the M100
keeps on state.
Detecting P020
signal
Timer T5
contact
T=20sec
Operating M100
indicator
4-37
Chapter 4. Basic instructions
4.10.1 CTU
CTU Up counter
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
Cxxx O
CTU 3
V O O
Setting value
1) Functions
Whenever a rising edged is detected at the count pulse input, the current value is increased by 1
The initial current value is 0 and when the current value is reached to the setting value, the counter
contact turns on.
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.
2) Program example
Whenever the P030 is changed from off to on, the current value of C010 is increased by 1.
[Program] P030
U CTU C010
P031
R <S> 00010
C010
( P060 )
P030
Setting value
C010
P060
4-38
Chapter 4. Basic instructions
4.10.2 CTD
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
Cxxx O
CTD 3
V O O
Setting value
1) Functions
Whenever the rising edge is detected from counter pulse input, the current value is decreased by 1.
The initial current value is the setting value, and when the current value reached to 0, the counter
contact is switched on.
When the reset signal turns on, the counter contact is switched off and the current value is reset as
the setting value.
2) Program example
Whenever the P030 is changed from off to on, the current value of C010 is decreased by 1.
[Program] P030
D CTD C010
P031
R <S> 00010
C010
( P060 )
[Time chart]
P031
P030
Setting value
C010
P060
4-39
Chapter 4. Basic instructions
4.10.3 CTUD
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
Cxxx O
CTUD 3
V O O
Setting value
1) 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 down count input.
The counter contact turns on when the current value is same or greater than the setting value.
When the reset signal turns on, the counter contact and current value is cleared as 0.
2) Program example
The P030 is up count input, and the P031 is down count input.
[Program] P030
U CTUD C000
P031
D
P032
R <S> 00010
C000
( P060 )
P030
P031
Setting value
C000
4-40
Chapter 4. Basic instructions
1. 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.
Program
2 2
3 3
. .
. .
. .
M4 M3 M2 M1 . .
. .
3. Program
P030
0000 U CTUD C001 C001 : operate 1st motor
P031
D
C005
R <S> 00001
P030
U CTUD C001 C002 : operate 2nd motor
0006
P031
D
C005
R <S> 00002
P030
0012 U CTUD C003 C003 : operate 3rd motor
P031
D
C005
R <S> 00001
P030
0018 U CTUD C0004 C004 : operate 4th motor
P031
D
C005
R <S> 00004
P030
0024 U CTUD C005 C005 : reset signal
P031
D
C005
R <S> 00005
C001
0030 ( P060 )
C002
0032 ( P061 )
C003
0034 ( P062 )
C004
0036 ( P063 )
0038 [ END ]
4-41
Chapter 4. Basic instructions
4.10.4 CTR
Steps
Instructions Error Zero Carry
#
M P K L F T C S D D Integer
(F110) (F111) (F112)
Cxxx O
CTR 3
V O O
Setting value
1) Functions
Whenever a rising edge is detected at the count pulse input, the current value is increased by 1.
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
When the reset signal turns on, the counter contact and current value will be cleared as 0.
2) 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.
[Program] P030
U CTR C010
P031
R <S> 00010
C005
( P060 )
P030
P060
4-42
Chapter 5 Application instructions
5.17.3 RGET.....................................................................................5-117
5 Application Instructions
MOV(P) S O O O O* O O O O O O
5/7 O
DMOV(P) D O O O O* O O O O
S D Operand setting
MOVP
DMOVP
* Available only when do not use computer link module or data link module
1) Functions
MOV(P) : Transfer the 16-bits data of the device specified at [ S ] to the device specified at [ D ].
16 bits
S 0 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1
D 0 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1
DMOV(P) : Transfer the 32-bits data of the device specified at [ S+1, S ] to the device specified at
[ D+1, D ].
16 bits 16 bits
S +1 1 0 0 1 1 0 1 1 0 0 1 1 0 1 S
D +1 1 0 0 1 1 0 1 1 0 0 1 1 0 1 D
5-1
Chapter 5. Application instructions
Execution condition
Input condition
MOVP, DMOVP
Executed only once Executed only once
2) Program example
Whenever a rising edge is detected at the P020, the ‘h00F3’ is moved to the P04 word.
P020
MOVP h70F3 P04
P04F P040
0 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1
5-2
Chapter 5. Application instructions
CMOV(P) S O O O O* O O O O O O
5/7 O
DCMOV(P) D O O O O* O O O O
S D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
CMOV(P) : Reverses the 16-bits data of [ S ] per bit and transfers the result to [ D ].
16 bits
S 0 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1
Reverse
D 1 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0
DCMOV(P) : Reverses the 32-bits data of [ S+1, S ] per bit and transfers the result to [ D+1, D ].
16 bits 16 bits
S +1 1 0 0 1 1 0 1 1 0 0 1 1 0 1 S
Reverse Reverse
D +1 0 1 1 0 0 1 0 0 1 1 0 0 1 0 D
5-3
Chapter 5. Application instructions
Execution conditions
Input condition
CMOVP, DCMOVP
Executed only once Executed only once
2) Program example
While the M020 is on, reverse the data of P02 word and transfer the result to P06 word.
M020
CMOV P02 P06
16 bits
P02 0 0 1 1 1 0 0 0 1 1 0 1 0 0 1 1
Reverse
P06 1 1 0 0 0 1 1 1 0 0 1 0 1 1 0 0
5-4
Chapter 5. Application instructions
S O O O O* O O O O O
GMOV
D O O O O* O O O O 7 O
GMOVP
n O O
S D n Operand setting
* Available only when do not use computer link module or data link module
1) Functions
Transfers the content of ‘n’ words, which begin with the device specified at [ S ], in blocks to ‘n’
words which begin with the device specified at [ D ].
S h0002 h0002 D
S +1 h0007 h0007 D +1
S +2 h007F h007F D +1
5-5
Chapter 5. Application instructions
Execution conditions
Input condition
GMOVP
Executed only once Executed only once
2) Program example
While the P020 is on, move the data of D000, D001, and D002 to P04, P05, and P06 area.
P020
GMOV D0000 P04 3
S D
h0001 h0001 P04
D0000
n D0001 h0004 h0004 P05
D0002 h005F h005F P06
5-6
Chapter 5. Application instructions
S O O O O* O O O O O
FMOV
D O O O O* O O O O 7 O
FMOVP
n O O
S D n Operand setting
* Available only when do not use computer link module or data link module
1) Functions
Transfers the content of device specified at [ S ] in blocks to ‘n’ points which begin with the device
specified at [ D ].
h005A D
h005A D +1
h005A D +1
S h005A
n words
h005A D + (n-3)
h005A D + (n-2)
h005A D + (n-1)
5-7
Chapter 5. Application instructions
Execution condition
Input condition
FMOVP
Executed only once Executed only once
2) Program example
Whenever a rising edge is detected at P030, transfer the content of P02 word to the block of P04,
P05, and P06.
P020
FMOVP P02 P04 3
5-8
Chapter 5. Application instructions
S O O O O* O O O O O
BMOV
D O O O O* O O O O 7 O
BMOVP
Cw O
S D Cw Operand setting
* Available only when do not use computer link module or data link module
1) Functions
h s d z z
Transfers the content of ‘zz’ bits from the ‘s’ bit of the device specified at [ S ] to the ‘zz’ bits from ‘d’
bit of the device specified at [ D ].
The maximum value of the ‘zz’ is h10 ( = 16). If the value of ‘zz’ is 0 or over h10, the instruction will
be ignored. (The error flag F110 is set when the ‘zz’ is over h10.)
5-9
Chapter 5. Application instructions
Execution condition
Input condition
BMOVP
Executed only once Executed only once
2) Program example
- Whenever a rising edge is detected at the P030, transfer 4 bits from the P020 bit to the 4 bits from the
P063 bit.
P030
BMOVP P02 P06 h0304
4bits
1 0 0 1 1
4bits
5-10
Chapter 5. Application instructions
BCD
FUN(60) BCD FUN(62) DBCD Applicable
(Binary coded All CPUs
FUN(61) BCDP FUN(63) DBCDP CPU
decimal)
BCD(P) S O O O O* O O O O O
5 O
DBCD(P) D O O O O* O O O O
S D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
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 ].
S BIN (9999) 0 0 1 0 0 1 1 1 0 0 0 0 1 1 1 1
Be sure to set as 0.
(BCD conversion will
be exceeded if not)
D BCD (9999) 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
DBCD : Converts binary data (0 to 99999999) of the device specified at [ S ] into BCD format and
transfers the result to the device specified at [ D ].
5-11
Chapter 5. Application instructions
Execution conditions
Input condition
BCDP, DBCDP
Executed only once Executed only once
Operation Error
In the following cases, operation error occurs and the error flag (F110) turns on.
2) Program example
While P020 is on, convert the binary data of D001 and transfer the result to the P05 word.
P020
BCD D0001 P05
D0001 (h1111) 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
P05 (4369) 0 1 0 0 0 0 1 1 0 1 1 0 1 0 0 1
4000 300 60 9
5-12
Chapter 5. Application instructions
1. Operation
There is a warehouse and numbers of product incoming / outgoing are counted by light switches. The
current stock of inside of warehouse is displayed by a digital indicator. When the stock of inside of
2. System diagram
Program
! ! 1 1
! ! ! ! Outgoing 2 2
Incoming ! ! ! 3 3
Conveyer motor ! ! ! ! ! ∙ 4
! ! ! ! ! ! ! Light S/W ∙ 5
M
∙ 6
"
∙ Output 7
Counter reset S/W module
(P032) ∙ P06 ∙
Digital indicator
∙ 0 F
1 8 ∙
∙
F
3. Program
P030
0000
U CTUD C000
P031
D
P032
R <S> 0003
C000
0006 ( P06F )
F010
Convert the current value of
0008 [ BCD C000 M000 ]
counter to BCD format
[ BMOV M000 P04 h0008 ] Display only last 8bits (2 digit)
0021 [END ]
5-13
Chapter 5. Application instructions
BIN(P) S O O O O* O O O O O
5 O
DBIN(P) D O O O O* O O O O
S D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
BIN : Converts BCD data (0 to 9999) of the device specified at [ S ] into binary format and transfers
the result to the device specified at [ D ].
S BCD (9999) 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
D BIN (9999) 0 0 1 0 0 1 1 1 0 0 0 0 1 1 1 1
Always set as 0
DBIN : Converts BCD data (0 to 99999999) of the device specified at [ S ] into binary format and
transfers the result to the device specified at [ D ].
5-14
Chapter 5. Application instructions
Execution conditions
Input condition
BINP, DBINP
Executed only once Executed only once
Operation Error
In the following cases, operation error occurs and the error flag (F110) turns on.
(Example : [ S ] = h78A5)
2) Program example
While P020 is on, convert the BCD data of P00 word and transfer the result to the D0001.
P020
BIN P00 D0001
P00 (4369) 0 1 0 0 0 0 1 1 0 1 1 0 1 0 0 1
4000 300 60 9
D0001 (h1111) 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
5-15
Chapter 5. Application instructions
CMP(P) S1 O O O O O O O O O O
5/9 O
DCMP(P) S2 O O O O O O O O O O
S1 S2 Operand setting
CMP S1
Data to be compared
DCMP
S2
S1 S2
CMPP
DCMPP
1) Functions
S1 < S2 1 1 0 0 0 1
S1 = S2 0 1 1 0 1 0
5-16
Chapter 5. Application instructions
Execution conditions
Input condition
CMPP, DCMPP
Executed only once Executed only once
2) Program example
While P020 is on, compare contests of D000 and D001 and set flags according to the result.
(D0000) 0 0 0 1 0 0 0 (h0008)
(D0001) 0 0 1 0 0 0 1 (h2001)
[ Program ]
[ Flag setting ]
5-17
Chapter 5. Application instructions
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.
2. Program
P030
0000 U CTUD C000
P031
D
P032
R <S> 00050
F010
C000 : the current value of
0006 CMP C000 00010 counter
F120
0012 ( M0000 ) Less than 10
F010
0014 CMP C000 00020
F120
0020 ( M0001 ) Less than 20
F010
0022 CMP C000 00030
F120
0028 ( M0002 ) Less than 30
F010
0030 CMP C000 00040
F120
0036 ( M0003 ) Less than 40
M0000
0038 ( P060 ) 0 ~ 10
M0000 M0001
0040 ( P061 ) 10 ~ 19
M0001 M0002
0043 ( P062 ) 20 ~ 29
M0002 M0003
0046 ( P063 ) 30 ~ 39
M0003
0049 ( P064 ) 40 or more
0051 END
5-18
Chapter 5. Application instructions
S1 O O O O O O O O O O
TCMP(P)
S2 O O O O O O O O O 7/9 O O
DTCMP(P)
D O O O O* O O O O
S1 S2 D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
Compares content of the device specified at [ S1 ] with each contents of 16 words from the device
specified at [ S2 ].
The comparison result (If two words are same, 1 is output. If not, 0 is output) consists of 16 bits,
and they are stored at the device specified at [ D ].
If all comparison result are 0, then the zero flag (F111) is switched on. ( [ D ] = 0)
Execution conditions
Input condition
TCMPP
Executed only once Executed only once
5-19
Chapter 5. Application instructions
2) Program example
While P020 is on, compare the content of D0001 with 16 words from M00 (M00 ~ M15) and output
the comparison result to P06 word (P060 ~ P06F).
P020
TCMP D0001 M000 P06
5-20
Chapter 5. Application instructions
LD S1 O O O O O O O O O O
5/9 O
LDD S2 O O O O O O O O O O
Operand setting
S1 S2
S1
Data to be compared
D S1 S2 S2
1) Functions
2) Program example
a) Compare P0000 ~ P000F and D0001. If their values are equal, P0010 bit will be switched on.
b) Compare 1000 and contents of D0001 and D0002 (32 bits). If the contents of D0001 and D0002 is
5-21
Chapter 5. Application instructions
AND S1 O O O O O O O O O O
5/9 O
ANDD S2 O O O O O O O O O O
Operand setting
S1 S2
S1
Data to be compared
D S1 S2 S2
1) Functions
2) Program example
a) Compare P0000 ~ P000F and D0001. If their values are equal and M000 is on, P0010 bit will be
switched on.
M000
= P000 D0001 ( P0010 )
b) Compare 1000 and contents of D0001 and D0002 (32 bits). If the content of D0001 and D0002 is less
5-22
Chapter 5. Application instructions
OR S1 O O O O O O O O O O
5/9 O
ORD S2 O O O O O O O O O O
Operand setting
S1 S2
S1
Data to be compared
S2
D S1 S2
1) Functions
2) Program example
a) Compare P0000 ~ P000F and D0001. If their values are equal or M000 is on, P0010 bit will be
switched on.
M000
= P000 D0001 ( P0010 )
b) Compare 1000 and contents of D0001 and D0002 (32 bits). If the content of D0001 and D0002 is less
5-23
Chapter 5. Application instructions
INC(P)
D O O O O* O O O O 3 O O O
DINC(P)
D Operand setting
INCP
DINCP
* Available only when do not use computer link module or data link module
1) Functions
If the device specified by #D is out of the range, the operation error occurs and the error flag (F110)
will be set.
16 bits
D h38D3 0 0 1 1 1 0 0 0 1 1 0 1 0 0 1 1
+1
D h38D4 0 0 1 1 1 0 0 0 1 1 0 1 0 1 0 0
5-24
Chapter 5. Application instructions
Execution conditions
Input condition
INCP, DINCP
Executed only once Executed only once
2) Program example
Whenever a rising edge is detected at P030, the content of P06 word will be increased by 1.
P030
INCP P006
P006 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 h00C6
+1
P006 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 h00C7
5-25
Chapter 5. Application instructions
DEC(P)
D O O O O* O O O O 3 O O O
DDEC(P)
D Operand setting
DECP
DDECP
* Available only when do not use computer link module or data link module
1) Functions
16 bits
D h38D3 0 0 1 1 1 0 0 0 1 1 0 1 0 0 1 1
–1
D h38D2 0 0 1 1 1 0 0 0 1 1 0 1 0 0 1 0
5-26
Chapter 5. Application instructions
Execution conditions
Input condition
DECP, DDECP
Executed only once Executed only once
2) Program example
Whenever a rising edge is detected at P020, the content of M06 word will be decreased by 1.
P020
DECP M006
M006 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 h00C6
-1
M006 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 h00C5
5-27
Chapter 5. Application instructions
ROL(P)
D O O O O* O O O O 3 O O
DROL(P)
D Operand setting
ROLP
DROLP
* Available only when do not use computer link module or data link module
1) Functions
Carry flag F E D C B A 9 8 7 6 5 4 3 2 1 0
D +1 D
Carry flag 16 bits 16 bits
5-28
Chapter 5. Application instructions
Execution conditions
Input condition
ROLP, DROLP
Executed only once Executed only once
2) Program example
Whenever a rising edge is detected at P030, 16-bits of D0000 word will be rotated with left direction.
P030
ROLP D0000
D0000 = h78D3
Rotate left
Carry flag
0 1 1 1 1 0 0 0 1 1 0 1 0 0 1 1 0
MSB LSB
Rotate left
Carry flag
1 1 1 1 0 0 0 1 1 0 1 0 0 1 1 0 1
MSB LSB
5-29
Chapter 5. Application instructions
ROR(P)
D O O O O* O O O O 3 O O
DROR(P)
D Operand setting
RORP
DRORP
* Available only when do not use computer link module or data link module
1) Functions
F E D C B A 9 8 7 6 5 4 3 2 1 0 Carry flag
D +1 D
16 bits 16 bits Carry flag
5-30
Chapter 5. Application instructions
Execution conditions
Input condition
RORP, DRORP
Executed only once Executed only once
2) Program example
Whenever a rising edge is detected at P030, 16-bits of D0000 word will be rotated with right
direction.
P030
RORP D0000
D0000 = h78D2
Rotate right
Carry flag
0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 1 0
MSB LSB
Rotate right
Carry flag
1 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 1
MSB LSB
5-31
Chapter 5. Application instructions
ROL
FUN(40) RCL FUN(42) DRCL Applicable
(Rotate left include All CPUs
FUN(41) RCLP FUN(43) DRCLP CPU
carry flag)
RCL(P)
D O O O O* O O O O 3 O O
DRCL(P)
D Operand setting
RCLP
DRCLP
* Available only when do not use computer link module or data link module
1) Functions
RCL(P) : Rotates 16 bits of the device specified at [ D ] and carry flag (F112) in left direction.
The MSB will be transferred to the carry flag (F112) and the carry flag will be transferred to the LSB.
Carry flag F E D C B A 9 8 7 6 5 4 3 2 1 0
DRCL(P) : Rotates 32-bits of the device specified as [ D+1, D] and carry flag in left direction.
The MSB of [ D+1 ] will be transferred to the carry flag (F112) and the carry flag will be transferred
to the LSB of [ D ].
D +1 D
Carry flag 16 bits 16 bits
5-32
Chapter 5. Application instructions
Execution conditions
Input condition
ROLP, DROLP
Executed only once Executed only once
2) Program example
Whenever a rising edge is detected at P030, 16-bits of D0000 word and carry flag will be rotated
with left direction.
P030
RCLP D0000
D0000 = h78D3
Rotate left
Carry flag
0 1 1 1 1 0 0 0 1 1 0 1 0 0 1 1 0
MSB LSB
Rotate left
Carry flag
1 1 1 1 0 0 0 1 1 0 1 0 0 1 1 0 0
MSB LSB
5-33
Chapter 5. Application instructions
RCR
FUN(44) RCR FUN(46) DRCR Applicable
(Rotate right All CPUs
FUN(45) RCRP FUN(47) DRCRP CPU
include carry flag)
RCR(P)
D O O O O* O O O O 3 O O
DRCR(P)
D Operand setting
RCRP
DRCRP
* Available only when do not use computer link module or data link module
1) Functions
RCR(P) : Rotates 16 bits of the device specified at [ D ] and the carry flag in right direction.
The LSB will be transferred to the carry flag (F112) and the carry flag will be transferred to the MSB.
F E D C B A 9 8 7 6 5 4 3 2 1 0 Carry flag
DRCR(P) : Rotates 32-bits of the device specified as [ D+1, D] and the carry flag in right direction.
The LSB of [ D ] will be transferred to the carry flag and the carry flag will be transferred to the MSB
of [ D+1 ].
D +1 D
16 bits 16 bits Carry flag
5-34
Chapter 5. Application instructions
Execution conditions
Input condition
RCRP, DRCRP
Executed only once Executed only once
2) Program example
Whenever a rising edge is detected at P030, 16-bits of D0000 word and carry flag will be rotated
with right direction.
P030
RCRP D0000
D0000 = h78D2
Rotate right
Carry flag
0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 1 0
MSB LSB
Rotate right
Carry flag
0 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 1
MSB LSB
5-35
Chapter 5. Application instructions
S1 O O O O*
BSFT(P) 5 O
S2 O O O O*
S1 S2 Operand setting
BSFTP
* Available only when do not use computer link module or data link module
1) Functions
Erased
0 is entered
0 0 1 1 1 0 0 0 1 1 0 1 0 0 1 0
[ S2 ] [ S1 ]
[ S1 ] [ S2 ]
n bits
When [ S1 ] is
higher than [ S2 ] 0 0 1 1 1 0 0 0 1 1 0 1 0 0 1 0
Erased
0 is entered
0 0 0 1 1 1 0 0 0 1 1 0 1 0 0 0
[ S1 ] [ S2 ]
5-36
Chapter 5. Application instructions
Execution conditions
Input condition
BSFTP
Executed only once Executed only once
2) Program example
At every 1 second, the block from P040 to P045 is shifted in left direction by 1 bit. The 1 second
clock flag (F093) is used for input condition. P040 is set as 1 when the P031 is on.
F093
BSFT P040 P045
P031
SET P040
0 0 1 1 1 0 0 0 1
5-37
Chapter 5. Application instructions
S1 O O O O* O O O O
WSFT(P) 5 O
S2 O O O O* O O O O
S1 S2 Operand setting
WSFTP
* Available only when do not use computer link module or data link module
1) Functions
Erased
h0000 is entered
[ S2+1 ] [ S2 ] [ S1 ] [ S1-1 ]
[ S1+1 ] [ S1 ] [ S2 ] [ S2-1 ]
n words
When [ S1 ] is
higher than [ S2 ]
Erased
h0000 is entered
[ S1+1 ] [ S1 ] [ S2 ] [ S2-1 ]
5-38
Chapter 5. Application instructions
Execution conditions
Input condition
WSFTP
Executed only once Executed only once
2) Program example
At every 1 second, the block from D0040 to D0043 is shifted in left direction by 1 word. The 1
second clock flag (F093) is used for input condition. D0040 is set as h1234 when the P031 is on.
F093
WSFT D0040 D0043
P031
MOV h1234 D0040
5-39
Chapter 5. Application instructions
5.6.3 SR
K200S
SR Applicable
FUN(237) SR K300S
(Shift register) CPU
K1000S
D O O O O*
BSFT(P) 5 O
n O O
* Available only when do not use computer link module or data link module
1) Functions
Whenever a rising edge is detected at the clock input, shifts the block from the bit specified at [ D ]
to the bit [ D+n ] by 1 bit.
At the start bit of shift operation, 0 is entered when the input data is off, and 1 is entered when the
input data is on. The start bit of shift operation is various according to the direction of shift operation
The shift direction indicates the direction of shift operation. If the shift direction is off, it means a left
direction shift. Otherwise, it means a right direction shift.
When the reset signal is switched on, all bit from [ D ] to [ D+n ] is cleared as 0.
Execution condition
Clock
SR
Executed only once Executed only once
5-40
Chapter 5. Application instructions
2) Program example
Shifts the block from P0013 ~ P001B (9 bits) with the configuration as following :
Input data bit : M000A
Shift direction but : M000B
Clock : P0000
Reset signal : P0001
M000A
M000B SR
P0000 D P0014
P0001 N 7
E D C B A 9 8 7 6 5 4 3 2 1 0
F
P001 1 0 1 1 1 1 0 1 1 1 0 1 1 0 1 0
Fill with 0
Left direction shift
a) After 1 clocks when M000A=0 and M000B=0
F E D C B A 9 8 7 6 5 4 3 2 1 0
P001 1 0 1 1 1 0 1 1 1 0 1 1 0 0 1 0
Fill with 1
Left direction shift
b) After 2 clocks when M000A=1 and M000B=0
F E D C B A 9 8 7 6 5 4 3 2 1 0
P001 1 0 1 1 0 1 1 1 0 1 1 0 1 0 1 0
Fill with 0
Right direction shift
c) After 3 clocks when M000A=0 and M000B=1
F E D C B A 9 8 7 6 5 4 3 2 1 0
P001 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 0
Fill with 1
Right direction shift
d) After 4 clocks when M000A=1 and M000B=1
F E D C B A 9 8 7 6 5 4 3 2 1 0
P001 1 0 1 1 1 0 0 1 1 1 0 1 1 0 1 0
5-41
Chapter 5. Application instructions
XCHG(P) D1 O O O O* O O O O
5 O
DXCHG(P) D2 O O O O* O O O O
D1 D2 Operand setting
1) Functions
D1+1 D1 D2+1 D2
DXCHG(P) : Exchanges 32-bits contents of two devices specified as [ D1+1, D1 ] and [ D2+1, D2 ].
D1+1 D1 D2+1 D2
5-42
Chapter 5. Application instructions
Execution condition
Input condition
XCHGP, DXCHGP
Executed only once Executed only once
2) Program example
While P020 is on, exchange contents of P04 and P05 words each other.
P020
XCHGP P04 P05
P05 P04
h5849 hF0B4
hF0B4 h5849
P05 P04
5-43
Chapter 5. Application instructions
S1 O O O O O O O O O O
ADD(P)
S2 O O O O O O O O O O 7/9/11 O O O
DADD(P)
D O O O O* O O O O
S1 S2 D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
ADD(P) : Performs the addition of 16-bits BIN data specified at [ S1 ] and [ S2 ]. The addition result
is stored at the device specified at [ D ].
DADD(P) : Performs the addition of 32-bits BIN data specified at [ S1+1, S1 ] and [ S2+1, S2 ]. The
addition result is stored at the device specified at [ D1+1, D1 ].
When the addition result is over hFFFF(ADD / ADDP) or hFFFFFFFF(DADD / DADDP), the carry
flag (F112) is set.
5-44
Chapter 5. Application instructions
Execution condition
Input condition
ADDP, DADDP
Executed only once Executed only once
2) Program example
When a rising edge is detected at P020, add contents of D0000 and D0001 and store the addition
result to P06 word.
16 bits
D0000 0 0 1 1 1 0 0 0 1 1 0 1 0 0 1 1 h38D3
+
D0001 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 h120C
P06 0 1 0 0 1 0 1 0 1 1 0 1 1 1 1 1 h4ADF
5-45
Chapter 5. Application instructions
S1 O O O O O O O O O O
SUB(P)
S2 O O O O O O O O O O 7/9/11 O O O
DSUB(P)
D O O O O* O O O O
S1 S2 D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
SUB(P) : Performs the subtraction of 16-bits BIN data specified at [ S1 ] and [ S2 ]. The subtraction
result is stored at the device specified at [ D ].
DSUB(P) : Performs the subtraction of 32-bits BIN data specified at [ S1+1, S1 ] and [ S2+1, S2 ].
The subtraction result is stored at the device specified at [ D1+1, D1 ].
When the minuend is less than subtrahend, the LSB will underflow, and the carry flag (F112) will be
set.
5-46
Chapter 5. Application instructions
Execution condition
Input condition
SUBP, DSUBP
Executed only once Executed only once
2) Program example
When a rising edge is detected at P020, subtract contents of D0000 and D0001 and store the
addition result to P06 word.
P020
SUBP D0000 D0001 P06
16 bits
D0000 0 0 1 1 1 0 0 0 1 1 0 1 0 0 1 1 h38D3
-
D0001 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 h120C
P06 0 0 1 0 0 1 1 0 1 1 0 0 0 1 1 1 h26C7
5-47
Chapter 5. Application instructions
S1 O O O O O O O O O O
MUL(P)
S2 O O O O O O O O O O 7/9/11 O O
DMUL(P)
D O O O O* O O O O
S1 S2 D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
MUL(P) : Performs the multiplication of BIN data specified as [ S1 ] and the BIN data specified as
[ S2 ], and stores the multiplication result into the device specified as [ D+1, D ].
DMUL(P) : Performs the multiplication of BIN data specified as [ S1+1, S ] and the BIN data
specified as [ S2+1, S2 ], and stores the multiplication result into the device specified as [ D+3, D+2,
D+1, D ]
Execution conditions
Input condition
MULP, DMULP
Executed only once Executed only once
5-48
Chapter 5. Application instructions
2) Program example
Program which stores the multiplication result of D0001 and D0002 at D0010, D0011 while P020 is
on.
P020
MUL D0001 D0002 D0010
Program which stores the multiplication result of D0001, D0002 and D0003,D0004 at D0010 ~
D0013 when P020 is switched on.
P020
DMULP D0001 D0003 D0010
5-49
Chapter 5. Application instructions
MULS K200S
FUN(072) MULS FUN(076) DMULS Applicable
(Signed binary K300S
FUN(073) MULSP FUN(077) DMULSP CPU
multiply) K1000S
S1 O O O O O O O O O O
MULS(P)
S2 O O O O O O O O O O 7/9/11 O O
DMULS(P)
D O O O O* O O O O
S1 S2 D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
MULS(P) : Performs the multiplication of the signed BIN data specified as [ S1 ] and the signed BIN
data specified as [ S2 ], and stores the multiplication result into the device specified as [ D+1, D ].
DMULS(P) : Performs the multiplication of signed BIN data specified as [ S1+1, S ] and the signed
BIN data specified as [ S2+1, S2 ], and stores the multiplication result into the device specified as
S1 S2 D
5-50
Chapter 5. Application instructions
Execution conditions
Input condition
MULSP, DMULSP
Executed only once Executed only once
2) Program example
Program which stores the multiplication result of D0001 and D0002 at D0010, D0011 while P020 is
on.
P020
MULS D0001 D0002 D0010
Program which stores the multiplication result of D0001, D0002 and D0003,D0004 at D0010 ~
D0013 when P020 is switched on.
P020
DMULSP D0001 D0003 D0010
(= –36840216) (= –864531798)
5-51
Chapter 5. Application instructions
S1 O O O O O O O O O O
DIV(P)
S2 O O O O O O O O O O 7/9/11 O O
DDIV(P)
D O O O O* O O O O
S1 S2 D Operand setting
DIV
S1 The device storing dividend
DDIV
S2 The device storing divider
* Available only when do not use computer link module or data link module
1) Functions
DIV(P) : Performs the division of BIN data specified as [ S1 ] and the BIN data specified as [ S2 ],
and stores the division result into the device specified as [ D+1, D ]. The quotient is stored at [ D ],
DDIV(P) : Performs the division of BIN data specified as [ S1+1, S ] and the BIN data specified as
[ S2+1, S2 ], and stores the division result into the device specified as [ D+3, D+2, D+1, D ]. The
Execution conditions
Input condition
DIVP, DDIVP
Executed only once Executed only once
5-52
Chapter 5. Application instructions
2) Program example
Program which stores the division result of D0001 and D0002 at D0010, D0011 while P020 is on.
P020
DIV D0001 D0002 D0010
Program which stores the division result of D0001, D0002 and D0003,D0004 at D0010 ~ D0013
when P020 is switched on.
P020
DDIVP D0001 D0003 D0010
Remainder Quotient
5-53
Chapter 5. Application instructions
DIVS K200S
FUN(124) DIV FUN(126) DDIV Applicable
(Signed binary K300S
FUN(125) DIVP FUN(127) DDIVP CPU
divide) K1000S
S1 O O O O O O O O O O
DIVS(P)
S2 O O O O O O O O O O 7/9/11 O O
DDIVS(P)
D O O O O* O O O O
S1 S2 D Operand setting
DIVS
S1 The device storing dividend
DDIVS
S2 The device storing divider
* Available only when do not use computer link module or data link module
1) Functions
DIVS(P) : Performs the division of the signed BIN data specified as [ S1 ] and the signed BIN data
specified as [ S2 ], and stores the division result into the device specified as [ D+1, D ]. The quotient
is stored at [ D ], and the remainder is stored at [ D+1 ].
DDIVS(P) : Performs the division of the signed BIN data specified as [ S1+1, S ] and the signed BIN
data specified as [ S2+1, S2 ], and stores the division result into the device specified as [ D+3, D+2,
D+1, D ]. The quotient is stored at [ D+1, D ], and the remainder is stored at [ D+3, D+2 ].
S1 S2 Quotient Remainder
5-54
Chapter 5. Application instructions
Execution conditions
Input condition
DIVSP, DDIVSP
Executed only once Executed only once
2) Program example
Program which stores the division result of D0001 and D0002 at D0010, D0011 while P020 is on.
P020
DIVS D0001 D0002 D0010
Program which stores the division result of D0001, D0002 and D0003,D0004 at D0010 ~ D0013
when P020 is switched on.
P020
DDIVSP D0001 D0003 D0010
Remainder Quotient
(= –696735) (= –53)
5-55
Chapter 5. Application instructions
S1 O O O O O O O O O O
ADDB(P)
S2 O O O O O O O O O O 7/9/11 O O O
DADDB(P)
D O O O O* O O O O
S1 S2 D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
ADDB(P) : Performs the addition of 16-bits BCD data specified at [ S1 ] and [ S2 ]. The addition
result is stored at the device specified at [ D ].
DADDB(P) : Performs the addition of 32-bits BIN data specified at [ S1+1, S1 ] and [ S2+1, S2 ].
The addition result is stored at the device specified at [ D1+1, D1 ].
When the addition result is over h9999(ADD / ADDP) or h99999999(DADD / DADDP), the carry flag
(F112) is set.
5-56
Chapter 5. Application instructions
Execution condition
Input condition
ADDBP, DADDBP
Executed only once Executed only once
2) Program example
When a rising edge is detected at P020, add BCD data of D0000 and D0001 and store the addition
result to P06 word.
P020
ADDP D0000 D0001 P06
16 bits
D0000 0 0 1 1 1 0 0 0 1 0 0 1 0 0 1 1 h3893
+
D0001 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 h1204
P06 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 h5097
5-57
Chapter 5. Application instructions
S1 O O O O O O O O O O
SUBB(P)
S2 O O O O O O O O O O 7/9/11 O O O
DSUBB(P)
D O O O O* O O O O
S1 S2 D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
SUBB(P) : Performs the subtraction of 16-bits BCD data specified at [ S1 ] and [ S2 ]. The
subtraction result is stored at the device specified at [ D ].
DSUBB(P) : Performs the subtraction of 32-bits BCD data specified at [ S1+1, S1 ] and [ S2+1, S2 ].
The subtraction result is stored at the device specified at [ D1+1, D1 ].
When the minuend is less than subtrahend, the LSB will underflow, and the carry flag (F112) will be
set.
5-58
Chapter 5. Application instructions
Execution condition
Input condition
SUBBP, DSUBBP
Executed only once Executed only once
2) Program example
When a rising edge is detected at P020, subtract contents of D0000 and D0001 and store the
addition result to P06 word.
P020
SUBB D0000 D0001 P06
16 bits
D0000 0 0 1 1 1 0 0 0 1 1 0 1 0 0 1 1 h3803
-
D0001 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 h1209
P06 0 0 1 0 0 1 1 0 1 1 0 0 0 1 1 1 h2594
5-59
Chapter 5. Application instructions
S1 O O O O O O O O O O
MULB(P)
S2 O O O O O O O O O O 7/9/11 O O
DMULB(P)
D O O O O* O O O O
S1 S2 D Operand setting
* Available only when do not use computer link module or data link module
1) Functions
MULB(P) : Performs the multiplication of BCD data specified as [ S1 ] and the BCD data specified
as [ S2 ], and stores the multiplication result into the device specified as [ D+1, D ].
DMULB(P) : Performs the multiplication of BCD data specified as [ S1+1, S ] and the BCD data
specified as [ S2+1, S2 ], and stores the multiplication result into the device specified as [ D+3, D+2,
D+1, D ]
Execution conditions
Input condition
MULBP, DMULBP
Executed only once Executed only once
5-60
Chapter 5. Application instructions
2) Program example
Program which stores the multiplication result of D0001 and D0002 at D0010, D0011 while P020 is
on.
P020
MULB D0001 D0002 D0010
Program which stores the multiplication result of D0001, D0002 and D0003,D0004 at D0010 ~
D0013 when P020 is switched on.
P020
DMULBP D0001 D0003 D0010
5-61
Chapter 5. Application instructions
S1 O O O O O O O O O O
DIVB(P)
S2 O O O O O O O O O O 7/9/11 O O
DDIVB(P)
D O O O O* O O O O
S1 S2 D Operand setting
DIVB
S1 The device storing dividend
DDIVB
S2 The device storing divider
* Available only when do not use computer link module or data link module
1) Functions
DIVB(P) : Performs the division of BCD data specified as [ S1 ] and the BCD data specified as
[ S2 ], and stores the division result into the device specified as [ D+1, D ]. The quotient is stored at
DDIVB(P) : Performs the multiplication of BCD data specified as [ S1+1, S ] and the BCD data
specified as [ S2+1, S2 ], and stores the multiplication result into the device specified as [ D+3, D+2,
D+1, D ]. The quotient is stored at [ D+1, D ], and the remainder is stored at [ D+3, D+2 ].
5-62
Chapter 5. Application instructions
Execution conditions
Input condition
DIVBP, DDIVBP
Executed only once Executed only once
2) Program example
Program which stores the division result of D0001 and D0002 at D0010, D0011 while P020 is on.
P020
DIVB D0001 D0002 D0010
Program which stores the division result of D0001, D0002 and D0003,D0004 at D0010 ~ D0013
when P020 is switched on.
P020
DDIVBP D0001 D0003 D0010
Remainder Quotient
5-63
Chapter 5. Application instructions
S1 O O O O O O O O O O
WAND(P)
S2 O O O O O O O O O O 7/9/11 O O
DWAND(P)
D O O O O* O O O O
S1 S2 D Operand setting
WAND
S1 Data for which logical
DWAND product will be performed
S2
S1 S2 D The device at which the
D result of logical product is
WANDP stored
DWANDP
* Available only when do not use computer link module or data link module
1) Functions
WAND(P) : Performs the logical product of the 16-bit data of device specified at [ S1 ] and [ S2 ] per
bit. Then stores the result of logical production into the device specified at [ D ].
16 bits
S1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 h3AD3
AND
S2 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 h224D
D 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 1 h2241
DWAND(P) : Performs the logical product of the 32-bit data of device specified as [ S1+1, S1 ] and
[ S2+1, S2 ] per bit, and stores the result into the device specified at [ D+1, D ].
5-64
Chapter 5. Application instructions
Execution conditions
Input condition
WANDP, DWANDP
Executed only once Executed only once
2) Program example
Program which performs the logical production of the contents of P04 and P05 words, then stores
the result to the P06 word when the P020 is switched on.
P020
WANDP P04 P05 P06
16 bits
P04 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 h3AD3
AND
P05 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 h224D
P06 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 1 h2241
5-65
Chapter 5. Application instructions
S1 O O O O O O O O O O
WOR(P)
S2 O O O O O O O O O O 7/9/11 O O
DWOR(P)
D O O O O* O O O O
S1 S2 D Operand setting
WOR
S1 Data for which logical
DWOR addition will be performed
S2
S1 S2 D The device at which the
D result of logical addition is
WORP stored
DWORP
* Available only when do not use computer link module or data link module
1) Functions
WOR(P) : Performs the logical addition of the 16-bit data of device specified at [ S1 ] and [ S2 ] per
bit. Then stores the result of logical addition into the device specified at [ D ].
16 bits
S1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 h3AD3
WOR
S2 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 h224D
D 0 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 h3ADF
DWOR(P) : Performs the logical addition of the 32-bit data of device specified as [ S1+1, S1 ] and
[ S2+1, S2 ] per bit, and stores the result into the device specified at [ D+1, D ].
5-66
Chapter 5. Application instructions
Execution conditions
Input condition
WORP, DWORP
Executed only once Executed only once
2) Program example
Program that performs the logical addition of the contents of P04 and P05 words, then stores the
result to the P06 word when the P020 is switched on.
P020
WORP P04 P05 P06
16 bits
P04 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 h3AD3
WOR
P05 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 h224D
P06 0 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 h3ADF
5-67
Chapter 5. Application instructions
S1 O O O O O O O O O O
WXOR(P)
S2 O O O O O O O O O O 7/9/11 O O
DWXOR(P)
D O O O O* O O O O
S1 S2 D Operand setting
WXOR
S1 Data for which exclusive
DWXOR OR will be performed
S2
S1 S2 D The device at which the
D result of exclusive OR is
WXORP stored
DWXORP
* Available only when do not use computer link module or data link module
1) Functions
WXOR(P) : Performs the exclusive OR of the 16-bit data of device specified at [ S1 ] and [ S2 ] per
bit. Then stores the result of logical production into the device specified at [ D ].
16 bits
S1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 h3AD3
WXOR
S2 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 h224D
D 0 1 0 1 1 0 0 0 1 0 0 1 1 1 1 0 h589E
DWXOR(P) : Performs the exclusive OR of the 32-bit data of device specified as [ S1+1, S1 ] and
[ S2+1, S2 ] per bit, and stores the result into the device specified at [ D+1, D ].
5-68
Chapter 5. Application instructions
Execution conditions
Input condition
WXORP, DWXORP
Executed only once Executed only once
2) Program example
Program that performs the exclusive OR of the contents of P04 and h2345, then stores the result to
the P06 word when the P020 is switched on.
P020
WXORP P04 h2345 P06
16 bits
P04 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 h3AD3
WXOR
h2345 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 h2345
P06 0 0 0 1 1 0 0 1 1 0 0 1 0 1 1 0 h1996
5-69
Chapter 5. Application instructions
WXOR
FUN(164) WXOR FUN(166) DWXOR Applicable
(Word exclusive All CPUs
FUN(165) WXORP FUN(167) DWXORP CPU
NOR)
S1 O O O O O O O O O O
WXNR(P)
S2 O O O O O O O O O O 7/9/11 O O
DWXNR(P)
D O O O O* O O O O
S1 S2 D Operand setting
WXNR
S1 Data for which exclusive
DWXNR NOR will be performed
S2
S1 S2 D The device at which the
D result of exclusive NOR is
WXNRP stored
DWXNRP
* Available only when do not use computer link module or data link module
1) Functions
WXNR(P) : Performs the exclusive NOR of the 16-bit data of device specified at [ S1 ] and [ S2 ]
per bit. Then stores the result of logical production into the device specified at [ D ].
16 bits
S1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 h3AD3
WXNR
S2 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 h224D
D 1 0 1 0 0 1 1 1 0 1 1 0 0 0 0 1 hA761
DWXNR(P) : Performs the exclusive NOR of the 32-bit data of device specified as [ S1+1, S1 ] and
[ S2+1, S2 ] per bit, and stores the result into the device specified at [ D+1, D ].
5-70
Chapter 5. Application instructions
Execution conditions
Input condition
WXNRP, DWXNRP
Executed only once Executed only once
2) Program example
Program that performs the exclusive NOR of the contents of P04 and h2345, then stores the result
to the P06 word when the P020 is switched on.
P020
WXNRP P04 h2345 P06
16 bits
P04 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 h3AD3
WXOR
h2345 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 h2345
P06 1 1 1 0 0 1 1 0 0 1 1 0 1 0 0 1 hE669
5-71
Chapter 5. Application instructions
S O O O O O O O O O
SEG
D O O O O* O O O O 7 O
SEGP
Cw O
S D Cw Operand setting
* Available only when do not use computer link module or data link module
1) Functions
h s d x z
c) x : Don’t care
Decodes the data of z4 bits block that start from the sth bit of device specified at [ S ] into 7
segment display data and stores the result to the z bits block that starts from the sth bit of device
[ D ].
5-72
Chapter 5. Application instructions
Execution conditions
Input condition
SEGP
Executed only once Executed only once
2) Program example
Program that decodes 8-bits from the bit 2 of D0000 into 7 segment display format, and stores the
result to 16-bits from the bit 3 of P06 when P030 is switched on.
P030
SEGP D0000 P06 h2302
F E D C B A 9 8 7 6 5 4 3 2 1 0
P04 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 h3AD3
3 2 1 0 F E D C B A 9 8 7 6 5 4 3 2 1 0
0 1 1 1 1 1 0 0 0 1 1 0 0 1 1 0
5-73
Chapter 5. Application instructions
S D
Configuration of 7 Displayed
Hex Binary segment b7 b6 b5 b4 b3 b2 b1 b0 data
0 0000 0 0 1 1 1 1 1 1 0
1 0001 0 0 0 0 0 1 1 0 1
2 0010 0 1 0 1 1 0 1 1 2
3 0011 0 1 0 0 1 1 1 1 3
4 0100 0 1 1 0 0 1 1 0 4
b0
5 0101 0 1 1 0 1 1 0 1 5
6 0110 b5 b1 0 1 1 1 1 1 0 1 6
b6
7 0111 0 0 1 0 0 1 1 1 7
b4 b2
8 1000 0 1 1 1 1 1 1 1 8
b3
9 1001 0 1 1 0 1 1 1 1 9
A 1010 0 1 1 1 0 1 1 1 A
B 1011 0 1 1 1 1 1 0 0 B
C 1100 0 0 1 1 1 0 0 1 C
D 1101 0 1 0 1 1 1 1 0 D
E 1110 0 1 1 1 1 0 0 1 E
F 1111 0 1 1 1 0 0 0 1 F
5-74
Chapter 5. Application instructions
S O O O O O O O O O
ASC
D O O O O* O O O O 7 O
ASCP
Cw O
S D Cw Operand setting
* Available only when do not use computer link module or data link module
1) Functions
h s d x z
g) x : Don’t care
Converts the data of z4 bits block that start from the sth bit of device specified at [ S ] into ASCII
code and stores the result to the z bits block that starts from the sth bit of device [ D ].
5-75
Chapter 5. Application instructions
Execution conditions
Input condition
ASCP
Executed only once Executed only once
2) Program example
Program that converts 8-bits from the bit 2 of D0010 into ASCII code data, and stores the result to
16-bits from the bit 1 of P06 while P030 is on.
P030
ASC D0010 P06 h2102
F E D C B A 9 8 7 6 5 4 3 2 1 0
D0010 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1
2 1 0 F E D C B A 9 8 7 6 5 4 3 2 1 0
0 0 1 0 0 0 0 1 0 0 0 1 1 0 1 0 0
5-76
Chapter 5. Application instructions
BSUM(P) S O O O O O O O O O O
5 O O
DBSUM(P) D O O O O* O O O O
S D Operand setting
BSUMP
DBSUMP
* Available only when do not use computer link module or data link module
1) Functions
BSUM(P) : Counts the numbers of ‘1’ in the device specified as [ S ], then stores the result into the
device specified as [ D ] in hexadecimal format.
DBSUM(P) : Counts the numbers of ‘1’ in the device specified as [ S+1, S ], then stores the result
into the device specified as [ D ] in hexadecimal format.
Execution conditions
Input condition
BSUMP, DBSUMP
Executed only once Executed only once
5-77
Chapter 5. Application instructions
2) Program example
Program that count the numbers of ‘1’ in P020 and P021, then store the count result into D0030
when M020 is switched on.
M020
DBSUMP P020 D0030
F E D C B A 9 8 7 6 5 4 3 2 1 0
P020 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 The numbers
of 1 = 9
F E D C B A 9 8 7 6 5 4 3 2 1 0
The numbers
P021 1 0 1 0 0 0 0 1 1 0 1 1 0 1 1 0 of 1 = 8
F E D C B A 9 8 7 6 5 4 3 2 1 0
Total numbers
D0030 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 of 1 = 17
(h0011)
5-78
Chapter 5. Application instructions
S O O O O O O O O O O
ENCO
D O O O O* O O O O 7 O
ENCOP
n O O
S D n Operand setting
* Available only when do not use computer link module or data link module
1) Functions
Encodes the data of 2n bits, which begin the bit 0 of device specified as [ S ], and stores the result
to the device specified as [ D ].
For ‘n’, 1 ~ 8 can be specified. If the value of n is out of this range, no processing is performed and
the contents of [ D ] is not changed.
When multiple bits are 1, processing is performed for the most significant bit. If the value of n is 0,
the zero flag (F111) will be set.
When the value of n is larger than 4, the source data area is expanded like [ S+1 ], [ S+2 ], …
When n=8, the length of source data is 256 bits. ( [ S+15, S+14, …, S+1, S ] )
Execution conditions
Input condition
ENCOP
Executed only once Executed only once
5-79
Chapter 5. Application instructions
2) Program example
Program that encode the 8-bits (bit 0 ~ bit 7) of P06 word and stores the encoding result to the P06
word when P020 is switched on.
P020
ENCOP P02 P06 3
F E D C B A 9 8 7 6 5 4 3 2 1 0
The highest
P02 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 position ‘1’ is
bit 7
When n = 3,
8 (=2n ) bits are effective
F E D C B A 9 8 7 6 5 4 3 2 1 0
Encoding
P06 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 result = h0007
Program that encode the current value of counter C000 and stores the encoding result at the P05
word. The counter C000 is increased at every 1 sec.
5-80
Chapter 5. Application instructions
S O O O O O O O O O O
DECO
D O O O O* O O O O 7 O
DECOP
n O O
S D n Operand setting
* Available only when do not use computer link module or data link module
1) Functions
Decodes the data of lower n bits of the device specified as [ S ], and stores the decoding result to
the block of 2n bits that start from the bit 0 of the device specified as [ D ].
For ‘n’, 1 ~ 8 can be specified. If the value of n is 0, no processing is performed and the contents of
[ D ] is not changed. If the value of n is over 8, the error flag (F110) is set and no processing is
performed.
When the value of n is larger than 4, the source data area is expanded like [ D+1 ], [ D+2 ], …
When n=8, the length of decoding result data is 256 bits. ( [ D+15, D+14, …, D+1, D ] )
Execution conditions
Input condition
DECOP
Executed only once Executed only once
5-81
Chapter 5. Application instructions
2) Program example
Program that decode lower 4 bits of p02 word and stores the decoding result to P05 word when
P030 is switched on.
P030
DECOP P02 P05 4
F E D C B A 9 8 7 6 5 4 3 2 1 0
The value of
P02 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 last 4 bit of
P02 = h9
When n = 4,
16 (=24 ) bits are effective
F E D C B A 9 8 7 6 5 4 3 2 1 0
Decoding
P05 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 result = h0009
Program that decodes the current value of counter C000 and stores the decoding result to P05 and
P06 word. The current value of counter is increased at every 1 second and when the current value
F093
U CTR C000
C000
R <S> 00031
F010
DECO C000 P05 5
END
5-82
Chapter 5. Application instructions
S O O O O O O O O O O
FILR(P)
D O O O O* O O O O 7 O
DFILR(P)
n O O
S D n Operand setting
* Available only when do not use computer link module or data link module
1) Functions
[ S -1 ] [ S -1 ]
[S] [S]
[ S+1 ] [ S+1 ]
Offset = n Offset = n
FILR(P) DFILR(P)
5-83
Chapter 5. Application instructions
Execution conditions
Input condition
FILRP, DFILRP
Executed only once Executed only once
2) Program example
Program that transfer the content of the M03+n word to M01 word when P020 is switched on. The n
is stored at D0010 word.
P020
FILRP M03 M01 D0010
M000
M001 h6030
M002
M003
M004
when n=3
M005
M006 h6030
M007 h5030
M000
M001 h5030
M002
M003
M004
M005 when n=4
M006 h6030
M007 h5030
5-84
Chapter 5. Application instructions
D O O O O* O O O O O
FILW(P)
S O O O O O O O O O 7 O
DFILW(P)
n O O
D S n Operand setting
* Available only when do not use computer link module or data link module
1) Functions
[ D -1 ] [ D -1 ]
[D] [D]
[ D+1 ] [ D+1 ]
Offset = n Offset = n
FILW(P) DFILW(P)
5-85
Chapter 5. Application instructions
Execution conditions
Input condition
FILWP, DFILWP
Executed only once Executed only once
2) Program example
Program that transfer the content of the M01 word to M03+n word when P020 is switched on. The n
is stored at D0010 word.
P020
FILWP M03 M01 D0010
M000
M001 h6030
M002
M003
M004
when n=3
M005
M006 h6030
M007
M000
M001 h6030
M002
M003
M004
M005 when n=4
M006
M007 h6030
5-86
Chapter 5. Application instructions
S O O O O O O O O O
DIS(P) D O O O O* O O O O 7 O
n O O
S D n Operand setting
* Available only when do not use computer link module or data link module
1) Functions
Transfers n nibbles that start from the bit 0 of device specified as [ S ] into the lower 4 bits of the
block specified as [ D+n-1 ] ~ [ D ].
The higher 12 bits (bit 4 ~ bit F) of the block specified as [ D+n-1 ] ~ [ D ] are cleared as 0.
When n=0, no processing is performed.
When n > 4, the error flag is set and no processing is performed.
When n = 4,
16 ( =44 ) bits are effective
F E D C B A 9 8 7 6 5 4 3 2 1 0
S 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1
F 4 3 0
D 0000 0000 0000 0001
5-87
Chapter 5. Application instructions
Execution conditions
Input condition
DISP
Executed only once Executed only once
2) Program examples
Program that dissociate the contents of lower 3 nibbles of P02 word to lower 4 bits of D0000 ~
D0003 when P030 is switched on.
P030
DISP P02 D0000 3
F E D C B A 9 8 7 6 5 4 3 2 1 0
P02 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1
F 4 3 0
D0000 0000 0000 0000 0001
5-88
Chapter 5. Application instructions
S O O O O O O O O O
UNI(P) D O O O O* O O O O 7 O
n O O
S D n Operand setting
* Available only when do not use computer link module or data link module
1) Functions
Transfers lowest 4 bits of the block specified as [ S+n-1 ] ~ [ S ] into the lower n nibbles of the
device specified as [ D ].
The higher bits (bit 2n ~ bit F) of the device specified as [ D ] are cleared as 0.
When n=0, no processing is performed.
When n > 4, the error flag is set and no processing is performed.
F 4 3 0
S 0000 0000 0000 0001
When n = 4
F E D C B A 9 8 7 6 5 4 3 2 1 0
0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1
5-89
Chapter 5. Application instructions
Execution conditions
Input condition
UNIP
Executed only once Executed only once
2) Program examples
Program that associate the content of lower 4 bits of D0000 ~ D0003 to lower 3 nibbles of P02 word
when P030 is switched on.
P030
UNIP D0000 P06 3
F 4 3 0
D0000 0000 0000 0000 0001
F E D C B A 9 8 7 6 5 4 3 2 1 0
P06 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 1
5-90
Chapter 5. Application instructions
K200S
IORF FUN(200) IORF Applicable
K300S
(I/O refresh) FUN(201) IORFP CPU
K1000S
D1 O
IORF(P) 5 O
D2 O
D1 D2 Operand setting
IORFP
1) Functions
This instruction is useful when read latest input data or output the data of P area to external device
immediately in a sequence program that has a long scan time.
Execution conditions
Input condition
IORFP
Executed only once Executed only once
5-91
Chapter 5. Application instructions
2) Program example
During FOR ~ NEXT loop execution, the P060 is keep the initial status, but the P061 is switched
on/off according to the status change of the P020.
P020
( P060 )
[ FOR 10000 ]
F010
[ WDT ]
F010 FOR ~ NEXT loop
[ IORF P02 P02 ]
P020 (Repeats 10000 times)
( P061 )
F010
[ IORF P06 P06 ]
[ NEXT ]
[ END ]
5-92
Chapter 5. Application instructions
5.12.1 FALS
K200S
FALS Applicable
FUN(204) FALS K300S
(Error display) CPU
K1000S
FALS n O 3
Operand setting
1) Functions
When the input condition is switched on, stores a number specified as ‘n’ to the F14 word (F140 ~
F14F) and set the FALS flag (F038).
Once the F14 is set by a FALS instruction, it keeps the value until it is cleared by executing ‘FALS
0000’ instruction. Even if other FALS instruction is executed, the value of F14 word is not changed.
Execution condition
Input condition
2) Program example
P030
FALS h1234
P031
FALS hAAAA
P032
FALS hBBBB
P033
FALS h0000
5-93
Chapter 5. Application instructions
5.12.2 DUTY
DUTY
Applicable
(User defined FUN(205) DUTY All CPUs
CPU
pulse)
D O
DUTY n1
O 7
n2 O
Operand setting
1) Functions
Generates an user defined timing clock specified as [ D ] to On at the scan count specified as ‘n1’
and to OFF at the scan count specified as ‘n2’.
At the initial status (when the timing pulse is off), the timing pulse is off.
When ‘n1’ =0, the timing pulse is always off.
When ‘n1’ >0 and ‘n2’ =0, the timing pulse is always on.
Input condition
Timing pulse
n1 scans n2 scans
5-94
Chapter 5. Application instructions
Even if the timing pulse input turns off, the timing pulse by the DUTY instruction does not turn off.
Therefore, to stop the timing pulse, execute the another DUTY instruction as shown below.
DUTY D 0 1
2) Program example
Program that generates a timing pulse of 250 scans on, and 300 scans off and output it to F100
contact when P030 switched on. When P031 is switched on, the timing pulse is stopped.
P030
DUTY F100 250 300
F100
( P061 )
P031
DUTY F100 0 1
P030
P031
Timing pulse
250 scans 300 scans
5-95
Chapter 5. Application instructions
WDT K200S
FUN(202) WDT Applicable
(Watch dog timer K300S
FUN(203) WDTP CPU
clear) K1000S
WDT
1
WDTP
WDT
WDTP
1) Functions
dog timer at every scan, change the set value of watch dog timer by the parameter setting
Set the set value of the watch dog timer so that ‘t1’ from step 0 to WDT(P) instruction and ‘t2’ from
the WDT(P) to END instruction do not exceed the set value. (See the diagram below)
Step 0 END
WDTP
t1 t2
The WDT(P) instruction can be user two or more times during one scan. However, please be
careful when use WDT(P) instruction because if an error occurs, the outputs cannot be turned off
immediately.
Values of scan time stored in special resisters (F device) are not cleared though the WDT(P)
instruction is executed.
5-96
Chapter 5. Application instructions
Execution conditions
Input condition
WDTP
Executed only once Executed only once
2) Program example
The program that has a long scan time because of FOR ~ NEXT loop.
FOR 50000
P020
WDT
END
5-97
Chapter 5. Application instructions
5.12.4 OUTOFF
OUTOFF Applicable
FUN(208) OUTOFF All CPUs
(All output off) CPU
OUTOFF 1
OUTOFF
1) Functions
Stops to output the operation result of P area to the external device and turn on the OUTOFF flag
(F113) when an input condition is turns on. However, the P device is updated according to the
operation result.
When the input condition switched off, the CPU restarts to output operation result of P area to
external devices.
Input condition
2) Program example
F093
INCP P05
F092
DECP P06
P020
OUTOFF
5-98
Chapter 5. Application instructions
5.12.5 STOP
STOP K200S
Applicable
(Stop execution of FUN(008) STOP K300S
CPU
program) K1000S
STOP 1
STOP
1) Functions
When an input condition is switched on, stops execution of sequence program and change mode to
STOP mode after finishing the current scan.
To resume the operation of CPU after the execution of STOP instruction, change the mode of CPU
to the STOP mode and move it to the RUN mode again by loader or mode switch.
2) Program example
P021
STOP
5-99
Chapter 5. Application instructions
JMP
n O 1
JME
Operand setting
JMP n
K10S1/K10S/K30S/K60S
: 0 ~ 63
n
K200S/K300S/K1000S
JME n
: 0 ~ 127
1) Functions
When the ‘JMP n’ instruction is executed by turn on of input condition, the CPU jumps to the JME
instruction that has same ‘n’ and instructions between ‘JMP n’ and ‘JME n’ are not executed.
The ‘JMP n’ instruction should be matched only one ‘JME n’ instruction. The duplication of ‘JME n’
is not permitted. However, the duplication of ‘JMP n’ instruction is possible.
JMP 001
JME 001
Error No Error
A ‘JMP n’ instruction without corresponding ‘JME n’ instruction (stand-alone ‘JMP n’) will cause
program error. If only a JME or JMP is inside of a loop (subroutine, FOR ~ NEXT, or interrupt
routine), an operation error will occur when the JMP instruction is enabled. (Refer 2.7.1 for details)
5-100
Chapter 5. Application instructions
Execution conditions
Input condition
2) Program example
- Program that skips the ring counter operation between ‘JMP 2’ and ‘JME 2’ when P020 is on.
P020
JMP 02
P030
U CTU C002
P031
R <s> 00100
C002
( P060 )
JME 02
5-101
Chapter 5. Application instructions
CALL(P)
n O 1
SBRT
RET
Operand setting
CALL(P) n
K10S1
: 0 ~ 15
END K10S/K30S/K60S
n
: 0 ~ 63
SBRT n K200S/K300S/K1000S
: 0 ~ 127
RET
1) Functions
When the input condition turns on, stops the sequence program and executes the corresponding
subroutine program specified by pointer ‘n’. After finishing execution of subroutine, resume to
Multiple levels of nesting of the CALL(P) instruction are allowed as much as 64.
The range of pointer ‘n’ is various according to the type of CPU. (See the above picture)
If a ‘CALL(P) n’ instruction has no corresponding ‘SBRT’ instruction that has same pointer ‘n’ with
the ‘CALL(P) n’ instruction, an instruction error occurs.
Execution conditions
Input condition
CALLP
Executed only once Executed only once
5-102
Chapter 5. Application instructions
2) Program example
P020
( P050 )
P021 P022
( P051 )
P02F
CALL 0003
END
SBRT 0003
F092
INCP D0000
F010
MOV D0000 P06
RET
5-103
Chapter 5. Application instructions
K200S
FOR / NEXT FUN(206) FOR Applicable
K300S
(Subroutine) FUN(207) NEXT CPU
K1000S
FOR n O 3
NEXT 1
Operand setting
FOR n
n Range : 0 ~ 32767
NEXT
1) Functions
The FOR instruction is unconditionally executed. The CPU repeats the FOR ~ NEXT block n times
and then performs the processing of the next step of the NEXT instruction.
The range of ‘n’ is 0 ~ 32767. If the value of ‘n’ is out of range, an instruction error occurs.
Up to five levels of the nesting of FOR is allowed.
In the following cases, operation error occurs;
a) After the execution of FOR instruction, the END instruction has been executed before the
b) The NEXT instruction has been executed before the FOR instruction is executed.
c) The number of the FOR instructions is different from that of the NEXT instructions.
d) The JMP instruction is executed to exit from the FOR ~ NEXT block or to enter into the FOR
~ NEXT block.
2) Program example
FOR 30
NEXT
5-104
Chapter 5. Application instructions
5.14.2 BREAK
BREAK K200S
Applicable
(Escape from FOR FUN(220) BREAK K300S
CPU
~ NEXT block) K1000S
BREAK 3
BREAK
1) Function
When the input condition is on, exits immediately from the current FOR ~ NEXT loop and go to the
next step of the NEXT instruction.
Execution condition
Input condition
2) Program example
M0006
FOR 5
( )
M0000
BREAK When M000 turns on, exits
immediately from FOR ~
FOR 4 NEXT loop and go to the
step #.
( )
( )
NEXT
( )
NEXT
# ( )
5-105
Chapter 5. Application instructions
STC, CLC
FUN(002) STC Applicable
(Set / Reset the All CPUs
FUN(003) CLC CPU
carry flag)
STC
1 O
CLC
STC
CLC
1) Functions
STC : Turns the carry flag (F112) on when the input condition is switched on.
CLC : Turns the carry flag (F112) off when the input condition is switched on.
Execution conditions
Input condition
2) Program example
Program that set the carry flag (F112) when M0000 is on.
M0000
STC
Program that reset the carry flag (F112) when M0001 is on.
M0001
CLC
5-106
Chapter 5. Application instructions
5.15.2 CLE
CLE K200S
Applicable
(Reset the latched FUN(009) CLE K300S
CPU
error flag) K1000S
CLE 1
CLE
1) Functions
Reset the latched error flag (F115) when the input condition turns on.
( See the 2.8.2 for detail information of F115 flag)
Execution condition
Input condition
2) Program example
- Program that resets the latched error flag (F115) when M0000 turns on.
M0000
CLE
5-107
Chapter 5. Application instructions
sl O
S O
GET(P) 9 O
D O O O O* O O O O
n2 O
Operand setting
Slot number of special function
sl module is mounted
GET sl S D n2 Start address of data to be read
S
D Start address of data to be stored
* Available only when do not use computer link module or data link module
1) Functions
Reads the data of ‘n2’ words, which start at the address specified as [ S ] of buffer memory inside
the special module specified at ‘sl’, and stores the data into devices which begin with the device
specified at [ D ].
[S] [D]
n2 words n2 words
5-108
Chapter 5. Application instructions
Execution conditions
Input condition
GETP
Executed only once Executed only once
2) Program example
Program that reads 4 words from the address 0 of buffer memory of A/D module, and stores them
to the 4 words from D0010 of CPU module.
[0] h1122
h4477 D0010 h1122
4 words
h0F0F h4477
4 words
hE246 h0F0F
hE246
5-109
Chapter 5. Application instructions
PUT, PUTP
K200S
FUN(234) PUT Applicable
(Write data to
K300S
special function FUN(235) PUTP CPU
K1000S
module)
sl O
D O
PUT(P) 9 O
S O O O O* O O O O
n2 O
Operand setting
Slot number of special function
n1 module is mounted
PUT sl D S n2 Start address of data to be stored
D
S Start address of source data
* Available only when do not use computer link module or data link module
1) Functions
Writes the data of ‘n2’ words, which start at the address specified as [ S ] of CPU, and transfer the
data into the block starting at the address specified as [ S ] of buffer memory inside the special
[S] [D]
n2 words n2 words
5-110
Chapter 5. Application instructions
Execution conditions
Input condition
PUTP
Executed only once Executed only once
2) Program example
Program that write 4 words from D0010 of CPU module, and stores them to the 4 words from the
address 0 of buffer memory of D/A module.
[0] h1122
h4477 D0010 h1122
4 words
h0F0F h4477
4 words
hE246 h0F0F
hE246
5-111
Chapter 5. Application instructions
5.17.1 READ
READ K200S
Applicable
(Read data from FUN(244) READ K300S
CPU
remote station) K1000S
sl O
St O O O O O O O O O O
D O O O O* O O O O
READ 13 O
S O O O O O O O O O
n2 O O
SS O O O O* O O O O
Operand setting
Slot number of FUEA module is
sl mounted
READ sl St D S n2 SS Station number of remote station
St to be read data
Start address of master station at
D
which read data is stored
Start address of remote station at
S
which data to be read
n2 Numbers of word to be read
Device at which the link status is
SS stored
* Available only when do not use computer link module or data link module
1) Functions
Reads ‘n2’ words which begin with the address [ S ] of the remote station that has station number
‘St’ through the FUEA module mounted at the slot ‘sl’, and store the read data to the block which
begin with the address [ D ] of the master station. The link status is stored at the address ‘SS’ of the
master station.
5-112
Chapter 5. Application instructions
[S] [D]
FUEA FUEA
module module
An instruction error occurs when the assress [ S+n2 ] or [ D+n2 ] is out of the range of specified
device.
Execution conditions
Input condition
READ
Executed only once Executed only once
2) Program example
Program that read 20 words which begin with D0200 of remote station (Station No. of FUEA
module = h1D) through the FUEA module of slot number 2, and store the read data to the block
which begin with D0300. The link status is stored at the M020 word.
D0200 D0300
20 words 20 words
FUEA FUEA
module module
at
Station slot No. M020 Link status
No =h1D = 02
5-113
Chapter 5. Application instructions
System configuration
Self-station
5-114
Chapter 5. Application instructions
5.17.2 WRITE
WRITE K200S
Applicable
(Write data to FUN(245) WRITE K300S
CPU
remote station) K1000S
sl O
St O O O O O O O O O O
S O O O O* O O O O
WRITE 13 O
D O O O O O O O O O
n2 O O
SS O O O O* O O O O
Operand setting
Slot number of FUEA module is
sl mounted
WRITE sl St S D n2 SS Station number of remote station
St to be read data
Start address of master station at
S
which read data is stored
D Start address of remote station at
which data to be read
n2 Numbers of word to be read
Device at which the link status is
SS stored
* Available only when do not use computer link module or data link module
1) Functions
Reads ‘n2’ words which begin with the address [ S ], and write the read data to the block which
begin with the address [ D ] of the remote station that has a station number specified as ‘St’ through
the FUEA module mounted at the slot ‘sl’ of self station. The link status is stored at the address ‘SS’
5-115
Chapter 5. Application instructions
[D] [S]
FUEA FUEA
module module
at
Station slot No. [ SS ] Link status
No =’St’ = ‘n1’
An instruction error occurs when the assress [ S+n2 ] or [ D+n2 ] is out of the range of specified
device.
Execution conditions
Input condition
WRITE
Executed only once Executed only once
2) Program example
Program that read 14 words which begin with D1234 of self station, and write the read data to the
block which begin with D5678 of remote station (Station No. of FUEA module = h2F) through the
FUEA module at slot number 3 of self station. The link status is stored at the K015 word.
(System configuration is same as the example of READ instruction.)
D5678 D1234
14 words 14 words
FUEA FUEA
module module
5-116
Chapter 5. Application instructions
5.17.3 RGET
RGET K200S
Applicable
(Read data from special function FUN(232) RGET K300S
CPU
module of remote station) K1000S
sl O
St O
D O O O O* O O O O
RGET 13 O
S O
n2 O O
SS O O O O* O O O O
Operand setting
RGET sl St D S n2 SS Slot number of FUEA module is
sl mounted & Type of special
The configuration of ‘sl’ function module to be read
Lower 8 bits (CD) : Slot No. of FUEA Station number of remote station
AB CD St to be read data & Slot number of
Higher 8 bits (AB) : Type of special
special function module
function module
Start address of self station at
D
The ID code of special function module which read data is stored
Start address of remote station at
AD DAI DAV TC RTD S
which data to be read
K1000S 00h 01h 02h 03h 04h n2 Numbers of word to be read
K300S 80h 81h 82h 83h 84h Device at which the link status is
80h 81h 82h − − SS stored
K200S
* Available only when do not use computer link module or data link module
1) Functions
Reads the data of ‘n2’ words, which start at the address specified as [ S ] of buffer memory inside
the special function module of remote station (station number & slot number is specified as ‘St’)
through the FUEA module, and stores the data into devices which begin with the device specified
as [ D ]. Then, stores the link status into the device specified as [ SS ] of self station.
5-117
Chapter 5. Application instructions
Buffer memory of
special function module
[D]
[S]
‘n2’ words ‘n2’ words
FUEA FUEA
module module
at
Station slot No. [ SS ] Link status
No =’St’ = ‘sl’
An instruction error occurs when the assress [ S+n2 ] or [ D+n2 ] is out of the range of specified
device.
Execution conditions
Input condition
RGET
Executed only once Executed only once
2) Program example
Program that reads 10 words, through the FUEA module mounted at the slot 03, from the address
10 of the buffer memory of the K1000S A/D module mounted at the slot 01 of remote station h1D,
and stores the read data to the 10 words which begin with D0300 of self station. The link status is
stored at M020 word of self station.
D0300
10
10 words 10 words
FUEA FUEA
module module
at
Station slot No. M020 Link status
No =h1D = 03
5-118
Chapter 5. Application instructions
System configuration
Self-station
Remote station 1
(K1000S) Power CPU 16 points 4 32 points FUEA
supply module input channel input module
module module A/D module
module Station
No h1D
slot 0 slot 1 slot 2 slot 3
Remote station 2
(K300S) Power CPU 16 points 32 points 4 FUEA
supply module input input channel module
module module module A/D
module Station
No h2F
slot 0 slot 1 slot 2 slot 3
5-119
Chapter 5. Application instructions
5.17.4 RPUT
RPUT K200S
Applicable
(Write data to special function FUN(233) RPUT K300S
CPU
module of remote station) K1000S
sl O
St O
S O
RPUT 13 O
D O O O O* O O O O
n2 O O
SS O O O O* O O O O
Operand setting
RPUT sl St S D n2 SS Slot number of FUEA module is
sl mounted & Type of special
The configuration of ‘sl’ function module to be read
Lower 8 bits (CD) : Slot No. of FUEA Station number of remote station
AB CD St to be read data & Slot number of
Higher 8 bits (AB) : Type of special
special function module
function module
Start address of self station at
S
The ID code of special function module which source data is stored
Start address of remote station at
AD DAI DAV TC RTD D
which data to be written
K1000S 00h 01h 02h 03h 04h n2 Numbers of word to be written
K300S 80h 81h 82h 83h 84h Device at which the link status is
80h 81h 82h − − SS stored
K200S
* Available only when do not use computer link module or data link module
1) Functions
Reads the data of ‘n2’ words, which start at the device specified as [ D ], and write the data to the
block which begin with the address specified as [ S ] of buffer memory inside the special function
module of remote station (station number & slot number is specified as ‘St’) through the FUEA
module. Then, stores the link status into the device specified as [ SS ] of self station.
5-120
Chapter 5. Application instructions
Buffer memory of
special function module
[S]
[D]
‘n2’ words ‘n2’ words
FUEA FUEA
module module
at
Station slot No. [ SS ] Link status
No =’St’ = ‘sl’
An instruction error occurs when the assress [ S+n2 ] or [ D+n2 ] is out of the range of specified
device.
Execution conditions
Input condition
RPUT
Executed only once Executed only once
2) Program example
Program that reads 15 words from D0200 of self station, then write the data to the 15 words block
which begin with the address 5 of buffer memory of the K300S A/D module mounted at the slot 02
of remote station h2F through the FUEA module at the slot 02. The link status is stored at M020
D0200
05
15 words 15 words
FUEA FUEA
module module
at
Station slot No. M020 Link status
No =h2F = 03
5-121
Chapter 5. Application instructions
5.17.5 STATUS
STATUS K200S
Applicable
(Read the link information of FUN(247) STATUS K300S
CPU
FUEA module of remote station) K1000S
sl O
St O O O O O O O O O
STATUS 9 O
D O O O O* O O O O
SS O O O O* O O O O
Operand setting
Slot number of FUEA module is
sl mounted & Type of special
function module to be read
STATUS sl St D SS
Station number of remote station
St to be read data & Slot number of
special function module
Start address of remote station at
D
which data to be written
Device at which the link status is
SS stored
* Available only when do not use computer link module or data link module
1) Functions
Read the link information (10 words) from the remote station of which station number is ‘St’ through
the FUEA module mounted at the slot number ‘sl’, and stores the information data to the block
begin with the device specified as [ D ]. The link status is stored into the device [ SS ].
Execution conditions
Input condition
RPUT
Executed only once Executed only once
2) Program example
- Program that reads the information of remote station (station number is stored at D0000) through the
FUEA module of slot 07, and stores the data from D1234. The link status is stored into K015 word.
5-122
Chapter 5. Application instructions
5.18.1 EI, DI
K200S
EI / DI FUN(238) EI Applicable
K300S
(Enable / Disable interrupt) FUN(239) DI CPU
K1000S
EI
n O 1
DI
Operand setting
EI n
0~7 (K200S)
n 0 ~ 13 (K300S)
DI n 0 ~ 29 (K1000S)
1) Functions
EI : Enables the inturrupt (TDI or PDI) specified as ‘n’ when input condition turns on. If ‘n’ is not
specified, all interrupts are enabled.
DI : Disables the inturrupt (TDI or PDI) specified as ‘n’ when input condition turns on. If ‘n’ is not
specified, all interrupts are disabled.
Input condition
2) Program example
EI 5
DI
5-123
Chapter 5. Application instructions
K200S
TDINT / IRET FUN(226) TDINT Applicable
K300S
(Time driven interrupt) FUN(225) IRET CPU
K1000S
TDINT n O 1
Operand setting
TDINT n 0~5 (K200S)
n 0~7 (K300S)
0 ~ 15 (K1000S)
1) Functions
The interval of interrupt can be set as 60msec ~ 60000msec (unit : 10msec) with parameter setting.
The execution time of interrupt routine should be less than the interval of interrupt.
The TDINT n instruction has to be placed after the END instruction.
The TDINT and IRET instructions are executed unconditionally.
2) Program example
TDINT n
M0000
( P0000 )
•
M0001
( P0001 )
IRET
5-124
Chapter 5. Application instructions
INT n O 1
Operand setting
INT n 0~5 (K200S)
n 0~7 (K300S)
0 ~ 15 (K1000S)
1) Functions
To use process driven interrupts, the interrupt module is required and general input module can not
ube used for interrupt input. However, K200S can use general input module for interrupt input by
2) Program example
INT n
M0000
( P0000 )
•
M0001
( P0001 )
IRET
5-125
Chapter 5. Application instructions
K200S
NEG FUN(240) NEG FUN(242) DNEG Applicable
K300S
(Sign inverse) FUN(241) NEGP FUN(243) DNEGP CPU
K1000S
NEG(P)
D O O O O* O O O O 1 O
DNEG(P)
D Operand setting
NEGP
DNEGP
* Available only when do not use computer link module or data link module
1) Functions
NEG(P) : Reverses the sign of the 16 bits data of device specified as [ D ] and stores the result in
the device specified as [ D ].
DNEG(P) : Reversees the sign of the 32 bits data of device specified as [ D+1, D ] and stores the
result in the device specified as [ D+1, D ].
Used to reverse the positive sign to the negative sign or vice versa.
D 16bits
Before execution 0 0 1 1 1 0 1 16
0 bits1 1 0 1 0 0 1 1 h3AD3
= 15059
Sign inversion 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
(2’s complement)
– 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1
D
After execution 1 1 0 0 0 1 0 1 0 0 1 0 1 1 0 1 hC52D
= –15059
5-126
Chapter 5. Application instructions
Execution conditions
Input condition
NEGP, DNEGP
Executed only once Executed only once
2) Program example
Program that get an absolute value of D0000 when the value of D0000 is negative.
M001A
NEG D0020
D0000 1 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 -23739
D0000 0 1 0 1 1 1 0 0 1 0 1 1 1 0 1 1 23739
5-127
Chapter 5. Application instructions
K200S
BLD FUN(248) BLD Applicable
K300S
(Bit load) FUN(249) BLDN CPU
K1000S
BLD D O O
5 O
BLDN n O
Operand setting
B D n The start address of source
D data
Offset from the bit 0 to the
BN D n n
destination bit
1) Functions
BLD : Start a NO contact. Draw the on/off status of the nth bit from the bit 0 of [ D ] and use the data
as an operation result.
BLDN : Start a NC contact. Draw the on/off status of the nth bit from the bit 0 of [ D ] and use the
data as an operation result.
1 0 1 1 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1
D +1 D
2) Program example
Program that turns P01E on when the 5th bit of the D0001 word is on.
M000A
MOV h0010 D0001
5-128
Chapter 5. Application instructions
K200S
BAND FUN(250) BAND Applicable
K300S
(Bit AND) FUN(251) BANDN CPU
K1000S
BAND D O O
5 O
BANDN n O
Operand setting
B D n The start address of source
D data
Offset from the bit 0 to the
BN D n n
destination bit
1) Functions
BAND : A series connection of a NO contact. Reads the on/off status of the nth bit from the bit 0 of
[ D ] and performs the AND operation with previous result, and use it as an new operation result.
BANDN : A series connection of a NC contact. Reads the on/off status of the nth bit from the bit 0 of
[ D ] and performs the AND operation with previous result, and use it as an new operation result..
1 0 1 1 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1
D +1 D
2) Program example
Program that turns on P001A and P001B according to the status of bit 1 and bit 8 of the D0003
word.
M0000
MOV h0F0F D0003 Result (M0001=1)
M0000
MOV hF0F0 D0003 M0000 P001A P001B
M0001
B D0003 00001 ( P001A ) 0 0 1
5-129
Chapter 5. Application instructions
K200S
BOR FUN(252) BOR Applicable
K300S
(Bit OR) FUN(253) BORN CPU
K1000S
BOR D O O
5 O
BORN n O
Operand setting
B D n The start address of source
D data
Offset from the bit 0 to the
BN D n n
destination bit
1) Functions
BOR : A parallel connection of a NO contact. Reads the on/off status of the nth bit from the bit 0 of
[ D ] and performs the OR operation with previous result, and use it as an new operation result.
BORN : A parallel connection of a NC contact. Reads the on/off status of the nth bit from the bit 0 of
[ D ] and performs the OR operation with previous result, and use it as an new operation result.
2) Program example
Program that turns on P0010 and P0011 according to the on/off status of bit 1 and bit 8 of the
D0000 word.
M0000
MOV hFF00 D0000
M0001
( P0010 )
B D0000 0001
M0001
( P0011 )
BN D0000 0008
5-130
Chapter 5. Application instructions
5.20.4 BOUT
K200S
BOUT Applicable
FUN(236) BOUT K300S
(Bit output) CPU
K1000S
Operand setting
BOUT D n The start address of source
D data
Offset from the bit 0 to the
n
destination bit
1) Function
Outputs the current operation result to the the nth bit from the bit 0 of [ D ].
2) Program example
M0002
BOUT D0001 7
5-131
Chapter 5. Application instructions
K200S
BSET / BRST FUN(232) BSET Applicable
K300S
(Bit set / reset) FUN(224) BRST CPU
K1000S
BSET D O O
5 O
BRST n O
Operand setting
BSET D n The start address of source
D data
Offset from the bit 0 to the
BRST D n n
destination bit
1) Functions
BSET : When the input condition of BSET instruction turns on, the nth bit from the bit 0 of [ D ] is
switched on. The bit remains on state even if the input condition of BSET instruction is turned off. It
BRST : When the input condition of BRST instruction turns on, the nth bit from the bit 0 of [ D ] is
switched off.
2) Program example
Program that set the bit 2 of D0001 when M0002 is on, and reset the bit 2 of D0001 when M0003 is
on.
M0002
BSET D0001 2
M0003
BSET D0001 2
M0002
M0003
Bit 2 of
D0001
5-132
Chapter 5. Application instructions
5.21.1 SND
SND K200S
Applicable
(Send data and frame name to FUN(169) SND K300S
CPU
Cnet module) K1000S
sl O
Fnam O O O O O O O
SND S O O O O O O O 11 O
n O O
SS O O O O O O O
Operand setting
SND sl Fnam S n SS Slot number of Cnet module is
sl mounted & Type of channel
The configuration of ‘sl’ (RS232C or RS422)
Lower 8 bits (CD) : Slot No. of Cnet Fnam The name of frame (8 words)
AB CD
module Start address of device that
Higher 8 bits (AB) : Type of channel S
stores source data to be sent
h00 : RS232C Numbers of byte to be sent
n
h01 : RS422
Device at which the link status is
SS stored
1) Functions
Sends ‘n’ bytes which begin with the device specified as [ S ] to the Cnet module that mounted on
the slot ‘sl’. The name of frame is stored as ASCII format into 8 words which begin with the device
2) Program example
Program that send 10 words from D1234 and frame name (8 words from D0000) to the Cnet
module at slot 3, channel 0 (RS232C). The link status is stored at K015 word.
5-133
Chapter 5. Application instructions
5.21.2 RCV
RCV K200S
Applicable
(Receive data and frame name FUN(168) RCV K300S
CPU
from Cnet module) K1000S
sl O
Fnam O O O O O O O
RCV D O O O O O O O 11 O
n O O
SS O O O O O O O
Operand setting
RCV sl Fnam D n SS Slot number of Cnet module is
sl mounted & Type of channel
The configuration of ‘sl’ (RS232C or RS422)
Lower 8 bits (CD) : Slot No. of Cnet Fnam The name of frame (8 words)
AB CD
module Start address of device that
D
Higher 8 bits (AB) : Type of channel stores source data to be sent
h00 : RS232C n Numbers of byte to be read
h01 : RS422
Device at which the link status is
SS stored
1) Functions
Receives ‘n’ bytes and frame name from the Cnet module that mounted on the slot ‘sl’, then stores
the data from the device specified as [ D ], and frame name as ASCII format into 8 words which
begin with the device [ Fnam ]. The link status is stored at the device specified as [ SS ].
2) Program example
Program that receive 20 words and frame name from Cnet module at slot 5, channel 1 (RS232C),
and stores them to the block which begin with D0200 and D0100. The link status is stored at K016
word.
5-134
Chapter 5. Application instructions
5.22.1 HSCNT
HSCNT
Applicable K10S1 / K10S
(Enable high FUN(210) HSCNT
CPU K30S / K60S
speed counter)
HSCNT 1
HSCNT
1) Functions
Enable a high speed counter when the input condition turns on.
After the high speed counter is enabled, it operates according to the parameter setting.
When the input condition is switched off, the high speed counter is reset.
The HSCNT instruction can not be used with HSC instruction in a sequence program
simultaneously.
Items Contents
5-135
Chapter 5. Application instructions
2) Program example
Program that output the high speed counter output to P002 word.
HSCNT
a) When the input condition turns on, the current value is stored to F14 and setting value of step
0 is stored to F15.
b) When the current value reaches to setting value #0, F070 ~ F077 is set / reset according to
c) When the current value reaches to the setting value of last step ( step 5 at the this example ),
F15 is updated as setting value of step 0 and current value (F14) is cleared as 0.
d) If the input condition turns off, current value and HSC output (F070 ~ F077) is cleared as 0.
5-136
Chapter 5. Application instructions
5.22.2 HSC
HSC
Applicable K10S1 / K10S
(High speed FUN(215) HSC
CPU K30S / K60S
counter)
PV O O O O O O O O O O
HSC 7/9/11
SV O O O O O O O O O O
Operand setting
HSC PV Preset value
EN
PV < > SV Setting value
U/D
SV < >
PR
1) Functions
HSC instruction can not be used with HSCNT instruction in a program. Only one of them can be
used in a sequence program.
b) U/D : operates as up counter when U/D is 0, and down counter when U/D is 1.
c) PR : If the PR input turns on, the current value is changed as preset value (PV).
5-137
Chapter 5. Application instructions
2) Program example
M003
MOV 100 D010
HSC
M001
EN
PV D010
M002
U/D
M003 SV 100
PR
5-138
Chapter 5. Application instructions
5.23.1 RECV
St O O O O O O O O O O
D O O O O O O O O O
RECV 9 O
S O O O O O O O
n O O O O O O O O O O
Operand setting
Station number of slave station to
St be read
RECV St D S n The start address of device of
D master station at which the
received data is stored
Start address of device of slave
S station that stores source data to
be sent
Numbers of word to be read
n
(n : h00 ~ h1F )
1) Functions
Read ‘n’ words from the device specified as [ S ] of slave station (Station number = ‘st’), and stores
the read data into the block which begin with the device specified as [ D ] of master station.
RECV instruction can be used with master station (station number = h1F) only.
Execution condition
Input condition
5-139
Chapter 5. Application instructions
2) Program example
Program that read 5 words from M010 of the slave station (station number = h1A), and stores the
data to D0000 ~ D0004 of the master station while the M0000 turns on.
M0000
RECV h1A D0000 M010 h05
D0000
M010
5 words 5 words
5-140
Chapter 5. Application instructions
5.23.2 SEND
St O O O O O O O O O O
S O O O O O O O O O
SEND 9 O
D O O O O O O O
n O O O O O O O O O O
Operand setting
Station number of slave station to
St which data to be written
SEND St S D n The start address of device of
S master station at which the
source data is stored
Start address of device of slave
D station at which the sent data is
stored
Numbers of word to be read
n
(n : h00 ~ h1F )
1) Functions
Sends ‘n’ words from the device specified as [ S ] of master station, and stores the read data into
the block which begin with the device specified as [ D ] of slave station (Station number = ‘st’)
SEND instruction can be used with master station (station number = h1F) only.
Execution condition
Input condition
5-141
Chapter 5. Application instructions
2) Program example
Program that send 5 words from D0010 of the master station, and stores the data to M0000 ~
M0004 of the slave station (station number = h0A) while the M0000 turns on.
M0000
SEND h0A D0010 M000 h05
D0010 M000
5 words
5 words
5-142
Appendix
Appendix
The bit memory device is the memory area that can be read / write by bit. The P, M, L, K, F areas are bit
memory devices. However, the bit memory device can be used as word device area.
F E D C B A 9 8 7 6 5 4 3 2 1 0
000
001
002
003
nnn
= P002B
A-1
Appendix
The timer and counter memory area consist of 3 parts - the output bit, current value word, and setting
value word. When the T or C device is used as a operand of bit instruction, the instruction takes effect to
the output bit of timer or counter. If the T or C device is used as an operand of word instruction, the current
value word is effected by the instruction. The setting value can not be changed by user.
The D device used by word. Therefore, the D device can not be used as an operand of bit instruction such
as LOAD, OUT, etc. To control the D device by bit, use special instructions such as BLD, BAND, BOR, etc.
F E D C B A 9 8 7 6 5 4 3 2 1 0
D0000
D0001
D0002
D0003
Dnnnn
= D0002
A-2
Appendix
1) F device
F03A RTC data error flag Set when an error is detected in RTC data
F040
Set in case of attachment/detachment of I/O unit
I/O combination error
During operation, or improper connection
F045
! h0000:No error ! h0023:Code error
F050
! h0014:I/O error ! h0024:Missing END error
Error code
! h0021:Parameter error
F05F ! h0025:Missing RET error
! The step No. where program error occurred is
F060
The step No. Where stored
error occurred ! In case of branch instruction error,
F06F the destination step No. is stored.
F070
HSC register High speed counter area
F077
! K10S:h0031
F080 ! K60S:h0036
Upper byte:PLC station No.
PLC model ! K30S:h0033
Lower byte:PLC model
F08F !
K100S:h0035
A-3
Appendix
F110 Arithmetic error flag Set when an arithmetic error occurred during operation
F111 Zero flag Set when the result value is zero
Set when Carry or Borrow occurs as a result of
F112 Carry flag
operation
F11A On sending flag
F11C On receiving flag These relays indicate the communication status
Receive completion When DIN, DOUT instruction are used.
F11E
Flag
! DIN, DOUT:Set when time-out error occurred
Communication
F11F ! SEND, RECV:Set when time-out error occurs or
error flag
NAK massage is detected.
F120
F121
These relays are set according to the result of
F122 =
Compare instructions
F123 >
(CMP, CMPP, DCMP, DCMPP)
F124
F125
F130
Each relays show whether relevant I/O modules
~ I/O status
Are attached or not.
F135
F140 HSCNT : The present value of high speed counter is stored.
~ HSC present value HSC : The low word of present value of high speed counter is
F14F stored.
F150 HSCNT : The preset value of high speed counter is stored.
~ HSC preset value HSC : The high word of present value of high speed counter is
F15F stored.
A-4
Appendix
A-5
Appendix
1) F relay
Contact Keyword Function Description
F0000 RUN mode Turns on when the CPU in the RUN mode.
F0001 Program mode Turns on when the CPU in the Program mode
F0002 Pause mode Turns on when the CPU in the Pause mode
F0003 Debug mode Turns on when the CPU in the Debug mode
F0006 Remote mode Turns on when the CPU in the Remote mode
F0007 User memory Turns on when a user memory is installed.
installation
F0008 and Unused
F0009
F000A User memory Turns on when a user memory is being
operation operated
F000B to F000E Unused
F000F p_STOP Execution of the Turns on when the STOP instruction is being
STOP instruction operated.
F0010 p _ON Always On Always On
F0011 p_OFF Always Off Always Off
F0012 p_1ON 1 Scan On 1 Scan On
F0013 p_1OFF 1 Scan Off 1 Scan Off
F0014 p_STOG Scan toggle Scan toggle
F0015 to F001F Unused
F0020 1 step run Turns on when the 1 step run is operated in
the Debug mode.
F0021 Breakpoint run Turns on when the breakpoint run is operated
in the Debug mode.
F0022 Scan run Turns on when the scan run is operated in the
Debug mode.
F0023 Coincident junction Turns on when the coincident junction run is
value run operated in the Debug mode.
F0024 Coincident word Turns on when the coincident word run is
value run operated in the Debug mode.
F0025 to F002F Unused
F0030 s_HEAVY_ER Fatal error Turns on when a fatal error has occurred.
F0031 s_LIGHT_ER Ordinary error Turns on when an ordinary error has occurred.
F0032 s_WD_ER WDT Error Turns on when a watch dog timer error has
occurred.
F0033 s_IO_TYER I/O combination Turns on when an I/O error has occurred.
error (When one or more bit(s) of F0040 to F005F
turns on)
F0034 s_BAT_ER Battery voltage Turns on when the battery voltage has fallen
error below the defined value.
F0035 s_FUSE_ER Fuse error Turns on when a fuse of output modules has
been disconnected.
F0036 to F0038 Unused
F0039 s_D_BCK_OK Normal backup Turns on when the data backup is normal.
operation
F003A s_RTC_ER RTC data error Turns on when the RTC data setting error has
occurred.
F003B During program Turns on during program edit while running
edit the program.
F003C Program edit error Turns on when a program edit error has
occurred while running the program.
F003D to F003F Unused
A-6
Appendix
A-7
Appendix
A-8
Appendix
A-9
Appendix
A-10
Appendix
A-11
Appendix
Function
0 1 2 3 4 5 6 7 8 9
No.
00x NOP END STC CLC RET MPUSH MLOAD MPOP STOP CLE
02x INC INCP DINC DINCP DEC DECP DDEC DDECP LD= ! LDD= !
03x ROL ROLP DROL DROLP ROR RORP DRDR DRDRP LD> ! LDD> !
04x RCL CMPP DRCL DRCLP RCR RCRP DRCR DRCRP LD< ! LDD< !
05x CMP BCDP DCMP DCMPPP TCMP TCMPP DTCMP DTCMPP LD>= ! LDD>= !
06x BCD WSFTP DBCD DBCDP BIN BINP DBIN DBINP LD<= ! LDD<= !
07x WSFT MOVP MULS ! MULSP ! BSFT BSFTP DMULS ! DMULSP! LD<> ! LDD<> !
08x MOV GMOVP DMOV DMOVP CMOV CMOVP DCMOV DCMOV DIVS ! DIVSP !
09x GMOV BMOVP FOMV FOMVP AND= ! ANDD= ! AND> ! ANDD> ! AND< ! ANDD<!
10X BMOV ADDP XCHG XCHGP DXCHG DXCHGP AND>= ! ANDD>=! ANDD>=! ANDD>=!
11X ADD ADDP DADD DADDP SUB SUBP DSUB DSUBP AND<> ! ANDD<>!
12X MUL MULP DMUL DMULP DIV DIVP DDIV DDIVP DDIVS DDIVSP
16X WXOR WXORP DWXOR DWXOR WXNR WXNRP DWXNR DWXNR RCV ! SND !
17X BSUM BSUMP DBUSM DBUSMP SEG SEGP ENCO ENCOP DECO DECOP
18X BSUM FILRP DFILR DFILRP FILW FILWP DFILW DFILWP OR= ! ORD= !
19X ASC ASCP UNI DSI DIS DISP OR> ! ORD> ! OR< ! ORD< !
20X IORF ! IORFP ! WDT ! WDTP ! FALS ! DUTY FOR ! NEXT ! OUTOFF .
24X NEG ! NEGP ! DNEG ! DNEGP ! READ ! WRITE ! CONN ! STATUS ! BLD ! BLDN !
A-12