Cj1m Programming Manual
Cj1m Programming Manual
W394-E1-03
PROGRAMMING MANUAL
6<60$&&6&-6HULHV
&6*+&38@@(9
&6*+&38@@+
&-*&38@@
&-*+&38@@+
&-0&38@@
3URJUDPPDEOH&RQWUROOHUV
3URJUDPPLQJ0DQXDO
5HYLVHG-XO\
iv
1RWLFH
OMRON products are manufactured for use according to proper procedures by a qualified operator
and only for the purposes described in this manual.
The following conventions are used to indicate and classify precautions in this manual. Always heed
the information provided with them. Failure to heed precautions can result in injury to people or dam-
age to property.
!DANGER Indicates an imminently hazardous situation which, if not avoided, will result in death or
serious injury.
!WARNING Indicates a potentially hazardous situation which, if not avoided, could result in death or
serious injury.
!Caution Indicates a potentially hazardous situation which, if not avoided, may result in minor or
moderate injury, or property damage.
205213URGXFW5HIHUHQFHV
All OMRON products are capitalized in this manual. The word Unit is also capitalized when it refers to
an OMRON product, regardless of whether or not it appears in the proper name of the product.
The abbreviation Ch, which appears in some displays and on some OMRON products, often means
word and is abbreviated Wd in documentation in this sense.
The abbreviation PLC means Programmable Controller. PC is used, however, in some Program-
ming Device displays to mean Programmable Controller.
9LVXDO$LGV
The following headings appear in the left column of the manual to help you locate different types of
information.
Note Indicates information of particular interest for efficient and convenient opera-
tion of the product.
1,2,3... ,QGLFDWHVOLVWVRIRQHVRUWRUDQRWKHUVXFKDVSURFHGXUHVFKHFNOLVWVHWF
OMRON, 2001
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 con-
stantly 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.
v
vi
TABLE OF CONTENTS
PRECAUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
1 Intended Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
2 General Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
3 Safety Precautions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
4 Operating Environment Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
5 Application Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
6 Conformance to EC Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
SECTION 1
CPU Unit Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1-1 Initial Setup (CS1 CPU Units Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1-2 Using the Internal Clock (CS1 CPU Units Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1-3 Internal Structure of the CPU Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1-4 Operating Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1-5 Programs and Tasks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1-6 Description of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
SECTION 2
Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2-1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2-2 Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
2-3 Checking Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
SECTION 3
Instruction Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3-1 Sequence Input Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3-2 Sequence Output Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3-3 Sequence Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
3-4 Timer and Counter Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
3-5 Comparison Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3-6 Data Movement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3-7 Data Shift Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3-8 Increment/Decrement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
3-9 Symbol Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3-10 Conversion Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3-11 Logic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3-12 Special Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3-13 Floating-point Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3-14 Double-precision Floating-point Instructions (CS1-H, CJ1-H, or CJ1M Only). . . . . . . . . . 112
3-15 Table Data Processing Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
3-16 Data Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
3-17 Subroutine Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
3-18 Interrupt Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
3-19 High-speed Counter and Pulse Output Instructions (CJ1M-CPU22/23 Only) . . . . . . . . . . . 127
3-20 Step Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
3-21 Basic I/O Unit Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
3-22 Serial Communications Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
3-23 Network Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
3-24 File Memory Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
3-25 Display Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
vii
TABLE OF CONTENTS
3-26 Clock Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
3-27 Debugging Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
3-28 Failure Diagnosis Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
3-29 Other Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
3-30 Block Programming Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
3-31 Text String Processing Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
3-32 Task Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
SECTION 4
Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
4-1 Task Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
4-2 Using Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
4-3 Interrupt Tasks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
4-4 Programming Device Operations for Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
SECTION 5
File Memory Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
5-1 File Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5-2 Manipulating Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
5-3 Using File Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
SECTION 6
Advanced Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
6-1 Cycle Time/High-speed Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
6-2 Index Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
6-3 Serial Communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
6-4 Changing the Timer/Counter PV Refresh Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
6-5 Using a Scheduled Interrupt as a High-precision Timer (CJ1M Only). . . . . . . . . . . . . . . . . 284
6-6 Startup Settings and Maintenance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
6-7 Diagnostic Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
6-8 CPU Processing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
6-9 Peripheral Servicing Priority Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
6-10 Battery-free Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
6-11 Other Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
SECTION 7
Program Transfer, Trial Operation, and Debugging . . . . . 317
7-1 Program Transfer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
7-2 Trial Operation and Debugging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Appendices
A PLC Comparison Charts: CJ-series, CS-series, C200HG/HE/HX,
CQM1H, CVM1, and CV-series PLCs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
B Changes from Previous Host Link Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
viii
$ERXWWKLV0DQXDO
This manual describes the programming of the CS1G/H-CPU@@-EV1 and CJ1G/H/M-CPU@@ CPU
Units for CS/CJ-series Programmable Controllers (PLCs) and includes the sections described on the
following page. The CS Series and CJ Series are subdivided as shown in the following table.
Unit CS Series CJ Series
CPU Units CS1-H CPU Units: CS1H-CPU@@H CJ1-H CPU Units: CJ1H-CPU@@H
CS1G-CPU@@H CJ1G-CPU@@H
CS1 CPU Units: CS1H-CPU@@-EV1 CJ1 CPU Units: CJ1G-CPU@@-EV1
CS1G-CPU@@-EV1 CJ1M CPU Units: CJ1M-CPU@@
Basic I/O Units CS-series Basic I/O Units CJ-series Basic I/O Units
Special I/O Units CS-series Special I/O Units CJ-series Special I/O Units
CPU Bus Units CS-series CPU Bus Units CJ-series CPU Bus Units
Power Supply Units CS-series Power Supply Units CJ-series Power Supply Units
Please read this manual and all related manuals listed in the table on the next page and be sure you
understand information provided before attempting to install or use CS1G/H-CPU@@-EV1 or CJ1G/H/
M-CPU@@ CPU Units in a PLC System.
This manual contains the following sections.
Section 1 describes the basic structure and operation of the CPU Unit.
Section 2 describes basic information required to write, check, and input programs.
Section 3 outlines the instructions that can be used to write user programs.
Section 4 describes the operation of tasks.
Section 5 describes the functions used to manipulate file memory.
Section 6 provides details on advanced functions: Cycle time/high-speed processing, index registers,
serial communications, startup and maintenance, diagnostic and debugging, Programming Devices,
and CJ Basic I/O Unit input response time settings.
Section 7 describes the processes used to transfer the program to the CPU Unit and the functions that
can be used to test and debug the program.
The Appendices provide a comparison of CS/CJ-series, restrictions in using C200H Special I/O Units,
and changes made to Host Link Systems.
ix
About this Manual, Continued
Name Cat. No. Contents
SYSMAC CS/CJ Series W394 This manual describes programming and other
CS1G/H-CPU@@-EV1, CS1G/H-CPU@@H, CJ1G- methods to use the functions of the CS/CJ-series
CPU@@, CJ1G/H-CPU@@H PLCs. (This manual)
Programmable Controllers Programming Manual
SYSMAC CS Series W339 Provides an outlines of and describes the design,
CS1G/H-CPU@@-EV1, CS1G/H-CPU@@H installation, maintenance, and other basic opera-
Programmable Controllers Operation Manual tions for the CS-series PLCs.
SYSMAC CJ Series W393 Provides an outlines of and describes the design,
CJ1G-CPU@@, CJ1G/H-CPU@@H installation, maintenance, and other basic opera-
Programmable Controllers Operation Manual tions for the CJ-series PLCs.
SYSMAC CJ Series W395 Describes the functions of the built-in I/O for
CJ1M-CPU22/23 CJ1M CPU Units.
Built-in I/O Functions Operation Manual
SYSMAC CS/CJ Series W340 Describes the ladder diagram programming
CS1G/H-CPU@@-EV1, CS1G/H-CPU@@H, CJ1G- instructions supported by CS/CJ-series PLCs.
CPU@@, CJ1G/H-CPU@@H
Programmable Controllers Instructions Reference Manual
SYSMAC CS/CJ Series W341 Provides information on how to program and
CQM1H-PRO01-E, C200H-PRO27-E, CQM1-PRO01-E operate CS/CJ-series PLCs using a Programming
Programming Consoles Operation Manual Console.
SYSMAC CS/CJ Series W342 Describes the C-series (Host Link) and FINS
CS1G/H-CPU@@-EV1, CS1G/H-CPU@@H, CJ1G- communications commands used with CS/CJ-
CPU@@, CJ1G/H-CPU@@H, CS1W-SCB21/41, CS1W- series PLCs.
SCU21, CJ1W-SCU41
Communications Commands Reference Manual
SYSMAC WS02-CXP@@-E W361 Provide information on how to use the CX-Pro-
CX-Programmer User Manual grammer, a programming device that supports
SYSMAC WS02-CXP@@-E W362 the CS/CJ-series PLCs, and the CX-Net con-
CX-Server User Manual tained within CX-Programmer.
SYSMAC CS/CJ Series W336 Describes the use of Serial Communications Unit
CS1W-SCB21/41, CS1W-SCU21, CJ1W-SCU41 and Boards to perform serial communications
Serial Communications Boards/Units Operation Manual with external devices, including the usage of stan-
dard system protocols for OMRON products.
SYSMAC WS02-PSTC1-E W344 Describes the use of the CX-Protocol to create
CX-Protocol Operation Manual protocol macros as communications sequences
to communicate with external devices.
SYSMAC CS/CJ Series W343 Describes the installation and operation of CJ1W-
CJ1W-ETN01/ENT11, CJ1W-ETN11 Ethernet Unit ETN01, CJ1W-ENT11, and CJ1W-ETN11 Ether-
Operation Manual net Units.
!WARNING Failure to read and understand the information provided in this manual may result in per-
sonal injury or death, damage to the product, or product failure. Please read each section
in its entirety and be sure you understand the information provided in the section and
related sections before attempting any of the procedures or operations given.
x
PRECAUTIONS
This section provides general precautions for using the CS/CJ-series Programmable Controllers (PLCs) and related devices.
The information contained in this section is important for the safe and reliable application of Programmable
Controllers. You must read this section and understand the information contained before attempting to set up or
operate a PLC system.
xi
Intended Audience 1
1 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.
2 General Precautions
The user must operate the product according to the performance specifica-
tions described in the operation manuals.
Before using the product under conditions which are not described in the
manual or applying the product to nuclear control systems, railroad systems,
aviation systems, vehicles, combustion systems, medical equipment, amuse-
ment machines, safety equipment, and other systems, machines, and equip-
ment that may have a serious influence on lives and property if used
improperly, consult your OMRON representative.
Make sure that the ratings and performance characteristics of the product are
sufficient for the systems, machines, and equipment, and be sure to provide
the systems, machines, and equipment with double safety mechanisms.
This manual provides information for programming and operating the Unit. Be
sure to read this manual before attempting to use the Unit and keep this man-
ual close at hand for reference during operation.
!WARNING It is extremely important that a PLC and all PLC Units be used for the speci-
fied purpose and under the specified conditions, especially in applications that
can directly or indirectly affect human life. You must consult with your OMRON
representative before applying a PLC System to the above-mentioned appli-
cations.
3 Safety Precautions
!WARNING The CPU Unit refreshes I/O even when the program is stopped (i.e., even in
PROGRAM mode). Confirm safety thoroughly in advance before changing the
status of any part of memory allocated to I/O Units, Special I/O Units, or CPU
Bus Units. Any changes to the data allocated to any Unit may result in unex-
pected operation of the loads connected to the Unit. Any of the following oper-
ation may result in changes to memory status.
!WARNING Do not attempt to take any Unit apart while the power is being supplied. Doing
so may result in electric shock.
xii
Safety Precautions 3
!WARNING Do not touch any of the terminals or terminal blocks while the power is being
supplied. Doing so may result in electric shock.
!WARNING Do not attempt to disassemble, repair, or modify any Units. Any attempt to do
so may result in malfunction, fire, or electric shock.
!WARNING Do not touch the Power Supply Unit while power is being supplied or immedi-
ately after power has been turned OFF. Doing so may result in electric shock.
!WARNING Provide safety measures in external circuits (i.e., not in the Programmable
Controller), including the following items, to ensure safety in the system if an
abnormality occurs due to malfunction of the PLC or another external factor
affecting the PLC operation. Not doing so may result in serious accidents.
Emergency stop circuits, interlock circuits, limit circuits, and similar safety
measures must be provided in external control circuits.
The PLC will turn OFF all outputs when its self-diagnosis function detects
any error or when a severe failure alarm (FALS) instruction is executed.
As a countermeasure for such errors, external safety measures must be
provided to ensure safety in the system.
The PLC outputs may remain ON or OFF due to deposition or burning of
the output relays or destruction of the output transistors. As a counter-
measure for such problems, external safety measures must be provided
to ensure safety in the system.
When the 24-V DC output (service power supply to the PLC) is over-
loaded or short-circuited, the voltage may drop and result in the outputs
being turned OFF. As a countermeasure for such problems, external
safety measures must be provided to ensure safety in the system.
!Caution Confirm safety before transferring data files stored in the file memory (Mem-
ory Card or EM file memory) to the I/O area (CIO) of the CPU Unit using a
peripheral tool. Otherwise, the devices connected to the output unit may mal-
function regardless of the operation mode of the CPU Unit.
!Caution Fail-safe measures must be taken by the customer to ensure safety in the
event of incorrect, missing, or abnormal signals caused by broken signal lines,
momentary power interruptions, or other causes. Abnormal operation may
result in serious accidents.
!Caution Interlock circuits, limit circuits, and similar safety measures in external circuits
(i.e., not in the Programmable Controller) must be provided by the customer.
Abnormal operation may result in serious accidents.
!Caution 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.
xiii
Operating Environment Precautions 4
!Caution Tighten the screws on the terminal block of the AC Power Supply Unit to the
torque specified in the operation manual. The loose screws may result in
burning or malfunction.
!Caution The operating environment of the PLC System can have a large effect on the
longevity and reliability of the system. Improper operating environments can
lead to malfunction, failure, and other unforeseeable problems with the PLC
System. Be sure that the operating environment is within the specified condi-
tions at installation and remains within the specified conditions during the life
of the system.
5 Application Precautions
Observe the following precautions when using the PLC System.
You must use the CX-Programmer (programming software that runs on
Windows) if you need to program more than one task. A Programming
Console can be used to program only one cyclic task plus interrupt tasks.
A Programming Console can, however, be used to edit multitask pro-
grams originally created with the CX-Programmer.
There are restrictions in the areas and addresses that can be accessed in
I/O memory of the CS-series CS1 CPU Units when using the C200H Spe-
cial I/O Units in combination with the following functions.
There are restrictions in data transfer with the CPU Unit when pro-
gramming transfers inside an ASCII Unit using the PLC READ, PLC
WRITE, and similar commands.
There are restrictions in data transfer with the CPU Unit for allocated
bits and DM area specifications (areas and addresses for source and
destination specifications).
xiv
Application Precautions 5
!WARNING Always heed these precautions. Failure to abide by the following precautions
could lead to serious or possibly fatal injury.
Always connect to a ground of 100 W or less when installing the Units. Not
connecting to a ground of 100 W or less may result in electric shock.
A ground of 100 W or less must be installed when shorting the GR and LG
terminals on the Power Supply Unit.
Always turn OFF the power supply to the PLC before attempting any of
the following. Not turning OFF the power supply may result in malfunction
or electric shock.
Mounting or dismounting Power Supply Units, I/O Units, CPU Units, In-
ner Boards, or any other Units.
Assembling the Units.
Setting DIP switches or rotary switches.
Connecting cables or wiring the system.
Connecting or disconnecting the connectors.
!Caution Failure to abide by the following precautions could lead to faulty operation of
the PLC or the system, or could damage the PLC or PLC Units. Always heed
these precautions.
A CJ-series CPU Unit is shipped with the battery installed and the time
already set on the internal clock. It is not necessary to clear memory or
set the clock before application, as it is for the CS-series CS1 CPU Units.
When using a CS-series CS1 CPU Unit for the first time, install the
CS1W-BAT1 Battery provided with the Unit and clear all memory areas
from a Programming Device before starting to program. When using the
internal clock, turn ON power after installing the battery and set the clock
xv
Application Precautions 5
xvi
Application Precautions 5
xvii
Application Precautions 5
Check the user program for proper execution before actually running it on
the Unit. Not checking the program may result in an unexpected opera-
tion.
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.
Force-setting/force-resetting any bit in memory.
Changing the present value of any word or any set value in memory.
Resume operation only after transferring to the new CPU Unit the con-
tents of the DM Area, HR Area, and other data required for resuming
operation. Not doing so may result in an unexpected operation.
Do not pull on the cables or bend the cables beyond their natural limit.
Doing either of these may break the cables.
Do not place objects on top of the cables or other wiring lines. Doing so
may break the cables.
Do not use commercially available RS-232C personal computer cables.
Always use the special cables listed in this manual or make cables
according to manual specifications. Using commercially available cables
may damage the external devices or CPU Unit.
When replacing parts, be sure to confirm that the rating of a new part is
correct. Not doing so may result in malfunction or burning.
Before touching a Unit, be sure to first touch a grounded metallic object in
order to discharge any static build-up. Not doing so may result in malfunc-
tion or damage.
When transporting or storing circuit boards, cover them in antistatic mate-
rial to protect them from static electricity and maintain the proper storage
temperature.
Do not touch circuit boards or the components mounted to them with your
bare hands. There are sharp leads and other parts on the boards that
may cause injury if handled improperly.
Do not short the battery terminals or charge, disassemble, heat, or incin-
erate the battery. Do not subject the battery to strong shocks. Doing any
of these may result in leakage, rupture, heat generation, or ignition of the
battery. Dispose of any battery that has been dropped on the floor or oth-
erwise subjected to excessive shock. Batteries that have been subjected
to shock may leak if they are used.
UL standards required that batteries be replaced only by experienced
technicians. Do not allow unqualified persons to replace batteries.
With a CJ-series PLC, the sliders on the tops and bottoms of the Power
Supply Unit, CPU Unit, I/O Units, Special I/O Units, and CPU Bus Units
must be completely locked (until they click into place). The Unit may not
operate properly if the sliders are not locked in place.
With a CJ-series PLC, always connect the End Plate to the Unit on the
right end of the PLC. The PLC will not operate properly without the End
Plate
Unexpected operation may result if inappropriate data link tables or
parameters are set. Even if appropriate data link tables and parameters
have been set, confirm that the controlled system will not be adversely
affected before starting or stopping data links.
CPU Bus Units will be restarted when routing tables are transferred from
a Programming Device to the CPU Unit. Restarting these Units is
xviii
Conformance to EC Directives 6
required to read and enable the new routing tables. Confirm that the sys-
tem will not be adversely affected before allowing the CPU Bus Units to
be reset.
6 Conformance to EC Directives
6-1 Applicable Directives
EMC Directives
Low Voltage Directive
6-2 Concepts
EMC Directives
OMRON devices that comply with EC Directives also conform to the related
EMC standards so that they can be more easily built into other devices or the
overall machine. The actual products have been checked for conformity to
EMC standards (see the following note). Whether the products conform to the
standards in the system used by the customer, however, must be checked by
the customer.
EMC-related performance of the OMRON devices that comply with EC Direc-
tives will vary depending on the configuration, wiring, and other conditions of
the equipment or control panel on which the OMRON devices are installed.
The customer must, therefore, perform the final check to confirm that devices
and the overall machine conform to EMC standards.
Note Applicable EMC (Electromagnetic Compatibility) standards are as follows:
EMS (Electromagnetic Susceptibility):
CS Series: EN61131-2 and EN61000-6-2
CJ Series: EN61000-6-2
EMI (Electromagnetic Interference):
EN50081-2
(Radiated emission: 10-m regulations)
Low Voltage Directive
Always ensure that devices operating at voltages of 50 to 1,000 V AC and 75
to 1,500 V DC meet the required safety standards for the PLC (EN61131-2).
xix
Conformance to EC Directives 6
Countermeasures
(Refer to EN50081-2 for more details.)
Countermeasures are not required if the frequency of load switching for the
whole system with the PLC included is less than 5 times per minute.
Countermeasures are required if the frequency of load switching for the whole
system with the PLC included is more than 5 times per minute.
Countermeasure Examples
When switching an inductive load, connect an surge protector, diodes, etc., in
parallel with the load or contact as shown below.
Circuit Current Characteristic Required element
AC DC
CR method Yes Yes If the load is a relay or solenoid, there is The capacitance of the capacitor must
a time lag between the moment the cir- be 1 to 0.5 mF per contact current of
cuit is opened and the moment the load 1 A and resistance of the resistor must
C is reset. be 0.5 to 1 W per contact voltage of 1 V.
Inductive
R the surge protector in parallel with the load and the characteristics of the
load. If the supply voltage is 100 to relay. Decide these values from experi-
200 V, insert the surge protector ments, and take into consideration that
between the contacts. the capacitance suppresses spark dis-
charge when the contacts are sepa-
rated and the resistance limits the
current that flows into the load when
the circuit is closed again.
The dielectric strength of the capacitor
must be 200 to 300 V. If the circuit is an
AC circuit, use a capacitor with no
polarity.
xx
Conformance to EC Directives 6
Diode method No Yes The diode connected in parallel with The reversed dielectric strength value
the load changes energy accumulated of the diode must be at least 10 times
by the coil into a current, which then as large as the circuit voltage value.
Inductive
flows into the coil so that the current will The forward current of the diode must
be converted into Joule heat by the be the same as or larger than the load
load
Power
cuit is opened and the moment the load
supply is reset.
If the supply voltage is 24 or 48 V, insert
the varistor in parallel with the load. If
the supply voltage is 100 to 200 V,
insert the varistor between the con-
tacts.
R
OUT OUT
R
COM COM
xxi
Conformance to EC Directives 6
xxii
SECTION 1
CPU Unit Operation
This section describes the basic structure and operation of the CPU Unit.
1
Initial Setup (CS1 CPU Units Only) Section 1-1
1,2,3... 1. Insert a flat-blade screwdriver in the small gap at the bottom of the battery
compartment and flip the cover upward to open it.
2
Initial Setup (CS1 CPU Units Only) Section 1-1
2. Hold the Battery Set with the cable facing outward and insert it into the bat-
tery compartment.
Battery compartment
Red
White
Battery connector terminals
(Connect to either set of terminals.)
3
Initial Setup (CS1 CPU Units Only) Section 1-1
Clearing Memory After installing the battery, clear memory using the memory clear operation to
initialize the RAM inside the CPU Unit.
Programming Console
Use the following procedure from a Programming Console.
Note You cannot specify more than one cyclic task when clearing memory from a
Programming Console. You can specify one cyclic task and one interrupt task,
or one cyclic task and no interrupt task. Refer to the Operation Manual for
more information on the memory clear operation. Refer to 6(&7,21&38
8QLW2SHUDWLRQ and 6(&7,217DVNV for more information on tasks.
CX-Programmer
Memory can also be cleared from the CX-Programmer. Refer to the CX-Pro-
grammer Operation Manual for the actual procedure.
Clearing Errors After clearing memory, clear any errors from the CPU Unit, including the low
battery voltage error.
Programming Console
Use the following procedure from a Programming Console.
MON
CX-Programmer
Errors can also be cleared from the CX-Programmer. Refer to the CX-Pro-
grammer Operation Manual for the actual procedure.
Note When an Inner Board is mounted, an Inner Board routing table error may con-
tinue even after you have cancelled the error using the CX-Programmer.
(A42407 will be ON for a Serial Communications Board.) If this occurs, either
reset the power or restart the Inner Board, then cancel the error again.
4
Using the Internal Clock (CS1 CPU Units Only) Section 1-2
5
Internal Structure of the CPU Unit Section 1-3
Auto-
matic I/O memory
backup
EM file memory
Auto-
Flash matic PLC Setup
memory backup and other
parameters
DIP switch
(CS1-H, CJ1-H, or
CJ1M CPU Units only)
The User Program The user program is created from up to 288 program tasks, including interrupt
tasks. The tasks are transferred to the CPU Unit from the CX-Programmer
programming software.
There are two types of tasks. The first is a cyclic task that is executed once
per cycle (maximum of 32) and the other is an interrupt task that is executed
only when the interrupt conditions occur (maximum of 256). Cyclic tasks are
executed in numerical order.
Note With the CS1-H, CJ1-H, or CJ1M CPU Units, interrupt tasks can be executed
cyclically in the same way as cyclic tasks. These are called extra cyclic
tasks. The total number of tasks that can be executed cyclically must be 288
or less.
Program instructions read and write to I/O memory and are executed in order
starting at the top of the program. After all cyclic tasks are executed, the I/O
for all Units are refreshed, and the cycle repeats again starting at the lowest
cyclic task number.
Refer to the section on CPU Unit operation in the CS/CJ Series Operation
Manual for details on refreshing I/O.
I/O Memory I/O memory is the RAM area used for reading and writing from the user pro-
gram. It is comprised of one area that is cleared when power is turned ON and
OFF, and another area that will retain data.
I/O memory is also partitioned into an area that exchanges data with all Units
and an area strictly for internal use. Data is exchanged with all Units once per
program execution cycle and also when specific instructions are executed.
6
Internal Structure of the CPU Unit Section 1-3
PLC Setup The PLC Setup is used to set various initial or other settings through software
switches.
DIP Switches DIP switches are used to set initial or other settings through hardware
switches.
Memory Cards Memory Cards are used as needed to store data such as programs, I/O mem-
ory data, the PLC Setup, and I/O comments created by Programming
Devices. Programs and various system settings can be written automatically
from the Memory Card when power is turned ON (automatic transfer at star-
tup).
Flash Memory (CS1-H, With the CS1-H, CJ1-H, or CJ1M CPU Units, the user program and parameter
CJ1-H, or CJ1M CPU Units area data, such as the PLC Setup, are automatically backed up in the built-in
Only) flash memory whenever the user writes data to the CPU Unit. This enables
battery-free operation without using a Memory Card. I/O memory, including
most of the DM Area, are not backed up without a battery.
7
Operating Modes Section 1-4
CPU Unit
Built-in RAM
Auto-
written
Parameter area Parameter area
(See note 1.)
File memory
Note 1. The parameter area and user program (i.e., the user memory) can be
write-protected by turning ON pin 1 of the DIP switch on the front of the
CPU Unit.
2. EM file memory is part of the EM Area that has been converted to file
memory in the PLC Setup. All EM banks from the specified bank to the end
of the EM Area can be used only as file memory for storage of data and
program files.
3. Be sure to install the battery provided (CS1W-BAT01) before using a CS1
CPU Unit for the first time. After installing the battery, use a Programming
Device to clear the PLCs RAM (parameter area, I/O memory area, and
user program).
4. A Battery is mounted to a CS1-H, CJ1, CJ1-H, or CJ1M CPU Unit when it
is shipped from the factory. There is no need to clear memory or set the
time.
5. The BKUP indicator on the front of the CPU Unit will light while data is be-
ing written to flash memory. Do not turn OFF the power supply to the CPU
Unit until the backup operation has been completed (i.e., until the BKUP
indicator goes out). Refer to )ODVK0HPRU\ for details.
PROGRAM Mode Program execution stops in PROGRAM mode, and the RUN indicator is not lit.
This mode is used when editing the program or making other preparations
operation, such as the following:
8
Operating Modes Section 1-4
!WARNING The CPU Unit refreshes I/O even when the program is stopped (i.e., even in
PROGRAM mode). Confirm safety thoroughly in advance before changing the
status of any part of memory allocated to I/O Units, Special I/O Units, or CPU
Bus Units. Any changes to the data allocated to any Unit may result in unex-
pected operation of the loads connected to the Unit. Any of the following oper-
ation may result in changes to memory status.
MONITOR Mode The following operations can be performed through Programming Devices
while the program is executing in MONITOR mode. The RUN indicator will be
lit. This mode is used to make test runs or other adjustments.
Online Editing.
Force-setting and force-resetting bits.
Changing values in I/O memory.
In this mode, the cyclic tasks specified for execution at startup (see note) and
those are made executable by TKON(820) will be executed when program
execution reaches their task number. Interrupt tasks will be executed if their
interrupt conditions occur.
Note The tasks that are executed at startup are specified in the program properties
from the CX-Programmer.
RUN Mode This mode is used for normal program execution. The RUN indicator will be lit.
Some Programming Device operations like online editing, force-set/force-
reset, and changing I/O memory values are disabled in this mode, but other
Programming Device operations like monitoring the status of program execu-
tion (monitoring programs and monitoring I/O memory) are enabled.
Use this mode for normal system operation. Task execution is the same as in
MONITOR mode.
See 10-2 CPU Unit Operating Modes in the Operation Manual for more details
on operations that are available in each operating mode.
9
Operating Modes Section 1-4
Note 1. Non-held areas: CIO Area, Work Area, Timer PVs, Timer Completion
Flags, Index Registers, Data Registers, Task Flags, and Condition Flags.
(The statuses of some addresses in the Auxiliary Area are held and others
are cleared.)
2. Held areas: Holding Area, DM Area, EM Area, Counter PVs, and Counter
Completion Flags.
3. Data in I/O memory will be retained when the IOM Hold Bit (A50012) is ON.
When the IOM Hold Bit (A50012) is ON and operation is stopped due to a
fatal error (including FALS(007)), the contents of I/O memory will be re-
tained but outputs on Output Units will all be turned OFF.
10
Operating Modes Section 1-4
Yes
No
11
Programs and Tasks Section 1-5
Cyclic Allocation
task 0 Interrupt condition
goes into effect Program B
Interrupt
task 100
Cyclic Allocation
task 1
Program C
Allocation
Program D
Cyclic
task n
Allocation
I/O refreshing
12
Programs and Tasks Section 1-5
One feature of the cyclic tasks is that they can be enabled (executable status)
and disabled (standby status) by the task control instructions. This means that
several program components can be assembled as a task, and that only spe-
cific programs (tasks) can then be executed as needed for the current product
model or process being performed (program step switching). Therefore perfor-
mance (cycle time) is greatly improved because only required programs will
be executed as needed.
Earlier system CS/CJ Series
Task 1
One continuous
subprogram
Allocation
Task 3
I/O refreshing
I/O refreshing
A task that has been executed will be executed in subsequent cycles, and a
task that is on standby will remain on standby in subsequent cycles unless it is
executed again from another task.
Note Unlike earlier programs that can be compared to reading a scroll, tasks can
be compared to reading through a series of individual cards.
All cards are read in a preset sequence starting from the lowest number.
All cards are designated as either active or inactive, and cards that are
inactive will be skipped. (Cards are activated or deactivated by task con-
trol instructions.)
13
Description of Tasks Section 1-6
A card that is activated will remain activated and will be read in subse-
quent sequences. A card that is deactivated will remain deactivated and
will be skipped until it is reactivated by another card.
Earlier program: CS/CJ-series program:
Like a scroll Like a series of cards that can be activated
or deactivated by other cards.
Activated Deactivated
14
Description of Tasks Section 1-6
Cyclic task 0
Interrupt task 5
Cyclic task 2
I/O refreshing
Peripheral processing
Program Structure Standard subroutine programs can be created and allocated to tasks as
needed to create programs. This means that programs can be created in
modules (standard components) and that tasks can be debugged individually.
Standard subroutine programs
15
Description of Tasks Section 1-6
Executable and Standby The TASK ON and TASK OFF instructions (TKON(820) and TKOF(821)) can
Status be executed in one task to place another task in executable or standby status.
Instructions in tasks that are on standby will not be executed, but their I/O sta-
tus will be maintained. When a task is returned to executable status, instruc-
tions will be executed with the I/O status that was maintained.
Example: Programming with a Control Task
In this example, task 0 is a control task that is executed first at the start of
operation. Other tasks can be set from the CX-Programmer (but not a Pro-
gramming Console) to start or not to start at the beginning of operation.
Once program execution has been started, tasks can be controlled with
TKON(820) and TKOF(821).
Task 0
Program
Task 1
Task 2
Task 3
16
Description of Tasks Section 1-6
Task 0
Task 1
Task 2
Program for task 1
Start task 1
when a is
ON.
Put task 1
Task 0 on standby Task 0
Task 0 when b is
ON.
Task 1 Task 1 Task 1
Task 2 Task 2 Task 2
If task 1 executed
Task 2
17
Description of Tasks Section 1-6
Task Execution Time While a task is on standby, instructions in that task are not executed, so their
OFF instruction execution time will not be added to the cycle time.
Note From this standpoint, instructions in a task that is on standby are just like
instructions in a jumped program section (JMP-JME).
Since instructions in a non-executed task do not add to the cycle time, the
overall system performance can be improved significantly by splitting the sys-
tem into an overall control task and individual tasks that are executed only
when necessary.
Earlier system CS/CJ-series PLCs
Most instructions
are executed. Task 0 Instructions are
(Instructions in executed only
subroutines and Task 1 when necessary.
jumps are
executed only
when neces Task 2
sary.)
Task 3
18
SECTION 2
Programming
This section basic information required to write, check, and input programs.
19
Basic Concepts Section 2-1
Allocated
Cyclic
task 1 Interrupt condition met.
Interrupt
task Program B
Allocated
Each ladder-diagram
program ends with an
END(001) instruction.
Cyclic
task n Program C
Allocated
I/O refresh
This section describes the basic concepts required to write CS/CJ-series pro-
grams. See 6(&7,217DVNV for more information on tasks and their rela-
tionship to ladder-diagram programs.
Note Tasks and Programming Devices
Tasks are handled as described below on the Programming Devices. Refer to
3URJUDPPLQJ'HYLFH2SHUDWLRQVIRU7DVNV and to the CS/CJ-series Pro-
gramming Consoles Operation Manual (W341) and CX-Programmer Opera-
tion Manual for more details.
CX-Programmer
The CX-Programmer is used to designate task types and task numbers as
attributes for individual programs.
Programming Console
Programs are accessed and edited on a Programming Console by specifying
CT00 to CT 31 for cyclic tasks and IT00 to IT255 for interrupt tasks. When the
memory clear operation is performed with a Programming Console, only
cyclic task 0 (CT00) can be written in a new program. Use CX-Programmer to
create cyclic tasks 1 through 31 (CT01 through CT31).
20
Basic Concepts Section 2-1
Power flow (P.F., execution condition) Power flow (P.F., execution condition)*1
Instruction
Instruction condition Instruction condition*2
Flags Flag
Memory
Power Flow
The power flow is the execution condition that is used to control the execute
and instructions when programs are executing normally. In a ladder program,
power flow represents the status of the execution condition.
Input Instructions Load instructions indicate a logical start and outputs the execution condi-
tion.
Outputs the
execution condition.
=
D00000
#1215
Output Instructions Output instructions execute all functions, using the power flow as an execution
condition.
LD power flow
Power flow for
output instruction
Instruction Conditions
Instruction conditions are special conditions related to overall instruction exe-
cution that are output by the following instructions. Instruction conditions have
a higher priority than power flow (P.F.) when it comes to deciding whether or
not to execute an instruction. An instruction may become not be executed or
may act differently depending on instruction conditions. Instruction conditions
21
Basic Concepts Section 2-1
are reset (canceled) at the start of each task, i.e., they are reset when the task
changes.
The following instructions are used in pairs to set and cancel certain instruc-
tion conditions. These paired instructions must be in the same task.
Instruction Description Setting Canceling
condition instruction instruction
Interlocked An interlock turns OFF part of the program. Special conditions, such as IL(002) ILC(003)
turning OFF output bits, resetting timers, and holding counters are in
effect.
BREAK(514) Ends a FOR(512) - NEXT(513) loop during execution. (Prevents execu- BREAK(514) NEXT(513)
execution tion of all instructions until to the NEXT(513) instruction.)
Executes a JMP0(515) to JME0(516) jump. JMP0(515) JME0(516)
Block program Executes a program block from BPRG(096) to BEND(801). BPRG(096) BEND(801)
execution
Flags
In this context, a flag is a bit that serves as an interface between instructions.
Input flags Output flags
Differentiation Flags Differentiation Flags
Differentiation result flags. The status of these Differentiation result flags. The status of these flags are output
flags are input automatically to the instruction for automatically from the instruction for all differentiated up/down
all differentiated up/down output instructions and output instructions and the UP(521)/DOWN(522) instruction.
the DIFU(013)/DIFD(014) instructions. Condition Flags
Carry (CY) Flag Condition Flags include the Always ON/OFF Flags, as well as
The Carry Flag is used as an unspecified operand flags that are updated by results of instruction execution. In user
in data shift instructions and addition/subtraction programs, these flags can be specified by labels, such as ER,
instructions. CY, >, =, A1, A0, rather than by addresses.
Flags for Special Instructions Flags for Special Instructions
These include teaching flags for FPD(269) instruc- These include memory card instruction flags and MSG(046)
tions and network communications enabled flags execution completed flags.
Operands
Operands specify preset instruction parameters (boxes in ladder diagrams)
that are used to specify I/O memory area contents or constants. An instruction
can be executed entering an address or constant as the operands. Operands
are classified as source, destination, or number operands.
Example
S (source) N (number)
D (destination)
22
Basic Concepts Section 2-1
Note Operands are also called the first operand, second operand, and so on, start-
ing from the top of the instruction.
First operand
Second operand
23
Basic Concepts Section 2-1
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
0000
0001
0002
Word Addresses
@@@@
Word address
DM and EM Areas addresses are given with D or E prefixes, as shown
below for the address D00200.
D00200
Word address
24
Basic Concepts Section 2-1
Example: The address of word 2000 in the current bank of the Extended Data
Memory would be as follows:
E00200
Word address
The address of word 2000 in the bank 1 of the Extended Data Memory would
be as follows:
E1_00200
Word address
Bank number
Specifying The word number is specified directly to speci- 0003 MOV 0003
word fy the 16-bit word. D00200
addresses Word number: 0003
@@@@
D00200
Indicates the word address.
Word number: 00200
25
Basic Concepts Section 2-1
@D@@@@@
Specifies D00256.
Specifies E0 00001.
Specifies E1_00257.
Specifies E2_00002.
Note When specifying an indirect address in Binary Mode, treat Data Memory (DM) and Extended Data
Memory (EM) (banks 0 to C) as one series of addresses. If the contents of an address with the @
symbol exceeds 32767, the address will be assumed to be an address in the Extended Data Mem-
ory (EM) continuing on from 00000 in bank No. 0.
Example: If the Data Memory (DM) word contains 32768, E1_00000 in bank 0 in Extended Data Mem-
ory (EM) would be specified.
Note If the Extended Data Memory (EM) bank number is specified as n and the contents of the word
exceeds 32767, the address will be assumed to be an address in the Extended Data Memory (EM)
continuing on from 00000 in bank N+1.
Example: If bank 2 in Extended Data Memory (EM) contains 32768, E3_00000 in bank number 3 in
Extended Data Memory (EM) would be specified.
26
Basic Concepts Section 2-1
27
Basic Concepts Section 2-1
41 42
43 44
00 00
ASCII characters that can be used in a text string includes alphanumeric characters, Katakana and sym-
bols (except for special characters). The characters are shown in the following table.
28
Basic Concepts Section 2-1
ASCII Characters
Bits 0 to 3 Bits 4 to 7
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
0000 0 Space # 3 C S # 3
0001 1 $ 4 D T $ 4
0010 2 j % 5 E U f % 5
0011 3 & 6 F V & 6
0100 4 ' 7 G W ' 7
0101 5 ( 8 H X ( 8
0110 6 ) 9 I Y ) 9
0111 7 l * : J Z h * :
1000 8 + ; K [ + ;
1001 9 , < L \ , <
1010 A
- = M ]
- =
1011 B . > N ^ . >
1100 C / ? O _ / ?
1101 D 0 @ P ` 0 @
1110 E ! 1 A Q ~ ! 1 A
1111 F " 2 B R " 2 B
29
Basic Concepts Section 2-1
Hex 23 22 21 20 23 22 21 20 23 22 21 20 23 22 21 20
Hex 23 22 21 2 0 23 22 21 20 23 22 21 20 23 22 21 20
Decimal
0 to 9 0 to 9 0 to 9 0 to 9
30
Basic Concepts Section 2-1
31
Basic Concepts Section 2-1
F F F F
1111 1111 1111 1111
True number 0 0 1 3
0000 0000 0001 0011
)
F F E C
1111 1111 1110 1100
0 0 0 1
0000 0000 0000 0001
+)
Two's complement F F E D
1111 1111 1110 1101
Complements
Generally the complement of base x refers to a number produced when all
digits of a given number are subtracted from x 1 and then 1 is added to the
rightmost digit. (Example: The tens complement of 7556 is 9999 7556 + 1 =
2444.) A complement is used to express a subtraction and other functions as
an addition.
Example: With 8954 7556 = 1398, 8954 + (the tens complement of 7556) =
8954 + 2444 = 11398. If we ignore the leftmost bit, we get a subtraction result
of 1398.
Twos Complements
A twos complement is a base-two complement. Here, we subtract all digits
from 1 (2 1 = 1) and add one.
Example: The twos complement of binary number 1101 is 1111 (F Hex)
1101 (D Hex) + 1 (1 Hex) = 0011 (3 Hex). The following shows this value
expressed in 4-digit hexadecimal.
The twos complement b Hex of a Hex is FFFF Hex a Hex + 0001 Hex =
b Hex. To determine the twos complement b Hex of a Hex, use b Hex =
10000 Hex a Hex.
Example: to determine the twos complement of 3039 Hex, use 10000 Hex
3039 Hex = CFC7 Hex.
Similarly use a Hex = 10000 Hex b Hex to determine the value a Hex from
the twos complement b Hex.
Example: To determine the real value from the twos complement CFC7 Hex
use 10000 Hex CFC7 Hex = 3039 Hex.
The CS/CJ Series has two instructions: NEG(160)(2S COMPLEMENT) and
NEGL(161) (DOUBLE 2S COMPLEMENT) that can be used to determine the
twos complement from the true number or to determine the true number from
the twos complement.
Signed BCD Data
Signed BCD data is a special data format that is used to express negative
numbers in BCD. Although this format is found in applications, it is not strictly
defined and depends on the specific application. The CS/CJ Series supports
the following instructions to convert the data formats: SIGNED BCD-TO-
BINARY: BINS(470), DOUBLE SIGNED BCD-TO-BINARY: BISL(472),
32
Basic Concepts Section 2-1
33
Basic Concepts Section 2-1
@
Instruction (mnemonic)
Differentiation variation
Immediate refresh variation
Non-differentiated
output instruction
Input instructions that create logical starts and intermediate instructions read
bit status, make comparisons, test bits, or perform other types of processing
every cycle. If the results are ON, power flow is output (i.e., the execution con-
dition is turned ON).
Example
Non-differentiated input instruction
Input-differentiated Instructions
Upwardly Differentiated Instructions (Instruction Preceded by @)
Output Instructions: The instruction is executed only during the cycle in
which the execution condition turned ON (OFF ON) and are not exe-
cuted in the following cycles.
Example
(@) Upwardly-differ
entiated instruction @MOV
34
Basic Concepts Section 2-1
Example
(%) Downwardly dif-
ferentiated instruction %SET
35
Basic Concepts Section 2-1
Input
A B1 read
Input
read
A B2 Input
read
A B3 Input
read
Input
Input read
A B4
read
!
A B5 Input
! read
A B6 Input
read
Input Input read
A B7
read
!
A B8 Input
! read
A B9 Input
! read
A B10
! !
A B11
! !
A B12
!
CPU pro-
cessing
Instruction I/O refresh
executed.
Differentiated Instructions
A differentiated instruction has an internal flag that tells whether the previ-
ous value is ON or OFF. At the start of operation, the previous value flags
for upwardly differentiated instruction (DIFU and @ instructions) are set to
ON and the previous value flags for downwardly differentiated instructions
36
Basic Concepts Section 2-1
0000
00
(002)
IL
0000
01
(013)
DIFU 001000
(003)
ILC
IL is IL is
executing executing
Use in Jumps (JMP - JME Instructions): Just as for interlocks, the pre-
vious value flag for a differentiated instruction is not changed when the
instruction is jumped, i.e., the previous value is maintained. Upwardly and
downwardly differentiate instructions will output the execution condition
only when the input status has changed from the status indicated by the
previous value flag.
Note a) Do not use the Always ON Flag or A20011 (First Cycle Flag) as
the input bit for an upwardly differentiated instruction. The instruc-
tion will never be executed.
b) Do not use Always OFF Flag as the input bit for a downwardly dif-
ferentiated instruction. The instruction will never be executed.
37
Basic Concepts Section 2-1
Cyclic Refresh
Every program allocated to a ready cyclic task or a task where interrupt condi-
tion has been met will execute starting from the beginning program address
and will run until the END(001) instruction. After all ready cyclic tasks or tasks
where interrupt condition have been met have executed, cyclic refresh will
refresh all I/O points at the same time.
Note Programs can be executed in multiple tasks. I/O will be refreshed after the
final END(001) instruction in the program allocated to the highest number
(among all ready cyclic tasks) and will not be refreshed after the END(001)
instruction in programs allocated to other cyclic tasks.
Top
15 0
! LD 000101 CIO 0001
16-bit units
15 0
! OUT 000209 CIO 0002
END
Top 15 0
CIO 0003 16-bit units
! MOV 0003 15 0
CIO 0004
END
Cyclic refresh
(batch processing)
I/O refresh All real data
Execute an IORF instruction for all required words prior to the END(001)
instruction if I/O refreshing is required in other tasks.
Immediate Refresh
Instructions with Refresh I/O will be refreshed as shown below when an instruction is executing if an
Variation (!) real I/O bit is specified as an operand.
Units Refreshed data
C200H Basic I/O Units (CS Series only) I/O will be refreshed for the 16 bits con-
CJ Basic I/O Units taining the bit.
38
Basic Concepts Section 2-1
Top
. Immediate refresh
. 15 0
. Input
!LD 000101 CIO 0001
.
. 16-bit units
. 15 0
!OUT 000209 Output
. CIO 0002
.
.
END
Top
. I/O refresh
. 15 0
. S
!MOV 0003 CIO 0003
. 0004
. 16-bit units
. 15 0
END D
CIO 0004
Cyclic refresh
(batch processing)
I/O refresh All real I/O
39
Basic Concepts Section 2-1
Units Refreshed for An I/O REFRESH (IORF(097)) instruction that refreshes real I/O data in a
IORF(097) or DLNK(226) specified word range is available as a special instruction. All or just a specified
range of real I/O data can be refreshed during a cycle with this instruction.
IORF can also be used to refresh words allocated to Special I/O Units.
Another instruction, CPU BUS UNIT REFRESH (DLNK(226)) is available to
refresh the words allocated to CPU Bus Units in the CIO and DM Areas, as
well as to perform special refreshing for the Unit, such as refreshing data
links. DLNK(226) is supported only by CS1-H, CJ1-H, or CJ1M CPU Units.
Units Refreshed for IORF(097)
Location CPU or Expansion I/O Rack (but not SYSMAC BUS Slave Racks)
Units Basic I/O Units CS/CJ-series Basic I/O Units Refreshed
C200H Basic I/O Units Refreshed
C200H Group-2 High-den- Refreshed
sity I/O Units
Special I/O Units Refreshed
CPU Bus Units Not refreshed
Words allocated in
CIO Area and DM
Area and any
special refreshing
DLNK
CPU Bus Unit with
unit number F.
#F
40
Basic Concepts Section 2-1
41
Basic Concepts Section 2-1
General Structure of the A ladder diagram consists of left and right bus bars, connecting lines, input
Ladder Diagram bits, output bits, and special instructions. A program consists of one or more
program runs. A program rung is a unit that can be partitioned when the bus is
split horizontally. In mnemonic form, a rung is all instructions from a LD/LD
NOT instruction to the output instruction just before the next LD/LD NOT
instructions. A program rung consists of instruction blocks that begin with an
LD/LD NOT instruction indicating a logical start.
Input bit Special Output bit
instruction
Left bus bar Connecting line Right bus bar
42
Basic Concepts Section 2-1
E (9) (10)
(8)
R2
0000 0000
00 05
TIM 0000 #0100
0002
00
43
Basic Concepts Section 2-1
0002
00
0002
00
Restrictions
1,2,3... 1.A ladder program must be closed so that signals (power flow) will flow
from the left bus bar to the right bus bar. A rung error will occur if the pro-
gram is not closed (but the program can be executed).
2. Output bits, timers, counters and other output instructions cannot be con-
nected directly to the left bus bar. If one is connected directly to the left bus
bar, a rung error will occur during the programming check by a Program-
ming Device. (The program can be executed, but the OUT and MOV(021)
will not be executed.)
Input condition must be provided.
MOV
ON (Always ON Flag)
MOV
44
Basic Concepts Section 2-1
3. An input bit must always be inserted before and never after an output in-
struction like an output bit. If it is inserted after an output instruction, then
a location error will occur during a Programming Device program check.
0000 0002
01 01
(Output bit)
0000
00
(Input bit)
0000
00
6. The total number 1 of LD/LD NOT instructions minus one indicating logi-
cal starts must match the total number of AND LD and OR LD instructions
connecting the instruction blocks. If they do not match, then a rung error
will occur during a Programming Device program check.
Example
A C E G LD A 3
OR B
LD C
OR D
B D F AND LD 2
LD E
OR F
AND LD
OUT G
45
Basic Concepts Section 2-1
END
Will not be executed.
END
END
END END
46
Basic Concepts Section 2-1
1,2,3... 1. First separate the rung into small blocks (a) to (f).
0005
00
(3)
(2)
47
Basic Concepts Section 2-1
Program the blocks from top to bottom and then from left to right.
(1)
LD 000000 LD 001000
AND 000001 AND 001001
OR LD
(2)
(4)
(a) 0000 0000 (f) 0000
02 03 06
AND LD
0005
00
OUT 000500
48
Basic Concepts Section 2-1
Program the parallel instruction in the A block and then the B block.
2. Series/Parallel Rungs
0000 0000 0000 0000 0002
00 01 02 03 01 Instruction Operands
LD 000000
0002
AND NOT 000001 a
01
LD 000002
0000 AND 000003
04
OR 000201 b
OR 000004
a b AND LD ---
A block B block OUT 000201
Separate the rung into A and B blocks, and program each individually.
Connect A and B blocks with an AND LD.
Program A block.
Instruction Operands
b1
LD NOT 000000
B1 block
0000 0000 0000 0000 0002 AND 000001 a
00 01 02 03 02
LD 000002
AND NOT 000003 b1
0000 0002
04 02 LD NOT 000004
AND 000202 b2
b2 OR LD --- b1 + b2
B2 block AND LD --- ab
OUT 000202
a b
A block B block
49
Basic Concepts Section 2-1
a1 b1
Instruction Operands
A1 block B1 block LD 000000
0000 0000 0000 0000 0002 a1
00 01 04 05 03 AND NOT 000001
LD NOT 000002
0000 0002 0002 0002
a2
02 03 06 07
AND 000003
OR LD --- a1 + a 2
LD 000004
b1
a2 b2 AND 000005
A2 block B2 block LD 000006
b2
a b AND 000007
A block B block OR LD --- b1 + b 2
AND LD --- a b
OUT 000203
0005
00
a b c n
50
Basic Concepts Section 2-1
4. Complex Rungs
0000 0000
0000 0000 0002 Instruction Operand 00 01
00 01 04
LD 000000 0000 0000
02 03
0000
02
0000
03
LD 000001
LD 000002
AND 000003 Z
0000 0000 Z
04 05
OR LD ---
The diagram above is based on the diagram below.
AND LD --- 0000
0000 0000 00 Z
06 07 LD 000004
AND 000005
OR LD ---
A simpler program can be written by rewriting
LD 000006 this as shown below.
AND 000007 0000 0000 0000
02 03 00
OR LD ---
OUT 000204
0000
01
b
Instruction Operand
Block
0000
00
0000
01
0000
02
0002
04
LD 000000 a
LD NOT 000001
b
a d
AND 000002
Block Block LD 000003
0000 0000 0000 c
03 04 05 AND NOT 000004
LD 000005
d
c
LD 000006
0000 0000
06 07 AND NOT 000007
Block e
OR LD ---
e
AND LD --- d+e
OR LD --- (d + e) c
Block
AND LD --- (d + e) c + b
The above rung can be rewritten as follows: ((d + e) c + b) a
OUT 000205
51
Basic Concepts Section 2-1
52
Basic Concepts Section 2-1
In the example below, use TR0 to store the execution condition at the branch point or rewrite the
rungs.
53
Precautions Section 2-2
The arrows show signal (power flow) flow when the rung consists of control relays.
A B
R1
A B
R1 C E
C E D
A E D
R2
R2
2-2 Precautions
2-2-1 Condition Flags
Using Condition Flags Conditions flags are shared by all instructions, and will change during a cycle
depending on results of executing individual instructions. Therefore, be sure
to use Condition Flags on a branched output with the same execution condi-
tion immediately after an instruction to reflect the results of instruction execu-
tion. Never connect a Condition Flag directly to the bus bar because this will
cause it to reflect execution results for other instructions.
Example: Using Instruction A Execution Results
Correct Use
Mnemonic
Instruction A
Instruction Operand
LD a
Reflects instruction A Instruction A
Condition Flag execution results. AND =
Example: =
Instruction B
Instruction B
The same execution condition (a) is used for instructions A and B to execute
instruction B based on the execution results of instruction A. In this case,
instruction B will be executed according to the Condition Flag only if instruc-
tion A is executed.
Incorrect Use
Preceding r ung
Instruction A
54
Precautions Section 2-2
If the Condition Flag is connected directly to the left bus bar, instruction B will
be executed based on the execution results of a previous rung if instruction A
is not executed.
Note Condition Flags are used by all instruction within a single program (task) but
they are cleared when the task switches. Therefore execution results in the
preceding task will not be reflected later tasks. Since conditions flags are
shared by all instructions, make absolutely sure that they do not interfere with
each other within a single ladder-diagram program. The following is an exam-
ple.
Using Execution Results in N.C. and N.C. Inputs
The Condition Flags will pick up instruction B execution results as shown in
the example below even though the N.C. and N.O. input bits are executed
from the same output branch.
Instruction A
Incorrect
Use
Reflects instruction A execution
results.
Condition Flag
Example: =
Instruction B
Instruction A
Reflects instruction A
execution results.
Condition Flag
Correct Example: =
Use
Reflects instruction A
Condition Flag execution results.
Example: =
Instruction B
55
Precautions Section 2-2
Example: The following example will move #0200 to D00200 if D00100 con-
tains #0010 and move #0300 to D00300 if D00100 does not contain #0010.
Incorrect
Use
Reflects CMP execution results.
(1)
(2)
The Equals Flag will turn ON if D00100 in the rung above contains #0010.
#0200 will be moved to D00200 for instruction (1), but then the Equals Flag
will be turned OFF because the #0200 source data is not 0000 Hex. The MOV
instruction at (2) will then be executed and #0300 will be moved to D0300. A
rung will therefore have to be inserted as shown below to prevent execution
results for the first MOVE instruction from being picked up.
Correct
Use
56
Precautions Section 2-2
Previous rung
Incorrect
Use
Instruction A
In this case then, instructions A and B are not differentiated instructions, the
DIFU (of DIFD) instruction is used instead as shown below and instructions A
and B are both upwardly (or downwardly) differentiated and executed for one
cycle only.
Previous rung
Correct
Use
Instruction A
Note The CS1-H, CJ1-H, or CJ1M CPU Units support instructions to save and load
the Condition Flag status (CCS(282) and CCL(283)). These can be used to
access the status of the Condition Flags at other locations in a task or in a dif-
ferent task.
Main Conditions Turning ON Condition Flags
Error Flag
The ER Flag will turn ON under special conditions, such as when operand
data for an instruction is incorrect. The instruction will not be executed when
the ER Flag turns ON.
57
Precautions Section 2-2
When the ER Flag is ON, the status of other Condition Flags, such as the <,
>, OF, and UF Flags, will not change and status of the = and N Flags will vary
from instruction to instruction.
Refer to the descriptions of individual instructions in the CS/CJ-series Pro-
grammable Controllers Programming Manual (W340) for the conditions that
will cause the ER Flag to turn ON. Caution is required because some instruc-
tions will turn OFF the ER Flag regardless of conditions.
Note The PLC Setup Settings for when an instruction error occurs determines
whether operation will stop when the ER Flag turns ON. In the default setting,
operation will continue when the ER Flag turns ON. If Stop Operation is spec-
ified when the ER Flag turns ON and operation stops (treated as a program
error), the program address at the point where operation stopped will be
stored at in A298 to A299. At the same time, A29508 will turn ON.
Equals Flag
The Equals Flag is a temporary flag for all instructions except when compari-
son results are equal (=). It is set automatically by the system, and it will
change. The Equals Flag can be turned OFF (ON) by an instruction after a
previous instruction has turned it ON (OFF). The Equals Flag will turn ON, for
example, when MOV or another move instruction moves 0000 Hex as source
data and will be OFF at all other times. Even if an instruction turns the Equals
Flag ON, the move instruction will execute immediately and the Equals Flag
will turn ON or OFF depending on whether the source data for the move
instruction is 0000 Hex or not.
Carry Flag
The CY Flag is used in shift instructions, addition and subtraction instructions
with carry input, addition and subtraction instruction borrows and carries, as
well as with Special I/O Unit instructions, PID instructions, and FPD instruc-
tions. Note the following precautions.
Note 1. The CY Flag can remain ON (OFF) because of execution results for a cer-
tain instruction and then be used in other instruction (an addition and sub-
traction instruction with carry or a shift instruction). Be sure to clear the
Carry Flag when necessary.
2. The CY Flag can be turned ON (OFF) by the execution results for a certain
instruction and be turned OFF (ON) by another instruction. Be sure the
proper results are reflected in the Carry Flag when using it.
Less Than and Greater Than Flags
The < and > Flags are used in comparison instruction, as well as in the LMT,
BAND, ZONE, PID and other instructions.
The < or > Flag can be turned OFF (ON) by another instruction even if it is
turned ON (OFF) by execution results for a certain instruction.
Negative Flag
The N Flag is turned OFF when the leftmost bit of the instruction execution
results word is 1 for certain instructions and it is turned OFF unconditionally
for other instruction.
Specifying Operands for Multiple Words
With the CS/CJ-series PLCs, an instruction will be executed as written even if
an operand requiring multiple words is specified so that all of the words for the
operand are not in the same area. In this case, words will be taken in order of
the PLC memory addresses. The Error Flag will not turn ON.
58
Precautions Section 2-2
W500
to Trans- to to
to
&10 Number of words ferred.
W511
First source word T0000
to to to to
First destination word
Instruction Combinations
The following table shows which of the special instructions can be used inside
other program sections.
Subroutine IL - ILC Step ladder FOR - NEXT JMP0 - JME0 Block program
section section loop section section
Subroutine Not possible. Not possible. Not possible. Not possible. Not possible. Not possible.
IL - ILC OK Not possible. Not possible. OK OK Not possible.
Step ladder Not possible. OK Not possible. Not possible. OK Not possible.
section
FOR - NEXT OK OK Not possible. OK OK Not possible.
loop
JMP0 - JME0 OK OK Not possible. Not possible. Not possible. Not possible.
Block pro- OK OK OK Not possible. OK Not possible.
gram section
59
Precautions Section 2-2
Note Instructions that specify program areas cannot be used for programs in other
tasks. Refer to 7DVN,QVWUXFWLRQ/LPLWDWLRQV for details.
Subroutines Place all the subroutines together just before the END(001) instruction in all
programs but after programming other than subroutines. (Therefore, a subrou-
tine cannot be placed in a step ladder, block program, FOR - NEXT, or JMP0 -
JME0 section.) If a program other than a subroutine program is placed after a
subroutine program (SBN to RET), that program will not be executed.
Program
Subroutine
Program
Subroutine
60
Precautions Section 2-2
Note 1. A step ladder program section can be used in an interlock section (be-
tween IL and ILC). The step ladder section will be completely reset when
the interlock is ON.
2. A step ladder program section can be used between MULTIPLE JUMP
(JMP0) and MULTIPLE JUMP END (JME0).
61
Precautions Section 2-2
Instructions Not Available The following instructions cannot be placed in block program sections.
in Block Program Sections Classification by Mnemonic Instruction
Function
Sequence Control FOR(512), NEXT(513), FOR, NEXT, and BREAK
and BREAK(514) LOOP
END(001) END
IL(002) and ILC(003) INTERLOCK and INTER-
LOCK CLEAR
JMP0(515) and JME0(516) MULTIPLE JUMP and
MULTIPLE JUMP END
Sequence Input UP(521) CONDITION ON
DOWN(522) CONDITION OFF
Sequence Output DIFU DIFFERENTIATE UP
DIFD DIFFERENTIATE DOWN
KEEP KEEP
OUT OUTPUT
OUT NOT OUTPUT NOT
Timer/Counter TIM TIMER
TIMH HIGH-SPEED TIMER
TMHH(540) ONE-MS TIMER
TTIM(087) ACCUMULATIVE TIMER
TIML(542) LONG TIMER
MTIM(543) MULTI-OUTPUT TIMER
CNT COUNTER
CNTR REVERSIBLE COUNTER
Subroutines SBN(092) and RET(093) SUBROUTINE ENTRY
and SUBROUTINE
RETURN
Data Shift SFT SHIFT
Ladder Step Control STEP(008) and STEP DEFINE and STEP
SNXT(009) START
Data Control PID PID CONTROL
Block Program BPRG(096) BLOCK PROGRAM
BEGIN
Damage Diagnosis FPD(269) FAILURE POINT DETEC-
TION
62
Checking Programs Section 2-3
CX-Programmer
The program will be automatically checked by the CX-Programmer at the fol-
lowing times.
Timing Checked contents
When inputting Instruction inputs, operand inputs, programming patterns
ladder diagrams
When loading All operands for all instructions and all programming patterns
files
When download- Models supported by the CS/CJ Series and all operands for all
ing files instructions
During online Capacity, etc.
editing
The results of checking are output to the text tab of the Output Window. Also,
the left bus bar of illegal program sections will be displayed in red in ladder
view.
63
Checking Programs Section 2-3
Area Check
Operand ranges Operand area ranges
Operand data types
Access check for read-only words
Operand range checks, including the following.
Constants (#, &, +, )
Control codes
Area boundary checks for multi-word operands
Size relationship checks for multi-word operands
Operand range overlaps
Multi-word allocations
Double-length operands
Area boundary checks for offsets
Program capacity Number of steps
for PLC Overall capacity
Number of tasks
Syntax Call check for paired instructions
ILILC
JMPJME, CJP/CJPN-JME
SBSSBNRET, MCROSBNRET
STEPSNXT
BPRGBEND
IFIEND
LOOPLEND
Restricted programming locations for BPRGBEND
Restricted programming locations for SBNRET
Restricted programming locations for STEPSNXT
Restricted programming locations for FORNEXT
Restricted programming locations for interrupt tasks
Required programming locations for BPRGBEND
Required programming locations for FORNEXT
Illegal nesting
END(001) instruction
Number consistency
Ladder diagram Stack overflows
structure
Output duplication Duplicate output check
By bit
By word
Timer/counter instructions
Long words (2-word and 4-word)
Multiple allocated words
Start/end ranges
FAL numbers
Instructions with multiple output operands
Tasks Check for tasks set for starting at beginning of operation
Task program allocation
Note Output duplication is not checked between tasks, only within individual tasks.
64
Checking Programs Section 2-3
Multi-word Operands Memory area boundaries are checked for multi-word operands for the pro-
gram check as shown in the following table.
CX-Programmer Programming
Consoles
The following functionality is provided by the CX-Programmer Checked when pro-
for multi-word operands that exceed a memory area boundary. grams are input, i.e.,
The program cannot be transferred to the CPU Unit. operands that
exceed a memory
The program also cannot be read from the CPU Unit. are boundary can-
Compiling errors are generated for the program check. not be written.
Warnings will appear on-screen during offline programming.
Warnings will appear on-screen during online editing in
PROGRAM or MONITOR mode.
65
Checking Programs Section 2-3
66
Checking Programs Section 2-3
In the rare even that this error does occur, it will be treated as a program error,
operation will stop (fatal error), and the UM Overflow Flag (A29515) will turn
ON.
Note If the Error Flag or Access Error Flag turns ON, it will be treated as a program
error and it can be used to stop the CPU from running. Specify operation for
program errors in the PLC Setup.
Program error Description Related flags
No END Instruction An END instruction is not present in the The No END Flag (A29511) turns ON.
program.
Error During Task Execution No task is ready in the cycle. The Task Error Flag (29512) turns ON.
No program is allocated to a task.
The corresponding interrupt task num-
ber is not present even though the exe-
cution condition for the interrupt task
was met.
Instruction Processing Error (ER Flag The wrong data values were provided The ER Flag turns ON and the Instruc-
ON) and Stop Operation set for Instruc- in the operand when an attempt was tion Processing Error Flag (A29508)
tion Errors in PLC Setup made to execute an instruction. turns ON if Stop Operation set for
Instruction Errors in PLC Setup.
Illegal Access Error (AER Flag ON) and A read or write was executed for a AER Flag turns ON and the Illegal
Stop Operation set for Instruction parameter area. Access Error Flag (A29510) turns ON if
Errors in PLC Setup A write was executed in a memory area Stop Operation set for Instruction
that is not mounted (see note). Errors in PLC Setup
A write was executed in an EM area
specified as EM File Memory.
A write was executed in a read-only
area.
The value specified in an indirect DM/
EM address in BCD mode was not
BCD.
67
Checking Programs Section 2-3
68
SECTION 3
Instruction Functions
This section outlines the instructions that can be used to write user programs.
69
Sequence Input Instructions Section 3-1
LOAD NOT Bus bar Indicates a logical start and creates an ON/OFF execution condition based
LD NOT on the reverse of the ON/OFF status of the specified operand bit. Not required
@LD NOT
%LD NOT
!LD NOT
!@LD NOT
!%LD NOT Starting
CS1-H, CJ1-H, or point of
CJ1M CPU Units block
only: @LD NOT
%LD NOT
!@LD NOT
!%LD NOT
AND Takes a logical AND of the status of the specified operand bit and the cur-
AND rent execution condition. Required
@AND
%AND
!AND
!@AND
!%AND
AND NOT Reverses the status of the specified operand bit and takes a logical AND
AND NOT with the current execution condition. Required
@AND NOT
%AND NOT
!AND NOT
!@AND NOT
!%AND NOT
CS1-H, CJ1-H, or
CJ1M CPU Units
only: @AND NOT
%AND NOT
!@AND NOT
!%AND NOT
OR Bus bar Takes a logical OR of the ON/OFF status of the specified operand bit and
OR the current execution condition. Required
@OR
%OR
!OR
!@OR
!%OR
OR NOT Bus bar Reverses the status of the specified bit and takes a logical OR with the cur-
OR NOT rent execution condition. Required
@OR NOT
%OR NOT
!OR NOT
!@OR NOT
!%OR NOT
CS1-H, CJ1-H, or
CJ1M CPU Units
only: @OR NOT
%OR NOT
!@OR NOT
!%OR NOT
70
Sequence Input Instructions Section 3-1
LD
to Logic block B
LD
to Logic block B
71
Sequence Output Instructions Section 3-2
OUTPUT NOT Reverses the result (execution condition) of the logical processing, and out- Output
OUT NOT puts it to the specified bit. Required
!OUT NOT
KEEP Output
S (Set) KEEP(011) Operates as a latching relay.
KEEP Required
!KEEP B Set
011 R (Reset)
B: Bit
Reset
S execution
condition
R execution
condition
Status of B
72
Sequence Output Instructions Section 3-2
Status of B
One cycle
DIFFERENTIATE DIFD(014) turns the designated bit ON for one cycle when the Output
DOWN DIFD(014) Required
execution condition goes from ON to OFF (falling edge).
DIFD B
!DIFD
014 B: Bit Execution condition
Status of B
One cycle
SET SET turns the operand bit ON when the execution condition is ON. Output
SET SET Required
@SET B Execution condition
%SET of SET
!SET
!@SET B: Bit
!%SET Status of B
RESET RSET turns the operand bit OFF when the execution condition is ON. Output
RSET RSET Required
@RSET B Execution condition
%RSET of RSET
!RSET
!@RSET B: Bit
!%RSET Status of B
MULTIPLE BIT SETA(530) turns ON the specified number of consecutive bits. Output
SET SETA(530) Required
SETA
@SETA D
530 N1
N2 bits are set to 1
N2 (ON).
D: Beginning
word
N1: Beginning bit
N2: Number of
bits
MULTIPLE BIT RSTA(531) turns OFF the specified number of consecutive bits. Output
RESET RSTA(531) Required
RSTA
@RSTA D
531 N1
N2 bits are reset to 0
N2 (OFF).
D: Beginning
word
N1: Beginning bit
N2: Number of
bits
73
Sequence Output Instructions Section 3-2
SINGLE BIT RSTB(533) turns OFF the specified bit in the specified word when the execu- Output
RESET RSTB(533) tion condition is ON. Required
(CS1-H, CJ1-H, Unlike the RSET instruction, RSTB(533) can be used to reset a bit in a DM or
or CJ1M only) D EM word.
RSTB N
@RSTB
!RSTB
D: Word address
533
N: Bit number
SINGLE BIT OUTB(534) outputs the result (execution condition) of the logical processing Output
OUTPUT OUTB(534) to the specified bit. Required
(CS1-H, CJ1-H, Unlike the OUT instruction, OUTB(534) can be used to control a bit in a DM
or CJ1M only) D or EM word.
OUTB N
@OUTB
!OUTB
D: Word address
534
N: Bit number
74
Sequence Control Instructions Section 3-3
Task 1 Program A
Task 2 Program B
Task n Program Z
I/O refreshing
NO OPERATION This instruction has no function. (No processing is performed for NOP(000).) Output
NOP Not required
000
INTERLOCK Interlocks all outputs between IL(002) and ILC(003) when the Output
IL IL(002) execution condition for IL(002) is OFF. IL(002) and ILC(003) are Required
002 normally used in pairs.
Execution Execution
Execution condition ON condition OFF
condition
Normal Outputs
Interlocked section execution interlocked.
of the program
75
Sequence Control Instructions Section 3-3
JUMP END Indicates the end of a jump initiated by JMP(004) or CJP(510). Output
JME JME(005) Not required
005 N
N: Jump number
CONDITIONAL Output
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 Required
CJP jumps directly to the first JME(005) in the program with the same jump
N
510 number. CJP(510) and JME(005) are used in pairs.
N: Jump number Execution Execution
condition OFF condition ON
Instructions
jumped
76
Sequence Control Instructions Section 3-3
Execution Execution
condition a ON condition a OFF
Instructions
jumped
Instructions
executed
Jumped instructions
are processed as
Execution Execution NOP(000). Instruction
condition b ON condition b OFF execution times are
the same as
NOP(000).
Instructions
executed
Instructions
jumped
MULTIPLE JUMP When the execution condition for JMP0(515) is OFF, all instructions from Output
END JME0(516) JMP0(515) to the next JME0(516) in the program are processed as NOP(000). Not required
JME0 Use JMP0(515) and JME0(516) in pairs. There is no limit on the number of
516 pairs that can be used in the program.
FOR-NEXT The instructions between FOR(512) and NEXT(513) are repeated a Output
LOOPS FOR(512) Not required
specified number of times. FOR(512) and NEXT(513) are used in
FOR pairs.
N
512
N: Number of Repeated N times
loops
Repetitions
forced to end.
Processed as
NOP(000).
FOR-NEXT The instructions between FOR(512) and NEXT(513) are repeated a specified Output
LOOPS NEXT(513) number of times. FOR(512) and NEXT(513) are used in pairs. Not required
NEXT
513
77
Timer and Counter Instructions Section 3-4
TIMX Completion
(Binary) TIMX(550) Flag
(CS1-H, CJ1-H, or
CJ1M only) N Timer input turns OFF before Completion Flag turns ON.
S
Timer input
N: Timer number
S: Set value SV
Timer PV
Completion
Flag
HIGH-SPEED TIMH(015) operates a decrementing timer with units of 10-ms. The Output
TIMER TIMH(015) Required
setting range for the set value (SV) is 0 to 99.99 s.
TIMH
N
015 Timer input
(BCD) S
Timer PV SV
N: Timer number
S: Set value
TIMHX Completion
551 TIMHX(551)
Flag
(Binary) N
(CS1-H, CJ1-H, or Timer input turns OFF before Completion Flag turns ON.
CJ1M only) S Timer input
N: Timer number
S: Set value Timer PV SV
Completion
Flag
ONE-MS TIMER TMHH(540) operates a decrementing timer with units of 1-ms. The setting Output
TMHH TMHH(540) range for the set value (SV) is 0 to 9.999 s. Required
540 N
(BCD) The timing charts for TMHH(540) are the same as those given above for
S TIMH(015).
N: Timer number
S: Set value
TMHHX
552 TMHHX(552)
(BCD) N
(CS1-H, CJ1-H, or
CJ1M only) S
N: Timer number
S: Set value
78
Timer and Counter Instructions Section 3-4
LONG TIMER TIML(542) operates a decrementing timer with units of 0.1-s that can Output
TIML TIML(542) Required
time up to 9999999.9 S (approx. 115 days).
542 D1
(BCD) Timer input
D2
S SV
Timer PV
D1: Completion
Flag
D2: PV word
S: SV word
Completion Flag
TIMLX (Bit 00 of D1)
553 TIMLX(553)
(Binary) D1
(CS1-H, CJ1-H, or
CJ1M only) D2
S
D1: Completion
Flag
D2: PV word
S: SV word
79
Timer and Counter Instructions Section 3-4
D1: Completion 0
Flags
D2: PV word
S: 1st SV word
MTIMX to to
554 MTIMX(554)
(Binary) D1
(CS1-H, CJ1-H, or
CJ1M only) D2 Timer input
S
SV 7
D1: Completion to
Flags SV 2
D2: PV word Timer PV (D2) SV 1
S: 1st SV word
SV 0
0
Bit 7
Completion to
flags (D1) Bit 2
Bit 1
Bit 0
COUNTER Count CNT operates a decrementing counter. The setting range for the set Output
CNT input CNT Required
value (SV) is 0 to 9,999.
(BCD) N
Count input
S
Reset
input
N: Counter Reset input
number
S: Set value Counter PV SV
CNTX
Count CNTX(546)
546 input
(Binary) N
(CS1-H, CJ1-H, or S Completion
CJ1M only) Flag
Reset
input
N: Counter
number
S: Set value
80
Timer and Counter Instructions Section 3-4
N: Counter
number
S: Set value
Counter PV
CNTRX Incre-
548 CNTRX(548)
ment
(Binary) input N
(CS1-H, CJ1-H, or SV
Decre- Counter PV
CJ1M only) S
ment
input +1
Reset
input
SV 1
Counter PV
Completion Flag
RESET TIMER/ Resets the timers or counters within the specified range of timer or counter Output
COUNTER CNR(545) numbers. Sets the set value (SV) to the maximum of 9999. Required
CNR N1
@CNR
545 N2
(BCD)
N1: 1st number in
range
N2: Last number
in range
CNRX
@CNRX CNRX(547)
547 N1
(Binary)
(CS1-H, CJ1-H, or N2
CJ1M only)
N1: 1st number in
range
N2: Last number
in range
81
Comparison Instructions Section 3-5
ON execution condition
AND when comparison result
is true.
<
OR
<
Symbol Compari- S1: Comparison Symbol comparison instructions (double-word, unsigned) compare two values
son (Double- data 1 (constants and/or the contents of specified double-word data) in unsigned 32-bit LD: Not
word, unsigned) S2: Comparison binary data and create an ON execution condition when the comparison condi- required
LD, AND, OR + =, tion is true. There are three types of symbol comparison instructions, LD AND, OR:
data 2 (LOAD), AND, and OR.
<>, <, <=, >, >= + Required
L
301 (=)
306 (<>)
311 (<)
316 (<=)
321 (>)
326 (>=)
Symbol Compari- S1: Comparison Symbol comparison instructions (signed) compare two values (constants and/or
son (Signed) data 1 the contents of specified words) in signed 16-bit binary (4-digit hexadecimal) LD: Not
LD, AND, OR + =, S2: Comparison and create an ON execution condition when the comparison condition is true. required
<>, <, <=, >, >= There are three types of symbol comparison instructions, LD (LOAD), AND, and AND, OR:
data 2 OR.
+S Required
302 (=)
307 (<>)
312 (<)
317 (<=)
322 (>)
327 (>=)
82
Comparison Instructions Section 3-5
DOUBLE Compares two double unsigned binary values (constants and/or the Output
UNSIGNED COM- CMPL(060)
contents of specified words) and outputs the result to the Arithmetic Required
PARE Flags in the Auxiliary Area.
S1
CMPL
060 S2 Unsigned binary
comparison
S1: Comparison S1+1 S2+1
data 1
S2: Comparison Arithmetic Flags
data 2 (>, >=, =, <=, <, <>)
SIGNED BINARY Compares two signed binary values (constants and/or the contents of Output
COMPARE CPS(114) Required
specified words) and outputs the result to the Arithmetic Flags in the
CPS S1 Auxiliary Area.
!CPS
114 S2 Signed binary
comparison
S1: Comparison
data 1
S2: Comparison Arithmetic Flags
data 2 (>, >=, =, <=, <, <>)
DOUBLE Compares two double signed binary values (constants and/or the Output
SIGNED BINARY CPSL(115)
contents of specified words) and outputs the result to the Arithmetic Required
COMPARE Flags in the Auxiliary Area.
S1
CPSL
115 S2 Signed binary
comparison
S1: Comparison S1+1 S2+1
data 1
S2: Comparison
data 2 Arithmetic Flags
(>, >=, =, <=, <, <>)
R 0: Words
are equal.
1: Words
S1: 1st word of aren't
set 1 equal.
S2: 1st word of
set 2
R: Result word
83
Comparison Instructions Section 3-5
UNSIGNED Compares the source data to 16 ranges (defined by 16 lower limits Output
BLOCK BCMP(068)
and 16 upper limits) and turns ON the corresponding bit in the result Required
COMPARE
S word when the source data is within the range.
BCMP
@BCMP T Ranges 1: In range
068 0: Not in range
R
Lower limit Upper limit R
S: Source data T to T+1 0
T: 1st word of
table T+2 to T+3 1
R: Result word Source data
S
T+28 to T+29 14
T+30 to T+31 15
EXPANDED Compares the source data to up to 256 ranges (defined by upper and lower limits) Output
BLOCK COM- BCMP2(502)
and turns ON the corresponding bit in the result word when the source data is Required12
PARE 7
S within a range.
BCMP2
@BCMP2 T 1: In range
502 T N n=255 max. 0: Not in range
84
Comparison Instructions Section 3-5
CD: Compare
data (1 word)
LL: Lower limit of
range
UL: Upper limit of
range
DOUBLE AREA Compares the 32-bit unsigned binary value in CD and CD+1 (word contents or Output
RANGE COM- ZCPL(116) constant) to the range defined by LL and UL and outputs the results to the Arith- Required
PARE metic Flags in the Auxiliary Area.
(CS1-H, CJ1-H, CD
or CJ1M only) LL
ZCPL
@ZCPL UL
116
CD: Compare
data (2 words)
LL: Lower limit of
range
UL: Upper limit of
range
85
Data Movement Instructions Section 3-6
Destination word
DOUBLE MOVE Transfers two words of data to the specified words. Output
MOVL MOVL(498) Required
S S+1
@MOVL S
498
D
Bit status
S: 1st source not changed.
word
D: 1st destination D D+1
word
Destination word
DOUBLE MOVE Transfers the complement of two words of data to the specified words. Output
NOT MVNL(499)
S S+1
Required
MVNL S
@MVNL
499 D
S: 1st source Bit status
word inverted.
D: 1st destination D D+1
word
S: Source word or
data
C: Control word
D: Destination
word
86
Data Movement Instructions Section 3-6
BLOCK Output
TRANSFER XFER(070)
Transfers the specified number of consecutive words.
Required
XFER
@XFER N
070 S N words
to to
D
S+(N1) D+(N1)
N: Number of
words
S: 1st source
word
D: 1st destination
word
BLOCK SET Copies the same word to a range of consecutive words. Output
BSET BSET(071) Required
@BSET Source word Destination words
S
071 St
St
E
S: Source word
St: Starting word
E: End word
E
87
Data Movement Instructions Section 3-6
SINGLE WORD Transfers the source word to a destination word calculated by adding Output
DISTRIBUTE DIST(080)
an offset value to the base address. Required
DIST S
@DIST
Bs S Bs Of
080
Of
S: Source word
Bs: Destination
base address
Of: Offset
Bs+n
DATA COLLECT Transfers the source word (calculated by adding an offset value to the Output
COLL(081)
COLL base address) to the destination word. Required
@COLL Bs
081 Bs Of
Of
D
MOVE TO Output
MOVR(560) Sets the PC memory address of the specified word, bit, or
REGISTER timer/counter Completion Flag in the specified Index Register. (Use Required
MOVR S MOVRW(561) to set the PC memory address of a timer/counter PV in
@MOVR an Index Register.)
560 D
I/O memory address of S
S: Source
(desired word or
bit)
D: Destination
(Index Register)
Index Register
Index Register
88
Data Shift Instructions Section 3-7
REVERSIBLE Creates a shift register that shifts data to either the right or the left. Output
SHIFT REGISTER SFTR(084) Required
SFTR C
@SFTR
084 St
E St Data input
E
Shift
C: Control word direc-
E St tion
St: Starting word Data
E: End word input
ASYNCHRO- Output
Shifts all non-zero word data within the specified word range either
NOUS SHIFT ASFT(017) towards St or toward E, replacing 0000Hex word data. Required
REGISTER
ASFT C
@ASFT St
017
E St
Shift direction
C: Control word Shift Shift enabled
St: Starting word
E: End word Clear
Shift
St
Non-zero data
Zero data
E
S: Source word
St: Starting word
E: End word
ARITHMETIC Output
SHIFT LEFT ASL(025) Shifts the contents of Wd one bit to the left.
Required
ASL Wd
@ASL
025 Wd: Word
15 0
89
Data Shift Instructions Section 3-7
ARITHMETIC Output
Shifts the contents of Wd one bit to the right.
SHIFT RIGHT ASR(026) Required
ASR
@ASR Wd
026 Wd: Word
DOUBLE SHIFT Shifts the contents of Wd and Wd +1 one bit to the right. Output
RIGHT ASRL(571) Required
ASRL Wd Wd+1 Wd
@ASRL
571 Wd: Word
ROTATE LEFT Shifts all Wd bits one bit to the left including the Carry Flag (CY). Output
ROL ROL(027) Required
@ROL Wd
027
Wd: Word
DOUBLE Shifts all Wd and Wd +1 bits one bit to the left including the Carry Flag Output
ROTATE LEFT ROLL(572)
(CY). Required
ROLL Wd
@ROLL Wd+1 Wd
572 Wd: Word
ROTATE LEFT Shifts all Wd bits one bit to the left not including the Carry Flag (CY). Output
WITHOUT RLNC(574) Required
CARRY
RLNC Wd Wd
@RLNC
Wd: Word
574
DOUBLE Shifts all Wd and Wd +1 bits one bit to the left not including the Carry Output
ROTATE LEFT RLNL(576) Required
Flag (CY).
WITHOUT
CARRY Wd Wd+1 Wd
RLNL
@RLNL Wd: Word
576
ROTATE RIGHT Shifts all Wd bits one bit to the right including the Carry Flag (CY). Output
ROR ROR(028) Required
@ROR Wd+1 Wd
Wd
028
Wd: Word
DOUBLE Shifts all Wd and Wd +1 bits one bit to the right including the Carry Output
ROTATE RIGHT RORL(573) Required
Flag (CY).
RORL Wd
@RORL Wd+1 Wd
573 Wd: Word
90
Data Shift Instructions Section 3-7
DOUBLE Shifts all Wd and Wd +1 bits one bit to the right not including the Carry Output
ROTATE RIGHT RRNL(577) Required
Flag (CY). The contents of the rightmost bit of Wd +1 is shifted to the
WITHOUT leftmost bit of Wd, and to the Carry Flag (CY).
CARRY Wd
RRNL Wd+1 Wd
@RRNL Wd: Word
577
ONE DIGIT SHIFT Shifts data by one digit (4 bits) to the right. Output
RIGHT SRD(075) Required
E St
SRD St
@SRD Lost
075 E
St: Starting word
E: End word
SHIFT N-BIT Shifts the specified number of bits to the left. Output
DATA LEFT NSFL(578) Required
NSFL
@NSFL D
578 C
N
SHIFT N-BIT Shifts the specified number of bits to the right. Output
DATA RIGHT NSFR(579) Required
NSFR D
@NSFR
579 C
N
Shifts one bit to the right
D: Beginning N1 bit
word for shift
C: Beginning bit
N: Shift data
length
N1 bit
91
Data Shift Instructions Section 3-7
N bits
DOUBLE SHIFT Shifts the specified 32 bits of word data to the left by the specified Output
N-BITS LEFT NSLL(582) Required
number of bits.
NSLL D
@NSLL
582 C
Shift nbits
D: Shift word
C: Control word
Contents of
"a" or "0"
shifted in
Lost
N bits
SHIFT N-BITS Shifts the specified 16 bits of word data to the right by the specified Output
RIGHT NASR(581)
number of bits. Required
NASR D
@NASR
581 C
Contents of "a" or
D: Shift word "0" shifted in
C: Control word Lost
N bits
DOUBLE SHIFT Shifts the specified 32 bits of word data to the right by the specified Output
N-BITS RIGHT NSRL(583)
number of bits. Required
NSRL D
@NSRL
583 C Shift nbits
D: Shift word
C: Control word Contents of
"a" or "0"
shifted in
Lost
92
Increment/Decrement Instructions Section 3-8
DOUBLE INCRE- Increments the 8-digit hexadecimal content of the specified words by 1. Output
MENT BINARY ++L(591) Required
++L Wd
@++L Wd+1 Wd Wd+1 Wd
591 Wd: Word
DECREMENT Decrements the 4-digit hexadecimal content of the specified word by 1. Output
BINARY (592) Required
@ Wd Wd Wd
592 Wd: Word
DECREMENT Decrements the 4-digit BCD content of the specified word by 1. Output
BCD B(596) Required
B
@ B Wd
Wd 1 Wd
596 Wd: Word
93
Symbol Math Instructions Section 3-9
DOUBLE Adds 8-digit (double-word) hexadecimal data and/or constants with the Output
SIGNED BINARY +CL(403) Required
Carry Flag (CY).
ADD WITH
CARRY Au Au+1 Au (Signed binary)
+CL Ad
@+CL Ad+1 Ad (Signed binary)
403 R
+ CY
Au: 1st augend
word CY will turn
Ad: 1st addend ON when there CY R+1 R (Signed binary)
word is a carry.
R: 1st result word
BCD ADD Adds 4-digit (single-word) BCD data and/or constants. Output
WITHOUT +B(404) Required
CARRY Au (BCD)
Au
+B
@+B Ad Ad (BCD)
+
404
R
CY will turn
Au: Augend word ON when there CY R (BCD)
Ad: Addend word is a carry.
R: Result word
94
Symbol Math Instructions Section 3-9
BCD ADD WITH Adds 4-digit (single-word) BCD data and/or constants with the Carry Flag Output
CARRY +BC(406) (CY). Required
+BC
@+BC Au Au (BCD)
406 Ad
Ad (BCD)
R
+ CY
Au: Augend word
Ad: Addend word CY will turn
R: Result word ON when there (BCD)
is a carry. CY R
DOUBLE BCD Adds 8-digit (double-word) BCD data and/or constants with the Carry Flag Output
ADD WITH +BCL(407) (CY). Required
CARRY
Au Au +1 Au (BCD)
+BCL
@+BCL Ad
407 Ad+1 Ad (BCD)
R
+ CY
Au: 1st augend word
Ad: 1st addend word CY will turn
R: 1st result word ON when there (BCD)
is a carry. CY R+1 R
SIGNED BINARY Subtracts 4-digit (single-word) hexadecimal data and/or constants. Output
SUBTRACT (410) Required
WITHOUT Mi (Signed binary)
CARRY Mi
Su (Signed binary)
@ Su
410 R
Mi: Minuend word CY will turn ON CY R (Signed binary)
Su: Subtrahend when there is a
word borrow.
R: Result word
SIGNED BINARY Subtracts 4-digit (single-word) hexadecimal data and/or constants with the Output
SUBTRACT C(412) Carry Flag (CY). Required
WITH CARRY Mi (Signed binary)
C Mi
@C Su Su (Signed binary)
412
R
CY
Mi: Minuend word CY will turn
Su: Subtrahend ON when there (Signed binary)
word CY R
is a borrow.
R: Result word
95
Symbol Math Instructions Section 3-9
BCD SUBTRACT Subtracts 4-digit (single-word) BCD data and/or constants. Output
WITHOUT B(414) Required
CARRY Mi (BCD)
Mi
B
@B Su Su (BCD)
414
R
CY will turn
ON when there CY R (BCD)
Mi: Minuend word
Su: Subtrahend is a carry.
word
R: Result word
96
Symbol Math Instructions Section 3-9
Md: 1st
multiplicand word R+3 R+2 R+1 R (Signed binary)
Mr: 1st multiplier
word
R: 1st result word
UNSIGNED Output
Multiplies 4-digit unsigned hexadecimal data and/or constants.
BINARY *U(422) Required
MULTIPLY
*U Md Md (Unsigned binary)
@*U
Mr
422 (Unsigned binary)
Mr
R
Md: Multiplicand
word R +1 R (Unsigned binary)
Mr: Multiplier
word
R: Result word
97
Symbol Math Instructions Section 3-9
Md: 1st
multiplicand word (BCD)
Mr: 1st multiplier R+3 R+2 R+1 R
word
R: 1st result word
SIGNED BINARY Divides 4-digit (single-word) signed hexadecimal data and/or constants. Output
DIVIDE /(430) Required
/
@/
Dd Dd (Signed binary)
430 Dr
Dr (Signed binary)
R
Dd: Dividend
word R +1 R (Signed binary)
Dr: Divisor word
R: Result word Remainder Quotient
DOUBLE Divides 8-digit (double-word) signed hexadecimal data and/or constants. Output
SIGNED BINARY /L(431) Required
DIVIDE
/L Dd Dd + 1 Dd (Signed binary)
@/L Dr
431 (Signed binary)
R Dr + 1 Dr
UNSIGNED Output
Divides 4-digit (single-word) unsigned hexadecimal data and/or constants.
BINARY DIVIDE /U(432) Required
/U
@/U Dd
Dd (Unsigned binary)
432 Dr
R Dr (Unsigned binary)
Dd: Dividend
word
Dr: Divisor word R +1 R (Unsigned binary)
R: Result word
Remainder Quotient
98
Conversion Instructions Section 3-10
DOUBLE BCD Divides 8-digit (double-word) BCD data and/or constants. Output
DIVIDE /BL(435) Required
/BL
@/BL Dd Dd + 1 Dd (BCD)
435 Dr
R Dr + 1 Dr (BCD)
DOUBLE Converts 8-digit hexadecimal (32-bit binary) data to 8-digit BCD data. Output
BINARY-TO- BCDL(059) Required
DOUBLE BCD
S (BIN) R (BCD)
BCDL
@BCDL R (BIN) R+1 (BCD)
059
S: 1st source
word
R: 1st result word
99
Conversion Instructions Section 3-10
DOUBLE 2S Output
COMPLEMENT NEGL(161) Calculates the 2's complement of two words of hexadecimal data.
Required
NEGL S 2's complement
@NEGL (Complement + 1)
161 R (S+1, S) (R+1, R)
S: 1st source
word
R: 1st result word
16-BIT TO 32-BIT Expands a 16-bit signed binary value to its 32-bit equivalent. Output
SIGNED BINARY SIGN(600) Required
SIGN MSB
@SIGN S
600 R S
MSB = 1: MSB = 0:
S: Source word 0000 Hex
R: 1st result word FFFF Hex
D+1 D
D = Contents of S
100
Conversion Instructions Section 3-10
R
R+1
C
l=1 (Convert 2 bytes.)
R+1
R+14
R+15
R+16
R+17
Two 16-word ranges
are used when l
R+30 specifies 2 bytes.
R+31
101
Conversion Instructions Section 3-10
S: Source word
Di: Digit
designator
D: 1st destination Number of
word digits (n+1)
102
Conversion Instructions Section 3-10
COLUMN TO Output
LINE LINE(063) Converts a column of bits from a 16-word range (the same bit number in 16
consecutive words) to the 16 bits of the destination word. Required
LINE
@LINE S N
Bit Bit
063 N 15 00
D 0 0 0 1 1 1 1 0 0 0 1 0 0 0 0 1
S
S: 1st source S+1 1 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1
word S+2 0 0 0 1 1 0 1 1 0 0 1 0 0 1 1 1
N: Bit number
D: Destination S+3 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1
word . . . .
. . . .
. . . .
S+15 0 1 1 0 0 0 0 1 1 0 0 0 1 0 1 0
Bit Bit
15 00
D 0 . . . 0 1 1 1
LINE TO COL- Converts the 16 bits of the source word to a column of bits in a 16-word range Output
UMN COLM(064)
of destination words (the same bit number in 16 consecutive words). Required
COLM
@COLM S
064 D Bit Bit
15 00
N
S 0 . . . . . . . 0 1 1 1
S: Source word
D: 1st destination
word
N: Bit number
Bit Bi Bit
15 00
D 0 0 0 0 1 1 1 0 0 0 1 0 0 0 0 1
D+1 1 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1
D+2 0 0 0 1 1 0 1 1 0 0 1 0 0 1 1 1
D+3 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1
. . . .
. . . .
. . . .
D+15 0 1 1 1 0 0 0 1 1 0 0 0 1 0 1 0
103
Conversion Instructions Section 3-10
DOUBLE Converts double signed BCD data to double signed binary data. Output
SIGNED BCD- BISL(472) Required
TO-BINARY
BISL C
@BISL S Signed BCD format
472 specified in C
D
Signed BCD Signed binary
C: Control word Signed BCD Signed binary
S: 1st source
word
D: 1st destination
word
SIGNED BINARY- Converts one word of signed binary data to one word of signed BCD data. Output
TO-BCD BCDS(471) Required
BCDS
@BCDS C
471 S Signed BCD format
specified in C
D
Signed binary Signed BCD
C: Control word
S: Source word
D: Destination
word
DOUBLE Converts double signed binary data to double signed BCD data. Output
SIGNED BINARY- BDSL(473) Required
TO-BCD
BDSL C
@BDSL S
473 Signed BCD format
D specified in C
104
Logic Instructions Section 3-11
DOUBLE LOGI- Takes the logical AND of corresponding bits in double words of word data Output
CAL AND ANDL(610) and/or constants. Required
ANDL
I1
@ANDL (I1, I1+1). (I2, I2+1) (R, R+1)
610 I2
I1, I1+1 I2, I2+1 R, R+1
R
1 1 1
I1: Input 1 1 0 0
I2: Input 2
R: Result word 0 1 0
0 0 0
LOGICAL OR Takes the logical OR of corresponding bits in single words of word data Output
ORW ORW(035) and/or constants. Required
@ORW I1
035 I1 + I2 R
I2 I1 I2 R
R 1 1 1
I1: Input 1 1 0 1
I2: Input 2
R: Result word 0 1 1
0 0 0
EXCLUSIVE OR Takes the logical exclusive OR of corresponding bits in single words of word Output
XORW XORW(036) Required
data and/or constants.
@XORW I1
036 I1. I2 + I1.I2 R
I2 I1 I2 R
R 1 1 0
I1: Input 1 1 0 1
I2: Input 2
R: Result word 0 1 1
0 0 0
105
Logic Instructions Section 3-11
EXCLUSIVE NOR Takes the logical exclusive NOR of corresponding single words of word data Output
XNRW XNRW(037) Required
and/or constants.
@XNRW I1 I1. I2 + I1.I2 R
037
I2 I1 I2 R
R 1 1 1
I1: Input 1 1 0 0
I2: Input 2 0 1 0
R: Result word
0 0 1
DOUBLE Takes the logical exclusive NOR of corresponding bits in double words of Output
EXCLUSIVE NOR XNRL(613) Required
word data and/or constants.
XNRL I1
@XNRL (I1, I1+1). (I2, I2+1) + (I1, I1+1). (I2, I2+1) (R, R+1)
613 I2
I1, I1+1 I2, I2+1 R, R+1
R
1 1 1
I1: Input 1 1 0 0
I2: Input 2
R: 1st result word 0 1 0
0 0 1
COMPLEMENT Turns OFF all ON bits and turns ON all OFF bits in Wd. Output
COM COM(029) Required
@COM Wd WdWd: 1 0 and 0 1
029
Wd: Word
DOUBLE COM- Turns OFF all ON bits and turns ON all OFF bits in Wd and Wd+1. Output
PLEMENT COML(614) Required
COML
Wd (Wd+1, Wd)(Wd+1, Wd)
@COML
614 Wd: Word
106
Special Math Instructions Section 3-12
BCD SQUARE Computes the square root of an 8-digit BCD number and outputs the integer Output
ROOT ROOT(072) portion of the result to the specified result word. Required
ROOT S
@ROOT
072 R S+1 S R
S: 1st source BCD data (8 digits) BCD data (4 digits)
word
R: Result word
ARITHMETIC Calculates the sine, cosine, or a linear extrapolation of the source data. Output
PROCESS APR(069) The linear extrapolation function allows any relationship between X and Y to be Required
APR approximated with line segments.
@APR
C
069 S
R
C: Control word
S: Source data
R: Result word
FLOATING Output
POINT DIVIDE FDIV(079) Divides one 7-digit floating-point number by another. The floating-point
numbers are expressed in scientific notation (7-digit mantissa and 1-digit Required
FDIV Dd exponent).
@FDIV
Dr Quotient
079
R R+1 R
BIT COUNTER Counts the total number of ON bits in the specified word(s). Output
BCNT BCNT(067) Required
@BCNT N
067 N words
S Counts the number
to of ON bits.
R
S+(N1) Binary result
N: Number of
words
S: 1st source R
word
R: Result word
107
Floating-point Math Instructions Section 3-13
108
Floating-point Math Instructions Section 3-13
FLOATING- Divides one 32-bit floating-point number by another and places the result in Output
POINT DIVIDE /F(457) the specified result words. Required
/F
@/F Dd
Dd+1 Dd Dividend (floating-
457 Dr point data, 32 bits)
R
Dr+1 Dr Divisor (floating-
point data, 32 bits)
Dd: 1st Dividend
word
Dr: 1st Divisor R+1 R Result (floating-
word
R: 1st result word point data, 32 bits)
DEGREES TO Converts a 32-bit floating-point number from degrees to radians and places Output
RADIANS RAD(458) Required
the result in the specified result words.
RAD S
@RAD
458 R S+1 S Source (degrees, 32-bit
floating-point data)
S: 1st source
word R+1 R Result (radians, 32-bit
R: 1st result word
floating-point data)
RADIANS TO Converts a 32-bit floating-point number from radians to degrees and places Output
DEGREES DEG(459) the result in the specified result words. Required
DEG S
@DEG
459 R S+1 S Source (radians, 32-bit
floating-point data)
S: 1st source
word
R: 1st result word R+1 R Result (degrees, 32-bit
floating-point data)
SINE Calculates the sine of a 32-bit floating-point number (in radians) and places Output
SIN SIN(460) Required
the result in the specified result words.
@SIN
S
460
R SIN S+1 S Source (32-bit
floating-point
S: 1st source data)
word
R: 1st result word R+1 R Result (32-bit
floating-point
data)
COSINE Calculates the cosine of a 32-bit floating-point number (in radians) and places Output
COS COS(461) the result in the specified result words. Required
@COS S Source (32-bit
461 COS S+1 S floating-point
R data)
S: 1st source
word
R: 1st result word R+1 R Result (32-bit
floating-point
data)
109
Floating-point Math Instructions Section 3-13
110
Floating-point Math Instructions Section 3-13
Floating Symbol Using LD: Compares the specified single-precision data (32 bits) or constants and creates LD:
Comparison an ON execution condition if the comparison result is true. Not required
(CS1-H, CJ1-H, Symbol, option
Three kinds of symbols can be used with the floating-point symbol comparison
or CJ1M only) S1 instructions: LD (Load), AND, and OR. AND or OR:
LD, AND. or OR S2 Required
+
=F (329), Using AND:
<>F (330), Symbol, option
<F (331),
<=F (332), S1
>F (333), S2
or >=F (334)
Using OR:
Symbol, option
S1
S2
S1: Comparison data 1
S2: Comparison data 2
111
Double-precision Floating-point Instructions (CS1-H, CJ1-H, or CJ1M Only) Section 3-14
ASCII TO FLOAT- Converts the specified text string (ASCII) representation of single-precision Output
ING-POINT FVAL(449) floating-point data (decimal-point or exponential format) to 32-bit single-preci- required
(CS1-H, CJ1-H, sion floating-point data and outputs the result to the destination words.
or CJ1M only) S
FVAL D
@FVAL
449 S: Source word
D: 1st destination
word
DOUBLE FLOAT- Converts the specified double-precision floating-point data (64 bits) to 32-bit Output
ING TO 32-BIT FIXLD(842) signed binary data and outputs the result to the destination words. Required
BINARY
FIXLD
S
@FIXLD D
842
S: 1st source
word
D: 1st destination
word
16-BIT BINARY Converts the specified 16-bit signed binary data to double-precision floating- Output
TO DOUBLE DBL(843) point data (64 bits) and outputs the result to the destination words. Required
FLOATING
DBL
S
@DBL D
843
S: Source word
D: 1st destination
word
112
Double-precision Floating-point Instructions (CS1-H, CJ1-H, or CJ1M Only) Section 3-14
DOUBLE FLOAT- Adds the specified double-precision floating-point values (64 bits each) and Output
ING-POINT ADD +D(845) outputs the result to the result words. Required
+D Au
@+D
845 Ad
R
Au: 1st augend
word
Ad: 1st addend
word
R: 1st result word
DOUBLE FLOAT- Subtracts the specified double-precision floating-point values (64 bits each) Output
ING-POINT SUB- D(846) and outputs the result to the result words. Required
TRACT
-D
Mi
@- D Su
846
R
Mi: 1st minuend
word
Su: 1st subtra-
hend word
R: 1st result word
DOUBLE FLOAT- Multiplies the specified double-precision floating-point values (64 bits each) and Output
ING-POINT MUL- *D(847) outputs the result to the result words. Required
TIPLY
D
Md
@D Mr
847
R
Md: 1st multipli-
cand word
Mr: 1st multiplier
word
R: 1st result word
DOUBLE FLOAT- Divides the specified double-precision floating-point values (64 bits each) and Output
ING-POINT /D(848) outputs the result to the result words. Required
DIVIDE
/D
Dd
@/D Dr
848
R
Dd: 1st Dividend
word
Dr: 1st divisor
word
R: 1st result word
DOUBLE Converts the specified double-precision floating-point data (64 bits) from Output
DEGREES TO RADD(849) degrees to radians and outputs the result to the result words. Required
RADIANS
RADD
S
@RADD R
849
S: 1st source
word
R: 1st result word
113
Double-precision Floating-point Instructions (CS1-H, CJ1-H, or CJ1M Only) Section 3-14
DOUBLE SINE Calculates the sine of the angle (radians) in the specified double-precision Output
SIND(851) floating-point data (64 bits) and outputs the result to the result words.
SIND Required
@SIND S
851
R
S: 1st source
word
R: 1st result word
DOUBLE Calculates the cosine of the angle (radians) in the specified double-precision Output
COSINE COSD(852) floating-point data (64 bits) and outputs the result to the result words. Required
COSD S
@COSD
852 R
S: 1st source
word
R: 1st result word
DOUBLE TAN- Calculates the tangent of the angle (radians) in the specified double-precision Output
GENT TAND(853) floating-point data (64 bits) and outputs the result to the result words. Required
TAND S
@TAND
853 R
S: 1st source
word
R: 1st result word
DOUBLE ARC Calculates the angle (in radians) from the sine value in the specified double- Output
SINE ASIND(854) precision floating-point data (64 bits) and outputs the result to the result words. Required
ASIND (The arc sine function is the inverse of the sine function; it returns the angle that
@ASIND
S produces a given sine value between -1 and 1.)
854 R
S: 1st source
word
R: 1st result word
DOUBLE ARC Calculates the angle (in radians) from the cosine value in the specified double- Output
COSINE ACOSD(855) precision floating-point data (64 bits) and outputs the result to the result words. Required
ACOSD (The arc cosine function is the inverse of the cosine function; it returns the
@ACOSD
S angle that produces a given cosine value between -1 and 1.)
855 R
S: 1st source
word
R: 1st result word
DOUBLE ARC Calculates the angle (in radians) from the tangent value in the specified double- Output
TANGENT ATAND(856) precision floating-point data (64 bits) and outputs the result to the result words. Required
ATAND (The arc tangent function is the inverse of the tangent function; it returns the
@ATAND
S angle that produces a given tangent value.)
856 R
S: 1st source
word
R: 1st result word
114
Double-precision Floating-point Instructions (CS1-H, CJ1-H, or CJ1M Only) Section 3-14
DOUBLE EXPO- Calculates the natural (base e) exponential of the specified double-precision Output
NENT EXPD(858) floating-point data (64 bits) and outputs the result to the result words. Required
EXPD S
@EXPD
858 R
S: 1st source
word
R: 1st result word
DOUBLE LOGA- Calculates the natural (base e) logarithm of the specified double-precision float- Output
RITHM LOGD(859) ing-point data (64 bits) and outputs the result to the result words. Required
LOGD S
@LOGD
859 R
S: 1st source
word
R: 1st result word
DOUBLE EXPO- Raises a double-precision floating-point number (64 bits) to the power of Output
NENTIAL PWRD(860) another double-precision floating-point number and outputs the result to the Required
POWER result words.
PWRD
B
@PWRD E
860
R
B: 1st base word
E: 1st exponent
word
R: 1st result word
DOUBLE SYM- Using LD: Compares the specified double-precision data (64 bits) and creates an ON exe- LD:
BOL COMPARI- cution condition if the comparison result is true. Not required
SON Symbol, option
Three kinds of symbols can be used with the floating-point symbol comparison
LD, AND. or OR S1 instructions: LD (Load), AND, and OR. AND or OR:
+ S2 Required
=D (335),
<>D (336), Using AND:
<D (337), Symbol, option
<=D (338),
>D (339), S1
or >=D (340) S2
Using OR:
Symbol, option
S1
S2
S1: Comparison data 1
S2: Comparison data 2
115
Table Data Processing Instructions Section 3-15
PUSH ONTO Writes one word of data to the specified stack. Output
STACK PUSH(632)
Required
PUSH PLC memory PLC memory
@PUSH
TB address address
632 S
TB TB
TB+1 TB+1
TB: 1st stack TB+2 TB+2
address TB+3 PUSH(632) TB+3
S: Source word
LAST IN FIRST Reads the last word of data written to the specified stack (the newest data in the Output
OUT LIFO(634) Required
stack).
LIFO
@LIFO
TB
Stack PLC memory PLC memory
634 D pointer address address
TB TB
TB: 1st stack
address TB+1 Newest TB+1
D: Destination data
TB+2 TB+2
word TB+3 TB+3 m1
Stack
pointer
m1 m1 A is
left un-
chang-
ed.
FIRST IN FIRST Reads the first word of data written to the specified stack (the oldest data in the Output
OUT FIFO(633)
stack). Required
FIFO TB PLC memory PLC memory
@FIFO address address
633 D TB TB
Oldest
Stack TB+1 data TB+1
TB: 1st stack pointer TB+2 TB+2
address m1
D: Destination TB+3 TB+3
word Stack
pointer
m1
First-in first-out
116
Table Data Processing Instructions Section 3-15
SET RECORD Writes the location of the specified record (the PLC memory address of the Output
LOCATION SETR(635)
beginning of the record) in the specified Index Register. Required
SETR N
@SETR PLC memory
Table number (N) address
635 R
SETR(635) writes the PLC memory ad-
D dress (m) of the first word of record R
R to Index Register D.
N: Table number
R: Record Record
number number (R)
D: Destination
Index Register
GET RECORD Returns the record number of the record at the PLC memory address contained Output
NUMBER GETR(636)
in the specified Index Register. Required
GETR N
@GETR Table number (N) PLC memory
636 IR address
D GETR(636) writes
the record number of
N: Table number IR Record number the record that in-
IR: Index Register (R) cludes I/O memory
D: Destination address (m) to D.
word
DATA SEARCH Searches for a word of data within a range of words. Output
SRCH(181)
SRCH Required
@SRCH C PLC memory
181 address
R1
R1 Search
Cd
C Cd
C: 1st control
word
R1: 1st word in
range R1+(C1)
Cd: Comparison Match
data
117
Table Data Processing Instructions Section 3-15
SUM Adds the bytes or words in the range and outputs the result to two words. Output
SUM SUM(184) Required
@SUM
C
184
R1
D R1
C: 1st control
word
R1: 1st word in R1+(W1)
range )
D: 1st destination
word
FRAME Calculates the ASCII FCS value for the specified range. Output
CHECKSUM FCS(180) Required
FCS C R1
@FCS
180 R1 C units
D
118
Table Data Processing Instructions Section 3-15
STACK DATA Reads the data from the specified data element in the stack. The offset value Output
READ SREAD(639) indicates the location of the desired data element (how many data elements required
(CS1-H, CJ1-H, before the current pointer position).
or CJ1M only) TB
SREAD C
@SREAD
639 D
TB: First stack
address
C: Offset value
D: Destination
word
STACK DATA Writes the source data to the specified data element in the stack (overwriting the Output
OVERWRITE SWRIT(640) existing data). The offset value indicates the location of the desired data element required
(CS1-H, CJ1-H, (how many data elements before the current pointer position).
or CJ1M only) TB
SWRIT C
@SWRIT
640 S
TB: First stack
address
C: Offset value
S: Source data
STACK DATA Inserts the source data at the specified location in the stack and shifts the rest of Output
INSERT SINS(641) the data in the stack downward. The offset value indicates the location of the required
(CS1-H, CJ1-H, insertion point (how many data elements before the current pointer position).
or CJ1M only) TB
SINS C
@SINS
641 S
TB: First stack
address
C: Offset value
S: Source data
STACK DATA Deletes the data element at the specified location in the stack and shifts the rest Output
DELETE SDEL(642) of the data in the stack upward. The offset value indicates the location of the required
(CS1-H, CJ1-H, deletion point (how many data elements before the current pointer position).
or CJ1M only) TB
SDEL C
@SDEL
642 D
TB: First stack
address
C: Offset value
D: Destination
word
119
Data Control Instructions Section 3-16
C
D PV input (S) PID control
S: Input word
C: 1st parameter
word Manipulated variable (D)
D: Output word
PID CONTROL Executes PID control according to the specified parameters. The PID con- Output
WITH AUTO PIDAT(191) stants can be auto-tuned with PIDAT(191). required
TUNING
(CS1-H, CJ1-H, S
or CJ1M only)
C
PIDAT
191 D
S: Input word
C: 1st parameter
word
D: Output word
LIMIT CONTROL Controls output data according to whether or not input data is within upper Output
LMT LMT(680) and lower limits. Required
@LMT
S
680
C
D
S: Input word Upper limit
C: 1st limit word C+1
D: Output word
Lower limit
C
DEAD BAND Controls output data according to whether or not input data is within the dead Output
CONTROL BAND(681) Required
band range.
BAND
@BAND S Output
681 C
D
Lower limit (C)
S: Input word
C: 1st limit word Input
D: Output word
Upper limit (C+1)
120
Data Control Instructions Section 3-16
SCALING Converts unsigned binary data into unsigned BCD data according to the Output
SCL SCL(194) specified linear function. Required
@SCL
194
S R (unsigned BCD) Scaling is performed according
P1 to the linear function defined
by points A and B.
R
Point B P (BCD) Converted
S: Source word value
P1: 1st parameter P1 + 1 (BIN)
Point A
word P1 + 2 (BCD)
R: Result word Converted
P1 + 3 (BIN) value
S (unsigned binary)
SCALING 2 Converts signed binary data into signed BCD data according to the specified Output
SCL2 SCL2(486) Required
linear function. An offset can be input in defining the linear function.
@SCL2
S
486
P1 Positive Offset Negative Offset
S: Source word
P1: 1st parameter
word Y
R: Result word
Y
Offset X
X
Offset of 0000
P1 Offset (Signed binary) R (signed BCD)
P1 + 1 Y (Signed binary)
P1 + 2 X (Signed BCD)
Y
Offset = 0000 hex
X
S (signed
binary)
121
Data Control Instructions Section 3-16
X X
Offset Offset S (signed BCD)
Min.
conver- S (signed BCD)
sion
Min. conversion
Offset of 0000
R (signed binary)
Max
conver-
sion
Y
X
S (signed BCD)
Min. conversion
AVERAGE Output
AVG(195) Calculates the average value of an input word for the specified number of
AVG cycles. Required
195 S S: Source word
N
R
S: Source word
N: Number of N: Number of cycles
cycles
R: Result word
R+1 Pointer
Average Valid Flag Average
R+2
R+3
N values
R+N+1
122
Subroutine Instructions Section 3-17
Main program
Subroutine
program
(SBN(092) to
RET(093))
Program end
MACRO Output
MCRO(099) Calls the subroutine with the specified subroutine number and executes that
MCRO program using the input parameters in S to S+3 and the output parameters in Required
@MCRO N D to D+3.
099
S MCRO(099)
D
N: Subroutine
number
S: 1st input Execution of subroutine
parameter word between SBN(092) and
RET(093).
D: 1st output
parameter word MCRO(099)
SUBROUTINE Indicates the beginning of the subroutine program with the specified Output
ENTRY SBN(092) subroutine number. Not required
SBN
N
092
N: Subroutine
number or
Subroutine region
123
Subroutine Instructions Section 3-17
GLOBAL SUB- Indicates the beginning of the subroutine program with the specified subroutine Output
ROUTINE ENTRY GSBN(751) number. Not required
(CS1-H, CJ1-H,
or CJ1M only) N
GSBN
N: Subroutine
751 number
124
Interrupt Control Instructions Section 3-18
Time interval
Scheduled
interrupt Set scheduled interrupt
time interval.
READ INTER- Reads the current interrupt processing settings that were set with MSKS(690). Output
RUPT MASK MSKR(692) Required
MSKR N
@MSKR
692 D
N: Interrupt
identifier
D: Destination
word
CLEAR Output
CLI(691) Clears or retains recorded interrupt inputs for I/O interrupts or sets the time to
INTERRUPT the first scheduled interrupt for scheduled interrupts. Required
CLI N N = 0 to 3 (I/O Interrupts are not supported by CJ1 CPU Units.)
@CLI
691 S Interrupt
Interrupt input n
input n
N: Interrupt
identifier Internal
S: Interrupt data Internal status
status
Time to first
scheduled interrupt
125
Interrupt Control Instructions Section 3-18
ENABLE Enables execution of all interrupt tasks that were disabled with DI(693). Output
INTERRUPTS EI(694) Not required
EI
694
126
High-speed Counter and Pulse Output Instructions (CJ1M-CPU22/23 Only) Section 3-19
P: Port specifier
C: Control data
NV: 1st word with
new PV
HIGH-SPEED PRV(881) is used to read the present value (PV) of a high-speed Output
COUNTER PV PRV
counter, pulse output, or interrupt input (counter mode). Required
READ P
PRV
@PRV C
881 D
P: Port specifier
C: Control data
D: 1st destination
word
COMPARISON CTBL(882) is used to perform target value or range comparisons for the Output
TABLE LOAD CTBL present value (PV) of a high-speed counter. Required
CTBL P
@CTBL
C
882
TB
P: Port specifier
C: Control data
TB: 1st compari-
son table word
SPEED OUTPUT SPED(885) is used to specify the frequency and perform pulse output without Output
SPED acceleration or deceleration.
SPED Required
@SPED P
885
M
F
P: Port specifier
M: Output mode
F: 1st pulse fre-
quency word
SET PULSES PULS(886) is used to set the number of pulses for pulse output. Output
PULS
PULS Required
@PULS P
886
T
N
P: Port specifier
T: Pulse type
N: Number of
pulses
127
Step Instructions Section 3-20
P: Port specifier
M: Output mode
S: 1st word of set-
tings table
F: 1st word of
starting frequency
ACCELERATION ACC(888) is used to set the pulse frequency and acceleration/deceleration Output
CONTROL ACC rates, and to perform pulse output with acceleration/deceleration (with the Required
ACC P same acceleration/deceleration rate). Both positioning and speed control are
@ACC possible.
M
888
S
P: Port specifier
M: Output mode
S: 1st word of set-
tings table
ORIGIN SEARCH ORG(889) is used to perform origin searches and returns. Output
ORG
ORG Required
@ORG P
889
C
P: Port specifier
C: Control data
PULSE WITH PWM(891) is used to output pulses with a variable duty factor. Output
VARIABLE DUTY PWM
Required
FACTOR P
PWM
@ F
891 D
P: Port specifier
F: Frequency
D: Duty factor
128
Basic I/O Unit Instructions Section 3-21
7-SEGMENT Converts the hexadecimal contents of the designated digit(s) into 8-bit, Output
DECODER SDEC(078) Required
7-segment display code and places it into the upper or lower 8-bits of the
SDEC S specified destination words.
@SDEC
078 Di
D Di
Number of digits
S: Source word First digit to convert
Di: Digit
designator
D: 1st destination
word
7-segment
C: Control data
S: Transfer
source and Desig-
number of words nated
number
D: Transfer of words
destination and read.
number of words
129
Serial Communications Instructions Section 3-22
CPU BUS UNIT Immediately refreshes the I/O in the CPU Bus Unit with the specified unit num- Output
I/O REFRESH DLNK(226) ber. required
(CS1-H, CJ1-H,
or CJ1M only) N
DLNK
@DLNK N: Unit number
226
TRANSMIT Outputs the specified number of bytes of data from the RS-232C port built into Output
TXD TXD(236) the CPU Unit. Required
@TXD
236
S
C
N
S: 1st source
word
C: Control word
N: Number of
bytes
0000 to 0100 hex
(0 to 256 decimal)
130
Network Instructions Section 3-23
D: 1st destination
word
C: Control word
N: Number of
bytes to store
0000 to 0100 hex
(0 to 256 decimal)
CHANGE SERIAL Changes the communications parameters of a serial port on the CPU Unit, Output
PORT SETUP STUP(237) Serial Communications Unit (CPU Bus Unit), or Serial Communications Board Required
STUP (CS Series only). STUP(237) thus enables the protocol mode to be changed
@STUP C during PLC operation.
237 S
C: Control word
(port)
S: First source
word
131
Network Instructions Section 3-23
15 0
D Re- Response
sponse
data (m Execute
(D1) bytes)
m
+ 2
132
File Memory Instructions Section 3-24
Number of
words
WRITE DATA Overwrites or appends data in the specified data file in file memory with the Output
FILE FWRIT(701)
specified data from the data area in the CPU Unit. If the specified file doesn't Required
FWRIT C exist, a new file is created with that filename.
@FWRIT
701 D1 CPU Unit Starting word File specified in D2
specified in
Starting D1+2 and
D2 address D1+3
specified
S in S Number of
words specified
C: Control word in D1 and D1+1
D1: 1st
destination word Overwrite
D2: Filename
S: 1st source Memory Card or EM file memory
word (Specified by the 4th digit of C.)
Append
Memory Card or EM file memory
(Specified by the 4th digit of C.)
Beginning
CPU Unit of file File speci- New file created
fied in D2
Starting
address Number of words
specified specified in D1
in S and D1+1
133
Display Instructions Section 3-25
N: Message
number
M: 1st message
word
C: 1st calendar
word
T: 1st time word
R: 1st result word T Minutes Seconds
T+1 Hours
R Minutes Seconds
R+1 Day Hour
R+2 Year Month
CALENDAR Subtracts time from the calendar data in the specified words. Output
SUBTRACT CSUB(731)
Required
CSUB C
@CSUB C Minutes Seconds
731 T C+1 Day Hour
R C+2 Year Month
C: 1st calendar
word
T: 1st time word
R: 1st result word T Minutes Seconds
T+1 Hours
R Minutes Seconds
R+1 Day Hour
R+2 Year Month
134
Debugging Instructions Section 3-27
Seconds
Minutes Seconds
Hours
CLOCK Changes the internal clock setting to the setting in the specified source words. Output
ADJUSTMENT DATE(735) Required
DATE
@DATE S
CPU Unit
735 S: 1st source
word
Internal clock
Minutes Seconds
New
setting Day Hour
Year Month
00 Day of week
135
Failure Diagnosis Instructions Section 3-28
Message displayed
on Programming
Console
Logic diagnosis
execution condition C
Diagnostic output B
136
Other Instructions Section 3-29
EXTEND MAXI- Extends the maximum cycle time, but only for the cycle in which this instruction Output
MUM CYCLE WDT(094) is executed. Required
TIME
WDT T
@WDT
T: Timer setting
094
SAVE CONDI- Saves the status of the condition flags. Output
TION FLAGS CCS(282) Required
(CS1-H, CJ1-H,
or CJ1M only)
CCS
@CCS
282
LOAD CONDI- Reads the status of the condition flags that was saved. Output
TION FLAGS CCL(283) Required
(CS1-H, CJ1-H,
or CJ1M only)
CCL
@CCL
283
CONVERT Converts a CV-series PLC memory address to its equivalent CS-series PLC Output
ADDRESS FROM FRMCV(284) memory address. Required
CV
(CS1-H, CJ1-H, S
or CJ1M only)
D
FRMCV
@FRMCV
284
S: Word contain-
ing CV-series
memory address
D: Destination
Index Register
CONVERT Converts a CS-series PLC memory address to its equivalent CV-series PLC Output
ADDRESS TO CV TOCV(285) memory address. Required
(CS1-H, CJ1-H,
or CJ1M only) S
TOCV D
@TOCV
285
S: Index Register
containing CS-
series memory
address
D: Destination
word
137
Block Programming Instructions Section 3-30
BLOCK Define a block programming area. For every BPRG(096) there must be a cor- Block program
PROGRAM END responding BEND(801). Required
BEND
801
BLOCK BPPS Pause and restart the specified block program from another block program. Block program
PROGRAM (811) Required
PAUSE
N
BPPS
811 N: Block program
number
to
BPPS(811) executed
to for block program n.
138
Block Programming Instructions Section 3-30
to
to BPRS(812) executed
for block program n.
CONDITIONAL EXIT(806) without an operand bit exits the program if the execution condition Block program
BLOCK EXIT
EXIT(806)
is ON. Required
EXIT B: Bit operand
806 Execution Execution
condition condition
OFF ON
Execution condition
"B" executed.
Block ended.
CONDITIONAL EXIT(806) B EXIT(806) without an operand bit exits the program if the execution condition Block program
BLOCK EXIT is ON. Required
EXIT B: Bit operand
806 Operand bit Operand bit
OFF ON
(ON for (OFF for EXIT
EXIT NOT) NOT)
"B" executed.
Block ended.
CONDITIONAL EXIT(806) without an operand bit exits the program if the execution condition Block program
BLOCK EXIT is OFF. Required
(NOT)
EXIT NOT
806
139
Block Programming Instructions Section 3-30
CONDITIONAL IF (802) If the operand bit is ON, the instructions between IF(802) and ELSE(803) will Block program
BLOCK B be executed. If the operand bit is OFF, the instructions between ELSE(803) Required
BRANCHING and IEND(804) will be executed.
IF B: Bit operand
802
Operand bit
ON?
IF R (IF NOT R)
CONDITIONAL The instructions between IF(802) and ELSE(803) will be executed and if the Block program
BLOCK IF (802) NOT operand bit is ON, the instructions be ELSE(803) and IEND(804) will be exe-
B Required
BRANCHING cuted is the operand bit is OFF.
(NOT) B: Bit operand
IF NOT
802
CONDITIONAL --- If the ELSE(803) instruction is omitted and the operand bit is ON, the instruc- Block program
BLOCK tions between IF(802) and IEND(804) will be executed Required
BRANCHING
(ELSE)
ELSE
803
CONDITIONAL --- If the operand bit is OFF, only the instructions after IEND(804) will be exe- Block program
BLOCK cuted. Required
BRANCHING
END
IEND
804
140
Block Programming Instructions Section 3-30
Wait
ONE CYCLE AND WAIT(805) B If the operand bit is OFF (ON for WAIT NOT(805)), the rest of the instructions Block program
WAIT in the block program will be skipped. In the next cycle, none of the block pro- Required
WAIT B: Bit operand gram will be executed except for the execution condition for WAIT(805) or
805 WAIT(805) NOT. When the execution condition goes ON (OFF for WAIT(805)
NOT), the instruction from WAIT(805) or WAIT(805) NOT to the end of the
program will be executed.
ONE CYCLE AND WAIT(805) NOT B If the operand bit is OFF (ON for WAIT NOT(805)), the rest of the instructions Block program
WAIT (NOT) in the block program will be skipped. In the next cycle, none of the block pro- Required
WAIT NOT B: Bit operand gram will be executed except for the execution condition for WAIT(805) or
WAIT(805) NOT. When the execution condition goes ON (OFF for WAIT(805)
805
NOT), the instruction from WAIT(805) or WAIT(805) NOT to the end of the
program will be executed.
TIMER WAIT Delays execution of the rest of the block program until the specified time has Block program
TIMW(813)
TIMW N elapsed. Execution will be continued from the next instruction after TIMW(813) Required
813 SV when the timer times out.
(BCD)
N: Timer number
SV: Set value
TIMWX TIMWX(816)
816 N "A"
(Binary) SV executed.
(CS1-H, CJ1-H, N: Timer number
CJ1M only) SV: Set value
SV
preset. Time elapsed.
"B" executed.
BEND
"C" executed.
C
141
Block Programming Instructions Section 3-30
CNTWX CNTWX(817)
817 N SV
(Binary) preset.
SV
(CS1-H, CJ1-H, Time elapsed.
CJ1M only)
N: Counter
number "B" executed.
SV: Set value
I: Count input
"C" "C" "C" executed.
executed. executed.
C
HIGH-SPEED TMHW(815) Delays execution of the rest of the block program until the specified time has Block program
TIMER WAIT N elapsed. Execution will be continued from the next instruction after Required
TMHW SV TMHW(815) when the timer times out. SV = 0 to 99.99 s
815 N: Timer number
(BCD) SV: Set value
TMHWX TMHWX(818)
818 N
(Binary)
SV "A"
(CS1-H, CJ1-H,
CJ1M only executed.
N: Timer number
SV: Set value SV
preset. Time elapsed.
"B" executed.
BEND
"C" executed.
C
142
Block Programming Instructions Section 3-30
Execution condition
Loop repeated
LEND LEND(810) LEND(810) or LEND(810) NOT specifies the end of the loop. When Block program
LEND LEND(810) or LEND(810) NOT is reached, program execution will loop back Required
to the next previous LOOP(809) until the operand bit for LEND(810) or
810 LEND(810) NOT turns ON or OFF (respectively) or until the execution condi-
tion for LEND(810) turns ON.
LEND If the operand bit is OFF for LEND(810) (or ON for LEND(810) NOT), Block program
LEND (810)
LEND B execution of the loop is repeated starting with the next instruction after Required
810 LOOP(809). If the operand bit is ON for LEND(810) (or OFF for LEND(810)
B: Bit operand NOT), the loop is ended and execution continues to the next instruction after
LEND(810) or LEND(810) NOT.
Loop repeated
143
Text String Processing Instructions Section 3-31
CONCATENATE Output
Links one text string to another text string.
STRING +$(656) Required
+$ +
@+$ S1
656 S2
D
S1: Text string 1
S2: Text string 2
D: First
destination word
GET STRING Fetches a designated number of characters from the left (beginning) of a text Output
LEFT LEFT$(652) Required
string.
LEFT$
@LEFT$ S1
652 S2
D
GET STRING Reads a designated number of characters from the right (end) of a text string. Output
RIGHT RGHT$(653)
Required
RGHT$ S1
@RGHT$ 00
653 S2
D
S1: Text string
first word
S2: Number of
characters
D: First
destination word
GET STRING Reads a designated number of characters from any position in the middle of a Output
MIDDLE MID$(654) Required
text string.
MID$
@MID$
S1
654 S2
S3
D
S1: Text string
first word
S2: Number of
characters
S3: Beginning
position
D: First
destination word
144
Text String Processing Instructions Section 3-31
REPLACE IN Output
STRING RPLC$(661) Replaces a text string with a designated text string from a designated position.
Required
RPLC$
@RPLC$ S1
661 S2
S3
S4
D
S1: Text string
first word
S2: Replacement
text string first
word
S3: Number of
characters
S4: Beginning
position
D: First
destination word
DELETE STRING Deletes a designated text string from the middle of a text string. Output
DEL$(658)
DEL$ Required
@DEL$ Number of characters to be
S1 deleted (designated by S2).
658
S2
S3
G
D
S1: Text string
first word
S2: Number of
characters
S3: Beginning
position
D: First
destination word
145
Text String Processing Instructions Section 3-31
CLEAR STRING Clears an entire te xt str ing with NUL (00 hex). Output
CLR$ CLR$(666) Required
@CLR$
S S A B S
C D
666
NUL NUL
S: Text string first
word
INSERT INTO Deletes a designated text string from the middle of a text string. Output
STRING INS$(657) Required
INS$
@INS$ S1
NUL
657 S2
S3
D Inserted
characters
S1: Base text
string first word
S2: Inserted text
string first word
S3: Beginning
position
D: First
destination word
String Sting comparison instructions (=$, <>$, <$, <=$, >$, >=$) compare two text
Comparison LD strings from the beginning, in terms of value of the ASCII codes. If the result of LD: Not
LD, AND, OR + Symbol the comparison is true, an ON execution condition is created for a LOAD, AND, required
=$, <>$, <$, <=$, or OR. AND, OR:
>$, >=$ S1 Required
670 (=$)
671 (<>$) S2
672 (<$)
673 (<=$) AND
674 (>$) Symbol
675 (>=$)
S1
S2
OR
Symbol
S1
S2
S1: Text string 1
S2: Text string 2
146
Task Control Instructions Section 3-32
Task m Task m
Be
Becomes comes
execut- execut-
able in able in
that cycle. the next
cycle.
Task n Task n
TASK OFF Puts the specified task into standby status. Output
TKOF TKOF(821) Required
@TKOF The specified task's task num The specified task's task num
N ber is higher than the local ber is lower than the local
821
task's task number (m<n). task's task number (m>n).
N: Task number
Task m Task m
In stand- In stand-
by status by status
that the next
cycle. cycle.
Task n Task n
147
Task Control Instructions Section 3-32
148
SECTION 4
Tasks
149
Task Features Section 4-1
150
Task Features Section 4-1
Start task B
Task B
(Program B)
Note 1. Up to 32 cyclic tasks and 256 interrupt tasks for a maximum total of 288
tasks can be created. Each task has its own unique number ranging from
0 to 31 for cyclic tasks and 0 to 255 for interrupt tasks.
2. With the CS1-H, CJ1-H, or CJ1M CPU Units, interrupt task (interrupt task
numbers 0 to 255) can be executed as cyclic tasks by starting them with
TKON. These are called extra cyclic tasks. If extra cyclic tasks are used,
then the total number of cyclic tasks that can be used is 288.
3. CJ1 CPU Units do not currently support I/O interrupt tasks and external in-
terrupt tasks. The maximum number of tasks for a CJ1 CPU Unit is thus
35, i.e., 32 cyclic tasks and 3 interrupt tasks. The total number of programs
that can be created and managed is also 35.
Each program allocated to a task must end with an END(001) instruction. I/O
refreshing will be executed only after all task programs in a cycle have been
executed.
151
Task Features Section 4-1
Cyclic task 0
Interrupt task 5
Executed in order starting
at the lowest number.
Cyclic task 1
Interrupt
occurs.
Cyclic task n
I/O refresh
Peripheral processing
Note All Condition Flags (ER, CY, Equals, AER, etc.) and instruction conditions
(interlock ON, etc.) will be cleared at the beginning of a task. Therefore Condi-
tion Flags cannot be read nor can INTERLOCK/INTERLOCK CLEAR (IL/ILC)
instructions, JUMP/JUMP END (JMP/JME) instructions, or SUBROUTINE
CALL/SUBROUTINE ENTRY (SBS/SBN) instructions be split between two
tasks.
With a CS1-H, CJ1-H, or CJ1M CPU Unit, interrupt task can be executed as
cyclic tasks by starting them with TKON. These are called extra cyclic tasks.
Extra cyclic tasks (interrupt task numbers 0 to 255) are executed starting at
the lowest task number after execution of the normal cyclic task (celiac task
numbers 0 to 31) has been completed.
152
Task Features Section 4-1
Cyclic task 0
END
END
I/O refresh
Peripheral
processing
153
Task Features Section 4-1
Cyclic Tasks
A cyclic task that is READY will be executed once each cycle (from the top of
the program until the END(001) instruction) in numerical order starting at the
task with the lowest number. The maximum number of cyclic tasks is 32.
(Cyclic task numbers: 00 to 31).
Note With the CS1-H, CJ1-H, or CJ1M CPU Units, interrupt task (interrupt task
numbers 0 to 255) can be executed as cyclic tasks just like normal cyclic
tasks (task numbers 0 to 31). If extra cyclic tasks are used, then the total num-
ber of cyclic tasks that can be used is 288.
Interrupt Tasks
An interrupt task will be executed if an interrupt occurs even if a cyclic task
(including extra cyclic tasks) is currently being executed. The interrupt task
will be executed using any time in the cycle, including during user program
execution, I/O refreshing, or peripheral servicing, when the execution condi-
tion for the interrupt is met.
With the CS1-H, CJ1-H, or CJ1M CPU Units, interrupt task can be executed
as cyclic tasks.
The built-in interrupt inputs and high-speed counter inputs on a CJ1M CPU
Unit can be used to activate interrupt tasks. Refer to the CJ Series Built-in I/O
Operation Manual for details.
Power OFF Interrupt Task The power OFF interrupt task will be executed if CPU Unit power is shut OFF.
Only one power OFF interrupt task can be programmed (Interrupt task num-
ber: 1).
Note The power OFF interrupt task must execute before the following time elapses
or the task will be forced to quit.
10 ms (Power OFF detection delay time)
The power OFF detection delay time is set in the PLC Setup.
Scheduled Interrupt Tasks A scheduled interrupt task will be executed at a fixed interval based on the
internal timer of the CPU Unit. The maximum number of scheduled interrupt
tasks is 2 (Interrupt task numbers: 2 and 3).
Note The SET INTERRUPT MASK (MSKS(690)) instruction is used to set the inter-
rupt for a scheduled interrupt task. Interrupt times can be set in 10-ms or 1.0-
ms increments in the PLC Setup.
I/O Interrupt Tasks An I/O interrupt task will be executed if an Interrupt Input Unit input turns ON.
The maximum number of I/O interrupt tasks is 32 (Interrupt task numbers: 100
to 131). The Interrupt Input Unit must be mounted to the CPU Rack. For CJ1-
H CPU Units, the Unit must be connected as one of the five Units next to the
CPU Unit (slots 0 to 4). For CJ1M CPU Units, the Unit must be connected as
one of the three Units next to the CPU Unit (slots 0 to 2). I/O Interrupt Units
154
Task Features Section 4-1
External Interrupt Tasks An external interrupt task will be executed when requested by an Special I/O
Unit, CPU Bus Unit, or Inner Board (CS Series only) user program. Special
I/O Units and CPU Bus Units, however, must be mounted to the CPU Rack.
The Special I/O Unit or CPU Bus Unit must be mounted to the CPU Rack. For
CJ1-H CPU Units, the Unit must be connected as one of the five Units next to
the CPU Unit (slots 0 to 4). For CJ1M CPU Units, the Unit must be connected
as one of the three Units next to the CPU Unit (slots 0 to 2). Units mounted
elsewhere cannot be used to generate external interrupts.
The maximum number of external interrupt tasks is 256 (Interrupt task num-
bers: 0 to 255). If an external interrupt task has the same number as a power
OFF, scheduled, or I/O interrupt task, the interrupt task will be executed for
either condition (the two conditions will operate with OR logic) but basically
task numbers should not be duplicated.
I/O interrupts are not supported by CJ1 CPU Units.
Extra Cyclic Tasks (CS1-H, An interrupt tasks can be executed every cycle, just like the normal cyclic
CJ1-H, or CJ1M CPU Units tasks. Extra cyclic tasks (interrupt task numbers 0 to 255) are executed start-
Only) ing at the lowest task number after execution of the normal cyclic task (cyclic
task numbers 0 to 31) has been completed. The maximum number of extra
cyclic tasks is 256 (Interrupt task numbers: 0 to 255). Cycle interrupt tasks,
however, are different from normal cyclic tasks in that they are started with the
TKON(820)instruction. Also, the TKON(820)and TKOF instructions cannot be
used in extra cyclic tasks, meaning that normal cyclic tasks and other extra
cyclic tasks cannot be controlled from within an extra cyclic task.
If an extra cyclic task has the same number as a power OFF, scheduled, or I/O
interrupt task, the interrupt task will be executed for either condition (the two
conditions will operate with OR logic). Do not use interrupt tasks both as nor-
mal interrupt tasks and as extra cyclic tasks.
Note 1. The power OFF interrupt task in 1) above has priority and will be executed
when power turns OFF even if another interrupt task is being executed.
2. If another interrupt task is being executed when a scheduled, I/O, or exter-
nal interrupt occurs, then these interrupt tasks will not be executed until the
interrupt task that is currently being executed has been completed. If mul-
tiple interrupts occur simultaneously, then interrupt tasks will be executed
sequentially starting at the lowest interrupt task number.
3. The differences between normal cyclic tasks and extra cyclic tasks are list-
ed in the following table.
Item Extra cyclic tasks Normal cyclic tasks
Activating at startup Setting is not possible. Set from CX-Programmer
Using TKON/TKOF Possible. Not possible.
instructions inside task
Task Flags Not supported. Supported.
Initial Task Execution Not supported. Supported.
Flag (A20015) and
Task Start Flag
(A20014)
Index (IR) and data Not defined when task is Undefined at the beginning
(DR) register values started (same as normal of operation. Values set in
interrupt tasks). Values the previous cycle can be
set in the previous cycle read.
cannot be read.
155
Task Features Section 4-1
4. The CJ1 CPU Units do not support I/O interrupt and external interrupt
tasks.
Note 1. The Interrupt Input Unit must be mounted to the CPU Rack. For CJ1-H
CPU Units, the Unit must be connected as one of the five Units next to the
CPU Unit (slots 0 to 4). For CJ1M CPU Units, the Unit must be connected
as one of the three Units next to the CPU Unit (slots 0 to 2). I/O Interrupt
Units mounted elsewhere cannot be used to request execution of I/O inter-
rupt tasks
2. The Special I/O Unit or CPU Bus Unit must be mounted to the CPU Rack.
For CJ1-H CPU Units, the Unit must be connected as one of the five Units
next to the CPU Unit (slots 0 to 4). For CJ1M CPU Units, the Unit must be
connected as one of the three Units next to the CPU Unit (slots 0 to 2).
Units mounted elsewhere cannot be used to generate external interrupts.
3. The number of cyclic tasks and interrupt tasks are limited when the mem-
ory clear operation is performed with a Programming Console.
Only cyclic task 0 can be created.
Cyclic tasks 1 to 31 cannot be created with a Programming Console,
but these tasks can be edited if they were already created with CX-
Programmer.
Only interrupt tasks 1, 2, 3, and 100 through 131 (CS Series only) can
be created.
Interrupt tasks 0, 4 through 99, and 132 through 255 cannot be created
with a Programming Console (except that 140 through 143 can be cre-
156
Task Features Section 4-1
ated for CJ1M CPU Units), but these tasks can be edited if they were
already created with CX-Programmer.
READY Status
A task attribute can be set to control when the task will go to READY status.
The attribute can be set to either activate the task using the TASK ON instruc-
tion or when RUN operation is started.
Operation-activated Tasks An operation-activated cyclic task will switch from Disabled status to READY
status when the operating mode is changed from PROGRAM to RUN or
MONITOR mode. This applies only to normal cyclic tasks.
Note A Programming Device can be used to set one or more tasks to go to READY
status when operation is started for task numbers 0 through 31. The setting,
however, is not possible with extra cyclic tasks.
RUN Status
A cyclic task that is READY will switch to RUN status and be executed when
the task obtains the right to execute.
Standby Status
A TASK OFF (TKOF(821)) instruction can be used to change a cyclic task
from Disabled status to Standby status.
Executed
Standby status
Note 1. A task in RUN status will be put into Standby status by the TKOF(821) in-
struction even when the TKOF(821) instruction is executed within that task.
157
Using Tasks Section 4-2
2. Activation at the start of operation is possible for normal cyclic tasks only.
It is not possible for extra cyclic tasks.
Standby status functions exactly the same way as a jump (JMP-JME). Output
status for the Standby task will be maintained.
Executes under
set conditions All instructions will
be executed un-
less jumps or other
functions are used.
Executes under
set conditions
Note Standby status simply means that a task will be skipped during task execu-
tion. Changing to Standby status will not end the program.
158
Using Tasks Section 4-2
The TASK ON and TASK OFF instructions can be used to change any cyclic
task between READY or Standby status at any time. A cyclic task that is in
READY status will maintain that status in subsequent cycles, and a cyclic task
that is in Standby status will maintain that status in subsequent cycles.
The TASK ON and TASK OFF instructions can be used only with cyclic tasks
and not with interrupt tasks.
Note At least one cyclic task must be in READY status in each cycle. If there is not
cyclic task in READY status, the Task Error Flag (A29512) will turn ON, and
the CPU Unit will stop running.
Cyclic task 1
Cyclic task 2
Cyclic task 3
READY status
159
Using Tasks Section 4-2
READY sta-
Cyclic task 1 tus at the Cyclic task 1 READY status
start of op-
eration
A cyclic task that is in Standby status will maintain that status in subsequent
cycles. The task will have to be activated using the TKON(820) instruction in
order to switch from Standby to READY status.
If a TKOF(821) instruction is executed for the task it is in, the task will stop
being executed where the instruction is executed, and the task will shift to
Standby status.
Task 2
Cyclic Task Numbers and the Execution Cycle (Including Extra Cyclic Tasks)
If task m turns ON task n and m > n, task n will go to READY status the next
cycle.
Example:If task 5 turns ON task 2, task 2 will go to READY status the next
cycle.
If task m turns ON task n and m < n, task n will go to READY status the same
cycle.
Example:If task 2 turns ON task 5, task 5 will go to READY status in the same
cycle.
160
Using Tasks Section 4-2
If task m places task n in Standby status and m > n, will go to Standby status
the next cycle.
Example: If task 5 places task 2 in Standby status, task 2 will go to Standby
status the next cycle.
If task m places task n in Standby status and m < n, task n will go to Standby
status in the same cycle.
Example: If task 2 places task 5 in Standby status, task 5 will go to Standby
status in the same cycle.
Note 1. The current EM bank is also shared by tasks. Therefore if the current EM
bank number is changed with cyclic task 1 for example, the new current EM
bank number will be valid for cyclic task 2 as well.
2. IR and DR values are not set when interrupt tasks (including extra cyclic
tasks) are started. If IR and DR are used in an interrupt task, these values
must be set by the MOVR/MOVRW (MOVE TO REGISTER and MOVE
TIMER/COUNTER PV TO REGISTER) instructions within the interrupt
task. After the interrupt task has been executed, IR and DR will return to
their values prior to the interrupt automatically.
Relationship of Tasks to Timer present values for TIM, TIMX, TIMH, TIMHX, TMHH, TMHHX, TIMW,
Timer Operation TIMWX, TMHW, and TMHWX programmed for timer numbers 0000 to 2047
will be updated even if the task is switched or if the task containing the timer is
changed to Standby status or back to READY status.
If the task containing TIM goes to Standby status and is the returned to
READY status, the Completion Flag will be turned ON if the TIM instruction is
executed when the present value is 0. (Completion Flags for timers are
updated only when the instruction is executed.) If the TIM instruction is exe-
cuted when the present value is not yet 0, the present value will continue to be
updated just as it was while the task was in READY status.
The present values for timers programmed with timer numbers 2048 to
4098 will be maintained when the task is in Standby status.
161
Using Tasks Section 4-2
Relationship of Tasks to All Condition Flags will be cleared before execution of each task. Therefore
Condition Flags Condition Flag status at the end of task 1 cannot be read in task 2. With a
CS1-H, CJ1-H, or CJ1M CPU Unit, however, CCS(282) and CCL(283) can be
used to read Condition Flag status from another part of the program, e.g.,
from another task.
Note When the status of Condition Flags is monitored from a Programming Con-
sole, the Programming Console will show the flags status at the end of the
cycle, i.e., their status at the end of the last task in the cycle.
162
Using Tasks Section 4-2
Task Flags A Task Flag is turned ON when a cyclic task in READY status and is turned
(TK00 to TK31) OFF when the task is in Disabled (INI) or in Standby (WAIT) status. Task num-
bers 00 to 31 correspond to Task Flags TK00 to TK31.
Note Task Flags are used only with cyclic tasks and not with interrupt tasks. With
an interrupt task, A44115 will turn ON if an interrupt task executes after the
start of operation, and the number of the interrupt task that required for maxi-
mum processing time will be stored in two-digit hexadecimal in A44100 to
A44107.
Initial Task Execution Flag The Initial Task Execution Flag will turn ON when cyclic tasks shift from Dis-
(A20015) abled (INI) to READY status, the tasks obtain the right to execute, and the
tasks are executed the first time. It will turn OFF when the first execution of the
tasks has been completed.
Ready Ready
Disabled Disabled
Task n
Initial Task
Execution Flag
The Initial Task Execution Flag tells whether or not the cyclic tasks are being
executed for the first time. This flag can thus be used to perform initialization
processing within the tasks.
Initializing
processing
Note Even though a Standby cyclic task is shifted back to READY status through
the TKON(820) instruction, this is not considered an initial execution and the
Initial Task Execution Flag (20015) will not turn ON. The Initial Task Execution
Flag (20015) will also not turn ON if a cyclic task is shifted from Disabled to
RUN status or if it is put in Standby status by another task through the
TKOF(821) instruction before the right to execute actually is obtained.
163
Using Tasks Section 4-2
Task Start Flag (A20014, The Task Start Flag can be used to perform initialization processing each time
CS1-H, CJ1-H, or CJ1M the task cycle is started. The Task Start Flag turns OF whenever cycle task
CPU Units only) status changes from Disabled (INI) or Standby (WAIT) status to READY status
(whereas the Initial Task Execution Flag turns ON only when status changes
from Disabled (INI) to READY).
Ready Ready
Disabled Disabled
Task n
The Task Start Flag can be used to perform initialization processing whenever
a task goes from Standby to RUN status, i.e., when a task on Standby is
enabled using the TRON(820) instruction.
Initialization
processing
Task Number when The type of task and the current task number when a task stops execution
Program Stopped (A294) due to a program error will be stored as follows:
Type A294
Cyclic task 0000 to 001F Hex (correspond to task numbers 0 to 31)
Interrupt task 8000 to 80FF Hex (correspond to interrupt task numbers 0 to 255)
This information makes it easier to determine where the fatal error occurred,
and it will be cleared when the fatal error is cleared. The program address
where task operation stopped is stored in A298 (rightmost bits of the program
address) and in A299 (leftmost bits of the program address).
Examples of Tasks
An overall control task that is set to go to READY status at the start of opera-
tion is generally used to control READY/Standby status for all other cyclic
tasks (including extra cyclic tasks). Of course, any cyclic task can control the
READY/Standby status of any other cyclic task as required by the application.
164
Using Tasks Section 4-2
Analog processing
task
Machining task
Overall control task
Assembly task
Conveyor task
165
Using Tasks Section 4-2
Interrupt
Order priority
External outputs
Overall Error processing
External I/O
2. Be sure to break down and design programs in a manner that will ensure
autonomy and keep the amount of data exchanged between tasks (pro-
grams) to an absolute minimum.
Minimize data
exchange
166
Using Tasks Section 4-2
8. Assign I/O memory into memory shared by tasks and memory used only
for individual tasks, and then group I/O memory used only for individual
tasks by task.
Relationship of Tasks to Up to 128 block programs can be created in the tasks. This is the total number
Block Programs for all tasks. The execution of each entire block program is controlled from the
ladder diagram, but the instructions within the block program are written using
mnemonics. In other words, a block program is formed from a combination of
a ladder instruction and mnemonic code.
Using a block program makes it easier to write logic flow, such as conditional
branching and process stepping, which can be hard to write using ladder dia-
grams. Block programs are located at the bottom of the program hierarchy,
and the larger program units represented by the task can be split into small
program units as block programs that operate with the same execution condi-
tion (ON condition).
Program
Block program 000
Task 0 Block program area 000
Block program 001
Block program n
Task 1
Block program area 001
Task n
167
Interrupt Tasks Section 4-3
END
Multiple tasks Cyclic task (including
extra cyclic task)
Call
GSBS
n
Return
I/O Interrupts (CS Series The I/O interrupt task will be executed when input to the Interrupt Input Unit is
Only) ON.
Interrupt
Input Unit CPU Unit
Interrupt
Pro-
gram
Fixed interval
Pro-
gram
Interrupt
Power OFF Interrupt The power OFF interrupt task will be executed when power is turned OFF.
Note The execution time for the power OFF task must be less than 10 ms (Power
OFF delay detection time).
168
Interrupt Tasks Section 4-3
CPU Unit
Interrupt Pro-
gram
Power OFF
External Interrupts (CS An external interrupt task will be executed when an interrupt is requested by
Series Only) an Special I/O Unit, CPU Bus Unit, or Inner Board (CS Series only). The Spe-
cial I/O Unit or CJ Bus Unit, however, must be on the CPU Rack to request
execution of an external interrupt task.
Special I/O Unit,
CS1 CPU Bus Unit
or Inner Board CPU Unit
Interrupt
Pro-
gram
Note 1. The Interrupt Input Unit must be mounted to the CPU Rack. For CJ1-H
CPU Units, the Unit must be connected as one of the five Units next to the
CPU Unit (slots 0 to 4). For CJ1M CPU Units, the Unit must be connected
as one of the three Units next to the CPU Unit (slots 0 to 2). I/O Interrupt
Units mounted elsewhere cannot be used to request execution of I/O inter-
rupt tasks
2. The Special I/O Unit or CPU Bus Unit must be mounted to the CPU Rack.
For CJ1-H CPU Units, the Unit must be connected as one of the five Units
next to the CPU Unit (slots 0 to 4). For CJ1M CPU Units, the Unit must be
connected as one of the three Units next to the CPU Unit (slots 0 to 2).
Units mounted elsewhere cannot be used to generate external interrupts.
169
Interrupt Tasks Section 4-3
3. CJ1 CPU Units do not support I/O interrupt and external interrupt tasks.
170
Interrupt Tasks Section 4-3
Note For CS-series PLCs, Interrupt Input Unit numbers are in order from 0 to 1
starting on the left side of the CPU Rack. For CJ-series PLCs, Interrupt Input
Unit numbers are in order from 0 to 1 starting from the CPU Unit.
CS-series PLCs CJ-series PLCs
Operand S (the Second Operand) of MSKS: The bits of FFF7 Hex corre-
spond to the interrupt inputs of the Interrupt Input Unit. Interrupt input num-
bers 0 to 15 correspond to bits 0 to 15.
1 1 1 1 0 1 1 1
F Hex F Hex F Hex 7 Hex
1,2,3... 1. Execute the MSKS (SET INTERRUPT MASK) instruction from a cyclic
task and set the time (cycle) for the specified scheduled interrupt.
2. Set the scheduled interrupt time unit in PLC Setup.
Note The interrupt time setting affects the cyclic task in that the shorter the interrupt
time, the more frequently the task executes and the longer the cycle time.
171
Interrupt Tasks Section 4-3
&100
Scheduled interrupt time unit in PLC
Setup = 10 ms (0.01 s)
Every second
172
Interrupt Tasks Section 4-3
Example: If the power OFF detection delay time is set to 4 ms in PLC Setup,
then execution time must be less than 10 minus 4 ms, or 6 ms.
Power OFF interrupt task
Note A power OFF condition is recognized when the power supply falls below 85%
of the minimum rated voltage (80% for DC power supplies), and the time it
takes before the power OFF interrupt task actually executes is the default
power OFF detection time (10 to 25 ms for AC power supplies and 2 to 5 ms
for DC power supplies) plus the power OFF detection delay time in the PLC
Setup (0 to 10 ms). Cyclic tasks will be executed for this amount of time.
Note Be sure that the power OFF interrupt task can be executed in less than 10 ms
minus the power OFF detection delay time set in the PLC Setup. Any remain-
ing instructions will not be executed after this time has elapsed. The power
OFF interrupt task will not be executed if power is interrupted during online
editing. In addition to the instructions that cannot be used in any interrupt task
(refer to the Programming Manual for details), the following instructions can-
not be used in the power OFF interrupt task: READ DATA FILE: FREAD(700),
WRITE DATA FILE: FWRIT(701), NETWORK SEND: SEND(090), NETWORK
RECEIVE: RECV(098), DELIVER COMMAND: CMND(490), TRANSMIT:
TXD(236), RECEIVE: RXD(235), and PROTOCOL MACRO: PMCR(260).
173
Interrupt Tasks Section 4-3
Cyclic task
Power
OFF
Power OFF interrupt task 1
Power OFF interrupt task ON/OFF
setting in PC Setup: ON
CPU reset
PLC Setup Settings for Power OFF Interrupt Task (Task Number: 1)
Address Name Description Settings Default
setting
Bit 15 at +225 Power OFF If bit 15 of +225 is ON, then a power OFF interrupt 0: OFF, 0
INTERRUPT task will start if power turns OFF. 1: ON
TASK
Bits 0 to 7 at Power OFF Power OFF is recognized when this time plus the 00 to 0A Hex: 0 00 Hex
+225 Detection default power OFF detection time (10 to 25 ms for AC to 10 ms (1-ms
Delay Time power supplies and 2 to 5 ms for DC power supplies) units)
expires.
Interrupt
174
Interrupt Tasks Section 4-3
number), the Board will request execution of an external interrupt task in the
CPU Unit after it receives data from its serial port and writes that data into the
CPU Units I/O memory.
CPU Unit Specifies exter- Serial Communications Board
nal interrupt task
Cyclic task number and re-
quests interrupt Data
processing.
Interrupt task
I/O memory
Note 1. When the response notification method is set for interrupt notification (fixed
number), the Board requests execution of the interrupt task with the preset
task number.
2. When the response notification method is set for interrupt notification (re-
ception case number), the external interrupt task number is calculated with
the specified formula and the Board requests execution of the interrupt
task with that task number.
3. If an external interrupt task (0 to 255) has the same number as a power
OFF task (task 1), scheduled interrupt task (task 2 or 3), or I/O interrupt
task (100 to 131), the interrupt task will be executed for either interrupt con-
dition (external interrupt or the other interrupt condition). As a rule, task
numbers should not be duplicated.
175
Interrupt Tasks Section 4-3
Interrupt task A
Interrupt during Interrupt task B
execution
Note If you do not want a specific I/O interrupt task number to be saved and exe-
cuted for a CS-series CPU Unit when it occurs while another interrupt task is
being executed, execute the CLI (CLEAR INTERRUPT) instruction from the
other interrupt task to CLEAR the interrupt number saved internally. Sched-
uled interrupts and external interrupts cannot be cancelled.
Interrupt task A
Interrupt I/O interrupt task
during
execution
176
Interrupt Tasks Section 4-3
Task Number when The type of task and the current task number when a program stops due to a
Program Stopped (A294) program error will be stored in the following locations.
Type A294
Interrupt task 8000 to 80FF Hex (corresponds to inter-
rupt task No. 0 to 255)
Cyclic task 0000 to 001F Hex (corresponds to task
No. 0 to 31)
177
Interrupt Tasks Section 4-3
offending interrupt task number will be stored in A426 (Interrupt Task Error,
Task Number). The CPU Unit however will continue to operate.
Up to 10 ms
Master SYSMAC 10 ms or
or longer
BUS Remote I/O Unit
SYSMAC BUS
Remote I/O
Executing IORF for a If an IORF(097) instruction has to be executed from an interrupt task for a
Special I/O Unit Special I/O Unit, be sure to turn OFF cyclic refresh for the Special I/O Unit
(using the unit number) in the PLC Setup.
A interrupt task error will occur if you try to refresh a Special I/O Unit with an
IORF(097) instruction from an interrupt task while that UNIT is also being
refreshed by cyclic I/O refresh or by I/O refresh instructions (IORF(097) or
immediate refresh instructions (!)). If Interrupt Task Error Detection is turned
ON in the PLC Setup when an interrupt task error occurs, A40213 (Interrupt
Task Error Flag) will turn ON and the unit number of the Special I/O Unit for
which I/O refreshing has been duplicated will be stored in A426 (Interrupt
Task Error, Task Number). The CPU Unit will continue running.
Note The leftmost bits of A426 (Interrupt Task Error, Task Number) can be used to
determine which of the above interrupt task errors occurred. (Bit 15: 10 ms or
higher execution error if 0, multiple refresh error if 1)
PLC Setup Settings
Address Name Description Settings Default
setting
Bit 14 at +128 Interrupt Task Error Specifies whether or not to detect interrupt 0: Detection 0
Detection task errors. The Interrupt Task Error Flag enabled,
(A40213) will be function when detection is 1: Detection
enabled. disabled
178
Interrupt Tasks Section 4-3
Disabling Interrupts Processing will be interrupted and the interrupt task will be executed in the fol-
lowing instances.
While an instruction is being executed
During Basic I/O Unit, CPU Bus Unit, Inner Board (CS Series only), or
SYSMAC BUS remote I/O (CS Series only) refreshing
During HOST LINK servicing
Data Concurrency Data may not be concurrent if a cyclic (including extra cyclic tasks) and an
between Cyclic and interrupt task are reading and writing the same I/O memory addresses. Use
Interrupt Tasks the following procedure to disable interrupts during memory access by cyclic
task instructions.
Immediately prior to reading or writing by a cyclic task instruction, use a
DI (DISABLE INTERRUPT) instruction to disable execution of interrupt
tasks.
Use an EI (ENABLE INTERRUPT) instruction immediately after process-
ing in order to enable interrupt task execution.
Cyclic task
Disabled
Interrupt task
Reading and writing I/O
memory common to interrupt
tasks.
Enabled
Interrupt task
Processing with interrupt task
execution enabled
Problems may occur with data concurrency even if DI(693) and EI(694) are
used to disable interrupt tasks during execution of an instruction that requires
response reception and processing (such as a network instruction or serial
communications instruction).
Note With the CS1-H, CJ1-H, or CJ1M CPU Unit, execution of the BIT COUNTER
(BCNT), BLOCK SET (BSET), and BLOCK TRANSFER (XFER) instructions
179
Programming Device Operations for Tasks Section 4-4
will not be interrupted for execution of interrupt task, i.e., execution of the
instruction will be completed before the interrupt task is executed, delaying
the response of the interrupt. To prevent this, separate data processing for
these instructions into more than one instructions, as shown below for XFER.
1,2,3... 1. Select View/Properties, or click the right button and select Properties on
the popup menu, to display the program that will be allocated a task.
2. Select the General tab, and select the Task Type and Task No. For the
cyclic task, click the check box for Operation start to turn it ON.
180
Programming Device Operations for Tasks Section 4-4
Programming Console A task is handled as the entire program on the Programming Console. Access
and edit a program with a Programming Console by specifying CT00 to CT31
for a cyclic task or IT001 to IT255 for an interrupt task.
CLR
Write Write
181
Programming Device Operations for Tasks Section 4-4
182
SECTION 5
File Memory Functions
183
File Memory Section 5-1
File
Memory
Card
File
File
EM area
File
Note 1. Refer to 5-2 Manipulating Files for details on installing and removing Mem-
ory Cards.
2. Initialize the Memory Card or EM File Memory before using it for the first
time. Refer to 5-3 Using File Memory for details on initialization.
3. The HMC-AP001 Memory Card Adapter can be used to mount a Memory
Card in the PLC card slot of a personal computer to use the Memory Card
as a storage device.
184
File Memory Section 5-1
4. When the CX-Programmer is being used, the CPU Unit can recognize
symbol tables (including I/O comments) and comments. The transfer des-
tination is the Memory Card when a Memory Card is installed or EM File
Memory if a Memory Card is not installed.
Memory Card Precautions
Confirm the following items before using a Memory Card.
Format
Memory Cards are formatted before shipping. There is no need to format
them after purchase. To format them once they have been used, always do so
in the CPU Unit using the CX-Programmer or a Programming Console.
If a Memory Card is formatted directly in a notebook computer or other com-
puter, the CPU Unit may not recognize the Memory Card. If this occurs, you
will not be able to use the Memory Card even if it is reformatted in the CPU
Unit.
Number of Files in Root Directory
There is a limit to the number of files that can be placed in the root directory of
a Memory Card (just as there is a limit for a hard disk). Although the limit
depends on the type and format of the Memory Card, it will be between 128
and 512 files. When using applications that write log files or other files at a
specific interval, write the files to a subdirectory rather than to the root direc-
tory.
Subdirectories can be created on a computer or by using the CMND(490)
instruction. Refer to '(/,9(5&200$1'&01'LQWKH&6&-
6HULHV,QVWUXFWLRQV5HIHUHQFH for a specific example using CMND(490).
Number of Writes
Generally speaking, there is no limit to the number of write operations that can
be performed for a flash memory. For the Memory Cards, however, a limit of
100,000 write operations has been set for warranty purposes. For example, if
the Memory Card is written to every 10 minutes, over 100,000 write opera-
tions will be performed within 2 years.
Minimum File Size
If many small files, such as ones containing only a few words of DM Area
data, are stored on the Memory Card, it will not be possible to use the com-
plete capacity of the Memory Card. For example, if a Memory Card with an
allocation unit size of 4,096 bytes is used, at least 4,096 bytes of memory will
be used for each file regardless of how small the file is. If you save 10 words
of DM Area data to the Memory Card, 4,096 bytes of memory will be used
even though the actual file size is only 68 bytes. Using files of such a small
size greatly reduces the utility rate of the Memory Card. If the allocation unit
size is reduced to increase the utility rate, however, the access speed will be
reduced.
The allocation unit size of the Memory Card can be checked from a DOS
prompt using CHKDSK. The specific procedure is omitted here. Refer to gen-
eral computer references for more information on allocation unit sizes.
Memory Card Access Precautions
When the PLC is accessing the Memory Card, the BUSY indicator will light on
the CPU Unit. Observe the following precautions.
1,2,3... 1. Never turn OFF the power supply to the CPU Unit when the BUSY indica-
tor is lit. The Memory Card may become unusable if this is done.
185
File Memory Section 5-1
2. Never remove the Memory Card from the CPU Unit when the BUSY indi-
cator is lit. Press the Memory Card power OFF button and wait for the
BUSY indicator to go out before removing the Memory Card. The Memory
Card may become unusable if this is not done.
3. Insert the Memory Card with the label facing to the right. Do not attempt to
insert it in any other orientation. The Memory Card or CPU Unit may be
damaged.
4. A few seconds will be required for the CPU Unit to recognize the Memory
Card after it is inserted. When accessing a Memory Card immediately after
turning ON the power supply or inserting the Memory Card, program an
NC condition for the Memory Card Recognized Flag (A34315) as an input
condition, as shown below.
Execution
condition
or
PC Setup
Entire
area
Note The following three types of files can also be written from the CX-Program-
mer.
6\PERO7DEOH)LOHV
&RPPHQW)LOHV
3URJUDP,QGH[)LOHV
186
File Memory Section 5-1
CPU Unit
Data transfer
operations from the
CX-Programmer
User program Program files Symbol files
I/O memory Data files Comment files
Memory Program index files
Etc.
Programming Device, Card
FINS commands,
ladder instructions, or
control bits
EM file
Program files memory When a Memory Card is
Data files not inserted
Note Symbol tables (symbols, addresses, and I/O comments) can be treated as
files from the CX-Programmer.
File File name Extension Contents
Symbol table file SYMBOLS .SYM Global and local symbols
Comment file COMMENTS .CMT Rung comments and comments
(annotations)
Program index file PROGRAM .IDX Section names and section com-
ments
Data transfer operations can be performed for projects from the CX-Program-
mer to transfer all of the above files (symbol table files, comment files, pro-
gram index files) between the CPU Unit and a Memory Card or between EM
file memory. (Program index file transfers are supported starting from version
2.0.) The symbol table files and comment files can also be transferred
between the CX-Programmer, computer RAM, and a data storage device with
CX-Programmer version 1.2 or later.
The CX-Programmer can also be used to save data from individual parameter
areas in files with an extension of .STD. (These files cannot be used for auto-
matic transfer at startup. All parameter areas must be save in one file to
enable automatic transfer at startup.)
187
File Memory Section 5-1
5-1-3 Files
Files are formatted in DOS, and therefore can be used as regular files on a
Windows computer.
Files are identified by file names and extensions, as shown in the following
table. A file name is written using the following characters: Letters A to Z,
numbers 0 to 9, !, &, $, #, `, {, }, , ^, (, ), and _
The following characters cannot be used in file names: ,, ., /, , ?, *, , :, :, <, >,
=, +, space
The filename extensions depend upon the type of file being stored. Data files
can have extensions IOM, TXT, CSV, or IOR. (TXT, CSV, and IOR extensions:
Not supported by CS-series CS1 CPU Units that are pre-EV1.) Program files
have the extension OBJ and parameter files have the extension STD. The
location of a file in memory can be specified in the directory, and a directory
can be up to 5 subdirectories deep (counting the root directory).
General-purpose Files The following table shows file names and extensions of general-purpose files.
Type Name1 Extension Description Explanation
Data File ******** .IOM Specified range in Data from start to end word in Binary format
.TXT I/O memory word units (16 bits) located in
one area. TXT format2
(non-delimited or
The area can be the CIO, HR, tab-delimited)
WR, AR, DM, or EM Area.
.CSV CSV format2
(comma-delimited)
Program File ******** .OBJ Entire user pro- All cyclic and interrupt tasks as well as task data for
gram one CPU Unit.
Parameter ******** .STD PLC Setup, regis- Includes all initial settings for one CPU Unit.
Area File tered I/O table, The user does not have to distinguish parameter data
routing tables, in the file by type.
CPU Bus Unit
settings3, etc.
188
File Memory Section 5-1
Note 1. Make sure the names of the files to be transferred automatically at startup
are AUTOEXEC or ATEXEC@@.
2. The ATEXECDM.IOM and [email protected] files: Not supported by CS-
series CS1 CPU Units that are pre-EV1.
189
File Memory Section 5-1
3. One example of the CPU Bus Unit settings would be the Data Link Tables.
Refer to the operation manuals for specific Units for other setup data.
Backup Files (Not The files in the following table are created automatically when data is trans-
Supported by CS-series ferred to and from the Memory Card during backup operation.
CS1 CPU Units That Are
Pre-EV1)
Type Name1 Extension Description Explanation
Data file BACKUP .IOM DM Area words allo- Contains DM data from D20000 to D32767.
cated to Special I/O This file must exist on the Memory Card when
Units, CPU Bus reading data from the Memory Card during
Units, and Inner backup.
Boards (CS Series
only)
BACKUPIO .IOR I/O memory data Contains all of the data in the CIO, WR, HR, and
areas AR data areas as well as timer/counter Comple-
tion Flags and PVs.2
This file must exist on the Memory Card when
reading data from the Memory Card during
backup.
BACKUPDM .IOM General-purpose DM Contains DM data from D00000 to D19999.
Area This file must exist on the Memory Card when
reading data from the Memory Card during
backup.
BACKUPE@ .IOM General-purpose EM Contains all of the EM data for EM bank @ with
Area addresses ranging from E@_00000 to E@_32767.
(The maximum bank number depends upon the
model of CPU Unit being used.)
This file must exist on the Memory Card when read-
ing data from the Memory Card during backup.
When data is backed up to the Memory Card, all
of the data in each EM bank is automatically writ-
ten to a separate file.
Program file BACKUP .OBJ Entire user program Contains all cyclic and interrupt task programs as
well as task data for one CPU Unit.
This file must exist on the Memory Card when
reading data from the Memory Card during
backup.
Parameter file .STD PLC Setup, regis- Contains all initial settings for one CPU Unit.
tered I/O table, rout- The user does not have to distinguish parameter
ing tables, CPU Bus data in the file by type.
Unit settings3, etc. This file must exist on the Memory Card when
reading data from the Memory Card during
backup.
Unit/Board BACKUP@@ .PRM Data for specific Unit Control backup data from one Unit or Board.
backup files (where @@ is or Board Refer to 6LPSOH %DFNXS )XQFWLRQ for
(CS1-H, CJ1- the unit details.
H, or CJ1M address of
CPU Units the
only) Unit/Board
being backed
up)
Note 1. Make sure the names of the files used for backup are BACKUP@@.
2. The CIO Area, WR Area, Timer/Counter Completion Flags and PVs, and
force-set/force-reset data that is read from the Memory Card at startup will
be cleared. This data can be retained with the following PLC Setup set-
tings: IOM Hold Bit Status at Startup and Forced Status Hold Bit Status at
Startup.
190
File Memory Section 5-1
3. One example of the CPU Bus Unit settings would be the Data Link Tables.
Refer to the operation manuals for specific Units for other setup data.
Directories
It is possible to access files in subdirectories with CS/CJ-series PLCs, but
Programming Consoles can access files only when they are in the root direc-
tory. The maximum length of a directory path is 65 characters. Be sure not to
exceed the maximum number of characters when creating subdirectories in
the Memory Card with a program such as Windows.
File Sizes
The size of files in bytes can be calculated with the equations in the following
table.
File type File size
Data files (.IOM) (Number of words 2) + 48 bytes
Example: Entire DM Area (D00000 to D32767)
(32,768 words 2) + 48 = 65,584 bytes
Data files (.TXT or .CSV) The file size depends upon the number of delimiters and
carriage returns being used. The delimiter code is one
byte and the carriage return code is two bytes.
Example 1: Non-delimited words, no carriage return
123456789ABCDEF012345678 occupies 24 bytes.
Example 2: Delimited words, carriage return every 2 fields
1234,5678
9ABC,DEF0
1234,5678
occupies 33 bytes.
Example 3: Delimited double words, carriage return every
2 fields
56781234,DEF01234
56781234
occupies 29 bytes.
Program files (.OBJ) (Number of steps used 4) + 48 bytes (See note.)
Parameter files (.STD) 16,048 bytes
Note Calculate the number of steps in the program file by subtracting the available
UM steps from the total UM steps. These values are shown in the CX-Pro-
grammers Cross-Reference Report. Refer to the CX-Programmer User Man-
ual for details.
191
File Memory Section 5-1
Data Files
General-purpose Files
1,2,3... 1. General-purpose data files have filename extensions IOM, TXT, or CSV.
(The TXT and CSV files: Not supported by CS-series CS1 CPU Units that
are pre-EV1.)
Extension Data format Contents Words/field
.IOM Binary CS/CJ-series data format ---
.TXT Non-delimited ASCII This format is created by converting one-word fields of I/O 1 word
(See notes.) words format memory (4-digit hexadecimal) to ASCII and packing the
fields without delimiters. Records can be delimited with car-
riage returns.
Non-delimited This format is created by converting two-word fields of I/O 2 words
double words memory (8-digit hexadecimal) to ASCII and packing the
fields without delimiters. Records can be delimited with car-
riage returns.
Tab-delimited This format is created by converting one-word fields of I/O 1 word
words memory (4-digit hexadecimal) to ASCII and delimiting the
fields with tabs. Records can be delimited with carriage
returns.
Tab-delimited This format is created by converting two-word fields of I/O 2 words
double words memory (8-digit hexadecimal) to ASCII and delimiting the
fields with tabs. Records can be delimited with carriage
returns.
.CSV Comma-delimited This format is created by converting one-word fields of I/O 1 word
(See notes.) words memory (4-digit hexadecimal) to ASCII and delimiting the
fields with commas. Records can be delimited with carriage
returns.
Comma-delimited This format is created by converting two-word fields of I/O 2 words
double words memory (8-digit hexadecimal) to ASCII and delimiting the
fields with commas. Records can be delimited with carriage
returns.
192
File Memory Section 5-1
e) Delimiters:
When there are no delimiters, the fields are packed consecutively
and then stored. When delimited by commas, commas are insert-
ed between fields before they are stored. When delimited by tabs,
tab codes are inserted between fields before they are stored.
When delimiters (commas or tabs) are specified in FREAD(700),
the data is read as delimited data with one-word delimiters (com-
mas or tabs).
f) Carriage Returns:
Data is packed consecutively when carriage returns are not used.
When carriage returns are used, a carriage return code is inserted
after the specified number of fields. An offset from the beginning
of the file (starting read word or starting write word) cannot be
specified in the FREAD(700)/FWRIT(701) instructions if carriage
returns are used in the file.
g) Number of Fields:
The overall amount of data in the file depends upon the number of
fields (number of write items) specified in the FWRIT(701) instruc-
tion and the number of words/field. There is one word/field when
words are used and two words/field when double words are used.
2. Data files do not contain information indicating what data is stored, i.e.,
what memory area is stored. Be sure to give file names that indicate the
contents, as shown in the examples below, to aid in file management.
Examples: D00100.IOM, CIO0020.IOM
Data from the beginning of the file will be written starting at the address
specified in I/O memory even if the data originally written to the data file
(IOM, TXT, or CSV) is not from the same area. For example, if CIO data in
a file is written to the DM Area from a Programming Device, the data will
be read to the DM Area of the CPU Unit without any indication that the area
is different.
Note Data files with the TXT and CSV format contain hexadecimal (0 to 9, A to F)
data that allows the I/O memory numerical data to be exchanged with spread-
sheet programs.
IOM Data File Structure The following illustration shows the binary data structure of a data file
(ABC.IOM) containing four words from I/O memory: 1234 Hex, 5678 Hex,
9ABC Hex, and DEF0 Hex. The user, however, does not have to consider the
data format in normal operations.
8 bytes
Contents of ABC.IOM
CSV/TXT Data File The following illustration shows the data structure of a CSV data file
Structure (Single Word) (ABC.CSV) with single-word fields containing four words from I/O memory:
1234 Hex, 5678 Hex, 9ABC Hex, and DEF0 Hex. The structure of the TXT file
with single-word fields is the same.
193
File Memory Section 5-1
4 bytes
I/O memory Converted
to ASCII
Delimiter
4 bytes
The file displayed as text.
Delimiter
Contents of ABC.CSV
CSV/TXT Data File The following illustration shows the data structure of a CSV data file
Structure (Double Word) (ABC.CSV) with double-word fields containing four words from I/O memory:
1234 Hex, 5678 Hex, 9ABC Hex, and DEF0 Hex. The structure of the TXT file
with double-word fields is the same.
Converted to
I/O memory ASCII (Upper
word first)
8 bytes
Delimiter
Contents of ABC.CSV
Creating Data Files with Use the following procedure to create TXT and CSV data files with spread-
Spreadsheet Software sheet software such as Microsoft Excel.
6HWWKHFHOOFRQWHQWVWRQXPHULFRUFKDUDFWHUV
,QSXW FKDUDFWHUV LQ HDFK FHOO LI VLQJOHZRUG ILHOGV DUH EHLQJ XVHG RU
FKDUDFWHUV LI GRXEOHZRUG ILHOGV DUH EHLQJ XVHG )RU H[DPSOH LI VLQJOH
ZRUGILHOGVDUHEHLQJXVHGLQSXW$QRWMXVW$
%HVXUHWRLQSXWRQO\KH[DGHFLPDOFKDUDFWHUVWR$WR)RUDWRILQ
WKHFHOOV2WKHUFKDUDFWHUVDQGFRGHVFDQQRWEHXVHG
When you want to store hexadecimal digits in I/O memory, it is helpful to con-
vert the spreadsheets decimal inputs to hexadecimal. Use the following pro-
cedure to convert to hexadecimal.
194
File Memory Section 5-1
([DPSOH,QSXWWLQJQRQQHJDWLYHGHFLPDOYDOXHV
Item Converting unsigned decimal to 4-digit Converting unsigned decimal to 8-digit
hexadecimal hexadecimal
Function DEC2HEX(cell_location,4) DEC2HEX(cell_location,8)
used
Example Input 10 in decimal and convert to 000A in 4-digit Input 10 in decimal and convert to 0000000A in
hexadecimal. 8-digit hexadecimal.
Data Files Transferred There are 3 kinds of files that are transferred automatically at startup when
Automatically at Startup the automatic transfer at startup function is being used.
$872(;(&,20 '0 ZRUGV DOORFDWHG WR 6SHFLDO ,2 8QLWV DQG ,QQHU
%RDUGV
7KH FRQWHQWV RI WKLV ILOH DUH WUDQVIHUUHG WR WKH '0 $UHD EHJLQQLQJ DW
'ZKHQSRZHULVWXUQHG21
$7(;(&'0,20*HQHUDOSXUSRVH'0ZRUGV
7KH FRQWHQWV RI WKLV ILOH DUH WUDQVIHUUHG WR WKH '0 $UHD EHJLQQLQJ DW
'ZKHQSRZHULVWXUQHG21
$7(;(&(@,20*HQHUDOSXUSRVH(0ZRUGV
7KH FRQWHQWV RI WKLV ILOH DUH WUDQVIHUUHG WR WKH (0 $UHD EHJLQQLQJ DW
(@BZKHQSRZHULVWXUQHG21
When creating the data files listed above, always specify the first address
shown above (D20000, D00000, or E@_00000) and make sure that the size of
the file does not exceed the capacity of the specified data area.
All of the data in each file will always be transferred starting at the specified
first address (D20000, D00000, or E@_00000).
195
File Memory Section 5-1
2. When using the CX-Programmer, you can specify a data file that will ex-
ceed the maximum DM Area address D32767 or maximum EM Area ad-
dress of E@_32767. If the AUTOEXEC.IOM file exceeds the boundary of
the DM area, all remaining data will be written to the EM Area starting at
E0_00000 and continuing in order of memory address and banks through
the final bank. It is thus possible to automatically transfer data to both the
DM and EM Areas at startup. Likewise, if the [email protected] file is larger
than an EM bank, the remaining data will be written to subsequent EM
banks.
3. The System Setups for Special I/O Units, CPU Bus Units, and the Inner
Board (CS Series only) can be changed by using different AUTOEX-
EC.IOM files containing different settings for the Special I/O Unit Area
(D20000 to D29599), CPU Bus Unit Area (D30000 to D31599), and the In-
ner Board Area (CS Series only, D32000 to D32099). Memory Cards can
thus be used to create libraries of System Setup data for Special I/O Units,
CPU Bus Units, and Inner Boards (CS Series only) for different systems or
devices.
Backup Data Files The backup function creates 4 kinds of data files as described below.
To backup data, turn pin 7 ON and turn pin 8 OFF on the CPU Units DIP
switch, insert the Memory Card, and press and hold the Memory Card Power
Supply Switch for three seconds. The four backup files (BACKUP.IOM, BACK-
UPIO.IOR, BACKUPDM.IOM, and [email protected]) will be created automat-
ically and written to the Memory Card.
The four backup files are used exclusively by the backup function, although
three of the files (BACKUP.IOM, BACKUPDM.IOM, and [email protected])
can be created with Programming Device operations. (BACKUPIO.IOR can-
not be created with Programming Device operations.)
196
File Memory Section 5-1
Note 1. FINS commands for file memory operations can be sent from host comput-
ers connected via a Host Link, another PLC connected to a network (using
CMND(490)), or the local PLCs program (using CMND(490)). (For CS-se-
ries CS1 CPU Units that are pre-EV1, file memory operations cannot be
executed using CMND(490) in the same CPU Unit for which the file mem-
ory operations are being performed.
2. Other Operations: Format file memory, read file data, write file data,
change file name, read file memory data, delete file, copy file, create sub-
directory, and change file name.
3. Data files with the TXT or CSV formats can be read and written only with
the FREAD(700) and FWRIT(701) instructions. They cannot be read and
written with a Programming Device.
4. Version V1.2 and higher versions of the CX-Programmer can be used to
transfer program files (.OBJ) between the computers RAM and a storage
device.
5-1-5 Applications
File memory can be used for the following applications.
Data Files In this application, DM Area data settings (for Special I/O Units, CPU Bus
Units, and Inner Boards (CS Series only)) are stored in the Memory Card. If
the data file is named AUTOEXEC.IOM, the settings stored in the file will be
automatically transferred when power is turned ON.
Example: ABC.IOM
In this application, operation data (trends, quality control, and other data) gen-
erated during program execution is stored in EM file memory using the
WRITE DATA FILE instruction (FWRIT(701)).
197
File Memory Section 5-1
Trends, etc.
EM file memory
Note Data that is often accessed, such as trend data, is better stored in EM file
memory rather than on a Memory Card.
ASCII Data Files Production data that has been saved on the Memory Card in the TXT or CSV
(.TXT and .CSV) format can be transferred to a personal computer via a Memory Card Adapter
and edited with a spreadsheet program (Not supported by CS-series CS1
CPU Units that are pre-EV1).
Memory Card
Conversely, data such as Special I/O Unit settings can be created with a
spreadsheet program in TXT or CSV format, stored on a Memory Card, and
read to the CPU Unit by FREAD(700) (Not supported by CS-series CS1 CPU
Units that are pre-EV1).
Program Files(.OBJ) In this application, programs that control different processes are stored on
individual Memory Cards. The entire PLC configuration (program, PLC Setup,
etc.) can be changed by inserting a different Memory Card and using the
automatic transfer at startup function.
A.OBJ B.OBJ C.OBJ
The entire program can be replaced during operation from the program itself
(without a Programming Device) using an Auxiliary Area control bit (Not sup-
ported by CS-series CS1 CPU Units that are pre-EV1).
During operation .OBJ
Replace program.
Parameter Area Files In this application, the PLC Setup, routing tables, I/O table, and other data for
(.STD) particular devices or machines are stored in Memory Cards. The data can be
transferred to another device or machine just by switching the Memory Card.
198
Manipulating Files Section 5-2
Use A.STD.
Backup Files The backup function can be used to store all of the CPU Units data (the entire
I/O memory, program, and parameter area) on the Memory Card without a
Programming Device. If a problem develops with the CPU Units data, the
backed-up data can be restored immediately. (Not supported by CS-series
CS1 CPU Units that are pre-EV1)
Symbols Table Files The CX-Programmer can be used to save program symbols and I/O com-
ments in symbols table files called SYMBOLS.SYM in Memory Cards or EM
file memory.
Comment Files The CX-Programmer can be used to save program rung comments in com-
ment files called COMMENTS.CMT in Memory Cards or EM file memory.
199
Manipulating Files Section 5-2
Create user program file. Programming Programming Create I/O memory file
Device Programming Programming
Console Device Console
Memory Card
Memory Card
User User
program program I/O
memory
I/O
memory
User
EM file memory
program I/O EM file memory
memory
Memory Card
Parameter
area
Parameter
area
Parameter
EM file memory
area
A Memory Card can be installed in a computers PLC Card slot with the HMC-
AP001 Memory Card Adapter (sold separately). Installing a Memory Card in
the computer allows the files in the card to be read and written by other pro-
grams, such as Windows Explorer.
200
Manipulating Files Section 5-2
Memory Card
1,2,3... 1. Double-click the Memory Card icon in the Project Window with the CPU
Unit online. The Memory Card Window will be displayed.
2. To transfer from the CPU Unit to file memory, select the program area, I/O
memory area, or parameter area in the project work space, select Transfer
from the File Memory, and then select transfer to the Memory Card or to
EM file memory.
or To transfer from file memory to the CPU Unit, select file in file memory
and then drag it to the program area, I/O memory area, or parameter area
in the project work space and drop it.
Note Use project transfer operations to create and read symbol table files (SYM-
BOLS.SYM) and comment files (COMMENTS.CMT) on the CX-Programmer.
Programming Console
000000 CT00
CLR
CONT 0: Transfer
FUN SHIFT
# 1: Verify
0: Initialize
1: Delete
The following operations can be performed.
Item 1 Item 2 Item 3 Item 4 Item 5
0: Send 0: PLC to Memory Card Select OBJ, CIO, HR, WR, Set transfer start and Media type, file name
AR, DM, EM, or STD. end addresses.
1: Memory Card to PLC Select OBJ, CIO, HR, WR, Set transfer start and Media type, file name
AR, DM, EM, or STD. end addresses.
1: Verify Select OBJ, CIO, HR, WR, Set comparison start and Media type, file name
AR, DM, EM, or STD. end addresses.
201
Manipulating Files Section 5-2
FINS command
Memory Card
I/O
memory
User
program EM file memory
Parame-
ter area
I/O
memor y
Another PLC on Memory Card
the network CMND User
instruction
program
FINS command
202
Manipulating Files Section 5-2
Note A computer on an Ethernet Network can read and write file memory (Memory
Cards or EM file memory) on a CPU Unit through an Ethernet Unit. Data in
files can be exchanged if the host computer functions as an FTP client and
the CS/CJ-series PLC functions as an FTP server.
Memory Card or
FTP command EM file memory
203
Manipulating Files Section 5-2
FREAD/FWRIT CMND
instruction instruction
Operation
Memory Card
Memory Card Operation
I/O memory I/O memory I/O memory
FREAD(700)/FWRIT(701) Instructions
FREAD(700) and FWRIT(701) transfer data between I/O memory and file
memory. All CJ CPU Units can transfer binary data (.IOM files) and the V1
CPU Units can also transfer ASCII files (.TXT and .CSV files).
Name Mnemonic Description
READ DATA FREAD(700) Reads specified data file data or data elements
FILE to specified I/O memory.
WRITE DATA FWRIT(701) Uses specified I/O memory area data to create
FILE a specified data file.
204
Manipulating Files Section 5-2
Transferring ASCII Files ASCII files can be transferred as well as binary files, so the third and fourth
(Not supported by CS- digits of the instructions control word operand (C) indicate the type of data file
series CS1 CPU Units that being transferred and the number of fields between carriage returns.
are pre-EV1) Bits in C Settings Programming Device
limitations
12 to 15 Data type If CX-Programmer V1.1 or an
0: Binary (.IOM) earlier version is being used,
1: Non-delimited words (.TXT) only 0 Hex (.IOM files) can be
2: Non-delimited double-words (.TXT) specified directly.
3: Comma-delimited words (.CSV) If CX-Programmer V1.2 or a
4: Comma-delimited double-words (.CSV) later version (or a Program-
5: Tab-delimited words (.TXT) ming Console) is being used,
6: Tab-delimited double-words (.TXT) the control word bits can be
set to between 0 and 6 Hex.
08 to 11 Carriage returns If CX-Programmer V1.1 or an
0: No returns earlier version (or a Program-
8: Return every 10 fields ming Console) is being used,
9: Return every 1 field only 0 Hex (no returns) can
A: Return every 2 fields be specified directly.
B: Return every 4 fields If CX-Programmer V1.2 or a
C: Return every 5 fields later version is being used,
D: Return every 16 fields the control word bits can be
set to 0 Hex or to between 8
and D Hex.
Note The time from the CPU Units internal clock is used to date files created in file
memory with FWRIT(701).
Only one file memory operation may be executed at a time, so FREAD(700)
and FWRIT(701) must not be executed when any of the following file memory
operations are being performed:
205
Manipulating Files Section 5-2
206
Manipulating Files Section 5-2
207
Manipulating Files Section 5-2
Note There are other FINS commands that can be sent to the local PLC in addition
to the ones related to file memory operations that are listed in the table above.
The File Memory Operation Flag must be used to prevent simultaneous exe-
cution of these other FINS commands, too.
208
Manipulating Files Section 5-2
recorded in advance and the specified program file must exist on the Memory
Card in order to replace the program during operation.
CPU Unit
Replacement
User program
Memory Card
Normal processing
The entire program
is replaced.
Replacement
Execution Start Bit
condition
The CPU Unit will
execute the in-
structions remain-
ing in the cycle af-
Normal processing ter the Replace-
ment Start Bit is
turned ON.
The program can also be replaced when program execution is stopped (PRO-
GRAM mode) by turning ON the Replacement Start Bit from a Programming
Device.
Note The replacement program file cannot be read from EM file memory.
The Replacement Start Bit (A65015) can be turned ON at any location (pro-
gram address) in the program. The CPU Unit will execute the instructions
remaining in the cycle after the Replacement Start Bit goes from OFF to ON.
The program will not be executed while the program is being replaced. After
the program has been replaced, operation will be started again just as if the
CPU Unit were switched from PROGRAM mode to RUN or MONITOR mode.
The program will be replaced at the end of the cycle in which the Replace-
ment Start Bit was turned from OFF to ON, i.e., after END(001) is executed in
the last task in the program.
209
Manipulating Files Section 5-2
Note 1. Turn ON the IOM Hold Bit (A50012) if you want to maintain the status of
I/O memory data through the program replacement.
Turn ON the Forced Status Hold Bit (A50013) if you want to maintain the
status of force-set and force-reset bits through the program replacement.
2. If the IOM Hold Bit (A50012) is ON before the program is replaced, the sta-
tus of bits in I/O memory will be maintained after program replacement. Be
sure that external loads will operate properly with the same I/O memory
data.
Likewise, if the Forced Status Hold Bit (A50013) is ON before the program
is replaced, the status of force-set and force-reset bits will be maintained
after program replacement. Be sure that external loads will operate prop-
erly with the same force-set and force-reset bits.
Replacement File The program file specified in the Program File Name (A654 to A657) will be
read from the Memory Card and will replace the existing program at the end of
the cycle in which the Replacement Start Bit (A65015) is turned from OFF to
ON.
File File name and Specifying the replacement file name (********)
extension
Program file ********.OBJ Write the replacement program file name to A654
through A657 before program replacement.
Conditions Required for The following conditions are required in order to replace the program during
Program Replacement operation.
7KHSURJUDPSDVVZRUG$$KDVEHHQZULWWHQWR$
7KH SURJUDP ILOH VSHFLILHG LQ WKH 3URJUDP )LOH 1DPH ZRUGV $ WR
$H[LVWVLQWKH0HPRU\&DUGVURRWGLUHFWRU\
7KH0HPRU\&DUGKDVEHHQGHWHFWHGE\WKH&388QLW$21
1RIDWDOHUURUVKDYHRFFXUUHG
1RILOHPHPRU\RSHUDWLRQVDUHEHLQJH[HFXWHG$2))
'DWDLVQRWEHLQJZULWWHQWRWKH3URJUDP$UHD
7KHDFFHVVULJKWLVDYDLODEOH)RUH[DPSOHGDWDLVQRWEHLQJWUDQVIHUUHG
IURPWKH&;3URJUDPPHUWRWKH3/&
Note The program may be transferred in any operating mode.
CPU Operation during The CPU Units operation will be as follows during program replacement:
Program Replacement 3URJUDPH[HFXWLRQ6WRSSHG
&\FOHWLPHPRQLWRULQJ1RPRQLWRULQJ
Operations Continuing When the IOM Hold Bit (A50012) is ON, the data in the following memory
during and after Program areas will be maintained: the CIO Area, Work Area (W), Timer Completion
Replacement Flags (T), Index Registers (IR), Data Registers (DR), and the current EM bank
number.
Note Timer PVs will be cleared during program replacement.
If the IOM Hold Bit is ON when the program is transferred, loads that were
being output before program replacement will continue to be output after
replacement. Be sure that external loads will operate properly after program
replacement.
The status of force-set and force-reset bits will be maintained through the pro-
gram replacement if the Forced Status Hold Bit (A50013) is ON.
Interrupts will be masked.
210
Manipulating Files Section 5-2
Operations after The status of the cyclic tasks depends upon their operation-start properties.
Program Replacement (Their status is the same as it would be if the PLC were switched from PRO-
GRAM to RUN/MONITOR mode.)
The First Cycle Flag (A20011) will be ON for one cycle after program execu-
tion resumes. (The status is the same as it would be if the PLC were switched
from PROGRAM to RUN/MONITOR mode.)
211
Manipulating Files Section 5-2
Example Program 1
Store program files ABC.OBJ and XYZ.OBJ in the Memory Card and select
one program or the other depending upon the value of D00000. Set D00000
to #1234 when selecting ABC.OBJ or set it to #5678 when selecting
XYZ.OBJ.
212
Manipulating Files Section 5-2
Start and execute another task to perform any processing required before pro-
gram replacement or IOM Hold Bit processing.
Main Task (Cyclic task number 0)
MOV
First Cycle Flag Program version
Version storage area
Execution
condition
Replacement
Start Bit
No File Flag
213
Manipulating Files Section 5-2
Processing to pro-
tect data before pro-
Always ON Flag gram replacement
begins
Outputs to required
loads during pro-
gram replacement.
Example Program 2
Store program files for several devices and the program file for automatic
transfer at startup (AUTOEXEC.OBJ) in a Memory Card. When the PLC is
turned ON, the automatic transfer at startup file is read and that program is
replaced later with a program file for a different device.
AUTOEXEC.OBJ ABC.OBJ
Replacement
Start Bit
Memory Card
Detected Flag
214
Manipulating Files Section 5-2
215
Manipulating Files Section 5-2
CPU Unit
Procedure
216
Manipulating Files Section 5-2
Pin 7: ON
Press and hold the
Memory Card Power
Switch for three seconds.
Memory Card
Note 1. The backup function will override the automatic transfer at startup function,
so the backup files will be read to the CPU Unit when the PLC is turned ON
even if pin 2 of the DIP switch is ON.
2. Data will not be read from the Memory Card to the CPU Unit if pin 1 of the
DIP switch is ON (write-protecting program memory).
3. When the backup files are read from the Memory Card by the backup func-
tion, the status of I/O memory and force-set/force-reset bits will be cleared
unless the necessary settings are made in the Auxiliary Area and PLC Set-
up.
If the IOM Hold Bit (A50012) is ON and the PLC Setup is set to maintain
the IOM Hold Bit Status at Startup when the backup files are written, the
217
Manipulating Files Section 5-2
status of I/O memory data will be maintained when data is read from the
Memory Card.
If the Forced Status Hold Bit (A50013) is ON and the PLC Setup is set to
maintain the Forced Status Hold Bit Status at Startup when the backup
files are written, the status of force-set and force-reset bits will be main-
tained when data is read from the Memory Card.
4. A CS1-H, CJ1-H, or CJ1M CPU Unit will remain in PROGRAM mode after
the simple backup operation has been performed and cannot be changed
to MONITOR or RUN mode until the power supply has been cycled. After
completing the backup operation, turn OFF the power supply to the CPU
Unit, changes the settings of pin 7, and then turn the power supply back
ON.
Power ON
Program Program Program
Memory Memory Memory
Card Card Compare Card
I/O memory I/O memory I/O memory
Note 1. Refer to Verifying Backup Operations with Indicators on page 221 for de-
tails on the results of read, write, and compare operations.
2. Refer to 5-3-2 Operating Procedures for Memory Cards for guidelines on
the time required for Memory Card backup operations.
218
Manipulating Files Section 5-2
Backup Files
Data Files
File name and Data area and range of Backup from Restore from Comparing Files required
extension addresses stored I/O memory to Memory Card Memory Card when
Memory Card to I/O memory to I/O memory restoring data
(creating files)
CPU Unit CS/CJ CS1/ CS1-H/
CJ1 CJ1-H
BACKUP.IOM DM D20000 to Yes Yes Yes --- Required in
D32767 Memory Card
BACKUPIO.IOR CIO 0000 to 6143 Yes ---4 Yes --- Required in
(Including forced Memory Card
bit status.)
WR W000 to W511 Yes ---4 Yes ---
(Including forced
bit status.)
HR H000 to H511 Yes Yes Yes ---
AR A000 to A447 Yes --- --- ---
A448 to A959 Yes Yes Yes ---
Timer 1 T0000 to T4095 Yes Yes 4 Yes ---
219
Manipulating Files Section 5-2
If the IOM Hold Bit (A50012) is ON and the PLC Setup is set to maintain
the IOM Hold Bit Status at Startup when the backup files are written, the
status of I/O memory data will be maintained when data is read from the
Memory Card.
If the Forced Status Hold Bit (A50013) is ON and the PLC Setup is set to
maintain the Forced Status Hold Bit Status at Startup when the backup
files are written, the status of force-set and force-reset bits will be main-
tained when data is read from the Memory Card.
Program Files
File name and Contents Backup from Restore from Comparing Files required
extension I/O memory to Memory Card Memory Card when
Memory Card to I/O memory to I/O memory restoring data
(creating files)
CPU Unit CS/CJ
BACKUP.OBJ Entire user program Yes Yes Yes Required in
Memory Card
Parameter Files
File name and Contents Backup from Restore from Comparing Files required
extension I/O memory to Memory Card Memory Card when
Memory Card to I/O memory to I/O memory restoring data
(creating files)
CPU Unit CS/CJ
BACKUP.STD PLC Setup Yes Yes Yes Required in
Registered I/O tables Memory Card
Routing tables
CPU Bus Unit setup
Etc.
220
Manipulating Files Section 5-2
221
Manipulating Files Section 5-2
Note 1. When the backup operation is completed normally, power to the Memory
Card will go OFF when the MCPWR indicator goes OFF. If the Memory
Card will be used again, press the Memory Card Power Switch to supply
power and execute the desired operation.
2. When data is written for a simple backup operation from a CS1-H, CJ1-H,
or CJ1M CPU Unit, errors for insufficient Memory Card capacity can be
checked in A397 (Simple Backup Write Capacity). If A397 contains any
value except 0000 Hex after the write operation has been executed, the
value will indicate the capacity that is required in the Memory Card in
Kbytes.
3. With CS1-H, CJ1-H, or CJ1M CPU Units, the backup files for Units and
Boards are also compared.
222
Manipulating Files Section 5-2
Note These flags are related for the CS1-H, CJ1-H, or CJ1M CPU Units because
the CPU Unit will automatically using an available communications port when
writing or comparing data for a Memory Card.
223
Manipulating Files Section 5-2
is written to the Memory Card. The data is backed up separately for each Unit
and Board.
Memory Card power
supply switch
DeviceNet Unit or other
specific Unit/Board CS1-H or CJ1-H CPU Unit
All data
Simple
backup Write
data Read Memory Card
Compare
Application
This function can be used to back up data for the entire PLC, including the
CPU Unit, DeviceNet Units, Serial Communications Units/Boards, etc. It can
also be used for Unit replacement.
Unit/Board Backup Files
The data from each Unit and Board is stored in the Memory Card using the
following file names: BACKUP@@.PRM. Here, @@ is the unit address of the
Unit or Board in hexadecimal.
Note Unit addresses are as follows:
CPU Bus Units: Unit number + 10 Hex
Special I/O Units: Unit number + 20 Hex
Inner Board: E1 Hex
These files are also used when reading from the Memory Card or comparing
Memory Card data.
Applicable Units and Boards
For Unit and Board data to be backed up, the Unit/Board must also support
the backup function. Refer to the operation manual for the Unit/Board for
details on support.
The following Units and Boards are supported as of July 2001.
Unit/Board Model numbers Backup data
(for CS1-H or CJ1-H CPU Unit only)
DeviceNet Unit CS1W-DRM21-V1 Device parameters (all data in EEPROM in
CJ1W-DRM21 the Unit)
(Although this is the same data as is backed
up from the Memory Card backup function
supported by the Unit or the DeviceNet Con-
figuration (Ver. 2.0), there is no file compati-
bility.
Serial Communi- CS1W-SCU21-V1 Protocol macro data
cations Unit CJ1W-SCU41 (Including both standard system protocols
Serial Communi- CS1W-SCB21-V1 and user-defined protocols from the flash
cations Boards CS1W-SCB41-V1 memory in the Unit or Board)
Note Data from the Units and Boards listed above will be automatically backed up
for the simple backup operation. There is no setting available to include or
exclude them.
Procedure
The procedure for the simple backup operation is the same regardless of
whether or not data is being backed up from specific Units and Boards
(including writing, reading, and comparing).
224
Manipulating Files Section 5-2
Backing Up Data
Simple
backup data Memory Card
Backup
When the Power Supply Switch is pressed, the MCPWR Indicator will flash
once, light during the write operation, and then go OFF if the write is com-
pleted normally.
Restoring Data
When the power supply is turned ON, the MCPWR Indicator will flash
once, light during the read operation, and then go OFF if the read is com-
pleted normally.
Comparing Data
225
Using File Memory Section 5-3
When the Power Supply Switch is pressed, the MCPWR Indicator will flash
once, light during the compare operation, and then go OFF if the compare
is completed normally and the data is the same.
Note Confirm that the Units and Boards are running properly before attempting the
above operations. The write, read, and compare operations will not be per-
formed unless the Units and Boards are running properly.
Or Memory Card
CX-Programmer
Programming
Console
EM File Memory
1,2,3... 1. Use a Programming Device like a Programming Console and set EM file
memory settings in the PLC Setup to enable EM file memory, and then set
the specified bank number for EM file memory to 0 to C Hex.
CX-Programmer
Programming
Console
CX-Programmer
Programming
Console
Initializing Individual EM A specified EM bank can be converted from ordinary EM to file memory.
File Memory
Note The maximum bank number for CJ-series CPU Units is 6.
226
Using File Memory Section 5-3
Bank 0 Bank 0
1. Set n in PLC Setup.
Bank n Bank n
2. Use a Programming Device or
Converted to FINS command to format starting at n.
file memory
Bank C Bank C 3. "n" is stored in A344.
Bank 0 Bank 0
2. If a Programming Device or FINS command
is used for formatting, memory starting at n
Bank n Bank n will be cleared to 0000 Hex.
Converted to Cleared
file memory
3. FFFF Hex will be stored in A344 to indicate
Bank C Bank C that there is no EM file memory.
PLC Setup
Address Name Description Initial setting
136 EM File Memory 0000 Hex: None 0000 Hex
Starting Bank 0080 Hex: Starting at bank No. 0
008C hex: Bank No. C
The EM area starting from the specified bank num-
ber will be converted to file memory.
(Only banks 0 to 6 can be specified for a CJ-series
CPU Unit.)
Reading/Writing Symbol Use the following procedure to transfer symbol tables or comments created on
Tables and Comments the CX-Programmer to and from a Memory Card or EM file memory.
using he CX-Programmer
1,2,3... 1. Place a formatted Memory Card into the CPU Unit or format EM File Mem-
ory.
2. Place the CX-Programmer online.
3. Select Transfer and then To PLC or From PLC from the PLC Menu.
227
Using File Memory Section 5-3
Memory Card
Or Initialize
CX-Programmer
Programming
Console
3. Use a Programming Device to name the CPU Unit data (user program, I/O
memory, parameter area), and then save the data to Memory Card. (Use
a Programming Device to read the Memory Card file to the CPU Unit.)
Automatically Transferring Files at Startup
1,2,3... 1. Insert a Memory Card into the CPU Unit. (Already initialized.)
Memory Card
Or Initialize
CX-Programmer
Programming
Console
Note A user program and parameter area file must be on the Memory Card.
3. Turn OFF the PLC power supply.
4. Turn ON DIP switch pin 2 (automatic transfer at startup).
228
Using File Memory Section 5-3
Note If pin 7 is ON and pin 8 is OFF, the backup function will be enabled
and will override the automatic transfer at startup function. (Turn
OFF pins 7 and 8 for automatic transfer at startup.)
5. Insert the Memory Card into the CPU Unit.
Memory Card
Simple Backup Function There are 3 backup operations: backing up data to the Memory Card, restor-
ing data from the Memory Card, and comparing data with the Memory Card.
Backing Up Data from the CPU Unit to the Memory Card
1,2,3... 1. Insert a Memory Card into the CPU Unit. (Already initialized.)
2. Turn ON pin 7 and turn OFF pin 8 on the CPU Units DIP switch.
3. Press and hold the Memory Card Power Supply Switch for three seconds.
4. Verify that the MCPWR Indicator flashes once and then goes OFF. (Other
changes indicate that an error occurred while backing up the data.)
Restoring Data from the Memory Card to the CPU Unit
1,2,3... 1. Insert the Memory Card containing the backup files into the CPU Unit.
229
Using File Memory Section 5-3
2. Turn ON pin 7 and turn OFF pin 8 on the CPU Units DIP switch.
3. The backup files will be restored when the PLC is turned ON.
4. Verify that the MCPWR Indicator flashes once and then goes OFF. (Other
changes indicate that an error occurred while restoring the data.)
Comparing Data in the Memory Card and CPU Unit
1,2,3... 1. Insert the Memory Card containing the backup files into the CPU Unit.
2. Turn OFF pins 7 and 8 on the CPU Units DIP switch.
3. Press and hold the Memory Card Power Supply Switch for three seconds.
4. The data matches if the MCPWR Indicator flashes once and then goes
OFF.
Note The MCPWR Indicator will flash if an error occurs while writing or comparing
data. This flashing will stop and the MCPWR Indicator will be lit when the
Memory Card Power Supply Switch is pressed.
The following table shows the time required for backup operations with a 20-
Kstep Program and 10-ms Cycle Time in RUN mode:
Mode Backing up Restoring Comparing
PROGRAM Approx. 50 s Approx. 30 s Approx. 7 s
RUN Approx. 5 min Approx. 2 min Approx. 7 s
The following table shows the time required for backup operations with a 30-
Kstep Program and 10-ms Cycle Time in RUN mode:
Mode Backing up Restoring Comparing
PROGRAM Approx. 50 s Approx. 30 s Approx. 7 s
RUN Approx. 5 min 30 s Approx. 2 min 40 s Approx. 7 s
The following table shows the time required for backup operations with a 250-
Kstep Program and 12-ms Cycle Time in RUN mode:
Mode Backing up Restoring Comparing
PROGRAM Approx. 1 min 30 s Approx. 1 min 30 s Approx. 20 s
RUN Approx. 13 min Approx. 7 min 30 s Approx. 20 s
Creating Variable Table Use the following CX-Programmer procedure to create variable table files or
and Comment Files comment files on Memory Cards or in EM file memory.
1,2,3... 1. Insert a formatted Memory Card into the CPU Unit or format EM file mem-
ory.
2. Place the CX-Programmer online.
3. Select Transfer and then To PLC or From PLC from the PLC Menu.
4. Select either Symbols or Comments as the data to transfer.
Note If a Memory Card is installed in the CPU Unit, data can be transferred only
with the Memory Card. (It will not be possible with EM file memory.)
230
Using File Memory Section 5-3
4. Use a Programming Device to read the file in EM file memory to the CPU
Unit.
Using FREAD(700)/FWRIT(701)/CMND(490)
1,2,3... 1. Use PLC Setup to specify the starting EM bank to convert to file memory.
2. Use a Programming Device to initialize EM file memory.
3. Use FWRIT(701) to name the file in the specified area of I/O memory and
then save the file to EM file memory.
4. Use FREAD(700) to read the file from the EM file memory to I/O memory
in the CPU Unit.
EM file memory operations can be executed by issuing FINS commands to
the local CPU Unit with CMND(490).
Power Interruptions while A file being updated may not be overwritten correctly if a power interruption
Accessing File Memory occurs while the CPU is accessing file memory (the Memory Card or EM file
memory). In this case, the affected file will be deleted automatically by the
system the next time that power is turned ON. The corresponding File Dele-
tion Notification Flag (A39507 for the Memory Card, A39506 for EM file mem-
ory) will be turned ON. The flag will be turned OFF the next time that the
power is turned OFF.
When a file is deleted, a deletion log file (DEL_FILE.IOM) will be created in
the root directory of the Memory Card or EM file memory. The deletion log file
can be read with CX-Programmer or FREAD(700) to check the following infor-
mation: The date that the file was deleted, the type of file memory (media) that
existed, the subdirectory, file name, and extension. When necessary, recreate
or recopy the deleted file.
The following diagram shows the structure of the deletion log file.
File size: 86 bytes
231
Using File Memory Section 5-3
232
SECTION 6
Advanced Functions
This section provides details on the following advanced functions: cycle time/high-speed processing functions, index
register functions, serial communications functions, startup and maintenance functions, diagnostic and debugging
functions, Programming Device functions, and the Basic I/O Unit input response time settings.
233
6-6-5 Disabling Power OFF Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
6-6-6 Clock Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
6-6-7 Program Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
6-6-8 Remote Programming and Monitoring . . . . . . . . . . . . . . . . . . . . . . . 292
6-6-9 Unit Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
6-6-10 Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
6-6-11 Startup Condition Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
6-7 Diagnostic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
6-7-1 Error Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
6-7-2 Output OFF Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
6-7-3 Failure Alarm Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
6-7-4 Failure Point Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
6-7-5 Simulating System Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
6-7-6 Disabling Error Log Storage of User-defined FAL Errors . . . . . . . . 300
6-8 CPU Processing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
6-8-1 CPU Processing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
6-8-2 Parallel Processing Mode and Minimum Cycle Times . . . . . . . . . . . 306
6-8-3 Data Concurrency in Parallel Processing with Asynchronous Memory Access306
6-9 Peripheral Servicing Priority Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
6-9-1 Peripheral Servicing Priority Mode. . . . . . . . . . . . . . . . . . . . . . . . . . 307
6-9-2 Temporarily Disabling Priority Mode Servicing. . . . . . . . . . . . . . . . 309
6-10 Battery-free Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
6-11 Other Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
6-11-1 I/O Response Time Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
6-11-2 I/O Area Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
234
Cycle Time/High-speed Processing Section 6-1
If the actual cycle time is longer than the minimum cycle time, the minimum
cycle time function will be ineffective and the cycle time will vary from cycle to
cycle.
Minimum cycle time Minimum cycle time Minimum cycle time
(Effective)
PLC Setup
Address Name Setting Default
208 Minimum Cycle Time 0001 to 7D00: 1 to 32,000 ms 0000 (no
Bits: 0 to 15 (1-ms units) minimum)
235
Cycle Time/High-speed Processing Section 6-1
Note If the peripheral servicing cycle exceeds 2.0 s for CS1-H, CJ1-H, or CJ1M
CPU Units in parallel processing mode, a peripheral servicing cycle time
exceeded error will occur and the CPU Unit will stop operation. If this hap-
pens, A40515 (Peripheral Servicing Cycle Time Over Flag) will turn ON.
236
Cycle Time/High-speed Processing Section 6-1
CS1W-IDP01: 0.1 ms
CJ1W-IDP01: 0.05 ms
C200H-ID501/ID215/MD501/MD115/MD215: 4 ms
237
Cycle Time/High-speed Processing Section 6-1
END Task
END Task
END Task
2. Immediate Refreshing
When an address in the I/O Area is specified as an operand in the immediate-
refreshing variation of an instruction, that operand data will be refreshed when
the instruction is executed. Immediate-refreshing instructions can refresh data
allocated to Basic I/O Units.
Immediate refreshing is also possible for the built-in I/O on CJ1M CPU Units.
Actual I/O data
Immediate refreshing
CIO 0001
CIO 0002
CIO 0003
CIO 0004
Note 1. When the instruction contains a bit operand, the entire word containing
that bit will be refreshed. When the instruction contains a word operand,
that word will be refreshed.
2. Input and source data will be refreshed just before execution of the instruc-
tion. Output and destination data will be refreshed just after execution of
the instruction.
3. The execution times for immediate-refreshing variations are longer than
the regular variations of instructions, so the cycle time will be longer. Refer
to 10-5 Instruction Execution Times and Number of Steps in the Operation
Manual for details.
238
Cycle Time/High-speed Processing Section 6-1
The following example shows IORF(097) used to refresh 8 words of I/O data.
0016
When a high-speed response is needed for input and output from a calcula-
tion, use IORF(097) just before and just after the calculation instruction.
Note IORF(097) has a relatively long instruction execution time and that execution
time increases proportionally with the number of words being refreshed, so it
can significantly increase the cycle time. Refer to 10-5 Instruction Execution
Times and Number of Steps in the Operation Manual for more details.
DLNK(226): CPU Bus Unit I/O Refresh (CS1-H, CJ1-H, or CJ1M CPU Units
Only)
DLNK(226) is used to refresh data for a CPU Bus Unit of a specified unit num-
ber. The following data is refreshed.
Words allocated to the Unit in the CIO Area
Words allocated to the Unit in the DM Area
Data specific to the Unit (See note.)
Note Data specific to a CPU Bus Unit would include data links for Control-
ler Link Unit or SYSMAC LINK Units, as well as remote I/O for De-
viceNet Units.
Example:
The instruction on the left would refresh the words
DLNK allocated to the Unit in the CIO Area and DM Area, and
#1
data specific to the CPU Bus Unit with unit number 1.
Application Example: With a long cycle time, the refresh interval for Controller
Link data links can be very long. This interval can be shortened by executing
DLNK(226) for the Controller Link Unit to increase the frequency of data link
refreshing.
239
Cycle Time/High-speed Processing Section 6-1
refreshing, but this cyclic refreshing can be disabled for individual Units in the
PLC Setup.
There are basically three reasons to disable cyclic refreshing:
1,2,3... 1. Cyclic refreshing for Special I/O Units can be disabled when the cycle time
is too long because so many Special I/O Units are installed.
2. If the I/O refreshing time is too short, the Units internal processing may not
be able to keep pace, the Special I/O Unit Error Flag (A40206) will be
turned ON, and the Special I/O Unit will not operate properly.
In this case, the cycle time can be extended by setting a minimum cycle
time in the PLC Setup or cyclic I/O refreshing with the Special I/O Unit can
be disabled.
3. Always disable cyclic refreshing for a Special I/O Unit when it will be re-
freshed in an interrupt task by IORF(097). An interrupt task error will occur
and the Interrupt Task Error Flag (A40213) will be turned ON if cyclic re-
freshing and IORF(097) refreshing are performed simultaneously for the
same Unit.
When cyclic refreshing has been disabled, the Special I/O Units data can be
refreshed during program execution with IORF(097).
PLC Setup
The Cyclic Refreshing Disable Bits for Special I/O Units 0 to 95 correspond
directly to the 96 bits in addresses 226 through 231.
Address Name Setting Default
226 bit 0 Cyclic Refreshing Disable Bit 0: Enabled 0 (Enabled)
for Special I/O Unit 0 1: Disabled
: : : :
231 bit 15 Cyclic Refreshing Disable Bit 0: Enabled 0 (Enabled)
for Special I/O Unit 95 1: Disabled
The following functions can be used to improve the refresh response for spe-
cial CPU Bus Unit data with CS1-H, CJ1-H, or CJ1M CPU Units.
Reducing the cycle time by using parallel processing mode or high-speed
instructions (Parallel processing mode is not supported by CJ1M CPU
Units.)
Executing DLNK(226) to refresh specific CPU Bus Units by specifying
their unit numbers (DLNK(226) can be used more than once in the pro-
gram.)
240
Cycle Time/High-speed Processing Section 6-1
Note 1. Longer cycle times (e.g., 100 ms) will increase the interval between when
data links are refreshed. DLNK(226) can be used in this case, as shown in
the following example.
Cyclic task n
END
Peripheral
servicing
Note If DLNK(226) is executed for a CPU Bus Unit that is busy refreshing
data, data will not be refreshed and the Equals Flag will turn OFF.
Normally, the Equals Flag should be programmed as shown below to
be sure that refreshing has been completed normally.
Execution condition
DLNK Refreshes data for the CPU
&0 Bus Unit with unit number 0.
= Flag Bit a
Turns ON bit a if data
refreshing fails, enabling the
problem to be detected.
2. IORF(097) is used to refresh data for Basic I/O Units and Special I/O Units.
DLNK(226) is used to refresh CPU Bus Units (CIO and DM Area words al-
located to the Units and special data for the Units).
241
Cycle Time/High-speed Processing Section 6-1
Program Processing in
execution CPU Unit #1
Processing in Program
execution
CPU Unit #2
Output Unit
Output ON delay
There are three points shown in the diagram above where processing is
delayed, increasing the data link I/O response time.
1,2,3... 1. The input arrives in the PLC (CPU Unit #1) just after I/O refreshing, caus-
ing a delay of one cycle before the input is read into the PLC. CPU Bus
Units are refreshed after program execution, causing a total delay of two
cycle times.
2. Data exchange occurs just after the PLC passes the token that makes it
the polling node, causing a delay of up to one communications cycle time
before the data is transferred in data link processing. There will also be a
delay of up to one communications cycle time after receiving the token,
causing a total delay of up to two communications cycle times.
3. The data transferred in data link processing arrives at the PLC (CPU Unit
#2) after data exchange, so the data will not be read into the PLC until the
next data exchange, causing a delay of up to one cycle. CPU Bus Units
are refreshed after program execution, causing a total delay of two cycle
times.
The equation for maximum data link I/O response time is as follows:
Input ON delay 1.5 ms
Cycle time of PLC at CPU Unit #1 2 25 ms 2
Communications cycle time 2 10 ms 2
Cycle time of PLC at CPU Unit #2 2 20 ms 2
242
Cycle Time/High-speed Processing Section 6-1
Output ON delay 15 ms
Total (data link I/O response time) 126.5 ms
Using DLNK(226) The following diagram illustrates the data flow that will produce the maximum
data link I/O response time when DLNK(226) is used.
Input
DLNK(226) execution
Input Unit
Program
DLNK execution DLNK DLNK Processing in
CPU Unit #1
Processing in DLNK
Program
execution DLNK DLNK
CPU Unit #2
Output Unit
Output ON delay
There are three points shown in the diagram above where processing is
delayed, increasing the data link I/O response time.
Note In this example, it is assumed that DNLK(226) is placed after other instruc-
tions in the program in both CPU Units
1,2,3... 1. The input arrives in the PLC (CPU Unit #1) just after I/O refreshing, caus-
ing a delay of one cycle before the input is read into the PLC. CPU Bus
Units are refreshed during program execution, reducing the total delay to
approximately 1.5 cycle times.
2. Data exchange occurs just after the PLC passes the token that makes it
the polling node, causing a delay of up to one communications cycle time
before the data is transferred in data link processing. There will also be a
delay of up to one communications cycle time after receiving the token,
causing a total delay of up to two communications cycle times.
3. The data transferred in data link processing arrives at the PLC (CPU Unit
#2) after the I/O refresh, but DLNK(226) refreshes the data, so the data will
be read into the PLC without causing a delay of up to one cycle. The Basic
I/O Units are refreshed after program execution, causing a total delay of
approximately one cycle time.
243
Cycle Time/High-speed Processing Section 6-1
The equation for maximum data link I/O response time is as follows:
Input ON delay 1.5 ms ---
Cycle time of PLC at CPU Unit #1 1.5 25 ms 1.5 Faster by 12.5 ms
(25 ms x 0.5)
Communications cycle time 2 10 ms 2 ---
Cycle time of PLC at CPU Unit #2 1 20 ms 1 Faster by 20 ms
(20 ms x 1)
Output ON delay 15 ms ---
Total (data link I/O response time) 94 ms Faster by 32.5 ms
(26% faster)
Applications
Background execution can be used for large quantities of data processing,
such as data compilation or processing, that is required only at special times
(e.g., once a day) when reducing the effect on the cycle time is more impor-
tant than the speed of the data processing.
Procedure
1,2,3... 1. Set the PLC Setup to enable background execution for the required in-
structions.
2. Set the communications port number (logical port number) to be used for
background execution in the PLC Setup. This port number will be used for
all instructions processed in the background.
Note One port is used for all background execution. Background execu-
tion for an instruction can thus not be started if background execution
is already being performed for another instruction. Use the Commu-
nications Port Enabled Flag to control instructions specified for back-
244
Cycle Time/High-speed Processing Section 6-1
245
Cycle Time/High-speed Processing Section 6-1
Conditions Flags
Conditions Flags will not be updated following execution of instructions pro-
cessed in the background. To access the Conditions Flag status, execute an
instruction that affects the Conditions Flags in the same way, as shown in the
following example, and then access the Conditions Flags.
Example:
MOV(021) affects the Equals and Negative Flags in the same way as
MAX(182), i.e., they both turn ON the Equals Flag for 0 and turn ON the Neg-
ative Flag if the MSB is ON. MOV(021) can thus be used to copy the results of
MAX(182) to the same address to manipulate the Conditions Flags so that the
status can be accessed.
Execution condition
MAX Finds the maximum value in the
D01000
D02000
table data starting at D020000
D00000 and places it in D000000.
RSET
000000
SET
000001
000001 A20200
MOV
Moves the contents of D000000
D00000 to D000000 to manipulate the
D00000 Conditions Flags.
Instruction Errors
If an instruction execution error or illegal access error occurs for an instruction
being processed in the background, the ER or AER Flags will not be turned
ON and A39510 will be turned ON instead. A39510 will remain ON until the
next time an instruction is processed in the background.
246
Cycle Time/High-speed Processing Section 6-1
247
Cycle Time/High-speed Processing Section 6-1
Note The communications ports (internal logical ports) in the CPU Unit are used
both for background execution and the following instructions
SEND(090), RECV(098), and CMND(490) (Network Communications
Instructions)
PMCR(260) (PROTOCOL MACRO)
Background instructions and the above instructions cannot be executed
simultaneously on the same port. Use the Communications Port Enabled
Flags to be sure that only one instruction is executed on each port at any one
time.
Note If an instruction is specified for execution in the background for a port
for which the Communications Port Enabled Flag is OFF, the ER Flag
will turn ON and the background instruction will not be executed.
Communications Port Enabled Flags
The Communications Port Enabled Flags are ON when the port is not being
used and OFF when processing is being performed on the port.
Communications Port
Enabled Flag
Background execution
I/O refresh
248
Cycle Time/High-speed Processing Section 6-1
Programming Example 1
Traditional Programming without Background Execution
As shown below, processing is completed when the instruction is executed.
Execution condition
a
MAX MAX(182) is executed completely as soon
D00000 as the execution condition a turns ON.
D00100
D00200
Communications
Execution
Port Enabled Flag
condition
b A20200
SUM SUM(184) execution is started if
D00002 execution condition b is ON and the
D00100 Communications Port Enabled Flag is ON
D00201 (i.e., when MAX(182) execution has been
completed).
c A20200
Confirmation of c is turned ON to enable confirming the
completion of
background completion of SUM(184).
execution
249
Cycle Time/High-speed Processing Section 6-1
Programming Example 2
This examples show background execution when index register output is
specified, as is possible for MAX(182), MIN(183), and SRCH(181).
Traditional Programming without Background Execution
As shown below, the actual memory map address of the word containing the
maximum value is output to an index register.
Execution condition
a
MAX(182) is executed completely as
MAX
soon as the execution condition a
D00000 turns ON, and the actual memory map
D00100 address of the word containing the
D00200 maximum value is output to IR0
Communications
Execution Port Enabled Flag
condition
b A20200
MOVL When execution condition b
A595 is ON and the
IR0 Communications Port Extra
Enabled Flag is ON, processing
MOVL(498) copies the actual required to
memory map address in move
A595 and A596 to IR0. address.
RSET
b
Note 1. Shared Index and Data Registers can be used to eliminate the need to
store and load register contents between tasks when the same contents is
needed in two or more tasks. Refer to the section on index registers in the
250
Cycle Time/High-speed Processing Section 6-1
1,2,3... 1. Select a PLC (PLC) in the CX-Programmer project tree and click the right
mouse button.
3. Leave the checkmark for using IR/DR independently per task if separate
index and data registers are required for each task. Remove the check-
mark to use shared index and data registers for all tasks.
Auxiliary Area Flags and Words
Name Address Description
IR/DR Opera- A09914 Indicates whether or not index and data registers are
tion between shared between tasks.
Tasks 0: Separate registers for each task (default)
1: Shared registers for all tasks
251
Index Registers Section 6-2
Pointer
All areas of
I/O Memory
MOVR(560)
Index Register
Indirect
addressing
Basic Operation
Basically, Index Registers are used with the following steps:
1,2,3... 1. Use MOVR(560) to store the PLC memory address of the desired bit or
word in an Index Register.
2. Specify the Index Register as the operand in almost any instruction to in-
directly address the desired bit or word.
3. Offset or increment the original PLC memory address (see below) to redi-
rect the pointer to another address.
4. Continue steps 2 and 3 to execute the instruction on any number of ad-
dresses.
Offsetting, Incrementing, and Decrementing Addresses
The following table shows the variations available for indirect addressing.
Variation Syntax
Indirect addressing ,IR@
Indirect addressing with constant offset Constant ,IR@
(Include a + or in the constant.)
252
Index Registers Section 6-2
Variation Syntax
Indirect addressing with DR offset DR@,IR@
Indirect addressing with auto-increment Increment by 1: ,IR@+
Increment by 2: ,IR@++
Indirect addressing with auto-decrement Decrement by 1: ,IR@
Decrement by 2: , IR@
Instruction A m+n
Example 2
The following example uses Index Registers in a FORNEXT loop to define
and start 100 timers (T0000 to T099) with SVs contained in D00100 through
D00109. Each timers timer number and Completion Flag are specified in
Index Registers and the loop is repeated as the Index Registers are incre-
mented by one with each repetition.
TIM starts the timer with the timer number (timer PV) indirectly
addressed by IR0+.
If the timer's Completion Flag (indirectly addressed by IR1+) is
ON, the work bit indirectly addressed by IR2+ is turned ON.
Repeated
The IR0+, IR1+, and IR2+ variations increment the address in
the Index Register after referencing the address.
The ++ instruction increments D00000.
253
Index Registers Section 6-2
T0000
MO VR Puts the PLC memory W000
00
T0000 address of T0000's
Completion Flag in IR1.
IR1
W000
01
MO VR Puts the PLC memory TIM
W00000
address of W00000
in IR2. 0001
IR2 D00101
MO V
T0001
&100 Writes &100 in D00000. W000
01
D00000
NEXT
JME
&1
254
Index Registers Section 6-2
Note Instructions for double-length operands (i.e., those with L at the end) are
used for index registers IR0 to IR15 because each register contains two
words.
255
Index Registers Section 6-2
Stack Processing
Stack instructions act on specially defined data tables called stacks. Data can
be drawn from a stack on a first-in first-out (FIFO) or last-in first-out (LIFO)
basis.
A particular region of I/O memory must be defined as a stack. The first words
of the stack indicate the length of the stack and contain the stack pointer. The
stack pointer is incremented each time that data is written to the stack to indi-
cate the next address where data should be stored.
A B C
Note Actually, the first two words of the stack contain the PLC memory address of
the last word in the stack and the next word contains the stack pointer.
FIFO (First-in First-out) Processing
The following diagram shows the operation of a first-in first-out (FIFO) stack.
Pointer address
A A Reads the oldest word of data stored
B in the stack. Each time that a word is
read, the pointer is decremented by one
C to indicate the next address for storage.
256
Index Registers Section 6-2
Stack Instructions
The following table lists the stack instructions and their functions. Typical
applications for stacks would be processing shelf information for automatic
warehousing systems, processing test results, and managing information on
workpieces on a conveyor.
Instruction Function
SSET(630) Defines a stack region.
PUSH(632) Stores data in the next available word in the stack.
FIFO(633) Reads data from the stack on a first-in first-out basis.
LIFO(634) Reads data from the stack on a last-in first-out basis.
SREAD(639) Read a specific entry from the table (CS1-H, CJ1-H, or CJ1M CPU
Units only).
SWRITE(640) Writes a specific entry to the table (CS1-H, CJ1-H, or CJ1M CPU
Units only).
SINS(641) Inserts a specific entry in the table (CS1-H, CJ1-H, or CJ1M CPU
Units only).
SDEL(642) Deletes a specific entry from the table (CS1-H, CJ1-H, or CJ1M CPU
Units only).
SNUM(638) Counts the number of entries in the table (CS1-H, CJ1-H, or CJ1M
CPU Units only).
257
Index Registers Section 6-2
The following table lists the range instructions and their functions.
Instruction Function Description
SRCH(181) Finds search data. Finds the search data in the specified range
and outputs the PLC memory address of the
word containing that value to IR0.
MAX(182) Finds max. value. Finds the maximum value in the specified
range and outputs the PLC memory address
of the word containing that value to IR0.
MIN(183) Finds min. value. Finds the minimum value in the specified
range and outputs the PLC memory address
of the word containing that value to IR0.
SUM(184) Calculates sum. Calculates the sum of the data in the specified
range.
FCS(180) Calculates checksum. Calculates the frame checksum of the data in
the specified range.
The Index Registers can be combined with other instructions (such as com-
parison instructions) in FORNEXT loops to perform more complicated opera-
tions on ranges of words.
Table Processing (Record-table Instructions)
The record-table instructions act on specially defined data tables made up of
equal-length records. The records can be accessed by record number for
easy processing.
Instruction Function Description
DIM(631) Defines a record table. Declares the length of each record and the
number of records.
SETR(635) Sets record location. Writes the location of the specified record (the
PLC memory address of the beginning of the
record) in the specified Index Register.
GETR(636) Gets record location. Returns the record number of the record that
contains the PLC memory address in the
specified Index Register.
Note Record numbers and word addresses are related through the Index Regis-
ters. Specify a record number in SETR(635) to store the PLC memory
address of the beginning of that record in an Index Register. When data is
required from the record, add the required offset to that Index Register to
access any word in the record.
Use the record-table instructions with Index Registers to perform the following
kinds of operations: reading/writing record data, searching records, sorting
258
Index Registers Section 6-2
record data, comparing record data, and performing calculations with record
data.
A typical application of record tables is storing manufacturing data for different
models of a product (such as temperature and pressure settings) in record
form and switching from model to model just by changing the record number.
Model A
Record table Model A
No. 2 Record 2
Record 1 Temperature setting
Pressure setting
Record 2
Record N
1,2,3... 1. Define the structure of the record table with DIM(631) and set the PLC
memory address of a record in an Index Register with SETR(635).
2. Offset or increment the PLC memory address in the Index Register to read
or compare words in the record.
3. Offset or increment the PLC memory address in the Index Register to
switch to another record.
4. Repeat steps 2 and 3 as required.
Example
The following example uses Index Registers and the record-table instructions
to compare three values to words 1, 3, and 5 in each record. If a match is
found, the record number is stored in D00000.
The first, third, and fifth words in the record are compared to three
different values.
If all three words match their respective values, the record number
is stored in D00000 by GETR(636) and the loop is broken.
If all three words do not match their respective values, 5 is added
to IR0 and the loop continues.
259
Index Registers Section 6-2
0000
01
DIM
1
Defines record table 1 with 1,000 records of
&5 5 words each.
&1000
E0_00000
SETR
Stores the PLC memory address of table
1 number 1's first record (record 0) in IR0.
&0
IR0
= = = GETR
BREAK
ON
+L
Adds 5 to the PLC memory address in IR0 to
IR0 move to the beginning of the next record.
&5
IR0
JME
Jump destination if the processing conditions
&1000 haven't been set.
Increments IR0 by five with each repetition and compares the first, third,
and fifth words in each record to the comparison data. Writes the record
number to D00000 and breaks the loop if matching data is found.
260
Serial Communications Section 6-3
261
Serial Communications Section 6-3
Serial PLC CJ1M CPU Unit Up to ten words per Unit can be Not allowed OK
Polling Unit
Links (CJ1M shared by up to nine CPU Units,
only) including one Polling Unit and
RS-422A/485
eight Polled Units.
CJ1W-CIF11
connected to
For NS-series PT:
An RS-422A Converter can be
RS-232C port
NS-AL002 connected to the RS-232C port on
each CPU Unit to communicate
via RS-422A/485, or two CPU
CJ1M CPU Unit CJ1M CPU Unit
Polled Unit Polled Unit Units can communicate via an RS-
232C connection.
8 Units max. The Serial PLC Links can also
CJ1M CPU Unit include PTs as Polled Units via NT
Polling Unit Links (1:N) combined with CJ1M
CPU Units.
RS-232C
262
Serial Communications Section 6-3
Create frame in the host com- Directly connect the host computer in a 1:1
FINS command1 puter and issue command to the or 1:N system.
(with host link header
PLC. Receive the response from
and terminator)
the PLC. OR
FINS Application:
Use these methods when com-
Header Terminator municating primarily from the Command
host computer to PLCs in the
network.
Command
PLC Issue frame with the CPU Units Directly connect the host computer in a 1:1
FINS command2
(with host link header SEND/RECV/CMND instruc- system.
Host computer and terminator) tions. Receive response from the
host computer. SEND/RECV/
CMND
FINS Application:
Use this method when communi-
Header Terminator cating primarily from the PLC to
the host computer to transmit
status information such as error Command
information.
Communicate with the host computer
through other PLCs in the network. (Convert
from host link to network protocol.)
SEND/RECV/
CMND
Command
Note 1. The FINS command must have a host link header and terminator attached
before it is transmitted from the host computer.
263
Serial Communications Section 6-3
2. The FINS command is transmitted from the PLC with a host link header
and terminator attached. A program must be prepared in the host comput-
er to analyze the FINS commands and return the proper responses.
Procedure
Set the PLC Setup from a Pro- Programming Console
gramming Device. Peripheral port: Addresses 144, 145, and 147
(Settings such as the communica- RS-232C port: Addresses 160 to 163
tions mode and parameters.)
Be sure to set the communications mode to host link.
(Refer to CX-Programmer User Manual for CX-Programmer procedures.)
Power OFF
Set the DIP switch on the front of Turn pin 4 ON when using the peripheral port.
the CPU Unit. Turn pin 5 OFF when using the RS-232C port.
Power ON
Host Link Commands The following table lists the host link commands. Refer to the C-series Host
Link Units System Manual (W143) for more details.
Header Name Function
code
RR CIO AREA READ Reads the contents of the specified number of CIO Area words, starting
from the specified word.
RL LINK AREA READ Reads the contents of the specified number of Link Area words, starting
from the specified word.
RH HR AREA READ Reads the contents of the specified number of Holding Area words,
starting from the specified word.
RC PV READ Reads the contents of the specified number of timer/counter PVs
(present values), starting from the specified timer/counter.
RG T/C STATUS READ Reads the status of the Completion Flags of the specified number of
timers/counters, starting from the specified timer/counter.
RD DM AREA READ Reads the contents of the specified number of DM Area words, starting
from the specified word.
RJ AR AREA READ Reads the contents of the specified number of Auxiliary Area words,
starting from the specified word.
264
Serial Communications Section 6-3
265
Serial Communications Section 6-3
FINS Commands The following table lists the FINS commands. Refer to the FINS Commands
Reference Manual (W227) for more details.
Type Command Name Function
code
I/O Memory 01 01 MEMORY AREA READ Reads consecutive data from the I/O memory area.
Area Access 01 02 MEMORY AREA WRITE Writes consecutive data to the I/O memory area.
01 03 MEMORY AREA FILL Fills the specified range of I/O memory with the same
data.
01 04 MULTIPLE MEMORY AREA Reads non-consecutive data from the I/O memory area.
READ
01 05 MEMORY AREA TRANSFER Copies and transfers consecutive data from one part of
the I/O memory area to another.
Parameter 02 01 PARAMETER AREA READ Reads consecutive data from the parameter area.
Area Access 02 02 PARAMETER AREA WRITE Writes consecutive data to the parameter area.
02 03 PARAMETER AREA FILL Fills the specified range of the parameter area with the
same data.
Program Area 03 06 PROGRAM AREA READ Reads data from the user program area.
Access 03 07 PROGRAM AREA WRITE Writes data to the user program area.
03 08 PROGRAM AREA CLEAR Clears the specified range of the user program area.
Execution 04 01 RUN Switches the CPU Unit to RUN, MONITOR, or DEBUG
Control mode.
04 02 STOP Switches the CPU Unit to PROGRAM mode.
Configuration 05 01 CONTROLLER DATA READ Reads CPU Unit information.
Read 05 02 CONNECTION DATA READ Reads the model numbers of the specified Units.
Status Read 06 01 CONTROLLER STATUS READ Reads the CPU Units status information.
06 20 CYCLE TIME READ Reads the average, maximum, and minimum cycle
times.
Clock Access 07 01 CLOCK READ Reads the clock.
07 02 CLOCK WRITE Sets the clock.
Message 09 20 MESSAGE READ/CLEAR Reads/clears messages and FAL(S) messages.
Access
Access Right 0C 01 ACCESS RIGHT ACQUIRE Acquires the access right if no other device holds it.
0C 02 ACCESS RIGHT FORCED Acquires the access right even if another device cur-
ACQUIRE rently holds it.
0C 03 ACCESS RIGHT RELEASE Releases the access right regardless of what device
holds it.
Error Access 21 01 ERROR CLEAR Clears errors and error messages.
21 02 ERROR LOG READ Reads the error log.
21 03 ERROR LOG CLEAR Clears the error log pointer to zero.
266
Serial Communications Section 6-3
FINS command
Refer to the CPU Bus Units Operation Manual for more details on the mes-
sage communications functions.
267
Serial Communications Section 6-3
Note A transmission delay or no-protocol mode delay can be specified in the PLC
Setup (address 162). This setting causes a delay of up to 30 seconds
between execution of TXD(236) and the transmission of data from the speci-
fied port.
Procedure
Set the PLC Setup from a Pro- Programming Console
gramming Device. Set addresses 160 to 163. In particular, set
(Settings such as the communica- the communications mode to no-protocol
tions mode and parameters.) mode, set the start code, end code, amount of
data, and no-protocol mode delay.
(Refer to CX-Programmer User Manual for
CX-Programmer procedures.)
Power OFF
Power ON
268
Serial Communications Section 6-3
memory. Up to 256 bytes (including the start and end codes) can be trans-
ferred in no-protocol mode.
The following table shows the message formats that can be set for transmis-
sions and receptions in no-protocol mode. The format is determined by the
start code (ST) and end code (ED) settings in the PLC Setup.
Start code End code setting
setting No Yes CR+LF
No data data+ED data+CR+LF
(data: 256 bytes max.) (data: 255 bytes max.) (data: 254 bytes max.)
Yes ST+data ST+data+ED ST+data+CR+LF
(data: 255 bytes max.) (data: 254 bytes max.) (data: 253 bytes max.)
When more than one start code is used, the first start code will be effec-
tive.
When more than one end code is used, the first end code will be effective.
Note 1. If the data being transferred contains the end code, the data transfer will
be stopped midway. In this case, change the end code to CR+LF.
2. There is a setting in the PLC Setup (address 162: no-protocol mode delay)
that will delay the transmission of data after the execution of TXD(236).
No-protocol mode
transmission delay
Transmission
Time
Execution of TXD(236)
269
Serial Communications Section 6-3
PLC Setup
Communications Programming Name Settings Default values Other conditions
port Console setting contents
address
Peripheral port 144 Serial communica- 02 Hex: NT Link 00 Hex: Host Link Turn ON pin 4 on
Bits: 8 to 11 tions mode (1:N mode) the CPU Unit DIP
145 Baud rate 00 to 09 Hex: 00 Hex: Standard switch.
Bits: 0 to 7 Standard NT Link NT Link
0A Hex: High-
speed NT Link
(see note 1)
150 NT Link mode 0 to 7 Hex 0 Hex (Max. unit ---
Bits: 0 to 3 maximum unit No. 0)
number
RS-232C port 160 Serial communica- 02 Hex: NT Link 00 Hex: Host Link Turn OFF pin 5 on
Bits: 8 to 11 tions mode (1:N mode) the CPU Unit DIP
161 Baud rate 00 to 09 Hex: 00 Hex: Standard switch.
Bits: 0 to 7 Standard NT Link NT Link
0A Hex: High-
speed NT Link
(see note 1)
166 NT Link mode 0 to 7 Hex 0 Hex (Max. unit ---
Bits: 0 to 3 maximum unit No. 0)
number
Note Set the baud rate to 115,200 bps when making settings with the CX-Program-
mer.
270
Serial Communications Section 6-3
Specifications
Item Specifications
Connection method RS-232C or RS-422A/485 connection via the CPU Units RS-
232C port.
Allocated data area Serial PLC Link Words:
CIO 3100 to CIO 3199 (Up to 10 words can be allocated for
each CPU Unit.)
Number of Units 9 Units max., comprising 1 Polling Unit and 8 Polled Units (A
PT can be placed on the same network in an NT Link (1:N),
but it must be counted as one of the 8 Polled Units.)
System Configuration
CPU Unit
Polling Unit
CPU Unit
Polling Unit
RS-422/485
CJ1W-CIF11
RS-422A
Converter
RS-232C
CPU Unit CPU Unit PT CPU Unit
Polled Unit No. 0 Polled Unit No. 1 Unit No. 2 Polled Unit No. 3
Note Up to 8 Units, including the PT and Polled Units, can be connected to the Poll-
ing Unit when a PT set for Serial PLC Link communications is on the same
network.
Complete Link Method The data from all nodes in the Serial PLC Links are reflected in both the Poll-
ing Unit and the Polled Units. (The only exceptions are the address allocated
to the connected PTs unit number and the addresses of Polled Units that are
not present in the network. These data areas are undefined in all nodes.)
271
Serial Communications Section 6-3
Polling Unit Link Method The data for all the Polled Units in the Serial PLC Links ar reflected in the Poll-
ing Unit only, and each Polled Unit reflects the data of the Polling Unit only.
The advantage of the Polling Unit link method is that the address allocated for
the local Polled Unit data is the same in each Polled Unit, allowing data to be
accessed using common ladder programming. The areas allocated for the
unit numbers of the PT or Polled Units not present in the network are unde-
fined in the Polling Unit only.
Example: Polling Unit link method, highest unit number: 3.
In the following diagram, Polled Unit No. 2 is a PT or a Unit not participating in
the network, so the corresponding area in the Polling Unit is undefined.
Polling Unit Polled Unit No.0 Polled Unit No.1 Polled Unit No.3
Local area Polling Unit Polling Unit Polling Unit
Polled Unit
No.0 Local area Local area Local area
Polled Unit
No.1 (Not used.) (Not used.) (Not used.)
Undefined (Not used.) (Not used.) (Not used.)
Polled Unit
No.3
(Not used.) (Not used.) (Not used.)
272
Serial Communications Section 6-3
Allocated Words
Complete Link Method
Address Link words 1 word 2 words 3 words to 10 words
CIO 3100 Polling Unit CIO 3100 CIO 3100 to CIO 3100 to CIO 3100 to
CIO 3101 CIO 3102 CIO 3109
Polled Unit No. 0 CIO 3101 CIO 3102 to CIO 3103 to CIO 3110 to
CIO 3103 CIO 3105 CIO 3119
Polled Unit No. 1 CIO 3102 CIO 3104 to CIO 3106 to CIO 3120 to
CIO 3105 CIO 3108 CIO 3129
Polled Unit No. 2 CIO 3103 CIO 3106 to CIO 3109 to CIO 3130 to
CIO 3107 CIO 3111 CIO 3139
Polled Unit No. 3 CIO 3104 CIO 3108 to CIO 3112 to CIO 3140 to
CIO 3109 CIO 3114 CIO 3149
Serial PLC
Link Words Polled Unit No. 4 CIO 3105 CIO 3110 to CIO 3115 to CIO 3150 to
CIO 3111 CIO 3117 CIO 3159
Polled Unit No. 5 CIO 3106 CIO 3112 to CIO 3118 to CIO 3160 to
CIO 3113 CIO 3120 CIO 3169
Polled Unit No. 6 CIO 3107 CIO 3114 to CIO 3121 to CIO 3170 to
CIO 3115 CIO 3123 CIO 3179
Polled Unit No. 7 CIO 3108 CIO 3116 to CIO 3124 to CIO 3180 to
CIO 3117 CIO 3126 CIO 3189
CIO 3199 Not used. CIO 3109 CIO 3118 to CIO 3127 to CIO 3190 to
to CIO 3199 CIO 3199 CIO 3199
CIO 3199
273
Serial Communications Section 6-3
Procedure
The Serial PLC Links operate according to the following settings in the PLC
Setup.
Settings at the Polling Unit
1,2,3... 1. Set the serial communications mode of the RS-232C communications port
to Serial PLC Links (Polling Unit).
2. Set the link method to the Complete Link Method or Polling Unit Link Meth-
od.
3. Set the number of link words (up to 10 words for each Unit).
4. Set the maximum unit number in the Serial PLC Links (1 to 7).
Settings at the Polled Units
1,2,3... 1. Set the serial communications mode of the RS-232C communications port
to Serial PLC Links (Polled Unit).
2. Set the unit number of the Serial PLC Link Polled Unit.
PLC Setup
Settings at the Polling Unit
Item PLC address Set value Default Refresh timing
Word Bit
RS-232C Serial communica- 160 11 to 08 8 hex: Serial PLC Links 0 hex Every cycle
port setting tions mode Polling Unit (except immediate
Port baud rate 161 07 to 00 00 hex: Standard 00 hex refresh when exe-
0A hex: High-speed cuting the
STUP(237) instruc-
Link method 166 15 0: Complete links 0 tion)
1: Polling Unit links
Number of link 07 to 04 1 to A hex 0 hex (See
words note.)
Highest unit num- 03 to 00 0 to 7 hex 0 hex
ber
Note Automatically allocates 10 words (A hex) when the default setting of 0 hex is
used.
274
Serial Communications Section 6-3
Note In the same way as for the existing NT Link (1:N), the status (communicating/
not communicating) of PTs in the Serial PLC Link can be checked from the
Polling Unit (CPU Unit) by reading the RS-232C Port Communicating with PT
Flag (A393 bits 00 to 07 for unit numbers 0 to 7).
275
Changing the Timer/Counter PV Refresh Mode Section 6-4
Note 1. Here, the CPU Units other than CS1 CPU Units are as follows:
CS1-H CPU Units
CJ1-H CPU Units
CJ1M CPU Units
2. When the mnemonic is monitored from the Programming Console for CS1-
H/CJ1-H CPU Units manufactured on or before 31 May 2002 with the tim-
er/counter PV refresh mode set to binary mode, the mnemonic of the bina-
ry is displayed as the mnemonic or the BCD instruction (example: TIMX
#0000 &16 is displayed as TIM #0000 &16), but operations are performed
in binary mode.
3. The PV refresh mode can be selected with CX-Programmer Ver 3.0 only.
Mode selection is not supported by CX-Programmer Ver 2.1 or earlier, or
the Programming Consoles.
4. CX-Programmer Ver. 2.1 or earlier cannot read user programs for the CPU
Unit containing binary-mode instructions, but it can read those set using
BCD-mode instructions.
276
Changing the Timer/Counter PV Refresh Mode Section 6-4
Note When the mnemonic is monitored from the Programming Console for CS1-H/
CJ1-H CPU Units manufactured on or before 31 May 2002 with the timer/
counter PV refresh mode set to binary mode, the mnemonic of the binary is
displayed as the mnemonic or the BCD instruction (example: TIMX #0000
&16 is displayed as TIM #0000 &16), but operations are performed in binary
mode.
Checking the CPU Unit Lot Number
1,2,3... 1. The lot number is printed on the bottom of the front panel (CS Series) or
the right corner of the top of the Unit (CJ Series), and is comprised of the
last two digits of the year, the month, and the day, in that order, as shown
in the following diagram.
Example: 020601 (Manufactured on 1 June 2002.)
020601
277
Changing the Timer/Counter PV Refresh Mode Section 6-4
CX-Programmer
Using BCD mode Ver.3.0 Programming
BCD/binary mode is
Console
selected under the PLC Using BCD mode
TIM
properties.
000001 TIM
0000 The Programming Console
cannot be used to select the Set value #0010
#0010 mode.
TIMX Timer/counter PV
refresh mode setting
0000 (See note.)
&10
User program
278
Changing the Timer/Counter PV Refresh Mode Section 6-4
When the setting is changed, the following dialog box will be displayed au-
tomatically.
Cancel
Click the OK Button to execute the program check. The program check
results will be displayed in the output window.
Example: The TIM instruction has been used even though the mode has been
changed to binary mode.
TIM is displayed
in red.
279
Changing the Timer/Counter PV Refresh Mode Section 6-4
Note When using the CX-Programmer in either BCD or binary mode, if the numeri-
cal value is input without including the input/display symbol # or & indicating
the constant, (e.g., TIM 0000 0010), the timer/counter set value will be input
as an address (e.g., the value in CIO word 0010 will be used as the set value).
6-4-5 Restrictions
BCD mode and binary mode cannot be used together in the same CPU
Unit.
When the Programming Console is used to create a new user program, or
to clear memory, the timer/counter PV refresh mode is fixed in BCD
mode.
When CX-Programmer Ver. 3.0 is used to place the CPU Unit online, the
set value that is stored in the CPU Units user memory for the timer/
counter PV refresh mode will be automatically used. If the CPU setting is
different from the setting for the CX-Programmer project, an error will
occur, and the online connection will not be possible. The following mes-
sage will be displayed.
Select whether to change the CPU Unit setting to that for the CX-Programmer
project or change the CX-Programmer project property setting to that for the
CPU Unit.
CX-Programmer Ver. 2.1 or earlier cannot read user programs in the CPU
Unit that are set using binary mode, but can read those set using BCD
mode.
280
Changing the Timer/Counter PV Refresh Mode Section 6-4
281
Changing the Timer/Counter PV Refresh Mode Section 6-4
282
Changing the Timer/Counter PV Refresh Mode Section 6-4
COUNTER
Instruction name BCD mode Binary mode
Mnemonic CNT CNTX(546)
S (counter set value) #0000 to #9999BCDcM &0 to& 65535 (decimal)
or #0000 to #FFFF (hexa-
decimal)
Setting 0 to 9,999 times 0 to 65,535 times
REVERSIBLE COUNTER
Instruction name BCD mode Binary mode
Mnemonic CNTR(012) CNTRX(548)
S (counter set value) #0000 to #9999BCDcM &0 to &65535 (decimal)
or #0000 to #FFFF (hexa-
decimal)
Setting 0 to 9,999 times 0 to 65,535 times
RESET TIMER/COUNTER
Instruction name BCD mode Binary mode
Mnemonic CNR(545) CNRX(547)
COUNTER WAIT
Instruction name BCD mode Binary mode
Mnemonic CNTW(814) CNTWX(818)
S (counter set value) #0000 to #9999BCDcM &0 to &65535 (decimal)
or #0000 to #FFFF (hexa-
decimal)
Setting 0 to 9,999 times 0 to 65,535 times
283
Using a Scheduled Interrupt as a High-precision Timer (CJ1M Only) Section 6-5
1,2,3... 1. Input interrupt task starts when the built-in input bit turns ON.
2. Output bit A turns ON in the input interrupt task, and the MSKS(690) in-
struction is executed to perform a scheduled interrupt reset start.
3. After a fixed interval, the scheduled interrupt task starts, and output bit A
in the scheduled interrupt task turns OFF, and the MSKS(690) instruction
is executed to prohibit a scheduled interrupt.
Output bit A
Cyclic task Input Input interrupt task turns ON.
interrupt SET
A
ON
Scheduled interrupt
reset start.
MSKS
Output bit A
14 Scheduled interrupt task turns OFF.
#0005
RESET
Fixed interval A Stop due to fixed
Example:
After 0.5 ms)
interrupt being
MSKS
4
prohibited.
#0000
284
Using a Scheduled Interrupt as a High-precision Timer (CJ1M Only) Section 6-5
285
Startup Settings and Maintenance Section 6-6
Hot Stop
When the IOM Hold Bit (A50012) is ON, all data* in I/O memory will also be
retained when the CPU Unit is switched from RUN/MONITOR mode to PRO-
GRAM mode to stop program execution.
Note *The following areas of I/O memory will be cleared during mode changes
(PROGRAM RUN/MONITOR) unless the IOM Hold Bit is ON: the CIO Area
(I/O Area, Data Link Area, CPU Bus Unit Area, Special I/O Unit Area, Inner
Board Area, SYSMAC BUS Area, I/O Terminal Area, DeviceNet (CompoBus/
D) Area, and Internal I/O Areas), Work Area, Timer Completion Flags, and
Timer PVs. (The Inner Board, SYSMAC BUS, and I/O Terminal Areas are
supported by CS-series CPU Units only.)
Auxiliary Area Flags and Words
Name Address Description
IOM Hold Bit A50012 When this bit is ON, all of I/O memory will be retained
when the operating mode is changed (PROGRAM
RUN/MONITOR).
When the IOM Hold Bit is ON, all outputs from Output Units will be maintained
when program execution stops. When the program starts again, outputs will
286
Startup Settings and Maintenance Section 6-6
have the same status that they had before the program was stopped.
(When the IOM Hold Bit is OFF, instructions will be executed after the outputs
have been cleared.)
PLC Power ON In order for all data* in I/O memory to be retained when the PLC is turned on
(OFF ON), the IOM Hold Bit must be ON and it must be protected in the
PLC Setup (address 80, IOM Hold Bit Status at Startup).
I/O memory
Retain
Power ON CIO and
other areas
PLC Setup
Program- Name Setting Default
ming Con-
sole
address
80 bit 15 IOM Hold Bit Sta- 0: The IOM Hold Bit is cleared to 0 when 0
tus at Startup power is turned on. (Cleared)
1: The IOM Hold Bit is retained when
power is turned on.
Power ON
PLC Setup
Program- Name Meaning Setting Default
ming
Console
address
81 Startup Specifies PRCN: Programming Consoles PRCN: Pro-
Mode operating mode switch gramming
mode to PRG: PROGRAM mode Consoles
use at mode switch
startup MON: MONITOR mode
RUN: RUN mode
Note If the Startup Mode is set to PRCN (Programming Consoles mode switch) but
a Programming Console isnt connected, the CPU Unit will start in RUN
mode. Change the PLC Setup from the default value to start in MONITOR
mode or PROGRAM mode when the power is turned ON. (The CS-series
CS1 CPU Units, however, will start in PROGRAM mode under the same con-
ditions.)
287
Startup Settings and Maintenance Section 6-6
RUN output
This RUN output can be used to create an external safety circuits, such as an
emergency stop circuit that prevents an Output Units external power supply
from providing power unless the PLC is on.
Note When a Power Supply Unit without a RUN output is used, an equivalent out-
put can be created by programming the Always ON Flag (A1) as the execu-
tion condition for an output point from an Output Unit.
!Caution If Output Units external power supply goes on before the PLCs power supply,
the Output Unit may malfunction momentarily when the PLC first goes on. To
prevent any malfunction, add an external circuit that prevents the Output
Units external power supply from going on before the power supply to the
PLC itself. Create a fail-safe circuit like the one described above to ensure
that power is supplied by an external power supply only when the PLC is
operating in RUN or MONITOR mode.
288
Startup Settings and Maintenance Section 6-6
This function can be used with sets of instructions that must be executed as a
group, e.g., so that execution does not start with intermediate stored data the
next time power is turned ON.
Procedure
1,2,3... 1. Set the Disable Setting for Power OFF Interrupts in A530 to A5A5 Hex to
enable disabling Power OFF Interrupts.
2. Enable disabling Power OFF Interrupts in the PLC Setup (this is the default
setting).
3. Use DI(693) to disable interrupts before the program section to be protect-
ed and then use EI(694) to enable interrupts after the section. All instruc-
tions between DI(693) and EI(694) will be completed before the Power
OFF Interrupt is executed even if the power interruption occurs while exe-
cuting the instructions between DI(693) and EI(694).
Execution condition
DI Interrupts disabled.
Power interrupted.
Instructions executed.
Related Settings
Name Address Meaning
Disable Setting A530 Enables using DI(693) to disable power OFF inter-
for Power OFF rupt processing (except for execution of the Power
Interrupts OFF Interrupt Task) until EI(694) is executed.
A5A5 Hex: Enables using DI(693) to disable power
OFF interrupt processing
Any other value: Disables using DI(693) to disable
power OFF interrupt processing
289
Startup Settings and Maintenance Section 6-6
Note The CS-series CS1 CPU Units are shipped without the backup battery
installed, and the CPU Units internal clock will be read 00/01/01 00:00:00 or
possibly another value when the battery is connected. To use the clock func-
tions, connect the battery, turn the power ON, and set the time and date with a
Programming Device (Programming Console or CX-Programmer) or the FINS
command (07 02, CLOCK WRITE). The CPU Units internal clock will begin
operating once it has been set.
Auxiliary Area Flags and Words
Name Addresses Function
Clock data A35100 to A35107 Second: 00 to 59 (BCD)
A35108 to A35115 Minute: 00 to 59 (BCD)
A35200 to A35207 Hour: 00 to 23 (BCD)
A35208 to A35215 Day of the month: 00 to 31 (BCD)
A35300 to A35307 Month: 00 to 12 (BCD)
A35308 to A35315 Year: 00 to 99 (BCD)
A35400 to A35407 Day of the week:
00: Sunday, 01: Monday,
02: Tuesday, 03: Wednesday,
04: Thursday, 05: Friday, 06: Saturday
Start-up Time A510 and A511 Contain the time at which the power
was turned on.
Power Interruption A512 and A513 Contain the time at which the power
Time was last interrupted.
Total Power ON Time A523 Contains the total time (in binary) that
the PLC has been on in 10-hour units.
Related Instructions
Instruction Name Function
SEC(065) HOURS TO SEC- Converts time data in hours/minutes/seconds
ONDS format to an equivalent time in seconds only.
HMS(066) SECONDS TO Converts seconds data to an equivalent time in
HOURS hours/minutes/seconds format.
CADD(730) CALENDAR ADD Adds time to the calendar data in the specified
words.
CSUB(731) CALENDAR SUB- Subtracts time from the calendar data in the
TRACT specified words.
DATE(735) CLOCK ADJUST- Changes the internal clock setting to the setting
MENT in the specified source words.
290
Startup Settings and Maintenance Section 6-6
Note 1. If you forget the password, the program within the PLC cannot be trans-
ferred to the computer. Make a note of the password, and store it in a safe
place.
2. If you forget the password, programs cannot be transferred from the com-
puter to the PLC. Programs can be transferred from the computer to the
PLC even if the password protection has not been released.
Password Protection
1,2,3... 1. Register a password either online or offline as follows:
a) Select the PLC and select Properties from the View Menu.
b) Select Protection from the PLC Properties Dialog Box and input the
password.
2. Set password protection online as follows:
a) Select PLC, Password Protection, and then Set. The Program Pro-
tection Setting Dialog Box will be displayed.
b) Click the OK button.
291
Startup Settings and Maintenance Section 6-6
Programming
Device
Programming
Device
Host Link
292
Startup Settings and Maintenance Section 6-6
Flash memory
Note 1. The BKUP indicator on the front of the CPU Unit will light while data is be-
ing written to flash memory. Do not turn OFF the power supply to the CPU
Unit until the backup operation has been completed (i.e., until the BKUP
indicator goes out) after transferring data from the a Programming Device
or file memory, or performing online editing.
2. Only for online editing and only when there is a Battery in the CPU Unit,
the CPU Unit will restart in the previous condition (e.g., with the BKUP in-
dicator lit) even if the power supply is turned OFF before the backup oper-
ation has been completed, although up to 1 minute will be required will be
required to start the CPU Unit. Even in this case (and even if there is a Bat-
tery in the CPU Unit, always be sure that the backup operation has been
completed before turning OFF the power supply if the CPU Unit will be left
unpowered for an extended period of time.
293
Startup Settings and Maintenance Section 6-6
The amount of time required to back up data (the time the BKUP indicator will
be lit) will depend on the size of the user program, as shown in the following
table.
User Backup processing time
program size MONITOR mode PROGRAM
Cycle time of 0.4 ms Cycle time of 10.0 ms mode
(example) (example)
10 Ksteps 2s 8s 1s
60 Ksteps 11 s 42 s 6s
250 Ksteps 42 s 170 s 22 s
Note 1. The BKUP indicator will be lit when power is supplied to the CPU Unit.
2. Depending on the type of online editing that was performed, up to 1 minute
may be required to backup data.
3. I/O memory (including the DM, EM, and HR Areas) is not written to flash
memory. The data in these areas is backed up by a Battery for recovery
after power interruptions. The data may not be correctly recovered if a bat-
tery error occurs, If the Battery Error Flag (A40204) is ON, take appropriate
steps in the ladder program to set the contents of these areas as required.
4. A backup status will be displayed in a Memory Backup Status Window by
the CX-Programmer when backing up data from the CX-Programmer for
transfer operations other than normal data transfers (PLC/Transfer). To
obtain this window, setting to display the backup status dialog box must be
checked in the PLC properties and the window must be selected from the
View Menu. For normal transfer operations, the backup status will be dis-
played in the transfer window after the transfer status for the program and
other data.
Auxiliary Area Flags
Name Address Meaning
Flash Memory A40310 Turns ON when the flash memory fails.
Error Flag
294
Startup Settings and Maintenance Section 6-6
This function is controller by setting the Startup Condition and Inner Board
Setting described in the following table.
Startup conditions PLC Setup
Startup Condition Inner Board Setting
(Programming Console (Programming Console
address 83, bit 15) address 84, bit 15)
To start without wait- 1: Enable operation without 1: Do not wait for specific
ing for all Units and waiting. Inner Boards.
Boards
To start without wait- 1: Enable operation without 0: Wait for all Boards before
ing for all Units (wait waiting. starting.
for Boards)
To wait for all Units 0: Always wait for all Units/ Any
and Boards before Boards
starting
Note With CS1 CPU Units, the CPU Unit will not start until all Units and Boards
have completed startup processing.
PLC Setup
Programming Name Setting Default CPU Unit
Console refresh
address timing
Word Bit
83 15 Startup 0: Wait for Units and Boards. 0: Wait Power ON
Condition 1: Dont wait.
84 15 Inner Board 0: Wait for all Boards. 0: Wait Power ON
Setting 1: Dont wait for specific
Boards.
Startup Condition
0: If there is one or more of the specific Boards or Units that has not com-
pleted startup processing, the CPU Unit will go on standby in MONITOR or
PROGRAM mode and wait for all Units and Boards.
1: Even if there is one or more of the specific Boards or Units that has not
completed startup processing, the CPU Unit will go ahead and start in MONI-
TOR or PROGRAM mode. The operation for Inner boards, however, also
depends on the following setting.
Inner Board Setting
This setting is used only if the Startup Condition is set to 1 to enable starting
without waiting for specific Units and Boards. This setting is ignored if the
Startup Condition is set to 0.
0: If there is one or more of the specific Boards that has not completed startup
processing, the CPU Unit will go on standby in MONITOR or PROGRAM
mode and wait for all Boards.
1: Even if there is one or more of the specific Boards that has not completed
startup processing, the CPU Unit will go ahead and start in MONITOR or
PROGRAM mode.
295
Diagnostic Functions Section 6-7
296
Diagnostic Functions Section 6-7
Error code
Error contents
Minute, second
Day, hour Time of
occurrence
Year, month
The number of records is stored in binary in the Error Log Pointer (A300). The
pointer is not incremented when more than 20 errors have occurred.
Application Precaution for When the master function is used with the CS1W-DRM21 or CJ1W-DRM21,
DeviceNet all slave outputs will be turned OFF. When the slave function is used, all
inputs to the master will be OFF. When the C200HW-DRM21-V1 is used,
however, slave outputs will not be turned OFF.
297
Diagnostic Functions Section 6-7
1,2,3... 1. The FAL Error Flag (A40215) or FALS Error Flag (A40106) is turned ON.
2. The corresponding error code is written to A400.
3. The error code and time of occurrence are stored in the Error Log.
4. The error indicator on the front of the CPU Unit will flash or light.
5. If FAL(006) has been executed, the CPU Unit will continue operating.
If FALS(007) has been executed, the CPU Unit will stop operating. (Pro-
gram execution will stop.)
Operation of FAL(006)
When execution condition A goes ON, an error with FAL number 2 is gener-
ated, A40215 (FAL Error Flag) is turned ON, and A36002 (FAL Number 2
Flag) is turned ON. Program execution continues.
Errors generated by FAL(006) can be cleared by executing FAL(006) with FAL
number 00 or performing the error read/clear operation from a Programming
Device (including a Programming Console).
Operation of FALS(007)
When execution condition B goes ON, an error with FALS number 3 is gener-
ated, and A40106 (FALS Error Flag) is turned ON. Program execution is
stopped.
Errors generated by FAL(006) can be cleared by eliminating the cause of the
error and performing the error read/clear operation from a Programming
Device (including a Programming Console).
298
Diagnostic Functions Section 6-7
Carr y Flag
Error-processing block
C (Diagnostic output)
Logic diagnosis
execution condition
B
Time Monitoring:
Monitors whether output C goes ON with 10 seconds after input A. If C
doesnt go ON within 10 seconds, a failure is detected and the Carry Flag
is turned ON. The Carry Flag executes the error-processing block. Also,
an FAL error (non-fatal error) with FAL number 004 is generated.
Logic Diagnosis:
FPD(269) determines which input bit in block B is preventing output C from
going ON. That bit address is output to D01000 and D01001.
Auxiliary Area Flags and Words
Name Address Operation
Error Code A400 When an error occurs, its error code is stored in
A400.
FAL Error Flag A40215 ON when FAL(006) is executed.
FALS Error Flag A40106 ON when FALS(007) is executed.
Executed FAL Num- A360 to The corresponding flag is turned ON when an
ber Flags A391 FAL(006) or FALS(007) error occurs.
Error Log Area A100 to The Error Log Area contains information on the
A199 most recent 20 errors.
Error Log Pointer A300 When an error occurs, the Error Log Pointer is
incremented by 1 to indicate where the next error
record will be recorded as an offset from the
beginning of the Error Log Area (A100).
Error Log Pointer A50014 Turn this bit ON to reset the Error Log Pointer
Reset Bit (A300) to 00.
FPD Teaching Bit A59800 Turn this bit ON when you want the monitoring
time to be set automatically when FPD(269) is
executed.
299
Diagnostic Functions Section 6-7
1,2,3... 1. Set the FAL or FALS number to use for simulation in A529. (A529 is used
when simulating errors for FAL(006) and FALS(007).
2. Set the FAL or FALS number to use for simulation as the first operand of
FAL(006) or FALS(007).
3. Set the error code and error to be simulated as the second operation (two
words) of FAL(006) or FALS(007). Indicate a nonfatal error for FAL(006)
and a fatal error for FALS(007).
To simulate more than one system error, use more than one FAL(006) or
FALS(007) instruction as described above.
Auxiliary Area Flags and Words
Name Address Operation
FAL/FALS Number A529 Set a dummy FAL/FALS number to use to simu-
for System Error late the system error.
Simulation 0001 to 01FF Hex: FAL/FALS numbers 1 to 511
0000 or 0200 to FFFF Hex: No FAL/FALS number
for system error simulation.
Note Use the same methods as for actual system errors to clear the simulated sys-
tem errors. Refer to the CS-series Operation Manual or the CJ-series Opera-
tion Manual for details. All system errors simulated with FAL(006) and
FALS(007) can be cleared by cycling the power supply.
300
CPU Processing Modes Section 6-8
This function can be used when only system FAL errors need to be stored in
the error log, e.g., when there are many user-defined errors generated by the
program using FAL(006) and these fill up the error log too quickly.
PLC Setup
Programming Name Setting Default CPU Unit
Console refresh
address timing
Word Bit
129 15 User FAL 0: Record user-defined FAL 0: Whenever
Storage errors in error log. Record FAL(006) is
Setting 1: Dont record user-defined executed
FAL errors in error log. (every
cycle)
Note The following items will be stored in the error log even if the above setting is
used to prevent user-defined FAL errors from being recorded.
User-defined fatal errors (FALS(007))
Non-fatal system errors
Fatal system errors
User-simulated nonfatal system errors (FAL(006))
User-simulated fatal system errors (FALS(007))
301
CPU Processing Modes Section 6-8
Normal Mode
Overseeing processing
Program execution
Cycle time
I/O refreshing
Peripheral Servicing
I/O refreshing
302
CPU Processing Modes Section 6-8
303
CPU Processing Modes Section 6-8
PLC Setup
The processing mode is specified in the PLC Setup.
Programming Name Setting Default CPU Unit
Console refresh
address timing
Word Bit
219 08 to CPU Pro- 00 Hex: Normal Mode 00 Hex: Start of
15 cessing 01 Hex: Parallel Processing Normal operation
Mode with Synchronous Memory Mode
Access
02 Hex: Parallel Processing
with Asynchronous Memory
Access
05 to FF Hex: Time slice pro-
gram execution time for
Peripheral Servicing Priority
Mode (5 to 255 ms in 1-ms
increments)
Settings of 03 and 04 Hex are
not defined (illegal) and will
cause PLC Setup errors (non-
fatal).
304
CPU Processing Modes Section 6-8
Peripheral Servicing
Overseeing Battery check, user program
memory check, etc.
0.2 ms
Peripheral Event servicing for Special I/O Units Includes event servicing to
servicing Event servicing for CPU Bus Units access I/O memory (See note.)
Peripheral port servicing Max. of 1 s for each service.
RS-232C port servicing
Event servicing for Inner Boards (CS
Series only)
Event servicing for communications
ports (internal logic ports) that are
being used (including background
execution)
Note Event servicing to access I/O memory includes 1) Servicing any received
FINS commands that access I/O memory (I/O memory read/write commands
with common codes beginning with 01 Hex or forced set/reset commands with
common codes beginning with 23 Hex) and 2) Servicing any received C-mode
commands that access I/O memory (excluding NT Links using the peripheral
or RS-232C port).
Peripheral Servicing
Overseeing Battery check, user program
memory check, etc.
0.2 ms
Peripheral Event servicing for Special I/O Units Except for event servicing to
servicing Event servicing for CPU Bus Units access I/O memory (See note.)
Peripheral port servicing Max. of 1 s for each service.
RS-232C port servicing
Event servicing for Inner Boards (CS
Series only)
Event servicing for communications
ports (internal logic ports) that are
being used (including background
execution)
Note Event servicing to access I/O memory includes 1) Servicing any received
FINS commands that access I/O memory (I/O memory read/write commands
305
Peripheral Servicing Priority Mode Section 6-9
with common codes beginning with 01 Hex or forced set/reset commands with
common codes beginning with 23 Hex) and 2) Servicing any received C-mode
commands that access I/O memory (excluding NT Links using the peripheral
or RS-232C port).
306
Peripheral Servicing Priority Mode Section 6-9
Prog ram Prog ram Prog ram Prog ram Nor mal per ipheral
Interrupted execution Interrupted execution Interrupted execution I/O refresh
execution ser vice
1 cycle
Peripheral Servicing Priority Mode can thus be used to execute periodic ser-
vicing for specified ports or Units along with the normal peripheral servicing.
This enables applications that require priority be given to peripheral servicing
over program execution, such as process control applications that require
rapid response for host monitoring.
Up to five Units or ports can be specified for priority servicing. CPU Bus
Units and CS/CJ Special I/O Units are specified by unit number.
Only one Unit or port is executed during each slice time for peripheral ser-
vicing. If servicing has been completed before the specified time expires,
program execution is resumed immediately and the next Unit or port is not
serviced until the next slice time for peripheral servicing. It is possible,
however, that the same Unit or port will be serviced more than once dur-
ing the same cycle.
Unit or ports are serviced in the order in which they are detected by the
CPU Unit.
Note 1. Even though the following instructions use the communications ports, they
will be executed only once during the execution cycle even if Peripheral
Servicing Priority Mode is used:
RXD(235) (RECEIVE)
TXD(236) (TRANSMIT)
2. If more than one word is read via a communications command, the con-
currence of the read data cannot be guaranteed when Peripheral Servicing
Priority Mode is used.
3. The CPU Unit might exceed the maximum cycle time when Peripheral Ser-
vicing Priority Mode is used. The maximum cycle time is set in the PLC
Setup as the Watch Cycle Time setting. If the cycle time exceeds the
Watch Cycle Time setting, the Cycle Time Too Long Flag (A40108) will be
turned ON and PLC operation will be stopped. If the Peripheral Servicing
Priority Mode is used, the current cycle time in A264 and A265 should be
monitored and the Watch Cycle Time (address: +209) adjusted as re-
quired. (The setting range is 10 to 40,000 ms in 10-ms increments with a
default setting of 1 s.)
307
Peripheral Servicing Priority Mode Section 6-9
PLC Setup Settings The following settings must be made in the PLC Setup to use the Peripheral
Servicing Priority Mode.
Slice Time for Program Execution: 5 to 255 ms in 1-ms increments
Slice Time for Peripheral Servicing: 0.1 to 25.5 ms in 0.1-ms increments
Units and/or Ports for Priority Servicing:CPU Bus Unit (by unit No.)
CS/CJ Special I/O Unit (by unit
No.)
Inner Board (CS Series only)
RS-232C port
Peripheral port
Address in Pro- Settings Default Function New set-
gramming Console tings effec-
Word Bit(s) tiveness
219 08 to 00 00 00: Disable priority mode servicing Takes effect
15 05 to FF 05 to FF: Time slice for instruction execution at the start
(Hex) (5 to 255 ms in 1-ms increments) of operation
00 to 00 to FF 00 00: Disable priority mode servicing (Cant be
changed
07 (Hex) 01 to FF: Time slice for peripheral servicing during oper-
(0.1 to 25.5 ms in 0.1-ms increments) ation.)
220 08 to 00 00 00: Disable priority mode servicing
15 10 to 1F 10 to 1F: CPU Bus Unit unit number + 10 (Hex)
00 to 20 to 2F 00
E1 20 to 7F: CS/CJ Special I/O Unit unit number + 20 (Hex)
07
FC E1: Inner Board
221 08 to FD (Hex) 00
FC: RS-232C port
15
FD: Peripheral port
00 to 00
07
222 08 to 00
15
Note If an error is detected in the PLC Setup, A40210 will turn ON and a non-fatal
error will occur.
308
Peripheral Servicing Priority Mode Section 6-9
Auxiliary Area Information If the slice times are set for program execution and peripheral servicing, the
total of all the program execution and peripheral servicing slice times will be
stored in A266 and A267. This information can be used as a reference in
making appropriate adjustments to the slice times.
When Peripheral Servicing Priority Mode is not being used, the program exe-
cution time will be stored. This value can be used in determining appropriate
settings for the slice times.
Words Contents Meaning Refreshing
A266 and A267 00000000 to Total of all slice times for program execution and The contents is
FFFFFFFF Hex all slice times for peripheral servicing. refreshed each cycle
(0 to 4294967295 and is cleared at the
decimal) 0.0 to 429,496,729.5 ms (0.1-ms increments) beginning of opera-
tion.
Value is stored
A267 A266 as 32-bit binary
(Most-signifi- (Least-signifi- (8-digit hexadeci-
cant bytes) cant bytes) mal) value
309
Peripheral Servicing Priority Mode Section 6-9
Operation
Time slice for Time slice for Time slice for
program execution peripheral servicing program execution
I/O refresh
Program section
requiring data
concurrence
Note 1. DI(693) and IOSP(287) will disable not only interrupts for priority servicing,
but also all other interrupts, including I/O, scheduled, and external inter-
rupts. All interrupts that have been generated will be executed after the cy-
clic task has been executed (after END(001) execution) unless CLI(691) is
executed first to clear the interrupts.
2. Disabling interrupts with DI(693) or IOSP(287) is effective until EI(694) or
IORS(288) is executed, until END(001) is executed, or until PLC operation
is stopped. Program sections can thus not be created that go past the end
of a task or cycle. Use DI(693) and EI(694) or IOSP(287) and IORS(288)
in each cyclic task when necessary to disable interrupts in more than one
cycle or task.
Condition Flags
Flag Label Operation
Error Flag ER Turns ON if DI(693) is executed in an interrupt task, and
OFF otherwise
EI(694) When executed, EI(694) enables all interrupts (except for interrupts for the
power interrupt task), including interrupts for priority servicing, I/O interrupts,
scheduled interrupts, and external interrupts. Interrupts will remain enabled if
EI(694) is executed when they are already enabled.
Symbol
EI(694) EI(694) requires no execution condition.
310
Peripheral Servicing Priority Mode Section 6-9
Condition Flags
Flag Label Operation
Error Flag ER Turns ON if EI(694) is executed in an interrupt task.
Condition Flags
Flag Label Operation
Error Flag ER Turns ON if IOSP(287) is executed in an interrupt task,
and OFF otherwise
IORS(288) When executed, IORS(288) enables disables peripheral servicing that was
disabled with IOSP(287). Peripheral servicing will remain enabled if
IORS(288) is executed when it is already enabled.
Symbol
IORS
Condition Flags
Flag Label Operation
Error Flag ER Turns ON if IORS(288) is executed in an interrupt task.
311
Battery-free Operation Section 6-10
Note 1. When using battery-free operation, disable detecting a low battery voltage
in the PLC Setup regardless of the method used for battery-free operation.
2. If a Battery is not connected or the Battery is exhausted, the following re-
strictions will apply to CPU Unit operation. This is true regardless of the
CPU Unit being used.
The contents of I/O memory (including the HR, DM, and EM Areas)
may not be correctly maintained. Therefore, set the PLC Setup so that
the status of the I/O Memory Hold Flag (A50012) and the Forced Sta-
tus Hold Flag (A50013) are not maintained when power is turned ON.
The clock function cannot be used. The clock data in A351 to A354
and the startup time in A510 and A511 will not be dependable. The
files dates on files written to the Memory Card from the CPU Unit will
also not be dependable.
The following data will be all-zeros at startup: Power ON Time (A523),
Power Interruption Time (A512 and A513), and Number of Power In-
terruptions (A514).
The Error Log Area in A100 to A199 will not be maintained.
The current EM bank will always be 0 at startup.
There will be no files left in the EM file memory at startup and the file
memory functions cannot be used. The EM file memory must be reset
in the PLC Setup and the EM file memory must be reformatted to use
it.
312
Battery-free Operation Section 6-10
as it is for the CS1 CPU Units. (With a Memory Card, the DM and EM Area
data can be included.)
Procedure
The following flowcharts show the procedures for the two types of CPU Unit.
CS1-H, CJ1-H, or CJ1M CPU Units
Power ON
Battery-free Operation
Use normal operation. No Memory
Initialize I/O No Card is required. User program and
memory before parameter data backed up in flash
memory.
program PLC Setup: Disable detection a low
execution? battery voltage.
Yes
No
313
Other Functions Section 6-11
No CNT/HR/DM/EM
Battery-free Operation
314
Other Functions Section 6-11
PLC Setup
The input response times for the 80 slots in a CS/CJ PLC (Rack 0 Slot 0
through Rack 7 slot 9) can be set in the 80 bytes in addresses 10 through 49.
Programming Name Setting (Hex) Default (Hex)
Console
address
10 CS/CJ Basic I/O Unit 00: 8 ms 00 (8 ms)
Bits 0 to 7 Input Response Time for 10: 0 ms
Rack 0, Slot 0 11: 0.5 ms
12: 1 ms
13: 2 ms
14: 4 ms
15: 8 ms
16: 16 ms
17: 32 ms
: : : :
49 CS/CJ Basic I/O Unit Same as above. 00 (8 ms)
Bits 8 to 15 Input Response Time for
Rack 7, Slot 9
315
Other Functions Section 6-11
316
SECTION 7
Program Transfer, Trial Operation, and Debugging
This section describes the processes used to transfer the program to the CPU Unit and the functions that can be used to test
and debug the program.
317
Program Transfer Section 7-1
318
Trial Operation and Debugging Section 7-2
Forced
Forced ON regardless set
Program
of programming
Forced
Input ignored set
I/O memory
Bit A
Moni-
tored
for OFF
to ON
transi-
tion.
319
Trial Operation and Debugging Section 7-2
Programming Device
The cycle time will be increased by from one to several cycle times if the pro-
gram in the CPU Unit is edited online in MONITOR mode.
The cycle time for CS1-H, CJ1-H, and CJ1M CPU Units will also be increased
to back up data in the flash memory after online editing. The BKUP indicator
will be lit during this period. The progress of the backup is displayed on the
CX-Programmer. The increases per cycle are listed in the following table.
CPU Unit Increase in cycle time
Online editing Backup to flash memory
CS1 CPU Units pre-EV1 90 ms max. Not supported.
CS1 CPU Units EV1 or later 12 ms max.
CS1-H CPU Units 4% or cycle time
CS1 CPU Units Not supported.
CJ1-H CPU Units 4% or cycle time
CJ1M CPU Units
With a CS1-H, CJ1-H, or CJ1M CPU Unit, there is a limit to the number of
edits that can be made consecutively. The actual number depends on the type
of editing that is performed, but the following can be used as guidelines.
CJ1M-CPU@@: 40 edits
CS1G-CPU@@H/CJ1G-CPU@@H: 160 edits
CS1H-CPU@@H/CJ1H-CPU@@H: 400 edits
320
Trial Operation and Debugging Section 7-2
Task Size and Cycle Time The relation to the size of the task being edited to cycle time extension is as
Extension follows:
When using a version 1 or later CS1 CPU Unit, CS1-H CPU Unit, CJ1 CPU
Unit, or CJ1M CPU Unit, the length of time that the cycle time is extended due
to online editing is almost unaffected by the size of the task (program) being
edited.
When using a pre-EV1 CS1 CPU Unit, the size of the task that is being edited
will determine the length of time that a program will be stopped for online edit-
ing. By splitting the program into smaller tasks, the amount of time that the
cycle is extended will be shorter using the Online Editing function than with
previous PLC models.
Precautions The cycle time will be longer than normal when a program is overwritten using
Online Editing in MONITOR mode, so make sure that the amount of time that
it is extended will not exceed the cycle monitoring time set in the PLC Setup. If
it does exceed the monitoring time, then a Cycle Time Over error will occur,
and the CPU Unit will stop. Restart the CPU Unit by selecting PROGRAM
mode first before changing to RUN or MONITOR mode.
Note If the task being edited online contains a block program, then previous exe-
cute data such as Standby (WAIT) or Pause status will be cleared by online
editing, and the next execution will be from the beginning.
Online Editing from CX-Programmer
1,2,3... 1. Display the program section that will be edited.
2. Select the instructions to be edited.
3. Select Program, Online Edit, and then Begin.
4. Edit the instructions.
5. Select Program, Online Edit, and then Send Changes The instructions
will be check and, if there are no errors, they will be transferred to the CPU
Unit. The instructions in the CPU Unit will be overwritten and cycle time will
be increased at this time.
!Caution Proceed with Online Editing only after verifying that the extended cycle time
will not affect operation. Input signals may not be input if the cycle time is too
long.
321
Trial Operation and Debugging Section 7-2
has been completed, the Online Editing Processing Flag (A20111) will turn
OFF.
Online editing can also be temporarily disabled by turning ON the Online Edit-
ing Disable Bit (A52709) while online editing is being performed. Here too, the
Online Editing Wait Flag (A20110) will turn ON.
If a second request for online editing is received while the first request is on
standby, the second request will not be recorded and an error will occur.
Online editing can also be disabled to prevent accidental online editing. As
described above, disable online editing by turning ON the Online Editing Dis-
able Bit (A52709) and setting the Online Editing Disable Bit Validator (A52700
to A52707) to 5A.
Enabling Online Editing from a Programming Device
When online editing cannot be enabled from the program, it can be enabled
from the CX-Programmer.
322
Trial Operation and Debugging Section 7-2
All OFF
Output OFF Bit: ON
Basic Procedure
1,2,3... 1. Sampling will start when the parameters have been set from the CX-Pro-
grammer and the command to start tracing has been executed.
2. Sampled data (after step 1 above) will be traced when the trace trigger
condition is met, and the data just after the delay (see note 1) will be stored
in Trace Memory.
3. Trace Memory data will be sampled, and the trace ended.
Note Delay value: Specifies how many sampling periods to offset the sampling in
Trace Memory from when the Trace Start Bit (A50814) turns ON. The setting
ranges are shown in the following table.
323
Trial Operation and Debugging Section 7-2
Sampling
Scheduled Data Trace A scheduled data trace will sample data at fixed intervals. Specified sampling
times are 10 to 2,550 ms in 10-ms units. Do not use the TRSM instruction in
the user program and be sure to set the sampling period higher than 0.
One-cycle Data Trace A one-cycle data trace will sample I/O refresh data after the end of the tasks
in the full cycle. Do not use the TRSM instruction in the user program and be
sure to set the sampling period higher than 0.
Data Trace via TRSM A sample will be taken once when the TRACE MEMORY SAMPLING instruc-
tion (TRSM) instruction is executed. When more than one TRSM instruction is
used in the program, a sample will be taken each time the TRSM instruction is
executed after the trace trigger condition has been met.
1,2,3... 1. Use the CX-Programmer to set trace parameters: Address of the sampled
data, sampling period, delay time, and trigger conditions.
2. Use CX-Programmer to start sampling or turn ON the Sampling Start Bit
(A50815).
3. Put the trace trigger condition into effect.
4. End tracing.
5. Use CX-Programmer to read the trace data.
a) Select Data Trace from the PLC Menu.
b) Select Select from the Execution Menu.
c) Select Execute from the Execution Menu.
d) Select Read from the Execution Menu.
Related Auxiliary Bits/Words
Name Address Description
Sampling Start Bit A50815 Use a Programming Device to turn ON this bit to start sampling. This bit
must be turned ON from a Programming Device.
Do not turn this bit ON and OFF from the user program.
Note: The bit will be cleared when the Data Trace has been completed.
Trace Start Bit A50814 When this bit is turned ON, the trace trigger will be monitored and sam-
pled data will be stored in Trace Memory when the trigger condition is
met. The following traces are enabled with this bit.
1) Scheduled trace (trace at fixed intervals of 10 to 2,550 ms)
2) TRSM instruction trace (trace when the TRSM executes)
3) One-cycle trace (trace at the end of execution of all cyclic tasks)
324
Trial Operation and Debugging Section 7-2
325
Appendix A
PLC Comparison Charts:
CJ-series, CS-series, C200HG/HE/HX,
CQM1H, CVM1, and CV-series PLCs
Functional Comparison
Item CJ Series CS Series C200HX/HG/ CVM1/CV CQM1H
HE Series
Basic features Ca- No. of I/O 2,560 points 5,120 points 1,184 points 6,144 points 512 points
pacity points
Program 120 Ksteps 250 Ksteps 2 Kwords 62 Kwords 15.2 Kwords
capacity One step is basically One step is basi- (63.2 Kwords
equivalent to one cally equivalent for -Z)
word. Refer to the end to one word.
of 10-5 Instruction Refer to the end
Execution Times and of 10-5 Instruc-
Number of Steps in tion Execution
the Operation Manual Times and Num-
for details. ber of Steps in
the Operation
Manual for
details.
Max. data 32 Kwords 32 Kwords 6 Kwords 24 Kwords 6 Kwords
memory
I/O bits 160 words (2,560 bits) 320 words 40 words 128 words 32 words
(5,120 bits) (640 bits) (2,048 bits) (512 bits)
Work bits 2,644 words 2,644 words 408 words 168 words 158 words
(42,304 bits) + WR: (42,304 bits) + (6,528 bits) (2,688 bits) (2,528 bits)
512 words (8,192 bits) WR: 512 words +400 words
= 3,156 words (8,192 bits) = (6,400 bits)
(50,496 bits) 3,156 words
(50,496 bits)
Holding bits 512 words (8,192 bits) 512 words 100 words 300 words 100 words
(8,192 bits) (1,600 bits) (4,800 bits) (1,600 bits)
Max.: 1,
400 words (2,
400 bits)
Max. 32 Kwords x 7 banks 32 Kwords x 6 Kwords x 3 32 Kwords x 8 6 Kwords
extended 13 banks banks (6 banks
data mem- Kwords x (Optional)
ory 16 banks for -Z)
Max. No. 4,096 each 4,096 each Timers/ 1,024 points Timers/
timers/ counters com- counters com-
counters bined: 512 bined: 512
Pro- Basic CJ1: 0.08 m s min. CS1: 0.104 m s min. 0.125 m s min. 0.375 m s min.
cess- instructions CJ1-H: 0.02 m s min. 0.04 m s min.
ing (LD) CJ1M: 0.1 m s min. CS1-H:
speed 0.02 m s min.
Special CJ1: 0.25 m s min. CS1: 0.417 m s min. 4.3 m s min. 17.7 m s
instructions CJ1-H: 0.18 m s min. 0.25 m s min.
(MOV)
CJ1M: 0.3 m s min. CS1-H:
0.18 m s min.
System CJ1: 0.5 ms min. CS1: 0.7 ms 0.5 ms 0.7 ms
overhead CJ1-H: 0.3 ms min. in 0.5 ms min.
time normal mode, 0.2 ms CS1-H: 0.3 ms
in a parallel process- min. in normal
ing mode mode, 0.2 ms in
CJ1M: 0.5 ms min. a parallel pro-
cessing mode
Delay during CJ1: Approx. 12 ms CS1: 80 ms (160 ms 500 ms Typically
Online Edit CJ1-H: Approx. 11 ms Approx. 12 ms for -Z) 250 ms
(write) for CPU4@ and CS1-H: Approx.
8 ms for CPU6 11 ms for CPU4@
CJ1M: and
Approx. 14 ms 8 ms for CPU6
327
PLC Comparison Charts Appendix A
328
PLC Comparison Charts Appendix A
329
PLC Comparison Charts Appendix A
330
PLC Comparison Charts Appendix A
331
PLC Comparison Charts Appendix A
332
PLC Comparison Charts Appendix A
333
PLC Comparison Charts Appendix A
334
PLC Comparison Charts Appendix A
335
PLC Comparison Charts Appendix A
Instruction Comparison
Item Mne- CJ Series CS Series C200HX/HG/HE CVM1/CV CQM1H
monic Series
Sequence LOAD/AND/OR LD/ Yes Yes Yes Yes Yes
Input AND/
Instructions OR
AND LOAD/OR AND Yes Yes Yes Yes Yes
LOAD LD/OR
LD
NOT NOT Yes Yes Yes Yes No
CONDITION ON UP Yes Yes No Yes (*1) No
CONDITION OFF DOWN Yes Yes No Yes (*1) No
BIT TEST TST/ Yes (Bit position Yes (Bit position Yes (Bit position Yes (Bit position No
TSTN specified in specified in specified in specified in
binary: binary: BCD.) (*2) BCD.) (*1)
0000 to 000F 0000 to 000F
Hex.) Hex.)
Sequence OUTPUT OUT Yes Yes Yes Yes Yes
Output
Instructions TR TR Yes Yes Yes Yes Yes
KEEP KEEP Yes Yes Yes Yes Yes
DIFFERENTIATE DIFU/ Yes (LD, Yes (LD, Yes (DIFU/ Yes (LD, Yes (DIFU/
UP/DOWN DIFD AND, OR) AND, OR) DIFD) AND, OR)/ DIFD)
(LD, AND, (LD, AND, (LD, AND,
OR) OR) OR)
SET and RESET SET/ Yes Yes Yes Yes Yes
RSET
MULTIPLE BIT SETA/ Yes (Beginning Yes (Beginning No (*1) No
SET/RESET RSTA bit and number bit and number (Beginning bit
of bits specified of bits specified and number of
in binary.) in binary.) bits specified in
BCD.)
SINGLE BIT SET/ SET/ CJ1: No CS1: No No No No
RESET RSTB CJ1-H: Yes CS1-H: Yes
CJ1M: Yes
SINGLE BIT OUT- OUTB CJ1: No CS1: No No No No
PUT CJ1-H: Yes CS1-H: Yes
CJ1M: Yes
Sequence END/NO OPERA- END/ Yes Yes Yes Yes Yes
Control TION NOP
Instructions
INTERLOCK/ IL/ILC Yes Yes Yes Yes Yes
INTERLOCK
CLEAR
JUMP/JUMP END JMP/ Yes (Jump num- Yes (Jump num- Yes (Jump num- Yes (Jump num- Yes (Jump num-
JME ber specified in ber specified in ber specified in ber specified in ber specified in
BCD: 0 to 1023) BCD: 0 to 1023) BCD: 0 to 99.) BCD: 0 to 999.) BCD: 0 to 99.)
CONDITIONAL CJP/ Yes (Jump num- Yes (Jump num- No Yes (Jump num- No
JUMP CJPN ber specified in ber specified in ber specified in
BCD: 0 to 1023.) BCD: 0 to 1023.) BCD: 0 to 999.)
(*1)
MULTIPLE JUMP/ JMP0/ Yes Yes No No (but PLC No
JUMP END JME0 Setup can be set
to enable multi-
ple jumps with
jump number 0)
FOR/NEXT FOR/ Yes Yes No No No
LOOPS NEXT
BREAK LOOP BREAK Yes Yes No No No
336
PLC Comparison Charts Appendix A
337
PLC Comparison Charts Appendix A
338
PLC Comparison Charts Appendix A
339
PLC Comparison Charts Appendix A
340
PLC Comparison Charts Appendix A
341
PLC Comparison Charts Appendix A
342
PLC Comparison Charts Appendix A
343
PLC Comparison Charts Appendix A
344
PLC Comparison Charts Appendix A
345
PLC Comparison Charts Appendix A
FAILURE POINT FPD Yes (Messages Yes (Messages Yes (Messages Yes (Messages Yes (Messages
DETECTION ended by NUL, ended by NUL, ended by CR, ended by CR, ended by CR,
text strings text strings text strings text strings text strings
stored in order of stored in order of stored in order stored in order of stored in order
leftmost to right- leftmost to right- of leftmost to leftmost to right- of leftmost to
most byte and most byte and rightmost byte most byte and rightmost byte
then rightmost to then rightmost to and then right- then rightmost to and then right-
leftmost word. leftmost word. most to leftmost leftmost word. most to leftmost
FAL number FAL number word. FAL num- FAL number word. FAL num-
specified in specified in ber specified in specified in ber specified in
binary.) binary.) BCD.) BCD.) (*1) BCD.)
Other SET CARRY/ STC/ Yes Yes Yes Yes Yes
Instructions CLEAR CARRY CLC
LOAD FLAGS/ CCL, CJ1: No CS1: No No Yes No
SAVE FLAGS CCS CJ1-H: Yes CS1-H: Yes
CJ1M: Yes
EXTEND MAXI- WDT Yes Yes Yes Yes (*1) Yes
MUM CYCLE TIME
CYCLE TIME SCAN No No Yes No No
LOAD REGISTER/ REGL, No No No Yes No
SAVE REGISTER REGS
SELECT EM EMBC Yes Yes Yes Yes No
BANK:
EXPANSION DM XDMR No No Yes No No
READ
INDIRECT EM IEMS No No Yes No No
ADDRESSING
ENABLE ACCESS/ IOSP, No CS1: No No Yes No
DISABLE ACCESS IORS CS1-H: Yes
CV-CS Address FRMCV CJ1: No CS1: No No No No
Conversion TOCV CJ1-H: Yes CS1-H: Yes
Instructions
CJ1M: Yes
346
PLC Comparison Charts Appendix A
347
Appendix B
Changes from Previous Host Link Systems
There are differences between Host Link Systems created using the CS/CJ-series Serial Communications
Boards (CS Series only) and Unit in comparison to Host Link Systems created with Host Link Units and CPU
Units in other PLC product series. These differences are described in this sections.
RS-232C Ports
Take the following differences into consideration when changing from an existing Host Link System to one
using an RS-232C port on a CS/CJ-series CPU Unit, Serial Communications Boards (CS Series only), or
Serial Communications Unit (CS1H/G-CPU@@ RS-232C port, CS1W-SCU21 ports, CS1W-SCB21 ports,
CS1W-SCB41 port 1, or CJ1W-SCU41 port 2).
Previous Model number Changes required for CS/CJ-series product
products Wiring Other
C-series Host 3G2A5-LK201-E The connector has been The following changes are necessary for
Link Units C500-LK203 changed from a 25-pin to a 9- systems that sync with ST1, ST2, and RT.
pin connector. Synchronized transfers will no longer be possi-
3G2A6-LK201-E
The CS/CJ-series products ble.
do not support the ST1, ST2, Full-duplex transmissions will be possible with
and RT signals and wiring the CS/CJ-series product, but the host com-
them is not required. puters communications program, hardware, or
both will need to be altered.
The following changes are necessary for
systems that did not sync with ST1, ST2,
and RT.
It may be possible to use the host computer
programs without alteration as long as the
same communications settings (e.g., baud rate)
are used. It may be necessary, however, to
change programs to allow for different text
lengths in frames or different CS/CJ command
specifications. (See note.)
C200H-LK201 The connector has been It may be possible to use the host computer
changed from a 25-pin to a 9- programs without alteration as long as the
pin connector. same communications settings (e.g., baud rate)
are used. It may be necessary, however, to
change programs to allow for different text
lengths in frames or different CS/CJ command
specifications. (See note.)
C-series CPU SRM1 No changes have been made It may be possible to use the host computer
Units CPM1 in wiring. programs without alteration as long as the
same communications settings (e.g., baud rate)
CPM1A are used. It may be necessary, however, to
CQM1-CPU@@-E change programs to allow for different CS/CJ
C200HS-CPU@@-E command specifications.
C200HX/HG/HE-
CPU@@-E
C200HW-COM@@-E
349
Changes from Previous Host Link Systems Appendix B
Note The number of words that can be read and written per frame (i.e., the text lengths) when using C-mode
commands is different for C-series Host Link Units and CS/CJ-series Serial Communications Boards/
Units. A host computer program previously used for C-series Host Link Units may not function correctly if
used for CS/CJ-series PLCs. Check the host computer program before using it and make any correc-
tions required to handle different frame text lengths. Refer to the CS/CJ-series Communications Com-
mands Reference Manual (W342) for details.
RS-422A/485 Ports
Take the following differences into consideration when changing from an existing Host Link System to one
using an RS-422A/485 port on a CS-series Serial Communications Board (CS1W-SCB41 port 2) or a CJ-
series Serial Communications Unit (CJ1W-SCU41 port 1).
Previous Model number Changes required for CS/CJ-series product
products Wiring Other
C-series Host Link 3G2A5-LK201-E Wiring pins have been It may be possible to use the host computer
Units C200H-LK202 changed as shown below. programs without alteration as long as the
SDA: Pin 9 to pin 1 same communications settings (e.g., baud
3G2A6-LK202-E rate) are used. It may be necessary, however,
SDB: Pin 5 to pin 2
RDA: Pin 6 to pin 6 to change programs to allow for different text
RDB: Pin 1 to pin 8 lengths in frames or different CS/CJ com-
SG: Pin 3 to mand specifications. (See note.)
Not connected
FG: Pin 7 to pin
Connector hood
C200HX/HG/HE C200HW-COM@@-E No changes have been made It may be possible to use the host computer
Communications in wiring. programs without alteration as long as the
Board same communications settings (e.g., baud
rate) are used. It may be necessary, however,
to change programs to allow for different CS/
CJ command specifications.
350
Changes from Previous Host Link Systems Appendix B
Note The number of words that can be read and written per frame (i.e., the text lengths) when using C-mode
commands is different for C-series Host Link Units and CS/CJ-series Serial Communications Boards/
Units. A host computer program previously used for C-series Host Link Units may not function correctly if
used for CS/CJ-series PLCs. Check the host computer program before using it and make any correc-
tions required to handle different frame text lengths. Refer to the CS/CJ-series Communications Com-
mands Reference Manual (W342) for details.
351
Index
$ counters
refresh mode, 276
addressing CPU Unit
index registers, 252 basic operation, 152
indirect addresses, 2627 capacities, 41
memory addresses, 24 internal structure, 6
operands, 25 operation, 1
See also index registers C-series Host Link Units
alarms changes in communications specifications, 349
user-programmed alarms, 297 C-series Units
applications changes in communications specifications, 350
file memory, 197 CVM1 Units
precautions, xiv changes in communications specifications, 350351
ASCII characters, 29 CV-series PLCs
automatic transfer at startup, 189, 214 comparison, 327
CV-series Units
% changes in communications specifications, 350351
CX-Programmer, 20
backing up data, 293
file memory, 201
Basic I/O Units
cycle time
Basic I/O Unit instructions, 129
minimum cycle time, 235
input response time, 314
monitoring, 236
battery
setting, 236
compartment, 2
task execution time, 18
installation, 2
cyclic refreshing, 38, 238
BCD data, 30
cyclic tasks, 151, 154
block programs, 22, 59, 62
Disabled status (INI), 157
block programming instructions, 138
READY status, 157
relationship to tasks, 167
RUN status, 157
status, 157
& WAIT status, 157
C200H Communications Boards, 350
C200HX/HG/HE Communications Board '
changes in communications specifications, 350 data areas
C200HX/HG/HE PLCs addressing, 24
comparison, 327 data files, 197
Carry Flag, 58 data formats, 30
clearing memory, 4 data tracing, 323
clock, 289 date
clock instructions, 134 setting the clock, 5
setting the clock, 5
dates
communications program and parameters, 291
messages, 267
debugging, 296, 318
no-protocol, 268
debugging instructions, 135
See also serial communications
failure diagnosis instructions, 136
serial communications instructions, 130
DeviceNet
comparison
precaution, 297
previous products, 350
diagnosis, 296
complete link method, 271
differentiated instructions, 36
Condition Flags, 54
directories, 191
operation in tasks, 162
down-differentiated instructions, 35
constants
operands, 28
353
Index
( force-setting bits
debugging, 318
EC Directives, xix FOR-NEXT loop, 59
EM file memory, 184
initializing, 226
operations, 230
*
See also file memory Greater Than Flag, 58
Equals Flag, 58
error log, 296 +
errors high-speed inputs, 237
access error, 65 Host Link commands, 264
error log, 296
Host Link communications, 263
failure point detection, 298
Host Link Units
fatal, 67
changes in communications specifications, 350
illegal instruction error, 65
hot starting, 286
instruction processing error, 65
program input, 63 hot stopping, 286
programming errors, 67
UM overflow error, 65 ,
user-programmed errors, 297
I/O allocations
executable status first word settings, 315
description, 16
I/O interrupts
execution conditions tasks, 154, 168171
tasks, 156
I/O memory, 67
variations, 34
addressing, 24
external interrupts initializing, 10
tasks, 155, 169171, 174 tasks, 161
I/O refreshing, 38
) I/O response time
failure alarms, 297 CS/CJ Basic I/O Units, 314
failure point detection, 298 immediate refreshing, 34, 38, 238
file memory, 183 index registers, 27, 252
accessing directories, 191 Initial Task Execution Flag, 163
applications, 197, 226 initialization
file memory instructions, 133, 204 EM file memory, 226
file names and file types, 188 I/O memory, 10
functions, 183 Memory Cards, 226
manipulating files, 199 installation
parameter files, 198 initial setup, 2, 5
program files, 198 precautions, xiv
file names, 188 instruction conditions
file types, 188 description, 21
FINS commands instructions
file memory, 202 Basic I/O Unit instructions, 129
list, 266 basic instructions, 21
flags, 22 block programming instructions, 138
Condition Flags, 54 block programs, 62
flash memory, 293 clock instructions, 134
floating-point data comparison instructions, 82
floating-point math instructions, 108 controlling tasks, 158
conversion instructions, 99
floating-point decimal, 31
counter instructions, 78
force-resetting bits
data control instructions, 120
debugging, 318
data movement instructions, 86
354
Index
355
Index
356
Index
7
table data
processing, 258
Task Error Flag, 164
Task Flags, 163
tasks, 12, 149
advantages, 150
creating tasks, 180
cyclic tasks, 151, 154
description, 14
designing, 166
examples, 164
execution, 160
execution conditions, 156
execution time, 18
features, 150
flags, 163
interrupt tasks, 151, 154, 169
introduction, 154
limitations, 162
operation of Condition Flags, 162
relationship to block programs, 167
See also cyclic tasks
See also interrupt tasks
status, 16
task control instructions, 147
task numbers, 160
timers, 161
text strings
operands, 28
text string processing instructions, 144
time
setting the clock, 5
timers, 276
creating with schedule interrupts, 284
trial operation, 318
357
Revision History
A manual revision code appears as a suffix to the catalog number on the front cover of the manual.
Revision code
The following table outlines the changes made to the manual during each revision. Page numbers refer to the
previous version.
Revision code Date Revised content
01 April 2001 Original production
02 October 2001 Added information on high-speed CS-series and high-speed CJ-series CPU Units (CS1G/H-
CPU@@H and CJ1G/H-CPU@@H)) throughout the manual.
03 July 2002 Information on CJ1M CPU Units added throughout.
PC changed to PLC for Programmable Controller.
Other changes are as follows:
Pages xvi and xviii: Caution added.
Page xix: Item 2 at bottom of page changed.
Page 28: Description for text string changed.
Page 167: Programming example changed.
Pages 168, 169, 265, and 266: Information added on DC power supplies.
Page 179: Precautions added on Memory Cards.
Page 229: Illustration changed.
Page 262: Information added on timer/counter refresh method.
Page 273: Precaution added on DeviceNet.
Page 301: Units corrected in processing speeds.
Page 304: Interrupt response time corrected.
Page 320: CJ1 support for IOSP/IORS changed.
359
Revision History
360
OMRON CORPORATION
FA Systems Division H.Q.
66 Matsumoto
Mishima-city, Shizuoka 411-8511
Japan
Tel: (81)55-977-9181/Fax: (81)55-977-9045
Regional Headquarters
OMRON EUROPE B.V.
Wegalaan 67-69, NL-2132 JD Hoofddorp
The Netherlands
Tel: (31)2356-81-300/Fax: (31)2356-81-388
OMRON ELECTRONICS LLC
1 East Commerce Drive, Schaumburg, IL 60173
U.S.A.
Tel: (1)847-843-7900/Fax: (1)847-843-8568
OMRON ASIA PACIFIC PTE. LTD.
83 Clemenceau Avenue,
#11-01, UE Square,
Singapore 239920
Tel: (65)6835-3011/Fax: (65)6835-2711
Authorized Distributor:
Cat. No. W394-E1-03 Note: Specifications subject to change without notice Printed in Japan