Omron PLC Manual
Omron PLC Manual
Omron PLC Manual
W483-E1-04
SYSMAC CP Series
CP1E-E@@D@-@
CP1E-N@@D@-@
CP1E-NA@@D@-@
INSTRUCTIONS
REFERENCE MANUAL
OMRON, 2009
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or
by any means, mechanical, electronic, photocopying, recording, or otherwise, without the prior written permission of
OMRON.
No patent liability is assumed with respect to the use of the information contained herein. Moreover, because OMRON is constantly striving to improve its high-quality products, the information contained in this manual is subject to change without
notice. Every precaution has been taken in the preparation of this manual. Nevertheless, OMRON assumes no responsibility
for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained in
this publication.
SYSMAC CP Series
CP1E-E@@D@-@
CP1E-N@@D@-@
CP1E-NA@@D@-@
CP1E CPU Unit
Instructions Reference Manual
Revised June 2010
Introduction
Thank you for purchasing a SYSMAC CP-series CP1E Programmable Controller.
This manual contains information required to use the CP1E. Read this manual completely and be sure
you understand the contents before attempting to use the CP1E.
Intended Audience
This manual is intended for the following personnel, who must also have knowledge of electrical systems (an electrical engineer or the equivalent).
Personnel in charge of installing FA systems
Personnel in charge of designing FA systems
Personnel in charge of managing FA systems and facilities
Applicable Products
CP-series CP1E CPU Units
Basic Models CP1E-ED-
A basic model of CPU Unit that support basic control applications using instructions such as
basic, movement, arithmetic, and comparison instructions.
Application Models CP1E-N/NAD-
An application model of CPU Unit that supports connections to Programmable Terminals, inverters, and servo drives.
The CP Series is centered around the CP1H, CP1L, and CP1E CPU Units and is designed with the
same basic architecture as the CS and CJ Series.
Always use CP-series Expansion Units and CP-series Expansion I/O Units when expanding I/O
capacity. I/O words are allocated in the same way as for the CPM1A/CPM2A PLCs, i.e., using fixed
areas for inputs and outputs.
This Manual
CP1E CPU Unit Hardware
Users Manual(Cat. No. W479)
Mounting and
1 Setting Hardware
Names and specifications of the parts of all Units
Basic system configuration for each CPU Unit
Connection methods for Expansion I/O Units
and Expansion Units
2 Wiring
Wiring methods for the power supply
Wiring methods between external I/O devices
and Expansion I/O Units or Expansion Units
Connecting
4 Software Setup
Software setting methods for the CPU
Units (PLC Setup)
Detailed information on
programming instructions
Checking and
6 Debugging Operation
Maintenance and
7 Troubleshooting
Manual Configuration
The CP1E CPU manuals are organized in the sections listed in the following tables. Refer to the appropriate section in the manuals as required.
Contents
Section 2 Instruction
This section provides the execution times for all instructions used with a
CP1E CPU Unit.
This section describes how to monitor and calculate the cycle time of a
CP1E CPU Unit that can be used in the programs.
Appendices
Contents
Section 1 Overview
This section describes the types of I/O memory areas in a CP1E CPU
Unit and the details.
This section describes the PLC Setup, which are used to perform basic
settings for a CP1E CPU Unit.
This section lists the built-in functions and describes the overall application flow and the allocation of the functions.
Section 10 Interrupts
This section describes the interrupts that can be used with CP1E PLCs,
including input interrupts and scheduled interrupts.
Section
Contents
This section describes the built-in analog function for NA-type CPU
Units.
Appendices
Contents
This section gives an overview of the CP1E, describes its features, and
provides its specifications.
This section describes the basic system configuration and unit models
of the CP1E.
Section 3 Part Names and Functions This section describes the part names and functions of the CPU Unit,
Expansion I/O Units, and Expansion Units in a CP1E PLC .
This section describes the features of the CX-Programmer used for programming and debugging PLCs, as well as how to connect the PLC with
the Programming Device by USB.
Section 6 Troubleshooting
This section describes periodic inspections, the service life of the Battery, and how to replace the Battery.
Appendices
Manual Structure
Page Structure and Icons
The following page structure and icons are used in this manual.
Installation
Level 1 heading
Level 2 heading
Level 3 heading
Installation Location
Level 2 heading
Level 3 heading
5-2
5-2-1
Use a screwdriver to pull down the DIN Track mounting pins from the back of the Units to release
them, and mount the Units to the DIN Track.
Indicates a step in a
procedure.
DIN Track mounting pins
Fit the back of the Units onto the DIN Track by catching the top of the Units on the Track and then
pressing in at the bottom of the Units, as shown below.
DIN Track
Release
5-2 Installation
Step in a procedure
Page tab
Gives the number
of the section.
Press in all of the DIN Track mounting pins to securely lock the Units in place.
Special Information
(See below.)
Icons are used to indicate
precautions and
additional information.
Manual name
5-3
This illustration is provided only as a sample and may not literally appear in this manual.
Special Information
Special information in this manual is classified as follows:
Description
A basic model of CPU Unit that support basic control applications using instructions such
as basic, movement, arithmetic, and comparison instructions.
Basic models of CPU Units are called E-type CPU Units in this manual.
An application model of CPU Unit that supports built-in analog and connections to Programmable Terminals, inverters, and servo drives.
Application models of CPU Units with built-in analog are called NA-type CPU Units in
this manual.
CX-Programmer
1
2
Summary of Instructions
3
Instructions
4
Appendices
CONTENTS
Introduction ............................................................................................................... 1
CP1E CPU Unit Manuals ...........................................................................................2
Manual Structure ....................................................................................................... 5
Safety Precautions .................................................................................................. 15
Precautions for Safe Use ........................................................................................ 18
Regulations and Standards.................................................................................... 19
Related Manuals ...................................................................................................... 20
Section 1
1-1
Section 2
10
Section 3
3-1
Section 4
4-1
4-2
Section A
Appendices ....................................................................A-1
11
LIMITATIONS OF LIABILITY
OMRON SHALL NOT BE RESPONSIBLE FOR SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES,
LOSS OF PROFITS OR COMMERCIAL LOSS IN ANY WAY CONNECTED WITH THE PRODUCTS,
WHETHER SUCH CLAIM IS BASED ON CONTRACT, WARRANTY, NEGLIGENCE, OR STRICT
LIABILITY.
In no event shall the responsibility of OMRON for any act exceed the individual price of the product on which
liability is asserted.
IN NO EVENT SHALL OMRON BE RESPONSIBLE FOR WARRANTY, REPAIR, OR OTHER CLAIMS
REGARDING THE PRODUCTS UNLESS OMRONS ANALYSIS CONFIRMS THAT THE PRODUCTS
WERE PROPERLY HANDLED, STORED, INSTALLED, AND MAINTAINED AND NOT SUBJECT TO
CONTAMINATION, ABUSE, MISUSE, OR INAPPROPRIATE MODIFICATION OR REPAIR.
12
Application Considerations
SUITABILITY FOR USE
OMRON shall not be responsible for conformity with any standards, codes, or regulations that apply to the
combination of products in the customers application or use of the products.
At the customers request, OMRON will provide applicable third party certification documents identifying
ratings and limitations of use that apply to the products. This information by itself is not sufficient for a
complete determination of the suitability of the products in combination with the end product, machine,
system, or other application or use.
The following are some examples of applications for which particular attention must be given. This is not
intended to be an exhaustive list of all possible uses of the products, nor is it intended to imply that the uses
listed may be suitable for the products:
Outdoor use, uses involving potential chemical contamination or electrical interference, or conditions or
uses not described in this manual.
Nuclear energy control systems, combustion systems, railroad systems, aviation systems, medical
equipment, amusement machines, vehicles, safety equipment, and installations subject to separate
industry or government regulations.
Systems, machines, and equipment that could present a risk to life or property.
Please know and observe all prohibitions of use applicable to the products.
NEVER USE THE PRODUCTS FOR AN APPLICATION INVOLVING SERIOUS RISK TO LIFE OR
PROPERTY WITHOUT ENSURING THAT THE SYSTEM AS A WHOLE HAS BEEN DESIGNED TO
ADDRESS THE RISKS, AND THAT THE OMRON PRODUCTS ARE PROPERLY RATED AND INSTALLED
FOR THE INTENDED USE WITHIN THE OVERALL EQUIPMENT OR SYSTEM.
PROGRAMMABLE PRODUCTS
OMRON shall not be responsible for the users programming of a programmable product, or any
consequence thereof.
13
Disclaimers
CHANGE IN SPECIFICATIONS
Product specifications and accessories may be changed at any time based on improvements and other
reasons.
It is our practice to change model numbers when published ratings or features are changed, or when
significant construction changes are made. However, some specifications of the products may be changed
without any notice. When in doubt, special model numbers may be assigned to fix or establish key
specifications for your application on your request. Please consult with your OMRON representative at any
time to confirm actual specifications of purchased products.
PERFORMANCE DATA
Performance data given in this manual is provided as a guide for the user in determining suitability and does
not constitute a warranty. It may represent the result of OMRONs test conditions, and the users must
correlate it to actual application requirements. Actual performance is subject to the OMRON Warranty and
Limitations of Liability.
14
Safety Precautions
Definition of Precautionary Information
The following notation is used in this manual to provide precautions required to ensure safe usage of a
CP-series PLC. The safety precautions that are provided are extremely important to safety. Always read
and heed the information provided in all safety precautions.
WARNING
Caution
Symbols
The triangle symbol indicates precautions (including
warnings). The specific operation is shown in the triangle
and explained in text. This example indicates a precaution for electric shock.
15
Caution
Be sure to sufficiently confirm the safety at the destination when you transfer
the program or I/O memory or perform procedures to change the I/O memory.
Devices connected to PLC outputs may incorrectly operate regardless of the operating mode of the CPU Unit.
With an E-type CPU Unit or with an N/NA-type CPU Unit without a Battery, the contents of the DM Area (D) *, Holding Area (H), the Counter Present Values (C), the status of Counter Completion Flags (C), and the status of bits in the Auxiliary Area (A)
related to clock functions may be unstable when the power supply is turned ON.
*This does not apply to areas backed up to EEPROM using the DM backup function.
If the DM backup function is being used, be sure to use one of the following methods
for initialization.
1. Clearing All Areas to All Zeros
Select the Clear Held Memory (HR/DM/CNT) to Zero Check Box in the Startup
Data Read Area in the PLC Setup.
2. Clearing Specific Areas to All Zeros or Initializing to Specific Values
Make the settings from a ladder program.
If the data is not initialized, the unit or device may operate unexpectedly because of
unstable data.
Execute online edit only after confirming that no adverse effects will be caused
by extending the cycle time.
Otherwise, the input signals may not be readable.
The DM Area (D), Holding Area (H), Counter Completion Flags (C), and Counter
Present Values (C) will be held by the Battery if a Battery is mounted in a CP1EN/NAD- CPU Unit. When the battery voltage is low, however, I/O memory
areas that are held (including the DM, Holding, and Counter Areas) will be unstable.
The unit or device may operate unexpectedly because of unstable data.
Use the Battery Error Flag or other measures to stop outputs if external outputs are performed from a ladder program based on the contents of the DM
Area or other I/O memory areas.
Sufficiently check safety if I/O bit status or present values are monitored in the
Ladder Section Pane or present values are monitored in the Watch Pane.
If bits are set, reset, force-set, or force-reset by inadvertently pressing a shortcut key,
devices connected to PLC outputs may operate incorrectly regardless of the operating mode.
16
Caution
Program so that the memory area of the start address is not exceeded when
using a word address or symbol for the offset.
For example, write the program so that processing is executed only when the indirect
specification does not cause the final address to exceed the memory area by using
an input comparison instruction or other instruction.
If an indirect specification causes the address to exceed the area of the start address,
the system will access data in other area, and unexpected operation may occur.
Set the temperature range according to the type of temperature sensor connected to the Unit.
Temperature data will not be converted correctly if the temperature range does not
match the sensor.
Do not set the temperature range to any values other than those for which temperature ranges are given in the following table.
An incorrect setting may cause operating errors.
17
Handling
To initialize the DM Area, back up the initial contents for the DM Area to backup memory using
one of the following methods.
Set the number of words of the DM Area to be backed up starting with D0 in the Number of
CH of DM for backup Box in the Startup Data Read Area.
Include programming to back up specified words in the DM Area to built-in EEPROM by turning ON A751.15 (DM Backup Save Start Bit).
Check the ladder program for proper execution before actually running it on the Unit. Not checking
the program may result in an unexpected operation.
The ladder program and parameter area data in the CP1E CPU Units are backed up in the built-in
EEPROM backup memory. The BKUP indicator will light on the front of the CPU Unit when the
backup operation is in progress. Do not turn OFF the power supply to the CPU Unit when the
BKUP indicator is lit. The data will not be backed up if power is turned OFF and a memory error
will occur the next time the power supply is turned ON.
With a CP1E CPU Unit, data memory can be backed up to the built-in EEPROM backup memory.
The BKUP indicator will light on the front of the CPU Unit when backup is in progress. Do not turn
OFF the power supply to the CPU Unit when the BKUP indicator is lit. If the power is turned OFF
during a backup, the data will not be backed up and will not be transferred to the DM Area in RAM
the next time the power supply is turned ON.
Before replacing the battery, supply power to the CPU Unit for at least 30 minutes and then complete battery replacement within 5 minutes. Memory data may be corrupted if this precaution is
not observed.
The equipment may operate unexpectedly if inappropriate parameters are set. Even if the appropriate parameters are set, confirm that equipment will not be adversely affected before transferring the parameters to the CPU Unit.
Before starting operation, confirm that the contents of the DM Area is correct.
After replacing the CPU Unit, make sure that the required data for the DM Area, Holding Area, and
other memory areas has been transferred to the new CPU Unit before restarting operation.
Do not attempt to disassemble, repair, or modify any Units. Any attempt to do so may result in malfunction, fire, or electric shock.
Confirm that no adverse effect will occur in the system before attempting any of the following. Not
doing so may result in an unexpected operation.
Changing the operating mode of the PLC (including the setting of the startup operating mode).
Force-setting/force-resetting any bit in memory.
Changing the present value of any word or any set value in memory.
External Circuits
Always configure the external circuits to turn ON power to the PLC before turning ON power to the
control system. If the PLC power supply is turned ON after the control power supply, temporary
errors may result in control system signals because the output terminals on DC Output Units and
other Units will momentarily turn ON when power is turned ON to the PLC.
Fail-safe measures must be taken by the customer to ensure safety in the event that outputs from
output terminals remain ON as a result of internal circuit failures, which can occur in relays, transistors, and other elements.
If the I/O Hold Bit is turned ON, the outputs from the PLC will not be turned OFF and will maintain
their previous status when the PLC is switched from RUN or MONITOR mode to PROGRAM mode.
Make sure that the external loads will not produce dangerous conditions when this occurs. (When
operation stops for a fatal error, including those produced with the FALS instruction, all outputs from
PLC will be turned OFF and only the internal output status in the CPU Unit will be maintained.)
18
19
Related Manuals
The following manuals are related to the CP1E. Use them together with this manual.
Manual name
Cat. No.
SYSMAC CP Series
CP1E CPU Unit Instructions Reference Manual
(this manual)
W483
SYSMAC CP Series
CP1E CPU Unit Software Users Manual
W480
Model numbers
CP1E-ED-
CP1E-ND-
CP1E-NAD-
CP1E-ED-
CP1E-ND-
CP1E-NAD-
Application
Contents
Use this manual together with the CP1E CPU Unit Hardware Users
Manual (Cat. No. W479) and Instructions Reference Manual (Cat. No.
W483).
SYSMAC CP Series
CP1E CPU Unit Hardware Users Manual
W479
CP1E-ED-
CP1E-ND-
CP1E-NAD-
Use this manual together with the CP1E CPU Unit Software Users
Manual (Cat. No. W480) and Instructions Reference Manual (Cat. No.
W483).
CS/CJ/CP/NSJ Series
Communications Commands Reference Manual
W342
CS1G/H-CPUH
CS1G/H-CPU-V1
CS1D-CPUH
CS1D-CPUS
CS1W-SCU-V1
CS1W-SCB-V1
CJ1G/H-CPUH
CJ1G-CPUP
CJ1M-CPU
Describes
1) C-mode commands and
2) FINS commands in detail.
Read this manual for details on C-mode and
FINS commands addressed to CPU Units.
CJ1G-CPU
CJ1W-SCU-V1
SYSMAC CP Series
CP1L/CP1E CPU Unit
Introduction Manual
W461
CP1L-L10D-
CP1L-L14D-
CP1L-L20D-
CP1L-M30D-
CP1L-M40D-
CP1L-M60D-
CP1E-ED-
CP1E-ND-
CP1E-NAD-
20
Summary of Instructions
This section provides a summary of instructions used with a CP1E CPU Unit.
1-1
1 Summary of Instructions
1-1
Summary of Instructions
There are 200 types of instructions can be used by CP1E.
The following table lists the instructions by function. Refer to the reference pages for the
detail of each instruction.
Instrucion
Type
Sequence
Input Instructions
Instruction
LOAD
FUN
No.
Function
Page
2-7
2-7
Takes a logical AND of the status of the specified operand bit and the current
execution condition.
2-9
Reverses the status of the specified operand bit and takes a logical AND with
the current execution condition.
2-9
Takes a logical OR of the ON/OFF status of the specified operand bit and the
current execution condition.
2-11
Reverses the status of the specified bit and takes a logical OR with the current
execution condition.
2-11
LD
@LD
%LD
!LD
!@LD
!%LD
LD NOT
@LD NOT
%LD NOT
!LD NOT
!@LD NOT
!%LD NOT
AND
@AND
%AND
!AND
!@AND
!%AND
AND NOT
@AND NOT
%AND NOT
!AND NOT
!@AND NOT
!%AND NOT
OR
@OR
%OR
!OR
!@OR
!%OR
OR NOT
@OR NOT
%OR NOT
!OR NOT
!@OR NOT
!%OR NOT
AND LOAD
AND LD
2-13
OR LOAD
OR LD
2-13
LOAD NOT
AND
AND NOT
OR
OR NOT
1-2
Mnemonic
NOT
NOT
520
2-16
CONDITION ON
UP
521
UP(521) turns ON the execution condition for one cycle when the execution
condition goes from OFF to ON.
2-17
CONDITION OFF
DOWN
522
DOWN(522) turns ON the execution condition for one cycle when the execution
condition goes from ON to OFF.
2-17
1 Summary of Instructions
Sequence
Output
Instructions
Instruction
OUTPUT
Mnemonic
FUN
No.
OUT
!OUT
OUT NOT
!OUT NOT
TR Bits
TR
KEEP
KEEP
OUTPUT NOT
Function
Instrucion
Type
Page
Outputs the result (execution condition) of the logical processing to the specified bit.
2-18
Reverses the result (execution condition) of the logical processing, and outputs
it to the specified bit.
2-18
TR bits are used to temporarily retain the ON/OFF status of execution conditions in a program when programming in mnemonic code.
2-20
011
2-21
013
DIFU(013) turns the designated bit ON for one cycle when the execution condition goes from OFF to ON (rising edge).
2-25
014
DIFD(014) turns the designated bit ON for one cycle when the execution condition goes from ON to OFF (falling edge).
2-27
SET turns the operand bit ON when the execution condition is ON.
2-29
RSET turns the operand bit OFF when the execution condition is ON.
2-29
530
2-31
531
2-31
532
SETB(532) turns ON the specified bit in the specified word when the execution
condition is ON.
2-33
!KEEP
DIFFERENTIATE
UP
DIFU
DIFFERENTIATE
DOWN
DIFD
SET
RESET
!DIFU
!DIFD
SET
@SET
%SET
!SET
!@SET
!%SET
RSET
@RSET
%RSET
!RSET
!@RSET
!%RSET
MULTIPLE BIT SET
SETA
@SETA
MULTIPLE BIT
RESET
SINGLE BIT SET
RSTA
@RSTA
SETB
@SETB
Unlike the SET instruction, SETB(532) can be used to set a bit in a DM word.
!SETB
!@SETB
SINGLE BIT RESET
RSTB
@RSTB
!RSTB
533
RSTB(533) turns OFF the specified bit in the specified word when the execution condition is ON.
2-33
!@RSTB
1-3
1 Summary of Instructions
Instrucion
Type
Sequence
Control
Instructions
Timer and
Counter
Instructions
Instruction
Mnemonic
Function
Page
END
END
001
2-38
NO OPERATION
NOP
000
2-39
INTERLOCK
IL
002
Interlocks all outputs between IL(002) and ILC(003) when the execution condition for IL(002) is OFF.
2-40
INTERLOCK
CLEAR
ILC
003
All outputs between IL(002) and ILC(003) are interlocked when the execution
condition for IL(002) is OFF.
2-40
MULTI-INTERLOCK
DIFFERENTIATION
HOLD
MILH
517
When the execution condition for MILH(517) is OFF, the outputs for all instructions between that MILH(517) instruction and the next MILC(519) instruction
are interlocked.
2-44
MULTI-INTERLOCK
DIFFERENTIATION
RELEASE
MILR
518
When the execution condition for MILR(518) is OFF, the outputs for all instructions between that MILR(518) instruction and the next MILC(519) instruction
are interlocked.
2-44
MULTI-INTERLOCK
CLEAR
MILC
519
Clears an interlock started by an MILH(517) or MILR(518) with the same interlock number.
2-44
JUMP
JMP
004
When the execution condition for JMP(004) is OFF, program execution jumps
directly to the first JME(005) in the program with the same jump number.
2-53
JUMP END
JME
005
2-53
CONDITIONAL
JUMP
CJP
510
The operation of CJP(510) is the basically the opposite of JMP(004). When the
execution condition for CJP(510) is ON, program execution jumps directly to the
first JME(005) in the program with the same jump number.
2-53
FOR LOOP
FOR
512
2-56
NEXT LOOP
NEXT
513
2-56
BREAK LOOP
BREAK
514
2-59
HUNDRED-MS
TIMER
TIM
2-66
TIMX
550
TEN-MS TIMER
TIMH
015
2-69
TIMHX
551
ONE-MS TIMER
TMHH
540
2-72
TMHHX
552
ACCUMULATIVE
TIMER
TTIM
087
2-74
TTIMX
555
LONG TIMER
TIML
542
2-77
TIMLX
553
CNT/CNTX(546) operates a decrementing counter.
2-80
2-83
2-86
COUNTER
CNT
CNTX
1-4
FUN
No.
546
REVERSIBLE
COUNTER
CNTR
012
CNTRX
548
RESET TIMER/
COUNTER
CNR/
@CNR
545
CNRX/
@CNRX
547
1 Summary of Instructions
Comparison
Instructions
Instruction
Mnemonic
Symbol Comparison
Time Comparison
UNSIGNED
COMPARE
FUN
No.
Function
Page
300
328
Symbol comparison instructions compare two values and create an ON execution condition when the comparison condition is true.
2-88
LD, AND,
OR+=DT
341
Time comparison instructions compare two BCD time values and create an ON
execution condition when the comparison condition is true.
2-91
LD, AND,
OR+<>DT
342
LD, AND,
OR+<DT
343
LD, AND,
OR+<=DT
344
LD, AND,
OR+>DT
345
LD, AND,
OR+>=DT
346
CMP
020
Compares two unsigned binary values (constants and/or the contents of specified words) and outputs the result to the Arithmetic Flags in the Auxiliary Area.
2-95
!CMP
DOUBLE
UNSIGNED
COMPARE
CMPL
060
Compares two double unsigned binary values (constants and/or the contents of
specified words) and outputs the result to the Arithmetic Flags in the Auxiliary
Area.
2-95
SIGNED BINARY
COMPARE
CPS
114
Compares two signed binary values (constants and/or the contents of specified
words) and outputs the result to the Arithmetic Flags in the Auxiliary Area.
2-98
DOUBLE SIGNED
BINARY COMPARE
CPSL
115
Compares two double signed binary values (constants and/or the contents of
specified words) and outputs the result to the Arithmetic Flags in the Auxiliary
Area.
2-98
TABLE COMPARE
TCMP
085
Compares the source data to the contents of 16 words and turns ON the corresponding bit in the result word when the contents are equal.
2-101
068
2-103
!CPS
@TCMP
Instrucion
Type
UNSIGNED BLOCK
COMPARE
BCMP
AREA RANGE
COMPARE
ZCP
088
2-105
DOUBLE AREA
RANGE COMPARE
ZCPL
116
Compares the 32-bit unsigned binary value in CD and CD+1 (word contents or
constant) to the range defined by LL and UL and outputs the results to the
Arithmetic Flags in the Auxiliary Area.
2-105
MOV
021
2-108
MOVE
@BCMP
@MOV
!MOV
!@MOV
DOUBLE MOVE
MOVL/
@MOVL
498
2-108
MOVE NOT
MVN/
@MVN
022
2-108
MOVE BIT
MOVB/
@MOVB
082
2-111
MOVE DIGIT
MOVD/
@MOVD
083
2-113
MULTIPLE BIT
TRANSFER
XFRB/
@XFRB
062
2-115
BLOCK TRANSFER
XFER/
@XFER
070
2-117
BLOCK SET
BSET/
@BSET
071
2-119
DATA EXCHANGE
XCHG/
@XCHG
073
2-121
SINGLE WORD
DISTRIBUTE
DIST/
@DIST
080
2-123
DATA COLLECT
COLL/
@COLL
081
Transfers the source word (calculated by adding an offset value to the base
address) to the destination word.
2-125
1-5
1 Summary of Instructions
Instrucion
Type
Data Shift
Instructions
Increment/
Decrement
Instructions
1-6
Instruction
Mnemonic
FUN
No.
Function
Page
SHIFT REGISTER
SFT
010
2-127
REVERSIBLE
SHIFT REGISTER
SFTR/
@SFTR
084
Creates a shift register that shifts data to either the right or the left.
2-129
WORD SHIFT
WSFT/
@WSFT
016
2-131
ARITHMETIC
SHIFT LEFT
ASL/
@ASL
025
ARITHMETIC
SHIFT RIGHT
ASR/
@ASR
026
2-134
ROTATE LEFT
ROL/
@ROL
027
Shifts all Wd bits one bit to the left including the Carry Flag (CY).
2-135
ROTATE RIGHT
ROR/
@ROR
028
Shifts all Wd bits one bit to the right including the Carry Flag (CY).
2-137
SLD/
@SLD
074
2-139
SRD/
@SRD
075
2-139
NASL/
@NASL
580
Shifts the specified 16 bits of word data to the left by the specified number of
bits.
2-141
DOUBLE SHIFT
N-BITS LEFT
NSLL/
@NSLL
582
Shifts the specified 32 bits of word data to the left by the specified number of
bits.
2-141
SHIFT N-BITS
RIGHT
NASR/
@NASR
581
Shifts the specified 16 bits of word data to the right by the specified number of
bits.
2-144
DOUBLE SHIFT
N-BITS RIGHT
NSRL/
@NSRL
583
Shifts the specified 32 bits of word data to the right by the specified number of
bits.
2-144
INCREMENT
BINARY
++/
@++
590
2-147
++L/
@++L
591
2-147
DECREMENT
BINARY
--/
@--
592
2-150
--L/
@--L
593
2-150
INCREMENT BCD
++B/
@++B
594
2-153
++BL/
@++BL
595
2-153
DECREMENT BCD
--B/
@--B
596
2-156
--BL/
@--BL
597
2-156
2-133
1 Summary of Instructions
Symbol Math
Instructions
Instruction
Mnemonic
FUN
No.
Function
Page
SIGNED BINARY
ADD WITHOUT
CARRY
+/
@+
400
2-158
DOUBLE SIGNED
BINARY ADD
WITHOUT CARRY
+L/
@+L
401
2-158
SIGNED BINARY
ADD WITH CARRY
+C/
@+C
402
Adds 4-digit (single-word) hexadecimal data and/or constants with the Carry
Flag (CY).
2-160
DOUBLE SIGNED
BINARY ADD WITH
CARRY
+CL/
@+CL
403
Adds 8-digit (double-word) hexadecimal data and/or constants with the Carry
Flag (CY).
2-160
BCD ADD
WITHOUT CARRY
+B/
@+B
404
2-162
+BL/
@+BL
405
2-162
+BC/
@+BC
406
Adds 4-digit (single-word) BCD data and/or constants with the Carry Flag (CY).
2-164
+BCL/
@+BCL
407
Adds 8-digit (double-word) BCD data and/or constants with the Carry Flag (CY).
2-164
SIGNED BINARY
SUBTRACT
WITHOUT CARRY
-/
@-
410
2-166
DOUBLE SIGNED
BINARY
SUBTRACT WITHOUT CARRY
-L/
@-L
411
2-166
SIGNED BINARY
SUBTRACT WITH
CARRY
-C/
@-C
412
2-170
DOUBLE SIGNED
BINARY WITH
CARRY
-CL/
@-CL
413
2-170
BCD SUBTRACT
WITHOUT CARRY
-B/
@-B
414
2-172
DOUBLE BCD
SUBTRACT
WITHOUT CARRY
-BL/
@-BL
415
2-172
BCD SUBTRACT
WITH CARRY
-BC/
@-BC
416
Subtracts 4-digit (single-word) BCD data and/or constants with the Carry Flag
(CY).
2-175
DOUBLE BCD
SUBTRACT
WITH CARRY
-BCL/
@-BCL
417
Subtracts 8-digit (double-word) BCD data and/or constants with the Carry Flag
(CY).
2-175
SIGNED BINARY
MULTIPLY
/
@
420
2-177
DOUBLE SIGNED
BINARY MULTIPLY
L/
@L
421
2-177
BCD MULTIPLY
B/
@B
424
2-179
DOUBLE BCD
MULTIPLY
BL/
@BL
425
2-179
SIGNED BINARY
DIVIDE
/
@/
430
2-181
DOUBLE SIGNED
BINARY DIVIDE
/L
@/L
431
2-181
BCD DIVIDE
/B
@/B
434
2-183
DOUBLE BCD
DIVIDE
/BL
@/BL
435
2-183
1-7
Instrucion
Type
1 Summary of Instructions
Instrucion
Type
Conversion
Instructions
Logic Instructions
Special Math
Instructions
1-8
Instruction
Mnemonic
FUN
No.
Function
Page
BCD TO BINARY
BIN/
@BIN
023
2-185
DOUBLE BCD TO
DOUBLE BINARY
BINL/
@BINL
058
2-185
BINARY TO BCD
BCD/
@BCD
024
2-187
DOUBLE BINARY
TO DOUBLE BCD
BCDL/
@BCDL
059
2-187
2S COMPLEMENT
NEG/
@NEG
160
2-189
DATA DECODER
MLPX/
@MLPX
076
Reads the numerical value in the specified digit (or byte) in the source word,
turns ON the corresponding bit in the result word (or 16-word range), and turns
OFF all other bits in the result word (or 16-word range).
2-191
DATA ENCODER
DMPX/
@DMPX
077
FInds the location of the first or last ON bit within the source word (or 16-word
range), and writes that value to the specified digit (or byte) in the result word.
2-196
ASCII CONVERT
ASC/
@ASC
086
Converts 4-bit hexadecimal digits in the source word into their 8-bit ASCII
equivalents.
2-201
ASCII TO HEX
HEX/
@HEX
162
2-205
LOGICAL AND
ANDW/
@ANDW
034
Takes the logical AND of corresponding bits in single words of word data and/or
constants.
2-210
DOUBLE LOGICAL
AND
ANDL/
@ANDL
610
Takes the logical AND of corresponding bits in double words of word data
and/or constants.
2-210
LOGICAL OR
ORW/
@ORW
035
Takes the logical OR of corresponding bits in single words of word data and/or
constants.
2-212
DOUBLE LOGICAL
OR
ORWL/
@ORWL
611
Takes the logical OR of corresponding bits in double words of word data and/or
constants.
2-212
EXCLUSIVE OR
XORW/
@XORW
036
2-214
DOUBLE EXCLUSIVE OR
XORL/
@XORL
612
2-214
COMPLEMENT
COM/
@COM
029
Turns OFF all ON bits and turns ON all OFF bits in Wd.
2-216
DOUBLE
COMPLEMENT
COML/
@COML
614
Turns OFF all ON bits and turns ON all OFF bits in Wd and Wd+1.
2-216
ARITHMETIC PROCESS
APR/
@APR
069
2-218
BIT COUNTER
BCNT/
@BCNT
067
2-227
1 Summary of Instructions
Floating-point
Math Instructions
Instruction
Data Control
Instructions
Subroutine
Instructions
Interrupt
Control
Instructions
FUN
No.
Function
Page
FLOATING TO
16-BIT
FIX/
@FIX
450
Converts a 32-bit floating-point value to 16-bit signed binary data and places
the result in the specified result word.
2-233
FLOATING TO
32-BIT
FIXL/
@FIXL
451
Converts a 32-bit floating-point value to 32-bit signed binary data and places
the result in the specified result words.
2-233
16-BIT TO
FLOATING
FLT/
@FLT
452
Converts a 16-bit signed binary value to 32-bit floating-point data and places
the result in the specified result words.
2-235
32-BIT TO
FLOATING
FLTL/
@FLTL
453
Converts a 32-bit signed binary value to 32-bit floating-point data and places
the result in the specified result words.
2-235
FLOATINGPOINT
ADD
+F/
@+F
454
Adds two 32-bit floating-point numbers and places the result in the specified
result words.
2-237
FLOATINGPOINT
SUBTRACT
-F/
@-F
455
Subtracts one 32-bit floating-point number from another and places the result in
the specified result words.
2-237
FLOATINGPOINT MULTIPLY
F/
@F
456
Multiplies two 32-bit floating-point numbers and places the result in the specified result words.
2-237
FLOATINGPOINT DIVIDE
/F
@/F
457
Divides one 32-bit floating-point number by another and places the result in the
specified result words.
2-237
Compares the specified single-precision data (32 bits) or constants and creates
an ON execution condition if the comparison result is true. Three kinds of symbols can be used with the floating-point symbol comparison instructions: LD
(Load), AND, and OR.
2-241
FLOATING
SYMBOL
COMPARISON
Table Data
Processing
Instructions
Mnemonic
=F
329
<>F
330
<F
331
<=F
332
2-241
>F
333
2-241
>=F
334
2-241
FLOATINGPOINT TO ASCII
FSTR/
@FSTR
448
2-244
ASCII TO
FLOATING-POINT
FVAL/
@FVAL
449
2-249
SWAP BYTES
SWAP/
@SWAP
637
Switches the leftmost and rightmost bytes in all of the words in the range.
2-253
FRAME
CHECKSUM
FCS/
@FCS
180
2-255
PID CONTROL
WITH AUTOTUNING
PIDAT
191
Executes PID control according to the specified parameters. The PID constants
can be auto-tuned with PIDAT(191).
2-257
TIME-PROPORTIONAL OUTPUT
TPO
685
Inputs the duty ratio or manipulated variable from the specified word, converts
the duty ratio to a time-proportional output based on the specified parameters,
and outputs the result from the specified output.
2-269
SCALING
SCL/
@SCL
194
Converts unsigned binary data into unsigned BCD data according to the specified linear function.
2-276
SCALING 2
SCL2/
@SCL2
486
Converts signed binary data into signed BCD data according to the specified
linear function. An offset can be input in defining the linear function.
2-280
SCALING 3
SCL3/
@SCL3
487
Converts signed BCD data into signed binary data according to the specified
linear function. An offset can be input in defining the linear function.
2-284
AVERAGE
AVG
195
Calculates the average value of an input word for the specified number of
cycles.
2-287
SUBROUTINE
CALL
SBS/
@SBS
091
Calls the subroutine with the specified subroutine number and executes that
program.
2-290
SUBROUTINE
ENTRY
SBN
092
Indicates the beginning of the subroutine program with the specified subroutine
number.
2-295
SUBROUTINE
RETURNI
RET
093
2-295
SET INTERRUPT
MASK
MSKS/
@MSKS
690
2-300
CLEAR
INTERRUPT
CLI/
@CLI
691
Clears or retains recorded interrupt inputs for I/O interrupts or sets the time to
the first scheduled interrupt for scheduled interrupts.
2-303
DISABLE
INTERRUPTS
DI/
@DI
693
Disables execution of all interrupt tasks except the power OFF interrupt.
2-306
ENABLE
INTERRUPTS
EI
694
Enables execution of all interrupt tasks that were disabled with DI(693).
2-307
2-241
2-241
1-9
Instrucion
Type
1 Summary of Instructions
Instrucion
Type
High-speed
Counter and
Pulse Output
Instructions
Instruction
Mnemonic
FUN
No.
Function
Page
MODE CONTROL
INI/
@INI
880
INI(880) is used to start and stop target value comparison, to change the
present value (PV) of a high-speed counter, to change the PV of an interrupt
input (counter mode), to change the PV of a pulse output, or to stop pulse output.
2-308
HIGH-SPEED
COUNTER PV
READ
PRV/
@PRV
881
PRV(881) is used to read the present value (PV) of a highspeed counter, pulse
output, or interrupt input (counter mode).
2-311
COMPARISON
TABLE LOAD
CTBL/
@CTBL
882
2-315
SPEED OUTPUT
SPED/
@SPED
885
SPED(885) is used to specify the frequency and perform pulse output without
acceleration or deceleration.
2-319
SET PULSES
PULS/
@PULS
886
2-323
PULSE OUTPUT
PLS2/
@PLS2
887
2-325
ACCELERATION
CONTROL
ACC/
@ACC
888
2-331
ORIGIN SEARCH
ORG/
@ORG
889
2-336
PULSE WITH
PWM/
@PWM
891
2-339
SNXT
009
2-342
VARIABLE DUTY
FACTOR
Step
Instructions
STEP START
STEP
008
2-342
Serial Communications
Instructions
Clock
Instructions
Failure
Diagnosis
Instructions
1-10
I/O REFRESH
IORF/
@IORF
097
2-352
7-SEGMENT
DECODER
SDEC/
@SDEC
078
Converts the hexadecimal contents of the designated digit(s) into 8-bit, 7-segment display code and places it into the upper or lower 8-bits of the specified
destination words.
2-354
DIGITAL SWITCH
INPUT
DSW
210
Reads the value set on an external digital switch (or thumbwheel switch) connected to an Input Unit or Output Unit and stores the 4-digit or 8-digit BCD data
in the specified words.
2-357
MATRIX INPUT
MTR
213
2-361
7SEG
214
Converts the source data (either 4-digit or 8-digit BCD) to 7-segment display
data, and outputs that data to the specified output word.
2-365
TRANSMIT
TXD/
@TXD
236
Outputs the specified number of bytes of data from the RS-232C port built into
the CPU Unit or the serial port of a Serial Communications Board (version 1.2
or later).
2-369
RECEIVE
RXD/
@RXD
235
Reads the specified number of bytes of data from the RS-232C port built into
the CPU Unit or the serial port of a Serial Communications Board (version 1.2
or later).
2-374
CALENDAR ADD
CADD/
@CADD
730
2-380
CALENDAR
SUBTRACT
CSUB/
@CSUB
731
2-380
CLOCK
ADJUSTMENT
DATE/
@DATE
735
Changes the internal clock setting to the setting in the specified source words.
2-385
FAILURE ALARM
FAL/
@FAL
006
2-387
SEVERE FAILURE
ALARM
FALS
007
2-393
1 Summary of Instructions
Other
Instructions
Instruction
Mnemonic
FUN
No.
Function
Page
SET CARRY
STC/
@STC
040
2-398
CLEAR CARRY
CLC/
@CLC
041
2-398
EXTEND MAXIMUM
CYCLE TIME
WDT/
@WDT
094
Extends the maximum cycle time, but only for the cycle in which this instruction
is executed.
2-399
Instrucion
Type
1-11
1 Summary of Instructions
1-12
Instructions
This section describes the functions, operands and sample programs of the instructions that are supported by a CP1E CPU Unit.
2-1
2 Instructions
Contents
Instruction
Mnemonic
Variations
Differentiation
Example: MOVB(082)
@ Instruction that differentiates when the execution condition turns ON.
% Instruction that differentiates when the execution condition turns OFF.
Immediate refreshing
!
Refreshes data in the I/O area specified by the operands or the Special I/O Unit words when
the instruction
is executed.
A
repeatedly as long a
execution condition
JMP
a
Function code
Function
The basic purpose of the instruction is described after the section heading.
Symbol
The ladder symbol used to represent the instruction on the CX-Programmer is shown, as in the example for the MOVE BIT instruction given below. The name of each operand is also provided with the ladder symbol.
MOVB
S
C: Control word
D: Destination word
Operands
The program areas in which the instruction can be used are specified. OK indicates the areas in
which the instruction can be used.
Area
Subroutines
Usage
OK
OK
Interrupt tasks
OK
Indicates a description of the operand, the data type, and the size.
Where necessary, the meaning of words and bits used in specific operands, such as control words, is
given.
15
C
8 7
n
Source bit: 00 to 0F
(0 to 15 decimal)
Destination bit: 00 to 0F
(0 to 15 decimal)
Operand Specifications
The memory areas addresses that can be used each operand are listed in a table like the following
one. The letters used in the column headings on the above are the same as those used in the ladder
symbol. --- is used to indicate when an area cannot be specific for an operand.
S
C
D
2-2
Indirect DM
addresses
Word addresses
Area
CIO WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
OK
CF
---
Pulse TR
bits bits
---
---
---
2 Instructions
Item
Contents
Flags
Name
Function
Label
The flags table indicates the status of the condition flags immediately after execution of the instruction.
Any flags that are not listed are not affected by the instruction. OFF indicates that a flag is turned
OFF immediately after execution of the instruction regardless of the results of executing the instruction.
Operation
Error Flag
ER
OFF
Equal Flag
Negative Flag
Hint
Precautions
Sample program
An example of using the instruction with specific operands is provided to further explain the function of
the instruction.
Constants
Constants input for operands are given as listed below.
Operand Descriptions and Operand Specifications
Operands Specifying Bit Strings (Normally Input as Hexadecimal):
Only the hexadecimal form is given for operands specifying bit strings, e.g., only #0000 to #FFFF is
specified as the S operand for the MOV(021) instruction. On the CX-Programmer, however, bit strings
can be input in decimal form by using the & prefix.
Operands Specifying Numeric Values (Normally Input as Decimal, Including Jump Numbers):
Both the decimal and hexadecimal forms are given for operands specifying numeric values, e.g.,
#0000 to #FFFF and &0 to &65535 are given for the N operand for the XFER(070) instruction.
Operands Indicating Control Numbers (Except for Jump Numbers):
The decimal form is given for control numbers, e.g., 0 to 1023 is given for the N operand for the
SBS(091) instruction.
Examples
In the examples, constants are given using the CX-Programmer notation, e.g., operands specifying
numeric values are given in decimal for with an & prefix, as shown in the following example.
XFER
&10
D100
D200
The input methods for constants for the Programming Devices are given in the following table.
Operand
Operands specifying bit strings (normally input as hexadecimal)
CX-Programmer
Input as decimal with an & prefix or input as hexadecimal
with an # prefix. (See note.)
Note When operands are input on the CX-Programmer, the input ranges will be displayed along with the appropriate prefixes.
2-3
2 Instructions
Condition Flags
With the CX-Programmer, the condition flags are registered in advance as global symbols with P_ in
front of the symbol name.
Flag
CX-Programmer label
Error Flag
P_ER
P_AER
Carry Flag
P_CY
P_GT
Equals Flag
P_EQ
P_LT
Negative Flag
P_N
Overflow Flag
P_OF
Underflow Flag
P_UF
P_GE
P_NE
P_LE
Always ON Flag
P_On
P_Off
Symbol Instructions
Some of the C/CV-series PLC instructions have been changed to different instructions with the same
functionality for the CP1E-series PLCs.
Instruction group
CP1E Series
EQU
AND=
Data Movement
MOVQ
MOV
Increment/Decrement
INC
++B
INCL
++BL
INCB
++
Symbol Math
Interrupt Control
2-4
C/CV Series
Comparison
INBL
++L
DEC
--B
DECL
--BL
DECB
--
DCBL
--L
ADB
+C
ADBL
+CL
ADD
+BC
ADDL
+BCL
SBB
-C
SBBL
-CL
SUB
-BC
SUBL
-BCL
MBS
MBSL
*L
MUL
*B
MULL
*BL
DBS
DBSL
/L
DIV
/B
DIVL
/BL
INT
MSKS / CLIDI / EI
2 Instructions
Mnemonic
Function
I/O refresh
Differentiated up
Differentiated down
Immediate refresh
Differentiated up /
immediate refresh
Differentiated down /
immediate refresh
Cyclic refreshing
2-5
2 Instructions
A
!
A
!
A
!
A
!
A
B2
Input
received
B1
Input
received
B2
B3
B3
B4
Input
received
B5
Input
received
B4
B5
B6
!
Input
received
Input
received
Input
received
B6
B7
Input
received
B8
Input
received
Input received
B7
!
B8
B9
!
A
B10
!
A
B11
!
A
B1
Input
received
Input
received
B9
B10
B11
B12
B12
CPU
processing
Instruction execution
2-6
I/O refreshing
2 Instructions
Instruction
Mnemonic
LOAD
LOAD NOT
Function
code
Variations
Function
LD
---
LD NOT
---
LD
LD NOT
Bus bar
Bus bar
LD/LD NOT
LD/LD NOT
Symbol
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
---
---
BOOL
---
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
---
---
---
Constants
CF
Pulse bits
---
OK
OK
LD
TR bits
OK
LD NOT
---
Flags
There are no flags affected by this instruction.
Function
LD
LD is used for the first normally open bit from the bus bar or for the first normally open bit of a logic
block. If there is no immediate refreshing specification, the specified bit in I/O memory is read. If there is
an immediate refreshing specification, the status of the CPU Units built-in input terminal is read and
used.
LD NOT
LD NOT is used for the first normally closed bit from the bus bar, or for the first normally closed bit of a
logic block. If there is no immediate refreshing specification, the specified bit in I/O memory is read and
reversed. If there is an immediate refreshing specification, the status of the CPU Units built-in input terminal is read, reversed, and used.
2-7
2 Instructions
Hint
LD/LD NOT is used in the following circumstances as an instruction for indicating a logical start.
1. When directly connecting to the bus bar.
2. When logic blocks are connected by AND LD or OR LD, i.e., at the beginning of a logic block.
The AND LOAD and OR LOAD instructions are used to connect in series or in parallel logic blocks
beginning with LD or LD NOT.
At least one LOAD or LOAD NOT instruction is required for the execution condition when outputrelated instructions cannot be connected directly to the bus bar. If there is no LOAD or LOAD NOT
instruction, a programming error will occur with the program check by the Peripheral Device.
When logic blocks are connected by AND LOAD or OR LOAD instructions, the total number of AND
LOAD/OR LOAD instructions must match the total number of LOAD/LOAD NOT instructions minus1.
If they do not match, a programming error will occur. For details, refer to AND LOAD: AND LD and
OR LOAD: OR LD.
Precautions
Differentiate up (@) or differentiate down (%) can be specified for LD. If differentiate up (@) is specified, the execution condition is turned ON for one cycle only after the status of the operand bit goes
from OFF to ON. If differentiate down (%) is specified, the execution condition is turned ON for one
cycle only after the status of the operand bit goes from ON to OFF.
Immediate refreshing (!) can be specified for LD/LD NOT. An immediate refresh instruction updates
the status of the built-in input bit just before the instruction is executed from the CPU Unit.
For LD, it is possible to combine immediate refreshing and up or down differentiation (!@ or !%). If
either of these is specified, the input is refreshed from the Basic Input Unit just before the instruction
is executed and the execution condition is turned ON for one cycle only after the status goes from
OFF to ON, or from ON to OFF.
Sample program
i
LD
LD
0.02
0.04
0.05
LD NOT
2-8
100.00
0.01
0.00
LD
0.03
Instruction
Operand
LD
0.00
LD
0.01
LD
0.02
AND
0.03
OR LD
--
AND LD
--
LD NOT
0.04
AND
0.05
OR LD
--
OUT
100.00
OR LD
AND LD
OR LD
2 Instructions
Instruction
Mnemonic
AND
AND NOT
Variations
Function
code
Function
AND
@AND, %AND,
!AND, !@AND,
!%AND
---
AND NOT
@AND NOT,
%AND NOT,
!AND NOT,
!@AND NOT,
!%AND NOT
---
AND/AND NOT
2
AND
AND NOT
Symbol
AND/AND NOT
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
---
---
BOOL
---
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
---
---
---
Constants
CF
Pulse bits
TR bits
---
OK
OK
---
AND
AND NOT
Flags
There are no flags affected by this instruction.
Function
AND
AND is used for a normally open bit connected in series. AND cannot be directly connected to the bus
bar, and cannot be used at the beginning of a logic block. If there is no immediate refreshing specification, the specified bit in I/O memory is read. If there is an immediate refreshing specification, the status
of the CPU Units built-in input terminal is read.
AND NOT
AND NOT is used for a normally closed bit connected in series. AND NOT cannot be directly connected
to the bus bar, and cannot be used at the beginning of a logic block. If there is no immediate refreshing
specification, the specified bit in I/O memory is read. If there is an immediate refreshing specification,
the status the CPU Units built-in input terminals is read.
2-9
2 Instructions
Precautions
Differentiate up (@) or differentiate down (%) can be specified for AND. If differentiate up (@) is specified, the execution condition is turned ON for one cycle only after the status of the operand bit goes
from OFF to ON. If differentiate down (%) is specified, the execution condition is turned ON for one
cycle only after the status of the operand bit goes from ON to OFF.
Immediate refreshing (!) can be specified for AND/AND NOT. An immediate refresh instruction
updates the status of the built-in input bit just before the instruction is executed from the CPU Unit.
For AND, it is possible to combine immediate refreshing and up or down differentiation (!@ or !%). If
either of these is specified, the input is refreshed from the Basic Input Unit just before the instruction
is executed and the execution condition is turned ON for one cycle only after the status goes from
OFF to ON, or from ON to OFF.
Sample program
i
AND
0.00
0.01
AND
0.02
0.04
100.00
0.03
0.05
AND NOT
2-10
Instruction
Operand
LD
0.00
AND
0.01
LD
0.02
AND
0.03
LD
0.04
AND NOT
0.05
OR LD
--
AND LD
--
OUT
100.00
2 Instructions
Instruction
Mnemonic
OR
OR NOT
Function
code
Variations
Function
OR
@OR, %OR,
!OR, !@OR,
!%OR
---
OR NOT
---
OR
OR/OR NOT
OR NOT
Bus bar
Bus bar
OR/OR NOT
Symbol
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
---
---
BOOL
---
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
---
---
---
Constants
CF
Pulse bits
TR bits
---
OK
OK
---
OR
OR NOT
Flags
There are no flags affected by this instruction.
Function
OR
OR is used for a normally open bit connected in parallel. A normally open bit is configured to form a logical OR with a logic block beginning with a LOAD or LOAD NOT instruction (connected to the bus bar or
at the beginning of the logic block). If there is no immediate refreshing specification, the specified bit in
I/O memory is read. If there is an immediate refreshing specification, the status of the CPU Units builtin input terminal is read.
OR NOT
OR NOT is used for a normally closed bit connected in parallel. A normally closed bit is configured to
form a logical OR with a logic block beginning with a LOAD or LOAD NOT instruction (connected to the
bus bar or at the beginning of the logic block). If there is no immediate refreshing specification, the
specified bit in I/O memory is read. If there is an immediate refreshing specification, the status of the
CPU Units built-in input terminal is read.
2-11
2 Instructions
Precautions
Differentiate up (@) or differentiate down (%) can be specified for OR. If differentiate up (@) is specified, the execution condition is turned ON for one cycle only after the status of the operand bit goes
from OFF to ON. If differentiate down (%) is specified, the execution condition is turned ON for one
cycle only after the status of the operand bit goes from ON to OFF.
Immediate refreshing (!) can be specified for OR/OR NOT. An immediate refresh instruction updates
the status of the built-in input bit just before the instruction is executed from the CPU Unit.
For OR, it is possible to combine immediate refreshing and up or down differentiation (!@ or !%). If
either of these is specified, the input is refreshed from the Basic Input Unit just before the instruction
is executed and the execution condition is turned ON for one cycle only after the status of the operand bit goes from OFF to ON, or from ON to OFF.
Sample program
i
0.00
0.01
0.02
0.04
0.05
100.00
0.06
Instruction
0.03
0.07
OR
2-12
OR NOT
Operand
LD
0.00
AND
0.01
AND
0.02
OR
0.03
AND
0.04
LD
0.05
AND
0.06
OR NOT
0.07
AND LD
--
OUT
100.00
2 Instructions
Instruction
Mnemonic
Function
code
Variations
AND LD/OR LD
Function
AND LOAD
AND LD
---
---
OR LOAD
OR LD
---
---
AND LD
OR LD
Logic block
Symbol
Logic block
Logic block
2
Logic block
AND LD/OR LD
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Flags
There are no flags affected by this instruction.
Function
AND LD
AND LD connects in series the logic block just
before this instruction with another logic block.
The logic block consists of all the instructions
from a LOAD or LOAD NOT instruction until
just before the next LOAD or LOAD NOT
instruction on the same rungs.
LD
to
LD
to
AND LD
OR LD
OR LD connects in parallel the logic block just
before this instruction with another logic block.
The logic block consists of all the instructions
from a LOAD or LOAD NOT instruction until
just before the next LOAD or LOAD NOT
instruction on the same rungs.
Logic block A
Logic block B
LD
to
Logic block A
LD
to
OR LD
Logic block B
Hint
AND LD
Three or more logic blocks can be connected in series using this instruction to first connect two of the
logic blocks and then to connect the next and subsequent ones in order. It is also possible to continue
placing this instruction after three or more logic blocks and connect them together in series.
OR LD
Three or more logic blocks can be connected in parallel using this instruction to first connect two of
the logic blocks and then to connect the next and subsequent ones in order. It is also possible to continue placing this instruction after three or more logic blocks and connect them together in parallel.
CP1E CPU Unit Instructions Reference Manual(W483)
2-13
2 Instructions
Precautions
When a logic block is connected by AND LOAD or OR LOAD instructions, the total number of AND
LOAD/OR LOAD instructions must match the total number of LOAD/LOAD NOT instructions minus 1. If
they do not match, a programming error will occur.
AND LD
In the following diagram, the two logic blocks are indicated by dotted lines. Studying this example shows
that an ON execution condition will be produced when either of the execution conditions in the left logic
block is ON (i.e., when either CIO 0.00 or CIO 0.01 is ON) and either of the execution conditions in the
right logic block is ON (i.e., when either CIO 0.02 is ON or CIO 0.03 is OFF).
i
0.00
0.02
0.01
0.03
100.00
Coding
Instruction
Operand
LD
0.00
OR
0.01
LD
0.02
OR NOT
0.03
AND LD
---
OUT
100.00
Second LD: Used for first bit of next block connected in series to previous block.
OR LD
The following diagram requires an OR LOAD instruction between the top logic block and the bottom
logic block. An ON execution condition would be produced either when CIO 0.00 is ON and CIO 0.01 is
OFF or when CIO 0.02 and CIO 0.03 are both ON. The operation of and mnemonic code for the OR
LOAD instruction is exactly the same as those for a AND LOAD instruction except that the current execution condition is ORed with the last unused execution condition.
i
0.00
0.01
100.01
Coding
Instruction
0.02
0.03
Operand
LD
0.00
AND NOT
0.01
LD
0.02
AND
0.03
OR LD
---
OUT
100.01
Second LD: Used for first bit of next block connected in series to previous block.
2-14
2 Instructions
Sample program
i
0.00
0.02
0.04
0.01
0.03
0.05
100.00
Operand
Instruction
Operand
LD
0.00
LD
0.00
OR NOT
0.01
OR NOT
0.01
LD NOT
0.02
LD NOT
0.02
OR
0.03
OR
0.03
AND LD
---
LD
0.04
LD
0.04
OR
0.05
OR
0.05
AND LD
---
.
.
.
.
.
.
.
.
AND LD
---
AND LD
---
OUT
100.00
.
.
.
.
OUT
100.00
2
AND LD/OR LD
The AND LOAD instruction can be used repeatedly. In programming method (2) above, however, the
number of AND LOAD instructions becomes one less than the number of LOAD and LOAD NOT
instructions before that.
In method (2), make sure that the total number of LOAD and LOAD NOT instructions before AND
LOAD is not more than eight.
To use nine or more, program using method (1).
If there are nine or more with method (2), then a program error will occur during the program check by
the Peripheral Device.
OR LD
i
0.00
0.01
0.02
0.03
0.04
0.05
100.01
Operand
Instruction
Operand
LD
0.00
LD
0.00
AND NOT
0.01
AND NOT
0.01
LD NOT
0.02
LD NOT
0.02
AND NOT
0.03
AND NOT
0.03
OR LD
---
LD
0.04
LD
0.04
AND
0.05
AND
0.05
OR LD
---
.
.
.
.
.
.
.
.
OR LD
---
OR LD
---
OUT
100.01
.
.
.
.
OUT
100.01
The OR LOAD instruction can be used repeatedly. In programming method (2) above, however, the
number of OR LOAD instructions becomes one less than the number of LOAD and LOAD NOT
instructions before that.
In method (2), make sure that the total number of LOAD and LOAD NOT instructions before OR
LOAD is not more than eight.
To use nine or more, program using method (1).
If there are nine or more with method (2), then a program error will occur during the program check by
the Peripheral Device.
CP1E CPU Unit Instructions Reference Manual(W483)
AND LD
2-15
2 Instructions
NOT
Instruction
Mnemonic
NOT
NOT
Variations
Function
code
---
520
Function
Reverses the execution condition.
NOT
Symbol
NOT(520)
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Flags
There are no flags affected by NOT(520).
Function
NOT(520) is placed between an execution condition and another instruction to invert the execution condition.
Precautions
NOT(520) is an intermediate instruction, i.e., it cannot be used as a right-hand instruction. Be sure to
program a right-hand instruction after NOT(520).
Sample program
i
0.00
100.00
0.01
NOT(520)
0.02
2-16
0.01
0.02
100.00
2 Instructions
Instruction
Mnemonic
Variations
Function
code
Function
CONDITION ON
UP
---
521
CONDITION OFF
DOWN
---
522
UP
DOWN
UP(521)
DOWN(522)
Symbol
2
UP/DOWN
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Flags
There are no flags affected by UP(521) and DOWN(522).
Function
UP
UP(521) is placed between an execution condition and another instruction to turn the execution condition into an up-differentiated condition. UP(521) causes the connecting instruction to be executed just
once when the execution condition goes from OFF to ON.
DOWN
DOWN(522) is placed between an execution condition and another instruction to turn the execution
condition into a down-differentiated condition. DOWN(522) causes the connecting instruction to be executed just once when the execution condition goes from ON to OFF.
Precautions
The operation of UP(521) and DOWN(522) depends on the execution condition for the instruction as
well as the execution condition for the program section when it is programmed in an interlocked program section, a jumped program section, or a subroutine.
The operation of UP(521) and DOWN(522) will not be consistent if the same subroutine is executed
more than once in the same cycle.
An subroutine will not be executed while the input condition for the subroutine is OFF. Caution is thus
required when using UP(521) and DOWN(522) in a function block definition. For details, refer to information on SBS(091).
Sample program
UP
i
0.00
100.01
UP
100.01
Cycle
time
UP/DOWN
2-17
2 Instructions
Mnemonic
OUTPUT
OUT
OUTPUT NOT
OUT NOT
Variations
Function
code
!OUT
---
!OUT NOT
---
Function
Outputs the result (execution condition) of the
logical processing to the specified bit.
Reverses the result (execution condition) of the
logical processing, and outputs it to the specified
bit.
OUT
OUT NOT
Symbol
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
---
---
BOOL
---
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
---
---
OK
---
---
Constants
CF
Pulse bits
TR bits
---
---
---
OK
OUT
OUT NOT
Flags
There are no flags affected by this instruction.
Function
OUT
If there is no immediate refreshing specification, the status of the execution condition (power flow) is
written to the specified bit in I/O memory. If there is an immediate refreshing specification, the status of
the execution condition (power flow) is also written to the CPU Units built-in output terminal in addition
to the output bit in I/O memory.
OUT NOT
If there is no immediate refreshing specification, the status of the execution condition (power flow) is
reversed and written to a specified bit in I/O memory. If there is an immediate refreshing specification,
the status of the execution condition (power flow) is reversed and also written to the CPU Units built-in
output terminal in addition to the output bit in I/O memory.
2-18
2 Instructions
Hint
Sample program
100.00
0.00
Immediate refreshing (!) can be specified for OUT and OUT NOT. An immediate refresh instruction
updates the status of the built-in output terminal just after the instruction is executed for the CPU Unit,
at the same time as it writes the status of the execution condition (power flow) to the specified output
bit in I/O memory.
100.01
OUT/OUT NOT
Instruction
Operand
LD
0.00
OUT
100.00
OUT NOT
100.01
2-19
2 Instructions
TR
Instruction
Mnemonic
TR Bits
Variations
Function
code
Function
---
---
TR
Function
TR bits are used to temporarily retain the ON/OFF status of execution conditions in a program when
programming in mnemonic code. They are not used when programming directly in ladder program form
because the processing is automatically executed by the Peripheral Device. The following diagram
shows a simple application using two TR bits.
Coding
0.00
TR0
0.01
TR1
0.02
0.03
100.00
100.01
0.04
100.02
0.05
100.03
Instruction
Operands
LD
0.00
OUT
TR0
AND
0.01
OUT
TR1
AND
0.02
OUT
100.00
LD
TR1
AND
0.03
OUT
100.01
LD
TR0
AND
0.04
OUT
100.02
LD
TR0
AND NOT
100.00
OUT
100.03
Relay Address
Temporary Relay
TR0 to TR15
2-20
0.00
0.02
100.00
TR0
0.01
100.01
0.03
100.02
100.03
(1)
(2)
2 Instructions
Instruction
Mnemonic
KEEP
KEEP
Variations
Function
code
!KEEP
011
KEEP
Function
Operates like a latching relay.
KEEP
S(SET)
Symbol
KEEP(011)
R(RESET)
R: Bit
2
Applicable Program Areas
Step program areas
Subroutines
Interrupt tasks
OK
OK
OK
KEEP
Area
Usage
Operands
Operand
Description
Data type
Size
Bit
BOOL
---
Operand Specifications
Word addresses
Indirect DM addresses
Area
R
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
---
---
---
OK
Flags
No flags are affected by KEEP(011).
Function
When S turns ON, the designated bit will go
ON and stay ON until reset, regardless of
whether S stays ON or goes OFF. When R
turns ON, the designated bit will go OFF. The
relationship between execution conditions and
KEEP(011) bit status is shown below on the
right.
Set
KEEP
Reset
B
S execution condition
ON
OFF
R execution condition
ON
OFF
Status of C
ON
OFF
2-21
2 Instructions
Hint
KEEP(011) has an immediate refreshing variation (!KEEP(011)). When a CPU Unit built-in output bit
has been specified for R in a !KEEP(011) instruction, any changes to R will be refreshed when
!KEEP(011) is executed and reflected immediately in the output bit.
KEEP(011) operates like the self-maintaining bit, but a self-maintaining bit programmed with
KEEP(011) requires one less instruction.
0.02
100.00
0.03
5.00
0.02
KEEP
100.00
0.03
Self-maintaining bits programmed with KEEP(011) will maintain status even in an interlock program
section, unlike the self-maintaining bit programmed without KEEP(011).
IL
IL
KEEP
A
C
ILC
ILC
KEEP
B
2-22
2 Instructions
0.02
KEEP
H0.00
0.03
Indicates
emergency
situation
0.04
0.05
H0.00
If a holding bit is used for R, the bit status will be retained even during a power interruption.
KEEP(011) can thus be used to program bits that will maintain status after restarting the PLC following a power interruption. An example of this that can be used to produce a warning display following
a system shutdown for an emergency situation is shown below.
Reset input
The status of I/O Area bits can be retained in the event of a power interruption by turning ON the IOM
Hold Bit and setting IOM Hold Bit Hold in the PLC Setup. In this case, I/O Area bits used in
KEEP(011) will maintain status after restarting the PLC following a power interruption, just like holding bits. Be sure to restart the PLC after changing the PLC Setup; otherwise the new settings will not
be used.
Precautions
If S and R are ON simultaneously, the reset
input takes precedence.
Set
ON
OFF
Reset
ON
OFF
Status of C
ON
OFF
Set
ON
OFF
Reset
ON
OFF
Status of C
ON
OFF
Input Unit
A
NEVER
KEEP
2-23
KEEP
100.00 Activates
warning
display
2 Instructions
Sample program
0.00
KEEP
100.00
0.01
0.02
0.03
KEEP
100.01
0.04
0.05
Coding
Instruction
Operand
LD
0.00
LD
0.01
KEEP (011)
100.00
LD
0.02
AND NOT
0.03
LD
0.04
OR
0.05
KEEP (011)
100.01
Note KEEP(011) is input in different orders on in ladder and mnemonic form. In ladder form, input the set input,
KEEP(011), and then the reset input. In mnemonic form, input the set input, the reset input, and then
KEEP(011).
2-24
2 Instructions
Instruction
Mnemonic
DIFFERENTIATE UP
DIFU
Variations
Function
code
!DIFU
013
Function
DIFU(013) turns the designated bit ON for one
cycle when the execution condition goes from
OFF to ON (rising edge).
DIFU
Symbol
DIFU
DIFU(013)
R
R: Bit
Subroutines
Interrupt tasks
Usage
OK
OK
OK
DIFU
Area
Operands
Operand
Description
Data type
Size
Bit
BOOL
---
Operand Specifications
Word addresses
Indirect DM addresses
Area
R
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
No flags are affected by DIFU(013).
Function
When the execution condition goes from OFF
to ON, DIFU(013) turns R ON. When
DIFU(013) is reached in the next cycle, R is
turned OFF.
Execution condition
Status of R
1 cycle
Hint
UP(521) can be used to execute an instruction for just one cycle when the execution condition goes
from OFF ON.
DIFU(013) has immediate refreshing variation (!DIFU(013)). When a CPU Unit built-in output bit has
been specified for R in this instruction, any changes to R will be refreshed when the instruction is executed and reflected immediately in the output bit.
2-25
2 Instructions
Precautions
The operation of DIFU(013) depends on the execution condition for the instruction itself as well as the
execution condition for the program section when it is programmed in an interlocked program section,
a jumped program section, or a subroutine.
An subroutine will not be executed while the input condition for the subroutine is OFF. Caution is thus
required when using DIFU(013) in a function block definition. For details, refer to information on
SBS(091).
The operation of DIFU(013) will not be consistent if the same subroutine is executed more than once
in the same cycle.
Sample program
When CIO 0.00 goes from ON to OFF in the following example, CIO 100.00 is turned ON for one cycle.
i
0.00
DIFU
100.00
0.00
100.00
1 cycle
2-26
1 cycle
2 Instructions
Instruction
Mnemonic
DIFFERENTIATE DOWN
DIFD
Variations
Function
code
Function
!DIFD
014
DIFD
Symbol
DIFD(014)
R
R: Bit
Area
Subroutines
Interrupt tasks
Usage
OK
OK
OK
DIFD
Operands
Operand
Description
Data type
Size
BOOL
---
Bit
Operand Specifications
Word addresses
Indirect DM addresses
Area
B
DIFD
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
No flags are affected by DIFD(014).
Function
When the execution condition goes from ON
to OFF, DIFD(014) turns R ON. When
DIFD(014) is reached in the next cycle, R is
turned OFF.
Execution condition
Status of R
1 cycle
Hint
DOWN(522) can be used to execute an instruction for just one cycle when the execution condition goes from ON OFF.
The operation of DIFD(014) depends on the execution condition for the instruction itself as well
as the execution condition for the program section when it is programmed in an interlocked program section, a jumped program section, or a subroutine.
DIFD(014) has immediate refreshing variation (!DIFD(014)). When a CPU Unit built-in output bit
has been specified for R in this instruction, any changes to R will be refreshed when the instruction is executed and reflected immediately in the output bit.
2-27
2 Instructions
Precautions
The operation of DIFD(014) will not be consistent if the same function block instance is executed
more than once in the same cycle.
An subroutine will not be executed while the input condition for the subroutine is OFF. Caution is thus
required when using DIFD(014) in a function block definition. For details, refer to information on
SBS(091).
Sample program
When CIO 0.00 goes from ON to OFF in the following example, CIO 100.00 is turned ON for one cycle.
i
0.00
DIFD
100.00
0.00
100.00
1 cycle
2-28
1 cycle
2 Instructions
Instruction
Mnemonic
SET
RESET
Variations
SET
RSET
@RSET, %RSET,
!RSET, !@RSET,
!%RSET
Function
code
Function
---
---
SET/RSET
2
SET
RSET
SET
R
R: Bit
SET/RSET
Symbol
RSET
R: Bit
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
BOOL
---
Bit
Operand Specifications
Word addresses
Indirect DM addresses
Area
R
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
No flags are affected by SET and RSET.
Function
SET
SET turns the operand bit ON when the execution condition is ON, and does not affect the status of the operand bit when the execution condition is OFF. Use
RSET to turn OFF a bit that has been turned ON with
SET.
Execution condition
of SET
ON
OFF
Status of R
ON
OFF
RSET
RSET turns the operand bit OFF when the execution
condition is ON, and does not affect the status of the
operand bit when the execution condition is OFF. Use
SET to turn ON a bit that has been turned OFF with
RSET.
Execution condition
of RSET
Status of R
ON
OFF
ON
OFF
2-29
2 Instructions
Hint
Differences between OUT/OUT NOT and SET/RSET
The operation of SET differs from that of OUT because the OUT instruction turns the operand bit
OFF when its execution condition is OFF. Likewise, RSET differs from OUT NOT because OUT NOT
turns the operand bit ON when its execution condition is OFF. For OUT, the operand bit is turned ON
when the input condition turns ON and is turned OFF when the input condition turns OFF. For SET
and RSET, the operand bit turns ON or OFF, respectively, when the input condition turns ON and the
operand bit does not change when the input condition turns OFF.
0.00
100.00
CIO 100.00 is turned ON/OFF
when CIO 0.00 goes ON/OFF.
0.01
SET
100.00
0.02
RSET
100.00
The set and reset inputs for a KEEP(011) instruction must be programmed with the instruction, but
the SET and RSET instructions can be programmed completely independently. Furthermore, the
same bit may be used as the operand in any number of SET or RSET instructions.
SET and RSET have immediate refreshing variations (!SET and !RSET). When a CPU Unit built-in
output bit has been specified for R in one of these instructions, any changes to R will be refreshed
when the instruction is executed and reflected immediately in the output bit.
If external output is specified for R by !SET (or !RSET), R will be OUT-refreshed as soon as it turns
ON (or OFF) (when the instruction is executed). R, which turned ON (or OFF), will remain ON (or
OFF) as normal until a RSET instruction (or SET instruction) is executed.
Precautions
SET and RSET cannot be used to set and reset timers and counters. When SET or RSET is programmed between IL(002) and ILC(003) or JMP(004) and JME(005), the status of the specified bit
will not be changed if the program section is interlocked or jumped.
2-30
2 Instructions
Instruction
Mnemonic
Function
code
Variations
Function
SETA
@SETA
530
RSTA
@RSTA
531
SETA
RSTA
SETA(530)
Symbol
RSTA(531)
D: Beginning word
D: Beginning word
N1
N1
N2
N2
SETA/RSTA
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Beginning Word
UINT
Variable
N1
Beginning Bit
UINT
N2
Number of Bits
UINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
---
N1,N2
OK
Flags
Operand
Error Flag
Description
P_ER
Data type
ON if N1 is not within the specified range of 0000 to 000F (&0 to &15).
OFF in all other cases.
Function
SETA
SETA(530) turns ON N2 bits, beginning
from bit N1 of D, and continuing to the left
(more-significant bits). All other bits are
left unchanged. (No changes will be
made if N2 is set to 0.)
N1
15
D 1
D+1 1
D+2
1 1
1 1
1
SETA/RSTA
2-31
2 Instructions
RSTA
N1
15
D 0
0 0
D+1 0
0 0
D+2
N2 bits are
reset to 0 (OFF).
Hint
SETA
SETA(530) can be used to turn ON bits in data areas that are normally accessed by words only, such
as the DM areas.
RSTA
RSTA(531) can be used to turn OFF bits in data areas that are normally accessed by words only,
such as the DM areas.
Sample program
SETA
When CIO 0.00 is turned ON in the following example, the 20 bits (0014 hexadecimal) beginning
with bit 5 of CIO 100 are turned ON.
0.00
SETA
D
N1
N2
N1: Bit 5
100
&5
&20
15
1211
8 7
5 4 3
D: 100 1 1 1 1 1 1 1 1 1 1 1
N2: 20 bits
1 1 1 1 1 1 1 1 1
101
RSTA
When CIO 0.00 is turned ON in the following example, the 20 bits (0014 hexadecimal) beginning
with bit 3 of CIO 100 are turned OFF.
0.00
RSTA
D
N1
N2
2-32
N1: Bit 3
100
&3
&20
15
1211
8 7
4 3
D: 100 0 0 0 0 0 0 0 0 0 0 0 0 0
101
N2: 20 bits
0 0 0 0 0 0 0
2 Instructions
Instruction
Mnemonic
Function
code
Variations
Function
SETB
@SETB, !SETB,
!@SETB
532
RSTB
@RSTB, !RSTB,
!@RSTB
533
SETB
RSTB
RSTB(533)
SETB(532)
Symbol
SETB/RSTB
D: Word address
D: Word address
N: Bit number
N: Bit number
SETB/RSTB
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Word address
UINT
Bit number
UINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
---
OK
Flags
Operand
Error Flag
Description
P_ER
Data type
ON if N is not within the specified range of 0000 to 000F (&0 to &15).
OFF in all other cases.
Function
SETB
15
Execution condition
ON
OFF
Bit N of word D
ON
OFF
2-33
2 Instructions
RSTB
15
Execution condition
ON
OFF
Bit N of word D
ON
OFF
Hint
Differences between SET/RSET and SETB(532)/RSTB(533)
The instructions operate in the same way when the specified bit is in the CIO, W, H, or A Area.
The SETB(532) and RSTB(533) instructions can control bits in the DM Areas, unlike SET and RSET.
The set and reset inputs for a KEEP(011) instruction must be programmed with the instruction, but
the SETB(532) and RSTB(533) instructions can be programmed completely independently. Furthermore, the same bit may be used as the operand in any number of SETB(532) and RSTB(533)
instructions.
Precautions
Bits turned ON by SETB(532) can be turned OFF by any other instruction, not just RSTB(533).
Bits turned OFF by RSTB(533) can be turned ON by any other instruction, not just SETB(532).
SETB(532) and RSTB(533) cannot set/reset timers and counters.
When SETB(532) or RSTB(533) is programmed between IL(002) and ILC(003) or JMP(004) and
JME(005), the status of the specified bit will not be changed if the program section is interlocked or
jumped, i.e., when the interlock condition or jump condition is OFF.
SETB(532) and RSTB(533) have immediate refreshing variations (!SETB(532) and !RSTB(533)).
When a CPU Unit built-in output bit has been specified in one of these instructions, any changes to
the specified bit will be refreshed when the instruction is executed and reflected immediately in the
output bit.
When a CPU Unit built-in output is specified for bit address N of word D by !SETB (or !RSTB instruction), bit address N of word D which turned ON (or OFF) will be OUT-refreshed at that point (when the
instruction is executed). Bit address N of word D which was turned ON (or OFF) remains ON (or
OFF) as normal until an RSTB instruction (or SETB instruction) is executed.
Sample program
0.00
SETB
D0
&2
0.01
RSTB
D0
&2
2-34
2 Instructions
0
A1
A1
ILC
b
MILH
b
IL
1
A2
A2
ILC
c
MILH
c
IL
2
A3
A3
MILC
ILC
2
MILC
1
MILC
0
2-35
2 Instructions
Precautions
Do not combine interlocks created with different interlock instructions (IL-ILC, MILH-MILC, and MILRMILC). The interlocks may not operate properly if different interlock methods are used together. For
details on combining instructions, refer to MULTI-INTERLOCK DIFFERENTIATION HOLD, MULTIINTERLOCK DIFFERENTIATION RELEASE, and MULTI-INTERLOCK CLEAR: MILH(517),
MILR(518), and MILC(519).
For example, an MILH(517) instruction cannot be inserted between IL(002) and IL(003).
IL
MILH
ILC
Note The different interlocks (IL-ILC, MILH-MILC, and MILR-MILC) can be used together as long as the interlocked program sections do not overlap.
For example, all three interlock methods can be used without overlapping, as shown in the following
diagram.
IL
ILC
MILH
MILC
MILR
MILC
2-36
2 Instructions
Instruction execution
OFF
Reset
The following table shows the differences between interlocks (created with IL(002)/ILC(003),
MILH(517)/MILC(519), or MILR(518)/MILC(519)) and jumps created with JMP(004)/JME(005).
Item
Treatment in IL(002)/ILC(003),
MILH(517)/MILC (519), or
MILR(518)/MILC (519)
Treatment in
JMP(004)/JME(005)
2-37
2 Instructions
END
Instruction
END
Mnemonic
END
Variations
Function
code
---
001
Function
Indicates the end of a program.
END
Symbol
END(001)
Subroutines
Interrupt tasks
Usage
Not allowed
Not allowed
OK
Flags
There are no flags affected by this instruction.
Function
END(001) completes the execution of a program for that cycle. No instructions written after END(001)
will be executed.
Precautions
Always place END(001) at the end of each program. A programming error will occur if there is not an
END(001) instruction in the program.
2-38
2 Instructions
Instruction
NO OPERATION
Mnemonic
NOP
Variations
Function
code
---
000
NOP
Function
This instruction has no function.
NOP
Symbol
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Flags
NOP
Function
No processing is performed for NOP(000), but this instruction can be used to set aside lines in the
program where instructions will be inserted later.
NOP(000) can only be used with mnemonic displays, not with ladder programs.
Hint
When the instructions are inserted later, there will be no change in program addresses.
2-39
2 Instructions
IL/ILC
Instruction
Mnemonic
Variations
Function
code
Function
INTERLOCK
IL
---
002
INTERLOCK CLEAR
ILC
---
003
IL
Symbol
ILC
ILC(003)
IL(002)
Subroutines
Interrupt tasks
Usage
Not allowed
OK
OK
Flags
There are no flags affected by this instruction.
Function
When the execution condition for IL(002) is OFF, the outputs for all instructions between IL(002) and
ILC(003) are interlocked. When the execution condition for IL(002) is ON, the instructions between
IL(002) and ILC(003) are executed normally.
The following table shows the treatment of various outputs in an interlocked section between IL(002)
and ILC(003).
Instruction
Treatment
OFF
Completion Flag
OFF (reset)
PV
Note Bits and words in all other instructions including TTIM(087), TTIMX(555), SET, RSET, CNT, CNTX(546),
CNTR(012), CNTRX(548), SFT, and KEEP(011) retain their previous status.
Execution
condition ON
Execution
condition
Execution
condition OFF
IL
Interlocked section
of the program
Normal Outputs
execution interlocked.
ILC
2-40
2 Instructions
Hint
Sequence Control Instructions
IL
IL
Precautions
The cycle time is not shortened when a section of the program is interlocked because the interlocked
instructions are executed internally.
IL
a
IL
b
Execution
condition
a
b
OFF
ON
OFF
OFF
ON
OFF
ON
ON
Program section
A
Interlocked
Interlocked
Not interlocked
Not interlocked
B
Interlocked
Interlocked
Interlocked
Not interlocked
ILC
IL(002) and ILC(003) cannot be nested, as in the following diagram. (Use MILH(517)/MILR(518) and
MILC(519) when it is necessary to nest interlocks.)
IL
IL
ILC
ILC
2-41
IL/ILC
In general, IL(002) and ILC(003) are used in pairs, although it is possible to use more than one
IL(002) with a single ILC(003) as shown in the following diagram. If IL(002) and ILC(003) are not
paired, an error message will appear when the program check is performed but the program will be
executed properly.
2 Instructions
0.00
IL
1. When 0.00 is OFF (interlock starts), input condition 0.01 of DIFU is OFF.
2. Input condition 0.01 of DIFU goes from OFF to ON while 0.00 is OFF (interlock in effect),
3. When 0.00 goes from OFF to ON (interlock cleared), the DIFU instruction is executed if input condition 0.01 of DIFU is ON.
0.01
DIFU
10.00
ILC
Reference:
An IL(002) instruction operates in the same way as an MILH(517) instruction in relation to differentiated
instruction operation.
Timing Chart
Not interlocked
Interlocked
Not interlocked
ON
0.00
OFF
ON Differentiation condition is satisfied
ON
0.01
OFF
OFF
The DIFU(013) instruction is executed.
ON
10.00
OFF
1 cycle
2-42
2 Instructions
Sample program
0.00
0.00 ON
0.00 OFF
IL
0.01
2.00
OFF
0.02
H0
OFF
TIM
Outputs
interlocked
Normal
execution
Reset
IL/ILC
SET
Retained
0.03
CNT
Retained
ILC
2-43
2 Instructions
MILH/MILR/MILC
Instruction
Mnemonic
Variations
Function
code
Function
MILH
---
517
MILR
---
518
MULTI-INTERLOCK CLEAR
MILC
---
519
MILH
MILR
MILC
MILH(517)
MILR(518)
MILC(519)
Symbol
N: Interlock Number
N: Interlock Number
N: Interlock Number
Subroutines
Interrupt tasks
Usage
Not allowed
OK
OK
Operands
Operand
Description
Interlock number
Data type
Size
--
BOOL
--
N: Interlock Number
The interlock number must be between 0 and 15. Match the interlock number of the MILH(517) (or
MILR(518)) instruction with the same number in the corresponding MILC(519) instruction.
The interlock numbers can be used in any order.
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
---
---
---
---
OK
OK
OK
OK
DM
@DM
*DM
---
---
---
---
---
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Error Flag
2-44
Label
P_ER
Operation
OFF
2 Instructions
Function
Interlock Status
The following table shows the treatment of various outputs in an interlocked section between
MILH(517)/MILR(518) instruction and the next MILC(519).
Instruction
Bits specified in OUT, OUT NOT
OFF
Completion Flag
PV
OFF (reset)
Time set value (reset)
Note Bits and words in all other instructions including TTIM(087), TTIMX(555), SET, RSET, CNT, CNTX(546),
CNTR(012), CNTRX(548), SFT, and KEEP(011) retain their previous status.
Input condition ON
(Normal operation)
MILH
Input condition
n
d
Interlocked program
section
Normal
operation
Interlock
Status Bit
(d) ON
Outputs interlocked.
(Outputs OFF, timers
reset, etc.)
Interlock Status Bit (d)
OFF
MILC
n
Nesting
Interlocks are nested when an interlocked program section (MILH(517)/MILR(518) and MILC(519) combination) is placed within another interlocked program section (MILH(517)/MILR(518) and MILC(519)
combination). Interlocks can be nested up to 16 levels.
Nesting can be used for the following kinds of applications.
Example 1
Interlocking the entire program with one condition and interlocking a part of the program
with another condition (1 nesting level)
Global interlock
(Emergency stop)
A1 (Peripheral processing)
Partial interlock
(Conveyor RUN)
A2 (Conveyor operation)
2-45
MILH/MILR/MILC
Treatment
When the execution condition for MILH(517) (or MILR(518)) with interlock number N is OFF, the outputs
for all instructions between that MILH(517)/MILR(518) instruction and the next MILC(519) with interlock
number N are interlocked.
When the execution condition for MILH(517) (or MILR(518)) with interlock number N is ON, the instructions between that MILH(517)/MILR(518) instruction and the next MILC(519) with interlock number N
are executed normally.
2 Instructions
Global interlock
(Emergency stop)
MILH
A1 (Peripheral processing)
Partial interlock
(Conveyor RUN)
MILH
1
A2 (Conveyor operation)
MILC
1
MILC
0
Example 2
Global interlock
(Emergency stop)
A1 (Peripheral processing)
Partial interlock
(Conveyor RUN)
A2 (Conveyor operation)
Partial interlock
(Arm RUN)
A3 (Arm operation)
Global interlock
(Emergency stop)
MILH
0
A1 (Peripheral processing)
Partial interlock
(Conveyor RUN)
MILH
1
A2 (Conveyor operation)
Partial interlock
(Arm RUN)
MILH
2
A3 (Arm operation)
MILC
2
MILC
1
MILC
0
2-46
2 Instructions
Differentiated instructions (DIFU, DIFD, or instructions with a @ or % prefix) operate differently in interlocks created with MILH(517) and MILR(518).
When a program section is interlocked with MILR(518), a differentiated instruction will not be executed
when the interlock is cleared even if the differentiation condition was activated during the interlock
(comparing the status of the execution condition when the interlock started to its status when the interlock was cleared).
When a program section is interlocked with MILH(517), a differentiated instruction will be executed
when the interlock is cleared if the differentiation condition was activated during the interlock (comparing the status of the execution condition when the interlock started to its status when the interlock was
cleared).
Instruction
MILH(517)
MULTI-INTERLOCK DIFFERENTIATION HOLD
Not interlocked
Interlocked
Not interlocked
MILH
0
ON
0.00
OFF
,
1. When CIO 0.00 is OFF (interlock starts), the DIFU s CIO 0.01 input condition is OFF.
,
2. The DIFU s CIO 0.01 input condition goes from OFF to ON while CIO 0.00 is OFF (DIFU interlocked),
3. When CIO 0.00 goes from OFF to ON (interlock cleared), DIFU is executed if CIO 0.01 is still ON.
0.01
ON
Status (OFF) at
start of interlock
ON
0.01
OFF
DIFU
W0.0
MILC
0
OFF
MILH(517) interlock
ON
W0.0
OFF
1 cycle
2-47
2
MILH/MILR/MILC
MILR(518)
MULTI-INTERLOCK DIFFERENTIATION RELEASE
2 Instructions
0.00
MILR
0
Interlocked
Not interlocked
ON
0.00
OFF
,
1. When CIO 0.00 is OFF (interlock starts), the DIFU s CIO 0.01 input condition is OFF.
,
2. The DIFU s CIO 0.01 input condition goes from OFF to ON while CIO 0.00 is OFF (DIFU interlocked),
3. When CIO 0.00 goes from OFF to ON (interlock cleared), DIFU is not executed even though CIO 0.01 is still ON.
0.01
ON
ON
0.01
OFF
OFF
DIFU
W0.0
MILR(518) interlock
DIFU(013) is not executed.
ON
MILC
0
W0.0
OFF
ON
OFF
MILH
n
100.00
Program section
controlled by interlock
MILC
n
2-48
n
100.00
Program section
controlled by interlock
MILC
n
2 Instructions
Hint
When nesting interlocks, assign interlock numbers so that the nested program section does not
exceed the outer program section.
a
MILH
0
Execution
condition
a
b
OFF
ON
A1
ON
b
Program section
OFF
OFF
ON
A1
Interlocked
A2
Interlocked
A3
Interlocked
Not interlocked
Not interlocked
Interlocked
Not interlocked
Interlocked
Not interlocked
The cycle time is not shortened when a section of the program is interlocked by MILH(517) or
MILR(518) because the interlocked instructions are executed internally.
MILH
1
MILH/MILR/MILC
A2
MILC
0
A3
MILC
a
MILH
0
100.00
A1
b
MILH
1
100.01
A2
MILC
1
A3
MILC
a
MILH
0
A1
ILC
A2
MILC
2-49
2 Instructions
a
MILR
0
A1
ILC
A2
MILC
0
a
MILH
0
A1
b
MILH
A2
MILC
0
Note The MILR(518) interlocks operate in the same way if there is another MILH(517) or MILR(518) instruction
with the same interlock number between an MILR(518) and MILC(519) pair.
a
MILH
0
A1
MILC
1
A2
MILC
0
a
IL
A1
b
MILH
0
A2
ILC
IL
A1
MILC
0
A2
ILC
2-50
2 Instructions
a
MILH
A1
0
b
A2
A1
b
MILH
1
Program operation can be switched more efficiently by using interlocks with MILH(517) or MILR(518).
Instead of switching processing with compound conditions, insert an MILH(517) or MILR(518)
instruction before each process and an MILC(519) instruction after each process.
A2
MILC
1
Unlike the IL(002) interlocks, MILH(517) and MILR(518) interlocks can be nested, so the operation of
similar programs will be different if MILH(517) or MILR(518) is used instead of ILC(002).
Program with MILH(517)/MILC(519) Interlocks
a
MILH
0
100.00
A1
b
MILH
1
100.01
Execution
condition
a
b
OFF
ON
OFF
ON
OFF
ON
ON
Program section
A1
Interlocked
A2
Interlocked
A3
Not interlocked
Not interlocked
Not interlocked
Interlocked
Not interlocked
Not interlocked
Not interlocked
A2
MILC
1
A3
MILC
0
A1
b
Execution
condition
a
OFF
ON
ON
IL
A2
Program section
ON
A1
Interlocked
A2
Interlocked
OFF
OFF
ON
Not interlocked
Not interlocked
Interlocked
Not interlocked
A3
Not interlocked
(Not controlled
by the
IL(002)/ILC(003)
interlock.)
ILC
This program section is not
controlled by the interlock.
A3
ILC
This ILC(003)
instruction is ignored
so ...
If there are bits which you want to remain ON in a program section interlocked by MILH(517) or
MILR(518), set these bits to ON with SET just before the MILH(517) or MILR(518) instruction.
2-51
MILH/MILR/MILC
MILC
2 Instructions
Sample program
When W0.00 and W0.01 are both ON, the instructions between MILH(517) with interlock number 0 and
MILC(519) with interlock number 0 are executed normally.
When W0.00 is OFF, the instructions between MILH(517) with interlock number 0 and MILC(519) with
interlock number 0 are interlocked.
When W0.00 is ON and W0.01 are OFF, the instructions between MILH(517) with interlock number 1
and MILC(519) with interlock number 1 are interlocked. The other instructions are executed normally.
i
W0.00
W0.00 OFF
MILH
0
100.00
0.01
Executed
normally.
2.00
OFF
W0.01
MILH
1
100.01
0.02
H0
SET
Executed
normally.
OFF
Held
Outputs
interlocked.
Outputs
interlocked.
0.03
MILC
1
CNT
1
#0010
Held
Executed
normally.
MILC
0
2-52
2 Instructions
Instruction
Mnemonic
JUMP
Variations
JMP
---
Function
code
Function
004
CONDITIONAL JUMP
CJP
---
510
JUMP END
JME
---
005
JME
JME(005)
JMP(004)
N:Jump number
N: Jump number
Symbol
CJP
CJP(510)
N: Jump number
Subroutines
Interrupt tasks
Usage
Not allowed
OK
OK
Operands
Operand
Description
Data type
Size
UINT
Jump number
N: Jump Number
The jump number must be 0000 to 007F (&0 to &127 decimal).
Operand Specifications
Word addresses
Indirect DM addresses
Area
JMP/CJP N
JME
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
---
---
---
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
OK
---
---
---
Flags
JMP/CJP
Name
Error Flag
Label
P_ER
Operation
ON if N is not within the specified range of 0000 to 007F.
ON if there is a JMP(004) in the program without a JME(005) with the same jump number.
OFF in all other cases.
JME
There are no flags affected by this instruction.
2
JMP/CJP/JME
JMP
JMP/CJP/JME
2-53
2 Instructions
Function
JMP
When the execution condition for JMP(004) is
ON, no jump is made and the program is executed consecutively as written.
When the execution condition for JMP(004) is
OFF, program execution jumps directly to the
first JME(005) in the program with the same
jump number. The instructions between
JMP(004) and JME(005) are not executed, so
the status of outputs between JMP(004) and
JME(005) is maintained. In block programs, the
instructions between JMP(004) and JME(005)
are skipped regardless of the status of the execution condition.
CJP
Execution
condition OFF
Execution condition
ON OFF
JMP
Instructions
jumped
Instructions in this
section are not executed
and output status is
maintained. The
instruction execution time
for these instructions is
eliminated.
Instructions
executed
JME
N
Execution
condition ON
Instructions
jumped
CJP
N
Instructions
executed
JME
N
Hint
Because all of instructions between JMP(004)/CJP(510) and JME(005) are skipped when the execution condition for JMP(004) is OFF, the cycle time is reduced by the total execution time of the
skipped instructions. In contrast, processing time equivalent to NOP(000) processing is required for
instructions between JMP0(515) and JME0(516), so the cycle time is not reduced as much with those
jump instructions.
The following table compares the various jump instructions.
JMP(004)
JME(005)
Item
Execution condition for jump
Number allowed
OFF
128
Not executed.
CJP(510)
JME(005)
ON
None
Bits and words maintain their previous status.
Operating timers continue timing.
Always jump.
Precautions
All of the outputs (bits and words) in jumped instructions retain their previous status. Operating timers
(TIM, TIMX(550), TIMH(015), TIMHX(551), TMHH(540) and TMHHX(552)) continue timing because
the PVs are updated even when the timer instruction is not being executed.
2-54
2 Instructions
JME
N
Program section A is executed
repeatedly as long as
execution condition a is OFF.
Sample program
When CIO 0.00 is OFF in the right example,
the instructions between JMP(004) and
JME(005) are not executed and the outputs
maintain their previous status.
When CIO 0.00 is ON in the right example,
the instructions between JMP(004) and
JME(005) are executed normally.
0.00
JMP
&1 &1
CIO 0.00
ON
Normal
execution
TIM
CIO 0.00
OFF
Instructions
not executed.
(Outputs
remain
unchanged.)
SET
CNT
JME
&1
2-55
2
JMP/CJP/JME
When there are two or more JME(005) instructions with the same jump number, only the
instruction with the lower address will be valid.
The JME(005) with the higher program
address will be ignored.
2 Instructions
FOR/NEXT
Variations
Function
code
FOR
---
512
NEXT
---
513
Instruction
Mnemonic
Function
The instructions between FOR(512) and
NEXT(513) are repeated a specified number of
times.
---
FOR
NEXT
NEXT(513)
FOR(512)
Symbol
N: Number of loops
Subroutines
Interrupt tasks
Usage
---
OK
OK
Operands
Operand
Description
Data type
Size
UINT
Number of loops
N: Number of loops
The number of loops must be 0000 to FFFF (0 to 65,535 decimal).
Operand Specifications
Word addresses
Indirect DM addresses
Area
N
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
OK
---
---
---
Flags
Name
Label
Operation
Error Flag
P_ER
Equals Flag
P_EQ
OFF
Negative Flag
P_N
OFF
Function
The instructions between FOR(512) and NEXT(513)
are executed N times and then program execution continues with the instruction after NEXT(513). The
BREAK(514) instruction can be used to cancel the
loop.
If N is set to 0, the instructions between FOR(512) and
NEXT(513) are processed as NOP(000) instructions.
Loops can be used to process tables of data with a
minimum amount of programming.
2-56
FOR
Repeated N times
NEXT
2 Instructions
Hint
FOR-NEXT Loop with BREAK
Start a FOR-NEXT loop with a maximum of N repetitions. Program BREAK(514) within the loop with
the desired execution condition. The loop will end before N repetitions if the execution condition is
input.
JME(005)-JMP(004) Loop
Program a loop with JME(005) before JMP(004). The instructions between JME(005) and JMP(004)
will be executed repeatedly as long as the execution condition for JMP(004) is OFF. (A Cycle Time
Too Long error will occur if the execution condition is not turned ON or END(001) is not executed
within the maximum cycle time.)
Precautions
If a loop repeats in one cycle and a differentiated instruction is used in the FOR-NEXT loop, that
instruction will be executed only once.It is not executed the number of loops.
UP(521),DOWN(522)
DIFU(013),DIFD(014)
Differentiated up instruction(Differentiation variation:@)
Differentiated down instruction(Differentiation variation:%)
FOR-NEXT loops can be nested up to 15 levels.
FOR
&3
FOR
&2
NEXT
C
NEXT
2-57
FOR/NEXT
Program FOR(512) and NEXT(513) in the same task. Execution will not be repeated if these instructions are not in the same task.
There are two ways to repeat a program section until a given execution condition is input.
2 Instructions
FOR
FOR
&3 &3
&3
BREAK
a
FOR
Remaining
&2
instructions are
processed as
NEXT
NOP(000).
BREAK
NEXT
Breaks FOR-NEXT loop 1.
BREAK
NEXT
A jump instruction such as JMP(004) may be executed within a FOR-NEXT loop, but do not jump
beyond the FOR-NEXT loop.
The following instructions cannot be used within FOR-NEXT loops:
STEP DEFINE and STEP START: STEP(008)/SNXT(009)
Sample program
FOR
&3
Repeated 3 times.
MOV
D100
@D200
MOV
++
D100
D0
D200
D1
D2
NEXT
2-58
D200
#0000
#0000
2 Instructions
Instruction
BREAK LOOP
Mnemonic
Variations
BREAK
---
Function
code
514
Function
Programmed in a FOR-NEXT loop to cancel the
execution of the loop for a given execution condition. The remaining instructions in the loop are
processed as NOP(000) instructions.
BREAK
Symbol
BREAK(514)
BREAK
Subroutines
Interrupt tasks
Usage
---
OK
OK
BREAK
Area
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
OFF
Negative Flag
P_N
OFF
Function
Program BREAK(514) between FOR(512) and
NEXT(513) to cancel the FOR-NEXT loop
when BREAK(514) is executed. When
BREAK(514) is executed, the rest of the
instructions up to NEXT(513) are processed as
NOP(000).
Condition a ON
N repetitions
FOR
N
BREAK
Repetitions
forced to
end.
a
Processed as
NOP(000).
NEXT
Precautions
A BREAK(514) instruction cancels only one loop, so several BREAK(514) instructions (the number of
levels nested) are required to escape from nested loops.
BREAK(514) can be used only in a FOR-NEXT loop.
2-59
2 Instructions
Description
BCD
Binary
Setting range
Set value
0~9.999
#0000~9999
0~65.535
&0~65535 or #0000~FFFF
The PLC Setup for all of the timer/counter-related instructions. The refresh method is valid also when
setting an SV indirectly (i.e., using the contents of memory word). (That is, the contents of the
addressed word is taken as either BCD or binary data according to the refresh method that is set.)
Applicable Instructions
Classification
Timer/counter
instructions
Mnemonic
Instruction
BCD
Binary
HUNDRED-MS TIMER
TIM
TIMX(550)
TEN-MS TIMER
TIMH(015)
TIMHX(551)
ONE-MS TIMER
TMHH(540)
TMHHX(552)
ACCUMULATIVE TIMER
TTIM(087)
TTIMX(555)
LONG TIMER
TIML(542)
TIMLX(553)
COUNTER
CNT
CNTX(546)
REVERSIBLE COUNTER
CNTR(012)
CNTRX(548)
RESET TIMER/COUNTER
CNR(545)
CNRX(547)
TIM/TIMX
(550)
TIMH(015)/
TIMHX(551)
TMHH(540)/
TMHHX(552)
TTIM(087)/
TTIMX(555)
TIML(542)/
TIMLX(553)
Timing method
Decrementing
Decrementing
Decrementing
Incrementing
Decrementing
Timing units
100 ms
10 ms
1 ms
100 ms
100 ms
TIM: 999.9 s
TIMH: 99.99 s
TMHH: 9.999 s
TTIM: 999.9 s
TIML:115 days
TIMX: 6,553.5 s
TIMHX: 655.35 s
TMHHX: 65.535 s
TTIMX: 6,553.5 s
Outputs/instruction
Timer numbers
Used
Used
Used
Used
Not used
Timer PV refreshing
(See note)
Completion
Flags
OFF
OFF
OFF
OFF
OFF
PVs
SV
SV
SV
SV
Maximum SV
Value after
reset
2-60
2 Instructions
Item
TIM/TIMX
(550)
TIMH(015)/
TIMHX(551)
TMHH(540)/
TMHHX(552)
TTIM(087)/
TTIMX(555)
TIML(542)/
TIMLX(553)
PV = 0
Completion Flag = OFF
---
Power interrupt/reset
PV = 0
Completion Flag = OFF
---
Execution of CNR(545)/CNRX(547)
Not applicable
PV = SV
Completion Flag = OFF
PV = SV
Completion Flag =
OFF
Completion Flag
ON
---
PVs
Set to 0.
---
Completion
Flags
OFF
---
PVs
Reset to SV.
Forced set
Forced reset
Set to 0.
---
2-61
Operating Mode
2 Instructions
TIM
Instruction
Operands
0001
LD
0.00
#9000
TM
T0001
#9000
(900 seconds)
TIM
LD
0002
#9000
100.00
T0002
T0001
TM
2
#9000
LD
T000
OUT
100.00
(100 times)
0002
#0100
0.01
Instruction
Operands
LD
100.00
LD
0.01
CNT
2
#0100
0.00
100.00
C0002
LD
0.00
AND NOT
100.00
0001
AND NOT
C0002
#0050
TIM
TIM
Start
Count up
(5 seconds)
100.00
T0001
100.01
C0002
1
#0050
LD
T0001
OUT
100.00
LD
C0002
OUT
100.01
0.01
#0700
Instruction
Operands
LD
0.00
AND
1s
LD NOT
0.01
CNT
A200.11
1
#0700
C0001
C0001
2-62
100.02
100.02
2 Instructions
0.00
0.01
CNT
Instruction
(100 times)
0001
0.02
#0100
Operands
LD
0.00
AND
0.01
LD NOT
0.02
OR
C0001
OR
C0002
C0001
CNT
C0002
#0100
C0001
CNT
LD
C0001
LD NOT
0.02
(200 times)
CNT
#0200
#0200
100.03
C0002
0002
0.02
LD
C0002
OUT
100.03
Operands
0001
LD
0.00
#0050
TIM
TIM
5.00
1
#0050
0.00
TIM
0002
#0030
LD
5.00
LD NOT
0.00
TIM
2
#0030
T0001
LD
T0002
T0001
KEEP
LD
T0002
100.05
KEEP(011)
100.05
0.00
100.05
5.0 s
3.0 s
When an SV higher than 9999 is required, two counters can be combined as shown in the following
example. In this case, two CNT instructions are combined to make a BCD counter with an SV of
20,000.
2-63
2 Instructions
0.00
10.00
Instruction
0.00
LD
10.00
AND NOT
100.00
100.00
OR LD
--
OUT
10.00
0001
LD
10.00
#0015
TIM
10.00
TIM
(1.5seconds)
1
#0015
100.00
T0001
10.00
Operands
LD
100.04
100.00
LD
T0001
OUT
100.00
LD
10.00
AND NOT
100.00
OUT
100.04
0.00
100.04
1.5 s
1.5 s
T0002
Instruction
TIM
(1 second)
0001
#0010
Operands
LD
0.00
AND LD
T0002
TIM
1
#0010
2.05
TIM
0002
(1.5 seconds)
LD
TIM
100.05
2
#0015
#0015
T0001
2.05
LD
T0001
OUT
100.05
0.00
100.05
1.0 s
2-64
2 Instructions
2) Clock Pulse
0.00
0.00
100.06
Instruction
Operands
LD
0.00
AND
1s
OUT
100.06
1s
A
The desired execution condition can be combined with a clock pulse to mimic the clock pulse (0.1 s, 0.2
s, or 1.0 s).
100.06
A,B=0.5s
#100
Timer input
CIO 0.01
ON
OFF
Timer PV
T0010
Completion
Flag
T0010
2-65
2 Instructions
TIM/TIMX
Instruction
Mnemonic
HUNDRED-MS TIMER
Variations
Function
code
Function
---
550
TIM/TIMX
TIM
TIMX
BCD
Binary
TIMX(550)
TIM
Symbol
N:Timer number
S: Set value
N: Timer number
S: Set value
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
Operands
Data type
Operand
Description
Size
TIM
TIMX
Timer Number
TIMER
TIMER
Set Value
WORD
UINT
N: Timer Number
The timer number must be between 0000 and 0255 (decimal).
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
---
---
---
---
OK
OK
OK
OK
DM
@DM
CF
Pulse bits
TR bits
---
---
---
*DM
---
---
---
---
---
OK
OK
OK
OK
OK
OK
Flags
Name
Error Flag
Label
P_ER
Operation
ON if in BCD mode and S does not contain BCD data.
OFF in all other cases.
2-66
2 Instructions
When the timer input is OFF, the timer specified by N is reset, i.e., the timers PV is
reset to the SV and its Completion Flag is
turned OFF.
When the timer input goes from OFF to ON,
TIM/TIMX(550) starts decrementing the PV.
The PV will continue timing down as long as
the timer input remains ON and the timers
Completion Flag will be turned ON when
the PV reaches 0.
ON
OFF
Timer input
SV
Timer PV
0
Completion
Flag
ON
OFF
2
TIM/TIMX
The status of the timers PV and Completion Flag will be maintained after the timer
times out. To restart the timer, the timer
input must be turned OFF and then ON
again or the timers PV must be changed to
a non-zero value (by MOV(021), for example).
Function
ON
OFF
Timer input
SV
Timer PV
0
ON
OFF
Completion
Flag
Hint
A TIM/TIMX(550) instructions PV and Completion Flag can be refreshed in the following ways
depending on the timer number that is used.
Refresh timing
Execution of TIM/TIMX(550)
Description
The PV is updated every time that TIM/TIMX(550) is executed.
The Completion Flag is turned ON if the PV is 0.
The Completion Flag is turned OFF if the PV is not 0.
Execution
condition
1-s clock
pulse bit
Count input
CNT
N
Reset input
Precautions
Timer numbers are shared with other timer instructions. If two timers share the same timer number,
but are not used simultaneously, a duplication error will be generated when the program is checked,
but the timers will operate normally. Timers which share the same timer number will not operate properly if they are used simultaneously.
Timers will not operate properly when the CPU Unit cycle time exceeds 4s. Use timer instructions
when the cycle time is no longer than 4s.
Timers will be reset or paused in the following cases. (When a timer is reset, its PV is reset to the SV
and its Completion Flag is turned OFF.)
2-67
2 Instructions
Condition
PV
Completion Flag
OFF
OFF
BCD: 9999
Binary: FFFF
OFF
Reset to SV.
OFF
Retains previous
status.
Retains previous
status.
*1 If the IOM Hold Bit (A500.12) has been turned ON, the status of timer Completion Flags and PVs will be maintained when
the operating mode is changed.
*2 The PV will be set to the SV when TIM/TIMX(550) is executed.
When TIM/TIMX(550) is in a program section between IL(002) and ILC(003) and the program section
is interlocked, the PV will be reset to the SV and the Completion Flag will be turned OFF.
When an operating TIM/TIMX(550) timer is in a jumped program section (JMP(004), CJP(510),
JME(005)), the timers PV will not be refreshed.
When a TIM/TIMX(550) timer is forced set, its Completion Flag will be turned ON and its PV will be
set to 0000. When a TIM/TIMX(550) timer is forced reset, its Completion Flag will be turned OFF and
its PV will be reset to the SV.
The timers Completion Flag is refreshed only when TIM/TIMX(550) is executed, so a delay of up to
one cycle may be required for the Completion Flag to be turned ON after the timer times out.
If online editing is used to overwrite a timer instruction, always reset the Completion Flag. The timer
will not operate properly unless the Completion Flag is reset.
Sample program
When timer input CIO 0.00 goes from OFF to ON in the following example, the timer PV will begin
counting down from the SV. Timer Completion Flag T0000 will be turned ON when the PV reaches 0.
When CIO 0.00 goes OFF, the timer PV will be reset to the SV and the Completion Flag will be turned
OFF.
i
0.00
TIM
0000
or
#0100
0.00
TIMX
0000
&0100
Timer input
0.00
Timer PV
T0000
Timer
Completion
Flag
T0000
2-68
ON
OFF
ON
OFF
100
ON
OFF
2 Instructions
Variations
Function
code
TIMH
---
015
TIMHX
---
551
Instruction
Mnemonic
TEN-MS TIMER
Function
TIMH(015)/TIMHX(551) operates a decrementing
timer with units of 10-ms.
TIMH
TIMHX
BCD
Binary
TIMHX(551)
TIMH(015)
Symbol
N: Timer number
N: Timer number
S: Set value
S: Set value
Area
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
TIMH/TIMHX
Operands
Data type
Operand
Description
Size
TIMH
TIMHX
Timer Number
TIMER
TIMER
Set Value
WORD
UINT
N: Timer Number
The timer number must be between 0000 and 0255 (decimal).
S: Set Value
TIMH (BCD): #0000 to #9999
TIMHX (Binary): &0 to &65535 (decimal) or #0000 to #FFFF (hex)
Operand Specifications
Word addresses
Indirect DM addresses
Area
N
Constants
CIO
WR
HR
AR
---
---
---
---
DM
@DM
*DM
---
---
---
---
---
OK
OK
OK
OK
OK
OK
S
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
Flags
Name
Error Flag
Label
ER
Operation
ON if in BCD mode and S does not contain BCD data.
OFF in all other cases.
TIMH/TIMHX
2-69
2 Instructions
Function
When the timer input is OFF, the timer specified
by N is reset, i.e., the timers PV is reset to the
SV and its Completion Flag is turned OFF.
When the timer input goes from OFF to ON,
TIMH(015)/TIMHX(551) starts decrementing the
PV. The PV will continue timing down as long as
the timer input remains ON and the timers Completion Flag will be turned ON when the PV
reaches 0000.
The status of the timers PV and Completion Flag
will be maintained after the timer times out. To
restart the timer, the timer input must be turned
OFF and then ON again or the timers PV must
be changed to a non-zero value (by MOV(021),
for example).
The setting range for the set value (SV) is 0 to
99.99 s for TIMH(015) and 0 to 655.35 s for
TIMHX(551).
The timer accuracy is 0 to 0.01 s.
Timer input
ON
OFF
SV
Timer PV
0
Completion
Flag
ON
OFF
Timer input
ON
OFF
SV
Timer PV
0
Completion
Flag
ON
OFF
Hint
A TIMH(015)/TIMHX(551) instructions PV and Completion Flag can be refreshed in the following ways
depending on the timer number that is used.
Refresh timing
Execution of TIMH(015)/TIMHX(551)
Description
The PV is updated every time that TIMH(015)/TIMHX(551) is executed.
The Completion Flag is turned ON if the PV is 0.
The Completion Flag is turned OFF if the PV is not 0.
Precautions
Timer numbers are shared with other timer instructions. If two timers share the same timer number,
but are not used simultaneously, a duplication error will be generated when the program is checked,
but the timers will operate normally. Timers which share the same timer number will not operate properly if they are used simultaneously.
Timers will not operate properly when the CPU Unit cycle time exceeds 4s. Use timer instructions
when the cycle time is no longer than 4s.
Timers will be reset or paused in the following cases. (When a timer is reset, its PV is reset to the SV
and its Completion Flag is turned OFF.)
2-70
2 Instructions
PV
Completion Flag
OFF
OFF
BCD: 9999
Binary: FFFF
OFF
Reset to SV.
OFF
Retains previous
status.
Retains previous
status.
(JMP(004)-JME(005))
Condition
Operating mode changed from RUN or MONITOR mode
to PROGRAM mode or vice versa.*1
*1 If the IOM Hold Bit (A500.12) has been turned ON, the status of timer Completion Flags and PVs will be maintained when
the operating mode is changed.
When TIMH(015)/TIMHX(551) is in a program section between IL(002) and ILC(003) and the program section is interlocked, the PV will be reset to the SV and the Completion Flag will be turned
OFF.
When a TIMH(015)/TIMHX(551) timer is forced set, its Completion Flag will be turned ON and its PV
will be set to 0000. When a TIMH(015)/TIMHX(551) timer is forced reset, its Completion Flag will be
turned OFF and its PV will be reset to the SV.
The timers Completion Flag is refreshed only when TIMH(015)/TIMHX(551) is executed, so a delay
of up to one cycle may be required for the Completion Flag to be turned ON after the timer times out.
If online editing is used to overwrite a timer instruction, always reset the Completion Flag. The timer
will not operate properly unless the Completion Flag is reset.
Sample program
When timer input CIO 0.00 goes from OFF to ON in the following example, the timer PV will begin
counting down from the SV (#0064 = 100 = 1.00 s). The Timer Completion Flag, T0000, will be turned
ON when the PV reaches 0.
When CIO 0.00 goes OFF, the timer PV will be reset to the SV and the Completion Flag will be turned
OFF.
i
0.00
TIMH
0
#0100
Timer input
0.00
Timer PV
T0000 100
(1.00 s)
ON
OFF
100
0
or
0.00
TIMHX
Timer Completion
Flag
T0000
ON
OFF
0
&100
2-71
TIMH/TIMHX
2 Instructions
TMHH/TMHHX
Instruction
Variations
Function
code
TMHH
---
540
TMHHX
---
552
Mnemonic
ONE-MS TIMER
Function
TMHH(540)/TMHHX(552) operates a decrementing timer with units of 1-ms.
TMHH
TMHHX
BCD
Binary
TMHHX(552)
TMHH(540)
Symbol
N: Timer number
N: Timer number
S: Set value
S: Set value
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
Operands
Data type
Operand
Description
Size
TMHH
TMHHX
Timer Number
TIMER
TIMER
Set Value
WORD
UINT
N: Timer Number
The timer must be between 0000 and 0015 decimal.
S: Set Value
TMHH (BCD): #0000 to #9999
TMHHX (Binary): &0 to &65535 (decimal) or #0000 to #FFFF (hex)
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
---
---
---
---
DM
@DM
*DM
---
---
---
---
---
OK
OK
OK
OK
OK
OK
S
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if in BCD mode and S does not contain BCD data.
OFF in all other cases.
Function
When the timer input is OFF, the timer specified by N is reset, i.e., the timers PV is reset to the SV
and its Completion Flag is turned OFF.
When the timer input goes from OFF to ON, TMHH(540)/TMHHX(552) starts decrementing the PV.
The PV will continue timing down as long as the timer input remains ON and the timers Completion
Flag will be turned ON when the PV reaches 0000.
The status of the timers PV and Completion Flag will be maintained after the timer times out. To
restart the timer, the timer input must be turned OFF and then ON again or the timers PV must be
changed to a non-zero value (by MOV(021), for example).
2-72
2 Instructions
Hint
The timer PV and timeup used in TMHH/TMHHX instructions are refreshed at the timing below.
Refresh timing
When each instruction is executed
Description
The PV is updated every time that each instruction is executed.
The timeup flag is ON when the PV is 0 and OFF otherwise.
Precautions
The Completion Flag is updated only when TMHH(540)/TMHHX(552) is executed. The Completion
Flag can thus be delayed by up to one cycle time from the actual set value.
The present value of a timer will not be refreshed even if the task is on standby.
Timers will be reset or paused in the following cases. (When a timer is reset, its PV is reset to the SV
and its Completion Flag is turned OFF.)
Condition
PV
Completion Flag
OFF
OFF
BCD: 9999
Binary: FFFF
OFF
Reset to SV.
OFF
Retains previous
status.
Retains previous
status.
(JMP(004)-JME(005))
*1 If the IOM Hold Bit (A500.12) has been turned ON, the status of timer Completion Flags and PVs will be maintained when
the operating mode is changed.
*2 The PV will be set to the SV when TMHH(540)/TMHHX(552) is executed.
The present value of all operating timers will not be refreshed even if the timer is in a program section
that is jumped using JMP(004), CJP(510), JME(005).
When TMHH(540)/TMHHX(552) is in a program section between IL(002) and ILC(003) and the program section is interlocked, the PV will be reset to the SV and the Completion Flag will be turned
OFF.
When a TMHH(540)/TMHHX(552) timer is forced set, its Completion Flag will be turned ON and its
PV will be set to 0. When a TMHH(540)/TMHHX(552) timer is forced reset, its Completion Flag will be
turned OFF and its PV will be reset to the SV.
If online editing is used to overwrite a timer instruction, always reset the Completion Flag. The timer
will not operate properly unless the Completion Flag is reset.
2-73
2
TMHH/TMHHX
Timer numbers are shared with other timer instructions. If two timers share the same timer number,
but are not used simultaneously, a duplication error will be generated when the program is checked,
but the timers will operate normally. Timers which share the same timer number will not operate properly if they are used simultaneously.
The setting range for the set value (SV) is 0 to 9.999 s for TMHH(540) and 0 to 65.535 for
TMHHX(552).
2 Instructions
TTIM/TTIMX
Instruction
Variations
Function
code
TTIM
---
087
TTIMX
---
555
Mnemonic
ACCUMULATIVE TIMER
Function
TTIM(087)/TTIMX(555) operates an incrementing
timer with units of 0.1-s.
TTIM
TTIMX
BCD
Binary
Timer input
Timer input
TTIM(087)
Symbol
TTIMX(555)
N: Timer number
S: Set value
Reset input
N: Timer number
S: Set value
Reset input
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
Operands
Data type
Operand
Description
Size
TTIM
TTIMX
Timer Number
TIMER
TIMER
Set Value
WORD
UINT
N: Timer Number
The timer number must be between 0000 to 0255 (decimal).
S: Set Value
TTIM (BCD): #0000 to #9999
TTIMX (Binary): &0 to &65535 (decimal) or #0000 to #FFFF (hex)
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
---
---
---
---
OK
OK
OK
OK
DM
@DM
CF
Pulse bits
TR bits
---
---
---
*DM
---
---
---
---
---
OK
OK
OK
OK
OK
OK
Flags
Name
Error Flag
Label
P_ER
Operation
ON if in BCD mode and S does not contain BCD data.
OFF in all other cases.
2-74
2 Instructions
When
the
timer
input
is
ON,
TTIM(087)/TTIMX(555) increments the PV.
When the timer input goes OFF, the timer
will stop incrementing the PV, but the PV will
retain its value. The PV will resume timing
when the timer input goes ON again. The
timers Completion Flag will be turned ON
when the PV reaches the SV.
SV
Timer PV
Timing resumes.
PV maintained.
0
Completion
Flag
ON
OFF
Reset input
ON
OFF
2
TTIM/TTIMX
ON
OFF
Timer input
Hint
Typical timers such as TIM/TIMX(550) are decrementing counters and the PV shows the time remaining until the timer times out. The PV of TTIM(087)/TTIMX(555) shows how much time has elapsed,
so the PV can be used unchanged in many calculations and display outputs.
Precautions
Timer numbers are shared with other timer instructions. If two timers share the same timer number,
but are not used simultaneously, a duplication error will be generated when the program is checked,
but the timers will operate normally. Timers which share the same timer number will not operate properly if they are used simultaneously.
Timers will be reset or paused in the following cases. (When a TTIM(087)/TTIMX(555) timer is reset,
its PV is reset to 0 and its Completion Flag is turned OFF.)
Condition
PV
Completion Flag
OFF
OFF
BCD: 9999
Binary: FFFF
OFF
Retains previous
status.
Retains previous
status.
Retains previous
status.
Retains previous
status.
(JMP(004)-JME(005))
*1 If the IOM Hold Bit (A500.12) has been turned ON, the status of timer Completion Flags and PVs will be maintained when
the operating mode is changed.
*2 The PV will be set to the SV when TTIM(087)/TTIMX(555) is executed.
When TTIM(087)/TTIMX(555) is in a program section between IL(002) and ILC(003) and the program
section is interlocked, the PV will retain its previous value (it will not be reset). Be sure to take this fact
into account when TTIM(087)/TTIMX(555) is programmed between IL(002) and ILC(003).
When an operating TTIM(087)/TTIMX(555) timer is in a program section between JMP(004) and
JME(005) and the program section is jumped, the PV will retain its previous value. Be sure to take
this fact into account when TTIM(087)/TTIMX(555) is programmed between JMP(004) and
JME(005).
CP1E CPU Unit Instructions Reference Manual(W483)
Function
2-75
2 Instructions
When a TTIM(087)/TTIMX(555) timer is forced set, its Completion Flag will be turned ON and its PV
will be reset to 0. When a TTIM(087)/TTIMX(555) timer is forced reset, its Completion Flag will be
turned OFF and its PV will be reset to 0. The forced set and forced reset operations take priority over
the status of the timer and reset inputs.
The timers PV is refreshed only when TTIM(087)/TTIMX(555) is executed, so the timer will not operate properly when the cycle time exceeds 100 ms because the timer increments in 100-ms units.
The timers Completion Flag is refreshed only when TTIM(087)/TTIMX(555) is executed, so a delay of
up to one cycle may be required for the Completion Flag to be turned ON after the timer times out.
Sample program
When timer input CIO 0.00 is ON in the following example, the timer PV will begin counting up from 0.
Timer Completion Flag T0001 will be turned ON when the PV reaches the SV.
If the reset input is turned ON, the timer PV will be reset to 0 and the Completion Flag (T0001) will be
turned OFF. (Usually the reset input is turned ON to reset the timer and then the timer input is turned
ON to start timing.)
If the timer input is turned OFF before the SV is reached, the timer will stop timing but the PV will be
maintained. The timer will resume from its previous PV when the timer input is turned ON again.
0.00
0.00
TTIM
0001
0.01
Timer input
0.00
Timer PV
T0001
ON
OFF
#0100
TTIMX
0001
or
#0100
0.01
&0100
ON
OFF
#0100
Timing resumes.
PV maintained.
Timer Completion
Flag
T0001
Reset input
2-76
ON
OFF
ON
OFF
ON
OFF
ON
OFF
2 Instructions
Variations
Function
code
TIML
---
542
TIMLX
---
553
Instruction
Mnemonic
LONG TIMER
Function
TIML(542)/TIMLX(553) operates a decrementing
timer with units of 0.1s.
TIML
TIMLX
BCD
Binary
TIML(542)
Symbol
TIMLX(553)
D1
D1
D2
D2: PV word
D2
D2: PV word
S: SV word
TIML/TIMLX
Area
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
Operands
Data type
Description
Size
TIML
TIMLX
D1
Completion Flag
WORD
UINT
D2
PV word
DWORD
UDINT
SV word
DWORD
UDINT
15
D1
Do not use.
Completion Flag
D2: PV Word
D2+1
D2
D2
S: SV Word
S+1
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
OK
OK
OK
OK
D1,D2
S
---
---
OK
OK
DM
@DM
*DM
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
--OK
Flags
Name
Error Flag
Label
P_ER
Operation
ON if in BCD mode and D2 does not contained BCD data.
ON if in BCD mode and S does not contained BCD data.
OFF in all other cases.
S: SV word
Operand
TIML/TIMLX
2-77
2 Instructions
Function
When the timer input is OFF, the timer is
reset, i.e., the timers PV is reset to the SV
and its Completion Flag is turned OFF.
When the timer input goes from OFF to ON,
TIML(542)/TIMLX(553) starts decrementing
the PV in D2+1 and D2. The PV will continue timing down as long as the timer input
remains ON and the timers Completion
Flag will be turned ON when the PV
reaches 0.
Timer input
ON
OFF
SV
Timer PV
0
Completion Flag
(Bit 00 of D1)
ON
OFF
The status of the timers PV and Completion Flag will be maintained after the timer
times out. To restart the timer, the timer
input must be turned OFF and then ON
again or the timers PV must be changed to
a non-zero value (by MOV(021), for example).
TIML(542)/TIMLX(553) can time up to 115 days for TIML(542) and 4,971 days for TIMLX(553).
The timer accuracy is 0 to 0.01 s.
Precautions
Unlike most timers, TIML(542)/TIMLX(553) does not use a timer number. (Timer area PV refreshing
is not performed for TIML(542)/TIMLX(553).)
Since the Completion Flag for TIML(542)/TIMLX(553) is in a data area it can be forced set or forced
reset like other bits, but the PV will not change.
The timers PV is refreshed only when TIML(542)/TIMLX(553) is executed, so the timer will not operate properly when the cycle time exceeds 100 ms because the timer increments in 100-ms units.
The timers Completion Flag is refreshed only when TIML(542)/TIMLX(553) is executed, so a delay of
up to one cycle may be required for the Completion Flag to be turned ON after the timer times out.
When TIML(542)/TIMLX(553) is in a program section between IL(002) and ILC(003) and the program
section is interlocked, the PV will be reset to the SV and the Completion Flag will be turned OFF.
When an operating TIML(542)/TIMLX(553) timer is in a program section between JMP(004) and
JME(005) and the program section is jumped, the PV will retain its previous value. Be sure to take
this fact into account when TIML(542)/TIMLX(553) is programmed between JMP(004) and JME(005).
Be sure that the words specified for the Completion Flag and PV (D1, D2, and D2+1) are not used in
other instructions. If these words are affected by other instructions, the timer might not time out
properly.
2-78
2 Instructions
When timer input CIO 0.00 is ON in the following example, the timer PV (in D201 and D200) will be set
to the SV (in D101 and D100) and the PV will begin counting down. The timer Completion Flag (CIO
200.00) will be turned ON when the PV reaches 0.
When CIO 0.00 goes OFF, the timer PV will be reset to the SV and the Completion Flag will be turned
OFF.
0.00
TIML
D1
200
D2
D100
D200
ON
OFF
Timer input
Timer SV
S: D200 and up
S+1: Content of D201
1000.00
Sample program
Timer PV
(D101 and D100)
0
TIML/TIMLX
ON
Timer Completion
OFF
Flag
(CIO 200.00)
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D1:200
Timer Completion
Flag
(CIO 0200.00)
15
D2:D100
Timers PV (LSB)
D101
Timers PV (MSB)
D201
D200
#0010
#0000
Timer SV:
(100,000 decimal= 10,000 s)
2-79
2 Instructions
CNT/CNTX
Instruction
Mnemonic
COUNTER
Variations
Function
code
---
546
CNT/CNTX
Function
CNT/CNTX(546) operates a decrementing
counter.
CNT
CNTX
BCD
Binary
Count input
Count input
Symbol
CNTX(546)
CNT
Reset input
N: Counter number
S: Set value
Reset input
N: Counter number
S: Set value
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Description
Counter Number
Set Value
Size
CNT
CNTX
COUNTER
COUNTER
WORD
UINT
N: Counter Number
The counter number must be between 0000 and 0255 (decimal).
S: Set Value
CNT (BCD): #0000 to #9999
CNTX (Binary): &0 to &65535 (decimal) or #0000 to #FFFF (hex)
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
---
---
---
---
---
OK
OK
OK
OK
OK
DM
@DM
CF
Pulse bits
TR bits
*DM
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if in BCD mode and S does not contain BCD data.
OFF in all other cases.
2-80
2 Instructions
Function
ON
Count input
OFF
ON
Reset input
Counter PV
OFF
SV
0
Completion
Flag
ON
2
CNT/CNTX
Hint
Counter PVs are retained even through a
power interruption. If you want to restart
counting from the SV instead of resuming
the count from the retained PV, add the
First Cycle Flag (A200.11) as a reset input
to the counter.
CNT
N
S
Note 1 In case CP1E CPU Unit is backed up in the capacitor and power remained OFF for a period in excess of
the following, the Counters PVs and Countup Flags are unfixed.
E-type CPU Unit
9 hours (60C), 50 hours (25C)
N/NA-type CPU Unit
7 hours (60C), 40 hours (25C)
2 By setting Zero Clear Holding Memory for the PLC Setup, the Counters PVs and Countup Flags will be
cleared each time power turns ON. In this case, the DM area (D) and Holding Area (H) will be cleared at
the same time.
3 N/NA-type CP1E CPU Unit (CP1E-N/NAD-) can be equipped with a battery. With the battery
installed, the Counters PVs and Countup Flags can be retained during power OFF.
Precautions
Counter numbers are shared by the CNT, CNTX(546), CNTR(012) and CNTRX(548) instructions. If
two counters share the same counter number but are not used simultaneously, a duplication error will
be generated when the program is checked but the counters will operate normally. Counters which
share the same counter number will not operate properly if they are used simultaneously.
A counters PV is refreshed when the count input goes from OFF to ON and the Completion Flag is
refreshed each time that CNT/CNTX(546) is executed. The Completion Flag is turned ON if the PV is
0 and it is turned OFF if the PV is not 0.
2-81
2 Instructions
When a CNT/CNTX(546) counter is forced set, its Completion Flag will be turned ON and its PV will
be reset to 0000. When a CNT/CNTX(546) counter is forced reset, its Completion Flag will be turned
OFF and its PV will be set to the SV.
Be sure to reset the counter by turning the reset input from OFF ON OFF before beginning
counting with the count input, as shown in the following diagram. The count input will not be received
if the reset input is ON.
Reset input
ON
OFF
Count input
ON
OFF
SV
Counter PV
0
Completion ON
Flag
OFF
Ready to start
counting
The reset input will take precedence and the counter will be reset if the reset input and count input
are both ON at the same time. (The PV will be reset to the SV and the Completion Flag will be turned
OFF.)
ON
Reset input
OFF
ON
Count input
OFF
SV
Counter PV
0
Completion
Flag
ON
OFF
Count input Reset input Count input
can be
takes
can be
precedence. received.
received.
If online editing is used to add a counter, the counter must be reset before it will work properly. If the
counter is not reset, the previous value will be used as the counters present value (PV), and the
counter may not operate properly after it is written.
2-82
2 Instructions
Variations
Function
code
CNTR
---
012
CNTRX
---
548
Instruction
Mnemonic
REVERSIBLE COUNTER
CNTR/CNTRX
Function
---
CNTR
CNTRX
BCD
Binary
Increment input
Increment input
CNTR(012)
Symbol
Decrement input
Reset input
CNTRX(548)
N: Counter number
S: Set value
Decrement input
Reset input
N: Counter number
S: Set value
CNTR/CNTRX
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Description
Counter Number
Set Value
Size
CNTR
CNTRX
COUNTER
COUNTER
WORD
UINT
N: Counter Number
The counter number must be between 0000 and 0255(decimal).
S: Set Value
CNTR (BCD):#0000 to #9999
CNTRX (Binary): &0 to &65535 (decimal) or #0000 to #FFFF (hex)
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
---
---
---
---
---
OK
OK
OK
OK
OK
DM
@DM
CF
Pulse bits
TR bits
---
---
---
*DM
---
---
---
---
OK
OK
OK
OK
OK
Flags
Name
Error Flag
Label
P_ER
Operation
ON if in BCD mode and S does not contain BCD data.
OFF in all other cases.
2-83
2 Instructions
Function
The counter PV is incremented by 1 every
time that the increment input goes from OFF
to ON and it is decremented by 1 every time
that the decrement input goes from OFF to
ON. The PV can fluctuate between 0 and the
SV.
When incrementing, the Completion Flag will
be turned ON when the PV is incremented
from the SV back to 0 and it will be turned
OFF again when the PV is incremented from
0 to 1.
When decrementing, the Completion Flag will
be turned ON when the PV is decremented
from 0 up to the SV and it will be turned OFF
again when the PV is decremented from the
SV to SV-1.
Increment input
Decrement input
Counter PV
0
SV
Counter PV
0
Completion Flag
+1
ON
OFF
SV
-1
Counter PV
0
ON
Completion Flag
OFF
Precautions
Counter numbers are shared by the CNT, CNTX(546), CNTR(012) and CNTRX(548) instructions. If
two counters share the same counter number but are not used simultaneously, a duplication error will
be generated when the program is checked but the counters will operate normally. Counters which
share the same counter number will not operate properly if they are used simultaneously.
The PV will not be changed if the increment and decrement inputs both go from OFF to ON at the
same time. When the reset input is ON, the PV will be reset to 0 and both count inputs will be
ignored.
The Completion Flag will be ON only when the PV has been incremented from the SV to 0 or decremented from 0 to the SV; it will be OFF in all other cases.
When inputting the CNTR(012)/CNTRX(548) instruction with mnemonics, first enter the increment
input (II), then the decrement input (DI), the reset input (R), and finally the CNTR(012)/CNTRX(548)
instruction. When entering with the ladder diagrams, first input the increment input (II), then the
CNTR(012)/CNTRX(548) instruction, the decrement input (DI), and finally the reset input (R).
Sample program
The counter PV is reset to 0 by turning the reset input (CIO 0.02) ON and OFF. The PV is incremented
by 1 each time that the increment input (CIO 0.00) goes from OFF to ON. When the PV is incremented
from the SV (3), it is automatically reset to 0 and the Completion Flag is turned ON.
Likewise, the PV is decremented by 1 each time that the decrement input (CIO 0.01) goes from OFF to
ON. When the PV is decremented from 0, it is automatically set to the SV (3) and the Completion Flag
is turned ON.
2-84
2 Instructions
Increment input
0.01
Decrement
input
0.00
CNTR
0.02
0001
#0003
Increment input
0.00
Reset input
0.01
0.02
OFF
ON
Decrement input
OFF
0.01
or
0.00
ON
Increment input
Reset input
0.02
CNTRX
ON
OFF
0001
Decrement
input
&3
Counter PV
C0001
SV
3
0
Reset input
The add and subtract count inputs increase/decrease the count once when the signal rises (OFF to
ON). When both inputs turn ON at the same time, neither increases/decreases the count. When the
reset input turns ON, the PV changes to 0 and count input is not accepted.
In the following example, the SV for CNTR(012) 0007 is determined by the content of CIO 0001. When
the content of CIO 0001 is controlled by an external switch, the set value can be changed manually
from the switch.
0.00
CNTR
Fixed SV:
5000
0006
0.01
#5000
0.02
Instruction
Operands
LD
0.00
LD
0.01
LD
0.02
CNTR (012)
0006
LD
200.07
OUT
0.03
LD
0.04
#5000
200.07
C0006
0.03
CNTR
SV:
CIO 0001
0007
0.04
LD
0.05
LD
0007
CNTR (012)
LD NOT
C0007
OUT
200.08
0.05
200.08
C0007
4999 5000 0
Increment input
1
0 5000 4999
Decrement input
Completion Flag
Roll-over
Roll-over
2-85
CNTR/CNTRX
ON
Completion Flag
OFF
C0001
2 Instructions
CNR/CNRX
Instruction
Mnemonic
RESET TIMER/COUNTER
Function
code
Variations
CNR
@CNR
545
CNRX
@CNRX
547
Function
Resets the timers or counters within the specified
range of timer or counter numbers.
CNR
CNRX
BCD
Binary
CNRX(547)
CNR(545)
Symbol
N1
N1
N2
N2
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Description
Size
CNT
CNTX
N1
TIMER/COUNTER*1
Variable
N2
TIMER/COUNTER*1
Variable
Operand Specifications
Word addresses
Indirect DM addresses
Area
N1,N2
CIO
WR
HR
AR
DM
@DM
*DM
---
---
---
---
OK
OK
---
---
---
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if N1 and N2 are not in the same data area.
OFF in all other cases.
Function
CNR(545)/CNRX(547) resets the Completion Flags of all timers or counters from N1 to N2. At the same
time, the PVs will all be set to the maximum value (9999 for BCD and FFFF for binary). (The PV will be
set to the SV the next time that the timer or counter instruction is executed.)
2-86
2 Instructions
Binary
TIMX(550):
TIMHX(551):
TMHHX(552):
TTIMX(555):
CNTX(546):
CNTRX(548):
HUNDRED-MS TIMER
TEN-MS TIMER
ONE-MS TIMER
ACCUMULATIVE TIMER
COUNTER
REVERSIBLE COUNTER
Instructions reset
Operation of CNRX(547)
HUNDRED-MS TIMER
TEN-MS TIMER
ONE-MS TIMER
ACCUMULATIVE TIMER
COUNTER
REVERSIBLE COUNTER
The CNR(545)/CNRX(547) instructions do not reset TIML(542) and TIMLX(553), because these timers do not use timer numbers.
The CNR(545)/CNRX(547) instructions do not reset the timer/counter instructions themselves, they
reset the PVs and Completion Flags allocated to those instructions. In most cases, the effect of
CNR(545)/CNRX(547) is different from directly resetting the instructions. For example, when a
TIM/TIMX(550) instruction is reset directly its PV is set to the SV, but when that timer is reset by
CNR(545)/CNRX(547) its PV is set to the maximum value (9999 for BCD and FFFF for binary).
When N1 and N2 are specified with N1>N2, only the Completion Flag for the timer/counter number
will be reset.
Sample program
0.00
CNR
T0002
T0005
0.01
CNR
C0003
C0007
0.00
CNRX
T0002
T0005
0.01
CNRX
C0003
C0007
2-87
2
CNR/CNRX
BCD
Operation of CNR(545)
Precautions
2 Instructions
Comparison Instructions
=, <>, <, <=, >, >=
Instruction
Mnemonic
Function
code
Function
300 to 328
Variations
---
Mnemonic
S1
AND connection
S1: Comparison data 1
S2: Comparison data 2
Mnemonic
S1
S2
OR connection
S1: Comparison data 1
S2: Comparison data 2
Mnemonic
S1
S2
S2
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Description
Size
Unsigned
Unsigned
double length
Signed
Signed
double length
One-word
Double length
S1
Comparison data 1
UINT
UDINT
INT
DINT
S2
Comparison data 2
UINT
UDINT
INT
DINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
S1,S2
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR
bits
OK
---
---
---
Flags
Operation
Name
Label
Data length: one-word
Error Flag
P_ER
OFF or unchanged
P_GT
Equal Flag
2-88
P_GE
P_EQ
P_NE
OFF or unchanged
2 Instructions
Operation
Name
Label
Data length: one-word
P_LT
P_LE
Negative Flag
P_N
OFF or unchanged
OFF or unchanged
Function
LD connection
<
S1
S2
ON execution condition when
comparison result is true.
AND connection
<
Operation
LD
AND
OR
S1
S2
OR connection
<
S1
S2
Options
The input comparison instructions can compare signed or unsigned data and they can compare oneword or double values. If no options are specified, the comparison will be for one-word unsigned data.
With the three input types and two options, there are 72 different input comparison instructions.
Symbol
=
(Equal)
S: Signed data
L: Double-length data
(Less than)
(Greater than)
Function
True if C1 = C2
True if C1 C2
True if C1 < C2
Mnemonic
Name
Code
LD/AND/OR =
EQUAL
300
LD/AND/OR =L
DOUBLE EQUAL
301
LD/AND/OR =S
SIGNED EQUAL
302
LD/AND/OR =SL
303
LD/AND/OR <>
NOT EQUAL
305
LD/AND/OR <>L
306
LD/AND/OR <>S
307
LD/AND/OR <>SL
308
LD/AND/OR <
LESS THAN
310
LD/AND/OR <L
311
LD/AND/OR<S
312
LD/AND/OR <SL
313
2-89
Comparison Instructions
2 Instructions
Function
True if C1 C2
True if C1 > C2
True if C1 C2
Mnemonic
Name
Code
LD/AND/OR <=
LD/AND/OR<=L
315
316
LD/AND/OR <=S
317
LD/AND/OR <=SL
318
LD/AND/OR >
GREATER THAN
320
LD/AND/OR >L
321
LD/AND/OR >S
322
LD/AND/OR >SL
323
LD/AND/OR >=
325
LD/AND/OR >=L
326
LD/AND/OR >=S
327
LD/AND/OR>=SL
328
Unsigned input comparison instructions (i.e., instructions without the S option) can handle unsigned
binary or BCD data. Signed input comparison instructions (i.e., instructions with the S option) handle
signed binary data.
Hint
Unlike instructions such as CMP(020) and CMPL(060), the result of an input comparison instruction
is reflected directly as an execution condition, so it is not necessary to access the result of the comparison through an Arithmetic Flag and the program is simpler and faster.
Precautions
Input comparison instructions cannot be used as right-hand instructions, i.e., another instruction
must be used between them and the right bus bar.
Sample program
AND LESS THAN: AND<(310)
When CIO 0.00 is ON in the following example, the contents of D100 and D200 are compared in as
unsigned binary data. If the content of D100 is less than that of D200, CIO 100.00 is turned ON and
execution proceeds to the next line. If the content of D100 is not less than that of D200, the remainder
of the instruction line is skipped and execution moves to the next instruction line.
i
100.00
0.00
<
D100
D200
100.01
0.01
Unsigned
LESS THAN
Comparison
S2: D200
S1: D100
8714
3A1C
Decimal: 34,580
Decimal: 14,876
<S
D110
D210
0.00
<
D100
D200
100.01
0.01
<S
D110
Signed
LESS THAN
Comparison
S2: D210
S1: D110
8714
3A1C
Decimal: 30,956
Decimal: 14,876
D210
2-90
2 Instructions
Variations
Function
code
Function
---
341
342
343
344
345
346
=DT
<>DT
<DT
<=DT
>DT
>=DT
LD
AND
Symbol
S1
S2
C
S1
S2
Symbol
C: Control word
S1: First word of present time
S2: First word of comparison time
C
S1
S2
C: Control word
S1: First word of present time
S2: First word of comparison time
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Control word
WORD
S1
WORD
S2
WORD
C: Control Word
Bits 00 to 05 of C specify whether or not the time data will be masked for the comparison. Bits 00 to 05
mask the seconds, minutes, hours, day, month, and year, respectively. If all 6 values are masked, the
instruction will not be executed, the execution condition will be OFF, and the Error Flag will be turned
ON.
i
15
C
2-91
C: Control word
S1: First word of present time
S2: First word of comparison time
OR
Symbol
Symbol
Comparison Instructions
Instruction
2 Instructions
15
8 7
15
S1
8 7
S2
Seconds: 00 to 59 (BCD)
Seconds: 00 to 59 (BCD)
Minutes: 00 to 59 (BCD)
Minutes: 00 to 59 (BCD)
15
8 7
15
S1+1
8 7
S2+1
Hour: 00 to 23 (BCD)
Hour: 00 to 23 (BCD)
Day: 01 to 31 (BCD)
15
8 7
Day: 01 to 31 (BCD)
0
15
S1+2
8 7
S2+2
Month: 01 to 12 (BCD)
Month: 01 to 12 (BCD)
Year: 00 to 99 (BCD)
Year: 00 to 99 (BCD)
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
OK
OK
OK
OK
OK
OK
OK
@DM
C
S1, S2
CF
Pulse bits
TR bits
---
---
---
*DM
---
---
OK
OK
OK
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if all 6 of the mask bits (C bits 00 to 05) are ON.
OFF in all other cases.
P_GT
ON if S1 > S2.
OFF in all other cases.
P_GE
Equal Flag
P_EQ
ON if S1 S2.
OFF in all other cases.
ON if S1 = S2.
OFF in all other cases.
P_NE
ON if S1 S2.
OFF in all other cases.
P_LT
ON if S1 < S2.
OFF in all other cases.
P_LE
ON if S1 S2.
OFF in all other cases.
2-92
2 Instructions
Function
The time comparison instructions are treated just like the LD, AND, and OR instructions to control the
execution of subsequent instructions.
There are 18 possible combinations of time comparison instructions.
Any time values that are masked in the control word (C) are not included in the comparison.
Comparison Instructions
The time comparison instruction compares the unmasked values (corresponding bit of C set to 0) of the
present time data in S1 to S1+2 with the comparison time data in S2 to S2+2 and creates an ON execution condition when the comparison condition is true. At the same time, the result of a time comparison
instruction is reflected in the arithmetic flags (=, <>, <, <=, >, >=).
The following table shows the ON/OFF status of each flag for each comparison result.
Flag status
Result
=
<>
<
<=
>
>=
ON
OFF
OFF
ON
OFF
ON
OFF
ON
OFF
OFF
ON
ON
S1 < S2
OFF
ON
ON
ON
OFF
OFF
Comparison
S1
S2
Conditions Flags
(=, <>, <, <=, >, >=)
Result
08 07
Minute (00 to
59, BCD)
Second (00 to
59, BCD)
Year (00 to
S1+2 99, BCD)
00
Month (01 to
12, BCD)
15
S2
S2+1
00
Second (00 to
59, BCD)
Day of month
Hour (00 to
(01 to 31, BCD) 23, BCD)
Year (00 to
S2+2 99, BCD)
08 07
Minute (00 to
59, BCD)
Month (01 to
12, BCD)
Hint
Previous data comparison instructions compared data in 16-bit units. The time comparison instructions are limited to comparing 8-bit time values.
The following table shows the structure of the CPU Units internal Calendar/Clock Area.
Addresses
Contents
A351.00 to A351.07
A351.08 to A351.15
A352.00 to A352.07
A352.08 to A352.15
A353.00 to A353.07
A353.08 to A353.15
The Calendar/Clock Area can be set with a Programming Device (including a Programming Console), DATE(735) instruction, or CLOCK WRITE FINS command (0702 hex).
2-93
S1 = S2
S1 > S2
2 Instructions
Precautions
Time comparison instructions cannot be used as right-hand instructions, i.e., another instruction must
be used between them and the right bus bar.
E-type CP1E CPU Unit (CP1E-E-) does not have the clock function.
The clock data inside the CPU Unit is always 01-01-01 01:01:01.
Sample program
When CIO 0.00 is ON and the time is 13:00:00, CIO 100.00 is turned ON. The contents of A351 to
A353 (the CPU Units internal calendar/clock data) are used as the present time data and the contents
of D100 to D102 are used as the comparison time data. The year, month, and day values are masked,
so only the hour, minute, and second data are compared.
100.00
0.00
=DT
D0
D0
S1
A352
S2
D100
15
A351
8 7
Minute
Year
Second
S2:
D100
15
8 7
00
00
Hour
S2+1:D101
13
Month
S2+2:D102
2-94
2 Instructions
CMP/CMPL
Mnemonic
COMPARE
Variations
CMP
DOUBLE COMPARE
Function
code
Function
020
060
!CMP
CMPL
---
Comparison Instructions
Instruction
2
CMP
CMPL
CMPL(060)
S1
S1
S2
S2
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
CMP
CMPL
CMP
CMPL
S1
UINT
UDINT
S2
UINT
UDINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
S1, S2
Constants
CF
Pulse bits
TR bits
OK
---
---
---
Flags
Name
Operation
CX-Programmer
label
CMP
CMPL
Error Flag
P_ER
Unchanged
Unchanged
P_GT
ON if S1 > S2.
P_GE
ON if S1 S2.
Equal Flag
P_EQ
ON if S1 = S2.
P_NE
P_LT
P_LE
Negative Flag
P_N
ON if S1 S2.
ON if S1 < S2.
ON if S1 S2.
Unchanged
Unchanged
2-95
CMP/CMPL
CMP(020)
Symbol
2 Instructions
The following table shows the status of the Arithmetic Flags after execution of CMP(020).
Flag status
CMP(020) Result
>
>=
<=
<
<>
S 1 > S2
ON
ON
OFF
OFF
OFF
ON
S 1 = S2
OFF
ON
ON
ON
OFF
OFF
S 1 < S2
OFF
OFF
OFF
ON
ON
ON
Unsigned binary
comparison
S1
S2
Arithmetic Flags
(>, >=, =, <=, <, <>)
The following table shows the status of the Arithmetic Flags after execution of CMPL(060).
Flag status
CMPL(060) Result
>
>=
<=
<
<>
ON
ON
OFF
OFF
OFF
ON
S1+1, S1 = S2+1, S2
OFF
ON
ON
ON
OFF
OFF
OFF
OFF
OFF
ON
ON
ON
Unsigned binary
comparison
S1+1
S1
S2+1
S2
Arithmetic Flags
(>, >=, =, <=, <, <>)
Function
CMP
CMP(020) compares the unsigned binary data in S1 and S2 and outputs the result to Arithmetic Flags
(the Greater Than, Greater Than or Equal, Equal, Less Than or Equal, Less Than, and Not Equal
Flags) in the Auxiliary Area.
CMPL
CMPL(060) compares the unsigned binary data in S1 +1, S1 and S2+1, S2 and outputs the result to
Arithmetic Flags (the Greater Than, Greater Than or Equal, Equal, Less Than or Equal, Less Than, and
Not Equal Flags) in the Auxiliary Area.
2-96
2 Instructions
Precautions
S2
Comparison Instructions
CMP
S1
Arithmetic Flag
(Example: Equal Flag)
CMPL
S1
S2
Instruction B
A
Arithmetic Flag
(Example: Equal Flag)
In this case, the results of instruction B might
change the results of CMP(020).
The immediate-refreshing variation (!CMP(020)) can be used with words allocated to CPU Unit builtin inputs specified in S1 and/or S2. When !CMP(020) is executed, input refreshing will be performed
for the external input word specified in S1 and/or S2 and that refreshed value will be compared.
Sample program
When CIO 0.00 is ON in the following example, the eight-digit unsigned binary data in CIO 0011 and
CIO 0010 is compared to the eight-digit unsigned binary data in CIO 0009 and CIO 0008 and the
result is output to the Arithmetic Flags. The results recorded in the Greater Than, Equals, and Less
Than Flags are immediately saved to CIO 20.00 (Greater Than), CIO 20.01 (Equals), and CIO 20.02
(Less Than).
i
0.00
CMPL
S1+1=11CH
S1=10CH
10
1234
5678
Comparison
20.00
>
S2+1=9CH
S2=8CH
ABCD
EF12
Flag status
Result
>
OFF (0)
OFF (0)
<
ON (1)
20.01
=
20.02
<
2-97
CMP/CMPL
2 Instructions
CPS/CPSL
Instruction
Mnemonic
Variations
CPS
Function
code
Function
114
115
Compares two double signed binary values (constants and/or the contents of specified words) and
outputs the result to the Arithmetic Flags in the
Auxiliary Area.
!CPS
CPSL
---
CPS
CPSL
CPS(114)
Symbol
CPSL(115)
S1: Comparison data 1
S1
S1
S2
S2
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
CPS
CPSL
CPS
CPSL
S1
INT
DINT
S2
INT
DINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
S1, S2
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse
bits
TR
bits
OK
---
---
---
Flags
Operation
Name
Label
CPS
CPSL
Error Flag
P_ER
Unchanged
OFF or unchanged
P_GT
ON if S1 > S2.
P_GE
Equal Flag
P_EQ
P_NE
ON if S1 S2.
ON if S1 = S2.
ON if S1 S2.
ON if S1 < S2.
P_LT
P_LE
ON if S1 S2.
Negative Flag
P_N
Unchanged
OFF or unchanged
2-98
2 Instructions
The following table shows the status of the Arithmetic Flags after execution of CPS(114).
Flag status
Result
>=
<=
<
<>
ON
ON
OFF
OFF
OFF
ON
S1 = S2
OFF
ON
ON
ON
OFF
OFF
S1 < S2
OFF
OFF
OFF
ON
ON
ON
Comparison Instructions
>
S1 > S2
Signed binary
comparison
S1
S2
Arithmetic Flags
(>, >=, =, <=, <, <>)
The following table shows the status of the Arithmetic Flags after execution of CPSL(115).
CPS/CPSL
Flag status
Result
>
>=
<=
<
<>
ON
ON
OFF
OFF
OFF
ON
S1+1, S1 = S2+1, S2
OFF
ON
ON
ON
OFF
OFF
OFF
OFF
OFF
ON
ON
ON
Signed binary
comparison
S1+1
S1
S2+1
S2
Arithmetic Flags
(>, >=, =, <=, <, <>)
Function
CPS
CPS(114) compares the signed binary data in S1 and S2 and outputs the result to Arithmetic Flags (the
Greater Than, Greater Than or Equal, Equal, Less Than or Equal, Less Than, and Not Equal Flags) in
the Auxiliary Area.
CPSL
CPSL(115) compares the double signed binary data in S1 +1, S1 and S2+1, S2 and outputs the result to
Arithmetic Flags (the Greater Than, Greater Than or Equal, Equal, Less Than or Equal, Less Than, and
Not Equal Flags) in the Auxiliary Area.
2-99
2 Instructions
Precautions
When CPS(114)/CPSL(115) is executed, the result is reflected in the Arithmetic Flags. Control the
desired output or right-hand instruction with a branch from the same input condition that controls
CPS(114)/CPSL(115), as shown in the following diagram.
CPS/CPSL
S1
S2
A
Arithmetic Flag
(Example: Equal Flag)
In this case, the Equals Flag and output A will be turned
ON when S1 = S2 or S1 +1, S1 = S2+1, S2.
Do not program another instruction between CPS(114)/CPSL(115) and the instruction controlled by
the Arithmetic Flag because the other instruction might change the status of the Arithmetic Flag.
CPS/CPSL
S1
S2
Instruction B
A
Arithmetic Flag
(Example: Equal Flag)
In this case, the results of instruction B might
change the results of CPS(114)/CPSL(115).
Sample program
When CIO 0.00 is ON in the following example, the eight-digit signed binary data in D2 and D1 is compared to the eight-digit signed binary data in D6 and D5 and the result is output to the Arithmetic Flags.
If the content of D2 and D1 is greater than that of D6 and D5, the Greater Than Flag will be turned
ON, causing CIO 20.00 to be turned ON.
If the content of D2 and D1 is equal to that of D6 and D5, the Equals Flag will be turned ON, causing
CIO 20.01 to be turned ON.
If the content of D2 and D1 is less than that of D6 and D5, the Less Than Flag will be turned ON,
causing CIO 20.02 to be turned ON.
i
0.00
CPSL
D2
D1
1234
5678
D1
D5
20.00
Comparison
D6
D5
ABCD
EF12
Flag status
Result
>
ON (1)
OFF (0)
<
OFF (0)
>
20.01
=
20.02
<
2-100
2 Instructions
TCMP
Mnemonic
TABLE COMPARE
Variations
TCMP
Function
code
Function
085
@TCMP
TCMP
TCMP(085)
Symbol
2
S: Source data
R: Result word
TCMP
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Source data
WORD
WORD
16
Result word
UINT
Comparison data 0
T+1
Comparison data 1
to
R: Result word
15 14
R
Comparison result for S and T
to
Comparison data 15
T+15
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
T, R
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Comparison Instructions
Instruction
2-101
2 Instructions
Function
Comparison
S
T
T+1
14
15
Sample program
When CIO 0.00 is ON in the following example, TCMP(085) compares the content of D100 with the
contents of words D200 through D215 and turns ON the corresponding bits in D300 when the contents
are equal or OFF when the contents are not equal.
R: D300
Comparison
0.00
TCMP
S
T
D
2-102
D100
D200
D300
S: D100
0 2 A 1
D201
D202
D203
0 3 A 1
D204
D205
0 2 A 1
D206
D207
D208
9 A B C
D209
D E F 0
D210
0 3 A 1
10
D211
11
D212
12
D213
9 A B C
13
D214
D E F 0
14
D215
0 3 A 1
15
T: D200
2 Instructions
BCMP
Mnemonic
BLOCK COMPARE
Variations
BCMP
Function
code
Function
068
@BCMP
BCMP
BCMP(068)
Symbol
S: Source data
B: First word of block
R: Result word
BCMP
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Source data
WORD
WORD
32
Result word
UINT
R: Result word
15
14
B+1
B+2
B+3
B+30
B+31
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
CF
Pulse bits
TR bits
---
---
---
*DM
S
B
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Comparison Instructions
Instruction
2-103
2 Instructions
Function
BCMP(068) compares the source data (S) to the 16 ranges defined by pairs of lower and upper limit
values in B through B+31. The first word in each pair (B+2n) provides the lower limit and the second
word (B+2n+1) provides the upper limit of range n (n = 0 to 15). If S is within any of these ranges (inclusive of the upper and lower limits), the corresponding bit in R is turned ON. If S is out of any these
ranges, the corresponding bit in R is turned OFF.
1 when inside the range
0 when outside of range
Lower limit value Upper limit value
R
B
B+1
0
Inside the range?
Comparison
data
B+2
B+3
B+28
B+29
14
B+30
B+31
15
Sample program
When CIO 0.00 is ON in the following example, BCMP(068) compares the content of D100 with the 16
ranges defined in D200 through D231 and turns ON the corresponding bits in D300 when S is within the
range or OFF when S is not within the range.
0.00
BCMP
D100
D200
R: D300
D300
S:D100
2-104
03A0
D200
0 3 A 1
to
D201
D202
to
D203
D204
to
D205
D206
0 3 A 1
to
D207
D208
0 3 A 0
to
D209
D210
to
D211
D212
to
D213
D214
0 3 A 1
to
D215
D216
to
D217
D218
to
D219
0 3 A 0
D220
to
D221
10
D222
0 3 A 1
to
D223
11
D224
to
D225
12
D226
to
D227
13
D228
0 3 A 1
to
D229
14
D230
to
D231
15
2 Instructions
ZCP/ZCPL
Mnemonic
Variations
ZCP
---
ZCPL
---
Function
code
Function
088
116
Comparison Instructions
Instruction
2
ZCP
ZCPL
ZCPL(116)
CD
CD
LL
UL
LL
UL
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
ZCP: Comparison data (one word of data)
CD
LL
UL
CMP
CMPL
CMP
CMPL
UINT
UDINT
UINT
UDINT
UINT
UDINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CD, LL, UL
Constants
CF
Pulse bits
TR bits
OK
---
---
---
Flags
Operation
Name
Label
ZCP
ZCPL
Error Flag
P_ER
ON if LL > UL.
P_GT
ON if CD > UL.
P_GE
Left unchanged.
Left unchanged.
Equal Flag
P_EQ
ON if LL CD UL.
P_NE
Left unchanged.
Left unchanged.
P_LT
ON if CD < LL.
P_LE
Left unchanged.
Left unchanged.
Negative Flag
P_N
Left unchanged.
Left unchanged.
2-105
ZCP/ZCPL
ZCP(088)
Symbol
2 Instructions
Function
ZCP
ZCP(088) compares the 16-bit signed binary data in CD with the range defined by LL and UL and outputs the result to the Greater Than, Equals, and Less Than Flags in the Auxiliary Area. (The Less Than
or Equal, Greater Than or Equal, and Not Equal Flags are left unchanged.)
When CD > UL as shown below, the > flag turns ON.
When LL CD UL, the = flag turns ON. When CD < LL, the < flag turns ON.
Flag status
ZCP(088)Result
>
CD > UL
ON
OFF
CD = UL
OFF
ON
<
OFF
LL < CD < UL
CD = LL
CD < LL
OFF
ON
ZCPL
ZCPL(116) compares the 32-bit signed binary data in CD+1, CD with the range defined by LL+1, LL
and UL+1, UL and outputs the result to the Greater Than, Equals, and Less Than Flags in the Auxiliary
Area. (The Less Than or Equal, Greater Than or Equal, and Not Equal Flags are left unchanged.)
When CD+1,CD > UL+1,UL as shown below, the > flag turns ON.
When LL+1,LL CD+1, CD UL+1, UL, the = flag turns ON.
When CD+1, CD < LL+1, LL, the < flag turns ON.
Flag status
ZCPL(116)Result
>
ON
OFF
CD+1, CD = UL+1, UL
OFF
ON
<
OFF
OFF
ON
Precautions
When ZCP(088)/ZCPL(116) is executed, the result is reflected in the Arithmetic Flags. Control the
desired output or right-hand instruction with a branch from the same input condition that controls
ZCP(088)/ZCPL(116), as shown in the following diagram.
ZCP
CD
LL
UL
A
Arithmetic Flag
(Example: Equal Flag)
In this case, the Equals Flag and output A will be
turned ON when LL
2-106
CD UL.
2 Instructions
Do not program another instruction between ZCP(088)/ZCPL(116) and the instruction controlled by
the Arithmetic Flag because the other instruction might change the status of the Arithmetic Flag.
Comparison Instructions
ZCPL
CD
LL
UL
Instruction B
A
Arithmetic Flag
(Example: Equal Flag)
In this case, the results of instruction B
might change the results of ZCP(088)/ZCPL(116).
When CIO 0.00 is ON in the following example, the 16-bit unsigned binary data in D0 is compared to
the range 0005 to 001F hex (5 to 31 decimal) and the result is output to the Arithmetic Flags.
CIO 20.00 is turned ON if 0005 hex content of D0 001F hex.
CIO 20.01 is turned ON if the content of D0 > 001F hex.
CIO 20.02 is turned ON if the content of D0 < 0005 hex.
0.00
ZCP
CD
D0
LL
#0005
UL
#001F
LL
CD
UL
Arithmetic Flags
D0
0005Hex
001FHex
ON(1)
> 001FHex
>
ON(1)
<
ON(1)
D0
20.00
D0
0005Hex >
=
20.01
>
20.02
<
2-107
ZCP/ZCPL
Sample program
2 Instructions
Mnemonic
Variations
Function
code
Function
MOVE
MOV
@MOV, !MOV,
!@MOV
021
DOUBLE MOVE
MOVL
@MOVL
498
MOVE NOT
MVN
@MVN
022
MOV
MOVL
MOVL(498)
MOV(021)
S
S: Source
D: Destination
D: First destination
word
Symbol
MVN
MVN(022)
S
S: Source
D: Destination
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
MOV / MVN: Source
MOV / MVN
MOVL
MOV / MVN
MOVL
WORD
DWORD
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equal Flag
P_EQ
Negative Flag
P_N
2-108
2 Instructions
Function
Data Movement Instructions
MOV
MOVL
MOVL(498) transfers S+1 and S to D+1 and
D. If S+1 and S are constants, the value can
be used for a data setting.
MVN
S+1
D+1
S
Bit status
inverted.
1
0
MOV/MOVL/MVN
0
1
Precautions
MOV(021) has an immediate refreshing variation (!MOV(021)). A CPU Unit Built-in input bits can be
specified for S and external output bits can be specified for D. Input bits used for S will refreshed just
before, and output bits used for D will be refreshed just after execution.
When CPU Unit Built-in input is specified for S, the value of S will be in-refreshed when the instruction
is executed and transferred to D. When external output is specified for D, the value of S will be transferred to D and immediately out-refreshed when the instruction is executed. It is also possible to inrefresh S and out-refresh D at the same time.
Sample program
When CIO 0.00 is ON in the following example, the content of CIO 100 is copied to D100.
0.00
MOV
100
D100
100CH
D100
2-109
2 Instructions
When CIO 0.00 is ON in the following example, the content of D101 and D100 are copied to D201 and
D200.
0.00
MOVL
D100
D200
D100
D200
D101
D201
0.01
MOV
#1234
12 11
15
D10
D10
8 7
2
4 3
3
0
4
(Hexadecimal 1234)
0.02
MOV
+1234
12 11
15
D11
D11
8 7
4
4 3
D
0
(Decimal 1234)
0.03
MOV
-1234
12 11
15
D12
D12
8 7
B
4 3
2
0
E
(Decimal -1234)
When CIO 0.00 is ON in the following example, the status of the bits in CIO 100 is inverted and the
result is copied to D100.
0.00
MVN
100
D100
100CH
D100
2-110
1001
0010
0000
1101
0110
1101
1111
0010
2 Instructions
Instruction
Mnemonic
MOVE BIT
Function
code
Variations
MOVB
@MOVB
082
MOVB
Function
Transfers the specified bit.
MOVB
MOVB(082)
Symbol
C: Control word
D: Destination word
Area
Subroutines
Interrupt tasks
Usage
OK
OK
OK
MOVB
Operands
Operand
Description
Control word
Destination word
Data type
Size
WORD
UINT
WORD
C: Control Word
15
8 7
n
Source bit: 00 to 0F
(0 to 15 decimal)
Destination bit: 00 to 0F
(0 to 15 decimal)
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
S, C
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the rightmost and leftmost two digits of C are not within the specified range of 00 to 0F.
OFF in all other cases.
2-111
2 Instructions
Function
MOVB(082) copies the specified bit (n) from S
to the specified bit (m) in D.
n
S
m
D
Hint
The same word can be specified for both S and D to copy a bit within a word.
Precautions
The other bits in the destination word are left unchanged.
Sample program
When CIO 0.00 is ON in the following example, the 5th bit of the source word (W0) is copied to the 12th
bit of the destination word (W100) in accordance with the control words value of 0C05.
0.00
MOVB
S
W0
D200
W100
8 7
15
C:D200
8 7
15 14
0C
0
05
1 0
S:W0
15 14
12
8 7
1 0
D:W100
2-112
2 Instructions
Instruction
Mnemonic
MOVE DIGIT
Function
code
Variations
MOVD
@MOVD
MOVD
Function
Transfers the specified digit or digits.
(Each digit is made up of 4 bits.)
083
MOVB
MOVD(083)
Symbol
C: Control word
D: Destination word
2
MOVD
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
C
D
Data type
Control word
UINT
Destination word
UINT
S: Source Word
D: Destination Word
12 11
15
S
Size
WORD
Digit 3
8 7
Digit 2
4 3
Digit 1
15
0
D
Digit 0
Digit 3
12 11
8 7
Digit 2
4 3
Digit 1
0
Digit 0
C: Control Word
15
C
12 11
8 7
4 3
0
m
First digit in D ( ): 0 to 3
Always 0.
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
S, C
CF
Pulse bits
TR bits
---
---
---
OK
---
2-113
2 Instructions
Flags
Name
Label
Error Flag
Operation
P_ER
ON if one of the first three digits of C is not within the specified range of 0 to 3.
OFF in all other cases.
Function
MOVB(082) copies the specified bit (n) from S
to the specified bit (m) in D. The other bits in
the destination word are left unchanged.
12 11
15
C
8 7
R
4 3
n
0
m
n
m
S
R
D
Precautions
If the number of digits being read or written exceeds the leftmost digit of S or D, MOVD(083) will wrap to
the rightmost digit of the same word.
Sample program
When CIO 0.00 is ON in the following example, four digits of data are copied from W0 to W100. The transfer begins with the digit 1 of W0 and digit 0 of W100, in accordance with the control words value of 31.
0.00
MOVD
S
W0
D300
W100
12 11
15
C:D300
8 7
0
4 3
3
0
1
Digit no.
2
12 11
15
1
8 7
0
4 3
S: W0
Digit no.
12 11
15
D: W100
8 7
1
4 3
2
0
3
Note After reading the leftmost digit of S (digit 3), MOVD(083) wraps to the rightmost digit (digit 0).
2-114
C30
C312
C230
Digit 0
Digit 0
Digit 0
Digit 0
Digit 0
Digit 0
Digit 0
Digit 0
Digit 1
Digit 1
Digit 1
Digit 1
Digit 1
Digit 1
Digit 1
Digit 1
Digit 2
Digit 2
Digit 2
Digit 2
Digit 2
Digit 2
Digit 2
Digit 2
Digit 3
Digit 3
Digit 3
Digit 3
Digit 3
Digit 3
Digit 3
Digit 3
2 Instructions
Instruction
Mnemonic
Function
code
Variations
XFRB
@XFRB
Function
Transfers the specified number of consecutive
bits.
062
XFRB
XFRB(062)
Symbol
C: Control word
2
XFRB
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Control word
S
D
Data type
WORD
Variable
WORD
Variable
C: Control Word
8 7
Size
UINT
15
n
4 3
15
to
First bit in S ( ): 0 to F
(0 to 15)
First bit in D (m): 0 to F
(0 to 15)
D+16 max.
Note The source words and the destination words must be in the same data area respectively.
to
S+16 max.
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
S, D
---
Flags
Name
Error Flag
Label
P_ER
XFRB
Operation
OFF
2-115
2 Instructions
Function
XFRB(062) transfers up to 255 consecutive
bits from the source words (beginning with bit
l of S) to the destination words (beginning with
bit m of D).
The beginning bits and number of bits are
specified in C, as shown in the following diagram.
15
8 7
4 3
m
0
l
n
l
S
m
D
Hint
Up to 255 bits of data can be transferred per execution of XFRB(062).
It is possible for the source words and destination words to overlap. By transferring data overlapping
several words, the data can be packed more efficiently in the data area. (This is particularly useful
when handling position data for position control.)
Since the source words and destination words can overlap, XFRB(062) can be combined with
ANDW(034) to shift m bits by n spaces.
Precautions
Be sure that the source words and destination words do not exceed the end of the data area.
When the number of transfer bits (n of C) is 0, transfer does not take place.
Bits in the destination words that are not overwritten by the source bits are left unchanged.
Sample program
When CIO 0.00 is ON in the following example, the 20 bits beginning with W0.06 are copied to the 20
bits beginning with W100.
0.00
XFRB
C
D100
W0
W100
15
8 7
C:D100
4 3
0
0
6
20 bits
1514
8 76 5 4 3 2 1 0
S:W0
W1
15
D:W100
W101
2-116
2 Instructions
Instruction
Mnemonic
BLOCK TRANSFER
Function
code
Variations
XFER
@XFER
Function
Transfers the specified number of consecutive
words.
070
XFER
XFER
XFER(070)
Symbol
N: Number of words
2
XFER
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Number of words
UINT
WORD
Variable
WORD
Variable
N: Number of Words
Specifies the number of words to be transferred. The possible range for N is 0000 to FFFF (0 to
65,535 decimal).
15
15
to
S+(N-1)
D
to
D+(N-1)
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
S, D
---
Flags
Name
Error Flag
Label
P_ER
Operation
OFF
2-117
2 Instructions
Function
XFER(070) copies N words beginning with S
(S to S+(N-1)) to the N words beginning with
D (D to D+(N-1)).
D
N words
S+(N-1)
D+(N-1)
Hint
It is possible for the source words and destination words to overlap, so XFER(070) can
perform word-shift operations.
XFER
D100
&10
D102
D100
D102
D109
D111
Precautions
Be sure that the source words (S to S+N-1) and destination words (D to D+N-1) do not exceed the
end of the data area.
Some time will be required to complete XFER(070) when a large number of words is being transferred. Even if an interrupt occurs, execution of this instruction will not be interrupted and execution of
the interrupt task will be started after execution of XFER(070) has been completed. If power is interrupted during execution of XFER(070), execution may not be completed, i.e., all of the specified data
may not be transferred.
XFER
&1000
D0
D1000
Sample Program
When CIO 0.00 is ON in the following example, the 10 words D100 through D109 are copied to D200
through D209.
0.00
XFER
&10
D100
D200
D100
D200
D101
D201
D102
D109
2-118
10
words
D202
D209
2 Instructions
Instruction
Mnemonic
BLOCK SET
Function
code
Variations
BSET
@BSET
Function
Copies the same word to a range of consecutive
words.
071
BSET
BSET
BSET(071)
Symbol
S: Source word
St
E: End word
2
BSET
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
Source word
Description
WORD
St
Starting word
WORD
Variable
End word
WORD
Variable
E: End Word
Specifies the last word in the destination range.
15
St
to
E
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
St, E
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if St is greater than E.
OFF in all other cases.
2-119
2 Instructions
Function
BSET(071) copies the same source word (S)
to all of the destination words in the range St
to E.
Destination words
Source word
S
St
Precautions
Some time will be required to complete BSET(071) when a large number of words is being set. Even
if an interrupt occurs, execution of this instruction will not be interrupted and execution of the interrupt
task will be started after execution of BSET(071) has been completed. If power is interrupted during
execution of BSET(071), execution may not be completed, i.e., all of the specified words may not be
set. One BSET(071) instruction can be replaced with two BSET(071) instructions to help avoid this
problem.
BSET
BSET
#0000
#0000
D1000
D1000
D1999
D1499
BSET
#0000
D1500
D1999
Sample program
When CIO 0.00 is ON in the following example, the source data in D100 is copied to D200 through
D209.
0.00
BSET
2-120
D100
St
D200
D209
SD100
1 2 3 4
St:D200
1 2 3 4
D201
1 2 3 4
D202
1 2 3 4
D203
1 2 3 4
D204
1 2 3 4
D205
1 2 3 4
D206
1 2 3 4
D207
1 2 3 4
D208
1 2 3 4
E:D209
1 2 3 4
2 Instructions
Instruction
Mnemonic
DATA EXCHANGE
Function
code
Variations
XCHG
@XCHG
XCHG
Function
Exchanges the contents of the two specified
words.
073
XCHG
XCHG(073)
Symbol
E1
E2
Area
Subroutines
Interrupt tasks
Usage
OK
OK
OK
XCHG
Operands
Operand
Description
Data type
Size
E1
WORD
E2
WORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
E1,E2
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Label
Error Flag
P_ER
Operation
Unchanged
Equals Flag
P_EQ
Unchanged
Negative Flag
P_N
Unchanged
Function
XCHG(073) exchanges the contents of E1 and E2.
E1
E2
2-121
2 Instructions
Hint
To exchange 3 or more words, use
XFER(070) to transfer the words to a third set
of words (a buffer) as shown in this diagram.
E1
1st XFER(070)
operation
Buffer
2nd XFER(070)
operation
E2
3rd XFER(070)
operation
Sample program
When CIO 0.00 is ON in this example, the content of D100 is exchanged with the content of
D200.
0.00
XCHG
D100
D200
2-122
D100 1
D200 A
D100 A
D200 1
2 Instructions
Instruction
Mnemonic
Function
code
Variations
DIST
@DIST
Function
Transfers the source word to a destination word
calculated by adding an offset value to the base
address.
080
DIST
DIST
DIST(080)
Symbol
S: Source word
Bs
Of
Of: Offset
DIST
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
1
Source word
WORD
Bs
WORD
Of
Offset
UINT
Bs
Bs+Of
Of: Offset
The offset can be any value from 0000 to FFFF (0 to 65,535 decimal).
Note Bs and Bs+Of must be in the same data area.
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
S
Bs
CF
Pulse bits
TR bits
---
---
---
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
Of
OK
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Negative Flag
P_N
2-123
2 Instructions
Function
DIST(080) copies S to the destination word
calculated by adding Of to Bs.
Bs
Of
Bs+n
Hint
The same DIST(080) instruction can be used to distribute the source word to various words in the data
area by changing the value of Of.
Precautions
Be sure that the offset does not exceed the end of the data area, i.e., Bs and Bs+Of are in the same
data area.
Sample program
When CIO 0.00 is ON in this example, the contents of D100 will be copied to D210 (D200 + 10) if the
contents of D300 is 10 (0A hexadecimal). The contents of D100 can be copied to other words by changing the offset in D300.
0.00
DIST
S
D100
Bs
D200
Of
D300
S:D100
Copied by DIST(080).
Of:
D300
Bs:D200
0 0 0 A
4-digit hexadecimal
D201
Offset +10 words
D210
2-124
2 Instructions
Instruction
Mnemonic
DATA COLLECT
Function
code
Variations
COLL
@COLL
Function
Transfers the source word (calculated by adding
an offset value to the base address) to the destination word.
081
COLL
COLL
COLL(081)
Symbol
Bs
Of
Of: Offset
D: Destination word
2
COLL
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Bs
WORD
Of
Offset
WORD
Destination word
WORD
Bs
Bs+Of
Of: Offset
The offset can be any value from 0000 to FFFF (0 to 65,535 decimal).
Note Bs and Bs+Of must be in the same data area.
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Bs
Of
CF
Pulse bits
TR bits
---
---
---
--OK
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Negative Flag
P_N
2-125
2 Instructions
Function
COLL(081) copies the source word (calculated
by adding Of to Bs) to the destination word.
Bs
Of
n
Bs+n
D
Hint
The same COLL(081) instruction can be used to collect data from various source words in the data
area by changing the value of Of.
Precautions
Be sure that the offset does not exceed the end of the data area, i.e., Bs and Bs+Of are in the same
data area.
Sample program
When CIO 0.00 is ON in the following example, the contents of D110 (D100 + 10) will be copied to
D300 if the content of D200 is 10 (0A hexadecimal). The contents of other words can be copied to D300
by changing the offset in D200.
D200 0
0.00
COLL
Bs:D100
Bs
D100
D101
Of
D200
D300
4-digit hexadecimal
Offset +10 words
D110
Copied by COLL(081).
D300
2-126
2 Instructions
SFT
Instruction
Mnemonic
SHIFT REGISTER
SFT
Variations
Function
code
---
010
Function
Operates a shift register.
SFT
Data input
Symbol
SFT(010)
Reset input
St
E: End word
SFT
Shift input
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
St
Starting word
UINT
Variable
End word
UINT
Variable
Operand Specifications
Word addresses
Indirect DM addresses
Area
St,E
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
---
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Label
Error Flag
P_ER
Operation
OFF
Function
When the execution condition on the shift input changes from OFF to ON, all the data from St to E is
shifted to the left by one bit (from the rightmost bit to the leftmost bit), and the ON/OFF status of the
data input is placed in the rightmost bit.
E
Lost
St
2-127
2 Instructions
Precautions
Do not use more than one SFT(010) instructions with overlapping shift words. The results will not be
dependable.
St and E must be in the same data area.
The bit data shifted out of the shift register is discarded.
When the reset input turns ON, all bits in the shift register from the rightmost designated word (St) to
the leftmost designated word (E) will be reset (i.e., set to 0). The reset input takes priority over other
inputs.
St must be less than or equal to E, but even when St is set to greater than E an error will not occur
and one word of data in St will be shifted.
Sample program
Shift Register Exceeding 16 Bits
The following example shows a 48-bit shift register using words CIO 128 to CIO 130. A 1-s clock pulse
is used so that the execution condition produced by CIO 0.05 is shifted into a 3-word register between
CIO 128.00 and CIO 130.15 every second.
0.05
Data input
1s (1-s clock)
128
Shift input
0.06
SFT
130
E: 130CH
Lost 15 14
St+1: 129CH
1 0 15 14
1 0 15 14
St: 128CH
10
Contents of
0.05
Reset
2-128
2 Instructions
SFTR
Mnemonic
SFTR
Variations
Function
code
Function
084
@SFTR
SFTR
SFTR(084)
Symbol
C: Control word
St
E: End word
2
SFTR
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Control word
UINT
St
Starting word
UINT
Variable
End word
UINT
Variable
C: Control Word
15
14
13
12
Shift direction
1 (ON): Left
0 (OFF): Right
Data input
Shift input
Reset
Operand Specifications
Word addresses
Indirect DM addresses
Area
C,St,E
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Label
Error Flag
P_ER
Carry Flag
P_CY
Instruction
Operation
ON when St is greater than E.
OFF in all other cases.
ON when 1 is shifted into it.
OFF when 0 is shifted into it.
OFF when reset is set to 1.
2-129
2 Instructions
Function
When the execution condition of
the shift input bit (bit 14 of C)
changes to ON, all the data from
St to E is moved in the designated
shift direction (designated by bit
12 of C) by 1 bit, and the ON/OFF
status of the data input is placed
in the rightmost or leftmost bit.
The bit data shifted out of the shift
register is placed in the Carry
Flag (CY)
Note
15141312
C
CY 15
0 15
15
St
0 Data input
Data input 15
0 15
15
St
0 CY
Shift direction
The above shift operations are applicable when the reset bit (bit 15 of C) is set to OFF.
When reset (bit 15 of C) turns ON all bits in the shift register, from St to E will be reset (i.e., set to 0).
Sample program
Shifting Data
If shift input W0.14 goes ON when CIO 0.00 is ON, and the reset bit W0.15 is OFF, words CIO 100
through CIO 102 will shift one bit in the direction designated by W0.12 (e.g., 1: Right) and the contents
of input bit W0.13 will be shifted into the rightmost bit, CIO 100.00. The contents of CIO 102.15 will be
shifted to the Carry Flag (CY).
0.00
SFTR
C
W0
St
100
102
15 14 13 12
CW0 0 1
1
Shift direction
Shift input bit:
Reset input bit:
CY
1
0
15
102
0
101
100
Data input:
W0.13
Resetting Data
If W0.14 is ON when CIO 0.00 is ON, and the reset bit, W0.15, is ON, words CIO 100 through CIO 102
and the Carry Flag will be reset to OFF.
Controlling Data
Resetting Data
15
All bits from St to E and the Carry Flag are set to 0 and
no other data can be received when the reset input bit
(bit 15 of C) is ON.
CY
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
15
Data
input
1/0
2-130
CY
2 Instructions
WSFT
Mnemonic
WORD SHIFT
Function
code
Variations
WSFT
@WSFT
Instruction
Function
016
WSFT
WSFT(016)
Symbol
S: Source word
St
E: End word
Area
Subroutines
Interrupt tasks
Usage
OK
OK
OK
WSFT
Operands
Operand
Description
Data type
Size
Control word
WORD
St
Starting word
UINT
Variable
End word
UINT
Variable
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
St,E
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON when St is greater than E.
OFF in all other cases.
Function
WSFT(016) shifts data from St to
E in word units and the data from
the source word S is places into
St. The contents of E is lost.
E
Lost 15
St
0 15
15
15
S
Precautions
St and E must be in the same data area.
When large amounts of data are shifted, the instruction execution time is quite long. Be sure that the
power is not cut while WSFT(016) is being executed, causing the shift operation to stop halfway
through.
2-131
2 Instructions
Sample program
When CIO 0.00 is ON, data from CIO 100 through CIO 102 will be shifted one word toward E. The contents of W0 will be stored in CIO 100 and the contents of CIO 102 will be lost.
i
0.00
WSFT
S
W0
St
100
102
St: W0
Lost
2-132
E: CIO 100
2 Instructions
ASL
Mnemonic
ASL
Variations
Function
code
@ASL
Instruction
Function
025
Symbol
ASL(025)
Wd
Wd: Word
Subroutines
Interrupt tasks
OK
OK
OK
ASL
Area
Usage
Operands
Operand
Description
Wd
Data type
Size
UINT
Word
Operand Specifications
Word addresses
Indirect DM addresses
Area
Wd
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Carry Flag
P_CY
Negative Flag
P_N
Function
ASL(025) shifts the contents of Wd one bit to
the left (from rightmost bit to leftmost bit). 0
is placed in the rightmost bit and the data
from the leftmost bit is shifted into the Carry
Flag (CY).
CY
15
15
Sample program
When CIO 0.00 is ON, CIO 100 will be
shifted one bit to the left. 0 will be placed in
CIO 100.00 and the contents of CIO 100.15
will be shifted to the Carry Flag (CY).
0.00
ASL
Wd
15
100
Wd: 100CH
1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
0
CY
1
0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0
2-133
2 Instructions
ASR
Instruction
Mnemonic
ASR
Variations
Function
code
@ASL
Function
026
ASR
Symbol
ASR(026)
Wd
Wd: Word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Wd
Data type
Size
UINT
Word
Operand Specifications
Word addresses
Indirect DM addresses
Area
Wd
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Carry Flag
P_CY
Negative Flag
P_N
OFF
Function
ASR(026) shifts the contents of Wd
one bit to the right (from leftmost bit to
rightmost bit). 0 will be placed in the
leftmost bit and the contents of the
rightmost bit will be shifted into the
Carry Flag (CY).
15
CY
Sample program
When CIO 0.00 is ON, word CIO 100 will
shift one bit to the right. 0 will be placed in
CIO 100.15 and the contents of CIO 100.00
will be shifted to the Carry Flag (CY).
0.00
ASR
Wd
15
100
Wd: 100CH
1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
0
CY
0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0
2-134
2 Instructions
ROL
Mnemonic
ROTATE LEFT
ROL
Variations
Function
code
@ROL
Instruction
Function
Shifts all Wd bits one bit to the left
027
ROL
Symbol
ROL(027)
Wd: Word
Wd
Subroutines
Interrupt tasks
OK
OK
OK
ROL
Area
Usage
Operands
Operand
Description
Wd
Data type
Size
UINT
Word
Operand Specifications
Word addresses
Indirect DM addresses
Area
Wd
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Carry Flag
P_CY
Negative Flag
P_N
Function
ROL(027) shifts all bits of Wd including the
Carry Flag (CY) to the left (from rightmost bit
to leftmost bit).
CY
15 14
1 0
Hint
It is possible to set the Carry Flag contents to 1 or 0 immediately before executing this instruction, by
using the Set Carry (STC(040)) or Clear Carry (CLC(041)) instructions.
2-135
2 Instructions
Sample program
When CIO 0.00 is ON, word CIO 100 and the
Carry Flag (CY) will shift one bit to the left.
The contents of CIO 100.15 will be shifted to
the Carry Flag (CY) and the Carry Flag contents will be shifted to CIO 100.00.
0.00
ROL
Wd
CY
0
15 14
100
1 0
1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
Instruction executed once
CY
1
2-136
15
0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0
2 Instructions
ROR
Mnemonic
ROTATE RIGHT
ROR
Variations
Function
code
@ROR
Instruction
Function
Shifts all Wd bits one bit to the right
including the Carry Flag (CY).
028
ROR
Symbol
ROR(028)
Wd
Wd: Word
2
Applicable Program Areas
Step program areas
Subroutines
Interrupt tasks
OK
OK
OK
ROR
Area
Usage
Operands
Operand
Description
Wd
Data type
Size
UINT
Word
Operand Specifications
Word addresses
Indirect DM addresses
Area
Wd
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Carry Flag
P_CY
Negative Flag
P_N
Function
ROR(028) shifts all bits of Wd including the
Carry Flag (CY) to the right (from leftmost bit
to rightmost bit).
15 14
1 0
CY
Wd
Hint
It is possible to set the Carry Flag contents to 1 or 0 immediately before executing this instruction, by
using the Set Carry (STC(040)) or Clear Carry (CLC(041)) instructions.
2-137
2 Instructions
Sample program
When CIO 0.00 is ON, word CIO 100
and the Carry Flag (CY) will shift one bit
to the right. The contents of CIO 100.00
will be shifted to the Carry Flag (CY) and
the Carry Flag contents will be shifted to
CIO 100.15.
0.00
ROR
Wd
15 14
100
1 0
1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1
15
0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0
2-138
CY
2 Instructions
SLD/SRD
Mnemonic
Function
code
Variations
Function
SLD
@SLD
074
SRD
@SRD
075
Symbol
SLD
SRD
SLD(074)
SRD(075)
St
E
Instruction
St
E: End word
E: End word
Area
Subroutines
Interrupt tasks
Usage
OK
OK
OK
SLD/SRD
Operands
Operand
Data type
Size
St
Starting Word
Description
UINT
Variable
End Word
UINT
Variable
Operand Specifications
Word addresses
Indirect DM addresses
Area
St,E
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON when St is greater than E.
OFF in all other cases.
Function
SLD
SLD(074) shifts data between St and E by one digit (4 bits) to the left. 0 is placed in the rightmost digit
(bits 3 to 0 of St), and the content of the leftmost digit (bits 15 to 12 of E) is lost.
SRD
SRD(075) shifts data between St and E by one digit (4 bits) to the right. 0 is placed in the leftmost digit
(bits 15 to 12 of E), and the content of the rightmost digit (bits 3 to 0 of St) is lost.
Precautions
St and E must be in the same data
area.
When large amounts of data are
shifted, the instruction execution
time is quite long. Be sure that the
power is not cut while SLD(074) and
SRD(075) is being executed, causing the shift operation to stop halfway through.
CP1E CPU Unit Instructions Reference Manual(W483)
SLD
E
0Hex
Lost
SRD
0Hex
t
Lost
2-139
2 Instructions
Sample program
SLD
When CIO 0.00 is ON, words CIO 100 through CIO 102 will shift by one digit (4 bits) to the left. A zero
will be placed in bits 0 to 3 of word CIO 100 and the contents of bits 12 to 15 of CIO 102 will be lost.
0.00
SLD
St
100
102
E: CIO 102
Lost 15 12 11 8 7 4 3 0 15 12 11 8 7 4 3 0
0Hex
15 12 11 8 7 4 3 0
SRD
When CIO 0.00 is ON, words CIO 100 through CIO 102 will shift by one digit (4 bits) to the right. A zero
will be placed in bits 12 to 15 of CIO 102 and the contents of bits 0 to 3 of word CIO 100 will be lost.
0.00
SRD
St
100
102
0Hex
E: CIO 102
15 12 11 8 7 4 3 0 15 12 11 8 7 4 3 0
2-140
Lost
2 Instructions
NASL/NSLL
Mnemonic
Variations
Function
code
Function
NASL
@NASL
580
NSLL
@NSLL
582
NASL
NSLL
NASL(580)
NSLL(582)
Symbol
D: Shift word
D: Shift word
C: Control word
C: Control word
NASL/NSLL
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
NASL
NSLL
NASL
NSLL
Shift Word
UINT
UDINT
Control word
UINT
UDINT
C: Control word
NASL
15
NSLL
12 11
8 7
15
12 11
8 7
Always 0.
Always 0.
Data shifted into register
0 Hex: 0 shifted in
8 Hex: Contents of rightmost bit shifted in
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CF
Pulse bits
TR bits
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
---
---
Instruction
2-141
2 Instructions
Flags
Name
Label
Error Flag
P_ER
Equals Flag
P_EQ
Carry Flag
P_CY
Negative Flag
P_N
Operation
ON when the control word C (the number of bits to shift) is not within range.
OFF in all other cases.
ON when the shift result is 0.
OFF in all other cases.
ON when 1 is shifted into the Carry Flag (CY).
OFF in all other cases.
ON when the leftmost bit is 1 as a result of the shift.
OFF in all other cases.
Function
NASL
NASL(580) shifts D (the shift word) by the specified number of binary bits (specified in C) to the left
(from the rightmost bit to the leftmost bit). Either zeros or the value of the rightmost bit will be placed
into the specified number of bits of the shift word starting from the rightmost bit.
12 11
15
C
8 7
4 3
0
Shift n-bits
a
D
Contents of a or 0 shifted in
a
CY
Lost
D
N bits
NSLL
NSLL(582) shifts D and D+1 (the shift words) by the specified number of binary bits (specified in C) to
the left (from the rightmost bit to the leftmost bit). Either zeros or the value of the rightmost bit will be
placed into the specified number of bits of the shift word starting from the rightmost bit.
15 12 11 8 7
C
0
43
Shift n-bits
D+1
CY
Contents of a
or 0 shifted in
Lost
N bits
Precautions
For any bits which are shifted outside the specified word, the contents of the last bit is shifted to the
Carry Flag (CY), and all other data is lost.
When the number of bits to shift (specified in C) is 0, the data will not be shifted. The appropriate
flags will turn ON and OFF, however, according to data in the specified word.
2-142
2 Instructions
Sample program
0.00
NASL
15
100
W0
12 11
8 7
0
4 3
0
When CIO 0.00 is ON, The contents of CIO 100 is shifted 10 bits to the left (from the rightmost bit to the
leftmost bit). The number of bits to shift is specified in bits 0 to 7 of word W0 (control data). The contents of bit 0 of CIO 100 is copied into bits from which data was shifted and the contents of the rightmost bit which was shifted out of range is shifted into the Carry Flag (CY). All other data is lost.
A
No. of bits to shift: 10 bits (0A Hex)
NASL/NSLL
Always 0.
Data shifted into register
8 Hex: Contents of right-most bit shifted in
Lost
15
8 7 6 5
100
CY
Rightmost bit
1 0 0 1 0 0 1
15 14 13 12 11 10 9 8
4 3 2 1 0
100 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1
When CIO 0.00 is ON, CIO 100 and CIO 101 will be shifted to the left (from the rightmost bit to the leftmost bit) by 10 bits. The number of bits to shift is specified in bits 0 to 7 of W0 (control data). The contents of bit 0 of CIO 100 is copied into bits from which data was shifted and the contents of the
rightmost bit which was shifted out of range is shifted into the Carry Flag (CY). All other data is lost.
0.00
NSLL
D
100
W0
15
C
12 11
8 7
0
4 3
0
0
A
No. of bits to shift: 10 bits (0A Hex)
Always 0.
Data shifted into register
8 Hex: Contents of right-most bit shifted in
Lost
15
101
CY
1
8 7
1 1 0 0 1 0 0 1
15
9 8 7
101 0 0 1 0 0 1 1 0 0 1 0 0 1 0 0 1
15
8 7 6 5
Rightmost bit a
100 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1
15
10 9 8 7
100 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1
No. of bits to shift: 10 bits
(Contents of the rightmost
bit is shifted in)
2-143
2 Instructions
NASR/NSRL
Instruction
Mnemonic
Variations
Function
code
Function
NASR
@NASR
581
NSRL
@NSRL
583
NASR
NSRL
NASR(581)
Symbol
D
C
NSRL(583)
D: Shift word
D: Shift word
C: Control word
C: Control word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
NASR
NSRL
NASR
Shift Word
UINT
UDINT
NSRL
2
Control word
UINT
UDINT
C: Control word
NASR
15
NSRL
12 11
8 7
15
12 11
8 7
Always 0.
Always 0.
Data shifted into register
0 Hex: 0 shifted in
8 Hex: Contents of rightmost bit shifted in
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
D
C
2-144
CF
Pulse bits
TR bits
---
---
---
--OK
2 Instructions
Flags
Name
Label
P_ER
Equals Flag
P_EQ
Carry Flag
P_CY
Negative Flag
P_N
Operation
ON when the control word C (the number of bits to shift) is not within range.
Error Flag
Function
NASR
a
D
Contents of a or
0 shifted in
CY
D
Lost
N bits
NSRL
NSRL(583) shifts D and D+1 (the shift words) by the specified number of binary bits (specified in C) to
the right (from the leftmost bit to the rightmost bit). Either zeros or the value of the rightmost bit will be
placed into the specified number of bits of the shift word starting from the rightmost bit.
15 12 11 8 7
C
0
43
Shift n-bits
D+1
a
Contents of a or
0 shifted in
D
CY
Lost
Precautions
For any bits which are shifted outside the specified word, the contents of the last bit is shifted to the
Carry Flag (CY), and all other data is discarded.
When the number of bits to shift (specified in C) is 0, the data will not be shifted. The appropriate
flags will turn ON and OFF, however, according to data in the specified word.
2-145
NASR/NSRL
NASR(581) shifts D (the shift word) by the specified number of binary bits (specified in C) to the right
(from the rightmost bit to the leftmost bit). Either zeros or the value of the rightmost bit will be placed
into the specified number of bits of the shift word starting from the rightmost bit.
2 Instructions
Sample program
When CIO 0.00 is ON, CIO 100 will be shifted 10 bits to the right (from the leftmost bit to the rightmost bit). The number of bits to shift is specified in bits 0 to 7 of W0. The contents of bit 15 of CIO 100
is copied into the bits from which data was shifted and the contents of the leftmost bit of data which
was shifted out of range, is shifted into the Carry Flag (CY). All other data is lost.
.
0.00
NASR
D
100
W0
15
12 11
8 7
4 3
0
0
A
No. of bits to shift: 10 bits (0A Hex)
Always 0.
Data shifted into register
8 Hex: Contents of leftmost bit shifted in
Leftmost bit
Lost
9 8 7
15
100 1 0 0 1 0 0 1
4 3 2 1 0
15 14 13 12 11 10 9 8
CY
100 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0
When CIO 0.00 is ON, CIO 100 and CIO 101 will be shifted 10 bits to the right (from the leftmost bit to
the rightmost bit). The number of bits to shift is specified in bits 0 to 7 of W0 (control data). The contents
of bit 15 of CIO will be copied into the bits from which data was shifted and the contents of the leftmost
bit of data which was shifted out of range will be shifted into the Carry Flag (CY). All other data is lost.
0.00
NSRL
D
100
W0
15
C
12 11
8
8 7
4 3
0
0
A
No. of bits to shift: 10 bits (0A Hex)
Always 0.
Data shifted into register
8 Hex: Contents of leftmost bit shifted in
Lost
Leftmost bit
15
8 7
101 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
15
8 7 6
101 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0
15
9 8 7
100 0 0 0 1 0 0 1
15
100 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0
CY 1
2-146
2 Instructions
Increment/Decrement Instructions
Instruction
Mnemonic
Variations
Function
code
Function
INCREMENT BINARY
++
@++
590
DOUBLE INCREMENT
BINARY
++L
@++L
591
Symbol
+ +L
++L(591)
++(590)
Wd
Wd
Wd: Word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
++: Word
++L: First word
Wd
++
++L
++
++L
UINT
UDINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
Wd
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Carry Flag
P_CY
Negative Flag
P_N
2
++/++L
++
Increment/Decrement
Instructions
++/++L
2-147
2 Instructions
Function
++
The ++(590) instruction adds 1 to the binary content
of Wd. The specified word will be incremented by 1
every cycle as long as the execution condition of
++(590) is ON. When the up-differentiated variation
of this instruction (@++(590)) is used, the specified
word is incremented only when the execution condition has gone from OFF to ON.
Wd
+1
Wd
+ +L
The ++L(591) instruction adds 1 to the 8-digit hexadecimal content of Wd+1 and Wd. The content of the
specified words will be incremented by 1 every cycle
as long as the execution condition of ++L(591) is
ON. When the up-differentiated variation of this
instruction (@++L(591)) is used, the content of the
specified words is incremented only when the execution condition has gone from OFF to ON.
Wd+1
Wd
+1
Wd+1
Wd
Sample program
Operation of ++(590)/++L(591)
In the following example, the content of D100 will be incremented by 1 every cycle as long as CIO 0.00
is ON.
0.00
++
D100
Wd: D100
0 0 1 A
In the following example, the content of D100 will be incremented by 1 every cycle as long as CIO 0.00
is ON.
Incremented every cycle
while CIO 0.00 is ON.
0.00
++L
D100
Wd+1: D101
0 0 0 0
Wd: D100
F F F F +1
Wd+1: D101
Wd: D100
0 0 0 1
0 0 0 0
0.00
Increment
2-148
Increment
Increment
Increment
2 Instructions
Operation of @++(590)/@++L(591)
The up-differentiated variation is used in the following example, so the content of D100 will be incremented by 1 only when CIO 0.00 has gone from OFF to ON.
@++
D100
Wd: D100
0 0 1 A
The up-differentiated variation is used in the following example, so the content of D101 and D100 will be
incremented by 1 only when CIO 0.00 has gone from OFF to ON.
@++L
D100
0.00
Wd+1: D101
Wd: D100
F F F F +1
Wd+1: D101
Wd: D100
0 0 0 1
0 0 0 0
++/++L
0 0 0 0
0.00
Increment
Increment/Decrement
Instructions
0.00
Increment
2-149
2 Instructions
--/--L
Instruction
Mnemonic
Variations
Function
code
Function
DECREMENT BINARY
--
@--
592
DOUBLE DECREMENT
BINARY
--L
@--L
593
-Symbol
--L
--(592)
--L(593)
Wd: Word
Wd
Wd
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
--: Word
--L: First word
Wd
--
--L
--
--L
UINT
UDINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
Wd
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse
bits
TR
bits
---
---
---
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Carry Flag
P_CY
Negative Flag
P_N
2-150
2 Instructions
Function
-Wd
Wd+1
-1
Wd
Increment/Decrement
Instructions
--L
Wd
-1
Wd+1
Wd
--/--L
Sample program
Operation of --(592)/--L(593)
The up-differentiated variation is used in the following example, so the content of D100 will be decremented by 1 only when CIO 0.00 has gone from OFF to ON.
0.00
-D100
Wd: D100
0 0 1 F
In the following example, the 8-digit hexadecimal content of D101 and D100 will be decremented by 1
every cycle as long as CIO 0.00 is ON.
Decremented every cycle
while CIO 0.00 is ON.
0.00
--L
D100
Wd+1: D101
Wd: D100
0 0 0 1
0 0 0 0
-1
Wd+1: D101
Wd: D100
0 0 0 0
F F F F
: Execution of --L(593)
0.00
Decrement
Decrement
Decrement
Decrement
2-151
2 Instructions
Operation of @--(592)/@--L(593)
In the following example, the content of D100 will be decremented by 1 every cycle as long as CIO 0.00
is ON.
0.00
@
D100
Wd: D100
0 0 1 F
The up-differentiated variation is used in the following example, so the content of D101 and D100 will be
decremented by 1 only when CIO 0.00 has gone from OFF to ON.
Decremented only for
up-differentiation.
0.00
@ L
D100
Wd+1: D101
Wd: D100
0 0 0 1
0 0 0 0
Wd+1: D101
Wd: D100
0 0 0 0
F F F F
: Execution of @--L(593)
0.00
Decrement
2-152
Decrement
2 Instructions
++B/++BL
Mnemonic
Variations
Function
code
Function
INCREMENT BCD
++B
@++B
594
++BL
@++BL
595
++B
Symbol
+ +BL
++B(594)
++BL(595)
Wd: Word
Wd
Wd
Area
Subroutines
Interrupt tasks
Usage
OK
OK
OK
++B/++BL
Operands
Data type
Operand
Size
Description
++B: Word
++BL: First word
Wd
++
++L
++
++L
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Wd
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse
bits
TR
bits
---
---
---
---
Flags
Name
Label
Error Flag
P_ER
Equals Flag
P_EQ
Carry Flag
P_CY
Operation
ON if the content of Wd/Wd+1 and Wd is not BCD.
OFF in all other cases.
ON if the result is 0000/0000 0000 after execution.
OFF in all other cases.
ON if a digit in Wd/Wd+1 or Wd went from 9 to 0 during execution.
OFF in all other cases.
Increment/Decrement
Instructions
Instruction
2-153
2 Instructions
Function
++B
The ++B(594) instruction adds 1 to the BCD content
of Wd. The specified word will be incremented by 1
every cycle as long as the execution condition of
++B(594) is ON. When the up-differentiated variation
of this instruction (@++B(594)) is used, the specified
word is incremented only when the execution condition has gone from OFF to ON.
+1
Wd
Wd
+ +BL
The ++BL(595) instruction adds 1 to the 8-digit BCD
content of Wd+1 and Wd. The content of the specified words will be incremented by 1 every cycle as
long as the execution condition of ++BL(595) is ON.
When the up-differentiated variation of this instruction (@++BL(595)) is used, the content of the specified words is incremented only when the execution
condition has gone from OFF to ON.
Wd+1
Wd
+1
Wd+1
Wd
Sample program
Operation of ++B(594)/++BL(595)
In the following example, the BCD content of D100 will be incremented by 1 every cycle as long as CIO
0.00 is ON.
0.00
++B
D100
Wd: D100
0 0 2 0
In the following example, the 8-digit BCD content of D101 and D100 will be incremented by 1 every
cycle as long as CIO 0.00 is ON.
Incremented every cycle
while CIO 0.00 is ON.
0.00
++BL
D100
Wd+1: D101
Wd: D100
0 0 0 0
9 9 9 9
+1
Wd+1: D101
Wd: D100
0 0 0 1
0 0 0 0
0.00
Increment
2-154
Increment
Increment
Increment
2 Instructions
Operation of @++B(594)/@++BL(595)
The up-differentiated variation is used in the following example, so the content of D100 will be incremented by 1 only when CIO 0.00 has gone from OFF to ON.
@++B
D100
Wd: D100
0 0 2 0
The up-differentiated variation is used in the following example, so the BCD content of D101 and D100
will be incremented by 1 only when CIO 0.00 has gone from OFF to ON.
@++BL
D100
0.00
Wd: D100
0 0 0 0
9 9 9 9
+1
Wd+1: D101
Wd: D100
0 0 0 1
0 0 0 0
++B/++BL
Wd+1: D101
0.00
Increment
Increment/Decrement
Instructions
0.00
Increment
2-155
2 Instructions
--B/--BL
Instruction
Mnemonic
Variations
Function
code
Function
DECREMENT BCD
--B
@--B
596
--BL
@--BL
597
--B
Symbol
--BL
--B(596)
--BL(597)
Wd: Word
Wd
Wd
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Description
--B: Word
--BL: First word
Wd
Size
--
--L
--
--L
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Wd
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse
bits
TR
bits
---
---
---
---
Flags
Name
Label
Error Flag
P_ER
Equals Flag
P_EQ
Carry Flag
P_CY
Operation
ON if the content of Wd/Wd+1 and Wd is not BCD.
OFF in all other cases.
ON if the result is 0000/0000 0000 after execution.
OFF in all other cases.
ON if a digit in Wd/Wd+1 or Wd went from 0 to 9 during execution.
OFF in all other cases.
Function
--B
The --B(596) instruction subtracts 1 from the BCD
content of Wd. The specified word will be decremented by 1 every cycle as long as the execution
condition of --B(596) is ON. When the up-differentiated variation of this instruction (@--B(596)) is used,
the specified word is decremented only when the execution condition has gone from OFF to ON.
Wd
Wd
-1
--BL
The --BL(597) instruction subtracts 1 from the 8-digit
BCD content of Wd+1 and Wd. The content of the
specified words will be decremented by 1 every cycle
as long as the execution condition of --BL(597) is ON.
When the up-differentiated variation of this instruction
(@--BL(597)) is used, the content of the specified
words is decremented only when the execution condition has gone from OFF to ON.
2-156
Wd+1
Wd
-1
Wd+1
Wd
2 Instructions
Sample program
Operation of --B(596)/--BL(597)
0.00
--B
D100
Wd: D100
0 0 1 9
In the following example, the 8-digit BCD content of D101 and D100 will be decremented by 1 every
cycle as long as CIO 0.00 is ON.
--BL
Wd: D100
0 0 0 1
0 0 0 0
Wd+1: D101
Wd: D100
0 0 0 0
9 9 9 9
-1
--B/--BL
Wd+1: D101
0.00
Decrement
Decrement
Decrement
Decrement
Operation of @--B(596)/@--BL(597)
The up-differentiated variation is used in the following example, so the BCD content of D100 will be decremented by 1 only when CIO 0.00 has gone from OFF to ON.
0.00
@--B
D100
Wd: D100
0 0 1 9
The up-differentiated variation is used in the following example, so the BCD content of D101 and D100
will be decremented by 1 only when CIO 0.00 has gone from OFF to ON.
Decremented only for
up-differentiation.
0.00
@--BL
D100
0.00
D100
Increment/Decrement
Instructions
In the following example, the BCD content of D100 will be decremented by 1 every cycle as long as CIO
0.00 is ON.
Wd+1: D101
Wd: D100
0 0 0 1
0 0 0 0
-1
Wd+1: D101
Wd: D100
0 0 0 0
9 9 9 9
0.00
Decrement
Decrement
2-157
2 Instructions
Mnemonic
Function
code
Variations
Function
@+
400
+L
@+L
401
+L
+L(401)
+(400)
Symbol
Au
Au
Ad
Ad
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
+:
Au
Augend word
Ad
Addend word
Result word
+L
+L
INT
DINT
INT
DINT
INT
DINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Au, Ad
R
2-158
CF
Pulse bits
TR bits
---
---
---
OK
---
2 Instructions
Flags
Operation
Label
+
+L
Error Flag
P_ER
OFF
OFF
Equals Flag
P_EQ
ON when the result of adding two positive numbers is in the range 8000 to FFFF hex.
ON when the result of adding two positive numbers is in the range 80000000 to FFFFFFFF hex.
ON when the result of adding two negative numbers is in the range 0000 to 7FFF hex.
ON when the result of adding two negative numbers is in the range 00000000 to 7FFFFFFF hex.
Carry Flag
P_CY
Overflow Flag
P_OF
Underflow Flag
P_UF
Negative Flag
P_N
Name
2
+/+L
Function
+
+(400) adds the binary values in Au and Ad and outputs the result to R.
CY will turn ON
when there is a
carry.
Au
(Signed binary)
Ad
(Signed binary)
CY
(Signed binary)
+L
+L(401) adds the binary values in Au and Au+1 and Ad and Ad+1 and outputs the result to R.
CY will turn ON
when there is a
carry.
Au+1
Au
(Signed binary)
Ad+1
Ad
(Signed binary)
CY
R+1
(Signed binary)
Sample program
0.00
+
D100
D110
D120
0.00
+L
D100
When CIO 0.00 is ON, D101 and D100 and D111 and D110 will
be added as 8-digit signed binary values and the result will be
output to D121 and D120.
D110
D120
2-159
2 Instructions
+C/+CL
Instruction
Mnemonic
Function
code
Variations
Function
+C
@+C
402
+CL
@+CL
403
+C
+CL
+C(402)
Symbol
+CL(403)
Au
Au
Ad
Ad
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
+C: Augend word
Au
Ad
+C
+CL
+C
+CL
INT
DINT
INT
DINT
INT
DINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Au, Ad
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Operation
Name
Label
+C
+CL
Error Flag
P_ER
OFF
OFF
Equals Flag
P_EQ
Carry Flag
P_CY
Overflow Flag
P_OF
ON when the result of adding two positive numbers and CY is in the range 80000000 to
FFFFFFFF hex.
Underflow Flag
P_UF
ON when the addition result of adding two negative numbers and CY is in the range 0000 to 7FFF
hex.
ON when the result of adding two negative numbers and CY is in the range 00000000 to
7FFFFFFF hex.
Negative Flag
P_N
2-160
2 Instructions
Function
+C
Symbol Math Instructions
+C(402) adds the binary values in Au, Ad, and CY and outputs the result to R.
Au
(Signed binary)
Ad
(Signed binary)
CY
+
CY will turn ON
when there is a
carry.
CY
(Signed binary)
+CL
+CL(403) adds the binary values in Au and Au+1, Ad and Ad+1, and CY and outputs the result to R.
Au
(Signed binary)
Ad+1
Ad
(Signed binary)
+
CY will turn ON
when there is a
carry.
CY
+C/+CL
Au+1
CY
R+1
(Signed binary)
Hint
To clear the Carry Flag (CY), execute the Clear Carry (CLC(041)) instruction.
Sample program
0.00
+C
D200
D210
D220
0.00
+CL
D200
When CIO 0.00 is ON, D201, D200, D211, D210, and CY will
be added as 8-digit signed binary values, and the result will
be output to D221 and D220.
D210
D220
2-161
2 Instructions
+B/+BL
Instruction
Mnemonic
Function
code
Variations
Function
+B
@+B
404
+BL
@+BL
405
+B
+BL
+BL(405)
+B(404)
Symbol
Au
Au
Ad
Ad
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
+B: Augend word
Au
Ad
+B
+BL
+B
+BL
WORD
DWORD
WORD
DWORD
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Au, Ad
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Operation
Name
Label
+B
Error Flag
Equals Flag
Carry Flag
2-162
P_ER
P_EQ
P_CY
+BL
2 Instructions
Function
+B
Symbol Math Instructions
+B(404) adds the BCD values in Au and Ad and outputs the result to R.
CY will turn ON
when there is a
carry.
Au
(BCD)
Ad
(BCD)
CY
(BCD)
+BL
+BL(405) adds the BCD values in Au and Au+1 and Ad and Ad+1 and outputs the result to R, R+1.
Au
(BCD)
Ad+1
Ad
(BCD)
CY
R+1
(BCD)
+B/+BL
CY will turn ON
when there is a
carry.
Au+1
Sample program
0.00
+B
D100
D110
D120
0.00
+BL
D100
D110
D120
2-163
2 Instructions
+BC/+BCL
Instruction
Mnemonic
Function
code
Variations
Function
+BC
@+BC
406
Adds 4-digit (single-word) BCD data and/or constants with the Carry Flag (CY).
+BCL
@+BCL
407
Adds 8-digit (double-word) BCD data and/or constants with the Carry Flag (CY).
+BC
+BCL
+BCL(407)
+BC(406)
Symbol
Au
Au
Ad
Ad
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
+BC: Augend word
Au
Ad
+BC
+BCL
+BC
+BCL
WORD
DWORD
WORD
DWORD
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Au, Ad
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Operation
Name
Label
+BC
Error Flag
P_ER
+BCL
Equals Flag
P_EQ
Carry Flag
P_CY
2-164
2 Instructions
Function
+BC
Symbol Math Instructions
+BC(406) adds BCD values in Au, Ad, and CY and outputs the result to R.
Au
(BCD)
Ad
(BCD)
CY
+
CY will turn ON
when there is a
carry.
CY
(BCD)
+BCL
+BCL(407) adds the BCD values in Au and Au+1, Ad and Ad+1, and CY and outputs the result to R,
R+1.
Au
(BCD)
Ad+1
Ad
(BCD)
+
CY will turn ON
when there is a
carry.
CY
+BC/+BCL
Au+1
CY
R+1
(BCD)
Hint
To clear the Carry Flay (CY), execute the Clear Carry (CLC(041)) instruction.
Sample program
0.00
+BC
D100
D110
D120
0.00
+BCL
D100
D110
D120
2-165
2 Instructions
/L
Instruction
Mnemonic
Function
code
Variations
Function
410
@L
411
-L(410)
-(410)
Symbol
Mi
Su
R
Mi
Su
R: Result word
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
:
Mi
Minuend word
Su
Subtrahend word
Result word
INT
DINT
INT
DINT
INT
DINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Mi, Su
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Operation
Name
Label
Error Flag
P_ER
OFF
OFF
Equals Flag
P_EQ
Carry Flag
P_CY
Overflow Flag
P_OF
ON when the result of subtracting a negative number from a positive number is in the range 8000 to
FFFF hex.
ON when the result of subtracting a negative number from a positive number is in the range
80000000 to FFFFFFFF hex.
Underflow Flag
P_UF
ON when the result of subtracting a negative number from a positive number is in the range 0000 to
7FFF hex.
ON when the result of subtracting a positive number from a negative number is in the range
00000000 to 7FFFFFFF hex.
Negative Flag
P_N
2-166
2 Instructions
Function
CY will turn ON
when there is a
borrow.
CY
Mi
(Signed binary)
Su
(Signed binary)
(Signed binary)
L
(400) subtracts the binary values in Su from Mi and outputs the result to R. When the result is negative, it is output to R as a 2s complement.
2
L(411) subtracts the binary values in Su and Su+1 from Mi and Mi+1 and outputs the result to R, R+1.
When the result is negative, it is output to R and R+1 as a 2s complement.
CY
Mi
(Signed binary)
Su+1
Su
(Signed binary)
R+1
(Signed binary)
/L
CY will turn ON
when there is a
borrow.
Mi+1
2-167
2 Instructions
Hint
2s Complement
A 2s complement is the value obtained by subtracting each binary digit from 1 and adding one to the
result. For example, the 2s complement for 1101 is calculated as follows: 1111 (F hexadecimal)
1101 (D hexadecimal) + 1 (1 hexadecimal) = 0011 (3 hexadecimal). The 2s complement for 3039
(hexadecimal) is calculated as follows: FFFF (hexadecimal) 3039 (hexadecimal) + 0001 (hexadecimal) CFC7 (hexadecimal). Therefore, in case of 4-digit hexadecimal value, the 2s complement can
be calculated as follows: FFFF (hexadecimal) a (hexadecimal) + 0001 (hexadecimal) = b (hexadecimal). To obtain the true number from the 2s complement b (hexadecimal): a (hexadecimal) = 10000
(hexadecimal) b (hexadecimal). For example, to obtain the true number from the 2s complement
CFC7 (hexadecimal): 10000 (hexadecimal) CFC7 = 3039.
Example 1
FFFF Hex
0001 Hex
FFFE Hex
Signed data
1
+1
2 Note 1
Unsigned data
65535
1
Note 1. Since the Negative Flag is ON, the result (FFFE hex) is
a negative value (2s complement) and is thus -2.
65534 Note 2
Negative Flag ON
Example 2
Signed data
Unsigned data
FFFD Hex
FFFF Hex
3
1
65533
65535
FFFE Hex
2 Note 3
65534 Note 4
Negative Flag ON
Carry Flag OFF
(1)
200
120
D100
P_CY
L
(2)
#00000000
D100
D100
P_CY
SET
display
21.00
In this example, the eight-digit binary value in CIO 121 and CIO 120 is subtracted from the value in CIO
201 and CIO 200, and the result is output in eight-digit binary to D101 and D100. If the result is negative, the instruction at (2) will be executed, and the actual result will then be output to D101 and D100.
2-168
2 Instructions
Subtraction at (1)
Mi+1: CIO 201
0
B
CY
R+1: D101
The Carry Flag (CY) is ON, so the result is subtracted from 0000 0000 to
obtain the actual number.
R+1: D100
2 D
Subtraction at (2)
0
Su+1: D101
6
CY
R+1: D101
9
A E
Su: D100
F
2 D
R+1: D100
0
6 D 3
/L
Su+1: D101
6
CY
1
R+1: D101
9
A E
Su: D100
F
2 D
R+1: D100
0
6 D 3
The Carry Flag (CY) is turned ON, so the actual number is 97AE06D3.
Because the content of D101 and D100 is negative, CY is used to turn
ON CIO 21.00 to indicate this.
Sample program
0.00
D100
D110
D120
0.00
L
D100
D110
D120
If the result of the subtraction is a negative number (Mi<Su or Mi+1, Mi <Su+1, Su), the result is output
as the 2s complement and the Carry Flag (CY) will turn ON to indicate that the result of the subtraction
is negative. To convert the 2s complement to the true number, an instruction which subtracts the result
from 0 is necessary using the Carry Flag (CY) as an execution condition.
2-169
2 Instructions
C/CL
Instruction
Mnemonic
Function
code
Variations
Function
@C
412
CL
@CL
413
CL
C(412)
Symbol
CL(413)
Mi
Mi
Su
Su
R: Result word
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
C: Minuend word
Mi
Su
CL
CL
INT
DINT
INT
DINT
INT
DINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Mi, Su
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Operation
Name
Label
C
CL
Error Flag
P_ER
OFF
OFF
Equals Flag
P_EQ
Carry Flag
P_CY
Overflow Flag
P_OF
ON when the result of subtracting a negative number and CY from a positive number is in the range
8000 to FFFF hex.
ON when the result of subtracting a negative number and CY from a positive number is in the range
80000000 to FFFFFFFF hex.
Underflow Flag
P_UF
ON when the result of subtracting a positive number and CY from a negative number is in the
range 0000 to 7FFF hex.
ON when the result of subtracting a positive number and CY from a negative number is in the
range 00000000 to 7FFFFFFF hex.
Negative Flag
P_N
2-170
2 Instructions
Function
C
Mi
(Signed binary)
Su
(Signed binary)
CY will turn ON
when there is a
borrow.
CY
CY
C(412) subtracts the binary values in Su and CY from Mi, and outputs the result to R. When the result
is negative, it is output to R as a 2s complement.
(Signed binary)
CL
Mi+1
Mi
(Signed binary)
Su+1
Su
(Signed binary)
CY
CY will turn ON
when there is a
borrow.
CY
R+1
(Signed binary)
Hint
To clear the Carry Flag (CY), execute the Clear Carry (CLC(041)) instruction.
2s Complement
A 2s complement is the value obtained by subtracting each binary digit from 1 and adding one to the
result.
Example: The 2s complement for the binary number 1101 is as follows:
1111 (F hex) 1101 (D hex) + 1 (1 hex) = 0011 (3 hex).
Example: The 2s complement for the 4-digit hexadecimal number 3039 is as follows:
FFFF hex - 3039 hex + 0001 hex = CFC7 hex.
Accordingly, the 2s complement for the 4-digit hexadecimal value a is as follows:
FFFF hex a hex + 0001 hex = b hex.
And to obtain the true number a hex from the 2s complement b hex:
a hex + 10000 hex b hex.
Example: To obtain the true number from the 2s complement CFC& hex:
10000 hex CFC7 hex = 3039 hex.
Sample program
0.00
C
D100
D110
D120
0.00
CL
D100
When CIO 0.00 is ON in the following example, D111, D110 and CY will be
subtracted from D101 and D100 as 8-digit signed binary values, and the
result will be output to D121 and D120.
D110
D120
If the result of the subtraction is a negative number (Mi<Su or Mi+1, Mi <Su+1, Su), the result is output
as a 2s complement. The Carry Flag (CY) will turn ON. To convert the 2s complement to the true number, a program which subtracts the result from 0 is necessary, as an input condition of the Carry Flag
(CY). The Carry Flag turning ON thus indicates that the result of the subtraction is negative.
CP1E CPU Unit Instructions Reference Manual(W483)
2-171
C/CL
CL(413) subtracts the binary values in Su and Su+1 and CY from Mi and Mi+1, and outputs the result
to R, R+1. When the result is negative, it is output to R, R+1 as a 2s complement.
2 Instructions
B/BL
Instruction
Mnemonic
Function
code
Variations
Function
@B
414
BL
@BL
415
BL
BL(415)
B(414)
Symbol
Mi
Mi
Su
Su
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
B: Minuend word
Mi
Su
BL
BL
WORD
DWORD
WORD
DWORD
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Mi, Su
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Operation
Name
Label
B
Error Flag
P_ER
BL
Equals Flag
P_EQ
Carry Flag
P_CY
2-172
2 Instructions
Function
B
CY will turn ON
when there is a
borrow.
Mi
(BCD)
Su
(BCD)
(BCD)
CY
BL
B(414) subtracts the BCD values in Su from Mi and outputs the result to R. If the result of the subtraction is negative, the result is output as a 10s complement.
BL(415) subtracts the BCD values in Su and Su+1 from Mi and Mi+1 and outputs the result to R, R+1.
If the result is negative, it is output to R, R+1 as a 10s complement.
Mi
(BCD)
Su+1
Su
(BCD)
CY
R+1
(BCD)
B/BL
CY will turn ON
when there is a
borrow.
Mi +1
Hint
10s Complement
A 10s complement is the value obtained by subtracting each digit from 9 and adding one to the
result. For example, the 10s complement for 7556 is calculated as follows: 9999 - 7556 + 1 = 2444.
For a four digit number, the 10's complement of A is 9999 A + 1 = B. To obtain the true number from
the 10s complement B: A = 10000 B. For example, to obtain the true number from the 10s complement 2444: 10000 2444 = 7556.
Example: 9,583,960 17,072,641 = -7,488,681. (BCD)
0.00
RSET
21.00
BL
(1)
200
120
D100
P_CY
BL
(2)
#00000000
D100
D100
P_CY
SET
display
21.00
In this example, the eight-digit BCD content of CIO 121 and CIO 120 is subtracted from the content of
CIO 201 and CIO 200, and the result is output in eight-digit BCD to D101 and D100. The result is negative, so the instruction at (2) will be executed, and the true value will then be output to D101 and D100.
2-173
2 Instructions
Subtraction at (1)
Mi+1: CIO 201
0
09583960+(100000000-17072641)
CY
1
R+1: D101
9
R+1: D100
1
The Carry Flag (CY) is ON, so the result is subtracted from 0000 0000.
Subtraction at (2)
0
Su+1: D101
Su: D100
1
00000000+(100000000-92511319)
CY
R+1: D101
R+1: D100
8
Su+1: D101
CY
1
R+1: D101
0
Su: D100
2
R+1: D100
8
The Carry Flag (CY) will be turned ON, so the actual number is
7,488,681. Because the content of D101 and D100 is negative, CY is
used to turn ON CIO 21.00 to indicate this.
Sample program
0.00
B
D100
D110
D120
0.00
BL
D100
When CIO 0.00 is ON in the following example, D111 and D110 will be
subtracted from D101 and D100 as 8-digit BCD values, and the result will
be output to D121 and D120.
D110
D120
If the result of the subtraction is a negative number (Mi<Su or Mi+1, Mi <Su+1, Su), the result is output
as a 10s complement. The Carry Flag (CY) will turn ON. To convert the 10s complement to the true
number, a program which subtracts the result from 0 is necessary, as an input condition of the Carry
Flag (CY). The Carry Flag turning ON thus indicates that the result of the subtraction is negative.
2-174
2 Instructions
BC/BCL
Mnemonic
Function
code
Variations
Function
BC
@BC
416
BCL
@BCL
417
BC
BCL
BC(416)
Symbol
BCL(417)
Mi: Minuend word
Mi
Su
Su
R: Result word
BC/BCL
Mi
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
BC: Minuend word
Mi
Su
BC
BCL
BC
BCL
WORD
DWORD
WORD
DWORD
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Mi, Su
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Operation
Name
Label
BC
Error Flag
Equals Flag
Carry Flag
P_ER
P_EQ
P_CY
BCL
Instruction
2-175
2 Instructions
Function
BC
BC(416) subtracts BCD values in Su and CY from Mi and outputs the result to R. If the result is negative, it is output to R as a 10s complement.
Mi
(BCD)
Su
(BCD)
CY will turn ON
when there is a
borrow.
CY
CY
(BCD)
BCL
BCL(417)subtracts the BCD values in Su, Su+1, and CY from Mi and Mi+1 and outputs the result to R,
R+1. If the result is negative, it is output to R, R+1 as a 10s complement.
Mi+1
Mi
(BCD)
Su+1
Su
(BCD)
CY
CY will turn ON
when there is a
borrow.
CY
R+1
(BCD)
Hint
To clear the Carry Flay (CY), execute the Clear Carry (CLC(041)) instruction.
10s Complement
A 10s complement is the value obtained by subtracting each digit from 9 and adding one to the
result. For example, the 10s complement for 7556 is calculated as follows: 9999 - 7556 + 1 = 2444.
For a four digit number, the 10s complement of A is 9999 A + 1 = B. To obtain the true number from
the 10s complement B: A = 10000 B. For example, to obtain the true number from the 10s complement 2444: 10000 2444 = 7556.
Sample program
0.00
BC
D100
D110
D120
0.00
BCL
D100
D110
D120
If the result of the subtraction is a negative number (Mi<Su or Mi+1, Mi <Su+1, Su), the result is output
as a 10s complement. The Carry Flag (CY) will turn ON. To convert the 10s complement to the true
number, a program which subtracts the result from 0 is necessary, as an input condition of the Carry
Flag (CY). The Carry Flag turning ON thus indicates that the result of the subtraction is negative.
2-176
2 Instructions
*/*L
Mnemonic
Function
code
Variations
Function
@*
420
*L
@*L
421
*L
*L(421)
*(420)
Symbol
Md
Mr
Mr
R: Result word
*/*L
Md
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
*:
Md
Multiplicand word
Mr
Multiplier word
*L
*L
INT
DINT
INT
DINT
DINT
LINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Md, Mr
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Operation
Name
Label
*
*L
Error Flag
P_ER
OFF
OFF
Equals Flag
P_EQ
Negative Flag
P_N
Instruction
2-177
2 Instructions
Function
*
*(420) multiplies the signed binary values in Md and Mr and outputs the result to R, R+1.
R+1
Md
(Signed binary)
Mr
(Signed binary)
(Signed binary)
*L
*L(421) multiplies the signed binary values in Md and Md+1 and Mr and Mr+1 and outputs the result to
R, R+1, R+2, and R+3.
R+3
R+2
Md + 1
Md
(Signed binary)
Mr + 1
Mr
(Signed binary)
R+1
(Signed binary)
Sample program
0.00
*
D100
D110
D120
0.00
*L
D100
D110
D120
2-178
2 Instructions
*B/*BL
Mnemonic
Function
code
Variations
Function
BCD MULTIPLY
*B
@*B
424
*BL
@*BL
425
*B
*BL
*BL(425)
*B(424)
Symbol
Md
Mr
Mr
R: Result word
*B/*BL
Md
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
*B: Multiplicand word
Md
Mr
*B
*BL
*B
*BL
WORD
DWORD
WORD
DWORD
DWORD
LWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Md, Mr
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Operation
Name
Label
*B
Error Flag
Equals Flag
P_ER
P_EQ
*BL
Instruction
2-179
2 Instructions
Function
*B
*B(424) multiplies the BCD content of Md and Mr and outputs the result to R, R+1.
R+1
Md
(BCD)
Mr
(BCD)
(BCD)
*BL
*BL(425) multiplies BCD values in Md and Md+1 and Mr and Mr+1 and outputs the result to R, R+1,
R+2, and R+3.
R+3
R+2
Md + 1
Md
(BCD)
Mr + 1
Mr
(BCD)
R+1
(BCD)
Sample program
0.00
*B
D100
D110
D120
0.00
*BL
D100
D110
D120
2-180
2 Instructions
/, /L
Mnemonic
Function
code
Variations
Function
@/
430
/L
@/L
431
/L
/L(431)
/(430)
Symbol
Dd
Dr
Dr
R: Result word
/, /L
Dd
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
Dd
Dr
R
/:
Dividend word
/L:
/:
Divisor word
/L:
/L
/L
INT
DINT
INT
DINT
DWORD
LWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Dd, Dr
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Label
Error Flag
P_ER
Equals Flag
P_EQ
Negative Flag
P_N
Operation
ON when the divisor is 0.
OFF in all other cases.
ON when as a result of the division, R/R+1, R is 0.
OFF in all other cases.
ON when the leftmost bit of the R/R+1, R is 1.
OFF in all other cases.
Instruction
2-181
2 Instructions
Function
/
/(430) divides the signed binary (16 bit) values in Dd by those in Dr and outputs the result to R, R+1.
The quotient is placed in R and the remainder in R+1.
Dd
(Signed binary)
Dr
(Signed binary)
R+1
(Signed binary)
Remainder
Quotient
/L
/L(431) divides the signed binary values in Dd and Dd+1 by those in Dr and Dr+1 and outputs the result
to R, R+1, R+2, and R+3. The quotient is output to R and R+1 and the remainder is output to R+2 and
R+3.
R+3 R+2
Remainder
Dd + 1
Dd
(Signed binary)
Dr + 1
Dr
(Signed binary)
R+1
(Signed binary)
Quotient
Sample program
0.00
/
D100
D110
D120
0.00
/L
D100
D110
D120
2-182
2 Instructions
/B, /BL
Mnemonic
Variations
Function
code
Function
BCD DIVIDE
/B
@/B
434
/BL
@/BL
435
/B
/BL
/BL(435)
/B(434)
Symbol
Dd
Dr
Dr
R: Result word
/B, /BL
Dd
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
/B: Dividend word
Dd
Dr
/B
/BL
/B
/BL
WORD
DWORD
WORD
DWORD
DWORD
LWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Dd, Dr
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Operation
Name
Label
/B
Error Flag
Equals Flag
P_ER
P_EQ
/BL
Instruction
2-183
2 Instructions
Function
/B
/B(434) divides the BCD content of Dd by those of Dr and outputs the quotient to R and the remainder
to R+1.
R +1
Remainder
Dd
(BCD)
Dr
(BCD)
(BCD)
Quotient
/BL
/BL(435) divides BCD values in Dd and Dd+1 by those in Dr and Dr+1 and outputs the quotient to R,
R+1 and the remainder to R+2, R+3.
R+3
R+2
Remainder
Dd + 1
Dd
(BCD)
Dr + 1
Dr
(BCD)
R+1
(BCD)
Quotient
Sample program
0.00
/B
D100
D110
D120
0.00
/BL
D100
D110
D120
2-184
2 Instructions
Conversion Instructions
Conversion Instructions
BIN/BINL
Instruction
Mnemonic
Function
code
Variations
Function
BCD TO BINARY
BIN
@BIN
023
BINL
@BINL
058
BIN
BINL
BINL(058)
S: Source word
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
BIN
BINL
BIN
BINL
WORD
DWORD
UINT
UDINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
S,R
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Operation
Name
Label
BIN
Error Flag
P_ER
Equals Flag
P_EQ
Negative Flag
P_N
BINL
ON if the result is 0.
OFF
OFF
2-185
BIN/BINL
BIN(023)
Symbol
2 Instructions
Function
BIN
BIN(023) converts the BCD data in S to binary data S
(BCD)
and writes the result to R.
The following diagram shows an example BCD-to-binary conversion.
15 12 11 8 7
3
43
5
15 12 11 8 7
43
7
(BIN)
0
C
BINL
BINL(058) converts the 8-digit BCD data in S and
S+1
S
S+1 to 8-digit hexadecimal (32-bit binary) data and
(BCD)
(BCD)
writes the result to R and R+1.
The following diagram shows an example of 8-digit BCD-to-binary conversion.
S+1
0
R+1
S
0
107106105104103102101100
R+1
(BIN)
(BIN)
167166165164163162161160
Sample program
When CIO 0.00 is ON in the following example, the 8-digit BCD value in CIO 0010 and CIO 0011 is converted to hexadecimal and stored in D200 and D201.
0.00
BINL
10
D200
S+1 : CIO 11
2-186
S : CIO 10
107
106
105
104
103
102
200050=3164+13162+7161+2160
10 10
1
R+1 : D201
R : D200
2 Instructions
BCD/BCDL
Mnemonic
BINARY TO BCD
DOUBLE BINARY TO
DOUBLE BCD
Function
code
Variations
Function
BCD
@BCD
024
BCDL
@BCDL
059
BCD
BCDL
BCDL(059)
BCD(024)
Symbol
S: Source word
D: Result word
BCD/BCDL
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
BCD
BCDL
BCD
BCDL
UINT
UDINT
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
S,R
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Operation
Name
Label
BCD
Error Flag
P_ER
Equals Flag
P_EQ
Conversion Instructions
Instruction
BCDL
ON if the result is 0.
2-187
2 Instructions
Function
BCD
BCD(024) converts the binary data in S to BCD data
(BIN)
S
and writes the result to R.
The following diagram shows an example BCD-to-binary conversion.
15 12 11 8 7
1
43
E
15 12 11 8 7
43
3
(BCD)
0
2
BCDL
S
S+1
BCDL(059) converts the 8-digit hexadecimal (32-bit
(BCD)
(BCD)
binary) data in S and S+1 to 8-digit BCD data and
writes the result to R and R+1.
The following diagram shows an example of 8-digit BCD-to-binary conversion.
S+1
0
R+1
S
D
167166165164163162161160
R+1
(BIN)
(BIN)
107106105104103102101100
Sample program
When CIO 0.00 is ON in the following example, the hexadecimal value in CIO 11 and CIO 10 is converted to a BCD value and stored in D100 and D101.
0.00
BCDL
10
D100
S+1 : CIO 11
MBS
S: CIO 10
167
166
165
164
163
162
161
160
LSB
2165+13164+3163+2162+10=2961930
R+1 : D101
MBS
2-188
R : D100
107
106
105
104
103
102
101
100
LSB
2 Instructions
NEG
Mnemonic
2S COMPLEMENT
Variations
NEG
Function
code
Function
160
@NEG
NEG
NEG(160)
Symbol
S: Source word
R: Result word
Conversion Instructions
Instruction
Subroutines
Interrupt tasks
OK
OK
OK
NEG
Area
Usage
Operands
Operand
Description
Data type
Size
Source word
WORD
Result word
UINT
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Negative Flag
P_N
Function
NEG
NEG(160) calculates the 2s complement of S and writes the result
to R. The 2s complement calculation basically reverses the status of
the bits in S and adds 1.
2s complement
(Complement + 1)
(S)
(R)
Hint
This operation (reversing the status of the bits and adding 1) is equivalent to subtracting the content
of S/S+1 and S from 0000/0000 0000.
2-189
2 Instructions
Sample program
When CIO 0.00 is ON in the following example, NEG(160) calculates the 2s complement of the content
of D100 and writes the result to D200.
0.00
NEG
D100
D200
Actual
calculation
D100
Equivalent
subtraction
4
-)
Add 1
D200
2-190
2 Instructions
MLPX
Mnemonic
DATA DECODER
Variations
MLPX
Function
code
Function
076
@MLPX
Conversion Instructions
Instruction
MLPX
MLPX(076)
Symbol
C: Control word
MLPX
S: Source word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Source word
UINT
Control word
UINT
UINT
Variable
12 11
Digit 3
Digit 2
4 3
Digit 1
Digit 0
C: Control Word
15
C
12 11
0
4 3
8 7
l
0
n
Specifies the first digit/byte to be converted
0 to 3 (digit 0 to 3)
2-191
2 Instructions
8 7
Digit 1
Digit 0
C: Control Word
15
C
12 11
4 3
8 7
0
n
Specifies the first digit/byte to be converted
0 or 1 (byte 0 or 1)
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
CF
Pulse bits
TR bits
---
---
---
*DM
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if C is not within the specified ranges.
OFF in all other cases.
Function
MLPX(076) can perform 4-to-16 bit or 8-to-256 bit conversions. Set the leftmost digit of C to 0 to specify
4-to-16 bit conversion and set it to 1 to specify 8-to-256 bit conversion.
n
m
15
R
R+1
2-192
l
S
m
1
2 Instructions
0
m
1
16
239
R+14 255
R+15
R+16
R+17
224
240
2
MLPX
P
R+30
R+31
Hint
As shown at right, 4 to 16 decoding consists of taking the 4-bit binary value as the
bit number and setting 1 in that bit number and 0 in the other bit numbers of the
16 bits.
As shown at right, 8 to 256 decoding consists of taking the 8-bit binary value as the
bit number and setting 1 in that bit number and 0 in the other bit numbers of the
256 bits.
4 bits
m
15
0 1 0
0
8 bits
m
255
0 1 0
Precaution
4-to-16 bit conversion
When two or more digits are being converted, MLPX(076) will read the digits in S from right to left and
will wrap around to the rightmost digit after the leftmost digit, if necessary.
Conversion Instructions
2-193
2 Instructions
Sample program
4-to-16 bit Conversion
When CIO 0.00 is ON in the following example, MLPX(076) will convert 3 digits in S beginning with digit
1 (the second digit), as indicated by C (#0021). The corresponding bits in D100, D101, and D102 will be
turned ON.
0.00
MLPX
S
100
#0021
D100
15
C: #
Digits
S: 100
R: D100
12 11
4 3
3
F
2
A
1
6
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1
1
D101
D102
8 7
100
#1011
D100
15
12 11
C: #
S: 100
8 7
4 3
Byte 1
0
1
Byte 0
A
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R: D100
D101
D102
1
Byte 1 contains 2D, so bit 13 (D)
of R+2 is turned ON.
D103
D115
D116
D117
D118
1
Byte 0 contains 1A, so bit 10 (A)
of R+1 is turned ON.
D131
2-194
2 Instructions
15
C: #0031
8 7
15
12 11
4 3
0
S Digit 3 Digit 2 Digit 1 Digit 0
8 7
15
12 11
4 3
0
S Digit 3 Digit 2 Digit 1 Digit 0
15
15
R+1
R+1
R+1
R+2
R+2
R+3
R+3
15
8 7
C: #1011
4 3
Digit 0
15
0
S
15
D+15
D+15
D+16
D+16
D+31
D+31
12 11
Digit 1
8 7
4 3
Digit 0
MLPX
12 11
Digit 1
Conversion Instructions
C: #0010
8 7
15
12 11
4 3
0
S Digit 3 Digit 2 Digit 1 Digit 0
2-195
2 Instructions
DMPX
Instruction
Mnemonic
DATA ENCODER
Variations
DMPX
Function
code
Function
077
@DMPX
DMPX
DMPX(077)
Symbol
R: Result word
C: Control word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
Description
UINT
Variable
Result word
UINT
Control word
UINT
R: Result Word
15
R
12 11
Digit 3
Digit 2
8 7
4 3
Digit 1
0
Digit 0
C: Control Word
15
C
12 11
0
4 3
8 7
l
0
n
Specifies the first digit/byte to receive converted data.
0 to 3 (digit 0 to 3)
2-196
2 Instructions
R: Result Word
Digit 1
0
Digit 0
C: Control word
15
C
12 11
4 3
8 7
Conversion Instructions
8 7
15
n
Specifies the first digit/byte to receive converted data.
0 or 1 (byte 0 or 1)
DMPX
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
S,R
CF
Pulse bits
TR bits
---
---
---
---
OK
Flags
Name
Label
Error Flag
P_ER
Operation
ON if any of the source words contains 0000 hex (i.e., no bit to encode).
ON if C is not within the specified ranges.
OFF in all other cases.
Function
DMPX(077) can perform 16-to-4 bit or 256-to-8 bit conversions. Set the leftmost digit of C to 0 to specify
16-to-4 bit conversion and set it to 1 to specify 256-to-8 bit conversion.
S
S+1
R=1 (Convert
2 words.)
Leftmost bit
2-197
2 Instructions
I/0
0
16
Leftmost
bit
Rightmost
bit
224
240
m
1
Hint
As shown at right, 16 to 4 encoding consists of converting the bit number (m) of
the leftmost or rightmost bit that has 1 set
among the 16 bits to a 4-bit binary value.
15
0 1 0
0
Leftmost ON bit
Rightmost ON bit
m
4 bits
As shown at right, 256 to 8 encoding consists of converting the bit number (m) of
the leftmost or rightmost bit that has 1 set
among the 256 bits to an 8-bit binary
value.
255
0 1 0
Rightmost ON bit
Leftmost ON bit
m
8 bits
Precaution
16-to-4 bit conversion
When two or more digits are being converted, DMPX(077) will write the values to the digits in R from
right to left and will wrap around to the rightmost digit after the leftmost digit, if necessary.
2-198
2 Instructions
Sample program
16-to-4 bit Conversion
0.00
DMPX
S
100
D100
#0021
15
12 11
8 7
C: #
4 3
Conversion Instructions
When CIO 0.00 is ON in the following example, DMPX(077) will find the leftmost ON bits in CIO 100,
CIO 101, and CIO 102 and write those locations to 3 digits in R beginning with digit 1 (the second digit),
as indicated by C (#0021).
S: 100
Starting digit
(Digit 1)
101
Digits
15
2
12 11
1
8 7
DMPX
102
R: D100
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1
0
4 3
C: #0011
15
C: #0030
15
S+1
S+1
S+1
C: #0013
S+2
S+3
15
12 11
8 7
4 3
0
R Digit 3 Digit 2 Digit 1 Digit 0
15
12 11
8 7
4 3
0
Digit 3 Digit 2 Digit 1 Digit 0
15
12 11
8 7
4 3
0
R Digit 3 Digit 2 Digit 1 Digit 0
C: #0032
15
S
S+1
S+2
S+3
15
12 11
8 7
4 3
0
R Digit 3 Digit 2 Digit 1 Digit 0
2-199
2 Instructions
15
S+15
S+15
S+16
S+16
S+31
S+31
8 7
15
S
Digit 1
8 7
15
0
Digit 0
C: #1011
15
Digit 1
0
Digit 0
If the conversion data contains 0000 hex, but other data is to be encoded, separate the conversion by
using more than one DMPX(077) instructions.
DMPX(077) D0 D100 #0300
2-200
2 Instructions
ASC
Mnemonic
ASCII CONVERT
ASC
Function
code
Variations
@ASC
Function
Converts 4-bit hexadecimal digits in the source
word into their 8-bit ASCII equivalents.
086
ASC
ASC(086)
Symbol
S: Source word
DI
2
ASC
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Source word
UINT
DI
Digit designator
UINT
UINT
Variable
S: Source Word
15
S
Conversion Instructions
Instruction
8 7
0
12 11
4 3
Digit 3
Digit 2
Digit 1
Digit 0
8 7
15
Leftmost byte
Rightmost byte
D+1
Leftmost byte
Rightmost byte
D+2
Leftmost byte
Rightmost byte
0: None
1: Even
2: Odd
2-201
2 Instructions
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
---
DI
OK
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the content of Di is not within the specified ranges.
OFF in all other cases.
Function
ASC(086) treats the contents of S as 4 hexadecimal digits, converts the designated digit(s) of S
into their 8-bit ASCII equivalents, and writes this
data into the destination word(s) beginning with
the specified byte in D.
A parity specification (bits 12 to 15 of K) is possible in the leftmost bit of the ASCII code data,
and this can be converted to an odd or even parity bit (the number of bits that are 1 of the eight
bits is adjusted to odd or even).
0
1/0
Di
First digit to convert
m
3
HEX Number of
digits (n+1)
ASCII
Left (1)
D
Right (0)
33
31
32
Hint
The parity bit is appended to the data to enable detection of errors when the data is transmitted. By
adding this bit, the number of bits that are 1 in the data can be indicated as odd or even, and if the
number of 1s in the received data is not similarly odd or even, it is assumed that an error has
occurred.
Precaution
When multiple digits are specified in the number of digits to be converted (K), the digits are converted
in order from the starting conversion digit going left (returns to digit 0 after digit 3), and the conversion
results are stored in order from the output position of D going to the left word side (in units of 8 bits).
Among the data in the conversion result output word, data in positions that are not to be output are
held.
When converting multiple digits, take care that D+1 and D+2CH do not exceed the area.
2-202
2 Instructions
Sample program
0.00
ASC
S
D100
Di
#0121
D200
15
12 11
0
Di: #
8 7
1
4 3
2
Conversion Instructions
When CIO 0.00 is ON in the following example, ASC(086) converts three hexadecimal digits in D100
(beginning with digit 1) into their ASCII equivalents and writes this data to D200 and D201 beginning
with the leftmost byte in D200. In this case, a digit designator of #0121 specifies no parity, the starting
byte (when writing) = leftmost byte, the number of digits to read = 3, and the starting digit (when reading) = digit 1.
2
Number of digits
Starting digit
15
2
12 11
S: D100
1
8 7
ASC
Digits
0
4 3
3
Starting byte
(leftmost byte)
HEX
ASCII
15
8 7
D: D200
33
D201
31
0
32
Bit content
Code
#30
#31
#32
#33
#34
#35
#36
#37
#38
#39
#41
#42
#43
#44
#45
#46
2-203
2 Instructions
Parity
It is possible to specify the parity of the ASCII data for use in error control during data transmissions.
The leftmost bit of each ASCII character will be automatically adjusted for even, odd, or no parity.
When no parity (0) is designated, the leftmost bit will always be zero. When even parity (1) is designated, the leftmost bit will be adjusted so that the total number of ON bits is even. When odd parity (2)
is designated, the leftmost bit of each ASCII character will be adjusted so that there is an odd number
of ON bits. The status of the parity bit does not affect the meaning of the ASCII code.
Examples of even parity:
When adjusted for even parity, ASCII 31 (00110001) will be B1 (10110001: parity bit turned ON to
create an even number of ON bits); ASCII 36 (00110110) will be 36 (00110110: parity bit remains
OFF because the number of ON bits is already even).
Examples of odd parity:
When adjusted for odd parity, ASCII 36 (00110110) will be B6 (10110110: parity bit turned ON to
create an odd number of ON bits); ASCII 46 (01000110) will be 46 (01000110: parity bit remains
OFF because the number of ON bits is already odd).
Examples of Di
Di: #0011
8 7
15
12 11
4 3
0
S Digit 3 Digit 2 Digit 1 Digit 0
15
8 7
Leftmost
Di: #0112
8 7
15
12 11
4 3
0
S Digit 3 Digit 2 Digit 1 Digit 0
0
Rightmost
15
D
D+1
8 7
Di: #0030
8 7
15
12 11
4 3
0
S Digit 3 Digit 2 Digit 1 Digit 0
Leftmost
15
D
Rightmost
D+1
8 7
Leftmost
Leftmost
0
Rightmost
Rightmost
Di: #0130
8 7
15
12 11
4 3
0
S Digit 3 Digit 2 Digit 1 Digit 0
15
D
D+1
D+2
2-204
8 7
Leftmost
Leftmost
Rightmost
Rightmost
2 Instructions
HEX
Mnemonic
ASCII TO HEX
Variations
HEX
Function
code
Function
162
@HEX
HEX
Conversion Instructions
Instruction
HEX(162)
Symbol
DI
D: Destination word
2
HEX
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
Description
UINT
Variable
DI
Digit designator
UINT
Destination word
UINT
D: Destination Word
8 7
15
Leftmost byte
0
Rightmost byte
15
12 11
4 3
8 7
0
Digit 3
Digit 2
Digit 1
Digit 0
The results of conversion to hex are stored
from the starting digit going left (returns to
digit 0 after digit 3)
0: None
1: Even
2: Odd
2-205
2 Instructions
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
---
DI
OK
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if there is a parity error in the ASCII data.
ON if the ASCII data in the source words is not equivalent to hexadecimal digits
ON if the content of Di is not within the specified ranges.
OFF in all other cases.
Function
HEX(162) treats the contents of the source
word(s) as ASCII data representing hexadecimal digits (0 to 9 and A to F), converts
the specified number of bytes to hexadecimal, and writes the hexadecimal data to the
destination word beginning at the specified
digit.
When converting data, the leftmost bit of
the ASCII code data can be treated as an
odd or even parity bit according to the parity
specification.
Di
0/1
S
S+1
Right (0)
32
34
ASCII
HEX
D
m
2
Hint
The parity bit is appended to the data to enable detection of errors when the data is transmitted. By
adding this bit, the number of bits that are 1 in the data can be indicated as odd or even, and if the
number of 1s in the received data is not similarly odd or even, it is assumed that an error has
occurred.
Precaution
When multiple digits are specified in the number of digits to be converted (C), the digits are converted
in order from the starting conversion position (C) of S going to the left word side, and the conversion
results are stored in order from the output starting bit (C) of D going to the left (returns to digit 0 after
digit 3).
Among the data in the conversion result output word, data of bits that are not to be output are held
(kept the same as before).
The following table shows ASCII data which can be contained in the source word(s) (excluding parity
bits) and corresponding hexadecimal digits.
ASCII data (2 hexadecimal digits)
2-206
Hexadecimal digits
30 to 39
0 to 9
41 to 46
A to F
2 Instructions
Sample program
HEX(162) converts three bytes of ASCII data (3 characters) beginning with the leftmost byte of D100
into their hexadecimal equivalents and writes this data to D200 beginning with digit 1.
0.00
HEX
S
D100
Di
#0121
D200
15
Di:#
12 11
0
8 7
1
4 3
2
Conversion Instructions
When CIO 0.00 is ON in the following example, HEX(162) converts the ASCII data in D100 and D101
according to the settings of the digit designator. (Di=#0121 specifies no parity, the starting byte (when
reading) = leftmost byte, the number of bytes to read = 3, and the starting digit (when writing) = digit 1.)
Starting byte
(leftmost byte)
HEX
15
8 7
S:D100
33
D101
35
0
34
Number of digits
Starting digit (digit 1)
3 digits
3
15
Di:D200
2
12 11
1
8 7
0
4 3
Parity
It is possible to specify the parity of the ASCII data for use in error control during data transmissions.
The leftmost bit in each byte is the parity bit. With no parity the parity bit should always be zero, with
even parity the status of the parity bit should result in an even number of ON bits, and with odd parity
the status of the parity bit should result in an odd number of ON bits.
The following table shows the operation of HEX(162) for each parity setting.
Parity setting
(leftmost digit of Di)
Operation of HEX(162)
No parity (0)
HEX(162) will be executed only when the parity bit in each byte is 0. An error will occur if a parity bit is non-zero.
HEX(162) will be executed only when there is an even number of ON bits in each byte. An error will occur if a byte has an
odd number of ON bits.
HEX(162) will be executed only when there is an odd number of ON bits in each byte. An error will occur if a byte has an
even number of ON bits.
2-207
2 Instructions
Output example
Conversion data
ASCII
code
Value
Bit content
#30
#31
#32
#33
#34
#35
#36
#37
#38
#39
#41
#42
#43
#44
#45
#46
When CIO 0.00 is ON in the following example, HEX(162) converts the ASCII data in D10 beginning
with the rightmost byte and writes the hexadecimal equivalents in D300 beginning with digit 1.
The digit designator setting of #1011 specifies even parity, the starting byte (when reading) = rightmost
byte, the number of bytes to read = 2, and the starting digit (when writing) = digit 1.)
0.00
HEX
15
D10
0
1
#1011
D300
Starting digit in D: Digit 1
Number of bytes: 2
Starting byte in S: Rightmost
Parity: Even
Parity bits: Result in even parity
15
0
S: D100 1 1 0 0 0 0 1 1 1 0 1 1 1 0 0 0
43
38
Starting byte: rightmost
Conversion
Starting digit (digit 1)
15
12 11
D: D300
8 7
C
4 3
8
0
Not changed
Number of bytes (2 bytes)
Not changed
2-208
2 Instructions
Leftmost
Rightmost
Di: #0030
8 7
15
Leftmost
S+1 Leftmost
Rightmost
Rightmost
8 7
15
12 11
4 3
0
D Digit 3 Digit 2 Digit 1 Digit 0
Leftmost
S+1 Leftmost
S+2
8 7
15
12 11
4 3
0
D Digit 3 Digit 2 Digit 1 Digit 0
Di: #0131
8 7
15
Rightmost
Rightmost
8 7
15
12 11
4 3
0
F Digit 3 Digit 2 Digit 1 Digit 0
Conversion Instructions
Di: #0112
8 7
2
HEX
2-209
2 Instructions
Logic Instructions
ANDW/ANDL
Instruction
Mnemonic
Variations
Function
code
Function
LOGICAL AND
ANDW
@ANDW
034
Takes the logical AND of corresponding bits in single words of word data and/or constants.
ANDL
@ANDL
610
ANDW
ANDL
ANDW(034)
ANDL(610)
Symbol
I1
I1 : Input 1
I2 : Input 2
I2
I2 : Input 2
R: Result word
R: Result word
I1
I1 : Input 1
I2
R
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
ANDW
ANDL
ANDW
ANDL
I1
Input 1
WORD
DWORD
I2
Input 2
WORD
DWORD
Result word
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
I1, I2
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Negative Flag
P_N
2-210
2 Instructions
Function
ANDW
I1, I2 R
ANDL
I1
I2
Logic Instructions
ANDW(034) takes the logical AND of data specified in I1 and I2 and outputs the result to R.
ANDL(610) takes the logical AND of data specified in I1, I1+1 and I2, I2+1 and outputs the result
to R, R+1.
I2, I2+1
R, R+1
2
ANDW/ANDL
I1, I1+1
Sample program
When the execution condition CIO 0.00 is ON, the logical AND is taken of corresponding bits in CIO 11,
CIO 10 and CIO 21, CIO 20 and the results will be output to corresponding bits in D201 and D200.
S1: 10CH
S1+1: 11CH
0.00
S2: 20CH
S2+1: 21CH
D: D200
D+1: D201
ANDL
10.00
20.00
00
10
10.01
20.01
01
20
10.02
20.02
02
D200
10.03
20.03
03
10.04
20.04
04
11.13
21.13
13
11.14
21.14
14
11.15
21.15
15
2-211
2 Instructions
ORW/ORWL
Instruction
Mnemonic
Variations
Function
code
Function
LOGICAL OR
ORW
@ORW
035
Takes the logical OR of corresponding bits in single words of word data and/or constants.
DOUBLE LOGICAL OR
ORWL
@ORWL
611
Takes the logical OR of corresponding bits in double words of word data and/or constants.
ORW
ORWL
ORW(035)
Symbol
ORWL(611)
I1
I1: Input 1
I1
I1: Input 1
I2
I2: Input 2
I2
I2: Input 2
R: Result word
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
ORW
ORWL
ORW
ORWL
Input 1
WORD
DWORD
I2
Input 2
WORD
DWORD
Result word
WORD
DWORD
I1
Operand Specifications
Word addresses
Indirect DM addresses
Area
I1, I2
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Negative Flag
P_N
2-212
2 Instructions
Function
ORW
I1, I2 R
ORWL
I1
I2
Logic Instructions
ORW(035) takes the logical OR of data specified in I1 and I2 and outputs the result to R.
I2, I2+1
R, R+1
2
ORW/ORWL
I1, I1+1
Sample program
When the execution condition CIO 0.00 is ON, the logical OR is taken of corresponding bits in CIO 21,
CIO 20 and CIO 31, CIO 30 and the results will be output to corresponding bits in D501 and D500.
0.00
ORWL
20
30
D500
S1: 20CH
S1+1: 21CH
S2: 30CH
S2+1: 31CH
D: D500
D+1: D501
D500
20.00
30.00
00
20.01
30.01
01
20.02
30.02
02
20.03
30.03
03
20.15
30.15
15
21.00
31.00
00
21.15
31.15
15
D501
2-213
2 Instructions
XORW/XORL
Instruction
Mnemonic
Variations
Function
code
Function
EXCLUSIVE OR
XORW
@XORW
036
DOUBLE EXCLUSIVE OR
XORL
@XORL
612
XORW
XORL
XORW(036)
XORL(612)
Symbol
I1
I1: Input 1
I1
I1: Input 1
I2
I2: Input 2
I2
I2: Input 2
R: Result word
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
XORW
XORL
XORW
XORL
I1
Input 1
WORD
DWORD
I2
Input 2
WORD
DWORD
Result word
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
I1, I2
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Negative Flag
P_N
2-214
2 Instructions
Function
XORW
I1 I2 + I1 I2 R
I1
I2
Logic Instructions
XORL
XORL(612) takes the logical exclusive OR of
data specified in I1 and I2 as double-word data
and outputs the result to R, R+1.
(I1, I1+1) (I2, I2+1) + (I1, I1+1) (I2, I2+1) (R, R+1)
I2, I2+1
R, R+1
XORW/XORL
I1, I1+1
Sample program
When the execution condition CIO 0.00 is ON, the logical exclusive OR is taken of corresponding bits in
CIO 151, CIO 150 and D1001, D1000 and the results will be output to corresponding bits in D1201 and
D1200.
0.00
XORL
S1: 150CH
S1+1: 151CH
1
150.00
D1000
S2: D1000
S2+1: D1001
1
00
D1200
D: D1200
D+1: D1201
0
00
150
150.01
01
01
D1000
150.02
02
02
D1200
150.03
03
03
150.15
15
15
151.00
00
00
151.15
15
15
D1001
D1201
2-215
2 Instructions
COM/COML
Instruction
Mnemonic
Variations
Function
code
Function
COMPLEMENT
COM
@COM
029
DOUBLE COMPLEMENT
COML
@COML
614
COM
COML
COM(029)
Symbol
COML(614)
Wd: Word
Wd
Wd: Word
Wd
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
Wd
Word
COM
COML
COM
COML
WORD
DWORD
Operand Specifications
Word addresses
Indirect DM addresses
Area
Wd
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Negative Flag
P_N
Function
COM
COM(029) reverses the status of every specified bit in Wd.
WdWd: 1 0 and 0 1
Note When using the COM instruction, be aware that the status of each bit will change each cycle in which the
execution condition is ON.
COML
COML(614) reverses the status of every specified bit in Wd and Wd+1.
(Wd+1, Wd)(Wd+1, Wd)
Note When using the COML instruction, be aware that the status of each bit will change each cycle in which the
execution condition is ON.
2-216
2 Instructions
Sample program
When CIO 0.00 is ON in the following example, the status of each bit D100 will be reversed.
0.00
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D100 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
D100
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D100 0 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0
When CIO 0.00 is ON in the following example, the status of each bit in D100 and D101 will be
reversed.
0.00
COML
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D100 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D100 0 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0
Logic Instructions
COM
D100
2-217
COM/COML
2 Instructions
Mnemonic
ARITHMETIC PROCESS
Variations
APR
Function
code
@APR
Function
Calculates the sine, cosine, or a linear extrapolation of the source data.
069
APR
APR(069)
Symbol
C: Control word
S: Source word
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
Control word
UINT
Variable
Source data
WORD
Result word
WORD
Description
Sine Function
Operand
Value
Data range
0000 hex
---
0 to 90
0.0000 to 0.9999
1.0000
Cosine Function
Operand
Value
Data range
0001 hex
0 to 90
---
0.0000 to 0.9999
1.0000
Note The actual result for SIN(90) and COS(0) is 1, but 9999 (0.9999) will be output to R.
2-218
2 Instructions
---
0000 to 9999
Data range
0 to 65,535
-32,768 to 32,767
-2,147,483,648 to
2,147,483,647
- ,
Floating-point data
-3.402823 1038 to
Value
-1.175494 10-38,
1.175494 10-38 to
3.402823 1038,
+
0000 to 9999
APR
0 to 65,535
-32,768 to 32,767
-2,147,483,648 to
2,147,483,647
- ,
Floating-point data
-3.402823 1038 to
-1.175494 10-38,
1.175494 10-38 to
3.402823 1038,
+
15 14 13 12 11 10 9
2-219
2 Instructions
0
Number of coordinates minus one (m-1),
00 to FF hex (1 m 256)
Floating-point specification for S and D
0: Integer data
0 0
0
Number of coordinates minus one (m-1),
00 to FF hex (1 m 256)
Floating-point specification for S and D
1: Single-precision floating-point data
X0 (*1)
C+2
Y0
C+3
X1
C+4
Y1
C+5
X2
C+6
Y2
Xn
X0 (rightmost 16 bits)
C+2
X0 (leftmost 16 bits)
C+3
Y0 (rightmost 16 bits)
C+4
Y0 (leftmost 16 bits)
C+5
X1 (rightmost 16 bits)
C+6
X1 (leftmost 16 bits)
C+7
Y1 (rightmost 16 bits)
C+8
Y1 (leftmost 16 bits)
to
to
Yn
Xm
C+ (2m+1)
Ym
C+ (2m+2)
Floating-point data
to
C+ (4n+1)
Xn (rightmost 16 bits)
C+ (4n+2)
Xn (leftmost 16 bits)
C+ (4n+3)
Yn (rightmost 16 bits)
C+ (4n+4)
to
Yn (leftmost 16 bits)
to
C+ (4m+1)
Xm (rightmost 16 bits)
C+ (4m+2)
Xm (leftmost 16 bits)
C+ (4m+3)
Ym (rightmost 16 bits)
C+ (4m+4)
Ym (leftmost 16 bits)
Note: The X coordinates must be in ascending order: X1 < X2 < ... < Xm. Input
all values of (Xn, Yn) as binary data, regardless of the data format
specified in control word C.
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
C,S
R
2-220
CF
Pulse bits
TR bits
---
---
---
OK
---
2 Instructions
Flags
Name
Label
P_ER
Operation
ON if C is a constant greater than 0001.
ON if C is a word address but the X coordinates are not in ascending order (X1 X2 ... Xm).
ON if C is a word address and bits 9, 11, and 15 of C indicate BCD input, but S is not BCD.
ON if C is a word address and bit 9 of C indicates floating-point data, but S is a one-word constant.
ON if C is 0000 or 0001 but S is not BCD between 0000 and 0900.
OFF in all other cases.
Equals Flag
P_EQ
Negative Flag
P_N
ON if the result is 0.
OFF in all other cases.
ON if bit 15 of R is ON.
Error Flag
Function
Operation of the Linear Extrapolation Function
1. For S < X0
Converted value = Y0
2. For X0 S Xmax, if Xn < S < Xn+1
Converted value = Yn +[{Yn + 1 - Yn}/{Xn + 1 - Xn}] {Input data S - Xn}
3. Xmax < S
Converted value = Ymax
Y (Binary data)
Ymax
Y0
X0
Xmax
X (Binary data)
Up to 256 endpoints can be stored in the line-segment data table beginning at C+1.
Y (binary data)
Equation:
f(S)= Yn+
Yn+1
Calculation
result
Yn
Xn+1-Xn
Xn
Xn+1
X (binary data)
Input data
2-221
APR
APR(069) processes the input data specified in S with the following equation and the line-segment data
(Xn, Yn) specified in the table beginning at C+1. The result is output to the destination word(s) specified
with D.
2 Instructions
Setting name
Input data (S) format
Bit in C
15
14
13
11
10
Floating-point specification
09
Setting
0: Binary
1: BCD
0: Binary
1: BCD
0: Operate on S
1: Operate on Xm-S
0: Unsigned data
Invalid (fixed at 16 bits)
0: Integer data
Setting name
Input data (S) format
Bit in C
15
14
Setting
0: Binary
1: BCD
0: Binary
1: BCD
0: Operate on S
13
Signed data specification for S
and D
11
10
Floating-point specification
09
1: Operate on Xm-S
0: Unsigned data
Invalid (fixed at 16 bits)
0: Integer data
Bit in C
Setting
15
0: Binary
14
0: Binary
13
11
10
Floating-point specification
09
0: Integer data
1: Signed data
Bit in C
Setting
15
0: Binary
14
0: Binary
13
0
1: Signed data
11
10
Floating-point specification
09
0: Integer data
Note If the Data length specification for S and D in bit 10 of C is set to 1 and
a 16-bit constant is input for S, the input data will be converted to 32-bit
signed binary before the linear extrapolation calculation.
2-222
2 Instructions
Floating-point Data
Setting name
Bit in C
Setting
15
14
13
11
10
Floating-point specification
09
0
0
1: Floating-point data
Sample program
Sine Function (C: #0000)
APR
The following example shows APR(069) used to calculate the sine of 30.
(SIN(30) = 0.5000)
Source data
0.00
Result
S: D0
APR
R: D100
#0000
101
100
101
D000
D100
101
102
103
104
degrees.
0.00
Source data
Result
S: D10
R: D100
APR
#0001
101
100
101
101
102
103
104
D010
D200
Y
Ym
Y4
Y3
Y1
Y2
Y0
X0 X1
X2
X3
X4
Xm
2-223
2 Instructions
Yn = f(Xn), Y0 = f(X0)
Word
Coordinate
C+1
Xm (max. X value)
C+2
Y0
C+3
X1
C+4
Y1
C+5
X2
C+6
Y2
C+(2m+1)
Xm (max. X value)
C+(2m+2)
Ym
This example shows how to construct a linear extrapolation with 12 coordinates. The block of data is
continuous, as it must be, from D0 to D26 (C to C + (2 12 + 2)). The input data is taken from CIO 10,
and the result is output to CIO 11.
0.00
Content
APR
D0
10
11
Bit
00
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1
D0
000B Hex
D1
05F0 Hex
X12
D2
0000 Hex
Y0
D3
0005 Hex
X1
D4
0F00 Hex
Y1
D5
001A Hex
X2
D6
0402 Hex
Y2
Bit
15
Coordinate
D25
05F0 Hex
X12
D26
1F20 Hex
Y12
x=S
In this case, the source word, CIO 0010, contains 0014, and f(0014) = 0726 is output to R, CIO 0011.
Y
$1F20
$0F00
(x,y)
$0726
$0402
X
(0,0)
$0005
$0014
$001A
$05F0
2-224
2 Instructions
Fluid volume= Y
APR
C
S
R
Y: Fluid volume
Ym
R
R+1
X: Variation from standard
Y data range:
2,147,483,648 to
2,147,483,647
Y0
X0
Xm
S
S+1
High-resolution 32-bit
signed binary data
2-225
2 Instructions
Fluid volume
=Y
Fluid height = X
0.00
APR
C
S
R
Y: Fluid volume
X: Fluid height
Ym
Y data range:
, 3.402823 1038 to
1.175494 1038,
1.175494 1038 to
3.402823 1038, or +
R
R+1
Y0
0
High-resolution
floating point data
2-226
X0
Xm
S
S+1
X data range:
, 3.402823 1038 to 1.175494 1038,
1.175494 1038 to 3.402823 1038, or +
2 Instructions
BCNT
Mnemonic
BIT COUNTER
Variations
BCNT
Function
code
Function
067
@BCNT
BCNT
BCNT(067)
Symbol
N: Number of words
R: Result word
2
BCNT
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Number of words
Data type
Size
UINT
UINT
Variable
Result word
UINT
N: Number of words
The number of words must be 0001 to FFFF (1 to 65,535 words).
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
S,R
---
Flags
Name
Instruction
Label
Operation
Error Flag
P_ER
ON if N is 0000.
ON if result exceeds FFFF.
OFF in all other cases.
Equals Flag
P_EQ
Function
BCNT(067) counts the total number of bits
that are ON in all words between S and S+(N1) and places the result in R.
S
N words
to
S+(N1)
Binary result
R
T
2-227
2 Instructions
Precautions
Some time will be required to complete BCNT(067) if a large number of words is specified. Even if an
interrupt occurs, execution of this instruction will not be interrupted and execution of the interrupt task
will be started after execution of BCNT(067) has been completed. One BCNT(067) instruction can
be replaced with two BCNT(067) instructions to help avoid this problem.
BCNT
BCNT
&1000
&500
D1000
D1000
W0
W1
BCNT
&500
D1500
W2
+
W1
W2
W0
Sample Program
When CIO 0.00 is ON in the following example, BCNT(067) counts the total number of ON bits in the 10
words from CIO 100 through CIO 109 and writes the result to D100.
15
0.00
BCNT
2-228
&10
100
D100
10 words
100
101
to
109
23 hexadecimal
(35 decimal)
2 Instructions
The floating-point data format conforms to the IEEE754 standards. Data is expressed in 32 bits, as follows:
Sign
Exponent
Mantissa
31
30
Data
23
22
No. of bits
Contents
s: sign
0: positive; 1: negative
e: exponent
The exponent (e) value ranges from 0 to 255. The actual exponent is the
value remaining after 127 is subtracted from e, resulting in a range of
127 to 128. e=0 and e=255 express special numbers.
f: mantissa
23
The mantissa portion of binary floating-point data fits the formal 2.0 > 1.f 1.0.
Number of Digits
The number of effective digits for floating-point data is seven digits for decimal.
Floating-point Data
The following data can be expressed by floating-point data:
3.402823 1038 value 1.175494 1038
0
1.175494 1038 value 3.402823 1038
+
Not a number (NaN)
1.175494 1038
Floating-point Math
Instructions
The Floating-point Math Instructions convert data and perform floating-point arithmetic operations.
3.402823 1038
1.175494 1038
3.402823 1038
Special Numbers
The formats for NaN, , and 0 are as follows:
NaN*:e = 255, f 0
+:e = 255, f = 0, s= 0
:e = 255, f = 0, s= 1
0: e = 0, f = 0
* NaN (not a number) is not a valid floating-point number. Executing floating-point calculation instructions will not
result in NaN.
2-229
2 Instructions
7 6
n
n+1 s
f
e
It is not necessary for the user to be aware of the IEEE754 data format when reading and writing floating-point data. It is only necessary to remember that floating point values occupy two words each.
Mantissa (f)
Not 0
Non-normalized number
All 1s (255)
Infinity
NaN
Note A non-normalized number is one whose absolute value is too small to be expressed as a normalized number. Non-normalized numbers have fewer significant digits. If the result of calculations is a non-normalized
number (including intermediate results), the number of significant digits will be reduced.
23 22
1 1 0 0 0 0 0 0 00 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Sign:
Exponent:
Mantissa:
Value:
2-230
128 127 = 1
1 + (222 + 221) 223 = 1 + (21 + 22) = 1 + 0.75 = 1.75
1.75 21 = 3.5
2 Instructions
23 22
0 0 0 0 0 0 0 0 00 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Sign:
Exponent:
Mantissa:
Value:
126
0 + (222 + 221) 223 = 0 + (21 + 22) = 0 + 0.75 = 0.75
0.75 2126
(3) Zero
Values of +0.0 and 0.0 can be expressed by setting the sign to 0 for positive or 1 for negative. The
exponent and mantissa will both be 0. Both +0.0 and 0.0 are equivalent to 0.0. Refer to Floating-point
Arithmetic Results, below, for differences produced by the sign of 0.0.
(4) Infinity
Values of + and can be expressed by setting the sign to 0 for positive or 1 for negative. The exponent will be 255 (28 1) and the mantissa will be 0.
(5) NaN
NaN (not a number) is produced when the result of calculations, such as 0.0/0.0, /, or , does not
correspond to a number or infinity. The exponent will be 255 (28 1) and the mantissa will be not 0.
Note There are no specifications for the sign of NaN or the value of the mantissa field (other than to be not 0).
Floating-point Math
Instructions
The mantissa (f) will be expressed from 1 to 233 1, and it is assume that, in the real mantissa, bit 233
is 0 and the binary point follows immediately after it.
2-231
2 Instructions
2-232
2 Instructions
FIX/FIXL
Instruction
Mnemonic
Function
code
Variations
Function
FIX
@FIX
450
FLOATING TO 32-BIT
FIXL
@FIXL
451
FIX
FIXL
FIX(450)
FIXL(451)
Symbol
R: Result word
FIX/FIXL
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
FIX
FIXL
FIX
REAL
REAL
INT
DINT
FIXL
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Error Flag
Label
P_ER
Operation
FIX
ON if the integer portion of S+1 and S is not within the range of -32,768 to 32,767.
FIXL
ON if the integer portion of S+1 and S is not within the range of -2,147,483,648 to 2,147,483,647.
ON if the data in S+1 and S is not a number (NaN).
OFF in all other cases.
Equals Flag
P_EQ
Negative Flag
P_N
Floating-point Math
Instructions
FLOATING TO 16-BIT
2-233
2 Instructions
Function
FIX
FIX(450) converts the integer portion of the 32-bit floating-point number in S+1 and S (IEEE754-format)
to 16-bit signed binary data and places the result in R.
S+1
Only the integer portion of the floating-point data is converted, and the fraction portion is truncated.
Example conversions:
A floating-point value of 3.5 is converted to 3.
A floating-point value of 3.5 is converted to 3.
FIXL
FIXL(451) converts the integer portion of the 32-bit floating-point number in S+1 and S (IEEE754-format) to 32-bit signed binary data and places the result in R+1 and R.
S+1
R+1
Only the integer portion of the floating-point data is converted, and the fraction portion is truncated.
Example conversions:
A floating-point value of 2,147,483,640.5 is converted to 2,147,483,640.
A floating-point value of 214,748,340.5 is converted to 214,748,340.
2-234
2 Instructions
FLT/FLTL
Instruction
Mnemonic
Function
code
Variations
Function
FLT
@FLT
452
32-BIT TO FLOATING
FLTL
@FLTL
453
FLT
FLTL
FLTL(453)
FLT(452)
Symbol
S: Source word
FLT/FLTL
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Data type
Operand
Size
Description
FLT
FLTL
FLT
INT
DINT
REAL
REAL
FLTL
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Floating-point Math
Instructions
16-BIT TO FLOATING
Label
Operation
Error Flag
P_ER
OFF
Equals Flag
P_EQ
Negative Flag
P_N
2-235
2 Instructions
Function
FLT
FLT(452) converts the 16-bit signed binary value in S to 32-bit floating-point data (IEEE754-format) and
places the result in R+1 and R. A single 0 is added after the decimal point in the floating-point result.
R+1
Only values within the range of -32,768 to 32,767 can be specified for S. To convert signed binary data
outside of that range, use FLTL(453).
Example conversions:
A signed binary value of 3 is converted to 3.0.
A signed binary value of -3 is converted to -3.0.
FLTL
FLTL(453) converts the 32-bit signed binary value in S+1 and S to 32-bit floating-point data (IEEE754format) and places the result in R+1 and R. A single 0 is added after the decimal point in the floatingpoint result.
CY
1
B 8 A 3
6 0 E 3
R+1: D00101
R+1: D00100
6 8 5 1
F 9 2 D
Signed binary data within the range of 2,147,483,648 to 2,147,483,647 can be specified for S+1 and
S. The floating point value has 24 significant binary digits (bits). The result will not be exact if a number
greater than 16,777,215 (the maximum value that can be expressed in 24-bits) is converted by
FLTL(453).
Example Conversions:
A signed binary value of 16,777,215 is converted to 16,777,215.0.
A signed binary value of 16,777,215 is converted to 16,777,215.0.
2-236
2 Instructions
+F, F, *F, /F
Instruction
Mnemonic
Variations
Function
FLOATING-POINT ADD
+F
@+F
454
FLOATING-POINT SUBTRACT
@F
455
FLOATING-POINT MULTIPLY
*F
@*F
456
FLOATING-POINT DIVIDE
/F
@/F
457
+F(454)
F(455)
Au
Mi
AD
Su
R
Symbol
*F
/F
*F(456)
/F(457)
Md
Dd
Mr
Dr
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Au
AD
Mi
Su
Md
Mr
Dd
Dr
+F
-F
*F
/F
R
Data type
Size
REAL
REAL
REAL
REAL
REAL
Operand Specifications
Word addresses
Indirect DM addresses
Area
Au, AD, Mi, Su,
Md, Mr, Dd, Dr
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
2
+F, F, *F, /F
+F
Floating-point Math
Instructions
Function
code
---
2-237
2 Instructions
Flags
Name
Label
Error Flag
P_ER
Operation
+F
ON if the augend or addend data is not a number (NaN).
ON if + and are added.
-F
ON if the minuend or subtrahend is not a number (NaN).
ON if + is subtracted from +.
ON if is subtracted from .
*F
ON if the multiplicand or multiplier is not a number (NaN).
ON if + and 0 are multiplied.
ON if and 0 are multiplied.
/F
ON if the dividend or divisor is not a number (NaN).
ON if the dividend and divisor are both 0.
ON if the dividend and divisor are both + or .
OFF in all other cases.
Equals Flag
P_EQ
Overflow Flag
P_OF
Underflow Flag
P_UF
Negative Flag
P_N
Function
The data specified in Au/Mi/Md/Dd and the data specified in AD/Su/Mr/Dr are added (+F), subtracted
(-F), multiplied (*F), or divided (/F) as single-precision floating-point data (32 bits: IEEE754) and output
to R+1, R.
+F
Au+1
Au
Ad+1
Ad
R+1
Mi+1
Mi
Su+1
Su
R+1
-F
2-238
2 Instructions
*F
Md
Mr+1
Mr
R+1
Floating-point Math
Instructions
Md+1
/F
Dd
Dr+1
Dr
R+1
If the absolute value of the result is greater than the maximum value that can be expressed as floating-point data, the Overflow Flag will turn ON and the result will be output as .
If the absolute value of the result is less than the minimum value that can be expressed as floatingpoint data, the Underflow Flag will turn ON and the result will be output as 0.
Operation rules
The result of an operation is output as shown below depending on the combination of floating-point
data.
Numeral
Numeral
Numeral
Numeral
See note 1.
ER
ER
NaN
NaN
ER
The Error Flag will be turned ON and the instruction will not be executed.
Numeral
Numeral
Numeral
Numeral
See note 1.
ER
ER
NaN
NaN
ER
The Error Flag will be turned ON and the instruction will not be executed.
2-239
+F, F, *F, /F
Dd+1
2 Instructions
Numeral
ER
ER
Numeral
See note 1.
+/
+/
ER
+/
ER
+/
NaN
NaN
ER
The Error Flag will be turned ON and the instruction will not be executed.
Numeral
ER
+/
Numeral
See note 2.
+/
+/
0 (See note 1)
ER
ER
0 (See note 1)
ER
ER
NaN
NaN
ER
2-240
The Error Flag will be turned ON and the instruction will not be executed.
2 Instructions
Mnemonic
Single-precision Floating-point
Comparison
Function
code
Function
---
329
330
331
332
333
334
LD connection
Symbol
AND connection
OR connection
Mnemonic
Mnemonic
Mnemonic
S1: Comparison data 1
S1
S1
S2
S2
S2
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Description
Data type
Size
S1
Comparison data 1
REAL
S2
Comparison data 2
REAL
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
S1, S2
Constants
CF
Pulse bits
TR bits
OK
---
---
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if S1+1, S1 or S2+1, S2 is not a number (NaN).
ON if S1+1, S1 or S2+1, S2 is +.
ON if S1+1, S1 or S2+1, S2 is .
OFF in all other cases.
P_GT
P_GE
Equal Flag
P_EQ
P_NE
P_LT
P_LE
Negative Flag
P_N
Unchanged
2-241
S1
Operand
Floating-point Math
Instructions
=F
<>F
<F
<=F
>F
>=F
Variations
2 Instructions
Function
The input comparison instruction
compares the data specified in S1
and S2 as single-precision floating
point values (32-bit IEEE754 data)
and creates an ON execution condition when the comparison condition
is true.
When the data is stored in words, S1
and S2 specify the first of two words
containing the 32-bit data. It is also
possible to input the floating-point
data as an 8-digit hexadecimal constant.
The input comparison instructions
are treated just like the LD, AND, and
OR instructions to control the execution of subsequent instructions.
LD connection
<F
S1
S2
ON execution condition when
comparison result is true.
AND connection
<F
S1
S2
OR connection
LD: The instruction can be connected directly to the left bus bar.
<F
AND: The instruction cannot be connected directly to the left bus bar.
S1
ON execution condition when
comparison result is true.
S2
OR: The instruction can be connected directly to the left bus bar.
Options
With the three input types and six symbols, there are 18 different possible combinations.
Symbol
(LD, AND, and OR cannot be
used in a ladder program)
LD=, AND=, OR=, LD<>, AND<>,
OR<>, LD<, AND<, OR<, LD<=,
AND<=, OR<=, LD>, AND>, OR>,
LD>=, AND>=, OR>=
Code
329
330
331
332
333
2-242
F: Single-precision floating-point
data
Mnemonic
LD=F
Name
LOAD FLOATING EQUAL
AND=F
OR=F
OR FLOATING EQUAL
LD<>F
AND<>F
True if
S1+1, S1 =
S2+1, S2
True if
S1+1, S1
S2+1, S2
OR<>F
LD<F
AND<F
OR<F
LD<=F
AND<=F
OR<=F
LD>F
AND>F
OR>F
Function
True if
S1+1, S1 <
S2+1, S2
True if
S1+1, S1
S2+1, S2
True if
S1+1, S1 >
S2+1, S2
2 Instructions
Code
334
Mnemonic
Name
Function
AND>=F
OR>=F
True if
S1+1, S1
S2+1, S2
Precautions
Input comparison instructions cannot be used as right-hand instructions, i.e., another instruction
must be used between them and the right bus bar.
Sample program
When CIO 0.00 is ON in the following example, the floating point data in D101, D100 is compared to the
floating point data in D201, D200. If the content of D101, D100 is less than that of D201, D200, execution proceeds to the next line and CIO 50.00 is turned ON. If the content of D101, D100 is not less than
that of D201, D200, execution does not proceed to the next instruction line.
<F
D100
D200
S1: D100 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
S1+1:D101 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 1
Decimal value: 2.3
15
S2: D200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S2+1:D201 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0
Decimal value: 3.5
2.3>3.5
15
S1: D100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S1+1:D101 0 1 0 0 1 1 1 1 1 0 0 0 0 0 0 0
15
S2: D200 1 1 1 0 0 1 0 1 0 1 1 1 0 0 1 1
S2+1:D201 0 1 0 0 1 1 1 1 1 0 1 0 0 1 0 1
Yields an ON condition.
2
=F, <>F, <F, <=F, >F, >=F
50.00
0.00
Floating-point Math
Instructions
LD>=F
2-243
2 Instructions
FSTR
Instruction
Mnemonic
FLOATING-POINT TO ASCII
Variations
FSTR
Function
code
Function
448
@FSTR
FSTR
FSTR(448)
Symbol
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
REAL
UINT
UINT
Variable
Total characters
Data format
Fractional digits
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
C, D
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the data in S+1 and S is not a valid floating-point number (NaN).
ON if the data in S+1 and S is +o or -o.
ON if the Data Format setting in C is not 0000 or 0001.
ON if the Total Characters setting in C+1 is not within the allowed range. (See 1. Limits on the Total
Number of ASCII Characters above for details.)
ON if the Fractional Digits setting in C+2 is not within the allowed range. (See 3. Limits on the Number
of Digits in the Fractional Part above for details.)
Equals Flag
P_EQ
2-244
2 Instructions
Function
FSTR(448) expresses the 32-bit floating-point number in S+1 and S (IEEE754-format) in decimal notation or scientific notation according to the control data in words C to C+2, converts the number to ASCII
text, and outputs the result to the destination words starting at D.
Decimal notation
Expresses a real number as an integer and fractional part.
Example: 124.56
Scientific notation
Expresses a real number as an integer part, fractional part, and exponent part.
Example: 1.2456E-2 (1.245610-2)
Floating-point Math
Instructions
The content of C (Data format) specifies whether to express the number in S+1, S in decimal notation
or scientific notation.
The content of C+1 (Total characters) specifies the number of ASCII characters after conversion
including the sign symbol, numbers, decimal point and spaces.
The ASCII text is stored in D and subsequent words in the following order: leftmost byte of D, rightmost
byte of D, leftmost byte of D+1, rightmost byte of D+1, etc.
Decimal notation (C=0 hex)
-1.23456
Conversion to
ASCII text
Example: -1.23456
S Floating-point
S+1 data
15
D:
87
2D
20
2E
33
00
Rounded off
0
20
31
32
34
00
15
87
2D
31
32
45
30
00
0
20
2E
33
2B
30
00
2-245
FSTR
The content of C+2 (Fractional digits) specifies the number of digits (characters) below the decimal
point.
2 Instructions
Fractional part
Decimal point
If there are more fractional digits in the source data than specified in C+1, the extra digits will be rounded
off. If there are fewer fractional digits, zeroes (ASCII: 30 hex) will added to the end of the source data.
A decimal point (ASCII: 2E hex) is added if the number fractional digits is greater than 0.
Spaces (ASCII: 20 hex) are added if the integer part of the floating-point data is shorter than the integer part of the result
(total number of characters - sign digit - decimal point - fractional digits).
Positive number: Space (20 hex)
Negative number: Minus sign (2D hex)
number of characters
Total number of characters0 to 9Total
are written as 00 to 09.
Positive: Plus sign (2B hex)
Negative: Minus sign (2D hex)
Letter E (ASCII: 45 hex) is written here.
If there are more fractional digits in the source data than specified in C+1, the extra digits will be rounded off.
If there are fewer fractional digits, zeroes (ASCII: 30 hex) will added to the end of the source data.
A decimal point (ASCII: 2E hex) is added if the number fractional digits is greater than 0.
Spaces (ASCII: 20 hex) are added if the integer part of the floating-point data is shorter than the integer part of the result (total
number of characters - sign digit - decimal point - fractional digits - E digit).
Positive number: Space (20 hex)
Negative number: Minus sign (2D hex)
Note Either one or two bytes of zeroes are added to the end of ASCII text as an end code.
Total number of characters odd: 00 hex is stored after the ASCII text.
Total number of characters even: 0000 hex is stored after the ASCII text.
2-246
2 Instructions
FSTR
Fractional Digits 7
Also: Fractional Digits (Total Number of ASCII Characters - 7)
Sample program
Converting to ASCII Text in Decimal Notation
When CIO 0.00 is ON in the following example, FSTR(448) converts the floating-point data in D1 and
D0 to decimal-notation ASCII text and writes the ASCII text to the destination words beginning with
D100. The contents of the control words (D10 to D12) specify the details on the data format (decimal
notation, 7 characters total, 3 fractional digits).
0.00
15
FSTR
D0
D10
D100
D0 1 0 1 0 1 0 0 0 0 1 1 1 0 0 1 0
D1 0 0 1 1 1 1 1 0 1 0 1 0 0 1 1 1
Conversion
0.327457
Storage
conditions
D10
D11
D12
0(Hex)
7(Hex)
3(Hex)
Decimal notation
Total characters = 7 characters
Fractional digits = 3 digits (characters)
Rounded off
0 .327457
Spaces
D100
D101
D102
D103
20(Space)
30(0)
33(3)
37(7)
Fractional part
20(Space)
2E(.)
32(2)
00
2-247
2 Instructions
15
FSTR
D0
D10
D100
D0 1 0 1 0 1 0 0 0 0 1 1 1 0 0 1 0
D1 0 0 1 1 1 1 1 0 1 0 1 0 0 1 1 1
Conversion
0.327457
Storage
conditions
2-248
20(Space)
33(3)
32(2)
35(5)
2D(-)
31(1)
Rounded off
20(Space)
2E(.)
37(7)
45(E)
30(0)
00
2 Instructions
FVAL
Instruction
Mnemonic
FVAL
Function
code
Function
449
Converts a number expressed in ASCII text (decimal or scientific notation) to a 32-bit floating-point
value (IEEE754-format) and outputs the floatingpoint value to the specified words.
@FVAL
FVAL
FVAL(449)
Symbol
2
FVAL
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
UINT
Variable
REAL
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
S, D
Constants
CF
Pulse
bits
TR
bits
---
---
---
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the digits (integer and fractional parts) in the source data starting at S are not 30 to 39 hex (0 to
9).
ON if the first two digits of the exponential part do not contain 45 and 2B hex (E+) or 45 and 2D hex
(E-). in the source data starting at S are not 30 to 39 hex (0 to 9).
ON if there are two or more exponential parts in the source data.
ON if the data is + or - after conversion.
ON if there are 0 characters in the text data.
ON if a byte containing 00 hex is not found within the first 25 characters.
OFF in all other cases.
Equals Flag
P_EQ
Floating-point Math
Instructions
ASCII TO FLOATING-POINT
Variations
Function
FVAL(449) converts the specified ASCII text number (starting at word S) to a 32-bit floating-point number (IEEE754-format) and outputs the result to the destination words starting at D.
FVAL(449) can convert ASCII text in decimal or scientific notation if it meets the following conditions:
Up to 6 characters are valid, excluding the sign, decimal point, and exponent. Any characters beyond
the 6th character will be ignored.
Decimal Notation
Real numbers expressed with an integer and fractional part.
Example: 124.56
2-249
2 Instructions
Scientific Notation
Real numbers expressed as an integer part, fractional part, and exponent part.
Example: 1.2456E-2 (1.245610-2)
The data format (decimal or scientific notation) is detected automatically.
The ASCII text must be stored in S and subsequent words in the following order: leftmost byte of S,
rightmost byte of S, leftmost byte of S+1, rightmost byte of S+1, etc.
Decimat notation
15
87
2D
20
32
2E
35
37
00
20
31
33
34
36
38
00
D 1110100101111001
D+1 1 1 0 0 0 0 1 0 1 1 1 1 0 1 1 0
Spaces are
ignored during
conversion
Scientific notation
15
87
0 Conversion of ASCII text number
20
2D
to 32-bit floating-point data
32-bit floating-point data
31
20
2
-1.23410
1100110011001101
32
2E
1100001011110110
34
33
Sign Exponent
2B
45
32
30
Stored in D and D+1.
00
00
SP SP 1 . 2 3 4 E + 0 2
(2D)(20)(20)(31)(2E)(32)(33)(34)(45)(2B)(30)(32)
Spaces are
ignored during
conversion
2-250
15
D 1100110011001101
D+1 1 1 0 0 0 0 1 0 1 1 1 1 0 1 1 0
2 Instructions
Floating-point Math
Instructions
00
Up to 00 hex
(25 characters max.)
Decimal notation
15
87
0
(20)
(20)
Digit
25 characters max
Integer part
Fractional part
FVAL
Sign
Sign
SP SP
00
00
.
Decimal
point
The 7th and higher digits are ignored. (The sign, decimal point,
and exponent characters are not counted as digits.)
Any spaces (20 hex) or zeroes (30 hex)
before the first digit are ignored.
Positive number: Space (20 hex) or Plus sign (2B hex)
Negative number: Minus sign (2D hex)
Scientific notation
15
87
Sign
25 characters max.
(20)
(20)
Digit
.(2E)
Digit
Digit
...
E(45)
Sign
Digit
Digit
Integer part
Fractional part
Exponential part
Sign
Sign
SP
00
Decimal
point
00
2-251
2 Instructions
Sample program
Converting ASCII Text in Decimal Notation to Floating-point Data
When CIO 0.00 is ON in the following example, FVAL(449) converts the specified decimal-notation
ASCII text number in the source words starting at D0 to floating-point data and writes the result to destination words D100 and D101.
0.00
Ignored
FVAL
D0
D100
The 7th and higher digits are ignored.
(The sign, decimal point, and leading
zeroes/spaces are not counted.)
20 (Space)
31 (1)
32 (2)
34 (4)
32 (2)
00
D0
D1
D2
D3
D4
D5
Conversion
15
0000010011000000
101111111 0011110
Storage
15
D100 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0
D101 1 0 1 1 1 1 1 1 1 0 0 1 1 1 1 0
Ignored
Ignored
1. 2345E - 0 2
D0
D1
D2
D3
D4
D5
D6
20 (Space)
Conversion
15
0100001010101111
1011110001001010
Storage
15
D100 0 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1
D101 1 0 1 1 1 1 0 0 0 1 0 0 1 0 1 0
2-252
2 Instructions
Instruction
Mnemonic
SWAP BYTES
Variations
SWAP
Function
code
Function
637
@SWAP
SWAP
2
SWAP
SWAP(637)
N
N: Number of words
R1
SWAP
Symbol
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
Number of words
Description
UINT
R1
UINT
Variable
N: Number of words
N specifies the number of words in the range and must be 0001 to FFFF hexadecimal (or &1 to
&65,535).
8 7
R1
to
to
to
R1+(N1)
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
N
R1
Constants
CF
OK
---
Pulse bits
TR bits
---
---
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the N is 0.
OFF in all other cases.
2-253
2 Instructions
Function
SWAP(637) switches the position of the two
bytes in all of the words in the range of memory from R1 to R1+N-1.
R1
N
Hint
This instruction can be used to reverse the order of ASCII-code characters in each word.
Sample program
When CIO 0.00 is ON in the following example, SWAP(637) switches the data in the leftmost bytes with
the data in the rightmost bytes in each word in the 10-word range from W0 to W9.
0.00
SWAP
N
&10
R1
W0
15
8 7
15
8 7
W0
W1
W1
W2
W2
W9
to
to
to
2-254
W0
W9
to
3
2 Instructions
FCS
Mnemonic
FRAME CHECKSUM
Function
code
Variations
FCS
@FCS
Function
Calculates the FCS value for the specified range
and outputs the result in ASCII.
180
FCS
FCS(180)
Symbol
R1
2
FCS
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
UDINT
R1
UINT
Variable
UINT
Variable
15
15 14 13 12 11
0000
00
0000
15
C+1
R1
Calculation range
to
to
R1+(W1)
0000
0
Starting byte (Valid only when bit 13 is 1.)
0: Leftmost byte
1: Rightmost byte
Calculation units
The leftmost four digits are stored in D+1 and the rightmost
four digits are stored in D.
0: Words
1: Bytes
0
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
OK
R1, D
---
Flags
Name
Error Flag
Label
P_ER
Instruction
Operation
ON if the content of C is not within the specified range of 0001 through FFFF.
OFF in all other cases.
2-255
2 Instructions
Function
FCS(180) calculates the FCS value for W units
of data beginning with the data in R1, converts
the value to ASCII code, and outputs the result
to D (for bytes) or D+1 and D (for words). The
settings in C+1 determine whether the units
are words or bytes, whether the data is binary
(signed or unsigned) or BCD, and whether to
start with the right or left byte of R1 if bytes are
being added.
R1
W (Table length)
ASCII conversion
Calculation
FCS value
D
Sample program
When CIO 0.00 is ON in the following example, FCS(180) calculates the FCS value for the 10 bytes of
data beginning with the rightmost byte of D100 and writes the result to D200.
0.00
FCS
C
D300
R1
D100
D200
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
C+1: D301
Always 0.
Starting byte (Effective only if bit 13 is 1.)
1: Rightmost byte
Units
1: Bytes
Always 0.
8 7
0
0
15
C: D300 0
0
A
10 bytes
Table length
15
8 7
R1: D100
0
0
D101
D102
D103
D104
D105
15
D: D200
2-256
2 Instructions
PIDAT
Instruction
Mnemonic
Variations
Function
code
Function
---
191
PIDAT
2
PID
PIDAT
PIDAT(191)
Symbol
S: Input word
D: Output word
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
Operands
Operand
Description
Input word
Output word
Data type
Size
UINT
WORD
41
UINT
15
C+7
C+1
C+8
C+2
C+3
C+4
Sampling period()
C+9
15 14 13 12
0 0 0
AT Calculation Gain
15
8 7
4 32 1
AT Command Bit
C+5
15
Forward/reverse designation
PID constant update timing designation
Manipulated variable output setting
8 7
0
Limit-cycle Hysteresis
C+11
2-PID parameter()
15 14 13 12 11
C+10
4 3
C+40
Work area
(30 words: Cannot be used by user.)
C+6 0 0 0
Output range
Integral and derivative unit
Input range
Manipulated variable output limit control
2-257
2 Instructions
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
S, C, D
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the C data is out of range.
ON if the actual sampling period is more than twice the designated sampling period.
ON if an error occurred during autotuning.
OFF in all other cases.
P_GT
P_LT
Carry Flag
P_CY
ON if the manipulated variable after the PID action exceeds the upper limit.
OFF in all other cases.
ON if the manipulated variable after the PID action is below the lower limit.
OFF in all other cases.
ON while PID control is being executed.
OFF in all other cases.
Function
When the execution condition is ON, PIDAT(191) carries out target value filtered PID control with two
degrees of freedom according to the parameters designated by C (set value, PID constant, etc.). It
takes the specified input range of binary data from the contents of input word S and carries out the PID
action according to the parameters that are set. The result is then stored as the manipulated variable in
output word D.
The parameter settings are read when the execution condition turns from OFF to ON, and the Error
Flag will turn ON if the settings are outside of the permissible range.
If the settings are within the permissible range, PID processing will be executed using the initial values.
Bumpless operation is not performed at this time. It will be used for manipulated variables in subsequent PID processing execution. (Bumpless operation is processing that gradually and continuously
changes the manipulated variable in order to avoid the adverse effects of sudden changes.)
When the execution condition turns ON, the PV for the specified sampling period is entered and processing is performed.
Parameters (C to C+8)
PV input (S)
PID control
Autotuning
The status of the AT Command Bit (bit 15 of C+9) is checked every cycle. If this control bit is turned ON
in a given cycle, PIDAT(191) will begin autotuning the PID constants. (The changes in the SV will not be
reflected while autotuning is being performed.)
The limit-cycle method is used for autotuning. PIDAT(191) forcibly changes the manipulated variable
(max. manipulated variable min. manipulated variable) and monitors the characteristics of the controlled system. The PID constants are calculated based on the characteristics that were observed, and
the new P, I, and D constants are stored automatically in C+1, C+2, and C+3. At this point, the AT Command Bit (bit 15 of C+9) is turned OFF and PID control resumes with the new PID constants in C+1,
C+2, and C+3.
If the AT Command Bit is ON when PIDAT(191) execution begins, autotuning will be performed first
and then PID control will start with the calculated PID constants.
If the AT Command Bit is turned ON during PIDAT(191) execution, PIDAT(191) interrupts the PID
control being performed with the user-set PID constants, performs autotuning, and then resumes PID
control with the calculated PID constants.
2-258
2 Instructions
2
PID control starts (or restarts) with the new
PID constants.
2 Also, if an AT execution error occurs, PID control will start with the PID constants that were being used
before autotuning began.
In both cases described in notes 1 and 2, the PID constants will be enabled if they were already calculated when autotuning was interrupted.
PID Control
The number of valid input data bits within the 16 bits of the PV input (S) is designated by the input
range setting in C+6, bits 08 to 11. For example, if 12 bits (4 hex) is designated for the input range,
the range from 0000 hex to 0FFF hex will be enabled as the PV. (Values greater than 0FFF hex will
be regarded as 0FFF hex.)
The set value range also depends on the input range.
Measured values (PV) and set values (SV) are in binary without sign, from 0000 hex to the maximum
value of the input range.
The number of valid output data bits within the 16 bits of the manipulated variable output is designated by the output range setting in C+6, bits 00 to 03. For example, if 12 bits (4 hex) is designated
for the output range, the range from 0000 hex to 0FFF hex will be output as the manipulated variable.
For proportional operation only, the manipulated variable output when the PV equals the SV can be
designated as follows:
0: Output 0%
1: Output 50%.
The direction of proportional operation can be designated as either forward or reverse.
The upper and lower limits of the manipulated variable output can be designated.
The sampling period can be designated in units of 10 ms (0.01 to 99.99 s), but the actual PID action
is determined by a combination of the sampling period and the time of PIDAT(191) instruction execution (with each cycle).
The timing of enabling changes made to PID constants can be set to either 1) the beginning of
PIDAT(191) instruction execution or 2) the beginning of PID instruction execution and each sampling
period. Only the proportional band (P), integral constant (Tik), and derivative constant (Tdk) can be
changed each sampling cycle (i.e., during PID instruction execution). The timing is set in bit 1 of C+5.
2-259
PIDAT
Note 1 If autotuning is interrupted by turning OFF the AT Command Bit during autotuning, PID control will start
with the PID constants that were being used before autotuning began.
2 Instructions
Hint
PIDAT(191) is executed as if the execution condition was a STOP-RUN signal. PID calculations are
executed when the execution condition remains ON for the next cycle after C+11 to C+40 are initialized. Therefore, when using the Always ON Flag (ON) as an execution condition for PIDAT(191), provide a separate process where C+11 to C+40 are initialized when operation is started.
Precautions
A PID parameter storage word cannot be shared by multiple PIDAT instructions. Even when the same
parameter is used in multiple PIDAT instructions, separate words must be specified.
When changing the PID constants manually, set the PID constant change enable setting (bit 1 of
C+5) to 1 so that the values in C+1, C+2, and C+3 are refreshed each sampling period in the PID calculation. This setting also allows the PID constants to be adjusted manually after autotuning.
Of the PID parameters (C to C+40), only the following parameters can be changed when the execution condition is ON. When any other values have been changed, be sure to change the execution
condition from OFF to ON to enable the new settings.
Set value (SV) in C
(Can be changed during PID control only. An SV change during autotuning will not be
reflected.)
PID constant change enable setting (bit 1 of C+5)
P, I, and D constants in C+1, C+2, and C+3
(Changes to these constants will be reflected each sampling period only if the PID constant
change enable setting (bit 1 of C+5) is set to 1.)
AT Command Bit (bit 15 of C+9)
AT Calculation Gain (bits 0 to 14 of C+9) and Limit-cycle Hysteresis (C+10) (These values are
read when autotuning starts.)
Performance Specifications
Item
Specifications
---
---
0.01 to 99.99 s
Proportional band
0.1 to 999.9%
Integral constant
Tik
1 to 8191, 9999 (No integral action for sampling period multiple, 9999.)
Derivative constant
Tdk
Sampling period
PID constant
Set value
SV
Measured value
PV
Manipulated variable
MV
Calculation Method
Calculations in PID control are performed by the target value filtered control with two degrees of
freedom.
2-260
2 Instructions
Block Diagram for Target Value PID with Two Degrees of Freedom
When target-value PID control with two degrees of freedom is used, on the other hand, there is no
overshooting, and response toward the target value and stabilization of disturbances can both be
speeded up (3).
Target value filter
Set value
(target value)
SV
1 + (1 ) Ti s
Kp +
Kp
Manipulated variable
Ti s
1 + Ti s
Preceding
derivative-type elements
Kp
PV
Kp:Proportional constant
Ti:Integral time
Td:Derivative time
s:Laplace operator
:2-PID parameter
:Incomplete derivative coefficient
Td/s
1 + Td s
PIDAT
Measured
value (PV)
(1)
Target response
Disturbance response
(2)
Overshoot
Item
Contents
Setting range
Change with ON
input condition
Allowed
C+1
Proportional band
The parameter for P action expressing the proportional control range/total control range.
C+2
Tik
Integral Constant
Can be changed
with input condition ON if bit 1 of
C+5 is 1.
C+3
Tdk
Derivative Constant
A constant expressing the strength of the derivative action. As this value increases, the derivative
strength decreases.
C+4
Sampling period ()
Bits 04 to 15
of C+5
2-PID parameter ()
Bit 03 of C+5
Manipulated variable
output designation
0:
1:
Bit 01 of C+5
The timing of enabling changes made to the proportional band (P), integral constant (Tik), and
derivative constant (Tdk) for use in PID calculations.
When overshooting is prevented with simple PID control, stabilization of disturbances is slowed (1). If
stabilization of disturbances is speeded up, on the other hand, overshooting occurs and response
toward the target value is slowed (2).
Not allowed
Output 0%
Output 50%
Allowed
2-261
2 Instructions
Control data
Bit 00 of C+5
Item
Contents
Setting range
PID forward/reverse
designation
0:
Reverse action
1:
Forward action
Bit 12 of C+6
Manipulated variable
output limit control
0:
1:
Bits 08 to 11
of C+6
Input range
0: 8 bits
1: 9 bits
2: 10 bits
3: 11 bits
4: 12 bits
Bits 04 to 07
of C+6
1:
9:
Bits 00 to 03
of C+6
Output range
0: 8 bits
1: 9 bits
2: 10 bits
3: 11 bits
4: 12 bits
C+7
Manipulated variable
output lower limit
C+8
Manipulated variable
output upper limit
Bit 15 of C+9
AT Command Bit
As a Control Bit:
Set the AT Command Bit to 1 to perform autotuning. (Autotuning can be started while
PIDAT(191) is being executed.)
0 1:
Executes autotuning.
AT Calculation Gain
Change with ON
input condition
Not allowed
5: 13 bits
6: 14 bits
7: 15 bits
8: 16 bits
Allowed
1 0:
Interrupts autotuning.
(PID(191) turns the bit OFF automatically
when autotuning is completed.
As a Flag:
0: Autotuning is not being executed.
1: Autotuning is being executed.
0000 hex: 1.00 (Default)
0001 to 03E8 hex (1 to 1000);
(0.01 to 10.00, in units of 0.01)
Allowed
(These parameters
are read when
autotuning starts.)
Limit-cycle Hysteresis
Sets the hysteresis when the limit cycle is generated. The default setting for reverse operation
turns ON the MV with a hysteresis of SV20%.
Increase this setting if a proper limit cycle cannot
be generated because the PV is unstable. However, the AT accuracy will decline if the Limit-cycle
Hysteresis is higher than necessary.
Note 1 When the unit is designated as 1, the range is from 1 to 8,191 times the period. When the unit is designated as 9, the
range is from 0.1 to 819.1 s. When 9 is designated, set the integral and derivative times to within a range of 1 to 8,191
times the sampling period.
2 Setting the 2-PID parameter () to 000 yields 0.65, the normal value.
3 When the manipulated variable output limit control is enabled (i.e., set to 1), set the values as follows:
0000 MV output lower limit MV output upper limit Max. value of output range
2-262
2 Instructions
If the sampling period is less than the cycle time, PID control is executed with each cycle and not with
each sampling period.
If the sampling period is greater than or equal to the cycle time, PID control is not executed with each
cycle, but PID(190) is executed when the cumulative value of the cycle time (the time between PID
instructions) is greater than or equal to the sampling period. The surplus portion of the cumulative
value (i.e., the cycle times cumulative value minus the sampling period) is carried forward to the next
cumulative value.
For example, suppose that the sampling period is 100 ms and that the cycle time is consistently 60
ms. For the first cycle after the initial execution, PID(190) will not be executed because 60 ms is less
than 100 ms. For the second cycle, 60 ms + 60 ms is greater than 100 ms, so PID(190) will be
executed. The surplus of 20 ms (i.e., 120 ms 100 ms = 20 ms) will be carried forward.
1 cycle
1 cycle
PID
1 cycle
PID
60ms
1 cycle
PID
60ms
1 cycle
PID
PID
60ms
60ms
Processing
Initial processing
(PID processing
with initial values)
Reading of
measurement
time
(60 ms)
Not executed.
(20 ms + 60 ms = 80 ms)
Not executed.
Executed
2-263
2
PIDAT
For the third cycle, the surplus 20 ms is added to 60 ms. Because the sum of 80 ms is less than 100
ms, PID(190) will not be executed. For the fourth cycle, the 80 ms is added to 60 ms. Because the
sum of 140 ms is greater than 100 ms, PID(190) will be executed and the surplus of 40 ms (i.e.,
120 ms 100 ms = 20 ms) will be carried forward. This procedure is repeated for subsequent cycles.
The sampling period can be designated in units of 10 ms (0.01 to 99.99 s), but the actual PID action is
determined by a combination of the sampling period and the time of PID instruction execution (with
each cycle). The relationship between the sampling period and the cycle time is as follows:
2 Instructions
PID control
Proportional Action (P)
Proportional action is an operation in which a proportional band is established with respect to the set
value (SV), and within that band the manipulated variable (MV) is made proportional to the deviation.
An example for reverse operation is shown in the following illustration.
If the proportional action is used and the present value (PV) becomes smaller than the proportional
band, the manipulated variable (MV) is 100% (i.e., the maximum value). Within the proportional band,
the MV is made proportional to the deviation (the difference between from SV and PV) and gradually
decreased until the SV and PV match (i.e., until the deviation is 0), at which time the MV will be at the
minimum value of 0% (or 50%, depending on the setting of the manipulated variable output designation
parameter). The MV will also be 0% when the PV is larger than the SV.
The proportional band is expressed as a percentage of the total input range. The smaller the proportional band, the larger the proportional constant and the stronger the corrective action will be. With proportional action an offset (residual deviation) generally occurs, but the offset can be reduced by making
the proportional band smaller. If it is made too small, however, hunting will occur.
Proportional Action (Reverse Action)
Manipulated variable
100%
50%
0%
SV
Proportional band just right
Set point
Proportional band too wide (large offset)
Proportional band when
MV output designation is
0 (output 0%)
Manipulated
0
variable
Pi Action and Integral Time
Step response
Deviation
0
PI action
I action
Manipulated
variable
P action
0
Ti
2-264
2 Instructions
The strength of the derivative action is indicated by the derivative time, which is the time required for the
manipulated variable of the derivative action to reach the same level as the manipulated variable of the
proportional action with respect to the step deviation, as shown in the following illustration. The longer
the derivative time, the stronger the correction by the derivative action will be.
Derivative Action
Step response
Deviation
PIDAT
Manipulated
0
variable
PD Action and Derivative Time
Ramp response
Deviation
PD action
P action
D action
Manipulated
0
variable
Td: Derivative time
PID Action
PID action combines proportional action (P), integral action (I), and derivative action (D). It produces
superior control results even for control objects with dead time. It employs proportional action to provide
smooth control without hunting, integral action to automatically correct any offset, and derivative action
to speed up the response to disturbances.
Step Response of PID Control Action Output
Step response
Deviation
PID action
I action
P action
D action
Manipulated
0
variable
Ramp Response of PID Control Action Output
Ramp response
Deviation
0
PID action
I action
Manipulated
variable
Proportional action and integral action both make corrections with respect to the control results, so
there is inevitably a response delay. Derivative action compensates for that drawback. In response to a
sudden disturbance it delivers a large manipulated variable and rapidly restores the original status. A
correction is executed with the manipulated variable made proportional to the incline (derivative
coefficient) caused by the deviation.
P action
D action
0
2-265
2 Instructions
Direction of Action
When using PID control, select either of the following two control directions. In either direction, the MV
increases as the difference between the SV and the PV increases.
Forward action: MV is increased when the PV is larger than the SV.
Reverse action: MV is increased when the PV is smaller than the SV.
Reverse Action
Output
100%
Forward Action
Output
100%
50%
50%
0%
0%
Low
SV
temperature
(MV output designation: 50%)
High
temperature
Low
temperature
SV
High
temperature
SV
When P is enlarged
When there is broad hunting, or when operation is tied up by overshooting and undershooting, it is probably because integral
action is too strong. The hunting will be
reduced if the integral time is increased or
the proportional band is enlarged.
SV
Enlarge I or P.
2-266
Lower D.
2 Instructions
Sample program
Interrupting PID Control to Perform Autotuning
PIDAT
S
10
D200
20
While CIO 0.00 is ON, PID control is executed at the sampling period
intervals according to the parameters set in D200 to D210. The manipulated variable is output to CIO 20.
W0.0
SETB
The PID constants used in PID calculations will not be changed even if
the proportional band (P), integral constant (Tik), or derivative constant is changed after CIO 0.00 turns ON.
D209
#000F
C:D200
Parameters
PV:
CIO 10
PID
calculation
0 1 2 C
C+1:D201
C+2:D202
0 4 B 0
C+3:D203
C+4:D204
C+5:D205
C+6:D206
C+7:D207
C+8:D208
C+9:D209
C+10:D210
C+11:D211
Work area
to
MV output: CIO 20
C+40:D240
Calculated PID
constants are set.
CIO 0.00
PID control AT executing
PID control
W0.00
Bit 15 of D209
PV
SV
Time
MV
Time
2-267
2
PIDAT
At the rising edge of CIO 0.00 (OFF to ON), the work area in D211 to
D240 is initialized according to the parameters (shown below) set in
D200 to D208. After the work area has been initialized, PID control is
executed and the manipulated variable is output to CIO 20.
0.00
2 Instructions
0.00
PIDAT
S
10
D200
20
Calculated PID
constants are set.
CIO 0.00
AT executing
PID control
Bit 15 of D209
PV
SV
Time
MV
Time
CIO 0.00
PID control AT executing
AT starts
PID control
AT is interrupted.
Bit 15 of D209
PV
SV
2-268
2 Instructions
Instruction
Mnemonic
TIME-PROPORTIONAL
OUTPUT
Variations
TPO
Function
code
Function
685
---
TPO
TPO
TPO
Symbol
S: Input word
TPO
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
S
Description
Input word
Data type
Size
UINT
WORD
BOOL
---
S: Input Word
Specifies the input word containing the input duty ratio or manipulated variable.
Input duty ratio: 0000 to 2710 hex (0.00% to 100.00%)
Input manipulated variable (See note.): 0000 to FFFF hex (0 to 65,535 max.) (Bits 00 to 03 of C specify the manipulated variable range, i.e., the number of valid bits in the manipulated variable. Specify
the same number of bits as specified for the output range setting in PIDAT(191).)
Note If S is a manipulated variable, specify the word containing the manipulated variable output from a
PIDAT(191) instruction.
12 11
8 7
4 3
15
C
Manipulated variable range
Input type
Input read timing
Output limit function
C+1
Control period
C+2
C+3
C+4
C+5
Work area
(3 words, cannot be used by user)
C+6
2-269
2 Instructions
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
---
---
---
---
---
CF
Pulse bits
TR bits
---
---
---
OK
OK
OK
OK
OK
---
Flags
Name
Error Flag
Label
ER
Operation
ON if the input data in S is out of range. (The input data setting range depends on the input type setting.)
ON if the C data is out of range. (The manipulated variable range will cause an error only when the
input type is set to manipulated variable.)
ON if the control period in C+1 is out of range.
ON if the output limit function is enabled but the output lower limit (C+2) or output upper limit (C+3) is
out of range.
ON if the output limit function is enabled but the output lower limit (C+2) is less than or equal to the
output upper limit (C+3).
OFF in all other cases.
Function
Receives a duty ratio or manipulated variable input from the word address specified by S, converts the
duty ratio to a time-proportional output (see note) based on the parameters specified in words C to C+3,
and outputs a pulse output to the bit specified by R.
Note A time-proportional output is changed proportionally based on the ON/OFF ratio in input word S. The period
in which the ON and OFF status changes is known as the control period and is set in parameter word C+1.
Example: When the control period is 1 s and the input value is 50%, the bit is ON for 0.5 s and OFF for 0.5 s.
When the control period is 1 s and the input value is 80%, the bit is ON for 0.8 s and OFF for 0.2 s.
Generally, TPO(685) is used together with PIDAT(191) and the PID instructions manipulated variable
result word (D) is specified as the input word (S) for the TPO(685) instruction. Also, an output bit allocated to a Transistor Output Unit is generally specified as R and a solid state relay is connected to the
Transistor Output Unit to perform time-proportional control of a heater (proportional control of the
ON/OFF ratio).
PV input
PID parameters
D0
Manipulated
variable
PID calculation
Manipulated variable (MV)
Output range
MV
D0
= MV range
TPO
D0
MV
Parameters
Pulse output
MV MV range
Duty ratio (0.00% to 100.00%)
Conversion to time-proportional
output
2-270
2 Instructions
COM
In this case, set the same value for the PID Control instructions output range and the TPO(685) instructions manipulated variable range. For example, when the PID Control instructions output range and the
TPO(685) instructions manipulated variable range are both set to 12 bits (0000 to 0FFF hex), the duty
ratio is calculated by dividing the manipulated variable from the PID Control instruction by 0FFF hex
and TPO(685) converts that duty ratio to a time-proportional output.
SSR
12 to 24 VDC
2
TPO
AC
Parameter Settings
Control data
Item
Word
C
Contents
Setting range
Bits
00 to 03
Manipulated
variable range
0 hex: 8 bits
1 hex: 9 bits
2 hex: 10 bits
3 hex: 11 bits
4 hex: 12 bits
5 hex: 13 bits
6 hex: 14 bits
7 hex: 15 bits
8 hex: 16 bits
04 to 07
Input type
Change with
ON input
condition
Allowed
Allowed
Allowed
12 to 15
C+1
00 to 15
Output limit
control
0 hex: Disabled
Control period
Control period
(Time period in which the ON/OFF
changes are made.)
Allowed
C +2
00 to 15
Output lower
limit
Allowed
C +3
00 to 15
Output upper
limit
Allowed
C+4
00 to 15
Work area
---
00 to 15
Cannot be used.
C+5
C+6
00 to 15
Note When the output limit control function is enabled, set the lower and upper limits as follows:
0000 hex lower limit upper limit 2710 hex.
Execution
The instruction is executed while the input condition is ON.
When instruction execution starts, the output bit (R) is turned ON/OFF according to the duty ratio.
2-271
2 Instructions
The parameters (in C to C+3) are read in real time each time that the instruction is executed. When
changing the parameters, change all of them at the same time so that different sets of parameters are
not mixed.
The output (R) is turned ON/OFF when the instruction is executed and the accuracy of the outputs
ON/OFF timing is 10 ms max.
Execution of the instruction stops when the input condition goes OFF. At that time, the elapsed time
value will be reset and the control period will be initialized.
The input type setting (bits 04 to 07 of C) determines whether the input word (S) contains a duty ratio
or manipulated variable. When S contains the manipulated variable, the duty ratio is calculated by
dividing the manipulated variable input by the manipulated variable range (bits 00 to 03 of C).
The input read timing setting (bits 08 to 11 of C) specifies when the input word (S) is read, as shown
in the following table:
Input read timing
Description
0:
The duty ratio input is read at the beginning of the control period and the ratio cannot be
changed during the control period.
1:
If the duty ratio input falls below the duty ratio at the beginning of the control period, the
lower value will take precedence and the output ON time will be reduced accordingly.
2:
If the duty ratio input rises above the duty ratio at the beginning of the control period, the
higher value will take precedence and the output ON time will be increased accordingly.
3:
Continuous adjustment
The duty ratio will be read in real time each time the instruction is executed and the
ON/OFF operation will be repeated within the control period.
The following diagrams show the operation of each input read timing setting.
Input time setting = 0 (Use the beginning value of the control period.)
Read only at the beginning of the control period.
Control period (a)
100%
Duty ratio
(MV/MV range)
70%
55%
0%
a 0.55 s
a 0.45 s
a 0.70 s
a 0.30 s
Output
Time
Each control periods output is determined by the duty ratio at the beginning of that period.
Use this setting for general applications.
100%
Duty ratio
(MV/MV range)
70%
55%
35%
55% target
cut to 35%.
0%
a 0.35 s
a 0.65 s
70% target
is kept.
a 0.70 s
a 0.30 s
Output
Time
If the duty ratio falls below the initial value early enough, the duty ratio will be adjusted and the
output will be turned OFF sooner.
Use this setting for applications such as avoiding overshooting when using time-proportional
control to control heating and using a relatively long control period.
2-272
2 Instructions
80%
70%
55%
Duty ratio
(MV/MV range)
100%
70% target
raised to 80%.
0%
a 0.45 s
a 0.55 s
a
0.20 s
a 0.80 s
Output
Time
TPO
If the duty ratio rises above the initial value early enough, the duty ratio will be adjusted and the
output will be turned ON sooner. (With this setting the outputs ON/OFF order is reversed and
the output goes from OFF to ON.)
Use this setting for applications such as avoiding undershooting when using time-proportional
control to control cooling and using relatively long control period.
100%
: Output ON
Duty ratio
(MV/MV range)
: Output OFF
0%
a 0.35 s
a
0.20 s
a
0.20 s
a
0.20 s
Output
Time
Changes in the duty ratio are monitored in real time. If the duty ratio falls below the
initial value early enough, the duty ratio will be adjusted and the output will be turned
OFF sooner. If the duty ratio rises again after that, the ratio will be adjusted again
and the output will be turned ON. This process is repeated continuously.Use this
setting to improve responsiveness when the control period is relatively long and the
duty ratio changes quickly. This setting is also appropriate for lighting or power
applications that require precise control.
The output limiter function (bits 12 to 15 of C) can be enabled to restrict (saturate) output when it is
outside the range between the output limiter lower limit (C + 2) and output limiter upper limit (C + 3).
2-273
2 Instructions
Precautions
When using TPO(685) in combination with PIDAT(191) in a cyclic task and also using an interrupt
task, temporarily disable interrupts by executing DI(693) (DISABLE INTERRUPTS) ahead PIDAT(191)
and TPO(685). If interrupts are not disabled and an interrupt occurs between the PIDAT(191) and
TPO(685), the control period may be shifted.
Cyclic task
DI
PIDAT
S PV input
C PID parameters
Reception prohibited
D Manipulated
variable
Interrupt task
TPO
Manipulated
S variable
C Parameters
R Pulse output
EI
Reception allowed
Interrupt task
Sample program
Combining TPO(685) with PIDAT(191)
When CIO 0.00 is ON, TPO(685) takes the manipulated variable output from PIDAT(191) (contained in
D0), calculates the duty ratio from that manipulated variable value (Duty ratio = MV MV range), converts the duty ratio to a time-proportional output, and outputs the pulses to bit 01 of CIO 100.
In this case, CIO 100 is allocated to a Transistor Output Unit and bit CIO 100.01 is connected to a solid
state relay for heater control.
0.00
PIDAT
S
10
D200
D0
PV input
PID parameters
Manipulated variable
TPO
S
D0
Manipulated variable
D500
Parameters
100.01
Pulse output
D200
D201
:
D206
:
D500
4
MV range: 4 hex
(12 bits: 0000 to 0FFF hex)
Input type: 1 hex (MV)
2-274
2 Instructions
In this case, the control period is 1 s and the output limit function is enabled with a lower limit 20.00%
and an upper limit of 80.00%.
0.00
TPO
D10
Duty ratio
D0
Parameters
100.00
Pulse output
When CIO 0.00 is ON, TPO(685) takes the duty ratio in D10, converts the duty ratio to a time-proportional output, and outputs the pulses to bit 00 of CIO 100.
2
1
D1
D2
D3
Duty ratio input, read initial value, and enable output limit function.
D4
Do not set.
D5
Do not set.
D6
Do not set.
TPO
D0
:
:
D10
0 to 2710 hex
0 to 100.00%
2-275
2 Instructions
SCL
Instruction
Mnemonic
SCALING
Variations
SCL
Function
code
Function
194
@SCL
SCL
SCL(194)
Symbol
S: Source word
S
P1
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Source word
UINT
P1
LWORD
Result word
WORD
P1
15
15
P1+1
P1+2
15
P1+3
Operand Specifications
Word addresses
Indirect DM addresses
Area
S, P1, R
2-276
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
2 Instructions
Flags
Name
Label
P_ER
Operation
ON if the contents of P1 (Ar) or P1+1 (Br) is not BCD.
ON if the contents of P1+1 (As) and P1+3 (Bs) are equal.
OFF in all other cases.
Equals Flag
P_EQ
ON if the result is 0.
OFF in all other cases.
Function
SCL(194) is used to convert the unsigned binary data contained in the source word S into unsigned
BCD data and place the result in the result word R according to the linear function defined by points
(As, Ar) and (Bs, Br). The address of the first word containing the coordinates of points (As, Ar) and (Bs,
Br) is specified for the first parameter word P1. These points define by 2 values (As and Bs) before scaling and 2 values (Ar and Br) after scaling.
Error Flag
SCL
(Br Ar)
R = Bd
Points A and B can define a line with either a positive or negative slope. Using a negative slope enables
reverse scaling.
The result will be rounded to the nearest integer. If the result is less than 0000, 0000 will be output as
the result.
If the result is greater than 9999, 9999 will be output.
Scaling is performed according to
the linear function defined by points
A and B.
R (unsigned BCD)
Point B
Br
Ar Point A
As
Bs
Ar(BCD)
P1+1
As(BIN)
P1+2
Br(BCD)
P1+3
Bs(BIN)
Converted value
Converted value
S (unsigned binary)
Hint
SCL(194) can be used to scale the results of analog signal conversion values from Analog Input
Units according to user-defined scale parameters. For example, if a 1 to 5-V input to an Analog Input
Unit is input to memory as 0000 to 0FA0 hexadecimal, the value in memory can be scaled to 50 to
200C using SCL(194).
SCL(194) converts unsigned binary to unsigned BCD. To convert a negative value, it will be necessary to first add the maximum negative value in the program before using SCL(194) (see example).
SCL(194) cannot output a negative value to the result word, R. If the result is a negative value, 0000
will be output to R.
2-277
2 Instructions
Sample program
In the following example, it is assume that an analog signal from 1 to 5 V is converted and input to D0
as 0000 to 0FA0 hexadecimal. SCL(194) is used to convert (scale) the value in CIO 200 to a value
between 0 and 300 BCD.
When CIO 0.00 is ON, the contents of D0 is scaled using the linear function defined by point A (0000,
0000) and point B (0FA0, 0300). The coordinates of these points are contained in D100 to D103, and
the result is output to D200.
SCL
0.00
D0
P1
D100
D200
0 0 0 0
Ar(BCD)
P1+1:D101
0 0 0 0
As(BIN)
P1+2:D102
0 3 0 0
Br(BCD)
P1+3:D103
0 F A 0
Bs(BIN)
P1:
Point B
0300
Point A
0000
0000Hex
0FA0Hex
1V
5V
Contents of D0 (S)
Reference:
An Analog Input Unit actually inputs values from FF38 to 1068 hexadecimal for 0.8 to 5.2 V. SCL(194),
however, can handle only unsigned binary values between 0000 and FFFF hexadecimal, making it
impossible to use SCL(194) directly to handle signed binary values below 1 V (0000 hexadecimal), i.e.,
FF38 to FFFF hexadecimal. In an actual application, it is thus necessary to add 00C8 hexadecimal to
all values so that FF38 hexadecimal is represented as 0000 hexadecimal before using SCL(194), as
shown in the following example.
5.2V
5V
200
1130Hex
1068Hex
1068 Hex
0FA0 Hex
#000C8
D0
+00C8 Hex
SCL
D0
D100
D200
1V
0.8V
00C8Hex
0000Hex
0000 Hex
FF38 Hex
0315
0000
Point A
0000Hex
00C8Hex
0.8V
1V
2-278
D100
Ar(BCD)
P1+1:D101
As(BIN)
P1+2:D102
Br(BCD)
P1+3:D103
Bs(BIN)
P1:
Point B
0300
Contents of D0 (S)
1130Hex
1068Hex
5.2V
5V
2 Instructions
In this example, values from 0000 to 00C8 hexadecimal will be converted to negative values. SCL(194),
however, can output only unsigned BCD values from 0000 to 9999, so 0000 BCD will be output whenever the contents of D0.00 is between 0000 and 00C8 hexadecimal.
Reverse scaling can also be used by setting As < Bs and Ar > Br. The following relationship will result.
R (unsigned BCD)
Ar
Point A
Point B
Br
2
As
S (unsigned binary)
Bs
0300 Point A
1V
Point B
0FA0Hex
5V
2-279
SCL
Reverse scaling can be used, for example, to convert (reverse scale) 1 to 5 V (0000 to 0FA0 hexadecimal) to 0300 to 0000, respectively, as shown in the following diagram.
0000
0000Hex
Reverse Scaling
2 Instructions
SCL2
Instruction
Mnemonic
SCALING 2
Variations
SCL2
Function
code
Function
486
@SCL2
SCL2
SCL2(486)
Symbol
S: Source word
S
P1
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
INT
WORD
Result word
WORD
Source word
P1
R
P1
P1+1
P1+2
Operand Specifications
Word addresses
Indirect DM addresses
Area
S, P1, R
2-280
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
2 Instructions
Flags
Name
Label
Operation
P_ER
Error Flag
Equals Flag
P_EQ
Carry Flag
P_CY
ON if the result is 0.
OFF in all other cases.
ON if the result is negative.
OFF if the result is zero or positive.
Function
Y
BCD conversion of X
The offset and slope can be a positive value, 0, or a negative value. Using a negative slope enables
reverse scaling.
The result will be rounded to the nearest integer.
The result in R will be the absolute BCD conversion value and the sign will be indicated by the Carry
Flag. The result can thus be between 9999 and 9999.
If the result is less than 9999, 9999 will be output as the result. If the result is greater than 9999,
9999 will be output.
Negative Offset
R (signed BCD)
Positive Offset
R (signed BCD)
Y
Y
X
Offset
X
S (signed binary)
S (signed binary)
Offset
Offset of 0000
Offset
(Signed binary)
P1+1
(Signed binary)
P1+2
(Signed BCD)
P1
R (signed BCD)
Y
Offset = 0000 hex
X
S (signed binary)
2-281
2
SCL2
SCL2(486) is used to convert the signed binary data contained in the source word S into signed BCD
data (the BCD data contains the absolute value and the Carry Flag shows the sign) and place the result
in the result word R according to the linear function defined by the slope (X, Y) and an offset. The
address of the first word containing X, Y, and the offset is specified for the first parameter word P1.
The sign of the result is indicated by the status of the Carry Flag (ON: negative, OFF: positive).
2 Instructions
Hint
SCL2(486) can be used to scale the results of analog signal conversion values from Analog Input
Units according to user-defined scale parameters. For example, if a 1 to 5-V input to an Analog Input
Unit is input to memory as 0000 to 0FA0 hexadecimal, the value in memory can be scaled to 100 to
200C using SCL2(486).
SCL2(486) converts signed binary to signed BCD. Negative values can thus be handled directly for S.
The result of scaling in R and the Carry Flag can also be used to output negative values for the scaling result.
Sample program
Scaling 1 to 5-V Analog Input to 0 to 300
In the following example, it is assumed that an analog signal from 1 to 5 V is converted and input to CIO
3 as 0000 to 1770 hexadecimal. SCL2(486) is used to convert (scale) the value in CIO 3 to a value
between 0000 and 0300 BCD.
When CIO 0.00 is ON, the contents of CIO 3 is scaled using the linear function defined by X (1770),
Y (0300), and the offset (0). These values are contained in D100 to D102, and the result is output to
D200.
0.00
SCL2
S
P1
D100
D200
Contents of R (D200)
D100
Offset
P1+1:D101
P1+2:D102
P1:
0315
0300
Y
0000
-0015
Contents of S (CIO 3)
FED4 0000
0.8V 1V
2-282
1770 189C
1770Hex
(X)
5V 5.2V
2 Instructions
When CIO 0.00 is ON, the contents of CIO 3 is scaled using the linear function defined by X (1770),
Y (0400), and the offset (07D0). These values are contained in D100 to D102, and the result is output
to D200.
0.00
SCL2
S
P1
D100
D200
Contents of R(D200)
2
0
Offset
0220
0200
P1+1:D101
P1+2:D102
Offset
07D0 Hex
SCL2
D100
P1:
0400(Y)
Contents of S (CIO 200)
0000
-0200
-0220
FED4
0000
1770
189C
0.8V
1V
5V
5.2V
1770 Hex
(X)
In the following example, it is assume that an analog signal from 1 to 5 V is converted and input to CIO
3 as 0000 to 1770 hexadecimal. SCL2(486) is used to convert (scale) the value in CIO 3 to a value
between 0200 and 0200 BCD.
2-283
2 Instructions
SCL3
Instruction
Mnemonic
SCALING 3
SCL3
Variations
Function
code
Function
487
@SCL3
SCL3
SCL3(487)
Symbol
S: Source word
P1
R: Result word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
Source word
Description
WORD
P1
WORD
Result word
INT
P1
15
P1+1
15
X
0001 to 9999 (BCD)
0
P1+2
Y
8000 to 7FFF (signed binary)
15
P1+3
Maximum conversion
8000 to 7FFF (signed binary)
15
P1+4
Minimum conversion
8000 to 7FFF (signed binary)
2-284
2 Instructions
Operand Specifications
Word addresses
Indirect DM addresses
Area
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Label
Error Flag
P_ER
Operation
ON if the contents of S is not BCD.
ON if the contents of C+1 (X) is not between 0001 and 9999 BCD.
OFF in all other cases.
Equals Flag
P_EQ
Negative Flag
P_N
S. P1,R
CIO
ON if the result is 0.
OFF in all other cases.
SCL3(487) is used to convert the signed BCD data (the BCD data contains the absolute value and the
Carry Flag shows the sign) contained in the source word S into signed binary data and place the result
in the result word R according to the linear function defined by the slope (X, Y) and an offset. The
maximum and minimum conversion values are also specified. The address of the first word containing
X, Y, the offset, the maximum conversion, and the minimum conversion is specified for the first
parameter word P1.
The sign of the result is indicated by the status of the Carry Flag (ON: negative, OFF: positive). Use
STC(040) and CLC(041) to turn the Carry Flag ON and OFF.
The following equations are used for the conversion.
R=
Y
Binary conversion of X
The offset and slope can be a positive value, 0, or a negative value. Using a negative slope enables
reverse scaling.
The result will be rounded to the nearest integer.
The source value in S is treated as an absolute BCD value and the sign is indicated by the Carry
Flag. The source value can thus be between 9999 and 9999.
If the result is less than the minimum conversion value, the minimum conversion value will be output
as the result. If the result is greater than the maximum conversion value, the maximum conversion
value will be output.
2-285
SCL3
Function
2 Instructions
Positive Offset
Negative Offset
R (signed binary)
R (signed binary)
Max conversion
Max conversion
X
Min. conversion
Offset
S (signed BCD)
Offset
S (signed BCD)
Min. conversion
Offset of 0000
R (signed binary)
Max conversion
Y
X
S (signed BCD)
Min. conversion
Hint
SCL3(487) is used to convert data using a user-defined scale to signed binary for Analog Output Units.
For example, SCL3(487) can convert 0 to 200 C to 0000 to 1770 (hex) and output an analog output
signal 1 to 5 V from the Analog Output Unit.
Sample program
When a value from 0 to 200 is scaled to an analog signal (1 to 5 V, for example), a signed BCD value of
0000 to 0200 is converted (scaled) to signed binary value of 0000 to 1770 for an Analog Output Unit.
When CIO 0.00 turns ON in the following example, the contents of D0 is scaled using the linear function
defined by X (0200), Y (1770), and the offset (0). These values are contained in D100 to D102. The
sign of the BCD value in D0 is indicated by the Carry Flag. The result is output to CIO 103.
0.00
SCL3
S
D0
P1
D100
103
:D100
Offset
P1+1:D101
P1+2:D102
P1+3:D103
Max. conversion
P1+4:D104
F E D 4
Min. conversion
P1
189C
1770
Y(1770 Hex)
-010
0200 2010
0000
2-286
2 Instructions
AVG
Mnemonic
AVERAGE
AVG
Variations
Function
code
Function
---
195
AVG
AVG(195)
Symbol
S: Source word
N: Number of cycles
2
AVG
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
UINT
Source word
Number of cycles
UINT
UINT
Variable
N: Number of Cycles
The number of cycles must be between 0001 and 0040 hexadecimal (0 to 64 cycles).
R+1
Used by system.
Average Valid Flag
OFF: Not valid (AVG(195) has not yet been executed the specified number of cycles.)
ON: Valid.
R+2:
Previous value #1
R+N+1:
Previous value #N
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
S, N
CF
Pulse bits
TR bits
---
---
---
OK
---
Flags
Name
Error Flag
Label
P_ER
Instruction
Operation
ON if the contents of N is 0.
OFF in all other cases.
2-287
2 Instructions
Function
For the first N1 cycles when the execution
condition is ON, AVG(195) writes the values of
S in order to words starting with R+2. The Previous Value Pointer (bits 00 to 07 of R+1) is
incremented each time a value is written. Until
the Nth value is written, the contents of S will
be output unchanged to R and the Average
Value Flag (bit 15 of R+1) will remain OFF.
S: Source word
N: Number of cycles
R
R+1
Pointer
Average
R+2
Cycle 1
R+3
Cycle 2
N values
R+N+1
Cycle N
Precautions
The processing information (R+1) is cleared to 0000 each time the execution condition changes from
OFF to ON.
But the processing information (R+1) will not be cleared to 0000 the first time the program is executed
at the start of operation. If AVG(195) is to be executed in the first program scan, clear the First Work
Area Word from the program.
Sample program
When CIO 0.00 is ON in the following example, the contents of D100 will be stored one time each scan
for the number of scans specified in D200. The contents will be stored in order in the ten words from
D302 to D311. The average of the contents of these ten words will be placed in D300 and then bit 15 of
D301 will be turned ON.
S:D100
0.00
AVG
S
D100
D200
D300
N:D200
(10 times)
R:D300
15
87
R+1:D301
Average Valid Flag
2-288
0
Pointer
R+2:D302
S, scan 1
R+3:D303
S, scan 2
R+11:D311
S, scan n
Average
2 Instructions
In the following example, the content of CIO 40 is set to #0000 and then incremented by 1 each cycle.
On the third and later cycles AVG(195) calculates the average value of the contents of D1002 to
D1004 and writes that average value to D1000.
0.00
@MOV
#0000
40
For the first two cycles, AVG(195) moves the content of CIO 40 to D1002 and D1003. The contents of
D1001 will also change (which can be used to confirm that the results of AVG(195) has changed).
AVG
40
#0003
D1000
AVG
CLC(41)
+
40
#0001
40
CIO 40
1st cycle
2nd cycle
3rd cycle
4th cycle
1
2 Average
D1000
Average
D1001
8000
8001
Pointer
D1002
D1003
---
D1004
---
---
3 previous values of IR 40
2-289
2 Instructions
Subroutines Instructions
SBS
Instruction
Mnemonic
SUBROUTINE CALL
Variations
SBS
Function
code
Function
091
@SBS
SBS
Symbol
SBS(091)
N
N: Subroutine number
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
---
Subroutine number
N: Subroutine number
Specifies the subroutine number between 0 and 127 decimal.
Operand Specifications
Word addresses
Indirect DM addresses
Area
N
CIO
WR
HR
AR
DM
@DM
*DM
---
---
---
---
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
OK
---
---
---
Combined-use instructions
SBN (subroutine entry) instructions and RET (subroutine return) instructions
Flags
Name
Error Flag
Label
P_ER
Operation
ON if nesting exceeds 16 levels.
ON if the specified subroutine number does not exist.
ON if a subroutine calls itself.
ON if a subroutine being executed is called.
ON if the specified subroutine is not defined in the current task.
OFF in all other cases.
2-290
2 Instructions
Function
Execution condition ON
Subroutines Instructions
SBS
n
Main program
Subroutine
program
(SBN(092) to
RET(093))
SBN
n
2
SBS
RET
END
Program end
Execution condition ON
SBS
n
Main program
D
D
SBN 10
SBN 11
to
to
SBS 11
SBS 12
to
to
RET
RET
SBN 12
SBN
n
to
A
A
RET
SBS
m
Execution condition ON
Subroutine
program n
C
Two-level
nesting
RET
SBN
m
Subroutine
program m
RET
END
Program end
2-291
2 Instructions
Precautions
The subroutine number must be unique
for each subroutine. You cannot use the
same number for more than one subroutine.
Each subroutine must have a unique
subroutine number. Do not use the
same subroutine number for more than
one subroutine.
Observe the following precautions
when using differentiated instructions
(DIFU(013), DIFD(014), or up/down differentiated instructions) in subroutines.
The operation of differentiated
instructions in a subroutine is unpredictable if a subroutine is executed
more than once in the same cycle.
In the following example, subroutine
1 is executed when CIO 0.00 is ON
and CIO 1.00 is turned ON by
DIFU(013) when CIO 0.01 has
gone from OFF to ON. If CIO 0.01
is ON in the same cycle, subroutine
1 will be executed again but this
time DIFU(013) will turn CIO 1.00
OFF without checking the status of
CIO 0.01.
In contrast, a differentiated instruction (UP, DOWN, DIFU(013) or
DIFD(014)) would maintain the ON
status if the instruction was executed and the output was turned ON
but the same subroutine was not
called a second time.
0.00
SBS
1
0.01
SBS
1
SBN
1
Subroutine
1
0.01
DIFU
4
2
The subroutine
is executed
again.
1.00
RET
0.00
SBS
1
SBN
1
0.01
DIFU
The subroutine is
not executed in
following cycles.
1.00
RET
2-292
2 Instructions
Sample program
Sequential (Non-nested) Subroutines
Subroutines Instructions
1
CIO 0.00 ON
0.00
SBS
1
3
Main program
B
CIO 0.01 ON
0.01
SBS
2
SBS
SBN
1
1
2
S1
RET
Subroutines
0.00
0.01
Order of execution
ON
ON
AS1BS2C
ON
OFF
AS1BC
OFF
ON
ABS2C
OFF
OFF
ABC
SBN
2
4
2
S2
RET
END
Program end
When CIO 0.00 is ON in the following example, subroutine 1 is executed and program execution
returns to the next instruction after SBS(091) 1. When CIO 0.01 is ON, subroutine 2 is executed and
program execution returns to the next instruction after SBS(091) 2.
2-293
2 Instructions
Nested Subroutines
A
1
CIO 0.00 ON
0.00
SBS
1
SBN
1
S1-1
0.01
SBS
CIO 0.00 ON
Subroutine 1
0.00
0.01
Order of execution
ON
ON
AS1-1S2S1-2B
ON
OFF
AS1-1S1-2B
OFF
ON
AB
OFF
OFF
AB
S1-2
RET
SBN
2
3
S2
Subroutine 2
RET
END
When CIO 0.00 is ON in the following example, subroutine 1 is executed. If CIO 0.01 is ON, subroutine
2 is executed from within subroutine 1 and program execution returns to the next instruction after
SBS(091) 2 when subroutine 2 is completed. Execution of subroutine 1 continues and program execution returns to the next instruction after SBS(091) 1 when subroutine 1 is completed.
2-294
2 Instructions
SBN/RET
Mnemonic
Variations
Function
code
Function
SUBROUTINE ENTRY
SBN
---
092
SUBROUTINE RETURN
RET
---
093
SBN
Symbol
RET
SBN(092)
N
RET(093)
N: Subroutine number
SBN/RET
Subroutines
Interrupt tasks
Usage
Not allowed
Not allowed
OK
Area
Subroutines
Interrupt tasks
Usage
Not allowed
OK
OK
RET
Operands
Data type
Operand
Description
Size
SBN
Subroutine number
---
SBN
N: Subroutine number
Specifies the subroutine number between 0 and 127 decimal.
Operand Specifications
Word addresses
Indirect DM addresses
Area
SBN
CIO
WR
HR
AR
DM
@DM
*DM
---
---
---
---
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
OK
---
---
---
Combined-use instructions
SBS (subroutine call) instruction
Subroutines Instructions
Instruction
2-295
2 Instructions
Flags
SBN/RET
There are no flags affected by this instruction.
Function
SBN
SBN(092) indicates the beginning of the subroutine with the specified subroutine number.
The end of the subroutine is indicated by
RET(093).
The region of the program beginning at the
first SBN(092) instruction is the subroutine
region. A subroutine is executed only when it
has been called by SBS(091) .
SBS
n
SBN
n
Subroutine
region
RET
RET
When program execution reaches RET(093), it is automatically returned to the next instruction after the
SBS(091) instruction that called the subroutine.
Precautions
Place the subroutine program area (SBN(092) to RET(093)) in the same task as the SBS(091)
instruction of the same number. Subroutines in other tasks cannot be called.
Not allowed
OK
Task 1
Task
SBS
SBS
n
SBN
n
RET
END
END
Task 2
SBN
n
RET
END
2-296
2 Instructions
Subroutines Instructions
SBN
SNXT
Not allowed
STEP
RET
Place the subroutines after the main program and just before the END(001) instruction in the program
for each task. If part of the main program is placed after the subroutine region, that program section
will be ignored.
SBS
n
SBN
n
Subroutine region
RET
END
Sample program
When CIO 0.00 is ON in the following example, subroutine 10 is executed and program
execution returns to the next instruction after
the SBS(091) or MCRO(099) instruction that
called the subroutine.
0.00
SBS
#10
SBN
#10
Subroutine 10
RET
END
2-297
SBN/RET
Note The input method for the subroutine number, N, is different for the CX-Programmer. Input #0 to #127 on
the CX-Programmer.
0.00
2 Instructions
Execution condition
Setting procedure
I/O Interrupts
Scheduled Interrupts
2-298
2 Instructions
Operation
A440
The maximum processing time for an interrupt task is stored in binary data in 0.1-ms units and is cleared
at the start of operation.
A441
The interrupt task number with maximum processing time is stored in binary data. Here, 8000 to 800F
Hex correspond to task numbers 00 to 0F Hex.
A441.15 will turn ON when the first interrupt occurs after the start of operation. The maximum processing time for subsequent interrupt tasks will be stored in the rightmost two digits in hexadecimal and will
be cleared at the start of operation.
Name
Maximum Interrupt
Task Processing Time
2-299
2 Instructions
MSKS
Instruction
Mnemonic
MSKS
Function
code
Variations
@MSKS
Function
Controls whether I/O interrupt tasks and scheduled interrupt tasks are executed.
690
MSKS
MSKS(690)
Symbol
N: Interrupt identifier
C: Control data
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Interrupt identifier
Control data
Data type
Size
---
UINT
Interrupt Mask
Note When the up/down differentiation setting is changed, all detected interrupt inputs will be cleared.
Contents
Scheduled Interrupt No.
N
4 or 14: Scheduled interrupt 0 (interrupt task 1)
Scheduled interrupt time units
0.1 ms
Note Settings 0001 to 000A cannot be used. An error will occur if one of these settings is used.
2-300
2 Instructions
Operand Specifications
Indirect DM addresses
CIO
WR
HR
AR
DM
@DM
Constants
CF
Pulse bits
TR bits
OK
---
---
---
*DM
---
---
---
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
Flags
Name
Error Flag
Label
P_ER
Operation
ON if N is not within the specified range.
Errors when specifying I/O Interrupts:
The Error Flag will go ON if C is not within the specified range.
Errors when specifying Scheduled Interrupts:
Word addresses
Area
The Error Flag will go ON if C is not between 10 and 9,999 decimal (000A to 270F hex).
OFF in all other cases.
When the program execution starts, the interrupt inputs that generate I/O interrupt tasks are masked
(disabled), and the internal timers creating the timer interrupts that generate scheduled interrupt tasks
are stopped.
Use MSKS(690) to enable the I/O interrupts and timer interrupts, so that the corresponding interrupt
tasks can be executed.
The value of N specifies the interrupt task and the kind of processing that will be performed.
(1) N = 102 to 107: Enabling/Disabling the Interrupt Inputs of I/O Interrupt Tasks
Enables or disables the interrupt inputs specified by N, based on the status of the bits in C. With
this function, MSKS(690) can control whether or not each task is executed.
When an interrupt input is enabled, any interrupts detected up to that point will be cleared.
(2) N = 112 to 117: Specifying the Differentiation of Interrupt Inputs
Specifies whether the interrupt inputs specified by N are up-differentiated or down-differentiated,
based on the status of the bits in C.
Use the differentiation specification together with the enabling/disabling function. If MSKS(690) is
not executed to specify up or down differentiation, the interrupt inputs are up-differentiated (the
default setting).
When MSKS(690) is executed to specify an interrupt inputs up or down differentiation, any interrupts detected up to that point will be cleared.
(3) N = 4 or 14: Resetting and Restarting Scheduled Interrupt Tasks
Sets the time interval (specified by C) for the specified scheduled interrupt task (specified by N),
resets the internal timers PV, and starts the internal timer. Since the internal timers PV is reset,
this function maintains the proper interval from the execution of MSKS(690) until the start of the
first interrupt .
Hint
The longest interrupt task processing time is stored in A440 (Maximum Interrupt Task Processing
Time). At the same time, the task number of the interrupt task with the longest interrupt task processing
time is stored in A441 (Interrupt Task with Maximum Processing Time).
2-301
MSKS
Function
2 Instructions
Precaution
Be sure that the time interval is longer than the time required to execute the scheduled interrupt task.
To accurately control the time to the first interrupt and the interrupt interval, program CLI(691) to set
the time to the first schedule interrupt just before programming MSKS(690). If MSKS(690) is used to
restart a schedule interrupt, however, the time to the first scheduled interrupt will be accurate even if
CLI(691) is not used.
During the execution of a scheduled interrput, the scheduled interrupt set time cannot be changed.
Please change the scheduled interrupt set time after disable interrupt (stop internal timer) is set with
MSKS instruction.
Sample program
Examples for Input Interrupts
When W0.00 turns ON in the following example, the first MSKS(690) (1) specifies generating input
interrupts for input interrupt 3 when the interrupt input turns ON and the second MSKS(690) (2)
unmasks the interrupt.
W0.00
MSKS
N
113
#0000
(1)
MSKS
N
103
#0000
(2)
2-302
14
&105
2 Instructions
Instruction
Mnemonic
CLEAR INTERRUPT
CLI
Variations
Function
code
Function
691
@CLI
CLI
CLI
CLI(691)
Symbol
N: Interrupt number
C: Control data
2
CLI
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Interrupt number
Control data
Data type
Size
---
UINT
Contents
Interrupt Input No.
102: Interrupt input 2 (interrupt task 2)
103: Interrupt input 3 (interrupt task 3)
Contents
Scheduled Interrupt No.
N
4: Interrupt task 0 (interrupt task 1)
Scheduled interrupt time units
(Set in the PLC Setup.)
C
0.1 ms
2-303
2 Instructions
Contents
High-speed Counter Input
10: High-speed counter input 0
11: High-speed counter input 1
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
Constants
CF
Pulse bits
TR bits
OK
---
---
---
*DM
---
---
---
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
Flags
Name
Error Flag
Label
P_ER
Operation
ON if N is not within the specified range.
ON if C is not 0000 or 0001 hex (for I/O interrupts or high-speed counter interrupts).
ON if C is not within the specified range of 10 to 9,999 decimal (000A to 270F hex) for scheduled
interrupts.
OFF in all other cases.
Function
Depending on the value of N, CLI(691) clears the specified recorded I/O interrupts, sets the time before
execution of the first scheduled interrupt, or clears the specified recorded high-speed counter interrupts.
(1) N = 102 to 107: Clearing Interrupt Inputs
CLI(691) clears a recorded interrupt input specified by N, when the corresponding bit of C is ON
and retains the recorded interrupt input when the corresponding bit is OFF.
Interrupt input n
Interrupt
input n
Internal status
Internal
status
If an I/O interrupt task is being executed and an interrupt input with a different interrupt number is
received, that interrupt number is recorded internally. The recorded I/O interrupts are executed
later in order of their priority (from the lowest number to the highest).
If you want to ignore interrupt inputs that are received while an interrupt task is being executed, use
CLI(691) to clear the recorded interrupts before they are executed.
2-304
2 Instructions
MSKS(690)
Execution of scheduled
interrupt task.
Time to first
scheduled interrupt
Sample program
When N is 4, the content of C specifies the time interval to the first scheduled interrupt task.
CLI
W0.00
CLI
N
102
#0001
D1100
15
D1100
0
0
10
#0001
2-305
2 Instructions
DI
Instruction
Mnemonic
DISABLE INTERRUPTS
Variations
DI
Function
code
Function
693
@DI
DI
Symbol
DI(693)
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
Flags
Name
Label
Error Flag
P_ER
Operation
ON if DI(693) is executed from an interrupt task.
OFF in all other cases.
Function
DI(693) is executed from the main program to temporarily disable all interrupt tasks (I/O interrupts,
scheduled interrupts).
Precautions
All interrupt tasks will remain disabled until EI(694) is executed.
DI(693) cannot be executed from an interrupt task.
Sample program
When CIO 0.00 is ON in the following example,
DI(693) disables all interrupt tasks.
0.00
DI
Disables execution of
all interrupt tasks
2-306
2 Instructions
Instruction
Mnemonic
ENABLE INTERRUPTS
Function
code
Variations
EI
---
694
Function
Enables execution of all interrupt tasks that were
disabled with DI(693).
EI
Symbol
EI(694)
EI
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
EI
Flags
Name
Error Flag
Label
P_ER
Operation
ON if EI(694) is executed from an interrupt task.
OFF in all other cases.
Function
EI(694) is executed from the main program to temporarily enable all interrupt tasks that were disabled
by DI(693). DI(693) disables all interrupts (I/O interrupts, scheduled interrupts).
Precautions
EI(694) does not require an execution condition. It is always executed with an ON execution condition.
EI(694) enables the interrupt tasks that were disabled by DI(693). It cannot unmask I/O interrupts that
have not been unmasked by MSKS(690) or set scheduled interrupts that have not been set by
MSKS(690).
EI(694) cannot be executed in an interrupt task.
Sample program
DI
EI
0.00
2-307
2 Instructions
Mnemonic
Variations
Function
code
Function
INI(880) can be used to execute the following operations
To start comparison with the high-speed counter comparison table
To stop comparison with the high-speed counter comparison table
MODE CONTROL
INI
@INI
880
INI
INI(880)
Symbol
P: Port specifier
C: Control data
NV
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
Port specifier
WORD
Control data
UINT
DWORD
NV
Description
P: Port Specifier
P
2-308
Port
0000 hex
Pulse output 0
0001 hex
Pulse output 1
0010 hex
High-speed counter 0
0011 hex
High-speed counter 1
0012 hex
High-speed counter 2
0013 hex
High-speed counter 3
0014 hex
High-speed counter 4
0015 hex
1000 hex
PWM(891) output 0
2 Instructions
C: Control Data
C
INI(880) function
Starts comparison.
0001 hex
Stops comparison.
0002 hex
0003 hex
High-speed Counter/Pulse
Output Instructions
0000 hex
15
NV
NV+1
INI
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
CF
Pulse bits
TR bits
---
---
---
*DM
P, C
---
---
---
---
---
---
---
---
---
OK
NV
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the specified range for P, C, or NV is exceeded.
ON if the combination of P and C is not allowed.
ON if a comparison table has not been registered but starting comparison is specified.
ON if a new PV is specified for a port that is currently outputting pulses.
ON if changing the PV of a high-speed counter is specified for a port that is not specified for a high-speed counter.
ON if INI(880) is executed in an interrupt task for a high-speed counter and an interrupt occurs when CTBL(882) is
executed.
OFF in all other cases.
Function
INI(880) performs the operation specified in C for the port specified in P. The possible combinations of
operations and ports are shown in the following table.
C: Control data
P: Port specifier
0002 hex:
Change PV
Not allowed.
Not allowed.
OK
OK
OK
OK
OK
Not allowed.
Not allowed.
Not allowed.
Not allowed.
OK
2-309
2 Instructions
Operation
Setting range
High-speed
counter input (P =
0010 to 0015 hex)
Linear Mode
Ring Mode
Stopping Pulse Output (P = 0000, 0001 or 1000 hex and C = 0003 hex)
If C is 0003 hex, INI(880) immediately stops pulse output for the specified port. If this instruction is executed when pulse output is already stopped, then the pulse amount setting will be cleared.
Sample program
When CIO 0.00 turns ON in the following example, SPED(885) starts outputting pulses from pulse output 0 in Continuous Mode at 500 Hz. When CIO 0.01 turns ON, pulse output is stopped by INI(880).
i
0.00
@SPED
D100
01F4
D101
#0000
Pulse output 0
#0100
D100
0.01
@INI
#0000
Pulse output 0
#0003
2-310
(Not used.)
2 Instructions
PRV
HIGH-SPEED
COUNTER PV READ
Mnemonic
PRV
Variations
@PRV
Function
code
Function
881
PRV
High-speed Counter/Pulse
Output Instructions
Instruction
PRV(881)
Symbol
P: Port specifier
C: Control data
2
PRV
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Port specifier
Control data
Data type
Size
---
---
WORD
Variable
P: Port Specifier
P
Port
0000 hex
Pulse output 0
0001 hex
Pulse output 1
0010 hex
High-speed counter 0
0011 hex
High-speed counter 1
0012 hex
High-speed counter 2
0013 hex
High-speed counter 3
0014 hex
High-speed counter 4
0015 hex
1000 hex
PWM(891) output 0
C: Control Data
C
PRV(881) function
0000 hex
0001 hex
Reads status.
0002 hex
00 3 hex
2-311
2 Instructions
15
D
Lower word of PV
D+1
Upper word of PV
2-word PV
Pulse output PV, high-speed counter input PV,
high-speed counter input frequency for high-speed counter input 0
0
15
D
PV
1-word PV
Status, range comparison results
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
P, C
---
---
---
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
CF
Pulse bits
TR
bits
---
---
---
Flags
Name
Label
Error Flag
P_ER
Operation
ON if the specified range for P or C is exceeded.
ON if the combination of P and C is not allowed.
ON if reading range comparison results is specified even though range comparison is not being executed.
ON if reading the output frequency is specified for anything except for high-speed counter 0.
ON if specified for a port not set for a high-speed counter.
OFF in all other cases.
Function
PRV(881) reads the data specified in C for the port specified in P. The possible combinations of data
and ports are shown in the following table.
C: Control data
P: Port specifier
0000 hex: Read PV
OK
OK
Not allowed.
OK
OK
OK
1000 hex:
PWM (891) output
Not allowed.
OK
Not allowed.
0033 hex:
1-s sampling method
OK
Not allowed.
Not allowed.
Not allowed.
Not allowed.
OK
(high-speed counter 0
only)
OK
(high-speed counter 0
only)
OK
(high-speed counter 0
only)
1000 hex:
PWM (891) output
Not allowed.
Not allowed.
Not allowed.
Not allowed.
P: Port specifier
2-312
2 Instructions
Operation
Setting range
High-speed counter
input (P = 0010 to 0015
hex)
Linear Mode
Ring Mode
High-speed Counter/Pulse
Output Instructions
Operation
The pulse output status is stored in D.
Results of reading
15
D 0 0 0 0 0 0 0 0
2
PRV
15
D 0 0 0 0 0 0 0 0 0 0 0 0 0
PWM(891) output
15
D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Pulse Output In-progress Flag
OFF: Stopped
ON: Outputting
15
D 0 0 0 0 0 0 0 0 0 0
Comparison Result 1
OFF: Not in range ON: In range
Comparison Result 2
OFF: Not in range ON: In range
Comparison Result 3
OFF: Not in range ON: In range
Comparison Result 4
OFF: Not in range ON: In range
Comparison Result 5
OFF: Not in range ON: In range
Comparison Result 6
OFF: Not in range ON: In range
2-313
2 Instructions
Value of C
Description
10 ms
0013 hex
Counts the number of pulses every 10 ms. The error is 10% max. at 1 kHz.
100 ms
0023 hex
Counts the number of pulses every 100 ms. The error is 1% max. at 1 kHz.
1s
0033 hex
Counts the number of pulses every 1 s. The error is 0.1% max. at 1 kHz.
Precautions
If the counter is reset when P is 0010 hex (high-speed counter 0) and C is 0013, 0023, or 0033 hex
(sampling method), the data read during the sampling time when the counter was reset will not be
dependable.
Sample program
When CIO 0.00 turns ON in the following
programming example, CTBL(882) registers
a range comparison table for high-speed
counter 0 and starts comparison. When CIO
0.01 turns ON, PRV(881) reads the range
comparison results at that time and stores
them in CIO 0100.
0.00
@CTBL
#0000
#0001
D100
0.01
@PRV
#0010
#0002
100
2-314
1.00
PRV
#0010
#0013
D200
2 Instructions
CTBL
REGISTER
COMPARISON TABLE
Mnemonic
CTBL
Function
code
Variations
@CTBL
Function
CTBL(882) is used to register a comparison table and perform
comparisons for a high-speed counter PV.
882
CTBL
CTBL(882)
Symbol
P: Port specifier
C: Control data
TB
2
CTBL
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Port specifier
Control data
TB
High-speed Counter/Pulse
Output Instructions
Instruction
Data type
Size
---
---
LWORD
Variable
P: Port specifier
P
Port
0000 hex
High-speed counter 0
0001 hex
High-speed counter 1
0002 hex
High-speed counter 2
0003 hex
High-speed counter 3
0004 hex
High-speed counter 4
0005 hex
C: Control data
C
CTBL(882) function
0000 hex
0001 hex
0002 hex
0003 hex
2-315
2 Instructions
0
0001 to 6 hex (1 to 6 target values)
TB
TB+1
TB+2
TB+16
TB+17
4 3
0
Interrupt task number
00 to 0F hex (0 to 15)
Direction
OFF: Incrementing,
ON: Decrementing
For range comparison, the comparison table always contains six ranges. The table is 30 words long,
as shown below. If it is not necessary to set six ranges, set the interrupt task number to FFFF hex for
all unused ranges.
15
Note Always set the upper limit greater than or equal to the lower limit for any one range.
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
P, C
---
---
---
---
---
---
---
---
---
OK
TB
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
2-316
CF
Pulse bits
TR bits
---
---
---
*DM
2 Instructions
Flags
Name
Label
P_ER
Operation
ON if the specified range for P or C is exceeded.
ON if the number of target values specified for target value comparison is set to 0.
ON if the number of target values specified for target value comparison exceeds 6.
ON if the upper value is less than the lower value for any range.
ON if the set values for all ranges are disabled during a range comparison.
ON if the high-speed counter is set for incremental pulse mode and decrementing is set in the table as the direction
for comparison.
ON if the same target value is specified more than once in the same comparison direction for target comparison
when the high-speed counter is set to incremental pulse mode and linear mode.
ON if an instruction is executed when the high-speed counter is set to Ring Mode and the specified value exceeds
the maximum ring value.
ON if specified for a port not set for a high-speed counter.
High-speed Counter/Pulse
Output Instructions
Error Flag
CTBL(882) registers a comparison table and starts comparison for the port specified in P and the
method specified in C. Once a comparison table is registered, it is valid until a different table is registered or until the CPU Unit is switched to PROGRAM mode.
Each time CTBL(882) is executed, comparison is started under the specified conditions. When using
CTBL(882) to start comparison, it is normally sufficient to use the differentiated version (@CTBL(882))
of the instruction or an execution condition that is turned ON only for one scan.
Note If an interrupt task that has not been registered is specified, a fatal program error will occur the first time an
interrupt is generated.
Stopping Comparison
Comparison is stopped with INI(880). It makes no difference what instruction was used to start comparison.
2-317
CTBL
Function
2 Instructions
Range Comparison
The corresponding interrupt task is called and executed when the PV enters a set range.
The same interrupt task number can be specified for more than one target value.
The range comparison table contains 6 ranges, each of which is defined by a lower limit and an upper
limit. If a range is not to be used, set the interrupt task number to FFFF hex to disable the range.
The interrupt task is executed only once when the PV enters the range.
If the PV is within more than one range when the comparison is made, the interrupt task for the range
closest to the beginning of the table will be given priority and other interrupt tasks will be executed in
following cycles.
If there is no reason to execute an interrupt task, specify AAAA hex as the interrupt task number. The
range comparison results can be read with PRV(881) or using the Range Comparison In-progress
Flags.
Note An error will occur if the upper limit is less than the lower limit for any one range.
Sample program
When CIO 0.00 turns ON in the following programming example, CTBL(882) registers a target value
comparison table and starts comparison for high-speed counter 0. The PV of the high-speed counter is
counted incrementally and when it reaches 500, it equals target value 1 and interrupt task 1 is executed. When the PV is incremented to 1000, it equals target value 2 and interrupt task 2 is executed.
0.00
@CTBL
D100
0002
#0000
D101
01F4
#0000
D102
0000
D103
0001
D104
03E8
D105
0000
D106
0002
D100
2-318
2 Instructions
SPED
Mnemonic
SPEED OUTPUT
Variations
SPED
@SPED
Function
code
Function
885
SPED
High-speed Counter/Pulse
Output Instructions
Instruction
SPED(855)
Symbol
P: Port specifier
M: Output mode
2
SPED
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Port specifier
UINT
Output mode
WORD
UDINT
P: Port specifier
P
Port
0000 hex
Pulse output 0
0001 hex
Pulse output 1
M: Output mode
15
12 11
87
15
0
F Lower word of target frequency
0 to 100,000 Hz
(0000 0000 to 0001 86A0 hex)
Direction
0 hex: CW
1 hex: CCW
Pulse output method
1 hex: Pulse + direction
Always 0 hex.
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
P, M
---
---
---
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
CF
Pulse bits
TR bits
---
---
---
*DM
2-319
2 Instructions
Flags
Name
Label
Error Flag
P_ER
Operation
ON if the specified range for P, M, or F is exceeded.
ON if PLS2(887) or ORG(889) is already being executed to control pulse output for the specified port.
ON if SPED(885) or INI(880) is used to change the mode between continuous and independent output during pulse
output.
ON if SPED(885) is executed in an interrupt task when an instruction controlling pulse output is being executed in a
cyclic task.
ON if SPEC(885) is executed in independent mode with an absolute number of pulses and the origin has not been
established.
OFF in all other cases.
Function
SPED(885) starts pulse output on the port
specified in P using the method specified in
M at the frequency specified in F. Pulse output will be started each time SPED(885) is
executed. It is thus normally sufficient to use
the differentiated version (@SPED(885)) of
the instruction or an execution condition
that is turned ON only for one scan.
Pulse frequency
Target frequency
Time
SPED(885) executed.
In independent mode, pulse output will stop automatically when the number of pulses set with
PULS(886) in advance have been output. In continuous mode, pulse output will continue until stopped
from the program.
An error will occur if the mode is changed between independent and continuous mode while pulses are
being output.
Note SPED instruction can be used only with transistor output type of CP1E N/NA-type CPU Unit.
In case of transistor output type of CP1E E-type CPU Unit or relay output type, NOP processing is applied.
Purpose
Application
Starting
pulse output
To output
with specified speed
Changing the
speed (frequency) in one
step
Frequency changes
Procedure/
instruction
Description
Pulse frequency
Outputs pulses at a
specified frequency.
SPED(885) (Continuous)
SPED(885) (Continuous)
Target frequency
Time
Execution of SPED(885)
Changing
settings
To change
speed in
one step
Changing the
speed during
operation
Pulse frequency
Target frequency
SPED(885) (Continuous)
Present frequency
Time
Execution of SPED(885)
2-320
2 Instructions
Purpose
Application
Stopping
pulse output
Stop pulse
output
Immediate stop
Description
Procedure/
instruction
SPED(885) (Continuous)
Frequency changes
Pulse frequency
Present frequency
INI(880)
Time
Execution of INI(880)
Stop pulse
output
Immediate stop
Pulse frequency
SPED(885) (Continuous)
High-speed Counter/Pulse
Output Instructions
Operation
Present frequency
Time
Execution of SPED(885)
SPED
Pulse output will stop immediately if the CPU Unit is changed to PROGRAM mode.
The number of output pulses must be set each time output is restarted.
The number of output pulses must be set in advance with PULS(881). Pulses will not be output for
SPED(885) if PULS(881) is not executed first.
The direction set in the SPED(885) operand will be ignored if the number of pulses is set with PULS(881)
as an absolute value.
Operation
Starting
pulse output
Purpose
To output with
specified
speed
Application
Positioning
without acceleration or
deceleration
Frequency changes
Pulse frequency
Procedure/
instruction
Description
Specified number of
pulses (Specified with
PULS(886).)
Target
frequency
PULS(886)
SPED(885)
(Independent)
Time
Execution of
SPED(885)
Changing
settings
To change
speed in one
step
Changing the
speed in one
step during
operation
Specified number
of pulses
Pulse
frequency (Specified with
Number of pulses
PULS(886).)
New target
specified with
frequency
PULS(886) does
Original target
not change.
frequency
PULS(886)
SPED(885)
(Independent)
SPED(885)
(Independent)
Time
Execution of SPED(885)
(independent mode)
SPED(885) (independent
mode) executed again to
change the target
frequency. (The target
position is not changed.)
2-321
2 Instructions
Operation
Stopping
pulse output
Purpose
Application
To stop pulse
output (Number of pulses
setting is not
preserved.)
Immediate stop
Frequency changes
Pulse frequency
Present
frequency
PULS(886)
SPED(885)
(Independent)
INI(880)
Time
Execution of
SPED(885)
Stop pulse
output (Number of pulses
setting is not
preserved.)
Procedure/
instruction
Description
Immediate stop
Execution
of INI(880)
Stops the pulse output
immediately and clears
the number of output
pulses setting.
Pulse frequency
Present frequency
PULS(886)
SPED(885)
(Independent)
SPED(885),
(Independent,
Target frequency of 0 Hz)
Time
Execution of
SPED(885)
Execution of
SPED(885)
Sample program
When CIO 0.00 turns ON in the following programming example, PULS(886) sets the number of output
pulses for pulse output 0. An absolute value of 5,000 pulses is set. SPED(885) is executed next to start
pulse output using the pulse + direction method in the clockwise direction in independent mode at a target frequency of 500 Hz. .
0.00
@PULS
#0000
Pulse output: 0
#0000
D100
D100
1388
D101
0000
D110
01F4
D111
0000
@SPED
#0000
#0101
D110
Pulse output: 0
Pulse + direction output
Direction:
CW in independent mode
Pulse frequency
Target frequency:
500 Hz
5,000 pulses
Time
PULS(881) and the
SPED(885) executed.
2-322
2 Instructions
PULS
Mnemonic
SET PULSES
PULS
Variations
@PULS
Function
code
Function
886
PULS(886) is used to set the pulse output amount (number of output pulses).
PULS
PULS(886)
Symbol
P: Port specifier
T: Pulse type
N: Number of pulses
2
PULS
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Port specifier
Pulse type
Number of pulses
Data type
Size
---
---
DINT
P: Port specifier
P
Port
0000 hex
Pulse output 0
0001 hex
Pulse output 1
T: Pulse type
T
Pulse type
0000 hex
Relative
0001 hex
Absolute
High-speed Counter/Pulse
Output Instructions
Instruction
The actual number of movement pulses that will be output are as follows:
For relative pulse output, the number of movement pulses = the set number of pulses.
For absolute pulse output, the number of movement pulses = the set number of pulses - the PV.
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
P, T
---
---
---
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
OK
---
---
---
2-323
2 Instructions
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the specified range for P, T, or N is exceeded.
ON if PULS(886) is executed for a port that is already outputting pulses.
ON if PULS(886) is executed in an interrupt task when an instruction controlling pulse output is being executed in a
cyclic task.
OFF in all other cases.
Function
PULS(886) sets the pulse type and number of pulses specified in T and N for the port specified in P.
Actual output of the pulses is started later in the program using SPED(885) or ACC(888) in independent
mode.
Note
An error will occur if PULS(886) is executed when pulses are already being output. Use the differentiated
version (@PULS(886)) of the instruction or an execution condition that is turned ON only for one scan to
prevent this.
The calculated number of pulses output for PULS(886) will not change even if INI(880) is used to change
the PV of the pulse output.
The direction set for SPED(885) or ACC(888) will be ignored if the number of pulses is set with
PULS(881) as an absolute value.
It is possible to move outside of the range of the PV of the pulse output amount (-2,147,483,648 to
2,147,483,647).
PULS instruction can be used only with transistor output type of CP1E N/NA-type CPU Unit.
In case of transistor output type of CP1E E-type CPU Unit or relay output type, NOP processing is
applied.
Sample program
When CIO 0.00 turns ON in the following programming example, PULS(886) sets the number of output
pulses for pulse output 0. An absolute value of 5,000 pulses is set. SPED(885) is executed next to start
pulse output using the pulse + direction method in the clockwise direction in independent mode at a target frequency of 500 Hz.
0.00
@PULS
#0000
Pulse output: 0
#0000
D100
@SPED
#0000
#0101
D110
2-324
D100
1388
D101
0000
D110
01F4
D111
0000
Pulse output: 0
Pulse + direction output
Direction:
CW in independent mode
2 Instructions
PLS2
Mnemonic
PULSE OUTPUT
Variations
PLS2
@PLS2
Function
code
Function
887
High-speed Counter/Pulse
Output Instructions
Instruction
PLS2
PLS2(887)
P
P: Port specifier
M: Output mode
PLS2
Symbol
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
---
Port specifier
Output mode
---
WORD
UDINT
P: Port Specifier
P
Port
0000 hex
Pulse output 0
0001 hex
Pulse output 1
M: Output Mode
15
12 11
87
4 3
M
Relative/absolute specifier
0 hex: Relative pulses
1 hex: Absolute pulses
Direction
0 hex: CW
1 hex: CCW
Pulse output method
1 hex: Pulse + direction
Always 0 hex.
2-325
2 Instructions
S1
Acceleration rate
S1+1
Deceleration rate
Specify the increase or decrease in the frequency per pulse control period (4 ms).
0 to 100,000 Hz
(0000 0000 to 0001 86A0 hex)
The actual number of movement pulses that will be output are as follows:
For relative pulse output, the number of movement pulses = the set number of pulses.
For absolute pulse output, the number of movement pulses = the set number of pulses the PV.
0 to 100,000 Hz
(0000 0000 to 0001 86A0 hex)
Operand Specifications
Word addresses
Indirect DM addresses
Area
P, M
Constants
CIO
WR
HR
AR
DM
@DM
*DM
---
---
---
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
Pulse bits
TR bits
---
---
---
OK
---
CF
OK
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the specified range for P, M, S, or F is exceeded.
ON if PLS2(887) is executed for a port that is already outputting pulses for SPED(885) or ORG(889).
ON if PLS2(887) is executed in an interrupt task when an instruction controlling pulse output is being executed in a
cyclic task.
ON if PLS2(887) is executed for an absolute pulse output but the origin has not been established.
OFF in all other cases.
2-326
2 Instructions
Function
The frequency is increased every pulse control period (4 ms) at the acceleration rate specified in S until
the target frequency specified in S is reached (2 in diagram).
When the target frequency has been reached, acceleration is stopped and pulse output continues at a
constant speed (3 in diagram).
The deceleration point is calculated from the number of output pulses and deceleration rate set in S and
when that point is reached, the frequency is decreased every pulse control period (4 ms) at the deceleration rate specified in S until the starting frequency specified in S is reached, at which point pulse output is stopped (4 in diagram).
Pulse output is started each time PLS2(887) is executed. It is thus normally sufficient to use the differentiated version (@PLS2(887)) of the instruction or an execution condition that is turned ON only for
one scan.
2
PLS2
Pulse frequency
Target frequency
Starting frequency
Time
PLS2(887) executed.
High-speed Counter/Pulse
Output Instructions
PLS2(887) starts pulse output on the port specified in P using the mode specified in M at the start frequency specified in F (1 in diagram).
2-327
2 Instructions
Changing settings
Purpose
Complex
trapezoidal
control
To change
speed
smoothly
(with
unequal
acceleration and
deceleration rates)
Application
Positioning with
trapezoidal acceleration and deceleration (Separate
rates used for
acceleration and
deceleration; starting speed)
The number of
pulses can be
changed during
positioning.
Changing the target speed (frequency) during
positioning
(different acceleration and deceleration rates)
Frequency changes
Specified number
of pulses
Pulse frequency
Target
frequency
Deceleration
rate
Acceleration
rate
Starting
frequency
Execution of
PLS2(887) Target
frequency
reached.
To change
target position
Stop
frequency
Time
Output stops.
Deceleration point
Specified number of
pulses (Specified with
PULS(886).)
Pulse
frequency
Changed target
frequency
Target frequency Acceleration/
deceleration
rate
Time
Execution of
ACC(888)
(independent
mode)
Pulse
frequency
Target
frequency
Specified
number of
pulses
Number of pulses
changed with
PLS2(887).
Acceleration/
deceleration
rate
Time
Execution of
PLS2(887) executed to
PLS2(887)
change the target position.
(The target frequency and
acceleration/deceleration
rates are not changed.)
To change
target position and
speed
smoothly
Number of pulses
Number of
changed with
Pulse
pulses specified PLS2(887).
frequency with PLS2(887).
Changed target
frequency
Target frequency Acceleration/
deceleration
rate
Time
Execution of
PLS2(887)
PLS2(887) executed to
change the target frequency,
acceleration rate and
deceleration rate.
2-328
Procedure/
instruction
Description
Accelerates and decelerates at a fixed rates. The
pulse output is stopped
when the specified number of pulses has been
output. (See note.)
PLS2(887)
PLS2(887)
ACC(888)
(Independent)
PLS2(887)
PLS2(887)
PULS(886)
PLS2(887)
PLS2(887)
PULS(886)
ACC(888)
(Independent)
PLS2(887)
PULS(886)
PLS2(887)
ACC(888)
(Independent)
PLS2(887)
PLS2(887)
2 Instructions
Operation
To change
target position and
speed
smoothly,
continued
Application
Changing the
acceleration and
deceleration rates
during positioning
(multiple start
function)
Frequency changes
Pulse
frequency Acceleration rate n
New target
Acceleration
frequency
rate 3
Original target
Acceleration
rate 2
frequency
Acceleration
Number of pulses
specified by
PLS2(887) #N.
Time
Execution of
PLS2(887) #1
Pulse
frequency
Specified
number of
pulses
Change of direction at the
specified deceleration rate
Number of pulses
(position) changed
by PLS2(887)
Stop pulse
output
(Number of
pulses setting is not
preserved.)
Immediate stop
PLS2(887)
PLS2(887)
PULS(886)
PLS2(887)
Pulse frequency
Present
frequency
PLS2(887)
PLS2(887)
INI(880)
Time
Execution of
SPED(885)
Stop pulse
output
smoothly.
(Number of
pulses setting is not
preserved.)
Decelerate to a
stop
Execution
of INI(880)
Pulse frequency
Present
frequency
Deceleration rate
Target
frequency = 0
Execution of
PLS2(887)
Time
ACC(888)
(Independent,
target frequency of
0 Hz)
Execution of
ACC(888)
Pulse frequency
Target
frequency
Specified number
of pulses
(Specified with
PLS2(887).)
Time
Execution of
PLS2(887)
PLS2(887)
ACC(888)
(Independent)
Time
Execution
of PLS2 Execution of
(887)
PLS2(887)
Stopping
pulse output
ACC(888)
(Independent)
2-329
PLS2
Target
frequency
PLS2(887)
Execution of PLS2(887) #N
Execution of PLS2(887) #3
Execution of
PLS2(887) #2
Changing the
direction during
positioning
PULS(886)
PLS2(887)
rate 1
To change
direction
Procedure/
instruction
Description
High-speed Counter/Pulse
Output Instructions
Changing
settings,
continued
Purpose
2 Instructions
Frequency changes
Pulse frequency
Procedure/
instruction
Description
ACC(888)
(Continuous)
PLS2(887)
Target
frequency
Time
Execution of
ACC(888)
(continuous
mode)
Execution of
PLS2(887)
Pulse
frequency
Present
frequency
Time
Execution of
ACC(888)
(continuous
mode)
Execution of PLS2(887)
with the following settings
Number of pulses =
number of pulses until stop
Relative pulse specification
Target frequency = present
frequency
Acceleration rate = 0001 to
07D0 hex
Deceleration rate = target
deceleration rate
Sample program
When CIO 0.00 turns ON in the following programming example, PLS2(887) starts pulse output from
pulse output 0 with an absolute pulse specification of 100,000 pulses. Pulse output is accelerated at a
rate of 500 Hz every 4 ms starting at 200 Hz until the target speed of 50 kHz is reached. From the
deceleration point, the pulse output is decelerated at a rate of 250 Hz every 4 ms starting until the starting speed of at 200 Hz is reached, at which point pulse output is stopped.
0.00
D100
01F4
D101
00FA
D102
C350
D100
Pulse output: 0
Pulse output method:
Pulse + direction output
Direction: CW
D103
0000
D110
D104
86A0
D105
0001
D110
00C8
D111
0000
@PLS2
#0000
#0100
Pulse frequency
Target frequency
50 kHz
100,000 pulses
Start frequency
200 Hz
Time
PLS2(887) executed.
2-330
2 Instructions
ACC
Mnemonic
ACCELERATION CONTROL
Variations
ACC
Function
code
Function
888
@ACC
ACC
High-speed Counter/Pulse
Output Instructions
Instruction
ACC(888)
Symbol
P: Port specifier
M: Output mode
2
ACC
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
Port specifier
Description
---
Output mode
---
WORD
P: Port Specifier
P
Port
0000 hex
Pulse output 0
0001 hex
Pulse output 1
M: Output Mode
15
12 11
87
4 3
M
Mode
0 hex: Continuous mode
1 hex: Independent mode
Direction
0 hex: CW
1 hex: CCW
Pulse output method
1 hex: Pulse + direction
Always 0 hex.
Note Use the same pulse output method when using both pulse outputs 0 and 1.
15
0
Acceleration/deceleration rate 1 to 65535 Hz (#0001 to FFFF)
Specify the increase or decrease in the frequency per pulse control period (4 ms).
0 to 100,000 Hz
(0000 0000 to 0001 86A0 hex)
2-331
2 Instructions
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
CF
Pulse
bits
TR
bits
---
---
---
*DM
P, M
---
---
---
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
Flags
Name
Label
Error Flag
P_ER
Operation
ON if the specified range for P, M, or S is exceeded.
ON if pulses are being output using ORG(889) for the specified port.
ON if ACC(888) is executed to switch between independent and continuous mode for a port that is outputting
pulses for SPED(885), ACC(888), or PLS2(887).
ON if ACC(888) is executed in an interrupt task when an instruction controlling pulse output is being executed in a
cyclic task.
ON if ACC(888) is executed for an absolute pulse output in independent mode but the origin has not been established.
OFF in all other cases.
Function
ACC(888) starts pulse output on the port specified in P using the mode specified in M using the target
frequency and acceleration/deceleration rate specified in S. The frequency is increased every pulse
control period (4 ms) at the acceleration rate specified in S until the target frequency specified in S is
reached.
Pulse output is started each time ACC(888) is executed. It is thus normally sufficient to use the differentiated version (@ACC(888)) of the instruction or an execution condition that is turned ON only for one
scan.
Pulse frequency
Acceleration/deceleration rate
Target frequency
Time
ACC(888) executed.
ACC(888) executed.
In independent mode, pulse output stops automatically when the specified number of pulses has been
output. In continuous mode, pulse output continues until it is stopped from the program.
An error will occur if an attempt is made to switch between independent and continuous mode during
pulse output.
PLS2(887) can be executed during pulse output for ACC(888) in either independent or continuous
mode, and during acceleration, constant speed, or deceleration. (See note.) ACC(888) can also be executed during pulse output for PLS2(887) during acceleration, constant speed, or deceleration.
If ACC(888) is executed in independent or continuous mode with a target frequency of 0 Hz and then
ACC(888) or PLS2(887) is executed before pulse output stops, the target frequency will not change and
pulse output will stop. Execute ACC(888) or PLS2(887) after pulse output stops.
Note 1 Executing PLS2(887) during speed control with ACC(888) (continuous mode) with the same target frequency as ACC(888) can be used to achieved interrupt feeding of a fixed distance. Acceleration will not be
performed by PLS2(887) for this application, but if the acceleration rate is set to 0, the Error Flag will turn
ON and PLS2(887) will not be executed. Always set the acceleration rate to a value other than 0.
2 If ACC (888) or PLS2 (887) is executed during the period from pulse output stop to one cycle after the stop
(when pulse output in-progress flag is ON), pulse output will start again in the next cycle after stopping.
However, if pulse output is stopped by INI (880), the pulse output instruction will become invalid within one
cycle after the stop. Execute the instruction till the pulse output in-progress flag is OFF.
3 ACC instruction can be used only with transistor output type of CP1E N/NA-type CPU Unit.
In case of transistor output type of CP1E E-type CPU Unit or relay output type, NOP processing is applied.
2-332
2 Instructions
Operation
Starting
pulse output
Purpose
Application
To output
with specified acceleration and
speed
Accelerating the
speed (frequency)
at a fixed rate
Frequency changes
Pulse frequency
Target frequency
Present frequency
Procedure/
instruction
Description
Outputs pulses and
changes the frequency at
a fixed rate.
ACC(888)
(Continuous)
ACC(888) or
SPED(885)
(Continuous)
ACC(888)
(Continuous)
ACC(888)
(Continuous)
ACC(888)
(Continuous)
ACC(888)
(Continuous)
Acceleration/
deceleration
rate
High-speed Counter/Pulse
Output Instructions
Note Pulse output will stop immediately if the CPU Unit is changed to PROGRAM mode.
Time
Execution of
ACC(888)
Changing settings
To change
speed
smoothly
Changing the
speed smoothly
during operation
Pulse frequency
Acceleration/
deceleration
rate
Present frequency
ACC(888)
(Continuous)
Time
Execution of
ACC(888)
Changing the
speed in a polyline
curve during operation
Pulse frequency
Acceleration rate n
Target frequency
Acceleration
rate 2
Acceleration
rate 1
Present frequency
ACC(888)
(Continuous)
Time
Execution of ACC(888)
Execution of ACC(888)
Execution of ACC(888)
Decelerating to a
stop
Pulse frequency
Acceleration/deceleration rate 1
Present
frequency
Acceleration/
deceleration rate 2
Target
frequency = 0
Time
Execution of ACC(888)
Execution of ACC(888)
Execution of ACC(888)
(target frequency = 0)
Stopping
pulse output
To stop
pulse output
Immediate stop
Pulse frequency
ACC(888)
(Continuous,
target frequency of
0 Hz)
Present frequency
INI(880) (Continuous)
Time
Execution of ACC(888) Execution of INI(880)
To stop
pulse
output
smoothly
Decelerating to a
stop
Pulse frequency
Acceleration/deceleration
Note If the target frerate (value set when starting)
quency of the second ACC(888)
instruction is 0 Hz,
Target frequency = 0
Time
the deceleration
rate from the first
Execution of ACC(888)
Execution of ACC(888)
ACC(888) instruction will be used.
Present frequency
ACC(888)
(Continuous)
ACC(888)
(Continuous,
target frequency of 0)
2-333
ACC
Target frequency
2 Instructions
Purpose
Application
Starting
pulse output
Positioning with
trapezoidal acceleration and deceleration (Same rate
used for acceleration and deceleration; no starting
speed)
The number of
pulses cannot be
changed during
positioning.
Changing settings
To change
speed
smoothly
(with the
same acceleration and
deceleration rates)
Frequency changes
Pulse frequency
Target
frequency
Specified number of
pulses (Specified
with PULS(886).)
Acceleration/
deceleration
rate
Time
Execution of
ACC(888)
Pulse
frequency
Changed target
frequency
Target frequency
Specified
number of
pulses
(Specified with
PULS(886).)
Number of pulses
specified with
PULS(886) does
not change.
Acceleration/
deceleration
rate
Stopping
pulse output
To stop
pulse output. (Number of
pulses setting is not
preserved.)
Immediate stop
PULS(886)
ACC(888) or
SPED(885)
(Independent)
ACC(888)
(Independent)
ACC(888)
(Independent)
PULS(886)
ACC(888)
(Independent)
Time
Execution of
ACC(888)
2-334
ACC(888)
(Independent)
Present
frequency
PLS2(887)
ACC(888) (independent
mode) executed again to
change the target frequency.
(The target position is not
changed, but the
acceleration/deceleration rate
is changed.)
Pulse frequency
PULS(886)
Time
Execution of
ACC(888)
(independent
mode)
Procedure/
instruction
Description
INI(880)
Execution of
INI(880)
2 Instructions
Operation
To stop
pulse output
smoothly.
(Number of
pulses setting is not
preserved.)
Application
Frequency changes
Decelerating to a
stop
Pulse frequency
Present
frequency
Deceleration rate
Target
frequency = 0
Execution of
PLS2(887)
Procedure/
instruction
Description
Time
Execution of
ACC(888)
PULS(886)
ACC(888) or
SPED(885)
(Independent)
ACC(888)
(Independent,
independent,
target frequency of 0)
PLS2(887)
Pulse frequency
Specified number
of pulses
(Specified with
PULS(886).)
Time
Execution of
ACC(888)
Sample program
When CIO 0.00 turns ON in the following programming example, ACC(888) starts pulse output from
pulse output 0 in continuous mode in the clockwise direction using the pulse + direction method. Pulse
output is accelerated at a rate of 20 Hz every 4 ms until the target frequency of 500 Hz is reached.
When CIO 0.01 turns ON, ACC(888) changes to an acceleration rate of 10 Hz every 4 ms until the target frequency of 1,000 Hz is reached.
0.00
@ACC
#0000
#0100
D100
Pulse output: 0
Pulse output method:
Pulse + direction output
Direction: CW in continuous mode
0.01
@ACC
#0000
#0100
D105
Pulse output: 0
Pulse output method:
Pulse + direction output
Direction: CW in continuous mode
D100
0014
D101
01F4
D102
0000
D105
000A
D106
03E8
D107
0000
Acceleration/deceleration rate: 20 Hz
Target frequency: 500 Hz
Acceleration/deceleration rate: 10 Hz
Target frequency: 1,000 Hz
Pulse frequency
Target frequency
1000 Hz
10 Hz/4 ms
500 Hz
20 Hz/4 ms
Time
ACC(888) executed. ACC(888) executed.
2-335
ACC
ACC(888)
(Independent,
target frequency of 0)
Target
frequency
High-speed Counter/Pulse
Output Instructions
Stopping
pulse output, continued
Purpose
2 Instructions
ORG
Instruction
Mnemonic
ORIGIN SEARCH
ORG
Variations
Function
code
@ORG
889
Function
ORG(889) performs an origin search or origin
return operation.
ORG
ORG(889)
Symbol
P: Port specifier
C: Control data
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Port specifier
---
Control data
---
P: Port Specifier
P
Port
0000 hex
Pulse output 0
0001 hex
Pulse output 1
C: Control Data
15
12 11
87
4 3
C
Always 0 hex.
Always 0 hex.
Pulse output method
1 hex: Pulse + direction
Mode
0 hex: Origin search
1 hex: Origin return
Operand Specifications
Word addresses
Indirect DM addresses
Area
P,C
2-336
CIO
WR
HR
AR
DM
@DM
*DM
---
---
---
---
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
OK
---
---
---
2 Instructions
Flags
Name
Label
P_ER
Operation
ON if the specified range for P or C is exceeded.
ON if ORG(889) is specified for a port during pulse output for SPED(885), ACC(888), or PLS2(887).
ON if ORG(889) is executed in an interrupt task when an instruction controlling pulse output is being executed in a
cyclic task.
ON if the origin search or origin return parameters set in the PLC Setup are not within range.
ON if the Origin Search High Speed is less than or equal to the Origin Search Proximity Speed or the Origin Search
Proximity Speed is less than or equal to the Origin Search Initial Speed.
ON if an origin return operation is attempted when the origin has not been established.
OFF in all other cases.
High-speed Counter/Pulse
Output Instructions
Error Flag
Function
ORG(889) performs an origin search or origin return operation for the port specified in P using the
method specified in C.
Origin search
ORG
The following parameters must be set in the PLC Setup before ORG(889) can be executed.
Origin return
An origin search or origin return is started each time ORG(889) is executed. It is thus normally sufficient
to use the differentiated version (@ORG(889)) of the instruction or an execution condition that is turned
ON only for one scan.
Note ORG instruction can be used only with transistor output type of CP1E N/NA-type CPU Unit.
In case of transistor output type of CP1E E-type CPU Unit or relay output type, NOP processing is applied.
Origin search
acceleration rate
Origin search
proximity speed
Origin search
initial speed
ORG(889) executed.
Time
Stop
2-337
2 Instructions
When the origin search operation has been completed, the Error Counter Reset Output will be
turned ON.
The above operation, however, depends on the operating mode, origin detection method, and other
parameters.
Pulse frequency
Origin return
target speed
Origin return
deceleration rate
Origin return
acceleration
rate
Origin return
initial speed
Time
Stop
ORG(889) executed.
Sample program
When CIO 0.00 turns ON in the following programming example, ORG(889) starts an origin return operation for pulse output 0 by outputting pulses using the pulse + direction method. According to the PLC
Setup, the initial speed is 100 pps, the target speed is 200 pps, and the acceleration and deceleration
rates are 50 Hz/4 ms.
0.00
Speed
@ORG
#0000
Pulse output 0
200 pps
#1100
100 pps
Time
ORG(889) executed.
Output stopped.
2-338
Setting
Pulse Output 0 Starting Speed for Origin Search and Origin Return
2 Instructions
PWM
Mnemonic
PWM
Variations
@PWM
Function
code
Function
891
PWM(891) is used to output pulses with the specified duty factor from the specified port.
PWM
PWM
Symbol
P: Port specifier
F: Frequency
D: Duty factor
Area
Subroutines
Interrupt tasks
Usage
OK
OK
OK
PWM
Operands
Operand
Description
Data type
Size
Port specifier
---
Frequency
---
Duty factor
---
P: Port Specifier
P
Port
1000 hex
1100 hex
F: Frequency
F specifies the frequency of the PWM output between 2.0 and 6,553.5 Hz (0.1 Hz units, 0014 to FFFF
hex), or between 2 and 32,000 Hz (2 Hz units, 0002 to 7D00 hex).
D: Duty Factor
0.0% to 100.0% (0.1% units, 0000 to 03E8 hex)
D specifies the duty factor of the PWM output, i.e., the percentage of time that the output is ON.
High-speed Counter/Pulse
Output Instructions
Instruction
2-339
2 Instructions
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
Constants
CF
Pulse bits
TR bits
OK
---
---
---
*DM
---
---
---
---
---
---
---
---
---
F, D
OK
OK
OK
OK
OK
OK
OK
OK
OK
Flags
Name
Label
Error Flag
P_ER
Operation
ON if the specified range for P, F, or D is exceeded.
ON if PWM are being output using ORG(889) for the specified port.
ON if PWM(891) is executed in an interrupt task when an instruction controlling PWM output is being executed in a
cyclic task.
OFF in all other cases.
Function
PWM(891) outputs the frequency specified in F at the duty factor specified in D from the port specified
in P. PWM(891) can be executed during duty-factor PWM output to change the duty factor without stopping PWM output. Any attempts to change the frequency will be ignored.
PWM output is started each time PWM(891) is executed. It is thus normally sufficient to use the differentiated version (@PWM(891)) of the instruction or an execution condition that is turned ON only for
one scan.
The PWM output will continue either until INI(880) is executed to stop it (C = 0003 hex: stop PWM output) or until the CPU Unit is switched to PROGRAM mode.
Note PWM instruction can be used only with transistor output type of CP1E N/NA-type CPU Unit.
In case of transistor output type of CP1E E-type CPU Unit or relay output type, NOP processing is applied.
Sample program
When CIO 0.00 turns ON in the following programming example, PWM(891) starts PWM output from
PWM output 0 at 200 Hz with a duty factor of 50%. When CIO 0.01 turns ON, the duty factor is changed
to 25%.
0.00
@PWM
#1000
PWM output 0
#07D0
Frequency: 200.0 Hz
&500
CIO 0.00 ON
CIO 0.01 ON
0.01
@PWM
#1000
PWM output 0
#07D0
Frequency: 200.0 Hz
&250
2-340
2 Instructions
Step Instructions
Instruction
Operation
SNXT(009): STEP
START
Step Instructions
In CP1E series PLCs, STEP(008)/SNXT(009) can be used together to create step programs.
Diagram
Equivalent to
STEP(008): STEP
DEFINE
Indicates the start of a step. Repeats the same step program until the conditions for progression to the next step
are established.
Equivalent to
Step
Corresponds
SNXT
a
A
a turns ON
STEP
A
Process A
Process A repeated until b turns ON.
Process A
SNXT
b
b turns ON
B
STEP
B
Process B
Process B repeated until c turns ON.
Process B
SNXT
c
c turns ON
STEP
C
Process C
Process C repeated until d turns ON.
Process C
SNXT
d
End
STEP
Note Work bits are used as the control bits for A, B, C and D.
2-341
2 Instructions
SNXT/STEP
Instruction
Mnemonic
Variations
Function
code
Function
STEP START
SNXT
---
009
STEP DEFINE
STEP
---
008
SNXT
STEP
When defining the beginning of a step, a control bit is specified as
follows:
SNXT(009)
STEP(008)
B: Bit
Symbol
B: Bit
STEP(008)
Subroutines
Interrupt tasks
Usage
OK
Not allowed
Not allowed
Operands
Operand
Description
Data type
Size
---
Bit
Operand Specifications
Word addresses
Indirect DM addresses
Area
B
CIO
WR
HR
AR
DM
@DM
*DM
---
OK
---
---
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Operation
Name
Label
SNXT
Error Flag
P_ER
STEP
Function
SNXT(009)
SNXT(009) is used in the following three ways:
1.To start step programming execution.
2. To proceed to the next step control bit.
3. To end step programming execution.
The step program area is from the first STEP(008) instruction (which always takes a control bit) to the
last STEP(008) instruction (which never takes a control bit).
2-342
2 Instructions
STEP(008)
STEP(008) functions in following 2 ways, depending on its position and whether or not a control bit has
been specified.
1. Starts a specific step.
2. Ends the step program area (i.e., step execution).
STEP(008) is placed at the beginning of each step with an operand, B, that serves as the control bit
for the step.
The control bit B will be turned ON by SNXT(009) and the instruction in the step will be executed
from the one immediately following STEP(008). A200.12 (Step Flag) will also turn ON when execution of a step begins.
After the first cycle, step execution will continue until the conditions for changing the step are established, i.e., until the SNXT(009) instruction turns ON the control bit in the next STEP(008).
When SNXT (009) turns ON the control bit for a step, the control bit B of the current instruction will
be reset (turned OFF) and the step controlled by bit B will become interlocked.
Handling of outputs and instructions in a step will change according to the ON/OFF status of the
control bit B. (The status of the control bit is controlled by SNXT(009)). When control bit B is turned
OFF, the instructions in the step are reset and are interlocked. Refer to the following tables.
Control bit status
Handling
ON
ONOFF
Bits and instructions in the step are interlocked as shown in the next table.
OFF
Status
All OFF
PV
Completion Flag
OFF (reset)
Holds the previous status (but the instructions are not
executed)
Note Indicates all other instructions, such as TTIM(087), TTIMX(555), SET, REST, CNT, CNTX(546),
CNTR(012), CNTRX(548), SFT(010), and KEEP(011).
The STEP(008) instruction must be placed at the beginning of each step. STEP(008) is placed at
the beginning of a step area to define the start of the step.
2-343
2
SNXT/STEP
Starting a Step
Step Instructions
2 Instructions
Hint
A200.12 (Step Flag) is turned ON for one cycle
when STEP(008) is executed. This flag can be
used to conduct initialization once the step execution has started.
0.00
Start
SNXT
W0.00
STEP
W0.00
A200.12
W0.00
1 cycle
0.01
CNT
A200.12
0001
#0003
Related Bits
Name
Step Flag
Address
A200.12
Details
ON for one cycle when a step program is started using STEP(008). Can be used to reset timers and
perform other processing when starting a new step.
c
SNXT
a
STEP
A executed
d
SNXT
b
STEP
b
B executed
e
SNXT
e turns ON (B is interlocked)
(Dummy)
STEP
Normal ladder
program
Precaution
The control bit, B, must be in the Work Area for STEP(008)/SNXT(009).
A control bit for STEP(008)/SNXT(009) cannot be use anywhere else in the ladder diagram. If the
same bit is used twice, as duplication bit error will occur.
If SBS(091) is used to call a subroutine from within a step, the subroutine outputs and instructions will
not be interlocked when the control bit turns OFF.
SNXT(009) will be executed only once, i.e., on the rising edge of the execution condition.
Input SNXT(009) at the end of the step program area and make sure that the control bit is a dummy
bit in the Work Area. If a control bit for a step is used in the last SNXT(009) in the step program area,
the corresponding step will be started when SNXT(009) is executed.
2-344
2 Instructions
STEP(008) and SNXT(009) cannot be used inside of subroutines, interrupt programs, or block programs.
Be sure that two steps are not executed during the same cycle.
The instructions that cannot be used within step programs are listed in the following table.
Mnemonic
Subroutine Instructions
Name
END(001)
END
IL(002)
INTERLOCK
ILC(003)
INTERLOCK CLEAR
JMP(004)
JUMP
JME(005)
JUMP END
CJP(510)
CONDITIONAL JUMP
SBN(092)
SUBROUTINE ENTRY
RET(093)
SUBROUTINE RETURN
Step Instructions
Function
2
SNXT/STEP
Sample program
0.00
SNXT
W0.00
STEP
W0.00
Step W0.00
SNXT
W0.01
STEP
W0.01
0.01
Step W0.01
0.02
SNXT
W30.0
STEP
2-345
2 Instructions
W0.00
STEP
W0.00
Step W0.00 (A)
W0.01
STEP
W0.01
0.04 (Step (C) reset conditions)
Step (B) ladder program
End
0.03
SNXT
W0.02
STEP
W0.02
0.04
SNXT
W30.0
STEP
2-346
2 Instructions
0.02
SNXT
W0.00
0.02
0.01
Step Instructions
SNXT
W0.01
STEP
W0.00
Step W0.00
(A)
0.03
End
SNXT
SNXT/STEP
W0.02
STEP
W0.01
Step W0.01
(B)
0.04
SNXT
W0.02
STEP
W0.02
Step W0.02
(C)
0.05
SNXT
W30.0
STEP
Additional Information:
In the above example, where SNXT(009) is executed for W0.02, the branching moves onto the next
steps even though the same control bit is used twice. This is not picked up as an error in the program
check using the CX-Programmer. A duplicate bit error will only occur in a step ladder program only
when a control bit in a step instructions is also used in the normal ladder diagram.
The above programming is used when steps A and B cannot be executed simultaneously. For simultaneous execution of A and B, delete the execution conditions illustrated below.
0.02
0.01
2-347
2 Instructions
W0.00
SNXT
W0.02
STEP
W0.00
0.02
SNXT
W0.01
0.05 (Step (C) reset conditions)
STEP
W0.01
End
Step W0.01
(B)
W0.03
200.03
0.04
SNXT
W0.04
STEP
W0.02
Step W0.02
(C)
0.03
SNXT
W0.03
STEP
W0.03
Step W0.03
(D)
STEP
W0.04
Step W0.04
(E)
0.05
SNXT
W30.0
STEP
2-348
2 Instructions
Application Examples
(1) Sequential Execution
Robot hand
Solenoid 1
SW 1
SW 4
SW 2
SW 3
Step Instructions
Solenoid 2
Photomicrosensor
Conveyor belt 2
Process A: Loading
SNXT/STEP
Conveyor belt 1
Conveyor belt 3
Process C: Inspection/Unloading
0.01(SW1)
SNXT
0.01 (SW1)
Process A
started.
W0.00
Loading
Process A
STEP
W0.00
0.02 (SW2)
Part Installation
Process B
0.03 (SW3)
Inspection/Unloading
Process C
W0.01
Process A
reset.
Process B
started.
STEP
0.04 (SW4)
W0.01
End
Programming for process B
Explanation of operation
(1) SW1 ON:
Solenoid 1 operates
Process A
Conveyor 1 operates
(2) SW2 ON stops the previous process
Robot hand operates
Process B
Conveyor 2 operates
(3) SW3 ON stops the previous process
Photo microsensor operates (for part inspection)
Conveyor 3 operates
Process C
Solenoid 2 operates (removal of defective items)
(4) SW4 ON stops the previous process
0.03(SW3)
SNXT
W0.02
STEP
W0.02
Additional Information
When another process is started from within a process (when an
SNXT instruction turns ON), all outputs of the current process are
turned OFF within that cycle.
Process B
reset.
Process C
started.
SNXT
Process C
reset.
W30.0
STEP
2-349
2 Instructions
SW D
SW A1
Guide
Printer
SW A2
SW C2
Process A
Conveyer A
Process B
Conveyer B
SW B2
SW B1
Weight scale
Process C
0.01
(SW A1)
0.02
(SW B1)
SNXT
0.02(SW B1)
0.01(SW A1)
Process A
0.01
(SW A1)
0.02
(SW B1)
Process B
W0.00
SNXT
Process A
started.
W0.01
0.03(SW A2)
0.04(SW B2)
STEP
Process C
W0.00
0.05(SW D)
Programming for process A
End
0.03(SW A2)
SNXT
Explanation of operation
Products are sorted by the guides by weight.
(1) SWA1 ON:
Conveyor (A) operates
Process A
Machine (A) operates
(2) SWB1 ON:
Conveyor (B) operates
Process B
Machine (B) operates
(3) SWA2 ON stops process A
Printing machine operates (down) Process C
UP by SWC2 ON
(4) SWB2 ON stops process B
Printing machine operates (down) Process C
UP by SWC2 ON
(5) SWD ON stops the printing machine
W0.02
Process A
reset.
Process C
started.
STEP
W0.01
Process B
reset.
Process C
started.
STEP
W0.02
Process C
reset.
W30.0
STEP
2-350
2 Instructions
Process A
SW3
Conveyer B
SW5
SW7
Conveyer A
Process B
SW2
Process C
Conveyer C
SW4
Conveyer D
Step Instructions
Process E
Process D
Conveyer E
SW6
0.01(SW1, SW2)
SNXT
W0.00
Process C
started.
SNXT
Process C
W0.02
0.03(SW4)
0.02(SW3)
STEP
W0.00
Process B
Process D
Programming for process A
0.02(SW3)
SNXT
W0.01
Process E
Process A
reset.
Process B
started.
STEP
0.05(SW7)
W0.01
End
Explanation of operation
(1) SW1, SW2 ON:
Conveyor (A) operates
Work (A) operates
Conveyor (C) operates
Work (C) operates
(2) SW3 ON:
Process (A) stops
Conveyor (B) operates
Work (B) operates
(3) SW4 ON:
Process (C) stops
Conveyor (D) operates
Work (D) operates
(4) SW5, SW6 ON:
Process (B) stops
Process (D) stops
Conveyor (E) operates
Work (E) operates
(5) SW7 ON:
Process (E) stops
Process A
W0.03 Used to
turn off
process D.
0.04(SW5, SW6)
SNXT
Process C
Process E
started.
W0.04
STEP
W0.02
Process B
Process D
SNXT
W0.03
Process C
reset.
Process D
started.
STEP
W0.03
Process E
Note When processes (B) and (D) are in operation and SW5 and
SW6 turn ON, it is judged that processes (B) and (D) are finished.
Execution of SNXT W0.04 turns OFF the outputs of process
(B) and W0.03 turns OFF.
STEP W0.03 judges ON to OFF and turns OFF the outputs of
process (D).
Additional Information
The STEP instruction turns all outputs in its process OFF when ON
changes to OFF.
STEP
W0.04
W0.04
2
SNXT/STEP
Process A
Process A
started.
Process E
reset.
W30.0
STEP
2-351
2 Instructions
Mnemonic
I/O REFRESH
Function
code
Variations
IORF
@IORF
097
Function
Refreshes the specified I/O words.
IORF
IORF(097)
Symbol
St
E: End word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
St
Starting word
Description
---
Variable
End word
---
Variable
E: End Word
CIO 001 to CIO 099, CIO 101 to CIO 199 (CP1W Expansion I/O Units I/O Area)
Operand Specifications
Word addresses
Indirect DM addresses
Area
St, E
CIO
WR
HR
AR
DM
@DM
*DM
OK
---
---
---
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if St is greater than E.
ON if St and E are in different memory areas.
OFF in all other cases.
2-352
2 Instructions
CH
NA-type CPU
Unit
Refreshable by IORF(097)
CP1E CPU Unit built-in I/O: 0CH, 1CH, 100CH and 101CH
No
Yes
Yes
CP1E CPU Unit built-in I/O: 0CH, 1CH, 2CH, 100CH, 101CH and 102CH
No
Yes
Yes
No
Yes
Yes
Yes
Note CP1E CPU Unit built-in I/O area cannot be refreshed with IORF(097).
CP1E CPU Unit built-in I/O area can be refreshed with immediate refreshing specifications (!).
IORF
Function
IORF(097) refreshes the I/O words between St and E,
inclusively. IORF(097) is used to refresh words allocated to CP1W Expansion (I/O) Units. For 30 or 40 I/O
Points, Expansion (I/O) Units are allocated words
between CIO 002 and CIO 099, CIO102 and CIO199.
For 60 I/O Points, Expansion (I/O) Units are allocated
words between CIO 003 and CIO 099, CIO103 and
CIO199. For NA20 I/O Points, Expansion (I/O) Units
are allocated words between CIO 001 and CIO 099,
CIO101 and CIO199.
Precaution
IORF(097) can be used in an interrupt task, which allows high-speed processing of specific I/O data
with an interrupt. If IORF(097) is used in an interrupt task, always disable cyclic refreshing of the
specified Special I/O Unit by turning ON the corresponding Special I/O Unit Cyclic Refreshing Disable Bit in the PLC Setup.
If words for which there is no Unit mounted exist between St and E, nothing will be done for those
words and only the words allocated to Units will be refreshed.
The I/O refreshing initiated by IORF(097) will be stopped midway if an I/O bus error occurs during I/O
refreshing.
Sample program
Refreshing Words in the I/O Bit Area
When CIO 0.00 turns ON in the following example, CIO 2 to CIO 4 (36 inputs) are refreshed (1) and
then after the required processing is performed (2), CIO 104 (8 outputs) is refreshed (3).
0.00
IORF
St
(1)
Processing
(2)
IORF
(3)
St
104
104
St CIO 2
CIO 3
E CIO 4
St CIO 104
E
CIO 4
I/O refreshing
15
CIO 104
2-353
2 Instructions
SDEC
Instruction
Mnemonic
7-SEGMENT DECODER
Function
code
Variations
SDEC
@SDEC
Function
Converts the hexadecimal contents of the designated digit(s) into 8-bit, 7-segment display code
and places it into the upper or lower 8-bits of the
specified destination words.
078
SDEC
SDEC(078)
Symbol
S: Source word
Di
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
Source word
Description
UINT
Di
Digit designator
UINT
UINT
Variable
12 11
0
Di
87
1/0
43
m
0
n
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
S
Di
CF
Pulse bits
TR bits
---
---
---
---
OK
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if settings in Di are not within the specified ranges.
OFF in all other cases.
2-354
2 Instructions
Function
15
Di
8 7
12 11
4 3
1/0
m
n
Number of digits
n
S
S+1
HEX
7-segment
D
D+1
D+2
If more than one digit is specified for conversion in Di, digits are converted in order toward the mostsignificant digit. Digit 0 is the next digit after digit 3.
Results are stored in D in order from the specified portion toward higher-address words. If just one of
the bytes in a destination word receives converted data, the other byte is left unchanged.
Sample program
When CIO 0.00 turns ON in the following example, the contents of the 3 digits beginning with digit 1 in
D100 will be converted from hexadecimal data to 7-segment data, and the results will be output to the
upper byte of D200 and both bytes of D201. The specifications of the bytes to be converted and the
location of the output bytes are made in CIO 100.
0.00
SDEC
D100
Di
100
D200
12 11
15
Di: 100
3
15
S: D100
8 7
12 11
2
4 3
8 7
1
4 3
F
Hexadecimal to 7-segment data conversion
(F 71, 1 06, and 2 5B)
D: D200
D201
7
5
1
B
2-355
SDEC
Precaution
2 Instructions
7-segment Data
The following table shows the data conversions from a hexadecimal digit (4 bits) to 7-segment code (8
bits).
Original data
Digit
2-356
Bits
Hex
3F
06
5B
4F
66
6D
LSB
1
7D
27
7F
6F
77
7C
39
5E
79
71
a
f
b
g
0
MSB
2 Instructions
DSW
Mnemonic
Variations
DSW
Function
code
Function
210
---
DSW
DSW(210)
Symbol
I: Input word
O: Output word
C1
C2
2
DSW
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
Operands
Operand
Description
Data type
Size
1
Input word
UINT
Output word
UINT
WORD
Variable
C1
Number of digit
UINT
C2
System word
WORD
Leftmost 4 digits
D3
D2
D1
D0
D0
D1
D2
D3
Rightmost 4 digits
8 7 6
3 2
CS0
CS1
CS2
CS3
Instruction
CS signals
2-357
2 Instructions
12 11
8 7
4 3
Digit 4
Digit 3
Digit 2
Digit 1
12 11
8 7
4 3
Digit 8
Digit 7
Digit 6
15
D+1
(See note.)
Digit 5
C2
System word
(Cannot be accessed by the user.)
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
I, O, D
OK
OK
OK
OK
OK
OK
OK
OK
OK
C1
---
---
---
---
---
---
---
---
C2
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
--OK
-----
Flags
Name
Error Flag
Label
P_ER
Operation
OFF
Function
DSW(210) outputs control signals to bits 00 to 04 of O, reads the specified number of digits (either 4digit or 8-digit, specified in C1) of digital switch data line data from I, and stores the result in D and D+1.
(If 4 digits are read, the result is stored in D. If 8 digits are read, the result is stored in D and D+1.)
DSW(210) reads the 4-digit or 8-digit switch data once every 16 cycles, and then starts over and continues reading the data. The One Round Flag (bit 05 of O) is turned ON once every 16 CPU Unit cycles.
2-358
2 Instructions
External Connections
COM
00
01
02
03
04
05
06
07
08
09
10
11
Connect the digital switch or thumbwheel switch to Input Unit contacts 0 to 7 and Output Unit contacts 0
to 4, as shown in the following diagram. The following example illustrates connections for an A7B Thumbwheel Switch.
84 21
IN
Switch
No. 8
CP1W-20EDT
Switch
No. 7
Switch
No. 6
Switch
No. 5
Switch
No. 4
Switch
No. 3
Switch
No. 2
Switch
No. 1
COM
00
COM
01
COM
02
03
COM
04
05
06
07
A7B
Thumbwheel
Switch
Timing Chart
I
Four digits: 00 to 03
10 0
10 1
10 2
10 3
Input data
Leftmost
4 digits
Rightmost
4 digits
O
D+1
00
When only 4 digits are read,
only word D is used.
01
CS signals
02
03
04
RD (read) signal
05
9 10 11 12 13 14 15 16
2-359
DSW
OUT
2 Instructions
Precaution
Do not read or write the system word (C2) from any other instruction. DSW(210) will not operate correctly if the system word is accessed by another instruction. The system word is not initialized by
DSW(210) in the first cycle when program execution starts. If DSW(210) is being used from the first
cycle, clear the system word from the program.
DSW(210) will not operate correctly if I/O refreshing is not performed with the Input Unit and Output
Unit connected to the digital switch or thumbwheel switch after DSW(210) is executed. Consequently,
set the input time constant for the Input Units used for the data line input word to a value that is
shorter than the cycle time.
DSW(210) reads the 4-digit or 8-digit data once in 16 cycles, and then starts over and reads the data
again in the next 16 cycles.
When executed, DSW(210) begins reading the switch data from the first of the sixteen cycles, regardless of the point at which the last instruction was stopped.
Sample program
In this example, DSW(210) is used to read an 8-digit number from a digital switch and outputs the
resulting value constantly to D0 and D3. The digital switch is connected through CIO 3 and CIO 104.
D1000 is used as the system word.
P_On
DSW(210)
Always ON Flag
2-360
104
D0
C1
#0001
C2
D1000
2 Instructions
MTR
Mnemonic
MATRIX INPUT
Variations
MTR
Function
code
Function
213
Inputs up to 64 signals from an 8 8 matrix connected to an Input Unit and an Output Unit (using
8 input points and 8 output points) and stores that
64-bit data in the 4 destination words.
---
MTR
MTR(213)
I: Input word
O: Output word
C: System word
2
MTR
Symbol
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
Operands
Operand
I
Description
Input word
Data type
Size
UINT
1
1
Output word
UINT
ULINT
System word
WORD
I: Input Word
Specify the input word allocated to the Input Unit and connect the 8 input signal lines to the Input Unit
as shown in the following diagram.
15 14 13 12 11 10 9
8 7 6
3 2
I
0
1
2
3
4
5
6
7
Bits 00 to 07 correspond to
Input Unit inputs 0 to 7.
8 7 6
3 2
O
0
1
2
3
4
5
6
7
Instruction
Bits 00 to 07 correspond to
Output Unit outputs 0 to 7.
2-361
2 Instructions
8 7 6
3 2
D
15
14
13
12
11
10
9
8
15 14 13 12 11 10 9
8 7 6
3 2
0
1
2
3
4
5
6
7
Bits 00 to 15 correspond to
matrix elements 0 to 15.
0
1
2
3
4
5
6
7
Bits 00 to 15 correspond to
matrix elements 16 to 31.
0
1
2
3
4
5
6
7
Bits 00 to 15 correspond to
matrix elements 32 to 47.
0
1
2
3
4
5
6
7
Bits 00 to 15 correspond to
matrix elements 48 to 63.
D+1
15
14
13
12
11
10
9
8
15 14 13 12 11 10 9
8 7 6
3 2
D+2
15
14
13
12
11
10
9
8
15 14 13 12 11 10 9
8 7 6
3 2
D+3
15
14
13
12
11
10
9
8
C: System Word
Specifies a work word used by the instruction. This word cannot be used in any other application.
15
C
System word
(Cannot be accessed by the user.)
Operand Specifications
Word addresses
Indirect DM addresses
Area
I, O, D, C
2-362
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
2 Instructions
Flags
Name
Label
Operation
P_ER
OFF
Function
MTR(213) outputs the selection signals to bits 00 to 07 of O, reads the data in order from bits 00 to 07
of I, and stores the 64 bits of data in the 4 words D through D+3. MTR(213) reads the status of the 64bit matrix every 24 CPU Unit cycles. The One Round Flag (bit 08 of O) is turned ON for one cycle in
every 24 cycles after each of the selection signals has been turned ON.
External Connections
Connect the hexadecimal keypad to Input Unit contacts 0 to 7 and Output Unit contacts 0 to 7, as
shown in the following diagram.
Error Flag
2
MTR
11
10
09
08
07
06
05
04
03
02
01
00
COM
1st row
IN
CP1W-20EDT
7th row
07
06
05
04
COM
03
02
COM
01
COM
00
COM
OUT
8th row
Timing Chart
00
01
02
03
04
05
06
07
00
:
32
:
64
00
:
32
:
64
08
Selection signals
Matrix status
2-363
2 Instructions
Precaution
Do not read or write the system word (C) from any other instruction. MTR(213) will not operate correctly if the system word is accessed by another instruction. The system word is not initialized by
MTR(213) in the first cycle when program execution starts. If MTR(213) is being used from the first
cycle, clear the system word from the program.
MTR(213) will not operate correctly if I/O refreshing is not performed with the Input Unit and Output
Unit connected to the external matrix after MTR(213) is executed. Consequently, set the input time
constant for the Input Units used for the data line input word to a value that is shorter than the cycle
time.
When executed, MTR(213) begins reading the matrix status from the beginning of the matrix, regardless of the point at which the last instruction was stopped.
Sample program
In this example, MTR(213) reads the 64 bits of data from the 8 8 matrix and stores the data in W0 to
W3. The 8 8 matrix is connected through CIO 3 and CIO 104. D1000 is used as the system word.
P_On
MTR(213)
Always ON Flag
I
O
2-364
3
104
W0
D1000
2 Instructions
7SEG
Mnemonic
7-SEGMENT DISPLAY
OUTPUT
Variations
Function
code
Function
---
214
7SEG
7SEG
Instruction
7SEG(214)
S
S: Source word
O: Output word
C: Control data
D: System word
Symbol
7SEG
Subroutines
Interrupt tasks
Usage
OK
OK
Not allowed
Operands
Operand
Description
Data type
Size
WORD
Variable
Output word
UINT
Control word
System word
WORD
Source word
O
C
D
S: Source Word
Specify the first source word containing the data that will be converted to 7-segment display data.
15
12 11
8 7
4 3
Digit 4
Digit 3
Digit 2
12 11
8 7
4 3
Digit 8
Digit 7
Digit 6
15
Digit 1
0
S+1
Digit 5
8 7 6
3 2
O
One Round Flag
Latch outputs
LE3
LE2
LE1
LE0
D0
D1
D2
D3
2-365
2 Instructions
Converting 8 digits
15 14 13 12 11 10 9
8 7 6
3 2
O
One Round Flag
LE3
LE2
LE1
LE0
Latch outputs
D0
D1
D2
D3
D0
D1
D2
D3
C: Control Data
The value of C indicates the number of digits of source data and the logic for the Input and Output
Units, as shown in the following table. (The logic refers to the transistor outputs NPN or PNP logic.)
Source data
4 digits (S)
0000
0001
0002
0003
0004
0005
0006
0007
D: System Word
Specifies a work word used by the instruction. This word cannot be used in any other application.
15
D
System word
(Cannot be accessed by the user.)
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
S, O
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
---
---
---
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
---
CF
Pulse bits
TR bits
---
---
---
Flags
Name
Error Flag
Label
P_ER
Operation
OFF
Function
7SEG(214) reads the source data, converts it to 7-segment display data, and outputs that data (as leftmost 4 digits D0 to D3, rightmost 4 digits D0 to D3, latch output signals LE0 to LE3) to the 7-segment
display connected to the output indicated by O. The value of C indicates the number of digits of source
data (either 4-digit or 8-digit) and the logic for the Input and Output Units.
7SEG(214) displays the 4-digit or 8-digit data in 12 cycles, and then starts over and continues displaying the data.
The One Round Flag (bit 08 of O when converting 4 digits, bit 12 of O when converting 8 digits) is
turned ON for one cycle in every 12 cycles after 7SEG(214) has turned ON each of the latch output signals.
2-366
2 Instructions
External Connections
11
10
09
08
07
06
05
04
03
02
01
00
11
10
09
08
07
06
05
04
03
02
01
00
COM
IN@ CH
IN@ CH
Connect the 7-segment display to the Output Unit as shown in the following diagram. This example
shows an 8-digit display. With a 4-digit display, the data outputs (D0 to D3) would be connected to outputs 0 to 3 and the latch outputs (LE0 to LE3) would be connected to outputs 4 to 7. Output point 12 (for
8-digit display) or output point 8 (for 4-digit display) will be turned ON when one round of data has been
output, but it is not necessary to connect them unless required by the application.
CP1W-40EDT
2
07
06
05
04
COM
03
02
01
00
COM
07
06
05
04
COM
03
02
OUT@ CH
COM
01
COM
00
COM
OUT@ CH
7SEG
LE3
LE2
LE1
D0
D1
D2
D3
LE0
VDD
(+)
VSS
(0)
LE3
LE2
LE1
VDD
(+)
VSS
(0)
Rightmost 4 digits
Leftmost 4 digits
LE0
D0
D1
D2
D3
7-segment display
Timing Chart
Bit(s) in O
Function
Data output
00 to 03
(4 digits, 2 blocks)
00 to 03
04 to 07
Latch output 0
04
08
Latch output 1
05
09
Latch output 2
06
10
Latch output 3
07
11
08
12
10 0
1 2 3
10 1
4 5
6 7
10 2
10 3
Note
8 9 10 11 12 1
2-367
2 Instructions
Precaution
Do not read or write the system word (D) from any other instruction. 7SEG(214) will not operate correctly if the system word is accessed by another instruction. The system word is not initialized by
7SEG(214) in the first cycle when program execution starts. If 7SEG(214) is being used from the first
cycle, clear the system word from the program.
After the 7-segment data is output in 12 cycles, 7SEG(214) starts over and converts the present contents of the source word(s) in the next 12 cycles.
When executed, 7SEG(214) begins on latch output 0 at the beginning of the round, regardless of the
point at which the last instruction was stopped.
Even if the connected 7-segment display has fewer than 4 digits or 8 digits in its display, 7SEG(214)
will still output 4 digits or 8 digits of data.
Sample program
In this example, 7SEG(214) converts the 8 digits of BCD data in D100 and D101 and outputs the data
through CIO 100.
There are 8 digits of data being output and the 7-segment displays logic is the same as the Output
Units logic, so the control data (C) is set to 4. D200 is used as the system word, D.
P_On
7SEG(214)
Always ON Flag
2-368
D100
100
D200
2 Instructions
Instruction
Mnemonic
TRANSMIT
Function
code
Variations
TXD
@TXD
Function
Outputs the specified number of bytes of data
from the CPU Units built-in RS-232C port or the
Serial Option Board port.
236
Serial Communication
Instructions
TXD
TXD
TXD
TXD(236)
Symbol
C: Control word
N: Number of bytes
0000 to 0100 hex (0 to 256)
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
UINT
Variable
Control word
UINT
UINT
C: Control word
15
12 11
8 7
4 3
C
Byte order
0: Most significant bytes first
1: Least significant bytes first
Always 0
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
---
C, N
OK
2-369
2 Instructions
Flags
Name
Label
Error Flag
P_ER
Operation
ON if no-protocol mode is not set in the PLC Setup.
ON if the value of C is not within range.
ON if the value for N is not between 0000 and 0100 hex.
ON if a send is attempted when the Send Ready Flag is OFF. (The Send Ready Flag is A392.05 for
the CPU Units RS-232C port, or A392.13 for Serial Option Board port.)
OFF in all other cases.
Address
A392.05
Contents
ON when data can be sent in the no-protocol mode.
Address
A392.13
Contents
ON when data can be sent in the no-protocol mode.
Function
TXD(236) reads N bytes of data from words S to S+(N2)-1 and outputs the raw data in no-protocol
mode from the CPU Units built-in RS-232C port or the Serial Option Board port. (The output port is
specified with bits 8 to 11 of C.)
The following send-message frame format can be set in the PLC Setup.
1) Start code: None or 00 to FF hex.
2) End code: None, CR+LF, or 00 to FF hex.
The data will be sent with any start and/or end codes specified in the PLC Setup. If start and end
codes are specified, the codes will be added to the send data (N). In this case, the maximum number
of bytes that can be specified for N is 256 bytes.
Data is sent in the order specified in C0 to C3.
Specification of control in C4 to C7 for the RS and ER signals take effect as follows:
1) If RS signal control is specified in C, bit 15 of S will be used as the RS signal.
2) If ER signal control is specified in C, bit 15 of S will be used as the ER signal.
3) If RS and ER signal control is specified in C, bit 15 of S will be used as the RS signal and bit 14 of S
will be used as the ER signal.
If 1, 2, or 3 hex is specified for RS and ER signal control in C, TXD(236) will be executed regardless
of the status of the Send Ready Flag (A392.05, or A392.13 depending on the port being used).
2-370
2 Instructions
Up to 259 bytes can be sent, including the send data (N = 256 bytes max.), the start code, and the
end code.
Specify the size of the send data, not including the start code and end code, in N.
Serial Communication
Instructions
87
S+1
S+2
...
...
ED
Send bytes before ED:
256 max.
...
ED
Send bytes between
ST and ED: 256 max.
TXD
CR
LF
Send bytes before
CR+LF: 256 max.
...
CR
LF
Send bytes between ST
and CR+LF: 256 max.
Data sent.
Hint
When sending data to another device by TXD instruction, the device may require that the data be
sent at certain intervals. In that case, a transmission delay time can be set to adjust the transmission
intervals.
Precautions
TXD(236) can be used only for the CPU Units RS-232C port or the Serial Option Board port. In addition, the port must be set to no-protocol mode.
Data can be sent only when the ports Send Ready Flag is ON. (The Send Ready Flag is A392.05 for
the CPU Units RS-232C port, or A392.13 for Serial Option Board port.)
Nothing will be sent if 0 is specified for N.
2-371
2 Instructions
Sample program
Sending Data to a Code Reader
This example shows how to send data to the V530-R150V3 2D Code Reader as an example of communicating with an external device.
Hardware Configuration
Sync Sensor
Monitor
F150-M05L
Power Supply
(24 VDC)
Console
F150-KP
Console Cable
RS-232C Cable
XW2Z-200T (2 m)
XW2Z-500T (5 m)
V530-R150V3
Programmable Controller
SYSMAC
CJ1G-CPU@@H
CJ1H-CPU@@H
CJ1M-CPU@@
Camera
F150-SLC20
In this example, the external device is connected to the RS-232C port built into the CPU Unit.
First, set the reading conditions for the Code Reader.
Communications Settings
The communications settings of the Code Reader are given in the following table. These are the default
settings.
Item
Setting
Communications mode
No-protocol
Baud rate
38,400 bps
8 bits
Parity
None
Stop bits
Start code
None
End code
#000D (CR)
Set the PLC communications settings to the same values in the PLC Setup. Only the end code needs to
be set.
2-372
2 Instructions
Programming Example
0.01
A392.05
@TXD
RS-232C Port Send
Ready Flag
0.02
D10
D20
&3
Serial Communication
Instructions
If CIO 0.01 turns ON while the RS-232C Port Send Ready Flag (A392.05) is ON, three bytes of data
starting from the upper byte of D10 are sent without conversion to the Code Reader connected to the
CPU Units built-in RS-232C port. These three bytes contain @GO, which is the normal read command used as a trigger input to the Code Reader from the RS-232C line.
A392.06
@RXD
RS-232C Port Receive
Ready Flag
D100
D20
Upper byte
15
Lower byte
12 11
S: D10
D11
15
C: D20
12 11
0
TXD
RS-232C Port
Reception Counter
A393
Sent
@GL
40 53 4E
ED
Three bytes
0
0
Byte Order
#0: Most significant bytes first
RS and ER Signal Control
#0: No RS and ER signal control.
Serial Port Specifier
#1: CPU Units built-in RS-232C port
Always #0.
Controlling Signals
0.01
TXD
S
D300
D400
&0
15
14
13
12
S: D300
12 11
0
4
3
0
0
Byte Order
#0: Most significant bytes first
2-373
2 Instructions
RXD
Instruction
Mnemonic
RECEIVE
Variations
RXD
@RXD
Function
code
Function
235
RXD
RXD(235)
Symbol
C: Control word
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Data type
Size
Description
UINT
Variable
Control word
UINT
UINT
C: Control Word
15
12 11
8 7
4 3
C
Byte order
0 Hex: Most significant byte to least significant byte
1 Hex: Lest significant byte to most significant byte
CS and DR signal monitoring
0: No CS and DR signal monitoring
1: CS signal monitoring
2: DR signal monitoring
3: CS and DR signal monitoring.
Always 0
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
---
C, N
OK
Flags
Name
Error Flag
Label
P_ER
Operation
ON if no-protocol mode is not set in the PLC Setup.
ON if the value of C is not within range.
ON if the value for N is not between 0000 and 0100 hex.
OFF in all other cases.
2-374
2 Instructions
Contents
ON when no-protocol reception is completed.
Number of Receive Bytes Specified: The flag will turn ON when the specified number of
bytes has been received.
End Code Specified: The flag will turn ON when the end code is received or when 256
bytes have been received.
A392.07
ON when more than the expected number of receive bytes has been received.
Serial Communication
Instructions
Name
RS-232C Port Reception Completed Flag
Number of Receive Bytes Specified: The flag will turn ON when anything is received
after reception has been completed and execution of the next RXD(235).
End Code Specified: The flag will turn ON when anything is received after the end code
has been received and execution of the next RXD(235) or when the 257th byte of data is
received before the end code is received.
RS-232C Port Reception Counter
A393
Counts in hexadecimal the number of bytes received in no-protocol mode (0 to 256 decimal).
RXD
Address
A392.14
Contents
ON when no-protocol reception is completed.
Number of Receive Bytes Specified: The flag will turn ON when the specified number of bytes has been received.
End Code Specified: The flag will turn ON when the end code is received or when
256 bytes have been received.
A392.15
ON when more than the expected number of receive bytes has been received in noprotocol mode.
Number of Receive Bytes Specified: The flag will turn ON when more data is
received after reception was completed but before the received data was not read
from the buffer with RXD(235).
End Code Specified: The flag will turn ON when 257 or more bytes of data are
received without an end code.
A394.00 to A394.15
2-375
2 Instructions
Function
RXD(235) reads data that has been received in no-protocol mode at the CPU Units built-in RS-232C
port or the Serial Option Board port (the port is specified with bits 8 to 11 of C) and stores N bytes of
data in words D to D+(N2)-1. If N bytes of data has not been received at the port, then only the data
that has been received will be stored.
The following receive message frame format can be set in the PLC Setup.
1) Start code: None or 00 to FF hex
2) End code: None, CR+LF, or 00 to FF hex. If no end code is specified, the number of bytes to
received is set from 00 to FF hex (1 to 256 decimal; 00 specifies 256 bytes).
Data will be stored in memory in the order specified in C0 to C3.
Cases where the reception completion flag turns ON
The Reception Completed Flag (note (a)) will turn ON when the number of bytes specified in the PLC
Setup has been received. When the Reception Completed Flag turns ON, the number of bytes in the
Reception Counter (note (b)) will have the same value as the number of receive bytes specified in the
PLC Setup.
If an end code is specified in the PLC Setup, the Reception Completed Flag (note (a)) will turn ON
when the end code is received or when 256 bytes of data have been received. If more bytes are
received than specified, the Reception Overflow Flag (note (c)) will turn ON.
When RXD(235) is executed, data is stored in memory starting at D, the Reception Completed Flag
(note (a)) will turn OFF (even if the Reception Overflow Flag (note (c)) is ON), and the Reception
Counter (note (b)) will be cleared to 0.
If the RS-232C Port Restart Bit (note (d)) is turned ON, the Reception Completed Flag (note (a)) will
be turned OFF (even if the Reception Overflow Flag is ON), and the Reception Counter (note (b)) will
be cleared to 0.
Specification of monitor in bits C4 to C7 for the CS and DR signals takes effect as follows:
1) If CS signal monitoring is specified in C, the status of the CS signal will be stored in bit 15 of D.
2) If DR signal monitoring is specified in C, the status of the DR signal will be stored in bit 15 of D.
3) If CS and DR signal monitoring is specified in C, the status of the CS signal will be stored in bit 15
of D and the status of the DR signal will be stored in bit 14 of D.
If 1, 2, or 3 hex is specified for CS and DR signal control in C, RXD(235) will be executed regardless
of the status of the Receive Completed Flag (note (a)).
Receive data will not be stored if CS or DR signal monitoring is specified.
Up to 259 bytes can be received, including the receive data (N = 256 bytes max.), the start code, and
the end code.
Specify the size of the receive data, not including the start code and end code, in N.
Note Related Auxiliary Area and CIO Area Addresses
(a) Reception Completed Flags
Built-in RS232C port
A392.06
A392.14
A393
A394
A392.07
A392.15
2-376
A526.00
A526.01
2 Instructions
Serial Communication
Instructions
ST
ED
Receive bytes before
ED: 256 max.
ST
ED
Receive bytes between
ST and ED: 256 max.
CR
1 2 3 4 5 6 0...
RXD
ST
LF
LF
Receive bytes between
ST and CR+LF: 256 max.
Received
Bytes
1
2
3
4
N bytes
stored in the
specified
Max: 256 bytes order.
15
87
D+1
D+2
6
When receiving the least significant
bytes first is specified (1):
Most significant bytes
15
D+1
D+2
Hint
When RXD(235) is used to read data that was received at one of the Serial Option Boards ports , the
ports reception buffer is cleared after RXD(235) is executed. Consequently, RXD(235) can not be
executed repeatedly to read a block of data in parts.
Precautions
RXD(235) can be used only for the CPU Units RS-232C port or the Serial Option Board port. In addition, the port must be set to no-protocol mode.
Execute this instruction when the reception completion flag (RS-232C incorporated in the CPU unit:
A392.06, Serial Option Board: A392.14) is 1 (ON) to receive data (from the reception buffer).
When data is received, the data must be read by an RXD instruction or the next data cannot be
received. When the reception completion flag turns ON, read the received data with an RXD instruction before the next reception.
Specify the size of the receive data, not including the start code and end code, in N.
If 0 is specified for N, the Reception Completed Flag and Reception Overflow Flag (note(a)) will be
turned OFF, the Reception Counter (note(b)) will be cleared to 0, and nothing will be stored in memory.
2-377
2 Instructions
Sample program
Receiving data
This example shows how to receive data from the V530-R150V3 2D Code Reader as an example of
communicating with an external device.
Hardware Configuration
Sync Sensor
Monitor
F150-M05L
Power Supply
(24 VDC)
Console
F150-KP
Console Cable
RS-232C Cable
XW2Z-200T (2 m)
XW2Z-500T (5 m)
V530-R150V3
Programmable Controller
SYSMAC
CJ1G-CPUH
CJ1H-CPUH
CJ1M-CPU
Camera
F150-SLC20
In this example, the external device is connected to the RS-232C port built into the CPU Unit.
First, set the reading conditions for the Code Reader.
Communications Settings
The communications settings of the Code Reader are given in the following table. These are the default
settings.
Item
Setting
Communications mode
No-protocol
Baud rate
38,400 bps
8 bits
Parity
None
Stop bits
Start code
None
End code
#000D (CR)
Set the PLC communications settings to the same values in the PLC Setup. Only the end code needs to
be set.
2-378
2 Instructions
Programming Example
0.01
A392.05
TXD
D10
D20
&3
0.02
A392.06
Serial Communication
Instructions
If CIO 0.02 turns ON while the RS-232C Port Send Ready Flag (A392.05) is ON, the number of bytes of
reading results specified in the RS-232C Port Reception Counter (A393) are read from the Code
Reader connected to the CPU Units built-in RS-232C port and stored starting from the upper byte of
D100.
RXD
RS-232C Port Receive
Ready Flag
D100
D20
2
RS-232C Port
Reception Counter
A393
36
2F
30
38
2F
31
S: D100
31
=06/08/11
15
C: D20
12 11 8 7
0
4 3
Lower byte
15 12 11 8 7
Received
30
RXD
Upper byte
4 3
3
0
6
D101
D102
D103
Byte Order
#0: Most significant bytes first
RS and ER Signal Control
#0: No RS and ER signal control
Serial Port Specifier
#1: CPU Units built-in RS-232C port
Always #0.
Controlling Signals
0.00
RXD
D
D100
D200
&10
15
14
13
12
D: D100
DR signal: 0
CS signal: 1
15
C: D200
12 11
0
4
3
0
0
Byte Order
#0: Most significant bytes first
2-379
2 Instructions
Clock Instructions
CADD/CSUB
Instruction
Mnemonic
Variations
Function
code
Function
CALENDAR ADD
CADD
@CADD
730
CALENDAR SUBTRACT
CSUB
@CSUB
731
CADD
CSUB
CSUB(731)
CADD(730)
Symbol
T
R
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
2-380
Description
Data type
Size
WORD
DWORD
WORD
2 Instructions
CADD
C through C+2: Calendar Data
15
Minutes: 00 to 59 (BCD)
Minutes: 00 to 59 (BCD)
15
15
C+1
Clock Instructions
Seconds: 00 to 59 (BCD)
Seconds: 00 to 59 (BCD)
T+1
2
Hour: 00 to 23 (BCD)
CADD/CSUB
Day: 01 to 31 (BCD)
15
C+2
Month: 01 to 12 (BCD)
Year: 00 to 99 (BCD)
Seconds: 00 to 59 (BCD)
Minutes: 00 to 59 (BCD)
15
R+1
Hour: 00 to 23 (BCD)
Day: 01 to 31 (BCD)
15
R+2
Month: 01 to 12 (BCD)
Year: 00 to 99 (BCD)
2-381
2 Instructions
CSUB
C through C+2: Calendar Data
15
Seconds: 00 to 59 (BCD)
Seconds: 00 to 59 (BCD)
Minutes: 00 to 59 (BCD)
Minutes: 00 to 59 (BCD)
15
15
T+1
C+1
Hour: 00 to 23 (BCD)
Day: 01 to 31 (BCD)
15
C+2
Month: 01 to 12 (BCD)
Year: 00 to 99 (BCD)
Seconds: 00 to 59 (BCD)
Minutes: 00 to 59 (BCD)
15
R+1
Hour: 00 to 23 (BCD)
Day: 01 to 31 (BCD)
15
R+2
Month: 01 to 12 (BCD)
Year: 00 to 99 (BCD)
2-382
2 Instructions
Operand Specifications
Word addresses
Indirect DM addresses
Area
Constants
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
CF
Pulse bits
TR bits
---
---
---
--OK
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the calendar data in C through C+2 is not within the specified ranges.
Clock Instructions
ON if the time data in T and T+1 is not within the specified ranges.
OFF in all other cases.
Equal Flag
P_EQ
CADD
CADD(730) adds the calendar data (words C through C+2) to the
time data (words T and T+1) and outputs the resulting calendar data
to R through R+2.
15
C
87
Minutes
C+1
C+2
Day
Hour
Year
Month
+
15
T
87
Minutes
15
87
R
R+1
Minutes
Day
Hour
R+2
Year
Month
CSUB
15
Seconds
87
Minutes
C
C+1
C+2
0
Seconds
Day
Hour
Year
Month
-
15
T
87
Minutes
0
Seconds
Hours
T+1
15
0
Seconds
Hours
T+1
CSUB(731) subtracts the time data (words T and T+1) from the calendar data (words C through C+2) to and outputs the resulting calendar data to R through R+2.
0
Seconds
87
R
R+1
Minutes
Day
Hour
R+2
Year
Month
Seconds
2-383
CADD/CSUB
Function
2 Instructions
Sample program
CADD
When CIO 0.00 turns ON in the following example, the calendar data in D100 through D102 (year,
month, day, hour, minutes, seconds) is added to the time data in D200 and D201 (hours, minutes, seconds) and the result is output to D300 through D302.
0.00
CADD
C
D100
D200
D300
15
87
0
20
18
12
30
10
99
C:D100
D101
D102
18:30:20
10 December, 1999
+
87
15
T:D200
D201
10
06
87
15
R:D300
D301
D302
0
15
00
40
04
00
10 minutes, 15 seconds
600 hours
0
35
18
01
18:40:35
4 January, 2000
CSUB
When CIO 0.00 turns ON in the following example, the time data in D200 and D201 (hours, minutes,
seconds) is subtracted from the calendar data in D100 through D102 (year, month, day, hour, minutes,
seconds) and the result is output to D300 through D302.
0.00
CSUB
C
D100
D200
D300
15
87
15
T:D200
D201
87
10
00
15
R:D300
D301
D302
2-384
0
20
18
07
30
10
98
C:D100
D101
D102
0
15
50
87
20
08
98
18:30:20
10 July, 1998
0
05
16
07
16:20:05
8 July, 1998
2 Instructions
DATE
Instruction
Mnemonic
DATE
Function
code
Function
735
@DATE
DATE
DATE(735)
Symbol
Clock Instructions
CLOCK ADJUSTMENT
Variations
2
Applicable Program Areas
Step program areas
Subroutines
Interrupt tasks
Usage
OK
OK
OK
DATE
Area
Operands
Operand
Description
Data type
Size
LWORD
15
S+2
Seconds:
00 to 59 (BCD)
Month:
01 to 12 (BCD)
Minutes: 00 to 59 (BCD)
15
Year: 00 to 99 (BCD)
0
8 7
15
S+3
S+1
Day of
the week: 00 = Sunday
01 = Monday
02 = Tuesday
03 = Wednesday
04 = Thursday
05 = Friday
06 = Saturday
Hour:
00 to 23 (BCD)
Always set to 00.
Day: 01 to 31 (BCD)
Operand Specifications
Word addresses
Indirect DM addresses
Area
S
CIO
WR
HR
AR
DM
@DM
*DM
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
---
---
---
---
Flags
Name
Error Flag
Label
P_ER
Operation
ON if the new clock setting in S through S+3 is not within the specified range.
OFF in all other cases.
ON when DATE instruction is executed for CP1E-E-.
2-385
2 Instructions
Address
Clock data
A351 to A354
Operation
A351.00 to A351.07: Seconds (00 to 59) (BCD)
A351.08 to A351.15: Minutes (00 to 59) (BCD)
A352.00 to A352.07: Hours (00 to 23) (BCD)
A352.08 to A352.15: Day of the month (01 to 31) (BCD)
A353.00 to A353.07: Month (01 to 12) (BCD)
A353.08 to A353.15: Year (00 to 99) (BCD)
A354.00 to A354.07: Day of the week (00 to 06) (BCD)
00: Sunday, 01: Monday, 02: Tuesday, 03: Wednesday, 04: Thursday,
05: Friday, 06: Saturday
Function
DATE(735) changes the internal clock
setting according to the clock data in
the four source words. The new internal clock setting is immediately
reflected in the Calendar/Clock Area
(A351 to A354).
CPU Unit
Internal clock
New setting
Seconds
S1
Minutes
S+1
Day
Hour
S+2
Year
Month
S+3
00
Day of week
Hint
The internal clock setting can also be changed from a Peripheral Device or the CLOCK WRITE FINS
command (0702).
Precaution
An error will not be generated even if the internal clock is set to a non-existent date (such as November 31).
In case this instruction is executed for E-type CPU Unit (CP1E-E-), the error flag will turn
ON and the instruction cannot be executed. For E-type CPU Unit, A351 to A354 is always 01-01-01
01:01:01 Sunday.
Sample program
When CIO 0.00 turns ON in the following example, the internal clock is set to 20:15:30 on Thursday,
October 9, 1998.
0.00
DATE
S
D100
15
S:D100
87
15
0
30
Minute
15
D101
Second
0
87
09
20
Day of
Hour
the month
0
15
87
D102
98
10
Year
15
D103
87
00
Always
set to
00.
2-386
Month
04
Day of the week
2 Instructions
FAL
Instruction
Mnemonic
FAILURE ALARM
Variations
FAL
Function
code
Function
006
@FAL
2
FAL
Generating or Clearing User-defined Non-fatal Errors
FAL
FAL(006)
FAL(006)
Symbol
N: FAL number
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
FAL number
Data type
Size
Constants only
WORD
Variable
0
#FFFF:
Word address:
Generates a non-fatal error with the corresponding FAL number.
The 16-character ASCII message contained in S through S+7 will
be displayed on the Programming Device.
#0000 to #FFFF:
Generates a non-fatal error with the corresponding FAL number (no
message).
S+1
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
*DM
---
---
---
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
Constants
CF
Pulse bits
TR bits
OK
---
---
---
2-387
2 Instructions
Flags
Name
Label
Error Flag
ER
Operation
ON if N is not within the specified range of 0 to 511 decimal.
ON if a non-fatal system error is being generated, but the specified error code or error details code is
incorrect.
OFF in all other cases.
Address
Operation
A402.15
A360.01 to
A391.15
When an error is generated with FAL(006), the corresponding flag will be turned ON. Flags A360.01 to
A391.15 correspond to FAL numbers1 to 511 decimal.
Address
System-generated FAL/FALS
number
A529
Operation
A dummy FAL/FALS number is used when a system error is generated with FAL(006). Set the same
dummy FAL/FALS number in this word (0001 to 01FF hex, 1 to 511 decimal).
Address
Operation
A100 to A199
The Error Log Area contains the error codes and time/date of occurrence for the most recent 20 errors,
including errors generated by FAL(006).
Error code
A400
When an error occurs its error code is stored in A400. The error codes for FAL numbers 0001 to 01FF
are 4101 to 42FF, respectively.
If two or more errors occur simultaneously, the error code of the most serious error will be stored in
A400.
Process
The FAL error of the specified number will be cleared.
FFFF hex
The most serious non-fatal error (even if it is a non-fatal system error) that has occurred. When more
than one FAL error has occurred, the FAL error with the smallest FAL number will be cleared.
2-388
2 Instructions
Function
The following table shows the error codes and FAL Error Flags for FAL(006).
FAL number
1 to 511 decimal
4101 to 42FF
A360.01 to A391.15
When FAL(006) is executed with N set to an FAL number (&1 to &511) that is not equal to the content of
A529 (the system-generated FAL/FALS number), a non-fatal error will be generated with that FAL number and the following processing will be performed:
FAL Error Flag ON
FAL
N
0000
FAL
Execution of
FAL(006)
generates a
non-fatal error with FAL
number N.
1. The FAL Error Flag (A402.15) will be turned ON. (PLC operation will continue.)
2. The Executed FAL Number Flag will be turned ON for the corresponding FAL number. Flags A360.01
to A391.15 correspond to FAL numbers 0001 to 01FF (1 to 511).
3. The error code will be written to A400. Error codes 4101 to 42FF correspond to FAL numbers 0001 to
01FF (1 to 511).
4. The error code and the time that the error occurred will be written to the Error Log Area (A100
through A199).
Note The error record will not be written to the Error Log Area if the Dont register FAL to error log Option in the
PLC Setup is selected.
Execution of FAL(006)
generates a non-fatal
system error with the
error code/details
specified in S and S+1.
Matching
values
A529CH
S
S+1
N
Error code
Error details
2-389
2 Instructions
The following table shows how to specify error codes and error details in S and S+1.
Error name
PLC Setup Error
S
009B hex
S+1
PLC Setup Error Location
0000 to FFFF hex
008A hex
00D1 hex
Battery Error
00F7 hex
Disable Error Log entries for user-defined FAL(006) errors when you want to record only the systemgenerated errors. For example, this function is useful during debugging if the FAL(006) instructions are
used in several applications and the Error Log is becoming full of user-defined FAL(006) errors.
The following screen capture shows the PLC Setup setting from the CX-Programmer.
2-390
2 Instructions
Note Even if PLC Setup word 129 bit 15 is set to 1 (Do not record FAL Errors in Error Log.), the following errors will
be recorded:
An ASCII message up to 16 characters long can be stored in S through S+7. The leftmost (most significant) byte in each word is displayed first.
FAL
The end code for the message is the null character (00 hexadecimal).
All 16 characters in words S to S+7 will be displayed if the null character is omitted.
If the contents of the words containing the message are changed after FAL(006) is executed, the
message will change accordingly.
Sample program
Generating a Non-fatal Error
When CIO 0.00 is ON in the following example, FAL(006) will generate a non-fatal error with FAL number 31 and execute the following processes.
1. The FAL Error Flag (A402.15) will be turned ON.
2. The corresponding Executed FAL Number Flag (A361.15) will be turned ON.
3. The corresponding error code (411F) will be written to A400.
4. The error code and the time/date that the error occurred will be written to the Error Log Area (A100
through A199).
5. The ERR Indicator on the CPU Unit will flash.
6. The ASCII message in D100 to D107 will be displayed at the Peripheral Device.
Note If a message is not required, specify a constant for S.
0.00
FAL
N
31
D100
15
M: D100
M:
4C
D101
57
20
D102
56
4F
D103
4C
54
D104
41
47
D105
45
00
D106
4F
MESSAGE
LOW VOLTAGE
Disregarded
D107
Note If two or more errors occur at the same time, the error code of the most serious error (with the highest error
code) will be stored in A400.
2-391
2 Instructions
#001F
#FFFF
#0000
FAL
N
10
D200
Matching
values
2-392
A529CH
000A
S: D200
#00D1
D201
#0001
2 Instructions
Instruction
Mnemonic
Variations
Function
code
---
007
FALS
Function
Generates user-defined fatal errors. Fatal errors
stop PLC operation.
FALS
Generating User-defined Fatal Errors
FALS(007)
Symbol
N: FAL number
Area
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Description
FAL number
Data type
Size
Constants only
WORD
Variable
Specifies the first of eight words containing an ASCII message to be displayed on the Programming Device.
Specify a constant (0000 to FFFF) if a message is not required.
S+1
Operand Specifications
Word addresses
Indirect DM addresses
Area
CIO
WR
HR
AR
DM
@DM
Constants
CF
Pulse bits
TR bits
OK
---
---
---
*DM
---
---
---
---
---
---
---
---
---
OK
OK
OK
OK
OK
OK
OK
OK
OK
Flags
Name
Error Flag
Label
P_ER
2
FALS
Operand
FALS
Operation
ON if N is not within the specified range of 0001 to 01FF (1 to 511 decimal).
ON if a fatal system error is being generated, but the specified error code or error details code is
incorrect.
OFF in all other cases.
2-393
2 Instructions
Address
A401.06
Operation
ON when an error is generated with FALS(007).
Address
System-generated FAL/FALS
number
A529
Operation
A dummy FAL/FALS number is used when a system error is generated with FALS(007). Set the same
dummy FAL/FALS number in this word (0001 to 01FF hex, 1 to 511 decimal).
Address
Operation
A100 to A199
The Error Log Area contains the error codes and time/date of occurrence for the most recent 20 errors,
including errors generated by FALS(007).
Error code
A400
When an error occurs its error code is stored in A400. The error codes for FALS numbers 0001 to 01FF
(1 to 511 decimal) are C101 to C2FF, respectively.
Note If two or more errors occur simultaneously, the error code of the most serious error will be stored
in A400.
Function
Generating Fatal User-defined Errors
FALS number
1 to 511
C101 TO C2FF
When FALS(007) is executed with N set to an FALS number (1 to 511) that is not equal to the content of
A529 (the system-generated FAL/FALS number), a fatal error will be generated with that FALS number
and the following processing will be performed:
FALS Error Flag ON
FALS
N
0000
Execution of
FALS(007)
generates a
fatal error
with FALS
number N.
1. The FALS Error Flag (A401.06) will be turned ON. (PLC operation will stop.)
2. The error code will be written to A400. Error codes C101 to C2FF correspond to FALS numbers 0001
to 01FF (1 to 511).
Note If an error more serious than the FALS(007) instruction (one with a higher error code) has occurred, A400
will contain the more serious errors error code.
3. The error code and the time/date that the error occurred will be written to the Error Log Area (A100
through A199).
4. The ERR Indicator on the CPU Unit will be lit.
5. If a word address has been specified in S, the ASCII message beginning at S will be registered (displayed on the Peripheral Device).
Note 1 If an error that is more serious (including fatal system errors) than an error registered with this instruction
occurs simultaneously, the error code of that error will be set in error code A400.
2 The end code for the message is the null character (00 hexadecimal). All 16 characters in words S to S+7
will be displayed if the null character is omitted.
3 N must between 0001 and 01FF. An error will occur and the Error Flag will be turned ON if N is outside of
the specified range.
2-394
2 Instructions
I/O memory
ON
Hold
OFF
OFF
Hold
OFF
Execution of FALS(007)
generates a fatal system
error with the error
code/details specified in
S and S+1.
Matching
values
A529CH
FALS
S
S+1
4 When a user-defined fatal error is registered, the I/O memory and output status from output units will be as
indicated below.
Error code
Error details
When FALS(007) is executed with N set to an FAL number (1 to 511) that is equal to the content of
A529 (the system-generated FAL/FALS number), a fatal error will be generated with the error code and
error details code specified in S and S+1. The following processing will be performed at the same time:
1. The specified error code will be written to A400.
2. The error code and the time that the error occurred will be written to the Error Log Area (A100
through A199).
3. The appropriate Auxiliary Area Flags are set based on the error code and error details.
4. The ERR Indicator on the CPU Unit will light and PLC operation will be stopped.
Note 1 The value of A529 (the system-generated FAL/FALS number) is a dummy FAL number (FAL and FALS
numbers are shared.) used when a non-fatal error is generated intentionally by the system. This number is
a dummy FAL number, so it is not reflected in the error code.
When it is necessary to generate two or more system errors, different errors can be generated by executing the FAL/FALS instructions more than once with the same values in A529 and N, but different values in
S and S+1.
2 If a more serious error (including a system-generated fatal error or another FALS(007) error) occurs at the
same time as the FALS(007) instruction, the more serious errors error code will be written to A400.
3 To clear a system error generated by FALS(007), turn the PLC OFF and then ON again. The PLC can be
kept ON, but the same processing will be required to clear the error as if the specified error had actually
occurred. Refer to CP1E CPU Unit Hardware Operation Manual or CP1E CPU Unit Software Operation
Manual for details.
4 The following table shows how the IOM Hold Bit affects the status of I/O memory and the status of outputs
on Output Units after a fatal system error has been generated with FALS(007).
Status of I/O memory
ON
Retained
OFF
OFF
Cleared
OFF
2-395
2 Instructions
The following table shows how to specify error codes and error details in S and S+1.
S
S+1
Error code
Error details
Error name
Memory Error
80F1 hex
80CA hex
80E1 hex
#0A0A hex
Bits 13 to 15: Error Cause
Bits 00 to 12: Details
The channel number of CP1W Expansion I/O Unit is too many.
Bits 13 to 15: 001
Bits 00 to 12: All zeroes
Program Error
80F0 hex
809F hex
#0000 hex
Precaution
When a fatal system error is registered, if the IOM Hold Bit is OFF, I/O memory will be cleared.
2-396
2 Instructions
Sample program
When CIO 0.00 is ON in the following example, FALS(007) will generate a fatal error with FAL number
31 and execute the following processes.
1. The FALS Error Flag (A401.06) will be turned ON.
2. The corresponding error code (C11F) will be written to A400.
3. The error code and the time/date that the error occurred will be written to the Error Log Area (A100
through A199).
4. The ERR Indicator on the CPU Unit will be lit.
5. The ASCII message in D100 to D107 will be displayed at the Peripheral Device.
FALS
FALS
N
31
D100
M: D100
15
4C
4F
D101
57
20
D102
56
4F
D103
4C
54
D104
41
47
D105
45
00
D106
MESSAGE
LOW VOLTAGE
Disregarded
D107
Note A400 will contain the error code of the most serious of all of the errors that have occurred, including non-fatal
and fatal system errors, as well as errors generated by FAL(006) and FAL(007).
FALS
N
10
D200
Matching
values
A529CH
000A
S: D200
#80F1
D201
#0001
2-397
2 Instructions
Other Instructions
STC/CLC
Instruction
Mnemonic
Function
code
Variations
Function
SET CARRY
STC
@STC
040
CLEAR CARRY
CLC
@CLC
041
STC
CLC
Symbol
CLC(041)
STC(040)
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Flags
Data type
Operand
Description
STC
Carry Flag
P_CY
ON
CLC
OFF
Function
STC
When the execution condition is ON, STC(040) turns ON the Carry Flag (CY). Although STC(040) turns
the Carry Flag ON, the flag will be turned ON/OFF by the execution of subsequent instructions which
affect the Carry Flag.
ROL(027) and ROR(028) make use of the Carry Flag in their rotation shift operations.
CLC
When the execution condition is ON, CLC(040) turns OFF the Carry Flag (CY). Although CLC(040)
turns the Carry Flag OFF, the flag will be turned ON/OFF by the execution of subsequent instructions
which affect the Carry Flag.
+C(402), +CL(403), +BC(406), +BCL(407), -C(412), -CL(413), -BC(416), and -BCL(417) make use of
the Carry Flag in their addition operations. Use CLC(041) just before any of these instructions to prevent any influence from other preceding instructions.
ROL(027) and ROR(028) make use of the Carry Flag in their rotation shift operations.
Hint
The +(400), +L(401), +B(404), +BL(405), -(410), -L(411), -B(414), and -BL(415) instructions do no
include the Carry Flag in their addition and subtraction operations. In general, use these instructions
when performing addition or subtraction.
2-398
2 Instructions
WDT
Instruction
Mnemonic
WDT
@WDT
Function
code
Function
094
Extends the maximum cycle time, but only for the cycle
in which the instruction is executed. WDT(094) can be
used to prevent errors for long cycle times when a
longer cycle time is temporarily required for special
processing.
Other Instructions
EXTEND MAXIMUM
CYCLE TIME
Variations
WDT
Symbol
WDT(094)
T
T: Timer setting
WDT
Subroutines
Interrupt tasks
Usage
OK
OK
OK
Operands
Operand
Description
Data type
Size
Timer setting
Constants only
T: Timer setting
Specifies the watchdog timer setting between 0000 and 0064 hexadecimal or between &0000 and
&0100 decimal.
Operand Specifications
Word addresses
Indirect DM addresses
Area
T
CIO
WR
HR
AR
DM
@DM
*DM
---
---
---
---
---
---
---
---
---
Constants
CF
Pulse bits
TR bits
OK
---
---
---
Flags
Operand
Error Flag
Description
P_ER
Data type
ON if the watchdog timer setting exceeds 1 second.
OFF in all other cases.
2-399
2 Instructions
Function
Note
Settings
A Cycle Time Too Long error (fatal error) will be registered if the cycle
time exceeds the maximum setting.
0001 to 0FA0
(10 to 1,000 ms, 10-ms units)
The default value for the maximum cycle time is 1,000 ms, although it can be set anywhere from 10 to 1,000 ms in
10-ms units.
WDT(094) can be used more than once in a cycle. When WDT(094) is executed more than once the cycle time
extensions are added together, although the total must not exceed 1,000 ms. If WDT(094) cannot be executed
again if the cycle has already been extended to 1,000 ms.
Address
Operation
A401.08
ON when the present cycle time exceeds the maximum cycle time (watch cycle time) set in
the PLC Setup. This is a fatal error which causes program execution to stop.
These words contain the maximum cycle time in 32-bit binary. This value is updated every
cycle.
These words contain the present cycle time in 32-bit binary. This value is updated every
cycle.
Function
WDT(094) extends the maximum cycle time for the cycle in which this instruction is executed. The
watchdog timer setting in the PLC Setup is extended by an interval of T 10 ms (0 to 1,000 ms).
When it is likely that the cycle time will increase due to a temporary increase in processing data, this
instruction can be used to prevent a cycle time error.
Sample program
0.00
WDT
&30
0.01
WDT
&500
0.02
WDT
&10
Operation of WDT(094)
In this example, the watchdog timer setting is set to 500ms.
When CIO 0.00 turns ON, the first WDT(094) instruction extends the cycle time by 300 ms (30 10 ms).
Thus, the total cycle time is 800 ms at this point.
When CIO 0.01 turns ON, the second WDT(094) instruction attempts to extend the cycle time by
another 500 ms. Since the total cycle time (1,300 ms) exceeds the upper limit of 1,000 ms, the extra
300 ms is ignored. As a result, the second WDT(094) instruction actually extends the total cycle time
by 200 ms.
When CIO 0.02 turns ON, the third WDT(094) instruction attempts to extend the cycle time by
another 10 ms. Since the total cycle time has already reached the upper limit of 1,000 ms, the third
WDT(094) instruction is not executed.
2-400
3-1 CP1E CPU Unit Instruction Execution Times and Number of Steps . . . . . 3-2
3-1
3-1
Note 1 Most instructions are supported in differentiated form (indicated with , , @, and %).
Specifying differentiation will increase the execution times by the following amounts.
(unit:s)
Symbol
or
+4.0
@ or %
+2.5
2 Use the following time as a guideline when instructions are not executed.
CP1E CPU Unit
CPU
1.4
3-2
LOAD
LOAD NOT
AND
AND NOT
OR
OR NOT
Mnemonic
FUN
No.
Length
(steps)
ON execution
time (s)
Instruction
Conditions
LD
---
1.19
---
!LD
---
10.26
---
LD NOT
---
1.19
---
!LD NOT
---
10.26
---
AND
---
1.19
---
!AND
---
10.26
-----
AND NOT
---
1.19
!AND NOT
---
10.26
---
OR
---
1.29
---
!OR
---
10.36
---
OR NOT
---
1.29
---
!OR NOT
---
10.36
---
AND LOAD
AND LD
---
0.60
---
OR LOAD
OR LD
---
0.60
---
NOT
NOT
520
0.80
---
CONDITION ON
UP
521
4.92
---
CONDITION OFF
DOWN
522
5.69
---
Length
(steps)
ON execution
time (s)
Conditions
OUTPUT NOT
Mnemonic
FUN
No.
OUT
---
1.61
---
!OUT
---
38.06
---
OUT NOT
---
1.61
---
!OUT NOT
---
38.06
---
KEEP
KEEP
011
4.72
---
DIFFERENTIATE UP
DIFU
013
4.12
---
DIFFERENTIATE DOWN
DIFD
014
4.19
---
SET
SET
---
2.69
---
!SET
---
39.12
RESET
RSET
---
2.69
--Word specified
!RSET
---
39.12
SETA
530
17.60
253.5
RSTA
531
17.60
249.5
SETB
532
16.60
54.60
---
16.60
---
54.60
---
!SETB
SINGLE BIT OUTPUT
RSTB
!RSTB
534
---
---
3-3
Mnemonic
FUN
No.
Length
(steps)
ON execution
time (s)
Conditions
END
END
001
4.6
---
NO OPERATION
NOP
000
1.2
---
INTERLOCK
IL
002
4.3
---
INTERLOCK CLEAR
ILC
003
4.3
MULTI-INTERLOCK
MILH
517
19.4
DIFFERENTIATION HOLD
MULTI-INTERLOCK
MILR
518
DIFFERENTIATION RELEASE
MULTI-INTERLOCK CLEAR
MILC
519
--During interlock
19.4
21.5
19.4
During interlock
19.4
21.5
8.9
8.9
Interlock cleared
JUMP
JMP
004
6.1
JUMP END
JME
005
6.2
CONDITIONAL JUMP
CJP
510
10.1
FOR LOOP
FOR
512
9.7
Designating a constant
BREAK LOOP
BREAK
514
4.1
NEXT LOOP
NEXT
513
5.8
5.7
-----
---
Mnemonic
TIM
TIMX
COUNTER
HIGH-SPEED TIMER
ONE-MS TIMER
ACCUMULATIVE TIMER
CNT
Length
(steps)
ON execution
time (s)
---
11.6
550
---
CNTX
546
TIMH
015
TIMHX
551
TMHH
540
TMHHX
552
TTIM
087
TTIMX
LONG TIMER
FUN
No.
TIML
555
542
553
11.5
CNTR
012
CNTRX
548
CNR
545
CNRX
3-4
547
11.6
10.8
-----
22.7
4
3
3
3
---
17.4
When resetting
15.0
When interlocking
22.2
---
17.4
When resetting
15.2
When interlocking
24.3
--When interlocking
24.5
22.2
REVERSIBLE COUNTER
20.4
TIMLX
Conditions
--When interlocking
26.2
---
25.4
---
19.0
659.0
19.0
659.0
Comparison Instructions
Mnemonic
FUN No.
Length
(steps)
ON execution
time (s)
Conditions
9.3
---
10.8
---
LD,AND,OR+=
300
(unsigned)
LD,AND,OR+<>
305
LD,AND,OR+<
310
LD,AND,OR+<=
315
LD,AND,OR+>
320
LD,AND,OR+>=
325
LD,AND,OR+=+L
301
(double, unsigned)
LD,AND,OR+<>+L
306
LD,AND,OR+<+L
311
LD,AND,OR+<=+L
316
LD,AND,OR+>+L
321
LD,AND,OR+>=+L
326
LD,AND,OR+=+S
302
(signed)
LD,AND,OR+<>+S
307
LD,AND,OR+<+S
312
LD,AND,OR+<=+S
317
LD,AND,OR+>+S
322
LD,AND,OR+>=+S
327
LD,AND,OR+=+SL
303
(double, signed)
LD,AND,OR+<>+SL
308
LD,AND,OR+<+SL
313
LD,AND,OR+<=+SL
318
LD,AND,OR+>+SL
323
LD,AND,OR+>=+SL
328
3
4
9.4
---
10.9
---
=DT
341
14.5
---
<>DT
342
14.5
---
<DT
343
14.4
---
<=DT
344
14.4
---
>DT
345
14.6
---
>=DT
346
14.6
---
CMP
020
8.1
---
!CMP
020
49.1
---
DOUBLE COMPARE
CMPL
060
9.5
---
CPS
114
8.1
---
!CPS
114
49.1
---
CPSL
115
9.5
COMPARE
---
TABLE COMPARE
TCMP
085
61.1
---
BCMP
068
107.6
---
ZCP
088
17.8
---
ZCPL
116
20.1
COMPARE
Instruction
---
3-5
Length
(steps)
MOV
021
!MOV
021
DOUBLE MOVE
MOVL
498
MOVE NOT
MVN
022
MOVE BIT
MOVB
MOVE DIGIT
MULTIPLE BIT TRANSFER
Instruction
MOVE
BLOCK TRANSFER
ON execution
time (s)
Conditions
8.0
---
57.7
---
8.9
---
13.7
---
082
21.4
---
MOVD
083
22.4
---
XFRB
062
Mnemonic
XFER
070
26.4
24.2
Transferring 1 word
3747.7
BLOCK SET
BSET
071
Transferring 1 word
137.3
21.3
2074.4
DATA EXCHANGE
XCHG
073
19.2
---
DIST
080
20.8
---
DATA COLLECT
COLL
081
20.6
---
FUN
No.
Length
(steps)
ON execution
time (s)
Conditions
010
Mnemonic
SFT
14.1
1076.0
SFTR
084
WORD SHIFT
WSFT
016
18.0
3784.4
25.8
3783.9
ASL
025
13.0
---
ASR
026
13.0
---
ROTATE LEFT
ROL
027
13.3
---
ROTATE RIGHT
ROR
028
13.5
SLD
074
21.8
SRD
075
3778.3
22.2
3778.6
3-6
Shifting 1 word
--Shifting 1 word
Shifting 1,000 words
Shifting 1 word
Shifting 1,000 words
NASL
580
19.5
-----
NSLL
582
20.8
NASR
581
19.6
---
NSRL
583
21.0
---
Increment/Decrement Instructions
Mnemonic
FUN
No.
Length
(steps)
ON execution
time (s)
Instruction
Conditions
INCREMENT BINARY
++
590
12.3
---
++L
591
13.5
---
DECREMENT BINARY
--
592
12.3
---
--L
593
13.6
---
INCREMENT BCD
++B
594
13.2
---
++BL
595
14.4
---
DECREMENT BCD
--B
596
13.2
---
--BL
597
14.5
---
Mnemonic
FUN
No.
Length
(steps)
ON execution
time (s)
Conditions
---
400
11.5
+L
401
13.0
---
+C
402
11.7
---
+CL
403
13.2
---
+B
404
20.6
---
+BL
405
22.9
---
+BC
406
20.8
---
+BCL
407
23.1
---
410
11.6
---
-L
411
13.2
---
-C
412
11.7
-----
-CL
413
13.3
-B
414
20.3
---
-BL
415
23.6
---
-BC
416
20.5
---
-BCL
417
23.8
---
420
18.4
---
421
23.9
---
BCD MULTIPLY
424
22.0
---
BL
425
33.2
---
430
19.8
---
/L
431
25.8
---
BCD DIVIDE
/B
434
23.2
---
/BL
435
33.0
---
3-7
Conversion Instructions
Instruction
Mnemonic
FUN
No.
Length
(steps)
ON execution
time (s)
Conditions
---
BCD TO BINARY
BIN
023
15.1
BINL
058
16.7
BINARY TO BCD
BCD
024
15.1
DOUBLE BINARY TO
BCDL
059
17.3
2S COMPLEMENT
NEG
160
14.3
DATA DECODER
MLPX
076
-------
DOUBLE BCD
DATA ENCODER
ASCII CONVERT
ASCII TO HEX
DMPX
ASC
HEX
077
086
---
19.6
31.0
79.4
138.2
32.5
63.0
68.0
112.3
22.8
24.7
162
18.4
FUN
No.
Length
(steps)
ON execution
time (s)
Logic Instructions
Instruction
Mnemonic
Conditions
LOGICAL AND
ANDW
034
18.6
---
ANDL
610
20.4
---
LOGICAL OR
ORW
035
18.6
---
DOUBLE LOGICAL OR
ORWL
611
20.4
---
EXCLUSIVE OR
XORW
036
18.6
---
DOUBLE EXCLUSIVE OR
XORL
612
20.4
---
COMPLEMENT
COM
029
12.4
---
DOUBLE COMPLEMENT
COML
614
13.6
---
BIT COUNTER
3-8
Mnemonic
APR
BCNT
FUN
No.
Length
(steps)
069
067
ON execution
time (s)
Conditions
34.2
25.9
19.5
Counting 1 word
FUN
No.
Length
(steps)
ON execution
time (s)
Conditions
FLOATING TO 16-BIT
FIX
450
15.9
---
FLOATING TO 32-BIT
FIXL
451
16.2
---
16-BIT TO FLOATING
FLT
452
16.2
---
32-BIT TO FLOATING
FLTL
453
17.1
---
FLOATING-POINT ADD
+F
454
24.1
---
FLOATING-POINT SUBTRACT
-F
455
25.2
---
FLOATING-POINT DIVIDE
/F
457
25.0
---
FLOATING-POINT MULTIPLY
456
24.4
---
11.6
Instruction
LD,AND,OR+=F
329
LD,AND,OR+<>F
330
---
---
LD,AND,OR+<F
331
---
LD,AND,OR+<=F
332
---
LD,AND,OR+>F
333
---
LD,AND,OR+>=F
334
---
FSTR
448
56.8
---
ASCII TO FLOATING-POINT
FVAL
449
42.9
---
FRAME CHECKSUM
Mnemonic
SWAP
FCS
FUN
No.
Length
(steps)
637
180
ON execution
time (s)
16.8
Conditions
Swapping 1 word
6250.0
24.1
2710.0
TIME-PROPORTIONAL OUTPUT
Mnemonic
PIDAT
TPO
FUN
No.
Length
(steps)
ON execution
time (s)
191
316.0
685
Conditions
Initial execution of PID processing
270.0
228.0
275.5
276.0
5.8
40.8
43.4
ON execution time with manipulated variable designation and output limit enabled
SCALING
SCL
194
24.8
---
SCALING 2
SCL2
486
20.2
---
SCALING 3
SCL3
487
26.4
---
AVERAGE
AVG
195
24.2
Average of an operation
225.5
Average of 64 operations
3-9
Subroutine Instructions
Instruction
Mnemonic
FUN
No.
Length
(steps)
ON execution
time (s)
Conditions
SUBROUTINE CALL
SBS
091
6.6
---
SUBROUTINE ENTRY
SBN
092
2.6
---
SUBROUTINE RETURN
RET
093
3.1
---
FUN
No.
Length
(steps)
ON execution
time (s)
Conditions
15.1
Set
15.1
Reset
Mnemonic
MSKS
690
CLEAR INTERRUPT
CLI
691
14.9
Set
18.0
Reset
DISABLE INTERRUPTS
DI
693
8.5
---
ENABLE INTERRUPTS
EI
694
8.9
---
HIGH-SPEED COUNTER PV
Mnemonic
INI
PRV
FUN
No.
Length
(steps)
ON execution
time (s)
880
46.0
31.8
48.7
35.2
881
READ
SPEED OUTPUT
3-10
CTBL
SPED
882
885
Conditions
27.2
13.0
40.0
35.0
37.2
32.6
24.5
36.5
29.1
69.3
116.3
126.6
46.3
93.3
122.5
69.2
Continuous mode
74.0
Independent mode
SET PULSES
PULS
886
44.1
---
PULSE OUTPUT
PLS2
887
97.6
---
Instruction
Mnemonic
ACCELERATION CONTROL
ACC
ORG
PWM
Length
(steps)
ON execution
time (s)
888
75.6
Continuous mode
82.8
Independent mode
52.2
Origin search
126.8
Origin return
889
891
Conditions
28.9
ORIGIN SEARCH
FUN
No.
---
Step Instructions
Instruction
Mnemonic
FUN
No.
Length
(steps)
ON execution
time (s)
10.5
10.4
Conditions
STEP DEFINE
STEP
008
STEP START
SNXT
009
9.6
---
FUN
No.
Length
(steps)
ON execution
time (s)
Conditions
097
Mnemonic
IORF
170.7
146.6
1725.8
1359.9
7-SEGMENT DECODER
SDEC
078
21.9
MATRIX INPUT
MTR
213
31.6
7SEG
214
31.6
27.1
4 digits
30.8
8 digits
RECEIVE
Mnemonic
TXD
RXD
FUN
No.
Length
(steps)
236
235
ON execution
time (s)
Conditions
25.0
Sending 1 byte
25.0
39.2
Storing 1 byte
256.6
Clock Instructions
Instruction
Mnemonic
FUN
No.
Length
(steps)
ON execution
time (s)
Conditions
CALENDAR ADD
CADD
730
56.6
---
CALENDAR SUBTRACT
CSUB
731
55.1
---
CLOCK ADJUSTMENT
DATE
735
29.9
---
3-11
Mnemonic
FAL
FALS
FUN
No.
Length
(steps)
ON execution
time (s)
006
55.6
Recording errors
79.6
007
Conditions
61.6
60.0
---
---
Other Instructions
Instruction
3-12
Mnemonic
FUN
No.
Length
(steps)
ON execution
time (s)
Conditions
32.6
---
SET CARRY
STC
040
CLEAR CARRY
CLC
041
3.9
---
WDT
094
11.7
---
4-3
4-4
4-5
4-6
4-6
4-1
4-1
4-1-1
The average (mean), maximum, and minimum cycle times will be displayed in order from the top.
Click the Reset Button to recalculate and display the cycle time values.
Additional Information
The cycle time present value and maximum value are stored in the following Auxiliary Area
words.
Cycle time present value (0.1-ms increments): A264 (lower bytes) and A265 (upper bytes)
Maximum Cycle Time (0.1-ms increments): A262 (lower bytes) and A263 (upper bytes)
4-2
4-2
4-2-1
The CPU Unit processes data in repeating cycles from the overseeing processing up to peripheral
servicing as shown in the following diagram.
Startup initialization
Power ON
Overseeing processing
Error
Check OK?
Normal
Peripheral servicing
I/O refresh
I/O refresh
Peripheral
servicing
YES
Waits until the set cycle time
has elapsed (when the
minimum cycle time is valid)
ERR/ALM
indicator ON or
flashing?
Program execution
4-3
4-2-2
The cycle time is the total time required for the PLC to perform the operations given in the following
tables.
Cycle time = (1) + (2) + (3) + (4) + (5)
(1) Overseeing
Processing time and
fluctuation cause
Operation
Checks the I/O bus and user memory, checks for battery errors,
etc.
0.4 ms min.
Operation
Executes the instructions in the user program. The time
required is the total of the executions times for all instructions.
When a minimum cycle time is not set, the time for step 3 is
approximately 0.
When a minimum cycle time is set, the time for step 3 is the
preset fixed cycle time minus the actual cycle time
((1) + (2) + (4) + (5)).
Operation
CPU Unit built-in I/O, CPU
Unit built-in analog I/O (NAtype only), CP-series Expansion Units and Expansion I/O
Units
4-4
4-2-3
Unit name
20-point I/O + Analog I/O
CPU Unit
Model numbers
CP1E-NA20D-
Note No matter whether use analog I/O function or not, the I/O refresh time is the same.
(Built-in RS-232C
port, serial option
board)
I/O Refresh Times for CP-series Expansion Units and Expansion I/O Units
Unit name
8-point Input Unit
8-point Output Unit
Expansion Unit
Model numbers
CP1W-8ED
CP1W-8ER
CP1W-8ET
CP1W-8ET1
CP1W-16ER
CP1W-16ET
CP1W-16ET1
CP1W-20EDR1
CP1W-20EDT
CP1W-20EDT1
CP1W-32ER
CP1W-32ET
CP1W-32ET1
CP1W-40EDR
CP1W-40EDT
CP1W-40EDT1
CP1W-AD041
CP1W-DA021
CP1W-DA041
CP1W-MAD11
CP1W-TS001
CP1W-TS002
CP1W-TS101
CP1W-TS102
CP1W-SRT21
0.17 ms
0.20 ms
0.33 ms
0.45 ms
0.72 ms
0.33 ms
0.36 ms
0.30 ms
0.57 ms
0.30 ms
0.57 ms
0.20 ms
Additional Information
The I/O refresh time for the built-in I/O of the CPU Unit is included in overseeing processing.
4-5
4-2-4
Conditions
Item
Description
1 Unit
CP1W-40EDR
Ladder diagram
5K steps
Yes or no
None
None
None
Calculation Example
Processing time
Process name
Equation
Peripheral USB
port connected
Peripheral USB
port not
connected
0.4 ms
0.4 ms
7.0 ms
7.0 ms
(1)Overseeing
(2)Program execution
4-2-5
1.19s2,500+1.61s2,500
0 ms
0 ms
(4)I/O refreshing
0.45 ms
0.45 ms
0.45 ms
(5)Peripheral servicing
0.2 ms
0 ms
Cycle time
(1)+(2)+(3)+(4)+(5)
8.15 ms
7.85 ms
When editing online, the cycle time will be extended and the schedule task execution may be delayed or
become abnormal according to the editing that is performed.
4-6
pp
Appendices
A-1
App
Appendices
Instruction
ACCELERATION
CONTROL
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
888
@ACC
---
---
Mnemonic
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Page
Page
AND<F
AND
331
FLOATING
LESS THAN
---
---
---
2-241
AND<L
311
---
---
---
2-88
AND<S
AND
312
SIGNED
LESS THAN
---
---
---
2-88
AND<
SL
AND DOU313
BLE
SIGNED
LESS THAN
---
---
---
2-88
AND=
AND
EQUAL
300
---
---
---
2-88
AND=
DT
AND TIME
EQUAL
341
---
---
---
2-91
AND=F
AND
FLOATING
EQUAL
329
---
---
---
2-241
AND=L
301
---
---
---
2-88
2-331
AND
AND
---
@AND
%AND
!AND
2-9
AND
LD
AND LOAD
---
---
---
---
2-13
AND
NOT
AND NOT
---
---
---
!AND
NOT
2-9
AND<
AND LESS
THAN
310
---
---
---
2-88
AND<=
AND LESS
THAN OR
EQUAL
315
---
---
---
2-88
AND<=F AND
FLOATING
LESS THAN
OR EQUAL
332
---
---
---
2-241
AND<=
DT
AND TIME
LESS THAN
OR EQUAL
344
AND<=L
316
---
---
---
2-88
AND=S
AND
SIGNED
EQUAL
302
---
---
---
2-88
---
---
2-88
---
---
---
2-88
AND DOUBLE
SIGNED
EQUAL
---
317
AND=
SL
303
AND<=S AND
SIGNED
LESS THAN
OR EQUAL
AND>
---
---
---
2-88
AND DOUBLE
SIGNED
LESS THAN
OR EQUAL
318
---
---
---
2-88
AND
GREATER
THAN
320
AND<=
SL
AND>=
325
---
---
---
2-88
AND<>
AND NOT
EQUAL
305
---
---
---
2-88
AND
GREATER
THAN OR
EQUAL
---
---
2-91
342
---
---
---
2-91
AND TIME
GREATER
THAN OR
EQUAL
---
AND TIME
NOT
EQUAL
AND>=
DT
346
AND<>
DT
AND<>F AND
FLOATING
NOT
EQUAL
330
---
---
---
2-241
334
---
---
---
2-241
AND<>L
306
---
---
---
2-88
AND>=F AND
FLOATING
GREATER
THAN OR
EQUAL
AND>=L
AND DOUBLE
GREATER
THAN OR
EQUAL
326
---
---
---
2-88
AND>=S AND
SIGNED
GREATER
THAN OR
EQUAL
327
---
---
---
2-88
---
---
---
2-91
AND<>S AND
SIGNED
NOT
EQUAL
307
---
---
---
2-88
AND<>
SL
AND DOUBLE
SIGNED
NOT
EQUAL
308
---
---
---
2-88
AND<
DT
AND TIME
343
LESS THAN
---
---
---
2-91
A-2
Appendices
Mnemonic
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Page
328
---
---
---
2-88
AND>
DT
AND TIME
GREATER
THAN
345
---
---
---
2-91
AND>F
AND
FLOATING
GREATER
THAN
333
AND DOUBLE
GREATER
THAN
321
AND
SIGNED
GREATER
THAN
322
AND DOUBLE
SIGNED
GREATER
THAN
323
DOUBLE
LOGICAL
AND
610
ANDW
LOGICAL
AND
034
@ANDW
---
---
APR
ARITHMETIC
PROCESS
069
@APR
---
ASC
ASCII CONVERT
086
@ASC
ASL
ARITH025
METIC
SHIFT LEFT
@ASL
ARITHMETIC
SHIFT
RIGHT
026
@ASR
AVERAGE
195
AND>L
AND>S
AND>
SL
ANDL
ASR
AVG
---
---
---
Instruction
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Page
BINL
DOUBLE
BCD TO
DOUBLE
BINARY
058
@BINL
---
---
2-185
BREAK
BREAK
LOOP
514
---
---
---
2-59
BSET
@BSET
---
---
2-119
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
2-241
C
---
---
---
2-88
Mnemonic
---
---
@ANDL
---
Instruction
Page
CADD
CALENDAR ADD
730
@CADD
---
---
2-380
CJP
CONDITIONAL
JUMP
510
---
---
---
2-53
CLC
CLEAR
CARRY
041
@CLC
---
---
2-398
CLI
CLEAR
INTERRUPT
691
@CLI
---
---
2-303
CMP
COMPARE
020
---
---
!CMP
2-95
2-210
CMPL
DOUBLE
COMPARE
060
---
---
---
2-95
---
2-218
CNR
RESET
545
TIMER/COU
NTER
@CNR
---
---
2-86
---
---
2-201
CNRX
RESET
547
TIMER/COU
NTER
@CNRX
---
---
2-86
---
---
2-133
CNT
COUNTER
---
---
---
---
2-80
CNTR
REVERSIBLE
COUNTER
012
---
---
---
2-83
CNTRX
REVERSIBLE
COUNTER
548
---
---
---
2-83
CNTX
COUNTER
546
---
---
---
2-80
COLL
DATA COLLECT
081
@COLL
---
---
2-125
COM
COMPLEMENT
029
@COM
---
---
2-216
COML
DOUBLE
COMPLEMENT
614
@COML
---
---
2-216
CPS
SIGNED
BINARY
COMPARE
114
---
---
!CPS
2-98
CPSL
DOUBLE
SIGNED
BINARYCOMPARE
115
---
---
---
2-98
CSUB
CALENDAR SUBTRACT
731
@CSUB
---
---
2-380
CTBL
REGISTERCOMPARISON TABLE
882
@CTBL
---
---
2-315
---
---
---
---
---
---
---
---
---
---
2-88
2-88
2-210
2-134
2-287
B
Mnemonic
FUN
No.
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Page
BCD
BINARY TO
BCD
024
@BCD
---
---
2-187
BCDL
DOUBLE
BINARY TO
DOUBLE
BCD
059
@BCDL
---
---
2-187
BCMP
BLOCK
COMPARE
068
@BCMP
---
---
2-103
BCNT
BIT
COUNTER
067
@BCNT
---
---
2-227
BIN
BCD TO
BINARY
023
@BIN
---
---
2-185
A-3
App
AND DBL
SIGNED
GREATER
THAN OR
EQUAL
Instruction
AND>=
SL
Mnemonic
Appendices
D
Mnemonic
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Mnemonic
CLOCK
ADJUSTMENT
735
@DATE
---
---
2-385
DI
DISABLE
INTERRUPTS
693
@DI
---
---
2-306
DIFD
DIFFERENTIATE
DOWN
014
---
---
!DIFD
2-27
DIFU
DIFFERENTIATE UP
013
---
---
!DIFU
2-25
SINGLE
WORD DISTRIBUTE
080
@DIST
---
---
2-123
DMPX
DATA
ENCODER
077
@DMPX
---
---
2-196
DOWN
CONDITION OFF
522
---
---
---
2-17
DSW
DIGITAL
SWITCH
INPUT
210
---
---
---
2-357
END
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
ENABLE
INTERRUPTS
694
---
---
---
END
001
---
512
---
---
---
2-56
448
@FSTR
---
---
2-244
FVAL
ASCII TO
FLOATINGPOINT
449
@FVAL
---
---
2-249
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
162
@HEX
---
---
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Mnemonic
HEX
Instruction
ASCII TO
HEX
Page
2-205
I
Instruction
Page
INI
MODE
CONTROL
880
@INI
---
---
2-308
IORF
I/O
REFRESH
097
@IORF
---
---
2-352
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
2-307
J
---
---
---
2-38
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Instruction
Page
JME
JUMP END
005
---
---
---
2-53
JMP
JUMP
004
---
---
---
2-53
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
KEEP
011
---
---
!KEEP
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
LD
LOAD
---
@LD
%LD
!LD
2-7
LD=DT
LOAD DATE
EQUAL
341
---
---
---
2-91
LD =S
LOAD
SIGNED
EQUAL
302
---
---
---
2-88
Page
FAL
FAILURE
ALARM
006
@FAL
---
---
2-387
FALS
SEVERE
FAILURE
ALARM
007
---
---
---
2-393
FCS
FRAME
CHECKSUM
180
@FCS
---
---
2-255
KEEP
FIX
FLOATING
TO 16-BIT
450
@FIX
---
---
2-233
FIXL
FLOATING
TO 32-BIT
451
@FIXL
---
---
2-233
FLT
16-BIT TO
FLOATING
452
@FLT
---
---
2-235
FLTL
32-BIT TO
FLOATING
453
@FLTL
---
---
2-235
A-4
Page
FLOATINGPOINT TO
ASCII
Page
F
Instruction
Immediate
refreshing
specification
FSTR
Mnemonic
Mnemonic
Downward
differentiation
FOR
Mnemonic
EI
Upward
differentiation
DIST
Instruction
FUN
No.
Page
DATE
Mnemonic
Instruction
Mnemonic
Mnemonic
Page
2-21
Page
Appendices
Mnemonic
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Page
---
---
---
!LD NOT
2-7
LOAD LESS
THAN
310
---
---
---
2-88
LD<=
LOAD LESS
THAN OR
EQUAL
315
---
---
---
2-88
LD<=
DT
LOAD DATE
LESS THAN
OR EQUAL
344
---
---
---
2-91
LD<=F
LOAD
FLOATING
LESS THAN
OR EQUAL
332
---
---
---
2-241
LD<=L
---
---
---
2-88
LD<=S
LOAD
SIGNED
LESS THAN
OR EQUAL
317
---
---
---
2-88
LD<=
SL
---
---
---
2-88
LD<>
LOAD NOT
EQUAL
305
---
---
---
2-88
LD<>
DT
LOAD DATE
NOT
EQUAL
342
---
---
---
2-91
LD<>F
LOAD
FLOATING
NOT
EQUAL
330
---
---
---
2-241
LD<>L
---
---
---
2-88
LD<>S
LOAD
SIGNED
NOT
EQUAL
---
---
---
2-88
307
LD<>
SL
---
---
---
2-88
LD<DT
LOAD DT
343
LESS THAN
---
---
---
2-91
LD<F
LOAD
331
FLOATING
LESS THAN
---
---
---
2-241
LD<L
---
---
---
2-88
LD<S
LOAD
312
SIGNED
LESS THAN
---
---
---
2-88
LD<SL
---
---
---
2-88
LD=
LOAD
EQUAL
---
---
---
2-88
300
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Page
LD=F
LOAD
FLOATING
EQUAL
329
---
---
---
2-241
LD=L
---
---
---
2-88
LD=SL
---
---
---
2-88
LD>
LOAD
GREATER
THAN
320
---
---
---
2-88
LD>=
LOAD
GREATER
THAN OR
EQUAL
325
---
---
---
2-88
LD>=
DT
LOAD DATE
GREATER
THAN OR
EQUAL
346
---
---
---
2-91
LD>=F
LOAD
FLOATING
GREATER
THAN OR
EQUAL
334
---
---
---
2-241
LD>=L
---
---
---
2-88
LD>=S
LOAD
SIGNED
GREATER
THAN OR
EQUAL
327
---
---
---
2-88
LD>=
SL
LOAD DBL
SIGNED
GREATER
THAN OR
EQUAL
328
---
---
---
2-88
LD>DT
LOAD DATE
GREATER
THAN
345
---
---
---
2-91
LD>F
LOAD
FLOATING
GREATER
THAN
333
---
---
---
2-241
LD>L
---
---
---
2-88
LD>S
LOAD
SIGNED
GREATER
THAN
322
---
---
---
2-88
LD>SL
---
---
---
2-88
A-5
App
LOAD NOT
Instruction
LD NOT
LD<
Mnemonic
Appendices
O
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
MULTIINTERLOCK
CLEAR
519
---
---
---
MULTIINTERLOCK DIFFERENTIAT
IONHOLD
517
MULTIINTERLOCK DIFFERENTIAT
IONRELEASE
518
MLPX
DATA
DECODER
076
@MLPX
---
---
2-191
MOV
MOVE
021
@MOV
---
!MOV
2-108
MOVB
MOVE BIT
082
@MOVB
---
---
2-111
MOVD
MOVE
DIGIT
083
@MOVD
---
---
2-113
MOVL
DOUBLE
MOVE
498
@MOVL
---
---
2-108
Mnemonic
MILC
MILH
MILR
Instruction
---
---
---
---
---
---
Page
2-44
2-44
2-44
MSKS
@MSKS
---
---
2-300
MTR
MATRIX
INPUT
213
---
---
---
2-361
MVN
MOVE NOT
022
@MVN
---
---
2-108
N
Mnemonic
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
580
@NASL
---
---
2-141
NASR
SHIFT N581
BITS RIGHT
@NASR
---
---
2-144
NEG
2'S COMPLEMENT
160
@NEG
---
---
2-189
NEXT
---
513
---
---
---
2-56
NOP
NO OPERA- 000
TION
---
---
---
2-39
NOT
NOT
520
---
---
---
2-16
NSLL
DOUBLE
SHIFT NBITS LEFT
582
@NSLL
---
---
2-141
DOUBLE
SHIFT NBITSRIGHT
583
A-6
@NSRL
---
---
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Instruction
FUN
No.
OR
OR
---
@OR
%OR
!OR
2-11
ORG
ORIGIN
SEARCH
889
@ORG
---
---
2-336
Page
OR LD
OR LOAD
---
---
---
---
2-13
OR NOT
OR NOT
---
---
---
!OR NOT
2-11
OR<
OR LESS
THAN
310
---
---
---
2-88
OR<=
OR LESS
THAN OR
EQUAL
315
---
---
---
2-88
OR<=
DT
OR DATE
LESS THAN
OR EQUAL
344
---
---
---
2-91
OR<=F
OR
FLOATING
LESS THAN
OR EQUAL
332
---
---
---
2-241
OR<=L
OR
DOUBLE
LESS THAN
OR EQUAL
316
---
---
---
2-88
OR<=S
OR SIGNED
LESS THAN
OR EQUAL
317
---
---
---
2-88
OR<=
SL
OR
DOUBLE
SIGNED
LESS THAN
OR EQUAL
318
---
---
---
2-88
OR<>
OR NOT
EQUAL
305
---
---
---
2-88
OR<>
DT
OR DATE
NOT EQUA
342
---
---
---
2-91
OR<>F
OR FLOATING NOT
EQUAL
330
---
---
---
2-241
OR<>L
OR
DOUBLE
NOT
EQUAL
306
---
---
---
2-88
OR<>S
OR SIGNED
NOT
EQUAL
307
---
---
---
2-88
OR<>
SL
OR
DOUBLE
SIGNED
NOT
EQUAL
308
---
---
---
2-88
OR<DT
OR DATE
343
LESS THAN
---
---
---
2-91
OR<F
OR
331
FLOATING
LESS THAN
---
---
---
2-241
OR<L
OR
311
DOUBLE
LESS THAN
---
---
---
2-88
OR<S
OR SIGNED 312
LESS THAN
---
---
---
2-88
OR<SL
OR
313
DOUBLE
SIGNED
LESS THAN
---
---
---
2-88
Page
NASL
NSRL
Mnemonic
2-144
Appendices
Immediate
refreshing
specification
Upward
differentiation
Downward
differentiation
OR=
OR EQUAL
300
---
---
---
2-88
OR=DT
OR DATE
EQUAL
341
---
---
---
2-91
OR=F
OR
FLOATING
EQUAL
329
---
---
---
2-241
OR=L
OR
DOUBLE
EQUAL
301
---
---
---
2-88
OR=S
OR SIGNED
EQUAL
302
---
---
---
2-88
OR=SL
OR DOUBLE
SIGNED
EQUAL
303
---
---
---
2-88
OR>
OR
GREATER
THAN
320
---
---
---
2-88
OR>=
OR
GREATER
THAN OR
EQUAL
325
---
---
---
2-88
OR DATE
GREATER
THAN OR
EQUAL
346
OR>=F
OR
FLOATING
GREATER
THAN OR
EQUAL
334
---
---
---
2-241
OR>=L
OR
DOUBLE
GREATER
THAN OR
EQUAL
326
---
---
---
2-88
OR>=S
OR SIGNED
GREATER
THAN OR
EQUAL
327
---
---
---
2-88
OR>=
SL
OR DBL
SIGNED
GREATER
THAN OR
EQUAL
328
---
---
---
2-88
OR DATE
GREATER
THAN
345
OR>=
DT
OR>DT
OR>F
---
---
---
Page
Mnemonic
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Page
ORWL
DOUBLE
LOGICAL
OR
611
@ORWL
---
---
2-212
OUT
OUTPUT
---
---
---
!OUT
2-18
OUT
NOT
OUTPUT
NOT
---
---
---
!OUT
NOT
2-18
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
P
Mnemonic
Instruction
Page
PIDAT
PID CON191
TROL
WITHAUTOTUNING
---
---
---
2-257
PLS2
PULSE
OUTPUT
887
@PLS2
---
---
2-325
PRV
HIGHSPEEDCOUNTER
PV READ
881
@PRV
---
---
2-311
PULS
SET
PULSES
886
@PULS
---
---
2-323
PWM
PULSE
WITH VARIABLEDUTY
FACTOR
891
@PWM
---
---
2-339
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
2-91
---
---
---
333
OR>L
OR
DOUBLE
GREATER
THAN
321
---
---
---
2-88
OR>S
OR SIGNED
GREATER
THAN
322
---
---
---
2-88
OR>SL
OR
DOUBLE
SIGNED
GREATER
THAN
323
---
---
---
2-88
ORW
LOGICAL
OR
035
@ORW
---
---
2-212
---
---
2-241
Instruction
Page
RET
SUBROUTINE
RETURN
093
---
---
---
2-295
ROL
ROTATE
LEFT
027
@ROL
---
---
2-135
ROR
ROTATE
RIGHT
028
@ROR
---
---
2-137
RSET
RESET
---
@RSET
%RSET
!RSET
2-29
RSTA
MULTIPLE
BIT RESET
531
@RSTA
---
---
2-31
RSTB
SINGLE BIT
RESET
533
@RSTB
---
!RSTB
2-33
RXD
RECEIVE
235
@RXD
---
---
2-374
2-91
OR FLOATING
GREATER
THAN
---
Mnemonic
A-7
App
FUN
No.
Instruction
Mnemonic
Appendices
S
Mnemonic
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Mnemonic
SUBROUTINE
ENTRY
092
---
---
---
2-295
SBS
SUBROUTINE CALL
091
@SBS
---
---
2-290
SCL
SCALING
194
@SCL
---
---
2-276
SCL2
SCALING 2
486
@SCL2
---
---
2-280
SCL3
SCALING 3
487
@SCL3
---
---
2-284
SDEC
7-SEGMENT
DECODER
078
@SDEC
---
---
2-354
SET
SET
---
@SET
%SET
!SET
2-29
SETA
MULTIPLE
BIT SET
530
@SETA
---
---
2-31
SETB
SINGLE BIT
SET
532
@SETB
---
!SETB
2-33
SFT
SHIFT
REGISTER
010
---
---
---
2-127
SFTR
REVERSIBLE SHIFT
REGISTER
084
@SFTR
---
---
2-129
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
@SLD
---
---
2-139
SNXT
STEP
START
009
---
---
---
2-342
SPED
SPEED
OUTPUT
885
@SPED
---
---
2-319
SRD
ONE DIGIT
SHIFT
RIGHT
075
@SRD
---
---
2-139
STC
SET
CARRY
040
@STC
---
---
2-398
STEP
STEP
DEFINE
008
---
---
---
2-342
SWAP
SWAP
BYTES
637
@SWAP
---
---
2-253
Page
TMHHX
ONE-MS
TIMER
552
---
---
---
2-72
TPO
TIME-PROPORTIONALOUTPUT
685
---
---
---
2-269
TR
TR Bits
---
---
---
---
2-20
TTIM
ACCUMULATIVE
TIMER
087
---
---
---
2-74
TTIMX
ACCUMULATIVE
TIMER
555
---
---
---
2-74
TXD
TRANSMIT
236
@TXD
---
---
2-369
Instruction
FUN
No.
Upward
differentiation
Downward differentiatio
n
Immediate
refreshing
specification
521
---
---
---
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
U
Mnemonic
UP
SLD
CONDITION ON
Page
2-17
W
Mnemonic
Instruction
Page
WDT
EXTEND
MAXIMUMCYCLE
TIME
094
@WDT
---
---
2-399
WSFT
WORD
SHIFT
016
@WSFT
---
---
2-131
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
T
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Mnemonic
Instruction
Page
TCMP
TABLE
COMPARE
085
@TCMP
---
---
2-101
TIM
HUNDREDMS TIMER
---
---
---
---
2-66
TIMH
TEN-MS
TIMER
015
---
---
---
2-69
TIMHX
TEN-MS
TIMER
551
---
---
---
2-69
TIML
LONG
TIMER
542
---
---
---
2-77
TIMLX
LONG
TIMER
553
---
---
---
2-77
TIMX
HUNDREDMS TIMER
550
---
---
---
2-66
TMHH
ONE-MS
TIMER
540
---
---
---
2-72
A-8
FUN
No.
Page
SBN
Mnemonic
Instruction
Page
XCHG
DATA
073
EXCHANGE
@XCHG
---
---
2-121
XFER
BLOCK
TRANSFER
070
@XFER
---
---
2-117
XFRB
MULTIPLE
062
BIT TRANSFER
@XFRB
---
---
2-115
XORL
DOUBLE
EXCLUSIVE OR
612
@XORL
---
---
2-214
XORW
EXCLUSIVE OR
036
@XORW
---
---
2-214
Appendices
Z
Mnemonic
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
Mnemonic
088
---
---
---
2-105
ZCPL
DOUBLE
AREA
RANGECOMPARE
116
---
---
---
2-105
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
7-SEGMENT DISPLAY
OUTPU
214
---
---
---
SIGNED
BINARY
ADDWITHOUT
CARRY
400
@+
---
---
2-158
++
INCREMENT
BINARY
590
@++
---
---
2-147
++B
INCREMENT BCD
594
@++B
---
---
2-153
++BL
DOUBLE
INCREMENT BCD
595
@++BL
---
---
2-153
++L
DOUBLE
INCREMENTBINARY
591
@++L
---
---
2-147
+B
BCD ADD
WITHOUT
CARRY
404
@+B
---
---
2-162
+BC
BCD ADD
WITH
CARRY
406
@+BC
---
---
2-164
+BCL
DOUBLE
BCD ADD
WITHCARRY
407
@+BCL
---
---
2-164
+BL
DOUBLE
BCD ADD
WITHOUTCARRY
405
@+BL
---
---
2-162
+C
SIGNED
BINARY
ADD WITHCARRY
402
@+C
---
---
2-160
+CL
DOUBLE
SIGNED
BINARYADD WITH
CARRY
403
@+CL
---
---
2-160
FLOATINGPOINT ADD
454
@+F
---
---
Immediate
refreshing
specification
Page
DOUBLE
SIGNED
BINARYADD WITHOUT
CARRY
401
@+L
---
---
2-158
SIGNED
BINARY
SUBTRACTWIT
HOUT
CARRY
410
@-
---
---
2-166
--
DECREMENT
BINARY
592
@--
---
---
2-150
--B
DECREMENT BCD
596
@--B
---
---
2-156
--BL
DOUBLE
DECREMENT BCD
597
@--BL
---
---
2-156
--L
DECREMENT
BINARY
593
@--L
---
---
2-150
-B
BCD SUBTRACT
WITHOUTCARRY
414
@-B
---
---
2-172
-BC
BCD SUBTRACT
WITHCARRY
416
@-BC
---
---
2-175
-BCL
DOUBLE
BCD SUBTRACTWIT
H CARRY
417
@-BCL
---
---
2-175
-BL
DOUBLE
BCD SUBTRACTWIT
HOUT
CARRY
415
@-BL
---
---
2-172
-C
SIGNED
BINARY
SUBTRACTWIT
H CARRY
412
@-C
---
---
2-170
-CL
DOUBLE
SIGNED
BINARYSUBTRACT
WITH
CARRY
413
@-CL
---
---
2-170
-F
FLOATINGPOINT
SUBTRACT
455
@-F
---
---
2-237
-L
DOUBLE
SIGNED
BINARYSUBTRACT
WITHOUTCARRY
411
@-L
---
---
2-166
SIGNED
BINARY
MULTIPLY
420
@*
---
---
2-177
*B
@*B
---
---
2-179
Page
2-365
2-237
A-9
App
FUN
No.
+F
Downward
differentiation
+L
Symbol
7SEG
Upward
differentiation
AREA
RANGE
COMPARE
Instruction
FUN
No.
Page
ZCP
Mnemonic
Instruction
Appendices
Instruction
FUN
No.
Upward
differentiation
Downward
differentiation
Immediate
refreshing
specification
*BL
DOUBLE
425
BCD MULTIPLY
@*BL
---
---
2-179
*F
FLOATINGPOINT
MULTIPLY
456
@*F
---
---
2-237
*L
DOUBLE
SIGNED
BINARYMULTIPLY
421
@*L
---
---
2-177
SIGNED
BINARY
DIVIDE
430
@/
---
---
2-181
/B
BCD
DIVIDE
434
@/B
---
---
2-183
/BL
DOUBLE
BCD
DIVIDE
435
@/BL
---
---
2-183
/F
FLOATINGPOINT
DIVIDE
457
@/F
---
---
2-237
/L
DOUBLE
SIGNED
BINARYDIVIDE
431
@/L
---
---
2-181
A-10
Mnemonic
Revision History
A manual revision code appears as a suffix to the catalog number on the front cover of the manual.
Revision code
Revision code
01
02
03
04
Date
March 2009
June 2009
January 2010
June 2010
Revised content
Original production
Errors were corrected.
Information added on E10/14, N14/60 and NA20 CPU Units.
CP1W-DA021 added for CP-series Expansion Units.
Revision-1
Revision-2
OMRON Corporation
Authorized Distributor:
Tokyo, JAPAN
Contact: www.ia.omron.com
Regional Headquarters
OMRON EUROPE B.V.
Wegalaan 67-69-2132 JD Hoofddorp
The Netherlands
Tel: (31)2356-81-300/Fax: (31)2356-81-388
0610