CQM1 CPM SRM+Programming Manual
CQM1 CPM SRM+Programming Manual
W228–E1–7
SYSMAC
CQM1/CPM1/CPM1A/SRM1
Programmable Controllers
PROGRAMMING MANUAL
CQM1/CPM1/CPM1A/SRM1
Programmable Controllers
Programming Manual
Revised May 1999
Notice:
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.
Visual Aids
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 operation
of the product.
1, 2, 3... 1. Indicates lists of one sort or another, such as procedures, checklists, etc.
OMRON, 1993
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 permis-
sion of OMRON.
No patent liability is assumed with respect to the use of the information contained herein. Moreover, because OMRON is
constantly striving to improve its high-quality products, the information contained in this manual is subject to change
without notice. Every precaution has been taken in the preparation of this manual. Nevertheless, OMRON assumes no
responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the informa-
tion contained in this publication.
v
About this Manual:
This manual describes programming of the CQM1, CPM1, CPM1A, and SRM1 Programmable Control-
lers, including memory structure, memory contents, ladder-diagram instructions, etc., and includes the
sections described below. Refer to the CQM1 Operation Manual, CPM1 Operation Manual, CPM1A Op-
eration Manual, and SRM1 Master Control Units Operation Manual for hardware information and Pro-
gramming Console operating procedures. Refer to the SSS Operation Manual: C-series PCs for SSS op-
erating procedures.
Note The SRM1 is a specialized programmable controller and is normally called a CompoBus/S Mas-
ter Control Unit. The SRM1, however, is programmed in the same way as the other Program-
mable Controllers and it is treated and referred to as a PC in this manual.
Please read this manual carefully and be sure you understand the information provided before attempting
to program and operate the CQM1, CPM1, CPM1A or SRM1.
Section 1 explains the PC Setup and related PC functions, including interrupt processing and commu-
nications. The PC Setup can be used to control the operating parameters of the PC.
Section 2 provides an introduction to new PC features, including the new instructions available through
expansion instructions and a new monitoring feature call differential monitoring.
Section 3 describes the structure of the PC’s memory areas, and explains how to use them. It also de-
scribes Memory Cassette operations used to transfer data between the CQM1 and a Memory Cassette.
Section 4 explains the basic steps and concepts involved in writing a basic ladder diagram program. It
introduces the instructions that are used to build the basic structure of the ladder diagram and control its
execution.
Section 5 individually describes the ladder-diagram programming instructions that can be used with the
PC.
Section 6 explains the methods and procedures for using host link commands, which can be used for host
link communications via the PC ports.
Section 7 explains the internal processing of the PCs, and the time required for processing and execu-
tion. Refer to this section to gain an understanding of the precise timing of PC operation.
Section 8 describes how to diagnose and correct the hardware and software errors that can occur during
PC operation.
The following appendices are also provided: A Programming Instructions, B Error and Arithmetic
Flag Operation, C Memory Areas, D Using the Clock Function, E I/O Assignment Sheet, F Pro-
gram Coding Sheet, G List of FAL Numbers, H Extended ASCII, and I CPM1A and CPM1 Memory
Area Comparison.
! WARNING Failure to read and understand the information provided in this manual may result in
personal 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.
vii
TABLE OF CONTENTS
PRECAUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
1 Intended Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
2 General Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
3 Safety Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
4 Application Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
SECTION 1
PC Setup and Other Features . . . . . . . . . . . . . . . . . . . . . . 1
1-1 PC Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1-2 Basic PC Operation and I/O Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1-3 Pulse Output Function (CQM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1-4 Pulse Output Function (CPM1A Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
1-5 CQM1 Interrupt Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1-6 CPM1/CPM1A Interrupt Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
1-7 SRM1 Interrupt Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
1-8 CompoBus/S Distributed I/O Functions (SRM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
1-9 Communications Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
1-10 Calculating with Signed Binary Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
SECTION 2
Special Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
2-1 Expansion Instructions (CQM1/SRM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
2-2 Advanced I/O Instructions (CQM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
2-3 Macro Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
2-4 Differential Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
2-5 Analog Settings (CQM1-CPU42-EV1/CPM1/CPM1A Only) . . . . . . . . . . . . . . . . . . . . . . 129
2-6 Quick-response Inputs (CPM1/CPM1A Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
SECTION 3
Memory Areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
3-1 CQM1 Memory Area Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
3-2 CPM1/CPM1A Memory Area Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
3-3 SRM1 Memory Area Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
3-4 SRM1 Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
3-5 Using Memory Cassettes (CQM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
SECTION 4
Ladder-diagram Programming . . . . . . . . . . . . . . . . . . . . 151
4-1 Basic Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
4-2 Instruction Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
4-3 Basic Ladder Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
4-4 Controlling Bit Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
4-5 Work Bits (Internal Relays) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
4-6 Programming Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
4-7 Program Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
viii
TABLE OF CONTENTS
SECTION 5
Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
5-1 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5-2 Instruction Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5-3 Data Areas, Definer Values, and Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5-4 Differentiated Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
5-5 Coding Right-hand Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
5-6 Instruction Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
5-7 Ladder Diagram Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
5-8 Bit Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
5-9 NO OPERATION – NOP(00) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
5-10 END – END(01) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
5-11 INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03) . . . . . . . . . . . . . . . . . . . 201
5-12 JUMP and JUMP END – JMP(04) and JME(05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
5-13 User Error Instructions:
FAILURE ALARM AND RESET – FAL(06) and
SEVERE FAILURE ALARM – FALS(07) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
5-14 Step Instructions:
STEP DEFINE and STEP START–STEP(08)/SNXT(09) . . . . . . . . . . . . . . . . . . . . . . . . . 206
5-15 Timer and Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
5-16 Shift Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
5-17 Data Movement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
5-18 Comparison Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
5-19 Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
5-20 BCD Calculation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
5-21 Binary Calculation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
5-22 Special Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
5-23 Logic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
5-24 Increment/Decrement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
5-25 Subroutine Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
5-26 Special Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
5-27 Communications Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
5-28 Advanced I/O Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
SECTION 6
Host Link Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
6-1 Communications Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
6-2 Command and Response Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
6-3 Host Link Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
SECTION 7
PC Operations and Processing Time . . . . . . . . . . . . . . . . 381
7-1 CQM1 Cycle Time and I/O Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
7-2 CPM1/CPM1A Cycle Time and I/O Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
7-3 SRM1 Cycle Time and I/O Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
SECTION 8
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
8-1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
8-2 Programming Console Operation Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
8-3 Programming Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
8-4 User-defined Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
8-5 Operating Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
8-6 Error Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
8-7 Host Link Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
8-8 Troubleshooting Flowcharts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
ix
TABLE OF CONTENTS
Appendices
A Programming Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
B Error and Arithmetic Flag Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
C Memory Areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
D Using the Clock Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
E I/O Assignment Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
F Program Coding Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
G List of FAL Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
H Extended ASCII . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
I CPM1/CPM1A and CQM1 Memory Area Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
x
PRECAUTIONS
This section provides general precautions for using the Programmable Controller (PC) and related devices.
The information contained in this section is important for the safe and reliable application of the Programmable Con-
troller. You must read this section and understand the information contained before attempting to set up or operate a
PC system.
xiii
Application Precautions 4
1 Intended Audience
This manual is intended for the following personnel, who must also have knowl-
edge 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 specifications
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, amusement ma-
chines, safety equipment, and other systems, machines, and equipment 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 manual
close at hand for reference during operation.
! WARNING It is extremely important that a PC and all PC Units be used for the specified
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 PC System to the above-mentioned
applications.
3 Safety Precautions
! 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.
! Caution Confirm safety at the destination node before transferring a program to another
node or changing the I/O memory area. Doing either of these without confirming
safety may result in injury.
4 Application Precautions
Observe the following precautions when using the PC System.
! Caution Failure to abide by the following precautions could lead to faulty operation of the
PC or the system, or could damage the PC or PC Units. Always heed these pre-
cautions.
xiv
Application Precautions 4
• Check the user program for proper execution before actually running it on the
Unit. Not checking the program may result in an unexpected operation.
• 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 PC.
• 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 contents of
the DM and HR Areas required for resuming operation. Not doing so may result
in an unexpected operation.
• Do not place objects on top of the cables. Doing so may break the cables.
• Before touching the Unit, be sure to first touch a grounded metallic object in
order to discharge any static built-up. Not doing so may result in malfunction or
damage.
• Do not touch the Expansion I/O Unit Connecting Cable while the power is
being supplied in order to prevent any malfunction due to static electricity.
! Caution Always clear memory before beginning to program the CPM1, CPM1A or SRM1.
Although memory is cleared before the CPU Unit is shipped (except for bits with
specific functions), AR 1314, which turns ON when the internal capacitor cannot
back up memory, may have turned ON during shipment.
! Caution If the CPM1 or CPM1A will be turned OFF for periods exceeding the data backup
period of the internal capacitor, design the system so that it will not be influenced
if data in the DM, HR, and CNT areas is cleared when power is turned OFF.
! Caution Either switch the CPM1 or CPM1A to RUN or MONITOR mode, or turn OFF and
ON power to the CPM1 or CPM1A after changing from a Programming Device
any data that is backed up in flash memory. This data includes the user program,
read-only DM area (DM 6144 to DM 6599), and the PC Setup (DM 6600 to DM
6655).
• The user program and memory area data in the CPM1 or CPM1A are backed
up either by an internal capacitor or in flash memory as shown in the following
table.
Backup method Data
Internal capacitor Read/write DM area (DM 0000 to DM 0999, DM 1022, and
DM 1023)
Error log area (DM 1000 to DM 1021)
HR area (HR 00 to HR 19)
Counter area (CNT 000 to CNT 127)
Flash memory User program
Read-only DM area (DM 6144 to DM 6599)
PC Setup (DM 6600 to DM 6655)
Note 1. The IR, TR, LR, and timer areas are not normally backed up when power is
turned OFF and all contents will be cleared the next time power is turned
ON. (The PC Setup setting in DM 6601 can be used to back up this data.
Refer to details on the PC Setup later in this manual for details.)
2. The bits in the AR and SR areas have special functions and are set accord-
ing to these functions when power is turned ON.
xv
Application Precautions 4
10
7
1
25 40 80
Ambient temperature (C)
If the power remains OFF for a period exceeding the data backup period,
AR 1314 will turn ON to indicate that the capacitor can no longer back up data
and the data backed up by the capacitor will be cleared. AR 1314 will remain
ON unless it is turned OFF using I/O monitor operations, using memory clear
operations, or from the user program.
If desired, the PC Setup setting in DM 6604 can be set to create a fatal error
and thus stop the system when AR 1314 goes ON.
• The data stored in flash memory will not be lost even if power remains OFF for
a period exceeding the data backup period, because the data stored in flash
memory will be read to the CPU Unit when the CPM1 or CPM1A is turned ON.
• If the power is turned OFF without changing the mode from PROGRAM mode
to RUN or MONITOR mode after having made changes in the data that is
backed up in flash memory, the changes will not be written to flash memory. If
the power is then left OFF for more than 20 days (at 25C), the changes (i.e.,
the contents of the RAM) will be erased and the data values will become unde-
fined.
! Caution Be sure that the SRM1 system is not influenced by any undefined data if the data
in the DM, HR, or CNT area is cleared when the SRM1 has been turned OFF for
a period exceeding the data backup period of the internal lithium battery. If the
AR 1414 flag is ON, the data will be held unless it is turned OFF using the I/O
Monitor operation, instructions, etc. The system can be stopped by designating
DM 6604 in the PC Setup so that a memory error occurs when the power inter-
ruption hold area is not held (with AR 1314 ON)
• A lithium battery in the CPU Unit is used to back up the counter values and the
contents of the DM area, and HR area. The deterioration of the lithium battery
capacity depends on the ambient temperature. The standard service life is
12 years at an ambient temperature of 40C when operating 8 hours a day.
If the power remains off for a period exceeding the data backup period, the
contents of the Data Memory (DM), Hold Relay (HR), and Counter (CNT)
Areas in the CPU Unit may be cleared and the AR 1314 flag (which turns ON
when the power interruption hold area is not held) may turn ON.
If the contents of the CPU Unit’s program area are lost, the program stored in
flash memory will be read to the CPU Unit’s program area when the SRM1 is
started up because the contents in the read-only area (DM 6144 through
DM 6599) and PC Setup (DM 6600 through DM 6655) will be written to flash
memory.
xvi
Application Precautions 4
• However, if the power is turned OFF without changing the mode even if
changes are made in the read-only DM area (DM 6144 through DM 6599), or
PC Setup (DM 6600 through DM 6655) using a peripheral device, the contents
of changes will not be written to flash memory. Although the data in these areas
is backed up by the lithium battery, contents of changes will disappear if the
service life of the lithium battery expires. In this case, programs in the flash
memory will be automatically read into the user program memory.
The changes can be saved by switching the SRM1 to RUN or MONITOR mode
or turning OFF and restarting the SRM1 soon after the changes are made.
xvii
TABLE OF CONTENTS
PRECAUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
1 Intended Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
2 General Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
3 Safety Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
4 Application Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
SECTION 1
PC Setup and Other Features . . . . . . . . . . . . . . . . . . . . . . 1
1-1 PC Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1-2 Basic PC Operation and I/O Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1-3 Pulse Output Function (CQM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1-4 Pulse Output Function (CPM1A Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
1-5 CQM1 Interrupt Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1-6 CPM1/CPM1A Interrupt Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
1-7 SRM1 Interrupt Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
1-8 CompoBus/S Distributed I/O Functions (SRM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
1-9 Communications Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
1-10 Calculating with Signed Binary Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
SECTION 2
Special Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
2-1 Expansion Instructions (CQM1/SRM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
2-2 Advanced I/O Instructions (CQM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
2-3 Macro Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
2-4 Differential Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
2-5 Analog Settings (CQM1-CPU42-EV1/CPM1/CPM1A Only) . . . . . . . . . . . . . . . . . . . . . . 129
2-6 Quick-response Inputs (CPM1/CPM1A Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
SECTION 3
Memory Areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
3-1 CQM1 Memory Area Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
3-2 CPM1/CPM1A Memory Area Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
3-3 SRM1 Memory Area Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
3-4 SRM1 Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
3-5 Using Memory Cassettes (CQM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
SECTION 4
Ladder-diagram Programming . . . . . . . . . . . . . . . . . . . . 151
4-1 Basic Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
4-2 Instruction Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
4-3 Basic Ladder Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
4-4 Controlling Bit Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
4-5 Work Bits (Internal Relays) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
4-6 Programming Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
4-7 Program Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
vii
TABLE OF CONTENTS
SECTION 5
Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
5-1 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5-2 Instruction Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5-3 Data Areas, Definer Values, and Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5-4 Differentiated Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
5-5 Coding Right-hand Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
5-6 Instruction Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
5-7 Ladder Diagram Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
5-8 Bit Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
5-9 NO OPERATION – NOP(00) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
5-10 END – END(01) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
5-11 INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03) . . . . . . . . . . . . . . . . . . . 201
5-12 JUMP and JUMP END – JMP(04) and JME(05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
5-13 User Error Instructions:
FAILURE ALARM AND RESET – FAL(06) and
SEVERE FAILURE ALARM – FALS(07) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
5-14 Step Instructions:
STEP DEFINE and STEP START–STEP(08)/SNXT(09) . . . . . . . . . . . . . . . . . . . . . . . . . 206
5-15 Timer and Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
5-16 Shift Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
5-17 Data Movement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
5-18 Comparison Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
5-19 Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
5-20 BCD Calculation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
5-21 Binary Calculation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
5-22 Special Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
5-23 Logic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
5-24 Increment/Decrement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
5-25 Subroutine Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
5-26 Special Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
5-27 Communications Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
5-28 Advanced I/O Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
SECTION 6
Host Link Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
6-1 Communications Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
6-2 Command and Response Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
6-3 Host Link Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
SECTION 7
PC Operations and Processing Time . . . . . . . . . . . . . . . . 381
7-1 CQM1 Cycle Time and I/O Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
7-2 CPM1/CPM1A Cycle Time and I/O Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
7-3 SRM1 Cycle Time and I/O Response Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
SECTION 8
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
8-1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
8-2 Programming Console Operation Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
8-3 Programming Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
8-4 User-defined Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
8-5 Operating Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
8-6 Error Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
8-7 Host Link Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
8-8 Troubleshooting Flowcharts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
viii
TABLE OF CONTENTS
Appendices
A Programming Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
B Error and Arithmetic Flag Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
C Memory Areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
D Using the Clock Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
E I/O Assignment Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
F Program Coding Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
G List of FAL Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
H Extended ASCII . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
I CPM1/CPM1A and CQM1 Memory Area Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
ix
PRECAUTIONS
This section provides general precautions for using the Programmable Controller (PC) and related devices.
The information contained in this section is important for the safe and reliable application of the Programmable Con-
troller. You must read this section and understand the information contained before attempting to set up or operate a
PC system.
xiii
Application Precautions 4
1 Intended Audience
This manual is intended for the following personnel, who must also have knowl-
edge 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 specifications
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, amusement ma-
chines, safety equipment, and other systems, machines, and equipment 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 manual
close at hand for reference during operation.
! WARNING It is extremely important that a PC and all PC Units be used for the specified
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 PC System to the above-mentioned
applications.
3 Safety Precautions
! 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.
! Caution Confirm safety at the destination node before transferring a program to another
node or changing the I/O memory area. Doing either of these without confirming
safety may result in injury.
4 Application Precautions
Observe the following precautions when using the PC System.
! Caution Failure to abide by the following precautions could lead to faulty operation of the
PC or the system, or could damage the PC or PC Units. Always heed these pre-
cautions.
xiv
Application Precautions 4
• Check the user program for proper execution before actually running it on the
Unit. Not checking the program may result in an unexpected operation.
• 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 PC.
• 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 contents of
the DM and HR Areas required for resuming operation. Not doing so may result
in an unexpected operation.
• Do not place objects on top of the cables. Doing so may break the cables.
• Before touching the Unit, be sure to first touch a grounded metallic object in
order to discharge any static built-up. Not doing so may result in malfunction or
damage.
• Do not touch the Expansion I/O Unit Connecting Cable while the power is
being supplied in order to prevent any malfunction due to static electricity.
! Caution Always clear memory before beginning to program the CPM1, CPM1A or SRM1.
Although memory is cleared before the CPU Unit is shipped (except for bits with
specific functions), AR 1314, which turns ON when the internal capacitor cannot
back up memory, may have turned ON during shipment.
! Caution If the CPM1 or CPM1A will be turned OFF for periods exceeding the data backup
period of the internal capacitor, design the system so that it will not be influenced
if data in the DM, HR, and CNT areas is cleared when power is turned OFF.
! Caution Either switch the CPM1 or CPM1A to RUN or MONITOR mode, or turn OFF and
ON power to the CPM1 or CPM1A after changing from a Programming Device
any data that is backed up in flash memory. This data includes the user program,
read-only DM area (DM 6144 to DM 6599), and the PC Setup (DM 6600 to DM
6655).
• The user program and memory area data in the CPM1 or CPM1A are backed
up either by an internal capacitor or in flash memory as shown in the following
table.
Backup method Data
Internal capacitor Read/write DM area (DM 0000 to DM 0999, DM 1022, and
DM 1023)
Error log area (DM 1000 to DM 1021)
HR area (HR 00 to HR 19)
Counter area (CNT 000 to CNT 127)
Flash memory User program
Read-only DM area (DM 6144 to DM 6599)
PC Setup (DM 6600 to DM 6655)
Note 1. The IR, TR, LR, and timer areas are not normally backed up when power is
turned OFF and all contents will be cleared the next time power is turned
ON. (The PC Setup setting in DM 6601 can be used to back up this data.
Refer to details on the PC Setup later in this manual for details.)
2. The bits in the AR and SR areas have special functions and are set accord-
ing to these functions when power is turned ON.
xv
Application Precautions 4
10
7
1
25 40 80
Ambient temperature (C)
If the power remains OFF for a period exceeding the data backup period,
AR 1314 will turn ON to indicate that the capacitor can no longer back up data
and the data backed up by the capacitor will be cleared. AR 1314 will remain
ON unless it is turned OFF using I/O monitor operations, using memory clear
operations, or from the user program.
If desired, the PC Setup setting in DM 6604 can be set to create a fatal error
and thus stop the system when AR 1314 goes ON.
• The data stored in flash memory will not be lost even if power remains OFF for
a period exceeding the data backup period, because the data stored in flash
memory will be read to the CPU Unit when the CPM1 or CPM1A is turned ON.
• If the power is turned OFF without changing the mode from PROGRAM mode
to RUN or MONITOR mode after having made changes in the data that is
backed up in flash memory, the changes will not be written to flash memory. If
the power is then left OFF for more than 20 days (at 25C), the changes (i.e.,
the contents of the RAM) will be erased and the data values will become unde-
fined.
! Caution Be sure that the SRM1 system is not influenced by any undefined data if the data
in the DM, HR, or CNT area is cleared when the SRM1 has been turned OFF for
a period exceeding the data backup period of the internal lithium battery. If the
AR 1414 flag is ON, the data will be held unless it is turned OFF using the I/O
Monitor operation, instructions, etc. The system can be stopped by designating
DM 6604 in the PC Setup so that a memory error occurs when the power inter-
ruption hold area is not held (with AR 1314 ON)
• A lithium battery in the CPU Unit is used to back up the counter values and the
contents of the DM area, and HR area. The deterioration of the lithium battery
capacity depends on the ambient temperature. The standard service life is
12 years at an ambient temperature of 40C when operating 8 hours a day.
If the power remains off for a period exceeding the data backup period, the
contents of the Data Memory (DM), Hold Relay (HR), and Counter (CNT)
Areas in the CPU Unit may be cleared and the AR 1314 flag (which turns ON
when the power interruption hold area is not held) may turn ON.
If the contents of the CPU Unit’s program area are lost, the program stored in
flash memory will be read to the CPU Unit’s program area when the SRM1 is
started up because the contents in the read-only area (DM 6144 through
DM 6599) and PC Setup (DM 6600 through DM 6655) will be written to flash
memory.
xvi
Application Precautions 4
• However, if the power is turned OFF without changing the mode even if
changes are made in the read-only DM area (DM 6144 through DM 6599), or
PC Setup (DM 6600 through DM 6655) using a peripheral device, the contents
of changes will not be written to flash memory. Although the data in these areas
is backed up by the lithium battery, contents of changes will disappear if the
service life of the lithium battery expires. In this case, programs in the flash
memory will be automatically read into the user program memory.
The changes can be saved by switching the SRM1 to RUN or MONITOR mode
or turning OFF and restarting the SRM1 soon after the changes are made.
xvii
SECTION 1
PC Setup and Other Features
This section explains the PC Setup and other CQM1/CPM1/CPM1A/SRM1 features, including interrupt processing and com-
munications. The PC Setup can be used to control the operating parameters of the CQM1/CPM1/CPM1A/SRM1. To change
the PC Setup, refer to the CQM1 Operation Manual, CPM1 Operation Manual, CPM1A Operation Manual or SRM1 Master
Control Units Operation Manual for Programming Console procedures. Refer to the SSS Operation Manual: C-series PCs
for SSS procedures.
If you are not familiar with OMRON PCs or ladder diagram program, you can read 1-5 PC Setup as an overview of the operat-
ing parameters available for the CQM1/CPM1/CPM1A/SRM1, but may then want to read Section 3 Memory Areas, Section 4
Ladder-diagram Programming, and related instructions in Section 5 Instruction Set before completing this section.
1-1 PC Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1-1-1 Changing the PC Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1-1-2 CQM1 PC Setup Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1-1-3 CPM1/CPM1A PC Setup Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1-1-4 SRM1 PC Setup Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1-2 Basic PC Operation and I/O Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1-2-1 Startup Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1-2-2 Hold Bit Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1-2-3 Program Memory Write-protection (CPM1/CPM1A Only) . . . . . . . . . . . . . . . . . 17
1-2-4 RS-232C Port Servicing Time (CQM1/SRM1 Only) . . . . . . . . . . . . . . . . . . . . . . 18
1-2-5 Peripheral Port Servicing Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1-2-6 Cycle Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1-2-7 Input Time Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1-2-8 High-speed Timers (CQM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1-2-9 DSW(87) Input Digits & Output Refresh Method (CQM1 Only) . . . . . . . . . . . . . 21
1-2-10 Error Log Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1-3 Pulse Output Function (CQM1 Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1-3-1 Types of Pulse Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1-3-2 Standard Pulse Output from an Output Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1-3-3 Standard Pulse Output from Ports 1 and 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
1-3-4 Variable-duty-ratio Pulse Output from Ports 1 and 2 . . . . . . . . . . . . . . . . . . . . . . 32
1-3-5 Determining the Status of Ports 1 and 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
1-4 Pulse Output Function (CPM1A Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
1-4-1 Programming Example in Continuous Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1-4-2 Programming Example in Independent Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1-4-3 Using Pulse Output Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1-4-4 Changing the Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
1-4-5 Stopping Pulse Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
1-5 CQM1 Interrupt Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1-5-1 Types of Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1-5-2 Input Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
1-5-3 Masking All Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
1-5-4 Interval Timer Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
1-5-5 High-speed Counter 0 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
1-5-6 High-speed Counter 0 Overflows/Underflows . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
1-5-7 High-speed Counter 1 and 2 Interrupts (CQM1-CPU43-EV1) . . . . . . . . . . . . . . . 55
1-5-8 Absolute High-speed Counter Interrupts (CQM1-CPU44-EV1) . . . . . . . . . . . . . 62
1-6 CPM1/CPM1A Interrupt Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
1-6-1 Types of Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
1-6-2 Input Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
1-6-3 Masking All Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
1-6-4 Interval Timer Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
1-6-5 High-speed Counter Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
1
Section
2
PC Setup Section 1-1
1-1 PC Setup
The PC Setup comprises various operating parameters that control
CQM1/CPM1/CPM1A/SRM1 operation. In order to make the maximum use of
CQM1/CPM1/CPM1A/SRM1 functionality when using interrupt processing and
communications functions, the PC Setup may be customized according to oper-
ating conditions.
At the time of shipping, the defaults are set for general operating conditions, so
that the CQM1/CPM1/CPM1A/SRM1 can be used without having to change the
settings. You are, however, advised to check the default values before opera-
tion.
Default Values The default values for the PC Setup are 0000 for all words. The default values
can be reset at any time by turning ON SR 25210.
! Caution When data memory (DM) is cleared from a Programming Device, the PC Setup
settings will also be cleared to all zeros.
Errors in the PC Setup If an incorrect PC Setup setting is accessed, a non-fatal error (error code 9B) will
be generated, the corresponding error flag (AR 2400 to AR 2402 in the CQM1,
AR 1300 to AR 1302 in the CPM1/CPM1A/SRM1) will be turned ON, and the
default setting will be used instead of the incorrect setting.
3
PC Setup Section 1-1
The PC Setup is broadly divided into four categories: 1) Settings related to basic
CQM1 operation and I/O processes, 2) Settings related to pulse output func-
tions, 3) Settings related to interrupts, and 4) Settings related to communica-
tions. This section will explain the settings according to these classifications.
The following table shows the setting in order in the DM area. For details, refer to
the page numbers shown.
4
PC Setup Section 1-1
5
PC Setup Section 1-1
6
PC Setup Section 1-1
7
PC Setup Section 1-1
8
PC Setup Section 1-1
The following table shows the settings for CPM1/CPM1A PCs in order. Refer to
the page number in the last column for more details on that setting.
9
PC Setup Section 1-1
10
PC Setup Section 1-1
Note 1. When the startup mode is set to continue the operating mode last used be-
fore the power was turned off, that operating mode will be retained by the
built-in capacitor. If the power remains off for longer than the backup time of
the capacitor, the data may be lost. (For details on the holding time, refer to
the CPM1A or CPM1 Operation Manual.)
11
PC Setup Section 1-1
2. Do not set to “05” to “07.” If set to this value, the CPM1/CPM1A will not oper-
ate properly and the RUN PC Setup Error Flag (AR 1302 ON) will not turn
ON.
3. Retention of IOM Hold Bit (SR 25212) Status
If the “IOM Hold Bit Status at Startup” (DM 6601, bits 08 to 11) is set to “Main-
tain” with the IOM Hold Bit (SR 25212) turned ON, operation can be started
with the I/O memory (I/O, IR, LR) status just as it was before the power was
turned OFF. (The input area is refreshed at startup, however, so it is over-
written by the most recently updated input status.)
Retention of Forced Status Hold Bit (SR 25211) Status
If the “Forced Status Hold Bit Status at Startup” (DM 6601, bits 12 to 15) is
set to “Maintain” with the Forced Status Hold Bit (SR 25211) turned ON, op-
eration can be started with the forced set/reset status just as it was before
the power was turned OFF. (When starting up in RUN Mode, however, the
forced set/reset status is cleared.)
Even if the “IOM Hold Bit Status at Startup” or “Forced Status Hold Bit Status
at Startup” is set to “Maintain,” the IOM Hold Bit (SR 25212) or Forced Status
Hold Bit (SR 25211) status may be cleared if the power remains OFF for
longer than the backup time of the built-in capacitor. (For details on the hold-
ing time, refer to the CPM1A or CPM1 Operation Manual.) At this time the
I/O memory will also be cleared, so set up the system so that clearing the I/O
memory will not cause problems.
4. The transmission delay is the delay between the previous transmission and
the next transmission.
12
PC Setup Section 1-1
The PC Setup is broadly divided into three categories: 1) Settings related to ba-
sic PC operation and I/O processes, 2) Settings related to the cycle time, and 3)
Settings related to communications. This section will explain the settings ac-
cording to these classifications.
The following table shows the settings for SRM1 PCs in order. Refer to the page
number in the last column for more details on that setting.
13
PC Setup Section 1-1
14
PC Setup Section 1-1
15
Basic PC Operation and I/O Processes Section 1-2
Note If an out-of-range value is set, the following communications conditions will re-
sult. In that case, reset the value so that it is within the permissible range.
Communications mode: Host Link
Communications format: Standard settings
(1 start bit, 7-bit data; even parity, 2 stop bits,
9,600 bps)
Transmission delay: No
Node number: 00
Startup Mode (Bits 08 to 15: Valid when bits 00 to 07 are set to 02)
00: PROGRAM mode
01: MONITOR mode
02: RUN mode
16
Basic PC Operation and I/O Processes Section 1-2
The Forced Status Hold Bit (SR 25211) determines whether or not the forced
set/reset status is retained when changing from PROGRAM mode to MONITOR
mode.
The IOM Hold Bit (SR 25212) determines whether or not the status of IR bits and
LR bits is retained when PC operation is started and stopped.
! Caution Do not use the I/O Hold Bit Status and Forced Status Hold Bit Status Bits
(DM 6601) when the power to the PC is going to be turned off longer than the
memory backup time of the internal capacitor. If the memory backup time is ex-
ceeded, memory status will be unstable even if the I/O Hold Bit Status and
Forced Status Hold Bit Status Bits are used. Unpredictable results may occur if
operation is attempted with unstable memory status.
Note 1. The memory backup time of the internal capacitor varies with the ambient
temperature, but is 20 days at 25C. Refer to hardware specifications for
more details.
2. The memory backup time assumes that the internal capacitor is fully
charged before power is turned off. Fulling charging the capacitor requires
that power is supplied to the CPU Unit for at least 15 minutes.
Always 00
Note DM 6602 itself can still be changed after the program memory has been write-
protected by setting bits 04 to 07 of DM 6602 to 1.
17
Basic PC Operation and I/O Processes Section 1-2
DM6616
Example: If DM 6616 is set to 0110, the RS-232C port will be serviced for 10% of
the cycle time.
The servicing time will be 0.34 ms minimum.
The entire servicing time will not be used unless processing requests exist.
DM6617
Example: If DM 6617 is set to 0115, the peripheral port will be serviced for 15%
of the cycle time.
The servicing time will be 0.34 ms minimum.
The entire servicing time will not be used unless processing requests exist.
If the actual cycle time is shorter than the minimum cycle time, execution will wait
until the minimum time has expired. If the actual cycle time is longer than the
minimum cycle time, then operation will proceed according to the actual cycle
time. AR 2405 will turn ON if the minimum cycle time is exceeded.
18
Basic PC Operation and I/O Processes Section 1-2
Time constant for IR 003, IR 005, IR 007, IR 009, IR 011, IR 013, and IR 015
Time constant for IR 002, IR 004, IR 006, IR 008, IR 010, IR 012, and IR 014
Default: 0000 (8 ms for each)
The nine possible settings for the input time constant are shown below. Set only
the rightmost digit for IR 000.
0: 8 ms 1: 1 ms 2: 2 ms 3: 4 ms 4: 8 ms
5: 16 ms 6: 32 ms 7: 64 ms 8: 128 ms
CPM1/CPM1A PCs Set the input time constants for CPM1/CPM1A inputs from a Peripheral Device.
Input Time Constants for IR 000
Bit 15 0
DM 6620
19
Basic PC Operation and I/O Processes Section 1-2
Bit 15 0
DM 6621: IR 001 and IR 002
DM 6621 to DM 6625
DM 6622: IR 003 and IR 004
DM 6623: IR 005 and IR 006
DM 6624: IR 007 and IR 008
DM 6625: IR 009
The nine possible settings for the input time constant are shown below. Set only
the rightmost digit for IR 000.
0: 8 ms 1: 1 ms 2: 2 ms 3: 4 ms 4: 8 ms
5: 16 ms 6: 32 ms 7: 64 ms 8: 128 ms
The CPM1/CPM1A’s I/O response time is the input time constant (1 ms to 128
ms; default is 8 ms) + the cycle time.
Refer to 7-2 CPM1/CPM1A Cycle Time and I/O Response Time for more details.
Bit 15 0
DM6629
Default: Interrupt processing for all high-speed timers,TIM 000 to TIM 015.
The setting indicates the number of timers that will use interrupt processing be-
ginning with TIM 000. For example, if “0108” is specified, then eight timers,
TIM 000 to TIM 007 will use interrupt processing.
Note High-speed timers will not be accurate without interrupt processing unless the
cycle time is 10 ms or less.
Interrupt response time for other interrupts will be improved if interrupt proces-
sing is set to 00 when high-speed timer processing is not required. This includes
any time the cycle time is less than 10 ms.
Note If the SPED(64) instruction is used and pulses are output at a frequency of
500 Hz or greater, then set the number of high-speed timers with interrupt pro-
cessing to four or less. Refer to information on the SPED(64) instruction for de-
tails.
20
Basic PC Operation and I/O Processes Section 1-2
1-2-9 DSW(87) Input Digits & Output Refresh Method (CQM1 Only)
Make the settings shown below to set the number of input digits the DSW(87)
instruction, and to set the output refresh method.
Bit 15 0
DM 6639
Refer to Section 2 New Features for details on the DSW(87) instruction and to
Section 7 PC Operations and Processing Time for details on I/O refresh meth-
ods.
1-2-10 Error Log Settings
Make the settings shown below for detecting errors and storing the error log.
Cycle Monitor Time (DM 6618)
Bit 15 0
DM6618
The cycle monitor time is used for checking for extremely long cycle times, as
can happen when the program goes into an infinite loop. If the cycle time ex-
ceeds the cycle monitor setting, a fatal error (FALS 9F) will be generated.
Note 1. The unit used for the maximum and current cycle times recorded in the AR
area (AR 26 and AR 27 in the CQM1, AR 14 and AR 15 in the
CPM1/CPM1A/SRM1) depend on the unit set for the cycle monitor time in
DM 6618, as shown below.
Bits 08 to 15 set to 01: 0.1 ms
Bits 08 to 15 set to 02: 1 ms
Bits 08 to 15 set to 03: 10 ms
2. If the cycle time is 1 s or longer, the cycle time read from Programming De-
vices will be 999.9 ms. The correct maximum and current cycle times will be
recorded in the AR area.
Example
If 0230 is set in DM 6618, an FALS 9F error will not occur until the cycle time
exceeds 3 s. If the actual cycle time is 2.59 s, the current cycle time stored in the
AR area will be 2590 (ms), but the cycle time read from a Programming Device
will be 999.9 ms.
A “cycle time over” error (non-fatal) will be generated when the cycle time ex-
ceeds 100 ms unless detection of long cycle times is disable using the setting in
DM 6655.
21
Pulse Output Function (CQM1 Only) Section 1-3
Default: Low battery voltage and cycle time over errors detected, and error records
stored for the 10 most recent errors.
Battery errors and cycle time overrun errors are non-fatal errors.
For details on the error log, refer to Section 8 Troubleshooting.
Note The low battery error is applicable to CQM1 only. This digit isn’t used in
CPM1/CPM1A/SRM1 PCs.
22
Pulse Output Function (CQM1 Only) Section 1-3
Variable-duty-ratio Pulse With the CQM1-CPU43-EV1, variable-duty-ratio pulses (duty ratio = 0% to 99%)
Output from Ports 1 and 2 can be output from port 1 and/or 2 with frequencies of 91.6 Hz, 1.5 kHz, or 5.9
kHz. Only one direction can be output and the pulse output will continue until
stopped with INI(61).
Refer to page 32 for more details.
t on
+ 50% (0.5)
T
ton
Time
PC Setup Settings Before executing SPED(64) to output pulses from an Output Unit, set the PC to
PROGRAM mode and make the following settings in the PC Setup.
In DM 6615, specify the output word that will be used for SPED(64) pulse output
to Output Units. (The bit is specified in the first operand in SPED(64).)
23
Pulse Output Function (CQM1 Only) Section 1-3
The content of DM 6615 (0000 to 0011) specifies output words IR 100 to IR 111.
For example, if DM 6615 is set to 0002, pulses will be output to IR 102.
Bit 15 0
DM6615 0 0
Always 00
Output word (rightmost 2 digits, BCD): 00 to 11
Continuous Pulse Output Pulses will begin to be output at the specified output bit when SPED(64) is
executed. Set the output bit from 00 to 15 (D=000 to 150) and the frequency from
20 Hz to 1000 Hz (F=0002 to 0100). Set the mode to continuous mode (M=001).
Execution condition
@SPED(64)
The pulse output can be stopped by executing INI(61) with C=003 or executing
SPED(64) again with the frequency set to 0. The frequency can be changed by
executing SPED(64) again with a different frequency setting.
Setting the Number of Pulses The total number of pulses that will be output can be set with PULS(65) before
executing SPED(64) in independent mode. The pulse output will stop automati-
cally when the number of pulses set by PULS(65) have been output.
Execution condition
@PULS(65)
000
000
P1
PULS(65) sets the 8-digit number of pulses P1+1, P1. These pulses can be set
from 00000001 to 16777215. The number of pulses set with PULS(65) is ac-
cessed when SPED(64) is executed in independent mode. (The number of
pulses cannot be changed for pulses that are being output.)
Execution condition
@SPED(64)
When SPED(64) is executed, pulses will begin to be output at the specified out-
put bit (D=000 to 150: bit 00 to 15) at the specified frequency (F=0002 to 0100:
20 Hz to 1000 Hz). Set the mode to independent mode (M=001) to output the
number of pulses set with PULS(65). The frequency can be changed by execut-
ing SPED(64) again with a different frequency setting.
24
Pulse Output Function (CQM1 Only) Section 1-3
Changing the Frequency The frequency of the pulse output can be changed by executing SPED(64) again
with a different frequency setting. Use the same output bit (P) and mode (M) set-
tings that were used to start the pulse output. The new frequency can be fre-
quency 20 Hz to 1000 Hz (F=0002 to 0100).
CPU Unit
t on
+ 50% (0.5)
T
ton
Port 1 CW
CCW
Port 2 CW
CCW T
Note Only the CQM1-CPU43-EV1 CPU Unit can output pulses from ports 1 and 2.
When outputting pulses from a port, the frequency can be changed smoothly or
in steps with SPED(64), PLS2(––), and ACC(––), as shown in the following dia-
gram.
Frequency
Time
25
Pulse Output Function (CQM1 Only) Section 1-3
The following table shows the types of frequency changes that can be made with
combinations of PULS(65), SPED(64), INI(61), PLS2(––), and ACC(––).
PC Setup Settings Before outputting pulses from port 1 or 2, switch the PC to PROGRAM mode and
make the following settings in the PC Setup.
In DM 6611, specify the mode setting for ports 1 and 2.
Bit 15 0
DM 6611 0 1
26
Pulse Output Function (CQM1 Only) Section 1-3
The setting in DM 6611 is read only when the CQM1 is started. If this setting is
changed, be sure to turn the PC off and then on again to make the new setting
effective.
Specify standard pulse outputs in DM 6643 (port 1) and/or DM 6644 (port 2).
Bit 15 0 Bit 15 0
DM 6643 0 DM 6644 0
Variable-duty-ratio pulses cannot be output from a port if it has been set for stan-
dard pulse output in DM 6643 or DM 6644.
Example 1: The following example shows PULS(65) and SPED(64) used to control a pulse
Starting Pulse Output with output from port 1. The number of pulses specified in PULS(65) (10,000) are out-
PULS(65) and SPED(64) put as the frequency is changed by executions of SPED(64) with different fre-
quency settings.
Before executing the program make sure that DM 6611 is set to 0001 (pulse out-
put mode) and DM 6643 is set to 0000 (standard pulse setting for port 1).
05000
@PULS(65) When 05000 goes ON, PULS(65) sets port 1 for 10,000 CW
pulses.
001
000
DM 0000
000
#0100
00000
@SPED(64) When 00000 goes ON, the frequency from port 1 is
changed to 1.5 kHz.
001
000
#0150
00001
@SPED(64) When 00001 goes ON, the frequency from port 1 is
changed to 1 kHz.
001
000
#0100
00002
@SPED(64) When 00002 goes ON, the frequency from port 1 is
changed to 500 Hz.
001
000
#0050
27
Pulse Output Function (CQM1 Only) Section 1-3
The following diagram shows the frequency of pulse outputs from port 1 as the
program is executed.
Frequency
1.5 kHz
1.0 kHz
0.5 kHz
Time
! Caution Be sure that the pulse frequency is within the motor’s self-starting frequency
range when starting and stopping the motor.
Note Speed control timing will be very accurate when frequency changes are per-
formed as input interrupt processes.
Example 2: Stopping Pulse The following example shows PULS(65) and SPED(64) used to control a pulse
Output with SPED(64) output from port 1. The frequency is changed by executions of SPED(64) with
different frequency settings and finally stopped with a frequency setting of 0.
05000
@PULS(65) When 05000 goes ON, PULS(65) sets port 1 for CW pulse
output. There is no number of pulses setting.
001
004
000
001
001
#0100
00005
@SPED(64) When 00005 goes ON, the frequency from port 1 is
changed to 1.5 kHz.
001
001
#0150
00006
@SPED(64) When 00006 goes ON, the frequency from port 1 is
changed to 1 kHz.
001
001
#0100
00007
@SPED(64) When 00007 goes ON, the pulse output from port 1 is
stopped with a frequency setting of 0 Hz.
001
001
#0000
28
Pulse Output Function (CQM1 Only) Section 1-3
The following diagram shows the frequency of pulse outputs from port 1 as the
program is executed.
Frequency
1.5 kHz
1.0 kHz
Time
! Caution Be sure that the pulse frequency is within the motor’s self-starting frequency
range when starting and stopping the motor.
Example 3: PLS2(––) The following example shows PLS2(––) used to output 100,000 CW pulses from
port 1. The frequency is accelerated to 10 kHz at approximately 500 Hz/4 ms
and decelerated at the same rate.
Five seconds after the CW pulses have been output, another PLS2(––) instruc-
tion outputs 100,000 CCW pulses with the same settings.
DM 0000 0050
DM 0001 1000
DM 0002 0000
DM 0003 0010
00000
SET 05000 05000 is turned ON when 00000 is ON.
05000
@PLS2(––) When 05000 goes ON, PLS2(––) starts CW pulse output
from port 1.
001
Acceleration rate: Approx. 500 Hz/4 ms
000 Target frequency: 10 kHz
Number of pulses: 100,000
DM 0000
AR 0514
TIM 000 A 5 s timer is started when AR 0514 (the Pulse Output Com-
pleted flag) is ON.
#0050
TIM 000
@PLS2(––) When TIM 000 times out, PLS2(––) starts CCW pulse out-
put from port 1.
001
Acceleration rate: Approx. 500 Hz/4 ms
001 Target frequency: 10 kHz
Number of pulses: 100,000
DM 0000
RSET 05000 05000 is turned OFF when TIM 000 times out.
The following diagram shows the frequency of pulse outputs from port 1 as the
program is executed.
Frequency
CW pulse output CCW pulse output
10 kHz
About 500 Hz/4 ms
Time
29
Pulse Output Function (CQM1 Only) Section 1-3
Example 4: ACC(––) Mode 0 The following example shows mode 0 of ACC(––) used to output 10,000 CW
pulses from port 1. The frequency is accelerated to 10 kHz at approximately
1 kHz/4 ms and decelerated to 1 kHz at approximately 250 Hz/4 ms. Decelera-
tion begins after 9,100 pulses have been output.
00000
@PULS(65) When 00000 goes ON, PULS(65) sets port 1 for CW pulse
output. The total number of pulses is set to 10,000 and the
001 deceleration point is set to 9,100 pulses.
002
DM 0000
The following diagram shows the frequency of pulse outputs from port 1 as the
program is executed.
Frequency
10 kHz
About 250 Hz/4 ms
About 1 kHz/4 ms
1 kHz
Time
Example 5: ACC(––) Mode 1 The following example shows mode 1 of ACC(––) used increase the frequency
of a pulse output from port 1. The frequency is accelerated from 1 kHz to 20 kHz
at approximately 500 Hz/4 ms.
DM 0000 0050
DM 0001 2000
00000
@PULS(65) When 00000 goes ON, PULS(65) sets port 2 for CCW pulse
output. The number of pulses is not set.
002
005
000
002
001
#0100
DM 0000
30
Pulse Output Function (CQM1 Only) Section 1-3
The following diagram shows the frequency of pulse outputs from port 2 as the
program is executed.
Frequency
20 kHz
1 kHz Time
00000 00001
goes ON goes ON
Example 6: ACC(––) Mode 2 The following example shows mode 2 of ACC(––) used decrease the frequency
of a pulse output from port 1. The 2-kHz pulse output is already in progress in
independent mode and stops automatically when the number of pulses is
reached.
DM 0000 0050
DM 0001 0001
00000
@ACC(––) When 00000 goes ON, ACC(––) begins decelerating the
port 1 pulse output at about 500 Hz/4 ms until it reaches the
001 target frequency of 10 Hz.
002
DM 0000
The following diagram shows the frequency of pulse outputs from port 1 as the
program is executed.
Frequency
2 kHz
About 500 Hz/4 ms
1 kHz
Time
Note The pulse output can be stopped by executing ACC(––) mode 2 with a target
frequency of 0, but the pulse output cannot be stopped at the correct number of
pulses, so this method should not be used except for emergency stops.
Example 7: ACC(––) Mode 3 The following example shows mode 3 of ACC(––) used decrease the frequency
of a pulse output from port 1. The 20-kHz pulse output is already in progress in
continuous mode.
DM 0000 0100
DM 0001 0500
00000
@ACC(––) When 00000 goes ON, ACC(––) begins decelerating the
port 1 pulse output at about 1 kHz/4 ms until it reaches the
001 target frequency of 5 kHz.
003
DM 0000
31
Pulse Output Function (CQM1 Only) Section 1-3
The following diagram shows the frequency of pulse outputs from port 1 as the
program is executed.
Frequency
20 kHz
About 1 kHz/4 ms
5 kHz
Time
00000
goes ON
Note Only the CQM1-CPU43-EV1 CPU Unit can output pulses from ports 1 and 2.
PC Setup Settings Before outputting variable-duty-ratio pulses from port 1 or 2, switch the PC to
PROGRAM mode and make the following settings in the PC Setup.
Specify variable-duty-ratio pulse outputs in DM 6643 (port 1) and/or DM 6644
(port 2).
Bit 15 0 Bit 15 0
DM 6643 1 DM 6644 1
Standard pulses cannot be output from a port if it has been set for standard vari-
able-duty-ratio pulse output in DM 6643 or DM 6644.
Starting the Pulse Output Pulses will begin to be output from the specified port when PWM(––) is
executed. Specify port 1 or 2 (P=001 to 002). Set the frequency to 5.9 kHz,
1.5 kHz, or 91.6 Hz (F=000, 001, or 002). Set the duty ratio from 1% to 99%
(D=0001 to 0099, BCD).
Execution condition
@PWM(––)
32
Pulse Output Function (CQM1 Only) Section 1-3
The pulse output will continue with the specified frequency and duty ratio until
PWM(––) is executed again with different settings or INI(61) is executed to stop
pulse outputs from the specified port.
Stopping the Pulse Output The pulse output from a port can be stopped by executing INI(61) with C=003.
Specify port 1 or 2 (P=001 to 002).
Execution condition
@INI(61)
003
000
Example: Using PWM(––) The following example shows PWM(––) used to start a 1.5 kHz pulse output
from port 1 and change the duty ratio from 50% to 25%.The pulse output is then
stopped with INI(61).
Before executing the program make sure that DM 6643 is set to 1000 (variable-
duty-ratio pulse setting for port 1).
00000
@PWM(––) When 00000 goes ON, a 1.5 kHz signal is output from port
1 with a duty ratio of 50%.
001
001
#0050
00001
@PWM(––) When 00001 goes ON, the duty ratio is changed to 25%.
001
001
#0025
00002
@INI(61) When 00002 goes ON, INI(61) stops the pulse output from
port 1.
001
003
000
The following diagram shows the duty ratio of the pulse output from port 1 as the
program is executed.
50% duty ratio pulses 25% duty ratio pulses
33
Pulse Output Function (CQM1 Only) Section 1-3
Executing PRV(62) The status of pulse outputs can be determined by executing PRV(62). Specify
port 1 or 2 (P=001 to 002) and the destination word D. The port status informa-
tion will be written to bits 04 to 07 of D and bits 00 to 03 and 08 to 15 will be set to
0.
When PRV(62) is used to read the port’s status, the most recent information will
be read, so the PC’s cycle time will not be a factor.
Execution condition
@PRV(62)
001
34
Pulse Output Function (CPM1A Only) Section 1-4
Single mode
Specified number off pulses
Stepping motor
Stepping motor
Control input
Motor
controller
Note 1. The CPM1A uses a single-phase pulse output. The control signal for the
direction of rotation (CW/CCW) for the motor driver must be written in the
program.
2. Be sure to use a CPU Unit with transistor outputs.
35
Pulse Output Function (CPM1A Only) Section 1-4
000
003
000
000
000
@PULS(65)
000
000
In N, set the beginning word address of the words where the number of pulses is
set. Store the number of pulses in words N and N+1, in eight digits BCD, with the
leftmost four digits in N+1 and the rightmost four digits in N.
Make the setting within a range of 00000001 to 16777215 (BCD).
36
Pulse Output Function (CPM1A Only) Section 1-4
Beginning Pulse Output With SPED(64), set the bit location for pulse outputs (IR 01000 or IR 01001), the
output mode (independent, continuous), and the pulse frequency to begin the
pulse output.
@SPED(64)
000
003
000
37
CQM1 Interrupt Functions Section 1-5
Interrupt Processing When an interrupt is generated, the specified interrupt processing routine is
executed. Interrupts have the following priority ranking. (Input interrupt 0 has the
highest priority and high-speed counter interrupt 0 has the lowest.)
1, 2, 3... 1. Input interrupt 0 > Input interrupt 1 > Input interrupt 2 > Input interrupt 3
2. High-speed counter interrupt 1 > High-speed counter interrupt 2
3. Interval timer interrupt 0 > Interval timer interrupt 1 > Interval timer interrupt 2
(Interval timer interrupt 2 is high-speed counter interrupt 0.)
When an interrupt with a higher priority is received during interrupt processing,
the current processes will be stopped and the newly received interrupt will be
processed instead. After that routine has been completely executed, then pro-
cessing of the previous interrupt will be resumed.
When an interrupt with a lower or equal priority is received during interrupt pro-
cessing, then the newly received interrupt will be processed as soon as the rou-
tine currently being processed has been completely executed.
Just as with ordinary subroutines, interrupt processing routines are defined us-
ing SBN(92) and RET(93) at the end of the main program.
When interrupt processing routines are executed, a specified range of input bits
can be refreshed.
When an interrupt processing routine is defined, a “no SBS error” will be gener-
ated during the program check but execution will proceed normally. If this error
occurs, check all normal subroutines to be sure that SBS(91) has been pro-
grammed before proceeding.
Pulse Output Instructions With the CQM1-CPU43/44-EV1 CPU Units, the following instructions cannot be
and Interrupts executed in an interrupt subroutine when an instruction that controls pulse I/O or
high-speed counters is being executed in the main program: (25503 turns ON)
INI(61), PRV(62), CTBL(63), SPED(64), PULS(65), PWM(––), PLS2(––)
and ACC(––)
38
CQM1 Interrupt Functions Section 1-5
@INT(89)
100
000
000
@PLS2(––)
001
000
DM 0010
@INT(89)
200
000
000
@PRV(62)
001
002
DM 0000
@CTBL(63)
001
000
DM 0000
RSET LR 0000
SBN(92) 000
25313
@CTBL(63)
001
000
DM 0000
25313
LR
0000
39
CQM1 Interrupt Functions Section 1-5
Processing There are two modes for processing input interrupts. The first is the Input Inter-
rupt Mode, in which the interrupt is carried out in response to an external input.
The second is the Counter Mode, in which signals from an external source are
counted at high speed, and an interrupt is carried out once for every certain num-
ber of signals.
In the Input Interrupt Mode, signals with a length of 100 s or more can be de-
tected. In the Counter Mode, signals up to 1 kHz can be counted.
PC Setup Parameters Before executing the program, make the following settings in the PC Setup in
PROGRAM mode.
Interrupt Input Settings (DM 6628)
If these settings are not made, interrupts cannot be used in the program.
Bit 15 0
DM6628
Input Interrupt Mode Use the following instructions to program input interrupts using the Input Inter-
rupt Mode.
Masking of Interrupts
With the INT(89) instruction, set or clear input interrupt masks as required.
40
CQM1 Interrupt Functions Section 1-5
Counter Mode Use the following steps to program input interrupts using the Input Interrupt
Mode.
Note The SR words used in the Counter Mode (SR 244 to SR 251) all contain binary
(hexadecimal) data (not BCD).
1, 2, 3... 1. Write the set values for counter operation to SR words correspond to inter-
rupts 0 to 3. The set values are written between 0000 and FFFF (0 to
65,535). A value of 0000 will disable the count operation until a new value is
set and step 2, below, is repeated.
Note These SR bits are cleared at the beginning of operation, and must be
written from the program.
That maximum input signal that can be counted is 1 kHz.
Interrupt Word
Input interrupt 0 SR 244
Input interrupt 1 SR 245
Input interrupt 2 SR 246
Input interrupt 3 SR 247
If the Counter Mode is not used, these SR bits can be used as work bits.
2. With the INT(89) instruction, refresh the Counter Mode set value and enable
interrupts.
(@)INT(89) If D bits 0 to 3, which correspond to input interrupts 0 to 3,
003
are set to “0,” then the set value will be refreshed and inter-
rupts will be permitted.
000 0: Counter mode set value refreshed and mask cleared.
D 1: Nothing happens. (Set to 1 the bits for all interrupts
that are not being changed.)
The input interrupt for which the set value is refreshed will be enabled in Counter
Mode. When the counter reaches the set value, an interrupt will occur, the count-
er will be reset, and counting/interrupts will continue until the counter is stopped.
Note 1. If the INT(89) instruction is used during counting, the present value (PV) will
return to the set value (SV). You must, therefore, use the differentiated form
of the instruction or an interrupt may never occur.
41
CQM1 Interrupt Functions Section 1-5
2. The set value will be set when the INT(89) instruction is executed. If inter-
rupts are already in operation, then the set value will not be changed just by
changing the content of SR 244 to SR 247, i.e., if the contents is changed,
the set value must be refreshed by executing the INT(89) instruction again.
Interrupts can be masked using the same process as for the Input Interrupt
Mode, but is masked are cleared using the same process, the Counter Mode will
not be maintained and the Input Interrupt Mode will be used instead. Interrupt
signals received for masked interrupts can also be cleared using the same pro-
cess as for the Input Interrupt Mode.
Counter PV in Counter Mode
When input interrupts are used in Counter Mode, the counter PV will be stored in
the SR word corresponding to input interrupts 0 to 3. Values are 0000 to FFFE (0
to 65,534) and will equal the counter PV minus one.
Interrupt Word
Input interrupt 0 SR 248
Input interrupt 1 SR 249
Input interrupt 2 SR 250
Input interrupt 3 SR 251
Example: The present value for an interrupt whose set value is 000A will be re-
corded as 0009 immediately after INT(89) is executed.
Note Even if input interrupts are not used in Counter Mode, these SR bits cannot be
used as work bits.
42
CQM1 Interrupt Functions Section 1-5
Application Example In this example, input interrupt 0 is used in Input Interrupt Mode and input inter-
rupt 1 is used in Counter Mode. Before executing the program, check to be sure
the PC Setup.
PC Setup: DM 6628: 0011 (IR 00000 and IR 00001 used for input interrupts) The
default settings are used for all other PC Setup parameters. (Inputs are not re-
freshed at the time of interrupt processing.)
00100
(@)INT(89) When IR 00100 turns ON:
001 Masked interrupts for input interrupts 0 and 1 are cleared.
000
#0003
#000E
#000D
BCD (24)
249 The contents of SR 249 (PV – 1) are converted to BCD
D0000 and stored in DM 0000.
INC(38)
The content to DM 0000 is incremented to the PC.
D0000
00100
(@)INT(89)
000
When IR 00100 turns OFF, input interrupts 0 and 1 are
000 masked and interrupts are prohibited.
#000F
SBN(92) 000
25313 (Always ON)
ADB(50)
245
#000A
245
When the Input interrupt is executed for interrupt 0, sub-
routine 000 is called and the counter mode is refreshed
INT(89) with the SV for input interrupt 1 with 10 added (SV = 20)
003
000
#000D
RET(93)
43
CQM1 Interrupt Functions Section 1-5
When the program is executed, operation will be as shown in the following dia-
gram.
00000
Subroutine 000
10 counts 10 counts 20 counts
00001
Subroutine 001
(see note 1) (see note 1)
00100
(see note 2)
Note 1. The counter will continue operating even while the interrupt routine is being
executed.
2. The input interrupt will remained masked.
(@)INT(89)
100
000
000
(@)INT(89)
200
000
000
44
CQM1 Interrupt Functions Section 1-5
Processing There are two modes for interval timer operation, the One-shot Mode, in which
only one interrupt will be executed when time expires, and the Scheduled Inter-
rupt Mode in which the interrupt is repeated at a fixed interval.
PC Setup When using interval timer interrupts, make the following settings in the PC Setup
in PROGRAM mode before executing the program.
Input Refresh Word Settings (DM 6636 to DM 6638)
Make these settings when it is necessary to refresh inputs.
Bit 15 0
45
CQM1 Interrupt Functions Section 1-5
The meanings of the settings are the same as for the one-shot mode, but in the
scheduled interrupt mode the timer PV will be reset to the set value and decre-
menting will begin again after the subroutine has been called. In the scheduled
interrupt mode, interrupts will continue to be repeated at fixed intervals until the
operation is stopped.
Note CQM1-CPU11-E/CPU21-E support subroutine numbers 0000 to 0127 only.
Reading the Timer’s Elapsed Time
Use the STIM(69) instruction to read the timer’s elapsed time.
C2: Number of times the decrementing counter has ben decremented (4 digits
BCD)
C2 + 1: Decrementing counter time interval (4 digits BCD; unit: 0.1 ms)
C3: Elapsed time from previous decrement (4 digits BCD; unit: 0.1 ms)
The time from when the interval timer is started until the execution of this instruc-
tion is calculated as follows:
{(Contents of word C2) x (Contents of word C2 + 1) + (Contents of word C3)} x 0.1 ms
If the specified interval timer is stopped, then “0000” will be stored.
Stopping Timers
Use the STIM(69) instruction to stop the interval timer.
(@)STIM(69)
C1
C1: Interval timer no. + 10
000 Interval timer 0: 010
000 Interval timer 1: 011
Interval timer 2: 012
46
CQM1 Interrupt Functions Section 1-5
Application Example In this example, an interrupt is executed every 2.4 ms (0.6 ms x 4) by means of
interval timer 1. Assume the default settings for all of the PC Setup. (Inputs are
not refreshed for interrupt processing.)
#0023
00100
@STIM(69) Interval timer 1 stops when IR 00100 turns
011 OFF.
000
000
SBN(92) 023
Every 2.4 ms the count is reached for interval
timer 1, and subroutine 023 is called.
RET(93)
When the program is executed, subroutine 023 will be executed every 2.4 ms
while IR 00100 is ON.
IR 00100
2.4 ms 2.4 ms 2.4 ms
Subroutine 023
Processing
Input Signal Types and Two types of signals can be input from a pulse encoder. The count mode used for
Count Modes high-speed counter 0 will depend on the signal type.
Up/Down Mode: A phase-difference 4X two-phase signal (A-phase and B-
phase) and a Z-phase signal are used for inputs. The
count is incremented or decremented according to differ-
ences in the 2-phase signals.
47
CQM1 Interrupt Functions Section 1-5
Incrementing mode: One single-phase pulse signal and a count reset signal
are used for inputs. The count is incremented according to
the single-phase signal.
Incrementing Mode
Up/Down Mode
A-phase Pulse
input
B-phase
Count 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0 –1 –2 Count 1 2 3 4
Note One of the methods in the following section should always be used to reset the
counter when restarting it. The counter will be automatically reset when program
execution is started or stopped.
The following signal transitions are handled as forward (incrementing) pulses:
A-phase leading edge to B-phase leading edge to A-phase trailing edge to B-
phase trailing edge. The following signal transitions are handled as reverse
(decrementing) pulses: B-phase leading edge to A-phase leading edge to B-
phase trailing edge to A-phase trailing edge.
The count range is from –32,767 to 32,767 for Up/Down Mode, and from 0 to
65,535 for Incrementing Mode. Pulse signals can be counted at up to 2.5 kHz in
Up/Down Mode, and up to 5.0 kHz in Incrementing Mode.
The Up/Down Mode always uses a 4X phase-difference input. The number of
counts for each encoder revolution would be 4 times the resolution of the count-
er. Select the encoder based on the countable ranges.
Reset Methods
Either of the two methods described below may be selected for resetting the PV
of the count (i.e., setting it to 0).
Z-phase signal + software reset: The PV is reset when the Z-phase signal (re-
set input) turns ON after the High-speed
Counter 0 Reset Bit (SR 25200) is turned
ON.
Software reset: The PV is reset when the High-speed Counter 0 Reset Bit
(SR 25200) is turned ON.
Z-phase signal + software reset Software reset
1 or more cycles
SR25200 SR25200
1 or more cycles Within 1 cycle Within 1 cycle
Reset by interrupt. Reset by cycle. Not reset. Reset by cycle.
Note The High-speed Counter 0 Reset Bit (SR 25200) is refreshed once every cycle,
so in order for it to be read reliably it must be ON for at least one cycle.
The “Z” in “Z-phase” is an abbreviation for “Zero.” It is a signal that shows that the
encoder has completed one cycle.
48
CQM1 Interrupt Functions Section 1-5
Count
Interrupts
Comparison Table
Target value 1
Target value 2
Target value 3
Target value 4
Target value 5
Initial value
Target value
1 2 3 4 5
Range Comparisons The current count is compared in cyclic fashion to all of the ranges at the same
time and interrupts are generated based on the results of the comparisons.
Comparison Table
0 Rage setting 1
Count Rage setting 2
Rage setting 3
1 3 Rage setting 4
2 4
Note When performing target value comparisons, do not repeatedly use the INI in-
struction to change the current value of the count and start the comparison op-
eration. The interrupt operation may not work correctly if the comparison opera-
tion is started immediately after changing the current value from the program.
(The comparison operation will automatically return to the first target value once
an interrupt has been generated for the last target value. Repetitious operation
is thus possible merely by changing the current value.)
Wiring Depending on the count mode, the input signals from the pulse encoder to the
CPU Unit’s input terminal are as shown below.
49
CQM1 Interrupt Functions Section 1-5
Changes in the setting in DM 6642 are effective only when power is turned on or
PC program execution is started.
Programming Use the following steps to program high-speed counter 0.
High-speed counter 0 begins the counting operation when the proper PC Setup
settings are made, but comparisons will not be made with the comparison table
and interrupts will not be generated unless the CTBL(63) instruction is executed.
High-speed counter 0 is reset to “0” when power is turned ON and when opera-
tion begins.
The present value of high-speed counter 0 is maintained in SR 230 and SR 231.
Controlling High-speed Counter 0 Interrupts
1, 2, 3... 1. Use the CTBL(63) instruction to save the comparison table in the CQM1 and
begin comparisons.
(@)CTBL(63)
P C: (3 digits BCD)
000: Target table set and comparison begun
C
001: Range table set and comparison begun
TB 002: Target table set only
003: Range table set only
TB: Beginning word of comparison table
50
CQM1 Interrupt Functions Section 1-5
If C is set to 000, then comparisons will be made by the target matching method;
if 001, then they will be made by the range comparison method. The comparison
table will be saved, and, when the save operation is complete, then comparisons
will begin. While comparisons are being executed, high-speed interrupts will be
executed according to the comparison table. For details on the contents of the
comparison tables that are saved, refer to the explanation of the CTBL(63)
instruction in Section 5 Instruction Set.
Note The comparison results are normally stored in AR 1100 through AR 1107 while
the range comparison is being executed.
If C is set to 002, then comparisons will be made by the target matching method;
if 003, then they will be made by the range comparison method. For either of
these settings, the comparison table will be saved, but comparisons will not be-
gin, and the INI(61) instruction must be used to begin comparisons.
2. To stop comparisons, execute the INI(61) instruction as shown below.
(@)INI(61)
000
001
000
To start comparisons again, set the second operand to “000” (execute compari-
son), and execute the INI(61) instruction.
Once a table has been saved, it will be retained in the CQM1 during operation
(i.e., during program execution) as long as no other table is saved.
Reading the PV
There are two ways to read the PV. The first is to read it from SR 230 and SR 231,
and the second to use the PRV(62) instruction.
Reading SR 230 and SR 231
The PV of high-speed counter 0 is stored in SR 230 and SR 231 as shown below.
The leftmost bit will be F for negative values.
Leftmost 4 digits Rightmost 4 digits Up/Down Mode Incrementing Mode
Note These words are refreshed only once every cycle, so there may be a difference
from the actual PV.
When high-speed counter 0 is not being used, the bits in these words can be
used as work bits.
Using the PRV(62) Instruction
Read the PV of high-speed counter 0 by using the PRV(62) instruction.
(@)PRV(62)
P1: Leading word of PV
000
000
P1
The PV of high-speed counter 0 is stored as shown below. The leftmost bit will be
F for negative values.
Leftmost 4 digits Rightmost 4 digits Up/Down Mode Incrementing Mode
51
CQM1 Interrupt Functions Section 1-5
Changing the PV
There are two ways to change the PV of high-speed counter 0. The first way is to
reset it by using the reset methods. (In this case the PV is reset to 0.) The second
way is to use the INI(61) instruction.
The method using the INI(61) instruction is explained here. For an explanation of
the reset method, refer to the beginning of this description of high-speed counter
0.
Change the timer PV by using the INI(61) instruction as shown below.
52
CQM1 Interrupt Functions Section 1-5
DM 0000
SPED(64)
020
Begins continuous pulse output to IR10002 at 500 Hz.
001
#0050
SBN(92) 101
25313 (Always ON)
SPED(64)
020 When the high-speed counter value reaches 1000, subroutine
101 is called and the frequency of the pulse output is changed to
001
200 Hz.
#0020
RET(93)
SBN(92) 102
25313 (Always ON)
SPED(64)
When the high-speed counter value reaches 2000, subroutine 102
020
is called and the pulse output is stopped by setting the frequency
001 to 0.
#0000
RET(93)
500
200
53
CQM1 Interrupt Functions Section 1-5
Note 1. The values given above are theoretical and assume a reasonably short
cycle time. The values will actually be those that existed one cycle before the
overflow/underflow existed.
2. The 6th and 7th digits of high-speed counter 0’s PV are normally 00, but can
be used as “Overflow/Underflow Flags” by detecting values beyond the al-
lowable counting ranges.
High-speed counter 0 can be reset as described in the previous section or it can
be reset automatically by restarting program execution. High-speed counter 0
and related operations will not function normally until the overflow/underflow
status is cleared. Operations during overflow/underflow status will be as follows.
• Comparison table operation will stop.
• The comparison table will not be cleared.
• Interrupt routines for the high-speed counter will not be executed.
• CTBL(63) can be used only to register the comparison table. If an attempt is
made to start comparison table operation, operation will not start and the com-
parison table will not be registered.
• INI(61) cannot be used to start or stop comparison table operation or to change
the present value.
• PRV(62) will read out only 0FFF FFFF or FFFF FFFF as the present value.
Note The range comparison results in AR 11 will remain after recovery. The interrupt
routine for a interrupt condition meet immediately after recovery will not be
executed if the interrupt condition was already met before the overflow/under-
flow status occurred. If interrupt routine execution is necessary, clear AR 11 be-
fore proceeding.
Reset Operation When high-speed counter 0 is reset, the PV will be set to 0, counting will begin
from 0, and the comparison table, execution status, and execution results will be
maintained.
Startup Counter Status When high-speed counter 0 is started, the counter mode in the PC Setup will be
read and used, the PV will be set to 0, overflow/underflow status will be cleared,
the comparison table registration and execution status will be cleared, and
range execution results will be cleared. (Range execution results are always
cleared when operation is begun or when the comparison table is registered.)
Stopped Counter Status When high-speed counter 0 is stopped, the PV will be maintained, the compari-
son table registration and execution status will be cleared, and range execution
results will be maintained.
54
CQM1 Interrupt Functions Section 1-5
Counting Modes
The counting modes (ring mode or linear mode) for high-speed counters 1 and 2
are specified in DM 6643 and DM 6644 respectively.
1, 2, 3... 1. Ring Mode:
In ring mode, the maximum count value +1 is set in CTBL(63). The counter
will go from the maximum count value to 0 when incrementing, and from 0 to
the maximum count value when decrementing. There are no negative val-
ues.
55
CQM1 Interrupt Functions Section 1-5
The number of points on the ring (maximum count value +1) can be set from
1 to 65,000.
2. Linear Mode:
The counting range in linear mode is –8,388,607 to 8,388,607. If the allow-
able counting range for high-speed counter 1 or 2 is exceeded, an underflow
or overflow status will occur and the counter’s PV will remain at 0838 8607
for overflows and F838 8607 for underflows, counting or comparison will be
stopped, and AR 0509 (port 1) or AR 0609 (port 2) will be turned ON.
Ring Mode Linear Mode
–8.388,607 0 8.388,607
Decrement Increment
Underflow Overflow
Note 1. One of the methods in the following section should always be used to reset
the counter when restarting it. The counter will be automatically reset when
program execution is started or stopped.
2. The following signal transitions are handled as forward (incrementing)
pulses: A-phase leading edge to B-phase leading edge to A-phase trailing
edge to B-phase trailing edge. The following signal transitions are handled
as reverse (decrementing) pulses: B-phase leading edge to A-phase lead-
ing edge to B-phase trailing edge to A-phase trailing edge.
Reset Methods
Either the Z-phase signal + software reset or software reset may be selected for
resetting the PV of the count (i.e., setting it to 0). These resets operate the same
as they do for high-speed counter 0. Refer to page 48 for details.
Note 1. The reset bits for high-speed counters 1 and 2 (SR 25201 and SR 25202)
are refreshed once every cycle. Make sure that a reset bit is ON for at least
one full cycle so it can be read reliably.
2. The comparison table, execution status, and range comparison results will
be retained through a reset. (A comparison will be continued after a reset is
performed.)
High-speed Counter Interrupt Count
The comparison tables used for high-speed counters 1 and 2 are just like the one
used for high-speed counter 0. Refer to page 49 for details.
PC Setup When using high-speed counter 1 and/or 2 interrupts, make the settings in PRO-
GRAM mode shown below before executing the program.
Port 1 and 2 Mode Setting (DM 6611)
Specify high-speed counter mode for ports 1 and 2. If high-speed counter mode
is not specified, CTBL(63) cannot be used to make count comparisons.
This setting is read when the PC is turned ON. If it is changed, the PC must be
turned off and then on again before executing the program.
Bit 15 0
DM 6611 0 0 0 0
56
CQM1 Interrupt Functions Section 1-5
Note If DM 6611 is set to pulse output mode, another comparison instruction such as
BCMP(68) can be used to compare the PV of high-speed counters 1 and 2.
Input Refresh Word Settings (DM 6634 and DM 6635)
DM 6634 contains the input refresh word settings for high-speed counter 1, and
DM 6635 contains the settings for high-speed counter 2. Make these settings
when it is necessary to refresh inputs.
Bit 15 0
DM 6634/DM 6635
Counting mode
0: Linear mode
1: Ring mode
Reset method
0: Z-phase and software reset
1: Software reset
Count mode
0: Differential Phase Mode
1: Pulse/Direction Mode
2: Up/Down Mode
Defaults: Linear Mode, Z-phase and software reset, Differential Phase Mode
(@)CTBL(63)
P P: Port
001: Port 1
C
002: Port 2
TB
C: (3 digits BCD)
000: Target table set and comparison begun
001: Range table set and comparison begun
002: Target table set only
003: Range table set only
TB: Beginning word of comparison table
57
CQM1 Interrupt Functions Section 1-5
(@)INI(61)
P
001
000
To start comparisons again, set the second operand to “000” (execute com-
parison), and execute the INI(61) instruction.
Once a table has been saved, it will be retained in the CQM1 during opera-
tion (i.e., during program execution) as long as no other table is saved.
Reading the PV
There are two ways to read the PV. The first is to read it from SR 232 and SR 233
(port 1) or SR 234 and SR 235 (port 2), and the second is to use PRV(62).
Reading SR 232 and SR 233 or SR 234 and SR 235
The PV of high-speed counter 1 is stored in SR 232 and SR 233, and the PV of
high-speed counter 2 is stored in SR 234 and SR 235 as shown below. In linear
mode, the leftmost digit will be F for negative values.
Leftmost 4 digits Rightmost 4 digits Linear Mode Ring Mode
Note These words are refreshed only once every cycle, so there may be a difference
from the actual PV.
Using the PRV(62) Instruction
Read the PV of high-speed counter 0 by using the PRV(62) instruction. Specify
high-speed counter 1 or 2 in P (P=001 or 002).
(@)PRV(62)
P: Port (001: port 1; 002: port 2)
P
P1: Leading word of PV
000
P1
58
CQM1 Interrupt Functions Section 1-5
001
59
CQM1 Interrupt Functions Section 1-5
Operation Example This example shows a program that outputs standard pulses from port 1 while
counting those pulses with high-speed counter 1. The high-speed counter oper-
ates in Up/Down Mode, with the pulse output’s CW pulses incrementing the
counter (B-phase input) and the CCW pulses decrementing the counter (A-
phase input). Before executing the program, set the PC Setup as follows and
restart the PC.
DM 6611: 0000 (High-speed counter mode).
DM 6643: 0002 (Port 1: Standard pulse output, linear counting mode, Z-phase
signal with software reset, and Up/Down Mode).
Other PC Setup settings use the default settings. (Inputs are not refreshed at the
time of interrupt processing.)
60
CQM1 Interrupt Functions Section 1-5
00000
@CTBL(63) Specifies port 1, saves the comparison
001 table in target matching format, and be-
gins comparing.
000
DM 0000
000
#0001
SBN(92) 100
RET(93)
SBN(92) 101
RET(93)
SBN(92) 102
25313 (Always ON)
SPED(64) Pulse output from port 1 is stopped by set-
001 ting the frequency to 0.
001
#0000
RET(93)
61
CQM1 Interrupt Functions Section 1-5
PC Setup When using absolute high-speed counter 1 and/or 2 interrupts, make the set-
tings in PROGRAM mode shown below before executing the program.
Input Refresh Word Settings (DM 6634 and DM 6635)
DM 6634 contains the input refresh word settings for absolute high-speed count-
er 1, and DM 6635 contains the settings for absolute high-speed counter 2.
Make these settings when it is necessary to refresh inputs.
Bit 15 0
DM 6634/DM 6635
62
CQM1 Interrupt Functions Section 1-5
Bit 15 0
DM6643/DM 6644
Count mode:
00: BCD mode
01: 360° mode
Resolution setting:
00: 8-bit
01: 10-bit
02: 12-bit
Origin Compensation It is possible to compensate for an offset between an absolute rotary encoder’s
origin and the actual origin. This adjustment can be made separately for ports 1
and 2.
Follow the procedure below to set origin compensation. After origin compensa-
tion has been set, the data from the encoder will be adjusted before being output
as the PV.
1, 2, 3... 1. Set the absolute rotary encoder to the desired origin location.
2. Make sure that pin 1 of the CPU Unit’s DIP switch is OFF (enabling Peripher-
al Devices to overwrite DM 6614 through DM 6655) and switch the PC to
PROGRAM mode.
3. Set the resolution setting in DM 6643 or DM 6644.
4. Make sure that a fatal error or FALS 9C error have not occurred.
5. Read the high-speed counter’s PV from IR 232 and IR 233 (port 1) or IR 234
and IR 235 (port 2) to determine the PV before origin compensation.
6. Turn ON the Port 1 Origin Compensation flag (SR 25201) or Port 2 Origin
Compensation flag (SR 25202) from a Peripheral Device.
The compensation value will be written to DM 6611 (port 1) or DM 6612
(port 2) and the Origin Compensation flag will be turned OFF automatically.
The compensation value will be recorded in BCD between 0000 and 4095
whether the counter is set to BCD mode or 360° mode.
7. Read the high-speed counter’s PV to determine the PV after origin com-
pensation. The PV should be 0000 after origin compensation.
The compensation value will be valid until it is changed again by the procedure
above.
Programming Use the following steps to program absolute high-speed counters 1 and 2.
Absolute high-speed counters 1 and 2 begin counting when the proper PC Setup
settings are made, but comparisons will not be made with the comparison table
and interrupts will not be generated unless the CTBL(63) instruction is executed.
The present value of absolute high-speed counter 1 is maintained in IR 232 and
IR 233 and the present value of absolute high-speed counter 2 is maintained in
IR 234 and IR 235.
63
CQM1 Interrupt Functions Section 1-5
(@)INI(61)
P
001
000
To start comparisons again, set the second operand to “000” (execute com-
parison), and execute the INI(61) instruction.
Once a table has been saved, it will be retained in the CQM1 during opera-
tion (i.e., during program execution) as long as no other table is saved.
Reading the PV
There are two ways to read the PV. The first is to read it from IR 232 and IR 233
(port 1) or IR 234 and IR 235 (port 2), and the second is to use PRV(62).
Reading IR 232 and IR 233 or IR 234 and IR 235
The PV of absolute high-speed counter 1 is stored in IR 232 and IR 233, and the
PV of absolute high-speed counter 2 is stored in IR 234 and IR 235 as shown
below.
Leftmost 4 digits Rightmost 4 digits BCD Mode 360 Mode
Note These words are refreshed only once every cycle, so there may be a difference
from the actual PV.
64
CQM1 Interrupt Functions Section 1-5
(@)PRV(62)
P: Port (001: port 1; 002: port 2)
P
P1: Leading word of PV
000
P1
Reading Absolute The status of absolute high-speed counters 1 and 2 can be determined either by
High-speed Counter Status reading the status of the relevant flags in the AR area or executing PRV(62).
The following table shows the relevant AR area flags and their functions.
The comparison flag status of absolute high-speed counters 1 and 2 can also be
determined by executing PRV(62). Specify absolute high-speed counter 1 or 2
(P=001 to 002) and the destination word D. The flag status (0: Stopped;
1: Comparing) will be written to bit 00 of D. Bits 01 to 15 will be set to 0.
Execution condition
@PRV(62)
001
Operation Example This example shows a program that receives an input signal from an absolute
rotary encoder at port 1 and uses this input to control outputs IR 10000 through
IR 10003. Absolute high-speed counter 1 is set for 8-bit resolution and 360°
Mode, and range comparisons are used. Before executing the program, set
DM 6643 to 0100 (Port 1: 360° Mode, 8-bit resolution).
Other PC Setup settings use the default settings. (Inputs are not refreshed at the
time of interrupt processing.)
In addition, the following data is stored for the comparison table:
65
CQM1 Interrupt Functions Section 1-5
DM 0000
SBN(92) 100
25313 (Always ON)
MOV(21) Turns ON 10000. Turns other bits in
#0001 IR 100 OFF.
100
RET(93)
SBN(92) 101
25313 (Always ON)
MOV(21) Turns ON 10001. Turns other bits in
#0002 IR 100 OFF.
100
RET(93)
SBN(92) 102
25313 (Always ON)
MOV(21) Turns ON 10002. Turns other bits in
#0004 IR 100 OFF.
100
RET(93)
SBN(92) 103
25313 (Always ON)
MOV(21) Turns ON 10003. Turns other bits in
#0008 IR 100 OFF.
100
RET(93)
66
CPM1/CPM1A Interrupt Functions Section 1-6
AR 0500
AR 0501
AR 0502
AR 0503
AR 0504 to AR 0507
67
CPM1/CPM1A Interrupt Functions Section 1-6
@INT(89)
100
000
000
INI(61)
000
000
000
@INT(89)
200
000
000
Method 2
Execute the instruction again in the main program.
1, 2, 3... 1. This is the program section from the main program:
@PRV(62)
000
002
DM 0000
LR 0000
CTBL(63)
000
000
DM 0000
RSET LR 0000
SBN(92) 000
25313
@CTBL(63)
000
000
DM 0000
25313
LR
0000
68
CPM1/CPM1A Interrupt Functions Section 1-6
Note 1. Define interrupt routines at the end of the main program with SBN(92) and
RET(93) instructions, just like regular subroutines.
2. When defining an interrupt routine, a “SBS UNDEFD” error will occur during
the program check operation, but the program will be executed normally.
CPM1 PCs
00003
00004
00005
00006
00003
00004
NC
24VDC
CPM1A PCs
Note If input interrupts are not used, use inputs 00003 to 00006 as regular inputs.
69
CPM1/CPM1A Interrupt Functions Section 1-6
Input Interrupt Settings Inputs 00003 to 00006 must be set as interrupt inputs in DM 6628 if they are to
be used for input interrupts in the CPM1/CPM1A. Set the corresponding digit to 1
if the input is to be used as an interrupt input (input interrupt or counter mode);
set it to 0 if it is to be used as a regular input.
Word Setting
DM 6628 0: Regular input (default setting)
1: Interrupt input
2: Quick-response input
Bit 15 0
DM 6628
Interrupt Subroutines Interrupts from inputs 00003 to 00006 are allocated interrupt numbers 00 to 03
and call subroutines 000 to 003. If the input interrupts aren’t being used, subrou-
tines 000 to 003 can be used in regular subroutines.
Input number Interrupt number Subroutine number
00003 0 000
00004 1 001
00005 2 002
00006 3 003
Input Refreshing If input refreshing is not used, input signal status within the interrupt routine will
not be reliable. Depending on the input time constant, the input signals might not
go ON even if input refreshing is used. This includes the status of the interrupt
input bit that activated the interrupt.
For example, IR 00000 would not be ON in interrupt routine for input interrupt 0
unless it was refreshed. In this case, use the Always ON Flag, SR 25313 in the
interrupt routine instead of IR 00000.
Input Interrupt Mode When an input interrupt signal is received, the main program is interrupted and
the interrupt program is executed immediately, regardless of the point in the
cycle in which the interrupt is received. The signal must be ON for 200 µs or more
to be detected.
Interrupt program
Input interrupt
Use the following instructions to program input interrupts using the Input Inter-
rupt Mode.
Masking/Unmasking of Interrupts
With the INT(89) instruction, set or clear input interrupt masks as required.
70
CPM1/CPM1A Interrupt Functions Section 1-6
All of the input interrupts are masked when PC operation is started. If input inter-
rupt mode is being used, be sure to enable the inputs by executing INT(89) as
shown above.
Clearing Masked Interrupts
If the bit corresponding to an input interrupt turns ON while masked, that input
interrupt will be saved in memory and will be executed as soon as the mask is
cleared. In order for that input interrupt not to be executed when the mask is
cleared, the interrupt must be cleared from memory.
Only one interrupt signal will be saved in memory for each interrupt number.
With the INT(89) instruction, clear the input interrupt from memory.
(@)INT(89) The status of the rightmost digit of the data stored in word D (bits
002 0 to 3) show the mask status.
0: Mask cleared. (Input interrupt enabled.)
000
1: Mask set. (Input interrupt disabled.)
D
Program Example
When input 00003 (interrupt no. 0) goes ON, operation moves immediately to
the interrupt program with subroutine number 000. Inputs for DM 6628 have
been set to 0001.
SBN(92) 000
Interrupt program
RET(93)
Counter Mode External signal inputs are counted at high speed and an interrupt is generated
when the count reaches the set value. When an interrupt is generated, the main
program is interrupted and the interrupt program is executed. Signals up to
1 kHz can be counted.
Interrupt program
Input interrupt
Set value
71
CPM1/CPM1A Interrupt Functions Section 1-6
Use the following steps to program input interrupts using the Counter Mode.
1, 2, 3... 1. Write the set values for counter operation to the SR words shown in the fol-
lowing table. The set values are written between 0000 and FFFF (0 to
65,535). A value of 0000 will disable the count operation until a new value is
set and step 2, below, is repeated.
Interrupt Word
Input interrupt 0 SR 240
Input interrupt 1 SR 241
Input interrupt 2 SR 242
Input interrupt 3 SR 243
The SR words used in the Counter Mode (SR 240 to SR 243) contain hexa-
decimal data, not BCD. If the Counter Mode is not used, these words can be
used as work bits.
Note These SR words are cleared at the beginning of operation, and must
be written from the program.
2. With the INT(89) instruction, refresh the Counter Mode set value and enable
interrupts.
(@)INT(89) If D bits 0 to 3, which correspond to input interrupts 0 to 3,
003
are set to “0,” then the set value will be refreshed and inter-
rupts will be permitted.
000 0: Counter mode set value refreshed and mask cleared.
D 1: Not refreshed.
Be sure to set the corresponding bit to 1 if an input interrupt isn’t being con-
trolled.
The input interrupt for which the set value is refreshed will be enabled in Counter
Mode. When the counter reaches the set value, an interrupt will occur, the count-
er will be reset, and counting/interrupts will continue until the counter is stopped.
Note 1. If the INT(89) instruction is used during counting, the present value (PV) will
return to the set value (SV). You must, therefore, use the differentiated form
of the instruction or an interrupt may never occur.
2. The set value will be set when the INT(89) instruction is executed. If inter-
rupts are already in operation, then the set value will not be changed just by
changing the content of SR 240 to SR 243, i.e., if the contents are changed,
the set value must be refreshed by executing the INT(89) instruction again.
Interrupts can be masked using the same process used with the Input Interrupt
Mode, but if the masked interrupts are cleared using the same process, the inter-
rupts will operate in Input Interrupt Mode, not Counter Mode.
Interrupt signals received for masked interrupts can also be cleared using the
same process as for the Input Interrupt Mode.
Counter PV in Counter Mode
When input interrupts are used in Counter Mode, the counter PV will be stored in
the SR word corresponding to input interrupts 0 to 3. Values are 0000 to FFFE (0
to 65,534) and will equal the counter PV minus one.
Interrupt Word
Input interrupt 0 SR 244
Input interrupt 1 SR 245
Input interrupt 2 SR 246
Input interrupt 3 SR 247
Example: The present value for an interrupt whose set value is 000A will be re-
corded as 0009 immediately after INT(89) is executed.
Note Even if input interrupts are not used in Counter Mode, these SR bits cannot be
used as work bits.
72
CPM1/CPM1A Interrupt Functions Section 1-6
Program Example
When input 00003 (interrupt no. 0) goes ON 10 times, operation moves immedi-
ately to the interrupt program with subroutine number 000. The following table
shows where the counters‘ set values and present values –1 are stored. Inputs
for DM 6628 have been set to 0001.
Interrupt Word containing Word containing
SV PV–1
Input 00003 (input interrupt 0) SR 240 SR 244
Input 00004 (input interrupt 1) SR 241 SR 245
Input 00005 (input interrupt 2) SR 242 SR 246
Input 00006 (input interrupt 3) SR 243 SR 247
@INT(89)
003 Refresh counter SVs.
000
SBN(92) 000
Interrupt program
RET(93)
(@)INT(89)
100
000
000
73
CPM1/CPM1A Interrupt Functions Section 1-6
000
74
CPM1/CPM1A Interrupt Functions Section 1-6
(@)STIM(69)
C1: Read elapsed time (006)
C1
C2: Leading word of parameter 1
C2
C3: Parameter 2
C3
C2: Number of times the decrementing counter has ben decremented (4 digits
BCD)
C2 + 1: Decrementing counter time interval (4 digits BCD; unit: 0.1 ms)
C3: Elapsed time from previous decrement (4 digits BCD; unit: 0.1 ms)
The time from when the interval timer is started until the execution of this instruc-
tion is calculated as follows:
{(Content of C2) × (Content of C2+1) + (Content of C3)} × 0.1 ms
If the specified interval timer is stopped, then “0000” will be stored.
Stopping the Timer
Use the STIM(69) instruction to stop the interval timer. The interval timer will be
stopped.
(@)STIM(69)
C1
C1: Stop interval timer (010)
000
000
Application Example In this example, an interrupt is generated 2.4 ms (0.6 ms × 4) after input 00005
(One-shot Mode) goes ON; the interrupt executes interrupt subroutine number 23.
MOV(21)
#0006 Sets the decrementing time interval to 0.6 ms.
DM 0011 (BCD: 0005 to 0320)
00005
@STIM(69)
000 Starts the interval timer in one-shot mode.
DM 0010 Specifies the first word containing the set value.
#0023 Specifies the subroutine number (23).
SBN(92) 023
Interrupt program
RET(93)
75
CPM1/CPM1A Interrupt Functions Section 1-6
Application Example In this example, an interrupt is generated every 4.0 ms (1.0 ms × 4) after input
(Scheduled Interrupt Mode) 00005 goes ON; the interrupts execute interrupt subroutine number 23.
MOV(21)
#0010 Sets the decrementing time interval to 1.0 ms.
DM 0011 (BCD: 0005 to 0320)
00005
@STIM(69)
003 Starts the interval timer in scheduled interrupt mode.
DM 0010 Specifies the first word containing the set value.
#0023 Specifies the subroutine number (23).
SBN(92) 023
Interrupt program
RET(93)
CPM1 PCs
00000
00001
00002
NC
24VDC
CPM1A PCs
76
CPM1/CPM1A Interrupt Functions Section 1-6
Note In incrementing mode, input 00001 can be used as a regular input. When the
reset method is used for the software reset, input 00002 can be used as a regular
input. Also, even when used for the Z-phase signal and software reset, the input
status is reflected inn 00002 of the I/O memory.
High-speed Counter Settings The following settings must be made in DM 6642 when using the
CPM1/CPM1A’s high-speed counter function.
DM 6642 Function Settings
Bits Incrementing Up/Down Not used
00 to 03 Sets the counter mode: 4 0 0 or 4
0: Up/down
4: Incrementing
04 to 07 Sets the reset method: 0 or 1 0 or 1 0 or 1
0: Z-phase + software reset
1: Software reset
08 to 15 Sets the counter: 01 01 00
00: Counter not being used.
01: Counter being used.
Count Range The CPM1/CPM1A’s high-speed counter uses linear operation and the count
(present value) is stored in SR 248 and SR 249. (The upper four digits are stored
in SR 249 and the lower four digits are stored in SR 248.)
Mode Count range
Up/Down F003 2767 to 0003 2767 (–32,767 to 32,767)
The leftmost digit in SR 248 indicates the sign. F is negative, 0 is
positive.
Incrementing 0000 0000 to 0006 5535 (0 to 65,535)
An overflow will occur if the count exceeds the upper limit in the count range and
an underflow will occur if the count goes below the lower limit in the count range.
Error Incrementing Up/Down Present
value
Overflow Occurs when the count is Occurs when the count is 0FFF FFFF
incremented from 65,535. incremented from 32,767.
Underflow --- Occurs when the count is FFFF FFFF
decremented from –32,767.
Processing Two types of signals can be input from a pulse encoder. The count mode used for
the high-speed counter will depend on the signal type. The count mode and re-
set mode are set in DM 6642; these settings become effective when the power is
turned on or PC operation is started.
Up/Down Mode:
A phase-difference 4× two-phase signal (A-phase and B-phase) and a Z-
phase signal are used for inputs. The count is incremented or decremented
according to differences in the 2-phase signals.
77
CPM1/CPM1A Interrupt Functions Section 1-6
Incrementing Mode:
One single-phase pulse signal and a count reset signal are used for inputs.
The count is incremented according to the single-phase signal.
B-phase
Count 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0 –1 –2 Count 1 2 3 4
Note One of the reset methods described below should always be used to reset the
counter when restarting it. The counter will be automatically reset when program
execution is started or stopped.
25200
78
CPM1/CPM1A Interrupt Functions Section 1-6
Note The High-speed Counter Reset Bit (SR 25200) is refreshed once every cycle, so
in order for it to be read reliably it must be ON for at least one cycle.
The “Z” in “Z-phase” is an abbreviation for “Zero.” It is a signal that shows that the
encoder has completed one cycle.
High-speed Counter Interrupt Count
For high-speed counter 0 interrupts, a comparison table is used instead of a
“count up.” The count check can be carried out by either of the two methods de-
scribed below. In the comparison table, comparison conditions (for comparing to
the PV) and interrupt routine combinations are saved.
Target value:
A maximum of 16 comparison conditions (target values and count direc-
tions) and interrupt routine combinations are saved in the comparison table.
When the counter PV and the count direction match the comparison condi-
tions, then the specified interrupt routine is executed.
Range (zone) comparison:
Eight comparison conditions (upper and lower limits) and interrupt routine
combinations are saved in the comparison table. When the PV is greater
than or equal to the lower limit and less than or equal to the upper limit, then
the specified interrupt routine is executed.
Target Value The current count is compared to the target values in the order that target values
Comparisons are set in the comparison table and interrupts are generated as the count equals
each target value. Once the count has equaled all of the target values in the
table, the target value is set to the first target value in the table, which is again
compared to the current counted until the two values are equal.
Count
Interrupts
Comparison Table
Target value 1
Target value 2
Target value 3
Target value 4
Target value 5
Initial value
Target value
1 2 3 4 5
Range Comparisons The current count is compared in cyclic fashion to all of the ranges at the same
time and interrupts are generated based on the results of the comparisons.
79
CPM1/CPM1A Interrupt Functions Section 1-6
Comparison Table
0 Rage setting 1
Count Rage setting 2
Rage setting 3
1 3 Rage setting 4
2 4
Note When performing target value comparisons, do not repeatedly use the INI in-
struction to change the current value of the count and start the comparison op-
eration. The interrupt operation may not work correctly if the comparison opera-
tion is started immediately after changing the current value from the program.
(The comparison operation will automatically return to the first target value once
an interrupt has been generated for the last target value. Repetitious operation
is thus possible merely by changing the current value.)
(@)CTBL(63)
P C: (3 digits BCD)
000: Target table set and comparison begun
C
001: Range table set and comparison begun
TB 002: Target table set only
003: Range table set only
TB: Beginning word of comparison table
(@)INI(61)
000
001
000
80
CPM1/CPM1A Interrupt Functions Section 1-6
To start comparisons again, set the second operand to “000” (execute com-
parison), and execute the INI(61) instruction.
Once a table has been saved, it will be retained in the CPM1/CPM1A during
operation (i.e., during program execution) as long as no other table is saved.
Reading the PV
There are two ways to read the PV. The first is to read it from SR 248 and
SR 249, and the second to use the PRV(62) instruction.
Reading SR 248 and SR 249
The PV of high-speed counter is stored in SR 248 and SR 249 as shown below.
The leftmost bit will be F for negative values.
Leftmost 4 digits Rightmost 4 digits Up/Down Mode Incrementing Mode
SR 249 SR 248 F0032767 to 00032767 00000000 to 00065535
(–32767)
Note 1. These words are refreshed only once every cycle, so there may be a differ-
ence from the actual PV.
2. When high-speed counter is not being used, the bits in these words can be
used as work bits.
Using the PRV(62) Instruction
Read the PV of the high-speed counter by using the PRV(62) instruction.
(@)PRV(62)
P1: Leading word of PV
000
000
P1
The PV of the high-speed counter is stored as shown below. The leftmost bit will
be F for negative values.
Leftmost 4 digits Rightmost 4 digits Up/Down Mode Incrementing Mode
81
CPM1/CPM1A Interrupt Functions Section 1-6
The comparison conditions (target values and count directions) are stored in the
comparison table with the subroutine numbers. Up to 16 target values can be
stored. The corresponding subroutine is executed when the counter’s PV
matches the target value.
The following data is stored for the comparison table:
DM 0000 0002 Number of comparison conditions: 2
DM 0001 1000 Target value 1: 1000
DM 0002 0000
DM 0003 0030 Comparison 1 interrupt subroutine no.: 30
DM 0004 2000 Target value 2: 2000
DM 0005 0000
DM 0006 0031 Comparison 2 interrupt subroutine no.: 31
The following diagram shows the example ladder program. DM 6642 must be
set to 014, where is the reset method which can be set to 0 or 1.
25315 (ON for first cycle)
CTBL(63)
000
000 Registers comparison table, target value mode
DM 0000 First word of the comparison table
SBN(92) 030
Interrupt program 30
RET(93)
SBN(92) 031
Interrupt program 31
RET(93)
Application Example This example shows a program that uses the high-speed counter with phase-dif-
(Up/Down Mode) ference inputs in the Up/Down Mode, making comparisons by means of the
range comparison method.
The comparison conditions (upper/lower limits of the ranges) are stored in the
comparison table with the subroutine numbers. Up to 8 separate ranges can be
defined. The corresponding subroutine is executed when the counter’s PV is
within the range.
Note Always set 8 ranges. If fewer than 8 ranges are needed, set the remaining sub-
routine numbers to FFFF. A value of FFFF indicates that no subroutine is to be
executed.
The following data is stored for the comparison table:
DM 0000 1500
DM 0001 0000 Lower limit 1: 1,500 counts
DM 0002 3000
DM 0003 0000 Upper limit 1: 3,000 counts
DM 0004 0040 Range 1 interrupt subroutine no.: 40
DM 0005 7500
DM 0006 0000 Lower limit 2: 7,500 counts
DM 0007 0000
DM 0008 0001 Upper limit 2: 10,000 counts
DM 0009 0041 Range 2 interrupt subroutine no.: 41
DM 0010 0000
DM 0011 0000
82
SRM1 Interrupt Functions Section 1-7
DM 0012 0000
DM 0013 0000
DM 0014 FFFF Range 3 interrupt subroutine not executed
. . .
. . .
. . .
. . .
. . .
DM 0035 0000
DM 0036 0000
DM 0037 0000
DM 0038 0000
DM 0039 FFFF Range 8 interrupt subroutine not executed
The following diagram shows the example ladder program. DM 6642 must be
set to 010, where is the reset method which can be set to 0 or 1.
SBN(92) 040
Interrupt program 40
RET(93)
SBN(92) 041
Interrupt program 41
RET(93)
83
SRM1 Interrupt Functions Section 1-7
Operation Use the following instruction to activate and control the interval timer.
Starting Up in One-Shot Mode
Use the STIM(69) instruction to start the interval timer in the one-shot mode.
(@)STIM(69)
C1: Interval timer, one-shot mode (000)
C1
C2: Timer set value (first word address)
C2
C3: Subroutine no. (4 digits BCD): 0000 to 0049
C3
(@)STIM(69)
C1: Interval timer, scheduled interrupt mode (003)
C1
C2: Timer set value (leading word no.)
C2
C3: Subroutine no. (4 digits BCD): 0000 to 0049
C3
(@)STIM(69)
C1: Read elapsed time (006)
C1
C2: Leading word of parameter 1
C2
C3: Parameter 2
C3
C2: Number of times the decrementing counter has been decremented (4 digits
BCD)
C2 + 1: Decrementing counter time interval (4 digits BCD; unit: 0.1 ms)
C3: Elapsed time from previous decrement (4 digits BCD; unit: 0.1 ms)
84
SRM1 Interrupt Functions Section 1-7
The time from when the interval timer is started until the execution of this instruc-
tion is calculated as follows:
{(Content of C2) × (Content of C2+1) + (Content of C3)} × 0.1 ms
If the specified interval timer is stopped, then “0000” will be stored.
Stopping the Timer
Use the STIM(69) instruction to stop the interval timer. The interval timer will be
stopped.
(@)STIM(69)
C1
C1: Stop interval timer (010)
000
000
Application Example In this example, an interrupt is generated 2.4 ms (0.6 ms × 4) after input 00005
(One-shot Mode) goes ON; the interrupt executes interrupt subroutine number 23.
MOV(21)
#0006 Sets the decrementing time interval to 0.6 ms.
DM 0011 (BCD: 0005 to 0320)
00005
@STIM(69)
000 Starts the interval timer in one-shot mode.
DM 0010 Specifies the first word containing the set value.
#0023 Specifies the subroutine number (only lower by-
tes are effective).
SBN(92) 023
Interrupt program
RET(93)
85
CompoBus/S Distributed I/O Functions (SRM1 Only) Section 1-8
Application Example In this example, an interrupt is generated every 4.0 ms (1.0 ms × 4) after input
(Scheduled Interrupt Mode) 00005 goes ON; the interrupts execute interrupt subroutine number 23.
MOV(21)
#0010 Sets the decrementing time interval to 1.0 ms.
DM 0011 (BCD: 0005 to 0320)
00005
@STIM(69)
003 Starts the interval timer in scheduled interrupt mode.
DM 0010 Specifies the first word containing the set value.
#0023 Specifies the subroutine number (only the lower by-
tes are effective).
SBN(92) 023
Interrupt program
RET(93)
The maximum no. of nodes can be set from a Programming Device by making
the following settings in DM 6603.
Note When changes are made to these settings, always turn the power off and on
again to make the new setting effective.
Slave Interrupts Input bits in IR 000 to IR 007 and output bits in IR 010 to IR 017 are used as inter-
rupts for CompoBus/S I/O Terminals. The CompoBus/S I/O Terminal interrupts
(IN 0 to 15 and OUT 0 to 15) are allocated as indicated in the following table.
IN0 to IN15 are the node addresses for the Input Terminals and OUT0 to OUT15
are the node addresses for the Output Terminals.
86
Communications Functions Section 1-9
Word Bit
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Input IR 000 IN1 IN0
IR 001 IN3 IN2
IR 002 IN5 IN4
IR 003 IN7 IN6
IR 004 IN9 IN8
IR 005 IN11 IN10
IR 006 IN13 IN12
IR 007 IN15 IN14
Output IR 010 OUT1 OUT0
IR 011 OUT3 OUT2
IR 012 OUT5 OUT4
IR 013 OUT7 OUT6
IR 014 OUT9 OUT8
IR 015 OUT11 OUT10
IR 016 OUT13 OUT12
IR 017 OUT15 OUT14
Note 1. When the maximum number of CompoBus/S nodes is set to 16, IN8 to IN15
can be used as work bits.
2. CompoBus/S Terminals with less than 8 points are allocated bit addresses
from either 0 or 8.
3. CompoBus/S Terminals with 16 points can be set for only even number ad-
dresses.
Status Flags The communications status between CompoBus/S terminals is output through
AR04 to AR07 Slave Add Flags and Slave Communications Error Flags.
Word Uppermost bits: Slave Communications Error Flags Lower Bits: Slave Add Flags
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
AR04 OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
AR05 IN7 IN6 IN5 IN4 IN3 IN2 IN1 IN0 IN7 IN6 IN5 IN4 IN3 IN2 IN1 IN0
AR06 OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT OUT
15 14 13 12 11 10 9 8 15 14 13 12 11 10 9 8
AR07 IN15 IN14 IN13 IN12 IN11 IN10 IN9 IN8 IN15 IN14 IN13 IN12 IN11 IN10 IN9 IN8
Note 1. IN0 to IN15 are the input terminals and OUT0 to OUT15 are the output termi-
nals.
2. When the maximum number of CompoBus/S units is set to 16, IN8 to IN15
and OUT8 to OUT15 cannot be used.
3. The Slave Add Flag turns ON when a slave joins the communications. When
the power to the CPU Unit is turned OFF and ON again all bits will turn OFF.
4. The Slave Communications Error Flag turns ON when a slave participating
in the network is separated from the network. The bit will turn OFF when the
slave re-enters the network.
87
Communications Functions Section 1-9
Note These types of communications cannot be carried out with the CQM1-CPU11-E,
which is equipped with only a peripheral port.
This section explains the required PC Setup and methods for using these types
of communications.
CPM1/CPM1A The CPM1/CPM1A can execute a variety of communications through its periph-
Communications eral port via an RS-232C Adapter or an RS-422 Adapter.
Host Link Communications
The CPM1/CPM1A PCs are compatible with the Host Link System, which allows
up to 32 PCs to be controlled from a host computer. An RS-232C Adapter is used
for 1-to-1 communications and an RS-422 Adapter and B500-AL004 Link
Adapter are used for 1-to-n communications.
A CPM1/CPM1A equipped with an RS-232C Adapter can also communicate
with a Programmable Terminal using host link commands.
Refer to 1-9-4 CPM1/CPM1A Host Link Communications in this manual and
1-2-2 Host Link Communications in the CPM1 Operation Manual or 1-2-2 Host
Link Communications in the CPM1A Operation Manual for more details.
1-to-1 Link
A data link can be created with a data area in another CPM1, CPM1A, CQM1, or
C200HS PC. An RS-232C Adapter is used to make the 1-to-1 connection.
Refer to 1-9-8 CPM1/CPM1A One-to-one Link Communications in this manual
and 1-2-3 1-to-1 Communications Links in the CPM1 Operation Manual or 1-2-3
1-to-1 Communications Links in the CPM1A Operation Manual for more details.
NT Link
Using the NT link, the CPM1/CPM1A PC can connected to the Programmable
Terminal (NT Link Interface) through an RS-232C Adapter.
Refer to 1-9-9 CPM1/CPM1A NT Link Communications in this manual and 1-2-4
NT Link Communications in the CPM1 Operation Manual or NT Link Commu-
nications in the CPM1A Operation Manual for more details.
SRM1 Communications The following types of communications can be executed through the ports of the
SRM1.
• Host link communications with a host computer
• RS-232C communications with a computer or other device
• One-to-one link communications with another SRM1
• NT Link communications with Programmable Terminals
Note NT Link communications are not possible with the SRM1-C01, which is
equipped with only a peripheral port. The SRM1-C01 may be connected to a PT
through an RS-232C Adapter in Host Link mode.
88
Communications Functions Section 1-9
Note The above setting apply to CPU Units manufactured from July 1995 (lot number
**75 for July 1995). For CPU Units manufactured before July 1995 (lot number
**65 for June 1995), only 1 stop bit will be set and the baud rate will be 2,400 bps.
The settings in DM 6645 and DM 6650 determine the main communications pa-
rameters, as shown in the following diagram.
Bit 15 0
DM 6645: RS-232C port
DM 6650: Peripheral port
Communications mode
0: Host link
1: RS-232C
2: One-to-one link slave
3: One-to-one link master
4: One-to-one NT Link (See note.)
One-to-one Links
To use a 1:1 link, the only settings necessary are the communications mode and
the link words. Set the communications mode for one of the PCs to the 1:1 mas-
ter and the other to the 1:1 slave, and then set the link words in the PC desig-
nated as the master. Bits 08 to 11 are valid only for the master for link one-to-one.
Note One-to-one link communications are possible for the RS-232C port only. This
setting is not possible for the peripheral port. A 1:1 NT Link cannot be used with
the CQM1-CPU21-E.
Node number
(2 digits BCD): 00 to 31
Default: 00
Set the node number to 00 unless multiple nodes are connected in a network.
89
Communications Functions Section 1-9
Bit 15 0
DM 6648: RS-232C port
DM 6653: Peripheral port 0 0
End code
0: Not set (Amount of reception data specified.)
1: Set (End code specified.)
2: CR/LF
Start code
0: Not set
1: Set (Start code specified.)
Specify whether or not a start code is to be set at the beginning of the data, and
whether or not an end code is to be set at the end. Instead of setting the end
code, it is possible to specify the number of bytes to be received before the re-
ception operation is completed. Both the codes and the number of bytes of data
to be received are set in DM 6649 or DM 6654.
Setting the Start Code, End Code, and Amount of Reception Data
Bit 15 0
DM 6649: RS-232C port
DM 6654: Peripheral port
Start code 00 to FF
Standard Communications If the following settings are satisfactory for these communications conditions,
then set the two rightmost digits to 00. The settings in DM 6646 and DM 6651 will
be ignored for this setting.
Start bits: 1 bit
Data length: 7 bits
Stop bits: 2 bits
Parity: Even
Baud rate: 9,600 bps
Bit 15 0
DM 6646: RS-232C port
DM 6651: Peripheral port
90
Communications Functions Section 1-9
Transmission Frame Setting Stop bits Data length Stop bits Parity
Format
00 1 7 1 Even
01 1 7 1 Odd
02 1 7 1 None
03 1 7 2 Even
04 1 7 2 Odd
05 1 7 2 None
06 1 8 1 Even
07 1 8 1 Odd
08 1 8 1 None
09 1 8 2 Even
10 1 8 2 Odd
11 1 8 2 None
Transmission Delay Time Depending on the devices connected to the RS-232 port, it may be necessary to
allow time for transmission. When that is the case, set the transmission delay to
regulate the amount of time allowed.
Bit 15 0
DM 6647: RS-232C port
DM 6652: Peripheral port
Default: No delay
91
Communications Functions Section 1-9
Communications Procedure This section explains how to use the host link to execute data transmissions from
the CQM1. Using this method enables automatic data transmission from the
CQM1 when data is changed, and thus simplifies the communications process
by eliminating the need for constant monitoring by the computer.
1, 2, 3... 1. Check to see that AR 0805 (RS-232C Port Transmit Ready Flag) is ON.
2. Use the TXD(48) instruction to transmit the data.
From the time this instruction is executed until the data transmission is complete,
AR 0805 (or AR 0813 for the peripheral port) will remain OFF. It will turn ON
again upon completion of the data transmission. The TXD(48) instruction does
not provide for a response, so in order to receive confirmation that the computer
has received the data, the computer’s program must be written so that it gives
notification when data is written from the CQM1.
The transmission data frame is as shown below for data transmitted in the Host
Link Mode by means of the TXD(48) instruction.
@ E X ↵
x 101 x 100
To reset the RS-232C port (i.e., to restore the initial status), turn ON SR 25209.
To reset the peripheral port, turn ON SR 25208. These bits will turn OFF auto-
matically after the reset.
If the TXD(48) instruction is executed while the CQM1 is in the middle of re-
sponding to a command from the computer, the response transmission will first
be completed before the transmission is executed according to the TXD(48)
instruction. In all other cases, data transmission based on a TXD(48) instruction
will be given first priority.
Application Example This example shows a program for using the RS-232C port in the Host Link
Mode to transmit 10 bytes of data (DM 0000 to DM 0004) to the computer. The
default values are assumed for all the PC Setup (i.e., the RS-232C port is used in
Host Link Mode, the node number is 00, and the standard communications
conditions are used.) From DM 0000 to DM 0004, “1234” is stored in every word.
From the computer, execute a program to receive CQM1 data with the standard
communications conditions.
00100 AR0805
@TXD(48)
DM 0000 If AR 0805 (the Transmit Ready Flag) is ON
when IR 00100 turns ON, the ten bytes of
#0000
data (DM 0000 to DM 0004) will be trans-
#0010 mitted.
92
Communications Functions Section 1-9
The following type of program must be prepared in the host computer to receive
the data. This program allows the computer to read and display the data re-
ceived from the PC while a host link read command is being executed to read
data from the PC.
10 ’CQM1 SAMPLE PROGRAM FOR EXCEPTION
20 CLOSE 1
30 CLS
40 OPEN ”COM:E73” AS #1
50 KEYIN
60 INPUT ”DATA ––––––––”,S$
70 IF S$=” ” THEN GOTO 190
80 PRINT ”SEND DATA = ”;S$
90 ST$=S$
100 INPUT ”SEND OK? Y or N?=”,B$
110 IF B$=”Y” THEN GOTO 130 ELSE GOTO KEYIN
120 S$=ST$
130 PRINT #1,S$ ’Sends command to PC
140 INPUT #1,R$ ’Receives response from PC
150 PRINT ”RECV DATA = ”;R$
160 IF MID$(R$,4,2)=”EX” THEN GOTO 210 ’Identifies command from PC
170 IF RIGHT$(R$,1)<>”” THEN S$=” ”:GOTO 130
180 GOTO KEYIN
190 CLOSE 1
200 END
210 PRINT ”EXCEPTION!! DATA”
220 GOTO 140
The data received by the computer will be as shown below. (FCS is “59.”)
“@00EX1234123412341234123459CR”
PC Setup Settings The CPM1/CPM1A’s peripheral port settings must be set properly in order to use
the host link communications, as shown in the following table.
93
Communications Functions Section 1-9
Note 1. If an improper setting is used, a non-fatal error will occur, AR 1302 will be
turned ON, and the default setting (0, 00, or 0000) will be used.
2. For information on the host link settings for another OMRON PC, refer to
that PC’s Operation Manual.
3. If an out-of-range value is set, the following communications conditions will
result. In that case, reset the value so that it is within the permissible range.
Communications mode: Host Link
Communications format: Standard settings
(1 start bit, 7-bit data; even parity, 2 stop bits,
9,600 bps)
Transmission delay: No
Node number: 00
94
Communications Functions Section 1-9
Example Program This example shows a BASIC program that reads the status of the CPM1’s in-
puts in IR 000. For more details, refer to Section 6 Host Link Commands.
An FCS (frame check sequence) check isn’t performed on the received re-
sponse data in this program. Be sure that the host computer’s RS-232C port is
configured correctly before executing the program.
1010 ’CPM1 SAMPLE PROGRAM
1020 ’SET THE COMMAND DATA
1030 S$=”@00RR00000001”
1040 FCS=0
1050 FOR I=1 TO LEN(S$)
1060 FCS=FCS XOR ASC(MID$(S$,I,1))
1070 NEXT I
1080 FCS$=(FCS):IF LEN(FCS$)=1 THEN FCS$=”0”+FCS$
1090 CLOSE 1
1100 CLS
1110 PRINT ”SENDING COMMAND”
1120 OPEN ”COM:E73” AS #1
1130 PRINT #1,S$ + FCS + CHR$(13);
1140 CLS
1150 PRINT ”RECEIVING RESPONSE DATA”
1160 LINE INPUT #1,A$
1170 PRINT A$
1180 END
PC Setup Settings The SRM1’s peripheral port and RS-232C port settings must be set properly in
order to use the host link communications, as shown in the following table.
95
Communications Functions Section 1-9
Note If an out-of-range value is set, the following communications conditions will re-
sult. In that case, reset the value so that it is within the permissible range.
Communications mode: Host Link
Communications format: Standard settings
(1 start bit, 7-bit data; even parity, 2 stop bits,
9,600 bps)
Transmission delay: No
Node number: 00
Word Bit Function Setting
RS-232C Port Settings
The following settings are effective after transfer to the PC.
DM 6645 00 to 03 Port settings To match
0: Standard (1 start bit, 7-bit data, even parity, 2 stop bits, 9,600 bps) host pa-
1: Settings in DM 6646 rameters
96
Communications Functions Section 1-9
Note If an out-of-range value is set, the following communications conditions will re-
sult. In that case, reset the value so that it is within the permissible range.
Communications mode: Host Link
Communications format: Standard settings
(1 start bit, 7-bit data; even parity, 2 stop bits,
9,600 bps)
Transmission delay: No
Node number: 00
97
Communications Functions Section 1-9
Example Program This example shows a BASIC program that reads the status of the SRM1’s in-
puts in IR 000. For more details, refer to Section 6 Host Link Commands.
An FCS (frame check sequence) check isn’t performed on the received re-
sponse data in this program. Be sure that the host computer’s RS-232C port is
configured correctly before executing the program.
1000 ’
1010 ’SRM1 Sample Program for PC-9801 N88-BASIC
1020 ’
1050 ’
1060 ’ Set value RS-232C SPEED:9600BPS,PAR-
ITY:EVEN,DATA:7,STOP:2
1070 OPEN ”COM:E73” AS #1
1080 *REPEAT
1090 ’ Transmission data input
1100 INPUT ”send data:”,SEND$
1110 ’ FCS Calculation
1120 FCS=0
1130 FOR IFCS=1 TO LEN(SEND$)
1140 FCS=FCS XOR ASC(MID$(SEND$;IFCS,1)
1150 NEXT
1160 FCS$=RIGHT$(”0”+HEX$(FCS),2)
1170 ’ Communications execute
1180 ZZZ$=SEND$+FCS$+”*”+CHR$(13)
1190 PRINT #1,ZZZ$;
1200 ’ Response check
1210 RECCNT=0:TMP$=””
1220 *DRECLOOP
1230 IF LOC(1)<>0 THEN *DREC1
1240 RECCNT=RECCNT+1
1250 IF RECCNT=5000 THEN *DRECERR ELSE *DRECLOOP
1260 *DREC1
1270 TMP$=TMP$+INPUT$(LOC(1),#1)
1280 IF RIGHT$(TMP$,1)=CHR$(13) THEN *DRECEND ELSE
RECCNT=0:GOTO *DRECLOOP
1290 *DRECERR
1300 TMP$=”No response!!”+CHR$(13)
1310 *DRECEND
1320 RECV$=TMP$
1330 PRINT ”receive data:”;RECV$
1340 ’ Go to transmission data input
1350 GOTO *REPEAT
1360 ’ Processing complete
1370 CLOSE #1
1380 END
Communications Procedure
Transmissions
1, 2, 3... 1. Check to see that AR 0805 (the RS-232C Port Transmit Ready Flag) has
turned ON.
98
Communications Functions Section 1-9
From the time this instruction is executed until the data transmission is complete,
AR 0805 ( or AR0813 for the peripheral port) will remain OFF. (It will turn ON
again upon completion of the data transmission.)
Start and end codes are not included when the number of bytes to be transmitted
is specified. The largest transmission that can be sent with or without start and
end codes in 256 bytes, N will be between 254 and 256 depending on the desig-
nations for start and end codes. If the number of bytes to be sent is set to 0000,
only the start and end codes will be sent.
256 bytes max.
To reset the RS-232C port (i.e., to restore the initial status), turn on SR 25209. To
reset the peripheral port, turn on SR 25208. These bites will turn OFF automati-
cally after the reset.
Receptions
1, 2, 3... 1. Confirm that AR 0806 (RS-232C Reception Complete Flag) or AR 0814 (Pe-
ripheral Reception Complete Flag) is ON.
2. Use the RXD(47) instruction to receive the data.
(@)RXD(47)
D: Leading word no. for storing reception data
D
C: Control data
C Bits 00 to 03
N 0: Leftmost bytes first
1: Rightmost bytes first
Bits 12 to 15
0: RS-232C port
1: Peripheral port
N: Number of bytes stored (4 digits BCD), 0000 to 0256
3. The results of reading the data received will be stored in the AR area. Check
to see that the operation was successfully completed. The contents of these
bits will be reset each time RXD(47) is executed.
RS-232C Peripheral Error
port port
AR 0800 to AR 0808 to RS-232C port error code (1 digit BCD) 0: Normal
AR 0803 AR 0811 completion 1: Parity error 2: Framing error 3: Over-
run error
AR 0804 AR0812 Communications error
AR 0807 AR0815 Reception Overrun Flag (After reception was com-
pleted, the subsequent data was received before the
data was read by means of the RXD(47) instruction.)
AR 09 AR10 Number of bytes received
To reset the RS-232C port (i.e., to restore the initial status), turn ON SR 25209.
To reset the peripheral port, turn ON SR 25208. These bits will turn OFF auto-
matically after the reset.
99
Communications Functions Section 1-9
The start code and end code are not included in AR 09 or AR 10 (number of bytes
received).
Application Example This example shows a program for using the RS-232C port in the RS-232C
Mode to transmit 10 bytes of data (DM 0100 to DM 0104) to the computer, and to
store the data received from the computer in the DM area beginning with
DM 0200. Before executing the program, the following PC Setup setting must be
made.
DM 6645: 1000 (RS-232C port in RS-232C Mode; standard communications
conditions)
DM 6648: 2000 (No start code; end code CR/LF)
The default values are assumed for all other PC Setup settings. From DM 0100
to DM 0104, 3132 is stored in every word. From the computer, execute a pro-
gram to receive CQM1 data with the standard communications conditions.
00100
DIFU(13) 00101
00101 AR0805
@TXD(48) If AR 0805 (the Transmit Ready Flag) is ON
DM 0100 when IR 00100 turns ON, the ten bytes of data
#0000
(DM 0100 to DM 0104) will be transmitted, left-
most bytes first.
#0010
AR0806
@RXD(47) When AR 0806 (Reception Completed Flag)
DM 0200 goes ON, the number of bytes of data specified in
AR 09 will be read from the CQM1’s reception
#0000
buffer and stored in memory starting at DM 0200,
AR09 leftmost bytes first.
Written automatically.
The word used by each PC will be as shown in the following table, according to
the settings for the master, slave, and link words.
DM 6645 setting LR 00 to LR 63 LR 00 to LR 31 LR 00 to LR 15
Master words LR00 to LR31 LR00 to LR15 LR00 to LR07
Slave words LR32 to LR63 LR16 to LR31 LR08 to LR15
Communications Procedure If the settings for the master and the slave are made correctly, then the one-to-
one link will be automatically started up simply by turning on the power supply to
both the CQM1s and operation will be independent of the CQM1 operating
modes.
100
Communications Functions Section 1-9
Link Errors If a slave does not received a response from the master within one second, the
1:1 Link Error Flag (AR 0802) and the Communications Error Flag (AR 0804) will
be turned ON.
Application Example This example shows a program for verifying the conditions for executing a one-
to-one link using the RS-232C ports. Before executing the program, set the fol-
lowing PC Setup parameters.
Master: DM 6645: 3200 (one-to-one link master; Area used: LR 00 to LR 15)
Slave: DM 6645: 2000 (one-to-one link slave)
The defaults are assumed for all other PC Setup parameters. The words used
for the one-to-one link are as shown below.
Master Slave
LR00 LR00
Area for writing Area for reading
LR07 LR07
LR08 LR08
Area for reading Area for writing
LR15 LR15
When the program is executed at both the master and the slave, the status of
IR 001 of each Unit will be reflected in IR 100 of the other Unit. Likewise, the sta-
tus of the other Unit’s IR 001 will be reflected in IR 100 of each Unit. IR 001 is an
input word and IR 100 is an output word
In the Master
MOV(21)
LR08
100
In the Slave
MOV(21)
LR00
100
101
Communications Functions Section 1-9
One-to-one CPM1/CPM1A The following diagram shows a one-to-one link between two CPM1s PCs. Refer
Links to the CPM1A Operation Manual for the corresponding information on the
CPM1A.
RS-232C Cable
The words used for the one-to-one link are as shown below.
Master Slave
LR00 LR00
Write data Area for writing Area for reading Read data
LR07 LR07
LR08 LR08
Read data Area for reading Area for writing Write data
LR15 LR15
Limitations of One-to-one Only the 16 LR words from LR 00 to LR 15 can be linked in the CPM1/CPM1A, so
Links with a CPM1/CPM1A use only those 16 words in the CQM1 or C200HS when making a one-to-one link
with one of those PCs. A one-to-one link cannot be made to a CPM1/CPM1A PC
using LR 16 through LR 63 in the CQM1 or C200HS.
PC Setup Settings The settings relating to 1-to-1 PC communications must be set as shown in the
following table.
Word Bit Function Setting Setting
(Master) (Slave)
DM 6650 00 to 07 Port settings1 00 00
00: Standard (1 start bit, 7-bit data, even parity, 2 stop bits, 9,600 bps) (Any val- (Any val-
01: Settings in DM 6651 ue is OK) ue is OK)
08 to 11 Link area for one-to-one PC link via peripheral port 0 0
0: LR 00 to LR 15 (Any val-
ue is OK)
12 to 15 Communications mode1 3 2
0: Host link; 2: 1-to-1 PC link (slave); 3: 1-to-1 PC link (master); 4: NT link
Note 1. If an improper setting is used, a non-fatal error will occur, AR 1302 will be
turned ON, and the default setting (0 or 00) will be used.
2. For information on the 1-to-1 link settings for another OMRON PC, refer to
that PC’s Operation Manual.
3. For information on CPM1/CPM1A one-to-one link connections and wiring
diagrams refer to 3-4-7 Host Link Connections in the CPM1 Operation
Manual or CPM1A Operation Manual. For the SRM1 refer to 3-4-4 RS-232C
Port Wiring in the SRM1 Master Control Unit Operation Manual.
4. If an out-of-range value is set, the following communications conditions will
result. In that case, reset the value so that it is within the permissible range.
Communications mode: Host Link
Communications format: Standard settings
(1 start bit, 7-bit data; even parity, 2 stop bits,
9,600 bps)
Transmission delay: No
Node number: 00
102
Communications Functions Section 1-9
Example Program This example shows ladder programs that copy the status of IR 000 in each
CPM1/CPM1A to SR 200 in the other CPM1/CPM1A.
Program in the Master Program in the Slave
MOV(21) MOV(21)
LR08 LR00
200 200
LR00 LR00
IR 000 Write Writing area Reading area Read SR 200
LR07 LR07
LR08 LR08
SR 200 Read Reading area Writing area Write IR 000
LR15 LR15
CPM1 CPU
RS-232C Cable
CPM1A PCs
RS-232C
OMRON Programmable Terminal Adapter CPM1A CPU Unit
RS-232C Cable
PC Setup Settings The settings relating to NT link PC communications must be set as shown in the
following table.
Word Bit Function Setting
DM 6650 00 to 07 Port settings1 00
00: Standard (1 start bit, 7-bit data, even parity, 2 stop bits, 9,600 bps) (Any val-
01: Settings in DM 6651 ue is OK)
08 to 11 Link area for one-to-one PC link via peripheral port 0
0: LR 00 to LR 15 (Any val-
ue is OK)
12 to 15 Communications mode1 4
0: Host link; 2: 1-to-1 PC link (slave); 3: 1-to-1 PC link (master); 4: NT link
103
Communications Functions Section 1-9
Note 1. If an improper setting is used, a non-fatal error will occur, AR 1302 will be
turned ON, and the default setting (0 or 00) will be used.
2. For information on the NT link settings for another OMRON PC, refer to that
PC’s Operation Manual.
3. If an out-of-range value is set, the following communications conditions will
result. In that case, reset the value so that it is within the permissible range.
Communications mode: Host Link
Communications format: Standard settings
(1 start bit, 7-bit data; even parity, 2 stop bits,
9,600 bps)
Transmission delay: No
Node number: 00
One-to-one SRM1 Links The following diagram shows a one-to-one link between two SRM1s.
SRM1 SRM1
The words used for the one-to-one link are as shown below.
Master Slave
LR00 LR00
Write data Area for writing Area for reading Read data
LR07 LR07
LR08 LR08
Read data Area for reading Area for writing Write data
LR15 LR15
Limitations of One-to-one Only the 16 LR words from LR 00 to LR 15 can be linked in the SRM1, so use only
Links with a SRM1 those 16 words in the CQM1 or C200HS when making a one-to-one link with one
of those PCs. A one-to-one link cannot be made to a SRM1 PC using LR 16
through LR 63 in the CQM1 or C200HS.
104
Communications Functions Section 1-9
PC Setup Settings The settings relating to 1-to-1 PC communications must be set as shown in the
following table.
Note 1. If an improper setting is used, a non-fatal error will occur, AR 1302 will be
turned ON, and the default setting (0 or 00) will be used.
2. For information on the 1-to-1 link settings for another OMRON PC, refer to
that PC’s Operation Manual.
3. If an out-of-range value is set, the following communications conditions will
result. In that case, reset the value so that it is within the permissible range.
Communications mode: Host Link
Communications format: Standard settings
(1 start bit, 7-bit data; even parity, 2 stop bits,
9,600 bps)
Transmission delay: No
Node number: 00
Example Program This example shows ladder programs that copy the status of IR 000 in each
SRM1 to SR 200 in the other SRM1.
MOV(21) MOV(21)
LR08 LR00
200 200
LR00 LR00
IR 000 Write Writing area Reading area Read SR 200
LR07 LR07
LR08 LR08
SR 200 Read Reading area Writing area Write IR 000
LR15 LR15
105
Communications Functions Section 1-9
NT Link is possible only with the SRM1-C02-V1, which has an RS-232C port.
PC Setup Settings The settings relating to NT link PC communications must be set as shown in the
following table.
Word Bit Function Setting
DM 6645 00 to 03 Port settings1 00
00: Standard (1 start bit, 7-bit data, even parity, 2 stop bits, 9,600 bps) (Any val-
01: Settings in DM 6646 ue is OK)
04 to 07 CTS control settings 0
0: Disable (Any val-
1: Set ue is OK)
08 to 11 Link area for one-to-one PC link via peripheral port 0
0: LR 00 to LR 15
12 to 15 Communications mode1 4
0: Host link; 1: No protocol; 2: 1-to-1 PC link (slave); 3: 1-to-1 PC link (master); 4: NT
link
Note 1. If an improper setting is used, a non-fatal error will occur, AR 1302 will be
turned ON, and the default setting (0 or 00) will be used.
2. For information on the NT link settings for another OMRON PC, refer to that
PC’s Operation Manual.
3. If an out-of-range value is set, the following communications conditions will
result. In that case, reset the value so that it is within the permissible range.
Communications mode: Host Link
Communications format: Standard settings
(1 start bit, 7-bit data; even parity, 2 stop bits,
9,600 bps)
Transmission delay: No
Node number: 00
106
Communications Functions Section 1-9
107
Communications Functions Section 1-9
Note If an out-of-range value is set, the following communications conditions will re-
sult. In that case, reset the value so that it is within the permissible range.
RS-232C Port Settings When the RS-232C port is used to conduct no protocol communications, the fol-
lowing settings must be made from the peripheral device to DM6645 to DM6649
in the SRM1.
108
Communications Functions Section 1-9
Note If an out-of-range value is set, the following communications conditions will re-
sult. In that case, reset the value so that it is within the permissible range.
Communications mode: Host Link
Communications format: Standard settings
(1 start bit, 7-bit data; even parity, 2 stop bits,
9,600 bps)
Transmission delay: No
Node number: 00
109
Communications Functions Section 1-9
Note 1. The start and end codes are set in DM 6648 to DM 6649 and DM 6653 to
DM 6654 of the PC Setup.
2. When there are several start and end codes, the first part of each will be ef-
fective.
3. When the end code duplicates the transmission data and the transmission is
stopped part way through, use CR or LF as the end code.
4. The start and end codes are not stored.
Note The timing from data reception starting to completion for the SRM1 is as indi-
cated below.
Reception Start:
Without start code: Normal reception status
With start code: After start code is received.
110
Calculating with Signed Binary Data Section 1-10
Reception Complete:
When either the end code, the specified no. of bytes, or 256 bytes are received.
00100
DIFU(13)
No protocol communications start
00101
00100 AR0805
@TXD
DM0100 First word holding send data.
#0000 Using the RS-232C port data is
stored from higher to lower values
#0010
10 bytes transmitted
AR0806
@RXD
DM0200 First word to store receive data.
#0000 Using the RS-232C port data is
stored from higher to lower values
256
256 bytes transmitted
111
Calculating with Signed Binary Data Section 1-10
Addition Subtraction
7 + 3 = 10 7–3=4
(–7) + 3 = –4 (–7) – 3 = –10
7 + (–3) = 4 7 – (–3) = 10
(–7) + (–3) = –10 (–7) – (–3) = –4
Multiplication Division
7 3 = 21 7 3 = 2 with a remainder of 1
(–7) 3 = –21 (–7) 3 = –2 with a remainder of –1
7 (–3) = –21 7 (–3) = –2 with a remainder of 1
(–7) (–3) = 21 (–7) (–3) = 2 with a remainder of –1
112
Calculating with Signed Binary Data Section 1-10
Input Instructions Only 16-bit operands can be input for the following instructions: NEG(––),
ADB(50), SBB(51), MBS(––), and DBS(––). Refer to the CQM1 Operation
Manual, CPM1 Operation Manual, CPM1A Operation Manual or SRM1 Master
Control Unit Operation Manual for details on inputting instructions from the Pro-
gramming Console.
Allocating Function Codes The procedure to using the Programming Console to allocate function codes is
shown in the CQM1 Operation Manual. Be sure that pin 4 on the CQM1’s DIP
switch is turned ON to enable use of a user-set instruction table before perform-
ing this operation.
113
Calculating with Signed Binary Data Section 1-10
ADB(50)
000 04D2
001
FF85
X 0
010 0457
MBS(––)
010
LR00
0457
X 04BC
020 00148BE4
CLC(41)
SBBL(––)
020
HR50
00148BE4
00003039
030 – 0
00145BAB
DBSL(––)
030
00145BAB
DM1000
FFFFFB2E
040 FFFFFBC7 Result
000000E8 Remainder
114
SECTION 2
Special Features
This section provides an introduction to some of the main CQM1/CPM1/CPM1A/SRM1 features, including the instructions
available through expansion instructions, a monitoring feature called differential monitoring, and the analog setting function
available in the CQM1-CPU42-EV1 and CPM1/CPM1A PCs.
If you are not familiar with OMRON PCs or ladder diagram program, you can skim over this section as an overview of these
features, but will want to read Section 3 Memory Areas and Section 4 Ladder-diagram Programming before reading this sec-
tion in detail. Also, details on programming instructions can be found in Section 5 Instruction Set.
115
Expansion Instructions (CQM1/SRM1 Only) Section 2-1
SPED SPED
MAX MAX
SUM SUM
At the time of shipping, the function codes are If pulse outputs are not being used, and if
assigned as shown above. (In this example, maximum values, minimum values, and
the instructions all relate to pulse outputs.) sums are required, then the Set Instructions
operation can be used as shown above to
reassign instructions in the instruction table.
Note Set the PC model to “CQM1” when setting the expansion instructions for the
SRM1 or CQM1 from the SSS.
116
Expansion Instructions (CQM1/SRM1 Only) Section 2-1
With the CQM1, an instructions table can also be stored on Memory Cassettes
when they are used. Exercise care when using a Memory Cassette that has
been used with another CQM1 or SRM1 and be sure the proper instructions
table is present.
! Caution If pin no. 4 of the CQM1’s DIP switch is set to OFF, only expansion instructions on
the default instructions table can be used and the user-set instructions table will
be ignored. The default instructions table will also be set whenever power is
turned on, deleting any previous settings.
Make sure that pin 4 of the CPU Unit DIP switch is ON when reading a program
from the Memory Cassette that has a user-set expansion instructions table. If pin
4 is OFF, the default instructions table will be used for expansion instructions in
programs read from a Memory Cassette. (In this case, the program read from
the Memory Cassette and the program on the Memory Cassette will not match
when the two are compared.)
117
Advanced I/O Instructions (CQM1 Only) Section 2-2
Hardware Prepare a 10-key keypad, and connect it so that the switches for numeric keys 0
through 9 are input to points 0 through 9 as shown in the following diagram.
Either the input terminals on the CPU Unit or the inputs on a DC Input Unit with 16
or more input points can be used.
ID212 0
0
1
2
3
4
5
6
7
8
9
10
11 9
12
13
14 10-key
15
COM
COM
0V
DC Input Unit
118
Advanced I/O Instructions (CQM1 Only) Section 2-2
TKY(18)
IW: Input word
IW
D1: First register word
D1
D2: Key input word
D2
If the input word for connecting the 10-key keypad is specified for IW, then opera-
tion will proceed as shown below when the program is executed.
IW
D1+1 D1
00
Before 0 0 0 0 0 0 0 0
01 execution
02 Input from 10-key
to (1) 0 0 0 0 0 0 0 1
09
“1” key input
D2
(2) 0 0 0 0 0 0 1 0
00
Note 1. While one key is being pressed, input from other keys will not be accepted.
2. If more than eight digits are input, digits will be deleted beginning with the
leftmost digit.
3. Input bits not used here can be used as ordinary input bits.
Application Example In this example, a program for inputting numbers from the 10-key is shown. As-
sume that the 10-key is connected to IR 000.
DM1002
00015
@XFER(70)
#0002
DM1000
DM 0000
The 10-key information input to IR 000 using TKY(18) is converted to BCD and
stored in DM 1000 and DM 1001. Key information is stored in DM 1002.
IR 00015 is used as an “ENTER key,” and when IR 00015 turns ON, the data
stored in DM 1000 and DM 1001 will be transferred to DM 0000 and DM 0001.
119
Advanced I/O Instructions (CQM1 Only) Section 2-2
OD212
C D E F
0
1
8 9 A B 2
3
4 5 6 7 4
5
0 1 2 3 6
7
8
ID212 9
0 10
1 11
2
3 12
13
4
14
5
15
6
COM
7
COM
8
9
10
11 Output Unit
12
13
14
15
COM
COM
Input Unit
The inputs can be connected to the input terminals on the CPU Unit or a DC Input
Unit with 8 or more input points and the outputs can be connected from a Tran-
sistor Output Unit with 8 points or more.
Using the Instruction
HKY
IW IW: Input word
0W OW: Control signal output word
D
D: First register word
120
Advanced I/O Instructions (CQM1 Only) Section 2-2
If the input word for connecting the hexadecimal keyboard is specified at IW, and
the output word is specified at OW, then operation will proceed as shown below
when the program is executed.
IW
00
01
02 16-key selection
control signals
03
16-key
0
to
9
to
Status of 16 keys
F
D+2
00
to Turn ON flags corre-
09 sponding to input
to keys (The flags re-
15 main ON until the
OW next input.)
04
ON for a 12-cycle
0 1 2 3 4 5 6 7 8 9 101112 period if a key is
pressed.
Once per 12 cycles
DM1000
00015
@XFER(70)
#0002
DM1000
DM0000
121
Advanced I/O Instructions (CQM1 Only) Section 2-2
ID212
0
Input Unit
1 D0 Interface D0
2 D1 D1 A7E data line rightmost digits
3 D2 D2
4 D3 D3
5 D0 D0
6 D1 D1
7 D2 D2
8 D3 D3 A7E data line
9 CS0 CS0 leftmost digits Leftmost digits A7E Rightmost digits
10 CS1 CS1
11 CS2 CS2
12 CS3 CS3
13 RD
To A7E chip selection
RD
14
15 To A7E RD terminal
COM
COM
122
Advanced I/O Instructions (CQM1 Only) Section 2-2
0
1
2
3
4
5
6
7
8
9
A7B
10 Thumbwheel
11
Switch
12
13 8 4 2 1
14
15 OD212
COM
COM Switch no. 8 7 6 5 4 3 2 1 C 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Output Unit DC
COM
The inputs can be connected to the CPU Unit’s input terminals or a DC Input Unit
with 8 or more input points and the outputs can be connected from a Transistor
Output Unit with 8 or more output points.
Preparations When using DSW(87), make the following setting in the PC Setup in PROGRAM
mode before executing the program.
Digital Switch Settings (PC Setup)
Bit 15 0
DM6639 – –
Do not make any changes to bits 0 to 7. They are not related to DSW(87).
Using the Instruction
DSW(87)
IW
IW: Input word
OW OW: Output word
R R: First register word
123
Advanced I/O Instructions (CQM1 Only) Section 2-2
If the input word for connecting the digital switch is specified at for IW, and the
output word is specified for OW, then operation will proceed as shown below
when the program is executed.
IW
Four digits: 00 to 03
100 101 102 103 Input data
Eight digits: 00 to 03, 04 to 07 Leftmost Rightmost
4 digits 4 digits
Wd 0
D+1 D
00
When only 4 digits are read,
01 only word D is used.
CS signal
02
03
04 RD (read) signal
05 1 Round Flag
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Note 1. Do not use DSW(87) more than once within the same program.
2. When using DSW(87), set the input constant for the relevant input word to
less than the cycle time. (Input constants can be changed from DM 6620
onwards.) The characteristics of the digital switch must also be considered
in system and program design.
3. Input and output bits not used here can be used as ordinary input and output
bits.
With this instruction, 4-digit or 8-digit set values can be read in 16 cycles.
Application Example This example shows a program for reading 4 digits in BCD from the digital
switch. Assume that the digital switch is connected to IR 000 (input) and IR 100
(output), and assume the default status for all the PC Setup (4 digits to read).
The data set from the digital switch by DSW(87) is stored in HR 51.
When IR 00015 turns ON, the value stored in HR 51 is moved to DM 0001.
25313
DSW(87)
000
100
HR51
00015
@MOV(21)
HR51
DM0000
Note Output point 5 (here, IR 10005) turns on when one round of data is read and can
be used to time switching the data storage area and gate signal (CS signal)
when DSW(87) is used to input data to different areas of memory.
124
Advanced I/O Instructions (CQM1 Only) Section 2-2
D0 VDD VDD D0
D1 (+) (+) D1
D2 VSS VSS D2
D3 (0) (0) D3
LE3 LE2 LE1 LE0 LE3 LE2 LE1 LE0
OD212
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
DC
COM
The outputs can be connected from a Transistor Output Unit with 8 or more out-
put points for four digits or 16 or more output points for eight digits.
Note 1. Output Unit outputs normally employ negative logic. (Only the PNP output
type employs positive logic.)
2. The 7-segment display may require either positive or negative logic, de-
pending on the model.
Using the Instruction
7SEG(88) S: First source word
S O: Output word
O
C: Control data
C
If the first word holding the data to be displayed is specified at S, and the output
word is specified at O, and the SV taken from the table below is specified at C,
then operation will proceed as shown below when the program is executed.
Data Storage Format
If only four digits are displayed, then only word S will be used.
125
Advanced I/O Instructions (CQM1 Only) Section 2-2
Data output 00 to 03 00 to 03 100 101 102 103 Note 0 to 3: Data output for word S
04 to 07 4 to 7: Data output for word S+1
Latch output 0 04 08
Latch output 1 05 09
Latch output 2 06 10
Latch output 3 07 11
004
The 8-digit BCD data in DM 0120 (rightmost 4 digits) and DM 0121 (leftmost 4
digits) are always displayed by means of 7SEG(88). When the contents of
DM 0120 and DM 0121 change, the display will also change.
126
Advanced I/O Instructions (CQM1 Only) Section 2-2
Example The following wiring and program examples show how to use input bits IR 00004
through IR 00007 and output bits IR 10004 through IR 10007 to input values from
a hexadecimal keypad.
Wiring Diagram (Not Complete)
C D E F
OD212
0
8 9 A B
1
2
4 5 6 7 3
ID212
4
0 3
0 1 2 5
1
2 6
3 7
8
4
9
5
6
7 Output Unit
IR 100
Input terminals
IR 000
Note Power supply lines have been omitted.
Program
DM0000
100
15 0 15 0
Output DM 0100
IR 000
HKY execution
127
Macro Function Section 2-3
Using Macros To use a macro, call a subroutine by means of the MACRO instruction,
MCRO(99), as shown below, in stead of SBS(91) (SUBROUTINE ENTRY).
MCRO(99)
Subroutine No
Fist input word
1, 2, 3... 1. The contents of the four consecutive words beginning with the first input
word will be transferred to IR 096 through IR 099 (SR 232 through SR 235 in
CPM1/CPM1A/SRM1 PCs). The contents of the four consecutive words be-
ginning with the first output word will be transferred to IR 196 through IR 199
(SR 236 through SR 239 in CPM1, CPM1A and SRM1 PCs).
2. The specified subroutine will be executed until RET(93) (Subroutine Return)
is executed.
3. The contents of IR 196 through IR 199 (SR 236 through SR 239 in CPM1/
CPM1A/SRM1 PCs) will be transferred to the four consecutive words begin-
ning with the first output word.
4. MCRO(99) will then be finished.
When MCRO(99) is executed, the same instruction pattern can be used as
needed simply by changing the first input word or the first output word.
The following restrictions apply when the macro function is used.
• The only words that can be used for each execution of the macro are the four
consecutive words beginning with the first input word number (for input) and
the four consecutive words beginning with the first output word (for output).
• The specified inputs and outputs must correctly correspond to the words used
in the subroutine.
• Even when the direct output method is used for outputs,subroutine results will
be actually reflected in the specified output words only when the subroutine
has been completed (step 3 above).
Note 1. In CQM1 PCs, IR 096 to IR 099 and IR 196 to IR 199 can be used as work
bits when MCRO(99) is not used.
2. In CPM1/CPM1A/SRM1 PCs, SR 232 through SR 239 can be used as work
bits when MCRO(99) is not used.
The first input word and the first output word can be specified not with I/O bits, but
also with other bits (such as HR bits, work bits, etc.) or with DM words.
Subroutines called by MCRO(99) are defined by SBN(92) and RET(93), just as
are ordinary subroutines.
128
Analog Settings (CQM1-CPU42-EV1/CPM1/CPM1A Only) Section 2-5
CQM1 Application Example When a macro is used, the program can be simplified as shown below.
10000 000
100
MCRO(99)
10500
090
00501 00502
SBN(92) 090
12001
09600 19601
01000 15001
19600
15000
19600
15000
RET(93)
CPM1/CPM1A/SRM1 The CPM1/CPM1A/SRM1 program can be simplified like the one shown above,
Application Example but words SR 232 through SR 235 would be used instead of IR 096 through
IR 099 and words SR 236 through SR 239 would be used instead of IR 196
through IR 199.
129
Analog Settings (CQM1-CPU42-EV1/CPM1/CPM1A Only) Section 2-5
The adjustment settings are stored in BCD and range from 0000 to 0200. Use a
precision screwdriver to adjust the settings. (Turn the switches clockwise to in-
crease the adjustment.)
CQM1-CPU42-EV1 Settings The CQM1-CPU42-EV1 has four analog adjustment controls. The following dia-
gram shows the CQM1-CPU42-EV1 adjustment controls and indicates the cor-
responding IR words that contain the adjustment settings.
In CQM1 CPU Units other than the CQM1-CPU42-EV1, IR 220 through IR 223
serve no special purpose. They can be used as work words in the program.
! Caution The CQM1-CPU42-EV1 continually refreshes IR 220 through IR 223 with the
adjustment settings as long as the power is on. Do not overwrite the content of
these words from the program or Peripheral Device.
CPM1/CPM1A Settings The CPM1/CPM1A PCs have two analog adjustment controls. The following
diagram shows the adjustment controls and indicates the corresponding SR
words that contain the adjustment settings. Use a phillips-head screwdriver to
adjust the settings.
Note The above diagram shows the CPM1, but the settings are the same for
CPM1A.
! Caution The analog setting may change with changing temperatures. Do not use the
analog adjustment controls for applications that require a precise, fixed setting.
130
Quick-response Inputs (CPM1/CPM1A Only) Section 2-6
Start condition
TIM SR 250 is specified as
000 the timer’s set value.
TIM 000
01003
Input signal
(00003)
IR 00003
One cycle
Setting Quick-response The input bits in the above table can be set as quick-response inputs in
Inputs DM 6628, as shown in the following table.
Word Settings
DM 6628 0: Normal input
1: Interrupt input
2: Quick-response input
(Default setting: 0)
Bit 15 0
DM 6628
131
Quick-response Inputs (CPM1/CPM1A Only) Section 2-6
Program Example
In this example, DM 6628 has been set to 0002.
132
SECTION 3
Memory Areas
This section describes the structure of the PC memory areas, and explains how to use them. It also describes the CQM1
Memory Cassette operations used to transfer data between the CQM1 CPU Unit and a Memory Cassette.
133
Using Memory Cassettes (CQM1 Only) Section 3-5
134
Using Memory Cassettes (CQM1 Only) Section 3-5
Note 1. IR and LR bits that are not used for their allocated functions can be used as
work bits.
2. At least 2,720 bits can be used as work bits. The total number of bits that can
be used depends on the configuration of the PC system.
3. When accessing a PV, TC numbers are used as word data; when accessing
Completion Flags, they are used as bit data.
4. Although the CQM1-CPU11-E and CQM1-CPU21-E do not support
DM 1024 through DM 6143, an error will not occur if they are addressed.
Any attempt to write to these words will have no effect and any reads will
produce all zeros.
5. Data in DM 6144 to DM 6655 cannot be overwritten from the program.
3-1-2 IR Area
The functions of the IR area are explained below.
Input and Output Area IR area bits are allocated to terminals on Input Units and Output Units. They re-
flect the ON/OFF status of input and output signals. Input bits begin at IR 00000,
and output bits begin at IR 10000. With the CQM1, only IR 00000 through
IR 01515 can be used as input bits and only IR 10000 through IR 11515 can be
used as output bits.
For information on allocating input and output bits, refer to page 139.
Note Input bits cannot be used in output instructions. Do not use the same output bit in
more than one OUT and/or OUT NOT instruction, or the program will not execute
properly.
Work Areas With the CQM1-CPU11/21-E and CQM1-CPU41-EV1 CPU Units, any of the bits
between IR 001 and IR 243 not used for specific functions can be used as work
bits. There are a few exceptions with the CQM1-CPU42/43/44-EV1 CPU Units,
as shown in the following table.
CPU Unit Bits Unavailable as Work Bits
CQM1-CPU42-EV1 IR 22000 to IR 22315
CQM1-CPU43/44-EV1 IR 23200 to IR 23915
The work bits can be used freely within the program. They can only be used with-
in the program, however, and not for direct external I/O. Work bits are reset (i.e.,
turned OFF) when the CQM1 power supply is turned off or when operation be-
gins or stops.
135
Using Memory Cassettes (CQM1 Only) Section 3-5
The bits in the ranges shown below have specific functions, but can still be used
as work bits when their specific functions are not being used.
Range Function
IR 001 to IR 015 When allocated to Input Units, these bits serve as input bits.
IR 096 to IR 099 When the MACRO instruction is used, these bits serve as oper-
and input bits.
IR 100 to IR 115 When allocated to Output Units, these bits serve as output bits.
IR 196 to IR 199 When the MACRO instruction is used, these bits serve as oper-
and output bits.
IR 220 to IR 223 In the CQM1-CPU42-EV1, these bits serve to store the analog
SV. They can be used as work bits in other CPU Units.
IR 230 to IR 231 When high-speed counter 0 is used, these bits are used to
store its present value.
IR 232 to IR 235 In the CQM1-CPU43/44-EV1, these bits are used to store the
present values for high-speed counters 1 and 2. They can be
used as work bits in other CPU Units.
IR 236 to IR 239 In the CQM1-CPU43-EV1, these bits are used to store the
present values for pulse outputs from ports 1 and 2. In the
CQM1-CPU44-EV1, they are used by the system. They can be
used as work bits in other CPU Units.
IR 200 to IR 215 and IR 240 to IR 243 will be used in future functions, but they can
be used as work bits for the time being.
LR 00 to LR 63 are used as link bits, but they can also be used as work bits when
not linked to another CQM1.
I/O Bit Allocation I/O words are allocated in order from the left, beginning with IR 001 for the Input
Unit and IR100 for the Output Unit. The CPU Unit’s input points are allocated to
IR 000. Even if the Input Unit and Output Unit are mounted at random the input
words and output words are in separate portions of the IR area.
One word is allocated even for 8-point I/O Units. Bit usage for 8-point I/O Units
are shown in the following table.
The number of I/O bits that can be allocated depends on the CQM1 CPU Unit
being used, as shown in the following table.
As many as 256 I/O bits (16 words) can be allocated for the CQM1. A 16-point
I/O Unit is allocated two words and must be counted as 16 points in calculating
the total.
Note The SYSMAC-CPT will display or print only 12 I/O words in the I/O table display
for the CQM1, i.e., IR 000 to IR 011. IR 012 to IR 015 will not be displayed for the
CQM1-CPU4-EV1 CPU Unit’s I/O table, even though it has an I/O capacity of
256 pts (16 words). You will be able to input IR 012 to IR 015 for the
CQM1-CPU4-EV1 CPU Unit and the program will execute correctly for these
bits, but “I” and “Q” will not be displayed to indicate input and output words/bits.
136
Using Memory Cassettes (CQM1 Only) Section 3-5
Cannot be used.
Work bits
15 8 7 0 15 8 7 0
IR 000 IR 100
IR 001 IR 101
IR 002 IR 102
IR 103
All bits in words beyond the last input word and output word allocated can be
used as work bits.
In order to make the word allocation easier to understand, and to help eliminate
problems with noise, it is recommended that all Input Units be mounted directly
following the CPU Unit. For the above example, the arrangement would be as
shown below.
The number of allocated input words is stored in BCD in AR 2200 to AR 2207; the
number of allocated output words in BCD in AR 2208 to AR 2215. The CQM1
PCs do not use an I/O table.
Note Up to 11 I/O Units can be mounted, regardless of the CPU Unit.
3-1-3 SR Area
These bits mainly serve as flags related to CQM1 operation. For details on the
various bit functions, refer to relevant sections in this manual or to Appendix C
Memory Areas.
SR 244 to SR 247 can also be used as work bits, when input interrupts are not
used in Counter Mode.
3-1-4 TR Area
When a complex ladder diagram cannot be programmed in mnemonic code just
as it is, these bits are used to temporarily store ON/OFF execution conditions at
program branches. They are used only for mnemonic code. When programming
directly with ladder diagrams using the Ladder Support Software (LSS) or the
SYSMAC Support Software (SSS), TR bits are automatically processed for you.
The same TR bits cannot be used more than once within the same instruction
block, but can be used again in different instruction blocks. The ON/OFF status
of TR bits cannot be monitored from a Peripheral Device.
Examples showing the use of TR bits in programming are provided on page 169.
3-1-5 HR Area
These bits retain their ON/OFF status even after the CQM1 power supply has
been turned off or when operation begins or stops. They are used in the same
way as work bits.
137
Using Memory Cassettes (CQM1 Only) Section 3-5
! Caution Never use an input bit in a NC condition on the reset (R) for KEEP(11) when the
input device uses an AC power supply (see diagram below). The delay in shut-
ting down the PC’s DC power supply relative to the AC power supply to the input
device can cause the designate bit of KEEP(11) to be reset.
A B
Set KEEP
HR0000
Input Unit
A
AC Reset
3-1-6 AR Area
These bits mainly serve as flags related to CQM1 operation. For details on the
various bit functions, refer to relevant sections in this manual or to Appendix C
Memory Areas.
With the exception of AR 23 (Power-off Counter), the status of AR words and bits
is refreshed each cycle. (AR 23 is refreshed only for power interruptions.)
3-1-7 LR Area
When the CQM1 is linked one to one with another CQM1, these bits are used to
share data. For details, refer to page 100.
LR bits can be used as work bits when not used for data links.
Note 1. TC numbers 000 through 015 and interrupt processing should be used for
TIMH(15) whenever the cycle time is longer than 10 ms. Using other timer/
counter numbers or not using interrupt processing will lead to inaccuracy in
the high-speed timers. Interrupt processing can be set in DM 6629 of the PC
Setup.
2. When the input condition turns OFF for TIM or TIMH(15), the PV is reset and
returns to the set value. The PV is also reset at the beginning of program
execution or when the interlock condition goes OFF in a interlocked pro-
gram section (IL–ILC). The PV for CNT or CNTR(12) is not reset like one for
the timer instruction, but rather is reset only when the reset input goes ON.
138
Using Memory Cassettes (CQM1 Only) Section 3-5
3-1-9 DM Area
Data is accessed in word units. As shown below, the DM area contains both an
area that can be freely used and areas with specific functions.
DM0000
This area has no specific functions and can be used
freely. Both reading and writing are possible from the
DM1024
program.
(see note 1)
DM6144 This area cannot be written from the program. It is used
Fixed DM for storing information that is not to be changed. Writing
(see note 2) can be executed by means of peripheral devices only.
DM6569
Error Log This area stores the error log. The user can only read this
area, and cannot write into it.
DM6600
PC Setup This area stores information related to CQM1 operation.
(see note 2) The settings are made by means of peripheral devices.
DM6655
3-1-10 UM Area
The UM area stores the user’s program. UM area contents can be read and writ-
ten only as program data, and not as words. The following table shows the size
of the UM area in the CQM1 CPU Units.
CPU Unit Model UM area size
CQM1-CPU11/21-E 3.2 KW
CQM1-CPU4-EV1 7.2 KW
139
Using Memory Cassettes (CQM1 Only) Section 3-5
3-2-2 IR Area
The functions of the IR area are explained below.
I/O Bits IR area bits from IR 00000 to IR 01915 are allocated to terminals on the CPU Unit
and I/O Units. They reflect the ON/OFF status of input and output signals. Input
bits begin at IR 00000, and output bits begin at IR 01000.
140
Using Memory Cassettes (CQM1 Only) Section 3-5
The following table shows which IR bits are allocated to the I/O terminals on the
CPM1 CPU Units and CPM1-20EDR I/O Unit.
CPM1 CPU Unit I/O CPU Unit Terminals I/O Unit Terminals
CPM1-10CDR- Inputs 6 points: 00000 to 00005 12 points: 00100 to 00111
Outputs 4 points: 01000 to 01003 8 points: 01100 to 01107
CPM1-20CDR- Inputs 12 points: 00000 to 00011 12 points: 00100 to 00111
Outputs 8 points: 01000 to 01007 8 points: 01100 to 01107
CPM1-30CDR- Inputs 18 points: 12 points: 00200 to 00211
00000 to 00011,
00100 to 00105
Outputs 12 points: 8 points: 01200 to 01207
01000 to 01007,
01100 to 01103
CPM1-30CDR- Inputs 18 points: 36 points: 00200 to 00211
-V1 00000 to 00011, 00300 to 00311
00100 to 00105 00400 to 00411
Outputs 12 points: 24 points:01200 to 01207
01000 to 01007, 01300 to 01407
01100 to 01103 01400 to 01407
The following table shows which IR bits are allocated to the I/O terminals on the
CPM1A’s CPU Units and Expansion I/O Unit.
Number CPU Unit terminals CPM1A-20ED Expansion I/O Unit Terminals Power Model
of I/O supply number
terminals
on the Inputs Outputs Inputs Outputs Inputs Outputs Inputs Outputs
CPU Unit
10 6 points: 4 points: --- --- --- --- --- --- AC CPM1A-
00000 to 01000 to 10CD-A
00005 01003 DC CPM1A-
10CD-D
20 12 points: 8 points: --- --- --- --- --- --- AC CPM1A-
00000 to 01000 to 20CD-A
00011 01007 DC CPM1A-
20CD-D
30 18 points: 12 points: 12 points: 8 points: 12 points: 8 points: 12 points: 8 points: AC CPM1A-
00000 to 01000 to 00200 to 01200 to 00300 to 01300 to 00400 to 01400 to 30CD-A
00011 01007 00211 01207 00311 01307 00411 01407
DC CPM1A-
00100 to 01100 to 30CD-D
00105 01103
40 24 points: 16 points: 12 points: 8 points: 12 points: 8 points: 12 points: 8 points: AC CPM1A-
00000 to 01000 to 00200 to 01200 to 00300 to 01300 to 00400 to 01400 to 40CD-A
00011 01007 00211 01207 00311 01307 00411 01407
DC CPM1A-
00100 to 01100 to 40CD-D
00111 01107
Work Bits The work bits can be used freely within the program. They can only be used with-
in the program, however, and not for direct external I/O.
3-2-3 SR Area
These bits mainly serve as flags related to CPM1/CPM1A operation or contain
present and set values for various functions. For details on the various bit func-
tions, refer to relevant sections in this manual or to Appendix C Memory Areas.
SR 244 to SR 247 can also be used as work bits, when input interrupts are not
used in Counter Mode.
141
Using Memory Cassettes (CQM1 Only) Section 3-5
3-2-4 TR Area
When a complex ladder diagram cannot be programmed in mnemonic code just
as it is, these bits are used to temporarily store ON/OFF execution conditions at
program branches. They are used only for mnemonic code. When programming
directly with ladder diagrams using the Ladder Support Software (LSS) or the
SYSMAC Support Software (SSS), TR bits are automatically processed for you.
The same TR bits cannot be used more than once within the same instruction
block, but can be used again in different instruction blocks. The ON/OFF status
of TR bits cannot be monitored from a Peripheral Device.
Examples showing the use of TR bits in programming are provided on page 169.
3-2-5 HR Area
These bits retain their ON/OFF status even after the CPM1/CPM1A power sup-
ply has been turned off or when operation begins or stops. They are used in the
same way as work bits.
3-2-6 AR Area
These bits mainly serve as flags related to CPM1/CPM1A operation. These bits
retain their status even after the CPM1/CPM1A power supply has been turned
off or when operation begins or stops. For details on the various bit functions,
refer to relevant sections in this manual or to Appendix C Memory Areas.
3-2-7 LR Area
When the CPM1/CPM1A is linked one-to-one with another CPM1/CPM1A, a
CQM1, an SRM1 or a C200HS PC, these bits are used to share data. For details,
refer to page 101.
LR bits can be used as work bits when not used for data links.
3-2-9 DM Area
DM area data is accessed in word units only. The contents of the DM area are
retained even after the CPM1/CPM1A power supply has been turned off or when
operation begins or stops.
DM words DM 0000 through DM 0999, DM 1022, and DM 1023 can be used
freely in the program; other DM words are allocated specific functions, de-
scribed below.
Error Log DM 1000 through DM 1021 contain the error log information. Refer to Section 8
Troubleshooting for details on the error log.
PC Setup DM 6600 through DM 6655 contain the PC Setup. Refer to 1-5 PC Setup for de-
tails.
142
Using Memory Cassettes (CQM1 Only) Section 3-5
143
Using Memory Cassettes (CQM1 Only) Section 3-5
3-3-2 IR Area
The functions of the IR area are explained below.
I/O Bits IR area bits from IR 00000 to IR 01915 are allocated to terminals on the CPU Unit
and I/O Unit. They reflect the ON/OFF status of input and output signals. Input
bits begin at IR 00000, and output bits begin at IR 01000.
Refer to 1-4 I/O and Data Area Allocation in the SRM1 Master Control Units Op-
eration Manual for further details.
Work Bits The work bits can be used freely within the program. They can only be used with-
in the program, however, and not for direct external I/O.
3-3-3 SR Area
These bits mainly serve as flags related to SRM1 operation or contain present
and set values for various functions. For details on the various bit functions, refer
to relevant sections in this manual or to Appendix C Memory Areas.
SR 240 to SR 247 and SR250, 251 can also be used as work bits, when input
interrupts are not used in Counter Mode. SR232 to SR239 can also be used as
work bits when the MCRO (99) instruction is not being used.
3-3-4 TR Area
When a complex ladder diagram cannot be programmed in mnemonic code just
as it is, these bits are used to temporarily store ON/OFF execution conditions at
program branches. They are used only for mnemonic code. When programming
directly with ladder diagrams using the Ladder Support Software (LSS) or the
SYSMAC Support Software (SSS), TR bits are automatically processed for you.
The same TR bits cannot be used more than once within the same instruction
block, but can be used again in different instruction blocks. The ON/OFF status
of TR bits cannot be monitored from a Peripheral Device.
Examples showing the use of TR bits in programming are provided on page 169.
144
Using Memory Cassettes (CQM1 Only) Section 3-5
3-3-5 HR Area
These bits retain their ON/OFF status even after the SRM1 power supply has
been turned off or when operation begins or stops. They are used in the same
way as work bits.
3-3-6 AR Area
These bits mainly serve as flags related to SRM1 operation. These bits retain
their status even after the SRM1 power supply has been turned off or when op-
eration begins or stops. For details on the various bit functions, refer to relevant
sections in this manual or to Appendix C Memory Areas.
3-3-7 LR Area
When the SRM1 is linked one-to-one with another SRM1, a CQM1, an
CPM1/CPM1A or a C200HS PC, these bits are used to share data. For details,
refer to page 101.
LR bits can be used as work bits when not used for data links.
3-3-9 DM Area
DM area data is accessed in word units only. The contents of the DM area are
retained even after the SRM1 power supply has been turned off or when opera-
tion begins or stops.
DM words DM 0000 through DM 1999, DM 2022, and DM 2047 can be used
freely in the program; other DM words are allocated specific functions, de-
scribed below.
Error Log DM 2000 through DM 2021 contain the error log information. Refer to Section 8
Troubleshooting for details on the error log.
PC Setup DM 6600 through DM 6655 contain the PC Setup. Refer to 1-5 PC Setup for de-
tails.
145
Using Memory Cassettes (CQM1 Only) Section 3-5
Changing Memory Areas When operating the SRM1 for the first time after changes have been made to the
UM area, the DM read only area (DM 6144 to DM 6599, and the PC Setup area
(DM 6600 to DM 6655), beware of the effect resulting from the SRM1’s delay in
the operation on other devices.
The first operation for the SRM1 after the above memory areas have been
changed will be a maximum of 850 ms later than the normal first operation with-
out changes.
Cycle Times A cycle time overflow warning will not be issued when any of the following opera-
tions are performed in either MONITOR or OPERATION modes. Be careful of
the effect of using online editing on SRM1 I/O response time.
• Changes to the program using online editing.
• Changes to the read-only DM area (DM 6144 to DM 6599.)
• Changes to the PC Setup area (DM 6600 to DM 6655.)
When any of the above operations are performed, the SRM1 cycle time will be
increased by a maximum of 850 ms. During this tiny interrupts will be disabled
while the program or memory contents is written.
Model Remarks
CQM1-ME04K EEPROM type (without clock) 4K words
CQM1-ME04R EEPROM type (with clock) 4K words
CQM1-MP08K EPROM type (without clock) 8K words
CQM1-MP08R EPROM type (with clock) 8K words
CQM1-ME08K EEPROM type (without clock) 8K words
CQM1-ME08R EEPROM type (with clock) 8K words
The following EEPROM chips (sold separately) are required for EPROM-type
Memory Cassettes.
For the CQM1 CPU Units, 8K words max. of information can be written to the
Memory Cassette. Therefore, any of the EPROM chips listed above would have
sufficient capacity, and the choice can be made strictly on the basis of ease of
purchase.
For instructions on using Memory Cassettes, refer to CQM1 Operation Manual.
146
Using Memory Cassettes (CQM1 Only) Section 3-5
Contents The information that can be written to a Memory Cassette is shown in the follow-
ing table.
Information Contents
Fixed DM Fixed Data Memory cannot be written from the program.
The range is DM 6144 to DM 6568. These words are avail-
able for the user.
PC Setup The PC Setup sets the operating parameters of the CQM1
and it stored in DM 6600 to DM 6655.
Instructions Table The instructions table assigns expansion instruction to func-
tion codes to enable using them in programming.
User Program The UM area holds the user’s program.
Memory (UM)
Program larger
than 3.2 KW X
X Program larger
than 3.2 KW
Note The two transfers shown above would be completed normally if the program
were 3.2 KW or smaller.
147
Using Memory Cassettes (CQM1 Only) Section 3-5
The approximate sizes of the programs in the UM area and Memory Cassette
can be determined by the content of AR 15, as shown in the following table.
Program Bits Content Meaning
location
Memory AR 1500 00 No Memory Cassette is installed or no program is
Cassette to saved in the Memory Cassette.
AR 1507 04 The program is less than 3.2 KW long and can be
read from any CQM1 CPU Unit.
08 The program is less than 7.2 KW long and can be
read from CQM1-CPU4-E/-EV1 CPU Units only.
UM area AR 1508 04 The program is less than 3.2 KW long and can be
to written to any Memory Cassette.
AR 1515 08 The program is less than 7.2 KW long and can be
written to 8-KW or larger Memory Cassettes only.
In CQM1-CPU11/21-E CPU Units, the content of AR 1508 to AR 1515 is normal-
ly 04, and the content of AR 1500 to AR 1507 is normally 04 when a 4-KW
Memory Cassette is installed.
The size of the program indicated in AR 15 does not include the NOP(00)
instructions after END(01), but will include any instructions other than NOP(00).
Be sure to clear any unneeded instructions after END(01) to get an accurate
measurement of the program’s size.
! Caution Data cannot be written to the Memory Cassette if a memory error has occurred.
Note If an error occurs while data is being transmitted, a non-fatal error (FAL 9D) will
be generated and the appropriate AR bit (from AR 1412 to AR 1415) will turn
ON/OFF. If this occurs, refer to Section 8 Troubleshooting and make the neces-
sary corrections.
148
Using Memory Cassettes (CQM1 Only) Section 3-5
Note When data is being read from the Memory Cassette to the CQM1, pin 1 of the
DIP switch on the CQM1 must be OFF (i.e., writing to the DM must be enabled).
Turn off the power to the CQM1 before turning this pin OFF.
Reading from the Memory Cassette can be executed regardless of the type of
Memory Cassette.
If an error occurs while data is being transmitted, a non-fatal error (FAL 9D) will
be generated and the appropriate AR bit (from AR 1412 to AR 1415 will turn ON/
OFF. (If this occurs, refer to the Troubleshooting section and make the neces-
sary correction.)
Peripheral Device Operation To use a peripheral device to read from the Memory Cassette, follow the proce-
dure outlined below.
1, 2, 3... 1. Check to see that the CQM1 is in PROGRAM mode. If it is in either RUN or
MONITOR mode, use the peripheral device to change the mode.
2. Use the peripheral device to turn ON AR 1401. The information will be read
from the Memory Cassette to the CQM1.
3. With the LSS/SSS, clear the forced-set status to turn OFF AR 1401, which
will not change even after the operation is complete. (If the Programming
Console is being used, AR 1401 will automatically turn OFF.)
Automatic Reading If pin 2 of the DIP switch on the CQM1 is turned ON (auto-boot), then data will
automatically be read from the Memory Cassette when the power supply is
turned on to the CQM1. Operation will not be possible if an error occurs during
transfer of data between the Memory Cassette and CQM1 memory.
! Caution Be absolutely sure that the power is turned off before changing CQM1 DIP
switch settings.
149
SECTION 4
Ladder-diagram Programming
This section explains the basic steps and concepts involved in writing a basic ladder diagram program. It introduces the
instructions that are used to build the basic structure of the ladder diagram and control its execution. The entire set of instruc-
tions used in programming is described in Section 5 Instruction Set.
151
Instruction Terminology Section 4-2
152
Basic Ladder Diagrams Section 4-3
00100 00002 00003 HR 0050 00007 TIM 001 LR 0515 00403 00405
Instruction
As shown in the diagram above, instruction lines can branch apart and they can
join back together. The vertical pairs of lines are called conditions. Conditions
without diagonal lines through them are called normally open conditions and
correspond to a LOAD, AND, or OR instruction. The conditions with diagonal
lines through them are called normally closed conditions and correspond to a
LOAD NOT, AND NOT, or OR NOT instruction. The number above each condi-
tion indicates the operand bit for the instruction. It is the status of the bit
associated with each condition that determines the execution condition for fol-
lowing instructions. The way the operation of each of the instructions corre-
sponds to a condition is described below. Before we consider these, however,
there are some basic terms that must be explained.
Note When displaying ladder diagrams with the SSS, a second bus bar will be shown
on the right side of the ladder diagram and will be connected to all instructions on
the right side. This does not change the ladder-diagram program in any function-
al sense. No conditions can be placed between the instructions on the right side
and the right bus bar, i.e., all instructions on the right must be connected directly
to the right bus bar. Refer to the SSS Operation Manual: C-series PCs for details.
00000
Instruction
Instruction is executed
when IR bit 00000 is ON.
Normally open
condition
00000
Instruction
Instruction is executed
when IR bit 00000 is OFF.
Normally closed
condition
153
Basic Ladder Diagrams Section 4-3
Execution Conditions In ladder diagram programming, the logical combination of ON and OFF condi-
tions before an instruction determines the compound condition under which the
instruction is executed. This condition, which is either ON or OFF, is called the
execution condition for the instruction. All instructions other than LOAD instruc-
tions have execution conditions.
Operand Bits The operands designated for any of the ladder instructions can be any bit in the
IR, SR, HR, AR, LR, or TC areas. This means that the conditions in a ladder dia-
gram can be determined by I/O bits, flags, work bits, timers/counters, etc. LOAD
and OUTPUT instructions can also use TR area bits, but they do so only in spe-
cial applications. Refer to 4-3-8 Branching Instruction Lines for details.
Logic Blocks The way that conditions correspond to what instructions is determined by the
relationship between the conditions within the instruction lines that connect
them. Any group of conditions that go together to create a logic result is called a
logic block. Although ladder diagrams can be written without actually analyzing
individual logic blocks, understanding logic blocks is necessary for efficient pro-
gramming and is essential when programs are to be input in mnemonic code.
Instruction Block An instruction block consists of all the instructions that are interconnected
across the ladder diagram. One instruction block thus consists of all the instruc-
tions between where you can draw a horizontal line across the ladder diagram
without intersecting any vertical lines and the next place where you can draw the
same type of horizontal line.
Program Memory Structure The program is input into addresses in Program Memory. Addresses in Program
Memory are slightly different to those in other memory areas because each ad-
dress does not necessarily hold the same amount of data. Rather, each address
holds one instruction and all of the definers and operands (described in more
detail later) required for that instruction. Because some instructions require no
operands, while others require up to three operands, Program Memory address-
es can be from one to four words long.
154
Basic Ladder Diagrams Section 4-3
Program Memory addresses start at 00000 and run until the capacity of Program
Memory has been exhausted. The first word at each address defines the instruc-
tion. Any definers used by the instruction are also contained in the first word.
Also, if an instruction requires only a single bit operand (with no definer), the bit
operand is also programmed on the same line as the instruction. The rest of the
words required by an instruction contain the operands that specify what data is
to be used. When converting to mnemonic code, all but ladder diagram instruc-
tions are written in the same form, one word to a line, just as they appear in the
ladder diagram symbols. An example of mnemonic code is shown below. The
instructions used in it are described later in the manual.
The address and instruction columns of the mnemonic code table are filled in for
the instruction word only. For all other lines, the left two columns are left blank. If
the instruction requires no definer or bit operand, the operand column is left
blank for first line. It is a good idea to cross through any blank data column
spaces (for all instruction words that do not require data) so that the data column
can be quickly scanned to see if any addresses have been left out.
155
Basic Ladder Diagrams Section 4-3
LOAD and LOAD NOT The first condition that starts any logic block within a ladder diagram corre-
sponds to a LOAD or LOAD NOT instruction. Each of these instruction requires
one line of mnemonic code. “Instruction” is used as a dummy instruction in the
following examples and could be any of the right-hand instructions described lat-
er in this manual.
00000
When this is the only condition on the instruction line, the execution condition for
the instruction at the right is ON when the condition is ON. For the LOAD instruc-
tion (i.e., a normally open condition), the execution condition would be ON when
IR 00000 was ON; for the LOAD NOT instruction (i.e., a normally closed condi-
tion), it would be ON when 00000 was OFF.
AND and AND NOT When two or more conditions lie in series on the same instruction line, the first
one corresponds to a LOAD or LOAD NOT instruction; and the rest of the condi-
tions, to AND or AND NOT instructions. The following example shows three
conditions which correspond in order from the left to a LOAD, an AND NOT, and
an AND instruction. Again, each of these instructions requires one line of mne-
monic code.
The instruction would have an ON execution condition only when all three condi-
tions are ON, i.e., when IR 00000 was ON, IR 00100 was OFF, and LR 0000 was
ON.
AND instructions in series can be considered individually, with each taking the
logical AND of the execution condition (i.e., the total of all conditions up to that
point) and the status of the AND instruction’s operand bit. If both of these are ON,
an ON execution condition will be produced for the next instruction. If either is
OFF, the result will also be OFF. The execution condition for the first AND
instruction in a series is the first condition on the instruction line.
Each AND NOT instruction in a series would take the logical AND between its
execution condition and the inverse of its operand bit.
156
Basic Ladder Diagrams Section 4-3
OR and OR NOT When two or more conditions lie on separate instruction lines running in parallel
and then joining together, the first condition corresponds to a LOAD or LOAD
NOT instruction; the rest of the conditions correspond to OR or OR NOT instruc-
tions. The following example shows three conditions which correspond in order
from the top to a LOAD NOT, an OR NOT, and an OR instruction. Again, each of
these instructions requires one line of mnemonic code.
00000
Instruction
00100
LR 0000
The instruction would have an ON execution condition when any one of the three
conditions was ON, i.e., when IR 00000 was OFF, when IR 00100 was OFF, or
when LR 0000 was ON.
OR and OR NOT instructions can be considered individually, each taking the
logical OR between its execution condition and the status of the OR instruction’s
operand bit. If either one of these were ON, an ON execution condition would be
produced for the next instruction.
Combining AND and OR When AND and OR instructions are combined in more complicated diagrams,
Instructions they can sometimes be considered individually, with each instruction performing
a logic operation on the execution condition and the status of the operand bit.
The following is one example. Study this example until you are convinced that
the mnemonic code follows the same logic flow as the ladder diagram.
00200
Here, an AND is taken between the status of IR 00000 and that of IR 00001 to
determine the execution condition for an OR with the status of IR 00200. The
result of this operation determines the execution condition for an AND with the
status of IR 00002, which in turn determines the execution condition for an AND
with the inverse (i.e., and AND NOT) of the status of IR 00003.
157
Basic Ladder Diagrams Section 4-3
158
Basic Ladder Diagrams Section 4-3
00000 00001
Instruction
END(01)
Program execution
ends here.
If there is no END instruction anywhere in the program, the program will not be
executed at all.
Now you have all of the instructions required to write simple input-output pro-
grams. Before we finish with ladder diagram basic and go onto inputting the pro-
gram into the PC, let’s look at logic block instruction (AND LOAD and OR LOAD),
which are sometimes necessary even with simple diagrams.
AND LOAD Although simple in appearance, the diagram below requires an AND LOAD
instruction.
00000 00002
Instruction
00001 00003
159
Basic Ladder Diagrams Section 4-3
The two logic blocks are indicated by dotted lines. Studying this example shows
that an ON execution condition will be produced when: either of the conditions in
the left logic block is ON (i.e., when either IR 00000 or IR 00001 is ON), and
when either of the conditions in the right logic block is ON (i.e., when either IR
00002 is ON or IR 00003 is OFF).
The above ladder diagram cannot, however, be converted to mnemonic code
using AND and OR instructions alone. If an AND between IR 00002 and the re-
sults of an OR between IR 00000 and IR 00001 is attempted, the OR NOT be-
tween IR 00002 and IR 00003 is lost and the OR NOT ends up being an OR NOT
between just IR 00003 and the result of an AND between IR 00002 and the first
OR. What we need is a way to do the OR (NOT)’s independently and then com-
bine the results.
To do this, we can use the LOAD or LOAD NOT instruction in the middle of an
instruction line. When LOAD or LOAD NOT is executed in this way, the current
execution condition is saved in special buffers and the logic process is begun
over. To combine the results of the current execution condition with that of a pre-
vious “unused” execution condition, an AND LOAD or an OR LOAD instruction is
used. Here “LOAD” refers to loading the last unused execution condition. An un-
used execution condition is produced by using the LOAD or LOAD NOT instruc-
tion for any but the first condition on an instruction line.
Analyzing the above ladder diagram in terms of mnemonic instructions, the
condition for IR 00000 is a LOAD instruction and the condition below it is an OR
instruction between the status of IR 00000 and that of IR 00001. The condition at
IR 00002 is another LOAD instruction and the condition below is an OR NOT
instruction, i.e., an OR between the status of IR 00002 and the inverse of the
status of IR 00003. To arrive at the execution condition for the instruction at the
right, the logical AND of the execution conditions resulting from these two blocks
would have to be taken. AND LOAD does this. The mnemonic code for the lad-
der diagram is shown below. The AND LOAD instruction requires no operands of
its own, because it operates on previously determined execution conditions.
Here too, dashes are used to indicate that no operands needs designated or in-
put.
OR LOAD The following diagram requires an OR LOAD instruction between the top logic
block and the bottom logic block. An ON execution condition would be produced
for the instruction at the right either when IR 00000 is ON and IR 00001 is OFF or
when IR 00002 and IR 00003 are both ON. The operation of and mnemonic code
for the OR LOAD instruction is exactly the same as those for a AND LOAD
instruction except that the current execution condition is ORed with the last un-
used execution condition.
00000 00001
Instruction
00002 00003
Naturally, some diagrams will require both AND LOAD and OR LOAD instruc-
tions.
160
Basic Ladder Diagrams Section 4-3
Logic Block Instructions in To code diagrams with logic block instructions in series, the diagram must be
Series divided into logic blocks. Each block is coded using a LOAD instruction to code
the first condition, and then AND LOAD or OR LOAD is used to logically combine
the blocks. With both AND LOAD and OR LOAD there are two ways to achieve
this. One is to code the logic block instruction after the first two blocks and then
after each additional block. The other is to code all of the blocks to be combined,
starting each block with LOAD or LOAD NOT, and then to code the logic block
instructions which combine them. In this case, the instructions for the last pair of
blocks should be combined first, and then each preceding block should be com-
bined, working progressively back to the first block. Although either of these
methods will produce exactly the same result, the second method, that of coding
all logic block instructions together, can be used only if eight or fewer blocks are
being combined, i.e., if seven or fewer logic block instructions are required.
Again, with the method on the right, a maximum of eight blocks can be com-
bined. There is no limit to the number of blocks that can be combined with the
first method.
00000 00001
10001
00002 00003
00004 00005
161
Basic Ladder Diagrams Section 4-3
The first of each pair of conditions is converted to LOAD with the assigned bit
operand and then ANDed with the other condition. The first two blocks can be
coded first, followed by OR LOAD, the last block, and another OR LOAD, or the
three blocks can be coded first followed by two OR LOADs. The mnemonic code
for both methods is shown below.
Again, with the method on the right, a maximum of eight blocks can be com-
bined. There is no limit to the number of blocks that can be combined with the
first method.
Combining AND LOAD and Both of the coding methods described above can also be used when using AND
OR LOAD LOAD and OR LOAD, as long as the number of blocks being combined does not
exceed eight.
The following diagram contains only two logic blocks as shown. It is not neces-
sary to further separate block b components, because it can coded directly using
only AND and OR.
00201
00004
Block Block
a b
Although the following diagram is similar to the one above, block b in the diagram
below cannot be coded without separating it into two blocks combined with OR
LOAD. In this example, the three blocks have been coded first and then OR
LOAD has been used to combine the last two blocks followed by AND LOAD to
combine the execution condition produced by the OR LOAD with the execution
condition of block a.
162
Basic Ladder Diagrams Section 4-3
When coding the logic block instructions together at the end of the logic blocks
they are combining, they must, as shown below, be coded in reverse order, i.e.,
the logic block instruction for the last two blocks is coded first, followed by the
one to combine the execution condition resulting from the first logic block
instruction and the execution condition of the logic block third from the end, and
on back to the first logic block that is being combined.
Block
b1
00004 00202
Block
b2
Block Block
a b
Complicated Diagrams When determining what logic block instructions will be required to code a dia-
gram, it is sometimes necessary to break the diagram into large blocks and then
continue breaking the large blocks down until logic blocks that can be coded
without logic block instructions have been formed. These blocks are then coded,
combining the small blocks first, and then combining the larger blocks. Either
AND LOAD or OR LOAD is used to combine the blocks, i.e., AND LOAD or OR
LOAD always combines the last two execution conditions that existed, regard-
less of whether the execution conditions resulted from a single condition, from
logic blocks, or from previous logic block instructions.
When working with complicated diagrams, blocks will ultimately be coded start-
ing at the top left and moving down before moving across. This will generally
mean that, when there might be a choice, OR LOAD will be coded before AND
LOAD.
163
Basic Ladder Diagrams Section 4-3
The following diagram must be broken down into two blocks and each of these
then broken into two blocks before it can be coded. As shown below, blocks a
and b require an AND LOAD. Before AND LOAD can be used, however, OR
LOAD must be used to combine the top and bottom blocks on both sides, i.e., to
combine a1 and a2; b1 and b2.
Block Block
a1 b1
Block Block
a2 b2
Block Block
a b
The following type of diagram can be coded easily if each block is coded in order:
first top to bottom and then left to right. In the following diagram, blocks a and b
would be combined using AND LOAD as shown above, and then block c would
be coded and a second AND LOAD would be used to combined it with the execu-
tion condition from the first AND LOAD. Then block d would be coded, a third
AND LOAD would be used to combine the execution condition from block d with
the execution condition from the second AND LOAD, and so on through to block
n.
10000
164
Basic Ladder Diagrams Section 4-3
Although the program will execute as written, this diagram could be drawn as
shown below to eliminate the need for the first OR LOAD and the AND LOAD,
simplifying the program and saving memory space.
The following diagram requires five blocks, which here are coded in order before
using OR LOAD and AND LOAD to combine them starting from the last two
blocks and working backward. The OR LOAD at program address 00008 com-
bines blocks blocks d and e, the following AND LOAD combines the resulting
execution condition with that of block c, etc.
165
Basic Ladder Diagrams Section 4-3
Again, this diagram can be redrawn as follows to simplify program structure and
coding and to save memory space.
00005
00001 00002
The next and final example may at first appear very complicated but can be
coded using only two logic block instructions. The diagram appears as follows:
Block a
10000
Block b Block c
166
Basic Ladder Diagrams Section 4-3
The first logic block instruction is used to combine the execution conditions re-
sulting from blocks a and b, and the second one is to combine the execution
condition of block c with the execution condition resulting from the normally
closed condition assigned IR 00003. The rest of the diagram can be coded with
OR, AND, and AND NOT instructions. The logical flow for this and the resulting
code are shown below.
Block a Block b
LD 00000 LD 01000
AND 00001 AND 01001
OR LD
Block c
OR 10000 LD 00004
AND 00005
AND LD
10000
167
Basic Ladder Diagrams Section 4-3
Branching
00000 point 00001
Instruction 1 Address Instruction Operands
00002 00000 LD 00000
Instruction 2
00001 AND 00001
Diagram B: Incorrect Operation 00002 Instruction 1
00003 AND 00002
00004 Instruction 2
If, as shown in diagram A, the execution condition that existed at the branching
point cannot be changed before returning to the branch line (instructions at the
far right do not change the execution condition), then the branch line will be
executed correctly and no special programming measure is required.
If, as shown in diagram B, a condition exists between the branching point and the
last instruction on the top instruction line, the execution condition at the branch-
ing point and the execution condition after completing the top instruction line will
sometimes be different, making it impossible to ensure correct execution of the
branch line.
There are two means of programming branching programs to preserve the
execution condition. One is to use TR bits; the other, to use interlocks
(IL(02)/IL(03)).
168
Basic Ladder Diagrams Section 4-3
TR Bits The TR area provides eight bits, TR 0 through TR 7, that can be used to tempo-
rarily preserve execution conditions. If a TR bit is placed at a branching point, the
current execution condition will be stored at the designated TR bit. When return-
ing to the branching point, the TR bit restores the execution status that was
saved when the branching point was first reached in program execution.
The previous diagram B can be written as shown below to ensure correct execu-
tion. In mnemonic code, the execution condition is stored at the branching point
using the TR bit as the operand of the OUTPUT instruction. This execution
condition is then restored after executing the right-hand instruction by using the
same TR bit as the operand of a LOAD instruction
In terms of actual instructions the above diagram would be as follows: The status
of IR 00000 is loaded (a LOAD instruction) to establish the initial execution
condition. This execution condition is then output using an OUTPUT instruction
to TR 0 to store the execution condition at the branching point. The execution
condition is then ANDed with the status of IR 00001 and instruction 1 is executed
accordingly. The execution condition that was stored at the branching point is
then re-loaded (a LOAD instruction with TR 0 as the operand), this is ANDed with
the status of IR 00002, and instruction 2 is executed accordingly.
In this example, TR 0 and TR 1 are used to store the execution conditions at the
branching points. After executing instruction 1, the execution condition stored in
TR 1 is loaded for an AND with the status IR 00003. The execution condition
stored in TR 0 is loaded twice, the first time for an AND with the status of IR
00004 and the second time for an AND with the inverse of the status of IR 00005.
169
Basic Ladder Diagrams Section 4-3
TR bits can be used as many times as required as long as the same TR bit is not
used more than once in the same instruction block. Here, a new instruction block
is begun each time execution returns to the bus bar. If, in a single instruction
block, it is necessary to have more than eight branching points that require the
execution condition be saved, interlocks (which are described next) must be
used.
When drawing a ladder diagram, be careful not to use TR bits unless necessary.
Often the number of instructions required for a program can be reduced and
ease of understanding a program increased by redrawing a diagram that would
otherwise required TR bits. In both of the following pairs of diagrams, the bottom
versions require fewer instructions and do not require TR bits. In the first exam-
ple, this is achieved by reorganizing the parts of the instruction block: the bottom
one, by separating the second OUTPUT instruction and using another LOAD
instruction to create the proper execution condition for it.
TR 0 00000 00003
00000 00001
Instruction 1
Instruction 1
Instruction 2 TR 0
00001 00002
00004
Instruction 2
00000
Instruction 2
00001
Instruction 1
00000
00001 00004
Instruction 2
Note TR bits are must be input by the user only when programming using mnemonic
code. They are not necessary when inputting ladder diagrams directly because
they are processed for you automatically. The above limitations on the number
of branching points requiring TR bits, and considerations on methods to reduce
the number of programming instructions, still hold.
Interlocks The problem of storing execution conditions at branching points can also be
handled by using the INTERLOCK (IL(02)) and INTERLOCK CLEAR (ILC(03))
instructions to eliminate the branching point completely while allowing a specific
execution condition to control a group of instructions. The INTERLOCK and IN-
TERLOCK CLEAR instructions are always used together.
170
Basic Ladder Diagrams Section 4-3
Diagram B can also be corrected with an interlock. Here, the conditions leading
up to the branching point are placed on an instruction line for the INTERLOCK
instruction, all of lines leading from the branching point are written as separate
instruction lines, and another instruction line is added for the INTERLOCK
CLEAR instruction. No conditions are allowed on the instruction line for INTER-
LOCK CLEAR. Note that neither INTERLOCK nor INTERLOCK CLEAR re-
quires an operand.
00000
IL(02) Address Instruction Operands
00001 00000 LD 00000
Instruction 1 00001 IL(02) ---
00002 00002 LD 00001
Instruction 2 00003 Instruction 1
00004 LD 00002
ILC(03) 00005 Instruction 2
00006 ILC(03) ---
As shown in the following diagram, more than one INTERLOCK instruction can
be used within one instruction block; each is effective through the next INTER-
LOCK CLEAR instruction.
00000
IL(02)
Address Instruction Operands
00001 00000 LD 00000
Instruction 1 00001 IL(02) ---
00002 LD 00001
00002
IL(02) 00003 Instruction 1
00004 LD 00002
00003 00004
00005 IL(02) ---
Instruction 2
00006 LD 00003
00005
Instruction 3
00007 AND NOT 00004
00008 Instruction 2
00006
Instruction 4 00009 LD 00005
00010 Instruction 3
00011 LD 00006
ILC(03)
00012 Instruction 4
00013 ILC(03) ---
171
Basic Ladder Diagrams Section 4-3
If IR 00000 in the above diagram is OFF (i.e., if the execution condition for the
first INTERLOCK instruction is OFF), instructions 1 through 4 would be
executed with OFF execution conditions and execution would move to the
instruction following the INTERLOCK CLEAR instruction. If IR 00000 is ON, the
status of IR 00001 would be loaded as the execution condition for instruction 1
and then the status of IR 00002 would be loaded to form the execution condition
for the second INTERLOCK instruction. If IR 00002 is OFF, instructions 2
through 4 will be executed with OFF execution conditions. If IR 00002 is ON, IR
00003, IR 00005, and IR 00006 will determine the first execution condition in
new instruction lines.
4-3-9 Jumps
A specific section of a program can be skipped according to a designated execu-
tion condition. Although this is similar to what happens when the execution
condition for an INTERLOCK instruction is OFF, with jumps, the operands for all
instructions maintain status. Jumps can therefore be used to control devices
that require a sustained output, e.g., pneumatics and hydraulics, whereas inter-
locks can be used to control devices that do not required a sustained output,
e.g., electronic instruments.
Jumps are created using the JUMP (JMP(04)) and JUMP END (JME(05))
instructions. If the execution condition for a JUMP instruction is ON, the program
is executed normally as if the jump did not exist. If the execution condition for the
JUMP instruction is OFF, program execution moves immediately to a JUMP
END instruction without changing the status of anything between the JUMP and
JUMP END instruction.
All JUMP and JUMP END instructions are assigned jump numbers ranging be-
tween 00 and 99. There are two types of jumps. The jump number used deter-
mines the type of jump.
A jump can be defined using jump numbers 01 through 99 only once, i.e., each of
these numbers can be used once in a JUMP instruction and once in a JUMP
END instruction. When a JUMP instruction assigned one of these numbers is
executed, execution moves immediately to the JUMP END instruction that has
the same number as if all of the instruction between them did not exist. Diagram
B from the TR bit and interlock example could be redrawn as shown below using
a jump. Although 01 has been used as the jump number, any number between
01 and 99 could be used as long as it has not already been used in a different part
of the program. JUMP and JUMP END require no other operand and JUMP END
never has conditions on the instruction line leading to it.
00000
JMP(04) 01 Address Instruction Operands
00001 00000 LD 00000
Instruction 1
00001 JMP(04) 01
00002 00002 LD 00001
Instruction 2
00003 Instruction 1
00004 LD 00002
JME(05) 01
00005 Instruction 2
00006 JME(05) 01
Diagram B: Corrected with a Jump
This version of diagram B would have a shorter execution time when IR 00000
was OFF than any of the other versions.
172
Controlling Bit Status Section 4-4
The other type of jump is created with a jump number of 00. As many jumps as
desired can be created using jump number 00 and JUMP instructions using 00
can be used consecutively without a JUMP END using 00 between them. It is
even possible for all JUMP 00 instructions to move program execution to the
same JUMP END 00, i.e., only one JUMP END 00 instruction is required for all
JUMP 00 instruction in the program. When 00 is used as the jump number for a
JUMP instruction, program execution moves to the instruction following the next
JUMP END instruction with a jump number of 00. Although, as in all jumps, no
status is changed and no instructions are executed between the JUMP 00 and
JUMP END 00 instructions, the program must search for the next JUMP END 00
instruction, producing a slightly longer execution time.
Execution of programs containing multiple JUMP 00 instructions for one JUMP
END 00 instruction is similar to that of interlocked sections. The following dia-
gram is the same as that used for the interlock example above, except redrawn
with jumps. The execution of this diagram would differ from that of the diagram
described above (e.g., in the previous diagram interlocks would reset certain
parts of the interlocked section, however, jumps do not affect the status of any bit
between the JUMP and JUMP END instructions).
00000
JMP(04) 00 Address Instruction Operands
00000 LD 00000
00001
Instruction 1 00001 JMP(04) 00
00002 LD 00001
00002 00003 Instruction 1
JMP(04) 00
00004 LD 00002
00003 00004 00005 JMP(04) 00
Instruction 2 00006 LD 00003
00005 00007 AND NOT 00004
Instruction 3 00008 Instruction 2
00006 00009 LD 00005
Instruction 4
00010 Instruction 3
00011 LD 00006
JME(05) 00 00012 Instruction 4
00013 JME(05) 00
173
Controlling Bit Status Section 4-4
SET will turn ON the operand bit when the execution condition goes ON, but un-
like the OUTPUT instruction, SET will not turn OFF the operand bit when the
execution condition goes OFF. RESET will turn OFF the operand bit when the
execution condition goes OFF, but unlike OUTPUT NOT, RESET will not turn ON
the operand bit when the execution condition goes OFF.
Here, IR 01000 will be turned ON for one cycle after IR 00000 goes ON. The next
time DIFU(13) 01000 is executed, IR 01000 will be turned OFF, regardless of the
status of IR 00000. With the DIFFERENTIATE DOWN instruction, IR 01001 will
be turned ON for one cycle after IR 00001 goes OFF (IR 01001 will be kept OFF
until then), and will be turned OFF the next time DIFD(14) 01001 is executed.
4-4-3 KEEP
The KEEP instruction is used to maintain the status of the operand bit based on
two execution conditions. To do this, the KEEP instruction is connected to two
instruction lines. When the execution condition at the end of the first instruction
line is ON, the operand bit of the KEEP instruction is turned ON. When the
execution condition at the end of the second instruction line is ON, the operand
bit of the KEEP instruction is turned OFF. The operand bit for the KEEP instruc-
tion will maintain its ON or OFF status even if it is located in an interlocked sec-
tion of the diagram.
174
Work Bits (Internal Relays) Section 4-5
175
Work Bits (Internal Relays) Section 4-5
Work Bit Applications Examples given later in this subsection show two of the most common ways to
employ work bits. These should act as a guide to the almost limitless number of
ways in which the work bits can be used. Whenever difficulties arise in program-
ming a control action, consideration should be given to work bits and how they
might be used to simplify programming.
Work bits are often used with the OUTPUT, OUTPUT NOT, DIFFERENTIATE
UP, DIFFERENTIATE DOWN, and KEEP instructions. The work bit is used first
as the operand for one of these instructions so that later it can be used as a
condition that will determine how other instructions will be executed. Work bits
can also be used with other instructions, e.g., with the SHIFT REGISTER
instruction (SFT(10)). An example of the use of work words and bits with the
SHIFT REGISTER instruction is provided in 5-16-1 SHIFT REGISTER –
SFT(10).
Although they are not always specifically referred to as work bits, many of the
bits used in the examples in Section 5 Instruction Set use work bits. Understand-
ing the use of these bits is essential to effective programming.
Reducing Complex Work bits can be used to simplify programming when a certain combination of
Conditions conditions is repeatedly used in combination with other conditions. In the follow-
ing example, IR 00000, IR 00001, IR 00002, and IR 00003 are combined in a
logic block that stores the resulting execution condition as the status of
IR 21600. IR 21600 is then combined with various other conditions to determine
output conditions for IR 10000, IR 10001, and IR 10002, i.e., to turn the outputs
allocated to these bits ON or OFF.
00000 00001
Address Instruction Operands
21600 00000 LD 00000
00001 AND NOT 00001
00002 00002 OR 00002
00003 OR NOT 00003
00004 OUT 21600
00003 00005 LD 21600
00006 AND 00004
00007 AND NOT 00005
21600 00004 00005
10000
00008 OUT 10000
00009 LD 21600
00010 OR NOT 00004
21600 00005
00011 AND 00005
10001
00012 OUT 10001
00013 LD NOT 21600
00004
00014 OR 00006
00015 OR 00007
21600 00016 OUT 10002
10002
00006
00007
176
Programming Precautions Section 4-6
Differentiated Conditions Work bits can also be used if differential treatment is necessary for some, but not
all, of the conditions required for execution of an instruction. In this example, IR
10000 must be left ON continuously as long as IR 001001 is ON and both IR
00002 and IR 00003 are OFF, or as long as IR 00004 is ON and IR 00005 is OFF.
It must be turned ON for only one cycle each time IR 00000 turns ON (unless one
of the preceding conditions is keeping it ON continuously).
This action is easily programmed by using IR 22500 as a work bit as the operand
of the DIFFERENTIATE UP instruction (DIFU(13)). When IR 00000 turns ON, IR
22500 will be turned ON for one cycle and then be turned OFF the next cycle by
DIFU(13). Assuming the other conditions controlling IR 10000 are not keeping it
ON, the work bit IR 22500 will turn IR 10000 ON for one cycle only.
00000
Address Instruction Operands
DIFU(13) 22500
00000 LD 00000
22500 00001 DIFU(13) 22500
10000
00002 LD 22500
00001 00002 00003 00003 LD 00001
00004 AND NOT 00002
00004 00005 00005 AND NOT 00003
00006 OR LD ---
00007 LD 00004
00008 AND NOT 00005
00009 OR LD ---
00010 OUT 10000
00000 00002
Instruction 1
00004
00001 00003
Instruction 2
177
Programming Precautions Section 4-6
The number of times any particular bit can be assigned to conditions is not lim-
ited, so use them as many times as required to simplify your program. Often,
complicated programs are the result of attempts to reduce the number of times a
bit is used.
Except for instructions for which conditions are not allowed (e.g., INTERLOCK
CLEAR and JUMP END, see below), every instruction line must also have at
least one condition on it to determine the execution condition for the instruction
at the right. Again, diagram A , below, must be drawn as diagram B. If an instruc-
tion must be continuously executed (e.g., if an output must always be kept ON
while the program is being executed), the Always ON Flag (SR 25313) in the SR
area can be used.
Instruction
25313
Instruction Address Instruction Operands
00000 LD 25313
Diagram B: Correct Version 00001 Instruction
There are a few exceptions to this rule, including the INTERLOCK CLEAR,
JUMP END, and step instructions. Each of these instructions is used as the se-
cond of a pair of instructions and is controlled by the execution condition of the
first of the pair. Conditions should not be placed on the instruction lines leading to
these instructions. Refer to Section 5 Instruction Set for details.
Diagram B
178
Program Execution Section 4-7
179
SECTION 5
Instruction Set
The CQM1 and CPM1 have large programming instruction sets that allow for easy programming of complicated control pro-
cesses. This section explains instructions individually and provides the ladder diagram symbol, data areas, and flags used with
each.
The many instructions provided by these PCs are organized in the following subsections by instruction group. These groups
include Ladder Diagram Instructions, instructions with fixed function codes, and set instructions.
Some instructions, such as Timer and Counter instructions, are used to control execution of other instructions, e.g., a TIM
Completion Flag might be used to turn ON a bit when the time period set for the timer has expired. Although these other
instructions are often used to control output bits through the Output instruction, they can be used to control execution of other
instructions as well. The Output instructions used in examples in this manual can therefore generally be replaced by other
instructions to modify the program for specific applications other than controlling output bits directly.
5-1 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5-2 Instruction Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5-3 Data Areas, Definer Values, and Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
5-4 Differentiated Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
5-5 Coding Right-hand Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
5-6 Instruction Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
5-6-1 CQM1 Function Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
5-6-2 CPM1/CPM1A Function Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
5-6-3 SRM1 Function Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
5-6-4 Alphabetic List by Mnemonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
5-7 Ladder Diagram Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
5-7-1 LOAD, LOAD NOT, AND, AND NOT, OR, and OR NOT . . . . . . . . . . . . . . . . . 196
5-7-2 AND LOAD and OR LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
5-8 Bit Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
5-8-1 OUTPUT and OUTPUT NOT – OUT and OUT NOT . . . . . . . . . . . . . . . . . . . . . 197
5-8-2 SET and RESET – SET and RSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
5-8-3 KEEP – KEEP(11) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
5-8-4 DIFFERENTIATE UP and DOWN – DIFU(13) and DIFD(14) . . . . . . . . . . . . . . 200
5-9 NO OPERATION – NOP(00) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
5-10 END – END(01) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
5-11 INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03) . . . . . . . . . . . . . . . . . . . . 201
5-12 JUMP and JUMP END – JMP(04) and JME(05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
5-13 User Error Instructions:
FAILURE ALARM AND RESET – FAL(06) and
SEVERE FAILURE ALARM – FALS(07) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
5-14 Step Instructions:
STEP DEFINE and STEP START–STEP(08)/SNXT(09) . . . . . . . . . . . . . . . . . . . . . . . . . . 206
5-15 Timer and Counter Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
5-15-1 TIMER – TIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
5-15-2 COUNTER – CNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
5-15-3 REVERSIBLE COUNTER – CNTR(12) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
5-15-4 HIGH-SPEED TIMER – TIMH(15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
5-15-5 INTERVAL TIMER – STIM(69) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
5-15-6 REGISTER COMPARISON TABLE – CTBL(63) . . . . . . . . . . . . . . . . . . . . . . . . 215
5-15-7 MODE CONTROL – INI(61) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
5-15-8 HIGH-SPEED COUNTER PV READ – PRV(62) . . . . . . . . . . . . . . . . . . . . . . . . 221
5-16 Shift Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
5-16-1 SHIFT REGISTER – SFT(10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
5-16-2 WORD SHIFT – WSFT(16) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
5-16-3 ARITHMETIC SHIFT LEFT – ASL(25) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
5-16-4 ARITHMETIC SHIFT RIGHT – ASR(26) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
5-16-5 ROTATE LEFT – ROL(27) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
5-16-6 ROTATE RIGHT – ROR(28) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
5-16-7 ONE DIGIT SHIFT LEFT – SLD(74) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
5-16-8 ONE DIGIT SHIFT RIGHT – SRD(75) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
5-16-9 REVERSIBLE SHIFT REGISTER – SFTR(84) . . . . . . . . . . . . . . . . . . . . . . . . . . 229
5-16-10 ASYNCHRONOUS SHIFT REGISTER – ASFT(17) . . . . . . . . . . . . . . . . . . . . . 230
181
Section
182
Section
183
Data Areas, Definer Values, and Flags Section 5-3
5-1 Notation
In the remainder of this manual, all instructions will be referred to by their mne-
monics. For example, the OUTPUT instruction will be called OUT; the AND
LOAD instruction, AND LD. If you’re not sure of the instruction a mnemonic is
used for, refer to Appendix A Programming Instructions.
If an instruction is assigned a function code, it will be given in parentheses after
the mnemonic. These function codes, which are 2-digit decimal numbers, are
used to input most instructions into the CPU Unit. A table of instructions listed in
order of function codes is also provided in Appendix A Programming Instruc-
tions. Lists of instructions are also provided in 5-6 Instruction Tables.
An @ before a mnemonic indicates the differentiated version of that instruction.
Differentiated instructions are explained in Section 5-4.
! Caution The IR and SR areas are considered as separate data areas. If an operand has
access to one area, it doesn’t necessarily mean that the same operand will have
access to the other area. The border between the IR and SR areas can, howev-
er, be crossed for a single operand, i.e., the last bit in the IR area may be speci-
fied for an operand that requires more than one word as long as the SR area is
also allowed for that operand.
184
Data Areas, Definer Values, and Flags Section 5-3
The Flags subsection lists flags that are affected by execution of an instruction.
These flags include the following SR area flags.
Indirect Addressing When the DM area is specified for an operand, an indirect address can be used.
Indirect DM addressing is specified by placing an asterisk before the DM: DM.
Word Content
MOV(21)
DM 0000 4C59
DM 0001
DM 0001 1111
LR 00 Indirect Indicates
DM 0002 F35A
address DM 1111.
DM 1111 5555
DM 1113 2506 5555 moved
DM 1114 D541 to LR 00.
When using indirect addressing, the address of the desired word must be in BCD
and it must specify a word within the DM area. In the above example, the content
of DM 0000 would have to be in BCD between 0000 and 1999.
Designating Constants Although data area addresses are most often given as operands, many oper-
ands and all definers are input as constants. The available value range for a giv-
en definer or operand depends on the particular instruction that uses it.
Constants must also be entered in the form required by the instruction, i.e., in
BCD or in hexadecimal.
185
Coding Right-hand Instructions Section 5-5
HR 10
00000 LD 00000
00001 MOV(21)
Diagram A DM 0000
HR 10
DM 0000
00000
@MOV(21) Address Instruction Operands
HR 10 00000 LD 00000
Diagram B DM 0000 00001 @MOV(21)
HR 10
DM 0000
186
Coding Right-hand Instructions Section 5-5
The first word of any instruction defines the instruction and provides any defin-
ers. If the instruction requires only a signal bit operand with no definer, the bit
operand is also placed on the same line as the mnemonic. All other operands are
placed on lines after the instruction line, one operand per line and in the same
order as they appear in the ladder symbol for the instruction.
The address and instruction columns of the mnemonic code table are filled in for
the instruction word only. For all other lines, the left two columns are left blank. If
the instruction requires no definer or bit operand, the data column is left blank for
first line. It is a good idea to cross through any blank data column spaces (for all
instruction words that do not require data) so that the data column can be quickly
scanned to see if any addresses have been left out.
If an IR or SR address is used in the data column, the left side of the column is left
blank. If any other data area is used, the data area abbreviation is placed on the
left side and the address is placed on the right side. If a constant to be input, the
number symbol (#) is placed on the left side of the data column and the number
to be input is placed on the right side. Any numbers input as definers in the
instruction word do not require the number symbol on the right side. TC bits,
once defined as a timer or counter, take a TIM (timer) or CNT (counter) prefix.
When coding an instruction that has a function code, be sure to write in the func-
tion code, which will be necessary when inputting the instruction via the Pro-
gramming Console. Also be sure to designate the differentiated instruction with
the @ symbol.
Note The mnemonics of expansion instructions are followed by “(––)” as the function
code to indicate that they must be assigned function codes by the user in the
instructions table before they can be used in programming. Refer to page 116 for
details.
187
Coding Right-hand Instructions Section 5-5
The following diagram and corresponding mnemonic code illustrates the points
described above.
00000 00001
Address Instruction Data
DIFU(13) 21600 00000 LD 00000
00002
00001 AND 00001
00002 OR 00002
00100 00200 21600 00003 DIFU(13) 21600
BCNT(67)
00004 LD 00100
01001 01002 LR 6300 #0001
00005 AND NOT 00200
004
00006 LD 01001
HR 00
00007 AND NOT 01002
00008 AND NOT LR 6300
00005 00009 OR LD ––
TIM 000
00010 AND 21600
#0150
00011 BCNT(67) ––
TIM 000 # 0001
MOV(21)
004
HR 00
HR 00
LR 00
00012 LD 00005
00013 TIM 000
HR 0015
00500 # 0150
00014 LD TIM 000
00015 MOV(21) ––
HR 00
LR 00
00016 LD HR 0015
00017 OUT NOT 00500
188
Coding Right-hand Instructions Section 5-5
Multiple Instruction Lines If a right-hand instruction requires multiple instruction lines (such as KEEP(11)),
all of the lines for the instruction are entered before the right-hand instruction.
Each of the lines for the instruction is coded, starting with LD or LD NOT, to form
‘logic blocks’ that are combined by the right-hand instruction. An example of this
for SFT(10) is shown below.
189
Instruction Tables Section 5-6
1 SFT KEEP CNTR DIFU DIFD TIMH (@) WSFT (@) ASFT (@) TKY (@) MCMP
SHIFT KEEP REVERS- DIFFER- DIFFER- HIGH- WORD ASYNCHRO- TEN KEY IN- MULTI-
REGISTER IBLE ENTIATE UP ENTIATE SPEED SHIFT NOUS SHIFT PUT WORD
COUNTER DOWN TIMER REGISTER COMPARE
2 CMP (@) MOV (@) MVN (@) BIN (@) BCD (@) ASL (@) ASR (@) ROL (@) ROR (@) COM
COMPARE MOVE MOVE NOT BCD TO BINARY TO SHIFT LEFT SHIFT ROTATE ROTATE COMPLE-
BINARY BCD RIGHT LEFT RIGHT MENT
3 (@) ADD (@) SUB (@) MUL (@) DIV (@) ANDW (@) ORW (@) XORW (@) XNRW (@) INC (@) DEC
BCD ADD BCD BCD BCD LOGICAL LOGICAL OR EXCLUSIVE EXCLUSIVE INCREMENT DECRE-
SUBTRACT MULTIPLY DIVIDE AND OR NOR MENT
4 (@) STC (@) CLC --- --- --- TRSM (@) MSG (@) RXD (@) TXD ---
SET CARRY CLEAR TRACE MESSAGE RECEIVE TRANSMIT
CARRY MEMORY DISPLAY
SAMPLE
(SEE NOTE)
5 (@) ADB (@) SBB (@) MLB (@) DVB (@) ADDL (@) SUBL (@) MULL (@) DIVL (@) BINL (@) BCDL
BINARY ADD BINARY BINARY BINARY DOUBLE DOUBLE DOUBLE DOUBLE DOUBLE DOUBLE
SUBTRACT MULTIPLY DIVIDE BCD ADD BCD BCD BCD BCD-TO- BINARY-TO-
SUBTRACT MULTIPLY DIVIDE DOUBLE DOUBLE
BINARY BCD
6 CMPL (@) INI (@) PRV (@) CTBL (@) SPED (@) PULS (@) SCL (@) BCNT (@) BCMP (@) STIM
DOUBLE MODE CON- HIGH- COMPARI- SPEED OUT- SET PULSES SCALING BIT COUNT- BLOCK INTERVAL
COMPARE TROL SPEED SON TABLE PUT ER COMPARE TIMER
COUNTER LOAD
PV READ
7 (@) XFER (@) BSET (@) ROOT (@) XCHG (@) SLD (@) SRD (@) MLPX (@) DMPX (@) SDEC ---
BLOCK BLOCK SET SQUARE DATA ONE DIGIT ONE DIGIT 4-TO-16 16-TO-4 7-SEGMENT
TRANSFER ROOT EXCHANGE SHIFT LEFT SHIFT DECODER ENCODER DECODER
RIGHT
8 (@) DIST (@) COLL (@) MOVB (@) MOVD (@) SFTR (@) TCMP (@) ASC (@) DSW (@) 7SEG (@) INT
SINGLE DATA MOVE BIT MOVE DIGIT REVERS- TABLE ASCII DIGITAL 7-SEGMENT INTERRUPT
WORD COLLECT IBLE SHIFT COMPARE CONVERT SWITCH DISPLAY CONTROL
DISTRIBUTE REGISTER OUTPUT
9 --- (@) SBS SBN RET --- --- --- (@) IORF --- (@) MCRO
SUBROU- SUBROU- SUBROU- I/O MACRO
TINE TINE TINE REFRESH
ENTRY DEFINE RETURN
190
Instruction Tables Section 5-6
1 SFT KEEP CNTR DIFU DIFD TIMH (@) WSFT (@) ASFT --- ---
SHIFT KEEP REVERS- DIFFER- DIFFER- HIGH- WORD ASYNCHRO-
REGISTER IBLE ENTIATE UP ENTIATE SPEED SHIFT NOUS SHIFT
COUNTER DOWN TIMER REGISTER
2 CMP (@) MOV (@) MVN (@) BIN (@) BCD (@) ASL (@) ASR (@) ROL (@) ROR (@) COM
COMPARE MOVE MOVE NOT BCD TO BINARY TO SHIFT LEFT SHIFT ROTATE ROTATE COMPLE-
BINARY BCD RIGHT LEFT RIGHT MENT
3 (@) ADD (@) SUB (@) MUL (@) DIV (@) ANDW (@) ORW (@) XORW (@) XNRW (@) INC (@) DEC
BCD ADD BCD BCD BCD LOGICAL LOGICAL OR EXCLUSIVE EXCLUSIVE INCREMENT DECRE-
SUBTRACT MULTIPLY DIVIDE AND OR NOR MENT
4 (@) STC (@) CLC --- --- --- --- (@) MSG --- --- ---
SET CARRY CLEAR MESSAGE
CARRY DISPLAY
5 (@) ADB (@) SBB (@) MLB (@) DVB (@) ADDL (@) SUBL (@) MULL (@) DIVL --- ---
BINARY ADD BINARY BINARY BINARY DOUBLE DOUBLE DOUBLE DOUBLE
SUBTRACT MULTIPLY DIVIDE BCD ADD BCD BCD BCD
SUBTRACT MULTIPLY DIVIDE
6 CMPL (@) INI (@) PRV (@) CTBL --- --- --- (@) BCNT (@) BCMP (@) STIM
DOUBLE MODE CON- HIGH- COMPARI- BIT COUNT- BLOCK INTERVAL
COMPARE TROL SPEED SON TABLE ER COMPARE TIMER
COUNTER LOAD
PV READ
7 (@) XFER (@) BSET --- (@) XCHG (@) SLD (@) SRD (@) MLPX (@) DMPX (@) SDEC ---
BLOCK BLOCK SET DATA ONE DIGIT ONE DIGIT 4-TO-16 16-TO-4 7-SEGMENT
TRANSFER EXCHANGE SHIFT LEFT SHIFT DECODER ENCODER DECODER
RIGHT
8 (@) DIST (@) COLL (@) MOVB (@) MOVD (@) SFTR (@) TCMP (@) ASC --- --- (@) INT
SINGLE DATA MOVE BIT MOVE DIGIT REVERS- TABLE ASCII INTERRUPT
WORD COLLECT IBLE SHIFT COMPARE CONVERT CONTROL
DISTRIBUTE REGISTER
9 --- (@) SBS SBN RET --- --- --- (@) IORF --- (@) MCRO
SUBROU- SUBROU- SUBROU- I/O MACRO
TINE TINE TINE REFRESH
ENTRY DEFINE RETURN
191
Instruction Tables Section 5-6
1 SFT KEEP CNTR DIFU DIFD TIMH (@) WSFT (@) ASFT --- ---
SHIFT KEEP REVERS- DIFFER- DIFFER- HIGH- WORD ASYNCHRO-
REGISTER IBLE ENTIATE UP ENTIATE SPEED SHIFT NOUS SHIFT
COUNTER DOWN TIMER REGISTER
2 CMP (@) MOV (@) MVN (@) BIN (@) BCD (@) ASL (@) ASR (@) ROL (@) ROR (@) COM
COMPARE MOVE MOVE NOT BCD TO BINARY TO SHIFT LEFT SHIFT ROTATE ROTATE COMPLE-
BINARY BCD RIGHT LEFT RIGHT MENT
3 (@) ADD (@) SUB (@) MUL (@) DIV (@) ANDW (@) ORW (@) XORW (@) XNRW (@) INC (@) DEC
BCD ADD BCD BCD BCD LOGICAL LOGICAL OR EXCLUSIVE EXCLUSIVE INCREMENT DECRE-
SUBTRACT MULTIPLY DIVIDE AND OR NOR MENT
4 (@) STC (@) CLC --- --- --- --- (@) MSG --- --- ---
SET CARRY CLEAR MESSAGE
CARRY DISPLAY
5 (@) ADB (@) SBB (@) MLB (@) DVB (@) ADDL (@) SUBL (@) MULL (@) DIVL --- ---
BINARY ADD BINARY BINARY BINARY DOUBLE DOUBLE DOUBLE DOUBLE
SUBTRACT MULTIPLY DIVIDE BCD ADD BCD BCD BCD
SUBTRACT MULTIPLY DIVIDE
6 CMPL --- --- --- --- --- --- (@) BCNT (@) BCMP (@) STIM
DOUBLE BIT COUNT- BLOCK INTERVAL
COMPARE ER COMPARE TIMER
7 (@) XFER (@) BSET --- (@) XCHG (@) SLD (@) SRD (@) MLPX (@) DMPX (@) SDEC ---
BLOCK BLOCK SET DATA ONE DIGIT ONE DIGIT 4-TO-16 16-TO-4 7-SEGMENT
TRANSFER EXCHANGE SHIFT LEFT SHIFT DECODER ENCODER DECODER
RIGHT
8 (@) DIST (@) COLL (@) MOVB (@) MOVD (@) SFTR (@) TCMP (@) ASC --- --- ---
SINGLE DATA MOVE BIT MOVE DIGIT REVERS- TABLE ASCII
WORD COLLECT IBLE SHIFT COMPARE CONVERT
DISTRIBUTE REGISTER
9 --- (@) SBS SBN RET --- --- --- (@) IORF --- (@) MCRO
SUBROU- SUBROU- SUBROU- I/O MACRO
TINE TINE TINE REFRESH
ENTRY DEFINE RETURN
192
Instruction Tables Section 5-6
193
Instruction Tables Section 5-6
194
Instruction Tables Section 5-6
195
Ladder Diagram Instructions Section 5-7
5-7-1 LOAD, LOAD NOT, AND, AND NOT, OR, and OR NOT
Ladder Symbols Operand Data Areas
B B: Bit
LOAD – LD
IR, SR, AR, HR, TC, LR, TR
B B: Bit
LOAD NOT – LD NOT
IR, SR, AR, HR, TC, LR
B B: Bit
AND – AND
IR, SR, AR, HR, TC, LR
B B: Bit
AND NOT – AND NOT
IR, SR, AR, HR, TC, LR
B: Bit
OR – OR B
IR, SR, AR, HR, TC, LR
B: Bit
OR NOT – OR NOT B
IR, SR, AR, HR, TC, LR
Limitations There is no limit to the number of any of these instructions, or restrictions in the
order in which they must be used, as long as the memory capacity of the PC is
not exceeded.
Description These six basic instructions correspond to the conditions on a ladder diagram.
As described in Section 4 Ladder-diagram Programming, the status of the bits
assigned to each instruction determines the execution conditions for all other
instructions. Each of these instructions and each bit address can be used as
many times as required. Each can be used in as many of these instructions as
required.
The status of the bit operand (B) assigned to LD or LD NOT determines the first
execution condition. AND takes the logical AND between the execution condi-
tion and the status of its bit operand; AND NOT, the logical AND between the
execution condition and the inverse of the status of its bit operand. OR takes the
logical OR between the execution condition and the status of its bit operand; OR
NOT, the logical OR between the execution condition and the inverse of the sta-
tus of its bit operand.
196
Bit Control Instructions Section 5-8
OR LOAD – OR LD
00000 00001
Ladder Symbol
00002 00003
Description When instructions are combined into blocks that cannot be logically combined
using only OR and AND operations, AND LD and OR LD are used. Whereas
AND and OR operations logically combine a bit status and an execution condi-
tion, AND LD and OR LD logically combine two execution conditions, the current
one and the last unused one.
In order to draw ladder diagrams, it is not necessary to use AND LD and OR LD
instructions, nor are they necessary when inputting ladder diagrams directly, as
is possible from the SSS. They are required, however, to convert the program to
and input it in mnemonic form.
In order to reduce the number of programming instructions required, a basic un-
derstanding of logic block instructions is required. For an introduction to logic
blocks, refer to 4-3-6 Logic Block Instructions.
B: Bit
B
IR, SR, AR, HR, LR, TR
B: Bit
B
IR, SR, AR, HR, LR
Limitations Any output bit can generally be used in only one instruction that controls its sta-
tus.
Description OUT and OUT NOT are used to control the status of the designated bit according
to the execution condition.
197
Bit Control Instructions Section 5-8
OUT turns ON the designated bit for an ON execution condition, and turns OFF
the designated bit for an OFF execution condition. With a TR bit, OUT appears at
a branching point rather than at the end of an instruction line. Refer to 4-3-8
Branching Instruction Lines for details.
OUT NOT turns ON the designated bit for a OFF execution condition, and turns
OFF the designated bit for an ON execution condition.
OUT and OUT NOT can be used to control execution by turning ON and OFF bits
that are assigned to conditions on the ladder diagram, thus determining execu-
tion conditions for other instructions. This is particularly helpful and allows a
complex set of conditions to be used to control the status of a single work bit, and
then that work bit can be used to control other instructions.
The length of time that a bit is ON or OFF can be controlled by combining the
OUT or OUT NOT with TIM. Refer to Examples under 5-15-1 TIMER – TIM for
details.
B: Bit
SET B
IR, SR, AR, HR, LR
B: Bit
RSET B
IR, SR, AR, HR, LR
Description SET turns the operand bit ON when the execution condition is ON, and does not
affect the status of the operand bit when the execution condition is OFF. RSET
turns the operand bit OFF when the execution condition is ON, and does not af-
fect the status of the operand bit when the execution condition is OFF.
The operation of SET differs from that of OUT because the OUT instruction turns
the operand bit OFF when its execution condition is OFF. Likewise, RSET differs
from OUT NOT because OUT NOT turns the operand bit ON when its execution
condition is OFF.
Precautions The status of operand bits for SET and RSET programmed between IL(02) and
ILC(03) or JMP(04) and JME(05) will not change when the interlock or jump
condition is met (i.e., when IL(02) or JMP(04) is executed with an OFF execution
condition).
Examples The following examples demonstrate the difference between OUT and SET/
RSET. In the first example (Diagram A), IR 10000 will be turned ON or OFF
whenever IR 00000 goes ON or OFF.
198
Bit Control Instructions Section 5-8
In the second example (Diagram B), IR 10000 will be turned ON when IR 00001
goes ON and will remain ON (even if IR 00001 goes OFF) until IR 00002 goes
ON.
00000
10000
Address Instruction Operands
00000 LD 00000
Diagram A 00001 OUT 10000
00001
SET 10000
Address Instruction Operands
00002 00000 LD 00001
RSET 10000
00001 SET 10000
00002 LD 00002
Diagram B 00003 RSET 10000
KEEP(11) B: Bit
B
IR, SR, AR, HR, LR
R
Limitations Any output bit can generally be used in only one instruction that controls its sta-
tus.
Description KEEP(11) is used to maintain the status of the designated bit based on two
execution conditions. These execution conditions are labeled S and R. S is the
set input; R, the reset input. KEEP(11) operates like a latching relay that is set by
S and reset by R.
When S turns ON, the designated bit will go ON and stay ON until reset, regard-
less of whether S stays ON or goes OFF. When R turns ON, the designated bit
will go OFF and stay OFF until reset, regardless of whether R stays ON or goes
OFF. The relationship between execution conditions and KEEP(11) bit status is
shown below.
S execution condition
R execution condition
Status of B
199
Bit Control Instructions Section 5-8
Precautions Exercise caution when using a KEEP reset line that is controlled by an external
normally closed device. Never use an input bit in an inverse condition on the re-
set (R) for KEEP(11) when the input device uses an AC power supply. The delay
in shutting down the PC’s DC power supply (relative to the AC power supply to
the input device) can cause the designated bit of KEEP(11) to be reset. This situ-
ation is shown below.
Input Unit
A S
KEEP(11)
NEVER A B
R
Bits used in KEEP are not reset in interlocks. Refer to the 5-11 INTERLOCK –
and INTERLOCK CLEAR IL(02) and ILC(03) for details.
B: Bit
DIFU(13) B
IR, SR, AR, HR, LR
B: Bit
DIFD(14) B
IR, SR, AR, HR, LR
Limitations Any output bit can generally be used in only one instruction that controls its sta-
tus.
Description DIFU(13) and DIFD(14) are used to turn the designated bit ON for one cycle
only.
Whenever executed, DIFU(13) compares its current execution with the previous
execution condition. If the previous execution condition was OFF and the cur-
rent one is ON, DIFU(13) will turn ON the designated bit. If the previous execu-
tion condition was ON and the current execution condition is either ON or OFF,
DIFU(13) will either turn the designated bit OFF or leave it OFF (i.e., if the desig-
nated bit is already OFF). The designated bit will thus never be ON for longer
than one cycle, assuming it is executed each cycle (see Precautions, below).
Whenever executed, DIFD(14) compares its current execution with the previous
execution condition. If the previous execution condition was ON and the current
one is OFF, DIFD(14) will turn ON the designated bit. If the previous execution
condition was OFF and the current execution condition is either ON or OFF,
DIFD(14) will either turn the designated bit OFF or leave it OFF. The designated
bit will thus never be ON for longer than one cycle, assuming it is executed each
cycle (see Precautions, below).
These instructions are used when differentiated instructions (i.e., those prefixed
with an @) are not available and single-cycle execution of a particular instruction
is desired. They can also be used with non-differentiated forms of instructions
that have differentiated forms when their use will simplify programming. Exam-
ples of these are shown below.
200
INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03) Section 5-11
Precautions rDIFU(13) and DIFD(14) operation can be uncertain when the instructions are
programmed between IL and ILC, between JMP and JME, or in subroutines. Re-
fer to 5-11 INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03), 5-12
JUMP and JUMP END – JMP(04) and JME(05), 5-25 Subroutine Instructions,
and 5-26-8 INTERRUPT CONTROL – INT(89).
Example In this example, IR 10014 will be turned ON for one cycle when IR 00000 goes
from OFF to ON. IR 10015 will be turned ON for one cycle when IR 00000 goes
from ON to OFF.
00000
DIFU(13) 10014 Address Instruction Operands
00000 LD 00000
00001 DIFU(13) 10014
DIFD(14) 10015
00002 DIFD(14) 10015
Description END(01) is required as the last instruction in any program. If there are subrou-
tines, END(01) is placed after the last subroutine. No instruction written after
END(01) will be executed. END(01) can be placed anywhere in the program to
execute all instructions up to that point, as is sometimes done to debug a pro-
gram, but it must be removed to execute the remainder of the program.
If there is no END(01) in the program, no instructions will be executed and the
error message “NO END INST” will appear.
Flags END(01) turns OFF the ER, CY, GR, EQ, and LE flags.
Description IL(02) is always used in conjunction with ILC(03) to create interlocks. Interlocks
are used to enable branching in the same way as can be achieved with TR bits,
but treatment of instructions between IL(02) and ILC(03) differs from that with
TR bits when the execution condition for IL(02) is OFF. If the execution condition
of IL(02) is ON, the program will be executed as written, with an ON execution
condition used to start each instruction line from the point where IL(02) is located
through the next ILC(03). Refer to 4-3-8 Branching Instruction Lines for basic
descriptions of both methods.
201
INTERLOCK and INTERLOCK CLEAR – IL(02) and ILC(03) Section 5-11
If the execution condition for IL(02) is OFF, the interlocked section between
IL(02) and ILC(03) will be treated as shown in the following table:
Instruction Treatment
OUT and OUT NOT Designated bit turned OFF.
TIM and TIMH(15) Reset.
CNT, CNTR(12) PV maintained.
KEEP(11) Bit status maintained.
DIFU(13) and DIFD(14) Not executed (see below).
All other instructions The instructions are not executed, and all IR, AR, LR,
HR, and SR bits and words written to as operands in the
instructions are turned OFF.
IL(02) and ILC(03) do not necessarily have to be used in pairs. IL(02) can be
used several times in a row, with each IL(02) creating an interlocked section
through the next ILC(03). ILC(03) cannot be used unless there is at least one
IL(02) between it and any previous ILC(03).
DIFU(13) and DIFD(14) in Changes in the execution condition for a DIFU(13) or DIFD(14) are not recorded
Interlocks if the DIFU(13) or DIFD(14) is in an interlocked section and the execution condi-
tion for the IL(02) is OFF. When DIFU(13) or DIFD(14) is execution in an inter-
locked section immediately after the execution condition for the IL(02) has gone
ON, the execution condition for the DIFU(13) or DIFD(14) will be compared to
the execution condition that existed before the interlock became effective (i.e.,
before the interlock condition for IL(02) went OFF). The ladder diagram and bit
status changes for this are shown below. The interlock is in effect while 00000 is
OFF. Notice that 01000 is not turned ON at the point labeled A even though
00001 has turned OFF and then back ON.
00000
Address Instruction Operands
IL(02)
00001 00000 LD 00000
DIFU(13) 01000 00001 IL(02)
00002 LD 00001
ILC(03)
00003 DIFU(13) 01000
A 00004 ILC(03)
ON
00000 OFF
ON
00001 OFF
ON
01000 OFF
202
JUMP and JUMP END – JMP(04) and JME(05) Section 5-12
Example The following diagram shows IL(02) being used twice with one ILC(03).
When the execution condition for the first IL(02) is OFF, TIM 127 will be reset to
1.5 s, CNT 001 will not be changed, and 00502 will be turned OFF. When the
execution condition for the first IL(02) is ON and the execution condition for the
second IL(02) is OFF, TIM 127 will be executed according to the status of 00001,
CNT 001 will not be changed, and 00502 will be turned OFF. When the execution
conditions for both the IL(02) are ON, the program will execute as written.
N: Jump number
JMP(04) N
#
N: Jump number
JME(05) N
#
Description JMP(04) is always used in conjunction with JME(05) to create jumps, i.e., to skip
from one point in a ladder diagram to another point. JMP(04) defines the point
from which the jump will be made; JME(05) defines the destination of the jump.
When the execution condition for JMP(04) in ON, no jump is made and the pro-
gram is executed consecutively as written. When the execution condition for
JMP(04) is OFF, a jump is made to the JME(05) with the same jump number and
the instruction following JME(05) is executed next.
203
JUMP and JUMP END – JMP(04) and JME(05) Section 5-12
If the jump number for JMP(04) is between 01 and 99, jumps, when made, will go
immediately to JME(05) with the same jump number without executing any
instructions in between. The status of timers, counters, bits used in OUT, bits
used in OUT NOT, and all other status bits controlled by the instructions between
JMP(04) and JMP(05) will not be changed. Each of these jump numbers can be
used to define only one jump. Because all of instructions between JMP(04) and
JME(05) are skipped, jump numbers 01 through 99 (01 through 49 in CPM1/
CPM1A/SRM1 PCs) can be used to reduce cycle time.
Jump Number 00
If the jump number for JMP(04) is 00, the CPU Unit will look for the next JME(05)
with a jump number of 00. To do so, it must search through the program, causing
a longer cycle time (when the execution condition is OFF) than for other jumps.
The status of timers, counters, bits used in OUT, bits used in OUT NOT, and all
other status controlled by the instructions between JMP(04) 00 and JMP(05) 00
will not be changed. jump number 00 can be used as many times as desired. A
jump from JMP(04) 00 will always go to the next JME(05) 00 in the program. It is
thus possible to use JMP(04) 00 consecutively and match them all with the same
JME(05) 00. It makes no sense, however, to use JME(05) 00 consecutively, be-
cause all jumps made to them will end at the first JME(05) 00.
DIFU(13) and DIFD(14) in Although DIFU(13) and DIFD(14) are designed to turn ON the designated bit for
Jumps one cycle, they will not necessarily do so when written between JMP(04) and
JMP (05). Once either DIFU(13) or DIFD(14) has turned ON a bit, it will remain
ON until the next time DIFU(13) or DIFD(14) is executed again. In normal pro-
gramming, this means the next cycle. In a jump, this means the next time the
jump from JMP(04) to JME(05) is not made, i.e., if a bit is turned ON by DIFU(13)
or DIFD(14) and then a jump is made in the next cycle so that DIFU(13) or
DIFD(14) are skipped, the designated bit will remain ON until the next time the
execution condition for the JMP(04) controlling the jump is ON.
Precautions When JMP(04) and JME(05) are not used in pairs, an error message will appear
when the program check is performed. This message also appears if JMP(04)
00 and JME(05) 00 are not used in pairs, but the program will execute properly
as written.
204
User Error Instructions Section 5-13
N: FAL number
FAL(06) N @FAL(06) N
# (00 to 99)
N: FAL number
FALS(07) N
# (01 to 99)
Description FAL(06) and FALS(07) are provided so that the programmer can output error
numbers for use in operation, maintenance, and debugging. When executed
with an ON execution condition, either of these instructions will output a FAL
number to bits 00 to 07 of SR 253. The FAL number that is output can be be-
tween 01 and 99 and is input as the definer for FAL(06) or FALS(07). FAL(06)
with a definer of 00 is used to reset this area (see below).
FAL Area
25307 25300
X101 X100
FAL(06) produces a non-fatal error and FALS(07) produces a fatal error. When
FAL(06) is executed with an ON execution condition, the ALARM/ERROR indi-
cator on the front of the CPU Unit will flash, but PC operation will continue. When
FALS(07) is executed with an ON execution condition, the ALARM/ERROR indi-
cator will light and PC operation will stop.
The system also generates error codes to the FAL area.
Resetting Errors FAL error codes will be retained in memory, although only one of these is avail-
able in the FAL area. To access the other FAL codes, reset the FAL area by
executing FAL(06) 00. Each time FAL(06) 00 is executed, another FAL error will
be moved to the FAL area, clearing the one that is already there. FAL error codes
are recorded in numerical order.
FAL(06) 00 is also used to clear message programmed with the instruction,
MSG(46).
If the FAL area cannot be cleared, as is generally the case when FALS(07) is
executed, first remove the cause of the error and then clear the FAL area through
the Programming Console or SSS.
205
Step Instructions Section 5-14
B: Control bit
STEP(08) B STEP(08)
IR, AR, HR, LR
Limitations All control bits must be in the same word and must be consecutive.
Description The step instructions STEP(08) and SNXT(09) are used together to set up
breakpoints between sections in a large program so that the sections can be
executed as units and reset upon completion. A section of program will usually
be defined to correspond to an actual process in the application. (Refer to the
application examples later in this section.) A step is like a normal programming
code, except that certain instructions (i.e., END(01), IL(02)/ILC(03),
JMP(04)/JME(05), and SBN(92)) may not be included.
STEP(08) uses a control bit in the IR or HR areas to define the beginning of a
section of the program called a step. STEP(08) does not require an execution
condition, i.e., its execution is controlled through the control bit. To start execu-
tion of the step, SNXT(09) is used with the same control bit as used for
STEP(08). If SNXT(09) is executed with an ON execution condition, the step
with the same control bit is executed. If the execution condition is OFF, the step is
not executed. The SNXT(09) instruction must be written into the program so that
it is executed before the program reaches the step it starts. It can be used at dif-
ferent locations before the step to control the step according to two different
execution conditions (see example 2, below). Any step in the program that has
not been started with SNXT(09) will not be executed.
Once SNXT(09) is used in the program, step execution will continue until
STEP(08) is executed without a control bit. STEP(08) without a control bit must
be preceded by SNXT(09) with a dummy control bit. The dummy control bit may
be any unused IR or HR bit. It cannot be a control bit used in a STEP(08).
206
Step Instructions Section 5-14
00000
SNXT(09) LR 1500 Starts step execution
STEP(08) LR 1500
00001
SNXT(09) LR 1501
STEP(08) LR 1501
00002
SNXT(09) LR 1502
Steps can be programmed in consecutively. Each step must start with STEP(08)
and generally ends with SNXT(09) (see example 3, below, for an exception).
When steps are programmed in series, three types of execution are possible:
sequential, branching, or parallel. The execution conditions for, and the position-
ing of, SNXT(09) determine how the steps are executed. The three examples
given below demonstrate these three types of step execution.
Precautions Interlocks, jumps, SBN(92), and END(01) cannot be used within step programs.
Bits used as control bits must not be used anywhere else in the program unless
they are being used to control the operation of the step (see example 3, below).
All control bits must be in the same word and must be consecutive.
If IR or LR bits are used for control bits, their status will be lost during any power
interruption. If it is necessary to maintain status to resume execution at the same
step, HR bits must be used.
207
Timer and Counter Instructions Section 5-15
Flags 25407: Step Start Flag; turns ON for one cycle when STEP(08) is executed and
can be used to reset counters in steps as shown below if necessary.
00000
SNXT(09) 01000 Start
01000
STEP(08) 01000
00100
CP
CNT 01
25407
25407
R #0003
1 cycle
208
Timer and Counter Instructions Section 5-15
Note that “TIM 000” is used to designate the TIMER instruction defined with TC
number 000, to designate the Completion Flag for this timer, and to designate
the PV of this timer. The meaning of the term in context should be clear, i.e., the
first is always an instruction, the second is always a bit operand, and the third is
always a word operand. The same is true of all other TC numbers prefixed with
TIM or CNT.
An SV can be input as a constant or as a word address in a data area. If an IR
area word assigned to an Input Unit is designated as the word address, the Input
Unit can be wired so that the SV can be set externally through thumbwheel
switches or similar devices. Timers and counters wired in this way can only be
set externally during RUN or MONITOR mode. All SVs, including those set ex-
ternally, must be in BCD.
N: TC number
Ladder Symbol
#
TIM N
SV
Operand Data Areas
Limitations SV is between 000.0 and 999.9. The decimal point is not entered.
Each TC number can be used as the definer in only one TIMER or COUNTER
instruction. TC numbers run from 000 through 511 in the CQM1 PCs and from
000 through 127 in the CPM1, CPM1A/SRM1 PCs.
TC 000 through TC 015 (TC 000 through TC 003 in the CPM1/CPM1A/SRM1)
should not be used in TIM if they are required for TIMH(15). Refer to 5-15-4
HIGH-SPEED TIMER – TIMH(15) for details.
Description A timer is activated when its execution condition goes ON and is reset (to SV)
when the execution condition goes OFF. Once activated, TIM measures in units
of 0.1 second from the SV.
If the execution condition remains ON long enough for TIM to time down to zero,
the Completion Flag for the TC number used will turn ON and will remain ON
until TIM is reset (i.e., until its execution condition is goes OFF).
The following figure illustrates the relationship between the execution condition
for TIM and the Completion Flag assigned to it.
ON
Execution condition OFF
ON
Completion Flag OFF
SV SV
Precautions Timers in interlocked program sections are reset when the execution condition
for IL(02) is OFF. Power interruptions also reset timers. If a timer that is not reset
under these conditions is desired, SR area clock pulse bits can be counted to
produce timers using CNT. Refer to 5-15-2 COUNTER – CNT for details.
209
Timer and Counter Instructions Section 5-15
N: TC number
Ladder Symbol
#
CP
CNT N
Limitations Each TC number can be used as the definer in only one TIMER or COUNTER
instruction. TC numbers run from 000 through 511 in the CQM1 PCs and from
000 through 127 in the CPM1/CPM1A/SRM1 PCs.
Description CNT is used to count down from SV when the execution condition on the count
pulse, CP, goes from OFF to ON, i.e., the present value (PV) will be decrem-
ented by one whenever CNT is executed with an ON execution condition for CP
and the execution condition was OFF for the last execution. If the execution
condition has not changed or has changed from ON to OFF, the PV of CNT will
not be changed. The Completion Flag for a counter is turned ON when the PV
reaches zero and will remain ON until the counter is reset.
CNT is reset with a reset input, R. When R goes from OFF to ON, the PV is reset
to SV. The PV will not be decremented while R is ON. Counting down from SV will
begin again when R goes OFF. The PV for CNT will not be reset in interlocked
program sections or by power interruptions.
Changes in execution conditions, the Completion Flag, and the PV are illus-
trated below. PV line height is meant only to indicate changes in the PV.
Execution condition ON
on count pulse (CP) OFF
Execution condition ON
on reset (R) OFF
ON
Completion Flag OFF
SV SV
PV SV – 1 0002
SV – 2 0001
0000
Precautions Program execution will continue even if a non-BCD SV is used, but the SV will
not be correct.
210
Timer and Counter Instructions Section 5-15
Example In the following example, CNT is used to create extended timers by counting SR
area clock pulse bits.
CNT 001 counts the number of times the 1-second clock pulse bit (SR 25502)
goes from OFF to ON. Here again, IR 00000 is used to control the times when
CNT is operating.
Because in this example the SV for CNT 001 is 700, the Completion Flag for
CNT 002 turns ON when 1 second x 700 times, or 11 minutes and 40 seconds
have expired. This would result in IR 01602 being turned ON.
00000 25502
CP Address Instruction Operands
CNT
001 00000 LD 00000
00001 00001 AND 25502
R
#0700
00002 LD NOT 00001
CNT 001
00003 CNT 001
01602 # 0700
00004 LD CNT 001
00005 OUT 01602
! Caution The shorter clock pulses will not necessarily produce accurate timers because
their short ON times might not be read accurately during longer cycles. In partic-
ular, the 0.02-second and 0.1-second clock pulses should not be used to create
timers with CNT instructions.
N: TC number
Ladder Symbol
#
II
CNTR(12)
DI N
Operand Data Areas
SV
R
SV: Set value (word, BCD)
Limitations Each TC number can be used as the definer in only one TIMER or COUNTER
instruction. TC numbers run from 000 through 511 in the CQM1 PCs and from
000 through 127 in the CPM1/CPM1A/SRM1 PCs.
Description The CNTR(12) is a reversible, up/down circular counter, i.e., it is used to count
between zero and SV according to changes in two execution conditions, those in
the increment input (II) and those in the decrement input (DI).
The present value (PV) will be incremented by one whenever CNTR(12) is
executed with an ON execution condition for II and the last execution condition
for II was OFF. The present value (PV) will be decremented by one whenever
CNTR(12) is executed with an ON execution condition for DI and the last execu-
tion condition for DI was OFF. If OFF to ON changes have occurred in both II and
DI since the last execution, the PV will not be changed.
If the execution conditions have not changed or have changed from ON to OFF
for both II and DI, the PV of CNT will not be changed.
When decremented from 0000, the present value is set to SV and the Comple-
tion Flag is turned ON until the PV is decremented again. When incremented
past the SV, the PV is set to 0000 and the Completion Flag is turned ON until the
PV is incremented again.
211
Timer and Counter Instructions Section 5-15
CNTR(12) is reset with a reset input, R. When R goes from OFF to ON, the PV is
reset to zero. The PV will not be incremented or decremented while R is ON.
Counting will begin again when R goes OFF. The PV for CNTR(12) will not be
reset in interlocked program sections or by the effects of power interruptions.
Changes in II and DI execution conditions, the Completion Flag, and the PV are
illustrated below starting from part way through CNTR(12) operation (i.e., when
reset, counting begins from zero). PV line height is meant to indicate changes in
the PV only.
Execution condition ON
on increment (II) OFF
Execution condition ON
on decrement (DI) OFF
ON
Completion Flag OFF
SV SV
PV SV – 1 SV – 1
0001
SV – 2 SV – 2
0000 0000
Precautions Program execution will continue even if a non-BCD SV is used, but the SV will
not be correct.
N: TC number
Ladder Symbol
#
TIMH(15) N
SV
Operand Data Areas
Limitations SV is between 00.00 and 99.99. (Although 00.00 and 00.01 may be set, 00.00
will disable the timer, i.e., turn ON the Completion Flag immediately, and 00.01 is
not reliably scanned.) The decimal point is not entered.
Each TC number can be used as the definer in only one TIMER or COUNTER
instruction. Use TC numbers from 000 through 015 in the CQM1 PCs and from
000 through 003 in the CPM1/CPM1A/SRM1 PCs.
High-speed timers with timer numbers TC 016 through TC 511 (TC 004 through
TC 127 in the CPM1/CPM1A/SRM1) should not be used if the cycle time ex-
ceeds 10 ms.
Description TIMH(15) operates in the same way as TIM except that TIMH measures in units
of 0.01 second. Refer to 5-15-1 TIMER – TIM for operational details.
Precautions Timers in interlocked program sections are reset when the execution condition
for IL(02) is OFF. Power interruptions also reset timers. If a timer that is not reset
212
Timer and Counter Instructions Section 5-15
under these conditions is desired, SR area clock pulse bits can be counted to
produce timers using CNT. Refer to 5-15-2 COUNTER – CNT for details.
Timers in jumped program sections will not be reset when the execution condi-
tion for JMP(04) is OFF, but the timer will stop timing if jump number 00 is used.
The timers will continue timing if jump numbers 01 through 99 (01 through 49 in
CPM1/CPM1A/SRM1 PCs) are used.
CQM1 Precautions
High-speed timers with timer numbers TC 000 through TC 015 will not be inac-
curate when the PC Setup (DM 6629) is set to perform interrupt processing on
these timers.
High-speed timers with timer numbers TC 016 through TC 511 will be inaccurate
when the cycle time exceeds 10 ms. If the cycle time is greater than 10 ms, use
TC 000 through TC 015 and set DM 6629 for interrupt processing of the timer
numbers used.
Example The following example shows a timer set with a constant. 01600 will be turned
ON after 00000 goes ON and stays ON for at least 1.5 seconds. When 00000
goes OFF, the timer will be reset and 01600 will be turned OFF.
00000
TIMH(15)
Address Instruction Operands
000
01.50 s 00000 LD 00000
#0150
00001 TIMH(15) 000
TIM 000 # 0150
01600
00002 LD TIM 000
00003 OUT 01600
Note STIM(69) is an expansion instruction for the SRM1. The function code 69 is the
factory setting and can be changed for the SRM1 if desired.
Limitations (CQM1) C1 must be 000 to 008 or 010 to 012.
If C1 is 000 to 005, a constant greater than 0255 cannot be used for C3.
If C1 is 006 to 008, constants and DM 6143 to DM 6655 cannot be used for C2 or
C3. If C1 is 010 to 012, both C2 and C3 must be set to 000.
Limitations C1 must be 000, 003, 006. or 010.
(CPM1/CPM1A/SRM1) If C1 is 000 or 003, a constant greater than 0049 cannot be used for C3.
If C1 is 006, constants and DM 6143 to DM 6655 cannot be used for C2 or C3.
If C1 is 010, both C2 and C3 must be set to 000.
213
Timer and Counter Instructions Section 5-15
Description STIM(69) is used to control the interval timers by performing four basic func-
tions: starting the timer for a non-shot interrupt, starting the timer for scheduled
interrupts, stopping the timer, and reading the timer’s PV. Set the value of C1 to
specify which of these functions will be performed and which of the three interval
timers it will be performed on, as shown in the following table. Refer to 1-5-4,
1-6-4, and 1-7-2 for more detailed descriptions of using interval timer interrupts.
STIM(69) is also described in more detail after the table.
Function Timer C1 value Applicable PCs
Starting timers 0 000 CQM1/CPM1/
CPM1A/SRM1
1 001 CQM1 only
2 002
Starting scheduled interrupts 0 003 CQM1/CPM1/
CPM1A/SRM1
1 004 CQM1 only
2 005
Reading timer PV 0 006 CQM1/CPM1/
CPM1A/SRM1
1 007 CQM1 only
2 008
Stopping timers 0 010 CQM1/CPM1/
CPM1A/SRM1
1 011 CQM1 only
2 012
Note 1. In CQM1 PCs, interval timer 0 cannot be used when a pulse output is being
output by the SPED(64) instruction.
2. In CQM1 PCs, interval timer 2 cannot be used when high-speed counter 0
operation has been enabled in DM 6642 of the PC Setup.
Starting Interrupts Set C1=000 to 002 to start timers 0 to 2 to activate a one-shot interrupt. Set
C1=003 to 005 to start scheduled interrupts using timers 0 to 2.
C2, which specifies the timer’s SV, can be a constant or the first of two words
containing the SV. The settings are slightly different depending on the method
used.
If C2 is a constant, it specifies the initial value of the decrementing counter (BCD,
0000 to 9999). The decrementing time interval is 1 ms.
If C2 is a word address, C2 specifies the initial value of the decrementing counter
(BCD, 0000 to 9999), and C2+1 specifies the decrementing time interval (BCD,
0005 to 0320) in units of 0.1 ms. The decrementing time interval can thus be 0.5
to 32 ms.
C3 specifies subroutine number 0000 to 0255 (0000 to 0127 in the
CQM1-CPU11/21-E, 0000 to 0049 in the CPM1/CPM1A/SRM1 PCs).
Note The time required from interval timer start-up to time-up is:
(the content of C2) × (the content of C2+1) × 0.1 ms
Reading Timer PVs Set C1=006 to 008 to read the PVs of timers 0 to 2.
C2 specifies the first of two destination words that will receive the timer’s PV. C2
will receive the number of times the decrementing counter has been decrem-
ented (BCD, 0000 to 9999) and C2+1 will receive the decrementing time interval
(BCD in 0.1 ms units).
C3 specifies the destination word that will receive the time which has elapsed
since the last time the timer was decremented (BCD in 0.1 ms units).
(Must be equal to or less than the decrementing time interval set in C2+1.)
Note The time that has elapsed since the timer was started is computed as follows:
(Content of C2 × (Content of C2 + 1) + Content of C3) × 0.1 ms
214
Timer and Counter Instructions Section 5-15
215
Timer and Counter Instructions Section 5-15
If the high-speed counter is enabled in the PC Setup (DM 6642), it will begin
counting from zero when the CQM1 begins operation. The PV will not be
compared to the comparison table until the table is registered and comparison is
initiated with INI(61) or CTBL(63). Comparison can be stopped and started, or
the PV can be reset with INI(61).
Once a comparison table has been registered, it is valid until the CQM1 is halted
or until a error occurs in attempting to register a new table. The differentiated
form of CTBL(63) is recommended when possible to reduce cycle time.
Target Value Comparison A target value comparison table contains up to sixteen target values. For the
CQM1-CPU4-EV1 CPU Units, up to 48 target values can be registered. A sub-
routine number is also registered for each target value. The corresponding sub-
routine is called and executed when the PV matches a target value. (When inter-
rupt processing is not required, an undefined subroutine number may be en-
tered.)
Target value comparisons are performed one item at a time in order of the com-
parison table. When the PV reaches the first target value in the table, the inter-
rupt subroutine is executed and comparison continues to the next value in the
table. When processing has been completed for the last target value in the table,
comparison returns to the first value in the table and the process is repeated.
The following diagram shows the structure of a target value comparison table for
use with high-speed counter 0, or high-speed counters 1 or 2 in linear mode.
The following diagram shows the structure of a target value comparison table for
use with high-speed counters 1 or 2 in ring mode. Input the target values in as-
cending or descending order.
The ring value specifies the number of points in the ring and the maximum count
value (ring value = max. count value+1). Do not change the ring value while a
comparison is in progress.
The following diagram shows the structure of a target value comparison table for
use with absolute high-speed counters 1 and 2 (CQM1-CPU44-E/-EV1 only).
Input the target values in ascending or descending order.
Note 1. The subroutine number can be 0000 to 0049 for CPM1/CPM1A PCs.
In CQM1 PCs, the subroutine number can be F000 to F255 (F000 to F127
216
Timer and Counter Instructions Section 5-15
2. Allow an interval of at least 0.2 ms for interrupt processing when setting the
target value for high-speed counters 1 and 2.
Count
Interrupts
Initial
value
As illustrated above, the current count is compared with each target value in the
order that they are registered in the target value comparison table. When the
count is the same as the current target value, an interrupt is generated, and com-
parison starts with the next target value. When all target values in the compari-
son table have been matched and interrupts for them generated, the target val-
ue is reset to the first target value in the table and the operation is repeated.
Range Comparison A range comparison table contains 8 ranges which are defined by an 8-digit low-
er limit and an 8-digit upper limit, as well as their corresponding subroutine num-
bers. The corresponding subroutine is called and executed when the PV falls
within a given range. (When interrupt processing is not required, an undefined
subroutine number may be entered.)
Always set 8 ranges. If fewer than 8 ranges are needed, set the remaining sub-
routine numbers to FFFF. If more than 8 ranges are needed, another compari-
son instruction such as BCMP(68) can be used to compare ranges with the high-
speed counter PVs in IR 230 through IR 235 (SR 248 and SR 249 in
CPM1/CPM1A PCs). Bear in mind that these words are refreshed just once
each cycle.
There are flags in the AR area which indicate when a high-speed counter’s PV
falls within one or more of the 8 ranges. The flags turn ON when a PV is within the
corresponding range.
217
Timer and Counter Instructions Section 5-15
The following diagram shows the structure of a range comparison table for use
with high-speed counter 0, or high-speed counters 1 or 2 in linear mode.
TB Lower limit #1, lower 4 digits (BCD)
TB+1 Lower limit #1, upper 4 digits (BCD)
TB+2 Upper limit #1, lower 4 digits (BCD) First range setting
TB+3 Upper limit #1, upper 4 digits (BCD)
TB+4 Subroutine number (See note 1.)
The following diagram shows the structure of a range comparison table for use
with high-speed counters 1 or 2 in ring mode (CQM1 only). The ring value speci-
fies the number of points in the ring and the maximum count value (ring value =
max. count value+1). Do not change the ring value while a comparison is in prog-
ress.
The following diagram shows the structure of a range comparison table for use
with absolute high-speed counters 1 and 2 (CQM1-CPU44-E/-EV1 only).
TB Lower limit #1(BCD)
TB+2 Upper limit #1 (BCD) First range setting
TB+4 Subroutine number (See note 2.)
Note 1. The subroutine number can be 0000 to 0255 (0000 to 0127 for the
CQM1-CPU11/21-E, 0000 to 0049 for the CPM1/CPM1A) and the subrou-
tine will be executed as long as the counter’s PV is within the specified
range. A value of FFFF indicates that no subroutine is to be executed.
2. The subroutine number can be 0000 to 0255 (0000 to 0127 for the
CQM1-CPU11/21-E, 0000 to 0049 for the CPM1/CPM1A) to activate the
subroutine when incrementing.
3. Allow a time interval of at least 2 ms between the lower and upper limits (up-
per limit – lower limit > 0.002 × input pulse frequency) in range comparisons
with high-speed counters 1 and 2.
218
Timer and Counter Instructions Section 5-15
The following table shows the possible values for target values, lower limit val-
ues, and upper limit values. The hexadecimal value F in the most significant digit
of indicates that the value is negative.
Counter Possible values
High-speed counter 0 Up/Down mode: F003 2767 to 0003 2767
Incrementing mode: 0000 0000 to 0006 5535
High-speed counters 1 and 2 Linear mode: F838 8607 to 0838 8607
Ring mode: 0000 0000 to 0006 4999
Absolute high-speed counters 1 BCD mode: 0000 to 4095
and 2 360° mode: 0000 to 0355 (5° units)
In 360° mode the absolute high-speed counter’s angular values are internally
converted to binary values. The binary value after conversion depends on the
resolution selected in the PC Setup (DM 6643 and/or DM 6644). The following
table shows the converted values for 5° to 45°.
Resolution Converted value
5° 10° 15° 20° 25° 30° 35° 40° 45°
8-bit (0 to 255) 4 7 11 14 18 21 25 28 32
10-bit (0 to 1023) 14 28 43 57 71 85 100 114 128
12-bit (0 to 4095) 57 114 171 228 284 341 398 455 512
For higher values, find the converted value to the nearest 45° and add the re-
mainder from the table. For example, to convert 145° into 8-bit resolution:
32×3 (for 135°) + 7 (for 10°) = 103.
! Caution With 10-bit and 12-bit resolution, interrupt processing might not be triggered
when the angular value matches the comparison value because the converted
values do not match exactly.
Range Range
1 3
Range Range
2 4
As illustrated above, the current count is compared against all the comparison
ranges at the same time and the result for each range is output.
219
Timer and Counter Instructions Section 5-15
CTBL(63) Table Comparison If C is 000 or 001, INI(61) starts or stops comparison of the high-speed counter’s
PV to the comparison table registered with CTBL(63). Refer to 1-5-5 High-speed
Counter 0 Interrupts (CQM1 PCs) or 1-6-5 High-speed Counter Interrupts
(CPM1/CPM1A PCs) for details on table comparison.
220
Timer and Counter Instructions Section 5-15
PV Change If C is 002, INI(61) changes the high-speed counter’s PV to the 8-digit value in P1
and P1+1.
With high-speed counter 0, the PV can be F003 2767 to 0003 2767 in Up/Down
Mode, or 0000 0000 to 0006 5535 in Incremental Mode. The hexadecimal value
F in the most significant digit of PV indicates that PV is negative.
Leftmost 4 digits Rightmost 4 digits Up/Down Mode Incrementing Mode
P1+1 P1 F0032767 to 00032767 00000000 to 00065535
With high-speed counters 1 and 2 (CQM1 only), the PV can be F838 8607 to
0838 8607 in Linear Mode, or 0000 0000 to 0006 4999 in Ring Mode.
The hexadecimal value F in the most significant digit of PV indicates that PV is
negative.
Leftmost 4 digits Rightmost 4 digits Linear Mode Ring Mode
P1+1 P1 F8388607 to 08388607 00000000 to 00064999
(–8,388,607 to 8,388,607)
Stop Pulse Output If C is 003, INI(61) stops pulse output. Refer to 1-3 Pulse Output Functions
(CQM1 Only) and 1-4 Pulse Output Function (CPM1A Only) for details on pulse
output.
Flags ER: The specified port and function are not compatible.
Indirectly addressed DM word is non-existent. (Content of *DM word is
not BCD, or the DM area boundary has been exceeded.)
P1+1 exceeds the data area boundary. (C=002)
There is an error in the operand settings.
INI(61) is executed in an interrupt subroutine while a pulse I/O or high-
speed counter instruction is being executed in the main program.
221
Timer and Counter Instructions Section 5-15
The port specifier (P) specifies the high-speed counter or pulse output.
P Function
000 Specifies high-speed counter 0 or a pulse output from a bit.
001 Specifies high-speed counter 1 or a pulse output from port 1.
002 Specifies high-speed counter 2 or a pulse output from port 2.
High-speed Counter PV If C is 000, PRV(62) reads the specified high-speed counter’s PV and writes the
(C=000) 8-digit value in D and D+1.
With high-speed counter 0, the PV can be F003 2767 to 0003 2767 in Up/Down
Mode, or 0000 0000 to 0006 5535 in Incremental Mode. The hexadecimal value
F in the most significant digit of PV indicates that the PV is negative.
Leftmost 4 digits Rightmost 4 digits Up/Down Mode Incrementing Mode
D+1 D F0032767 to 00032767 00000000 to 00065535
With high-speed counters 1 and 2 (CQM1 only), the PV can be F838 8607 to
0838 8607 in Linear Mode, or 0000 0000 to 0006 4999 in Ring Mode. The hexa-
decimal value F in the most significant digit of PV indicates that the PV is nega-
tive.
Leftmost 4 digits Rightmost 4 digits Linear Mode Ring Mode
D+1 D F8388607 to 08388607 00000000 to 00064999
(–8,388,607 to 8,388,607)
High-speed Counter or If C is 001 (CQM1 only), PRV(62) reads the operating status of the specified
Pulse Output Status high-speed counter or pulse output and writes the data to D. Refer to 1-3-5 De-
(C=001) termining the Status of Ports 1 and 2 for details on determining the status of
pulse outputs.
The following table shows the function of bits in D for high-speed counters 1 and
2, and pulse outputs from ports 1 and 2 (CQM1-CPU43-E/-EV1 only). Bits not
listed in the table are not used and will always be 0.
Bit Function
00 High-speed counter comparison status. (0: Stopped; 1: Comparing)
01 High-speed counter underflow/overflow.
(0: Normal; 1: Underflow/Overflow occurred.)
04 Deceleration of pulse frequency. (0: Not specified; 1: Specified.)
05 Total number of pulses specified. (0: Not specified; 1: Specified.)
06 Pulse output completed. (0: Not completed; 1: Completed)
07 Pulse output status (0: Stopped; 1: Outputting)
222
Timer and Counter Instructions Section 5-15
Note These flags are in AR 05 and AR 06, but those words are normally refreshed only
once each cycle, so the data obtained with PRV(62) will be more up-to-date.
Range Comparison Results If C is 002 (CQM1 only), PRV(62) reads the results of the comparison of the PV
(C=002) to the 8 ranges defined by CTBL(63) and writes this data to D. Bits 00 through 07
of D contain the Comparison Result flags for ranges 1 to 8. (0: Not in range; 1: In
range)
Note These flags are in AR 05 and AR 06, but those words are normally refreshed only
once each cycle, so the data obtained with PRV(62) will be more up-to-date.
Flags ER: The specified port and function are not compatible.
Indirectly addressed DM word is non-existent. (Content of *DM word is
not BCD, or the DM area boundary has been exceeded.)
D+1 exceeds the data area boundary. (C=000)
There is an error in the operand settings.
PRV(62) is executed in an interrupt subroutine while a pulse I/O or high-
speed counter instruction is being executed in the main program.
223
Shift Instructions Section 5-16
R E: End word
E
Limitations E must be greater than or equal to St, and St and E must be in the same data
area.
If a bit address in one of the words used in a shift register is also used in an
instruction that controls individual bit status (e.g., OUT, KEEP(11)), an error
(“COIL/OUT DUPL”) will be generated when program syntax is checked on the
Programming Console or another Programming Device. The program, howev-
er, will be executed as written. See Example 2: Controlling Bits in Shift Registers
for a programming example that does this.
Lost data
Execution condition I
224
Shift Instructions Section 5-16
Example The following example uses the 1-second clock pulse bit (25502) so that the
execution condition produced by 00000 is shifted into IR 010 every second. Out-
put 10000 is turned ON whenever a “1” is shifted into 01007.
00000
I Address Instruction Operands
SFT(10)
25502 00000 LD 00000
P
010 00001 LD 25502
00001 00002 LD 00001
R
010
00003 SFT(10) 010
010
00004 LD 01007
01007
00005 OUT 10000
10000
Limitations St and E must be in the same data area, and E must be greater than or equal to
St.
DM 6144 to DM 6655 cannot be used for St or E.
Description When the execution condition is OFF, WSFT(16) is not executed. When the
execution condition is ON, WSFT(16) shifts data between St and E in word units.
Zeros are written into St and the content of E is lost.
E St + 1 St
F 0 C 2 3 4 5 2 1 0 2 9
Lost
0000
E St + 1 St
3 4 5 2 1 0 2 9 0 0 0 0
Flags ER: The St and E words are in different areas, or St is greater than E.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
225
Shift Instructions Section 5-16
Description When the execution condition is OFF, ASL(25) is not executed. When the execu-
tion condition is ON, ASL(25) shifts a 0 into bit 00 of Wd, shifts the bits of Wd one
bit to the left, and shifts the status of bit 15 into CY.
Bit Bit
CY 15 00
1 0 0 1 1 1 0 0 0 1 0 1 0 0 1 1
0
Precautions A 0 will be shifted into bit 00 every cycle if the undifferentiated form of ASL(25) is
used. Use the differentiated form (@ASL(25)) or combine ASL(25) with
DIFU(13) or DIFD(14) to shift just one time.
Precautions A 0 will be shifted into bit 15 every cycle if the undifferentiated form of ASR(26) is
used. Use the differentiated form (@ASR(26)) or combine ASR(26) with
DIFU(13) or DIFD(14) to shift just one time.
226
Shift Instructions Section 5-16
Description When the execution condition is OFF, ROL(27) is not executed. When the
execution condition is ON, ROL(27) shifts all Wd bits one bit to the left, shifting
CY into bit 00 of Wd and shifting bit 15 of Wd into CY.
Bit Bit
CY 15 00
0 1 0 1 1 0 0 1 1 1 0 0 0 1 1 0 1
Precautions Use STC(41) to set the status of CY or CLC(41) to clear the status of CY before
doing a rotate operation to ensure that CY contains the proper status before
executing ROL(27).
CY will be shifted into bit 00 every cycle if the undifferentiated form of ROL(27) is
used. Use the differentiated form (@ROL(27)) or combine ROL(27) with
DIFU(13) or DIFD(14) to shift just one time.
Description When the execution condition is OFF, ROR(28) is not executed. When the
execution condition is ON, ROR(28) shifts all Wd bits one bit to the right, shifting
CY into bit 15 of Wd and shifting bit 00 of Wd into CY.
Bit Bit
CY 15 00
0 0 1 0 1 0 1 0 0 0 1 1 1 0 0 0 1
Precautions Use STC(41) to set the status of CY or CLC(41) to clear the status of CY before
doing a rotate operation to ensure that CY contains the proper status before
execution ROR(28).
CY will be shifted into bit 15 every cycle if the undifferentiated form of ROR(28) is
used. Use the differentiated form (@ROR(28)) or combine ROR(28) with
DIFU(13) or DIFD(14) to shift just one time.
227
Shift Instructions Section 5-16
Limitations St and E must be in the same data area, and E must be greater than or equal to
St.
DM 6144 to DM 6655 cannot be used for St or E.
Description When the execution condition is OFF, SLD(74) is not executed. When the execu-
tion condition is ON, SLD(74) shifts data between St and E (inclusive) by one
digit (four bits) to the left. 0 is written into the rightmost digit of the St, and the
content of the leftmost digit of E is lost.
E ... St
8 F C 5 D 7 9 1
Lost data 0
Precautions If a power failure occurs during a shift operation across more than 50 words, the
shift operation might not be completed.
A 0 will be shifted into the least significant digit of St every cycle if the undifferen-
tiated form of SLD(74) is used. Use the differentiated form (@SLD(74)) or com-
bine SLD(74) with DIFU(13) or DIFD(14) to shift just one time.
Flags ER: The St and E words are in different areas, or St is greater than E.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
Limitations St and E must be in the same data area, and E must be less than or equal to St.
DM 6144 to DM 6655 cannot be used for St or E.
228
Shift Instructions Section 5-16
Description When the execution condition is OFF, SRD(75) is not executed. When the
execution condition is ON, SRD(75) shifts data between St and E (inclusive) by
one digit (four bits) to the right. 0 is written into the leftmost digit of St and the
rightmost digit of E is lost.
St E
...
3 4 5 2 F 8 C 1
0 Lost data
Precautions If a power failure occurs during a shift operation across more than 50 words, the
shift operation might not be completed.
A 0 will be shifted into the most significant digit of St every cycle if the undifferen-
tiated form of SRD(75) is used. Use the differentiated form (@SRD(75)) or com-
bine SRD(75) with DIFU(13) or DIFD(14) to shift just one time.
Flags ER: The St and E words are in different areas, or St is less than E.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
Limitations St and E must be in the same data area and St must be less than or equal
to E.
DM 6144 to DM 6655 cannot be used for C, St, or E.
Description SFTR(84) is used to create a single- or multiple-word shift register that can shift
data to either the right or the left. To create a single-word register, designate the
same word for St and E. The control word provides the shift direction, the status
to be put into the register, the shift pulse, and the reset input. The control word is
allocated as follows:
15 14 13 12 Not used.
Shift direction
1 (ON): Left (LSB to MSB)
0 (OFF): Right (MSB to LSB)
Reset
229
Shift Instructions Section 5-16
The data in the shift register will be shifted one bit in the direction indicated by bit
12, shifting one bit out to CY and the status of bit 13 into the other end whenever
SFTR(84) is executed with an ON execution condition as long as the reset bit is
OFF and as long as bit 14 is ON. If SFTR(84) is executed with an OFF execution
condition or if SFTR(84) is executed with bit 14 OFF, the shift register will remain
unchanged. If SFTR(84) is executed with an ON execution condition and the re-
set bit (bit 15) is OFF, the entire shift register and CY will be set to zero.
Flags ER: St and E are not in the same data area or ST is greater than E.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
CY: Receives the status of bit 00 of St or bit 15 of E, depending on the shift
direction.
Example In the following example, IR 00000, IR 00001, IR 00002, and IR 00003 are used
to control the bits of C used in @SFTR(84). The shift register is in DM 0010, and
it is controlled through IR 00004.
00000
Address Instruction Operands
03512 Direction
00000 LD 00000
00001 OUT 03512
00001 00002 LD 00001
03513 Status to input 00003 OUT 03513
00004 LD 00002
00005 OUT 03514
00002
Shift pulse
00006 LD 00003
03514
00007 OUT 03515
00008 LD 00004
00003 00009 @SFT(10)
03515 Reset 035
DM 0010
00004 DM 0010
@SFTR(84)
035
DM 0010
DM 0010
C: Control word
Ladder Symbols
IR, SR, AR, DM, HR, LR, #
ASFT(17) @ASFT(17) St: Starting word
C C IR, SR, AR, DM, HR, LR
St St
E: End word
E E IR, SR, AR, DM, HR, LR
Note ASFT(17) is an expansion instruction for the SRM1. The function code 17 is the
factory setting and can be changed for the SRM1 if desired.
Limitations St and E must be in the same data area, and E must be greater than or equal to
St.
DM 6144 to DM 6655 cannot be used for St or E.
230
Shift Instructions Section 5-16
Description When the execution condition is OFF, ASFT(17) does nothing and the program
moves to the next instruction. When the execution condition is ON, ASFT(17) is
used to create and control a reversible asynchronous word shift register be-
tween St and E. This register only shifts words when the next word in the register
is zero, e.g., if no words in the register contain zero, nothing is shifted. Also, only
one word is shifted for each word in the register that contains zero. When the
contents of a word are shifted to the next word, the original word’s contents are
set to zero. In essence, when the register is shifted, each zero word in the regis-
ter trades places with the next word. (See Example below.)
The shift direction (i.e. whether the “next word” is the next higher or the next low-
er word) is designated in C. C is also used to reset the register. All of any portion
of the register can be reset by designating the desired portion with St and E.
Control Word Bits 00 through 12 of C are not used. Bit 13 is the shift direction: turn bit 13 ON to
shift down (toward lower addressed words) and OFF to shift up (toward higher
addressed words). Bit 14 is the Shift Enable Bit: turn bit 14 ON to enable shift
register operation according to bit 13 and OFF to disable the register. Bit 15 is the
Reset bit: the register will be reset (set to zero) between St and E when
ASFT(17) is executed with bit 15 ON. Turn bit 15 OFF for normal operation.
Note If the non-differentiated form of ASFT(17) is used, data will be shifted every cycle
while the execution condition is ON. Use the differentiated form to prevent this.
Flags ER: The St and E words are in different areas, or St is greater than E.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
Example The following example shows instruction ASFT(17) used to shift words in an
11-word shift register created between DM 0100 and DM 0110 with C=#6000.
Non-zero data is shifted towards St (DM 0110).
00000
Address Instruction Operands
ASFT(17)
#6000 00000 LD 00000
DM 0100
00001 ASFT(17)
DM 0110
# 6000
DM 0100
DM 0110
Note The zeroes are shifted “upward” if C=4000, and the entire shift register is set to
zero if C=8000.
231
Data Movement Instructions Section 5-17
Bit status
not changed.
IR 000 0 1 1 1 0 0 1 1 1 0 0 0 0 1 0 1
HR 05 0 1 1 1 0 0 1 1 1 0 0 0 0 1 0 1
232
Data Movement Instructions Section 5-17
Description When the execution condition is OFF, MVN(22) is not executed. When the
execution condition is ON, MVN(22) transfers the inverted content of S (speci-
fied word or four-digit hexadecimal constant) to D, i.e., for each ON bit in S, the
corresponding bit in D is turned OFF, and for each OFF bit in S, the correspond-
ing bit in D is turned ON.
Bit status
inverted.
Example The following example shows @MVN(22) being used to copy the complement of
#F8C5 to DM 0010 when IR 00001 goes from OFF to ON.
00001
@MVN(22)
Address Instruction Operands
#F8C5 00000 LD 00001
DM 0010 00001 @MOV(21)
# F8C5
DM 0010
#F8C5 1 1 1 1 1 0 0 0 1 1 0 0 0 1 0 1
DM 0010 0 0 0 0 0 1 1 1 0 0 1 1 1 0 1 0
Limitations S and S+N must be in the same data area, as must D and D+N.
DM 6144 to DM 6655 cannot be used for D.
233
Data Movement Instructions Section 5-17
Description When the execution condition is OFF, XFER(70) is not executed. When the
execution condition is ON, XFER(70) copies the contents of S, S+1, ..., S+N to
D, D+1, ..., D+N.
S D
3 4 5 2 3 4 5 2
S+1 D+1
3 4 5 1 3 4 5 1
S+2 D+2
3 4 2 2 3 4 2 2
S+N D+N
6 4 5 2 6 4 5 2
Limitations St must be less than or equal to E, and St and E must be in the same data area.
DM 6144 to DM 6655 cannot be used for St or E.
Description When the execution condition is OFF, BSET(71) is not executed. When the
execution condition is ON, BSET(71) copies the content of S to all words from St
through E.
S St
3 4 5 2 3 4 5 2
St+1
3 4 5 2
St+2
3 4 5 2
E
3 4 5 2
BSET(71) can be used to change timer/counter PV. (This cannot be done with
MOV(21) or MVN(22).) BSET(71) can also be used to clear sections of a data
area, i.e., the DM area, to prepare for executing other instructions. It can also be
used to clear words by transferring all zeros.
234
Data Movement Instructions Section 5-17
Flags ER: St and E are not in the same data area or St is greater than E.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
Example The following example shows how to use BSET(71) to copy a constant (#0000)
to a block of the DM area (DM 0000 to DM 0500) when IR 00000 is ON.
E1 E2
If you want to exchange content of blocks whose size is greater than 1 word, use
work words as an intermediate buffer to hold one of the blocks using XFER(70)
three times.
235
Data Movement Instructions Section 5-17
Description DIST(80) can be used for single-word distribution or for a stack operation de-
pending on the content of the control word, C.
Single-word Distribution When bits 12 to 15 of C=0 to 8, DIST(80) can be used for a single word distribute
operation. The entire contents of C specifies an offset, Of.
When the execution condition is OFF, DIST(80) is not executed. When the
execution condition is ON, DIST(80) copies the content of S to DBs+Of, i.e., Of is
added to DBs to determine the destination word.
Note DBs and DBs+Of must be in the same data area and cannot be between
DM 6144 and DM 6655.
Example
The following example shows how to use DIST(80) to copy #00FF to HR 10 + Of.
The content of LR 10 is #3005, so #00FF is copied to HR 15 (HR 10 + 5) when IR
00000 is ON.
LR 10 #00FF HR 10
3 0 0 5 0 0 F F 0 0 0 0
HR 15
0 0 F F
Stack Operation When bits 12 to 15 of C=9, DIST(80) can be used for a stack operation. The other
3 digits of C specify the number of words in the stack (000 to 999). The content of
DBs is the stack pointer.
When the execution condition is OFF, DIST(80) is not executed. When the
execution condition is ON, DIST(80) copies the content of S to DBs+1+the con-
tent of DBs. In other words, 1 and the content of DBs are added to DBs to deter-
mine the destination word. The content of DBs is then incremented by 1.
Note 1. DIST(80) will be executed every cycle unless the differentiated form
(@DIST(80)) is used or DIST(80) is used with DIFU(13) or DIFD(14).
2. Be sure to initialize the stack pointer before using DIST(80) as a stack op-
eration.
236
Data Movement Instructions Section 5-17
Example
The following example shows how to use DIST(80) to create a stack between
DM 0001 and DM 0005. DM 0000 acts as the stack pointer.
IR 001 FFFF
IR 216 9005
Flags ER: The offset or stack length in the control word is not BCD.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
During stack operation, the value of the stack pointer+1 exceeds the
length of the stack.
EQ: ON when the content of S is zero; otherwise OFF.
237
Data Movement Instructions Section 5-17
Example
The following example shows how to use COLL(81) to copy the content of
DM 0000+Of to IR 001. The content of 010 is #0005, so the content of DM 0005
(DM 0000 + 5) is copied to IR 001 when IR 00001 is ON.
DM 0005
0 0 F F
FIFO Stack Operation When bits 12 to 15 of C=9, COLL(81) can be used for an FIFO stack operation.
The other 3 digits of C specify the number of words in the stack (000 to 999). The
content of SBs is the stack pointer.
When the execution condition is ON, COLL(81) shifts the contents of each word
within the stack down by one address, finally shifting the data from SBs+1 (the
first value written to the stack) to the destination word (D). The content of the
stack pointer (SBs) is then decremented by one.
Note COLL(81) will be executed every cycle unless the differentiated form
(@COLL(81)) is used or COLL(81) is used with DIFU(13) or DIFD(14).
Example
The following example shows how to use COLL(81) to create a stack between
DM 0001 and DM 0005. DM 0000 acts as the stack pointer.
When IR 00000 goes from OFF to ON, COLL(81) shifts the contents of DM 0002
to DM 0005 down by one address, and shifts the data from DM 0001 to IR 001.
The content of the stack pointer (DM 0000) is then decremented by one.
IR 216 9005
Stack pointer
DM 0000 0005 decremented DM 0000 0004 IR 001 AAAA
DM 0001 AAAA DM 0001 BBBB
DM 0002 BBBB DM 0002 CCCC
DM 0003 CCCC DM 0003 DDDD
DM 0004 DDDD DM 0004 EEEE
DM 0005 EEEE DM 0005 EEEE
LIFO Stack Operation When bits 12 to 15 of C=8, COLL(81) can be used for an LIFO stack operation.
The other 3 digits of C specify the number of words in the stack (000 to 999). The
content of SBs is the stack pointer.
238
Data Movement Instructions Section 5-17
When the execution condition is ON, COLL(81) copies the data from the word
indicated by the stack pointer (SBs+the content of SBs) to the destination word
(D). The content of the stack pointer (SBs) is then decremented by one.
The stack pointer is the only word changed in the stack.
Note COLL(81) will be executed every cycle unless the differentiated form
(@DIST(80)) is used or DIST(80) is used with DIFU(13) or DIFD(14).
Example
The following example shows how to use COLL(81) to create a stack between
DM 0001 and DM 0005. DM 0000 acts as the stack pointer.
When IR 00000 goes from OFF to ON, COLL(81) copies the content of DM 0005
(DM 0000 + 5) to IR 001. The content of the stack pointer (DM 0000) is then de-
cremented by one.
IR 216 8005
Stack pointer
DM 0000 0005 decremented DM 0000 0004 IR 001 EEEE
DM 0001 AAAA DM 0001 AAAA
DM 0002 BBBB DM 0002 BBBB
DM 0003 CCCC DM 0003 CCCC
DM 0004 DDDD DM 0004 DDDD
DM 0005 EEEE DM 0005 EEEE
Flags ER: The offset or stack length in the control word is not BCD.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
During stack operation, the value of the stack pointer exceeds the
length of the stack; an attempt was made to write to a word beyond the
end of the stack.
EQ: ON when the content of S is zero; otherwise OFF.
Limitations The rightmost two digits and the leftmost two digits of Bi must each be between
00 and 15.
DM 6144 to DM 6655 cannot be used for Bi or D.
239
Data Movement Instructions Section 5-17
Description When the execution condition is OFF, MOVB(82) is not executed. When the
execution condition is ON, MOVB(82) copies the specified bit of S to the speci-
fied bit in D. The bits in S and D are specified by Bi. The rightmost two digits of Bi
designate the source bit; the leftmost two bits designate the destination bit.
Bit Bit
15 00
Bi 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1
Bi
Bit 1 2 0 1 Bit
MSB 1 2 0 1 LSB
15 00
S 0 1 0 1 0 1 0 0 0 1 1 1 0 0 0 1
Source bit (00 to 15)
Bit Bit
Destination bit (00 to 15) 15 00
D 0 1 0 0 0 1 0 0 0 1 1 1 0 0 0 1
Flags ER: Bi is not BCD, or it is specifying a non-existent bit (i.e., bit specification
must be between 00 and 15).
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
First digit in S (0 to 3)
Number of digits (0 to 3)
0: 1 digit
1: 2 digits
2: 3 digits
3: 4 digits
First digit in D (0 to 3)
240
Data Movement Instructions Section 5-17
Digit Designator The following show examples of the data movements for various values of Di.
0 0 0 0
1 1 1 1
2 2 2 2
3 3 3 3
Flags ER: At least one of the rightmost three digits of Di is not between 0 and 3.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
Description When the execution condition is OFF, XFRB(––) is not executed. When the
execution condition is ON, XFRB(––) copies the specified source bits to the spe-
cified destination bits. The two rightmost digits of C specify the starting bits in S
and D and the leftmost two digits indicate the number of bits that will be copied.
C
MSB LSB
First bit of S (0 to F)
First bit of D (0 to F)
Number of bits (00 to FF)
241
Comparison Instructions Section 5-18
Example In the following example, XFRB(––) is used to transfer 5 bits from IR 020 and
IR 021 to LR 00 and LR 01. The starting bit in IR 020 is D (13), and the starting bit
in LR 00 is E (14), so IR 02013 to IR 02101 are copied to LR 0014 to LR 0102.
00001
XFRB(––)
Address Instruction Operands
#05ED 00000 LD 00001
020 00001 XFRB(––)
LR 00 # 05ED
020
LR 00
1 1 1 0 0 0 0 1 0 0 1 1 1 1 0 1 1 1 0 0 0 1 0 0 1 0 1 0 0 0 0 1
Flags ER: The specified source bits are not all in the same data area.
The specified destination bits are not all in the same data area.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
Limitations When comparing a value to the PV of a timer or counter, the value must be in
BCD.
Description When the execution condition is OFF, CMP(20) is not executed. When the
execution condition is ON, CMP(20) compares Cp1 and Cp2 and outputs the
result to the GR, EQ, and LE flags in the SR area.
Precautions Placing other instructions between CMP(20) and the operation which accesses
the EQ, LE, and GR flags may change the status of these flags. Be sure to ac-
cess them before the desired status is changed.
Flags ER: Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
EQ: ON if Cp1 equals Cp2.
LE: ON if Cp1 is less than Cp2.
GR: ON if Cp1 is greater than Cp2.
Flag Address C1 < C2 C1 = C2 C1 > C2
GR 25505 OFF OFF ON
EQ 25506 OFF ON OFF
LE 25507 ON OFF OFF
242
Comparison Instructions Section 5-18
Example: The following example shows how to save the comparison result immediately. If
Saving CMP(20) Results the content of HR 09 is greater than that of 010, 10200 is turned ON; if the two
contents are equal, 10201 is turned ON; if content of HR 09 is less than that of
010, 10202 is turned ON. In some applications, only one of the three OUTs would
be necessary, making the use of TR 0 unnecessary. With this type of program-
ming, 10200, 10201, and 10202 are changed only when CMP(20) is executed.
TR
0
00000
CMP(20)
HR 09
010
25505
10200 Greater Than
25506
10201 Equal
25507
10202 Less Than
Flags ER: The comparison table (i.e., TB through TB+15) exceeds the data area.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
243
Comparison Instructions Section 5-18
Example The following example shows the comparisons made and the results provided
for TCMP(85). Here, the comparison is made during each cycle when IR 00000
is ON.
Note BCMP(68) is an expansion instruction for the SRM1. The function code 68 is the
factory setting and can be changed for the SRM1 if desired.
Limitations Each lower limit word in the comparison block must be less than or equal to the
upper limit.
DM 6144 to DM 6655 cannot be used for R.
Description When the execution condition is OFF, BCMP(68) is not executed. When the
execution condition is ON, BCMP(68) compares CD to the ranges defined by a
block consisting of CB, CB+1, CB+2, ..., CB+31. Each range is defined by two
words, the first one providing the lower limit and the second word providing the
upper limit. If CD is found to be within any of these ranges (inclusive of the upper
and lower limits), the corresponding bit in R is set. The comparisons that are
244
Comparison Instructions Section 5-18
made and the corresponding bit in R that is set for each true comparison are
shown below. The rest of the bits in R will be turned OFF.
CB ≤ CD ≤ CB+1 Bit 00
CB+2 ≤ CD ≤ CB+3 Bit 01
CB+4 ≤ CD ≤ CB+5 Bit 02
CB+6 ≤ CD ≤ CB+7 Bit 03
CB+8 ≤ CD ≤ CB+9 Bit 04
CB+10 ≤ CD ≤ CB+11 Bit 05
CB+12 ≤ CD ≤ CB+13 Bit 06
CB+14 ≤ CD ≤ CB+15 Bit 07
CB+16 ≤ CD ≤ CB+17 Bit 08
CB+18 ≤ CD ≤ CB+19 Bit 09
CB+20 ≤ CD ≤ CB+21 Bit 10
CB+22 ≤ CD ≤ CB+23 Bit 11
CB+24 ≤ CD ≤ CB+25 Bit 12
CB+26 ≤ CD ≤ CB+27 Bit 13
CB+28 ≤ CD ≤ CB+29 Bit 14
CB+30 ≤ CD ≤ CB+31 Bit 15
Flags ER: The comparison block (i.e., CB through CB+31) exceeds the data area.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
Example The following example shows the comparisons made and the results provided
for BCMP(68). Here, the comparison is made during each cycle when IR 00000
is ON.
00000
BCMP(68)
Address Instruction Operands
001 00000 LD 00000
DM 0010 00001 BCMP(68)
LR 05 001
DM 0010
LR 05
245
Comparison Instructions Section 5-18
Note CMPL(60) is an expansion instruction for the SRM1. The function code 60 is the
factory setting and can be changed for the SRM1 if desired.
Limitations Cp1 and Cp1+1 must be in the same data area.
Cp2 and Cp2+1 must be in the same data area.
Set the third operand to 000.
Description When the execution condition is OFF, CMPL(60) is not executed. When the
execution condition is ON, CMPL(60) joins the 4-digit hexadecimal content of
Cp1+1 with that of Cp1, and that of Cp2+1 with that of Cp2 to create two 8-digit
hexadecimal numbers, Cp+1,Cp1 and Cp2+1,Cp2. The two 8-digit numbers are
then compared and the result is output to the GR, EQ, and LE flags in the SR
area.
Precautions Placing other instructions between CMPL(60) and the operation which ac-
cesses the EQ, LE, and GR flags may change the status of these flags. Be sure
to access them before the desired status is changed.
246
Comparison Instructions Section 5-18
Flags ER: One of the tables (i.e., TB1 through TB1+15, or TB2 through TB2+15)
exceeds the data area.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
EQ: ON if the entire contents of both tables are equal and R=0000.
247
Comparison Instructions Section 5-18
Example The following example shows the comparisons made and the results provided
for MCMP(19). Here, the comparison is made during each cycle when 00000 is
ON.
00000
MCMP(19)
Address Instruction Operands
100 00000 LD 00000
DM 0200 00001 MCMP(19)
DM 0300 100
DM 0200
DM 0300
Description When the execution condition is OFF, CPS(––) is not executed. When the
execution condition is ON, CPS(––) compares the 16-bit (4-digit) signed binary
contents in Cp1 and Cp2 and outputs the result to the GR, EQ, and LE flags in the
SR area.
Precautions Placing other instructions between CPS(––) and the operation which accesses
the EQ, LE, and GR flags may change the status of these flags. Be sure to ac-
cess them before the desired status is changed.
248
Comparison Instructions Section 5-18
Example In the following example, the content of 102 is greater than that of DM 0020, so
10000 is turned ON and the other bits, 10001 and 10002, are turned OFF.
249
Comparison Instructions Section 5-18
Precautions Placing other instructions between CPSL(––) and the operation which accesses
the EQ, LE, and GR flags may change the status of these flags. Be sure to ac-
cess them before the desired status is changed.
Flags ER: Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
EQ: ON if Cp1+1, Cp1 equals Cp2+1, Cp2.
LE: ON if Cp1+1, Cp1 is less than Cp2+1, Cp2.
GR: ON if Cp1+1, Cp1 is greater than Cp2+1, Cp2.
Comparison result Flag status
GR (SR 25505) EQ (SR 25506) LE (SR 25507)
Cp1+1, Cp1 < Cp2+1, Cp2 0 0 1
Cp1+1, Cp1 = Cp2+1, Cp2 0 1 0
Cp1+1, Cp1 > Cp2+1, Cp2 1 0 0
Example In the following example, the content of 103, 102 is less than that of DM 0021,
DM 0020, so 10002 is turned ON and the other bits, 10000 and 10001, are
turned OFF.
250
Comparison Instructions Section 5-18
Description When the execution condition is OFF, ZCP(––) is not executed. When the
execution condition is ON, ZCP(––) compares CD to the range defined by lower
limit LL and upper limit UL and outputs the result to the GR, EQ, and LE flags in
the SR area. The resulting flag status is shown in the following table.
Comparison result Flag status
GR (SR 25505) EQ (SR 25506) LE (SR 25507)
CD < LL 0 0 1
LL ≤ CD ≤ UL 0 1 0
UL < CD 1 0 0
Precautions Placing other instructions between ZCP(––) and the operation which accesses
the EQ, LE, and GR flags may change the status of these flags. Be sure to ac-
cess them before the desired status is changed.
EQ: ON if LL ≤ CD ≤ UL
LE: ON if CD < LL.
GR: ON if CD > UL.
Example In the following example, the content of IR 002 (#6FA4) is compared to the range
#0010 to #AB1F. Since #0010 ≤ #6FA4 ≤ #AB1F, the EQ flag and IR 10001 are
turned ON.
TR
0
00000
ZCP(––)
002
#0010
#AB1F
25505
10000 Greater Than
(above range)
25506
10001 Equal
(within range)
25507
10002 Less Than
(below range)
10000: OFF
LL: #0010 CD: 002 UL: #AB1F
0 0 1 0 < 6 F A 4 < A B 1 F
10001: ON
10002: OFF
251
Conversion Instructions Section 5-19
Precautions Placing other instructions between ZCPL(––) and the operation which accesses
the EQ, LE, and GR flags may change the status of these flags. Be sure to ac-
cess them before the desired status is changed.
252
Conversion Instructions Section 5-19
Description When the execution condition is OFF, BIN(23) is not executed. When the execu-
tion condition is ON, BIN(23) converts the BCD content of S into the numerically
equivalent binary bits, and outputs the binary value to R. Only the content of R is
changed; the content of S is left unchanged.
BCD S
Binary R
BIN(23) can be used to convert BCD to binary so that displays on the Program-
ming Console or any other programming device will appear in hexadecimal rath-
er than decimal. It can also be used to convert to binary to perform binary arith-
metic operations rather than BCD arithmetic operations, e.g., when BCD and
binary values must be added.
Limitations If the content of S exceeds 270F, the converted result would exceed 9999 and
BCD(24) will not be executed. When the instruction is not executed, the content
of R remains unchanged.
DM 6144 to DM 6655 cannot be used for R.
Description BCD(24) converts the binary (hexadecimal) content of S into the numerically
equivalent BCD bits, and outputs the BCD bits to R. Only the content of R is
changed; the content of S is left unchanged.
Binary S
BCD R
BCD(24) can be used to convert binary to BCD so that displays on the Program-
ming Console or any other programming device will appear in decimal rather
than hexadecimal. It can also be used to convert to BCD to perform BCD arith-
metic operations rather than binary arithmetic operations, e.g., when BCD and
binary values must be added.
253
Conversion Instructions Section 5-19
Description When the execution condition is OFF, BINL(58) is not executed. When the
execution condition is ON, BINL(58) converts an eight-digit number in S and S+1
into 32-bit binary data, and outputs the converted data to R and R+1.
BCD S+1 S
Binary R+1 R
Flags ER: The contents of S and/or S+1 words are not BCD.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
EQ: ON when the result is zero.
254
Conversion Instructions Section 5-19
Description BCDL(59) converts the 32-bit binary content of S and S+1 into eight digits of
BCD data, and outputs the converted data to R and R+1.
Binary S+1 S
BCD R+1 R
Source word
C
255
Conversion Instructions Section 5-19
The first digit and the number of digits to be converted are designated in Di. If
more digits are designated than remain in S (counting from the designated first
digit), the remaining digits will be taken starting back at the beginning of S. The
final word required to store the converted result (R plus the number of digits to be
converted) must be in the same data area as R, e.g., if two digits are converted,
the last word address in a data area cannot be designated; if three digits are con-
verted, the last two words in a data area cannot be designated.
Digit Designator The digits of Di are set as shown below.
Digit number: 3 2 1 0
Some example Di values and the digit-to-word conversions that they produce
are shown below.
Di: 0010 Di: 0030
S S
0 R 0 R
1 R+1 1 R+1
2 2 R+2
3 3 R+3
Flags ER: Undefined digit designator, or R plus number of digits exceeds a data
area.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD or the DM area boundary has been exceeded.)
256
Conversion Instructions Section 5-19
Example The following program converts digits 1 to 3 of data from DM 0020 to bit positions
and turns ON the corresponding bits in three consecutive words starting with HR
10. Digit 0 is not converted.
00000
MLPX(76) Address Instruction Operands
DM 0020 00000 LD 00000
#0021 00001 MLPX(76)
HR 10 DM 0020
# 0021
HR 10
257
Conversion Instructions Section 5-19
Result word
C
Up to four digits from four consecutive source words starting with S may be en-
coded and the digits written to R in order from the designated first digit. If more
digits are designated than remain in R (counting from the designated first digit),
the remaining digits will be placed at digits starting back at the beginning of R.
The final word to be converted (S plus the number of digits to be converted) must
be in the same data area as SB.
Digit numbers: 3 2 1 0
Some example Di values and the word-to-digit conversions that they produce
are shown below.
Flags ER: Undefined digit designator, or S plus number of digits exceeds a data
area.
Content of a source word is zero.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
258
Conversion Instructions Section 5-19
Example When 00000 is ON, the following diagram encodes IR words 010 and 011 to the
first two digits of HR 10 and then encodes LR 10 and 11 to the last two digits of
HR 10. Although the status of each source word bit is not shown, it is assumed
that the bit with status 1 (ON) shown is the highest bit that is ON in the word.
00000
DMPX(77) Address Instruction Operands
010 00000 LD 00000
HR 10 00001 DMPX(77)
#0010 010
HR 10
DMPX(77)
# 0010
00002 DMPX(77)
LR 10
LR 10
HR 10
HR 10
#0012
# 0012
IR 010 IR 011
01000 01100
: :
01011 1 01109 1
01012 0 01110 0
: : : : : :
HR 10
01015 0 01115 0
Digit 0 B
Digit 1 9
LR 10 LR 11 Digit 2 1
LR 1000 LR 1100 Digit 3 8
LR 1001 1 :
LR 1002 0 LR 1108 1
: : : LR 1109 0
: : : : : :
LR 1015 0 LR 1115 0
259
Conversion Instructions Section 5-19
Any or all of the digits in S may be converted in sequence from the designated
first digit. The first digit, the number of digits to be converted, and the half of D to
receive the first 7-segment display code (rightmost or leftmost 8 bits) are desig-
nated in Di. If multiple digits are designated, they will be placed in order starting
from the designated half of D, each requiring two digits. If more digits are desig-
nated than remain in S (counting from the designated first digit), further digits will
be used starting back at the beginning of S.
Digit Designator The digits of Di are set as shown below.
Digit number: 3 2 1 0
Some example Di values and the 4-bit binary to 7-segment display conversions
that they produce are shown below.
Di: 0011 Di: 0030
S digits D S digits D
0 1st half 0 1st half
1 2nd half 1 2nd half
2 2
3 3 D+1
1st half
2nd half
D+2
1st half
2nd half
260
Conversion Instructions Section 5-19
Example The following example shows the data to produce an 8. The lower case letters
show which bits correspond to which segments of the 7-segment display. The
table underneath shows the original data and converted code for all hexadeci-
mal digits.
00000
@ SDEC(78)
DM 0010
LR 07
100
a
LR 07 DM 0010 IR 100
f b
g
0 20 0 Bit 00 1 a
1 21 1 1 b
1: Second digit e c
x100 0 1 c
0 22 0
0 23 0 1 d d
0 20 0 1 e
0 21 0 8 1 f
x101 0: One digit 1
0 22 0 1 g
0 23 1 Bit 07 0
0 20 0
0 21 1
x102 0 or 1: 2
0 0 Bits 00 through 07 22 1
1 Bits 08 through 15.
0 23 1
0 20 1
0 x103 3 21 0
Not used.
0 22 1
0 23 1
261
Conversion Instructions Section 5-19
Flags ER: Incorrect digit designator, or data area for destination exceeded.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
Description When the execution condition is OFF, ASC(86) is not executed. When the
execution condition is ON, ASC(86) converts the designated digit(s) of S into the
equivalent 8-bit ASCII code and places it into the destination word(s) beginning
with D.
Any or all of the digits in S may be converted in order from the designated first
digit. The first digit, the number of digits to be converted, and the half of D to re-
ceive the first ASCII code (rightmost or leftmost 8 bits) are designated in Di. If
multiple digits are designated, they will be placed in order starting from the des-
ignated half of D, each requiring two digits. If more digits are designated than
remain in S (counting from the designated first digit), further digits will be used
starting back at the beginning of S.
Digit number: 3 2 1 0
262
Conversion Instructions Section 5-19
Some examples of Di values and the 4-bit binary to 8-bit ASCII conversions that
they produce are shown below.
Di: 0011 Di: 0030
S D S D
0 1st half 0 1st half
1 2nd half 1 2nd half
2 2
3 3 D+1
1st half
2nd half
D+2
1st half
2nd half
Parity The leftmost bit of each ASCII character (2 digits) can be automatically adjusted
for either even or odd parity. If no parity is designated, the leftmost bit will always
be zero.
When even parity is designated, the leftmost bit will be adjusted so that the total
number of ON bits is even, e.g., when adjusted for even parity, ASCII “31”
(00110001) will be “B1” (10110001: parity bit turned ON to create an even num-
ber of ON bits); ASCII “36” (00110110) will be “36” (00110110: parity bit turned
OFF because the number of ON bits is already even). The status of the parity bit
does not affect the meaning of the ASCII code.
When odd parity is designated, the leftmost bit of each ASCII character will be
adjusted so that there is an odd number of ON bits.
Flags ER: Incorrect digit designator, or data area for destination exceeded.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
263
Conversion Instructions Section 5-19
Parity 0: none
1: even
2: odd
264
Conversion Instructions Section 5-19
Some examples of Di values and the 8-bit ASCII to 4-bit hexadecimal conver-
sions that they produce are shown below.
Di: 0011 Di: 0030
S D S D
1st byte 0 1st byte 0
2nd byte 1 2nd byte 1
2 2
3 S+1 3
1st byte
2nd byte
S+2
1st byte
2nd byte
ASCII Code Table The following table shows the ASCII codes before conversion and the hexadeci-
mal values after conversion. Refer to Appendix H for a table of ASCII characters.
Original data Converted data
ASCII Code Bit status (See note.) Digit Bits
30 * 0 1 1 0 0 0 0 0 0 0 0 0
31 * 0 1 1 0 0 0 1 1 0 0 0 1
32 * 0 1 1 0 0 1 0 2 0 0 1 0
33 * 0 1 1 0 0 1 1 3 0 0 1 1
34 * 0 1 1 0 1 0 0 4 0 1 0 0
35 * 0 1 1 0 1 0 1 5 0 1 0 1
36 * 0 1 1 0 1 1 0 6 0 1 1 0
37 * 0 1 1 0 1 1 1 7 0 1 1 1
38 * 0 1 1 1 0 0 0 8 1 0 0 0
39 * 0 1 1 1 0 0 1 9 1 0 0 1
41 * 1 0 1 0 0 0 1 A 1 0 1 0
42 * 1 0 1 0 0 1 0 B 1 0 1 1
43 * 1 0 1 0 0 1 1 C 1 1 0 0
44 * 1 0 1 0 1 0 0 D 1 1 0 1
45 * 1 0 1 0 1 0 1 E 1 1 1 0
46 * 1 0 1 0 1 1 0 F 1 1 1 1
Note The leftmost bit of each ASCII code is adjusted for parity.
Parity The leftmost bit of each ASCII character (2 digits) is automatically adjusted for
either even or odd parity.
With no parity, the leftmost bit should always be zero. With odd or even parity, the
leftmost bit of each ASCII character should be adjusted so that there is an odd or
even number of ON bits.
If the parity of the ASCII code in S does not agree with the parity specified in Di,
the ER Flag (SR 25503) will be turned ON and the instruction will not be
executed.
265
Conversion Instructions Section 5-19
Flags ER: Incorrect digit designator, or data area for destination exceeded.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
Example In the following example, the 2nd byte of LR 10 and the 1st byte of LR 11 are con-
verted to hexadecimal values and those values are written to the first and se-
cond bytes of IR 010.
LR 10 00000 LD 00000
HR 10 00001 @HEX(––)
010
LR 10
HR 10
010
HR 10 0 1 1 0
LR 12 3 5 3 4 LR 11 4 2 3 2 LR 10 3 1 3 0
Conversion to
hexadecimal
010 0 0 2 1
Description SCL(66) is used to linearly convert a 4-digit hexadecimal value to a 4-digit BCD
value. Unlike BCD(24), which converts a 4-digit hexadecimal value to its 4-digit
BCD equivalent (Shex → SBCD), SCL(66) can convert the hexadecimal value ac-
cording to a specified linear relationship. The conversion line is defined by two
points specified in the parameter words P1 to P1+3.
When the execution condition is OFF, SCL(66) is not executed. When the execu-
tion condition is ON, SCL(66) converts the 4-digit hexadecimal value in S to the
4-digit BCD value on the line defined by points (P1, P1+1) and (P1+2, P1+3) and
places the results in R. The results is rounded off to the nearest integer. If the
results is less than 0000, then 0000 is written to R, and if the result is greater than
9999, then 9999 is written to R.
266
Conversion Instructions Section 5-19
The following table shows the functions and ranges of the parameter words:
BY
AY
The results can be calculated by first converting all values to BCD and then using
the following formula.
Results = BY – [(BY – AY)/(BX – AX) X (BX – S)]
P1 and P1+3 are not in the same data area, or other setting error.
Example When 00000 is turned ON in the following example, the BCD source data in
DM 0100 (#0100) is converted to hexadecimal according to the parameters in
DM 0150 to DM 0153. The result (#0512) is then written to DM 0200.
267
Conversion Instructions Section 5-19
∆Y
∆X
R
X-intercept
268
Conversion Instructions Section 5-19
The result can be calculated by first converting all signed hexadecimal values to
BCD and then using the following formula.
R + Y (S–P1)
X
2
FFFD IR 001 FFE2
DM 0000 FFFD 3
DM 0001 0003 FFE2
DM 0002 0002
LR 00 0018 CY=1
–0018
CY flag is turned ON because
R + 0002 (FFE2–FFFD) the conversion result is negative.
0003
+2 (–1B) + –18
3
269
Conversion Instructions Section 5-19
Description SCL3(––) is used to linearly convert a 4-digit 4-digit BCD value to 4-digit signed
hexadecimal. SCL3(––) converts the BCD value according to a specified linear
relationship. The conversion line is defined by the y-intercept and the slope of
the line specified in the parameter words P1 to P1+2.
When the execution condition is OFF, SCL3(––) is not executed. When the
execution condition is ON, SCL3(––) converts the 4-digit BCD value in S to the
4-digit signed hexadecimal value on the line defined by the y-intercept (0, P1)
and the slope (P1+2 ÷ P1+1) and places the result in R. The result is rounded off
to the nearest integer.
The content of S can be 0000 to 9999, but S will be treated as a negative value if
CY=1, so the effective range of S is actually –9999 to 9999. Be sure to set the
desired sign in CY using STC(40) or CLC(41).
Parameter words P1+3 and P1+4 define upper and lower limits for the result. If
the result is greater than the upper limit in P1+3, then the upper limit is written to
R. If the result is less than the lower limit in P1+4, then the lower limit is written to
R.
Note The upper and lower limits for a 12-bit Analog Input Unit would be 07FF and
F800.
The following table shows the functions and ranges of the parameter words:
Parameter Function Range
P1 x-intercept (signed hex.) 8000 to 7FFF (–32,768 to 32,767)
P1+1 ∆X (BCD) 0000 to 9999
P1+2 ∆Y (signed hex.) 8000 to 7FFF (–32,768 to 32,767)
P1+3 Upper limit (signed hex.) 8000 to 7FFF (–32,768 to 32,767)
P1+4 Lower limit (signed hex.) 8000 to 7FFF (–32,768 to 32,767)
The following diagram shows the source word, S, converted to R according to
the line defined by the point (0, P1) and slope ∆Y/∆X.
Value after conversion
(Signed hexadecimal) ∆Y
Upper limit
∆X
R
Y-intercept
Value before con-
S version (BCD)
Lower limit
The result can be calculated by first converting all BCD values to signed binary
and then using the following formula.
R+ ǒY
X
Ǔ
S ) P1
270
Conversion Instructions Section 5-19
Example The status of 00101 determines the sign of the BCD source word in the following
example. If 00101 is ON, then the source word is negative. When 00100 is
turned ON, the BCD source data in LR 02 is converted to signed binary accord-
ing to the parameters in DM 0000 to DM 0004. The result is then written to
DM 0100. (In the second conversion, the signed binary equivalent of –1035 is
less than the lower limit specified in DM 0004, so the lower limit is written to
DM 0100.)
25313
(Always ON)
Address Instruction Operands
CLC(41)
00000 LD 25313
00101
00001 CLC(41)
STC(40) 00002 LD 00101
00101 STC(40)
00100 00004 LD 00100
@SCL3(––) 00005 SCL3(––)
LR 02 LR 02
DM 0000 DM 0000
DM 0100 DM 0100
Signed hex.
CY=0 CY=1
6 DM 0000 0005
LR 02 0100 LR 02 1035
DM 0001 0003
3
0005 DM 0002 0006
BCD DM 0003 07FF
DM 0100 00CD DM 0100 F800
DM 0004 F800
000
271
Conversion Instructions Section 5-19
Flags ER: S and S+1 or R and R+1 are not in the same data area.
S and/or S+1 do not contain BCD.
Number of seconds and/or minutes exceeds 59.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
EQ: ON when the result is zero.
Example When 00000 is OFF (i.e., when the execution condition is ON), the following
instruction would convert the hours, minutes, and seconds given in HR 12 and
HR 13 to seconds and store the results in DM 0100 and DM 0101 as shown.
00000
SEC(––)
Address Instruction Operands
HR 12 00000 LD NOT 00000
DM 0100 00001 SEC(––)
000 HR 12
DM 0100
HR 12 3 2 0 7 2,815 hrs, 32 min, 000
HR 13 2 8 1 5 07 s
DM 0100 5 9 2 7 10,135,927 s
DM 0101 1 0 1 3
000
Flags ER: S and S+1 or R and R+1 are not in the same data area.
S and/or S+1 do not contain BCD or exceed 36,000,000 seconds.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
EQ: ON when the result is zero.
272
Conversion Instructions Section 5-19
Example When 00000 is OFF (i.e., when the execution condition is ON), the following
instruction would convert the seconds given in HR 12 and HR 13 to hours, min-
utes, and seconds and store the results in DM 0100 and DM 0101 as shown.
00000
HMS(––)
Address Instruction Operands
HR 12 00000 LD NOT 00000
DM 0100 00001 HMS(––)
000 HR 12
DM 0100
HR 12 5 9 2 7 10,135,927 s
000
HR 13 1 0 1 3
DM 0100 3 2 0 7
2,815 hrs, 32 min, 07 s
DM 0101 2 8 1 5
Bit
C Bit
15 00
S 0 0 0 0 1 1 1 0 0 0 1 0 0 0 0 1
S+1 1 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1
S+2 0 0 0 1 1 0 1 1 0 0 1 0 0 1 1 1
S+3 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1
. . . .
. . . .
. . . .
S+15 0 1 1 1 0 0 0 1 1 0 0 0 1 0 1 0 Bit Bit
15 00
D 0 . . . 0 1 1 1
Flags ER: The column bit designator C is not BCD, or it is specifying a non-existent
bit (i.e., bit specification must be between 00 and 15).
273
Conversion Instructions Section 5-19
S 0 . . . . . . . 0 1 1 1
Bit C 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
Flags ER: The bit designator C is not BCD, or it is specifying a non-existent bit (i.e.,
bit specification must be between 00 and 15).
274
Conversion Instructions Section 5-19
Example The following example shows how to use COLM(––) to move the contents of
word DM 0100 (00 to 15) to bit column 15 of the set (DM 0200 to DM 0215).
00000
COLM(––)
Address Instruction Operands
DM 0100 00000 LD 00000
DM 0200 00001 COLM(––)
#0015 DM 0100
DM 0200
# 0015
Description Converts the four-digit hexadecimal content of the source word (S) to its 2’s
complement and outputs the result to the result word (R). This operation is effec-
tively the same as subtracting S from 0000 and outputting the result to R; it will
calculate the absolute value of negative signed binary data.
If the content of S is 0000, the content of R will also be 0000 after execution and
EQ (SR 25506) will be turned on.
If the content of S is 8000, the content of R will also be 8000 after execution and
UF (SR 25405) will be turned on.
Note Refer to 1-10 Calculating with Signed Binary Data for more details.
275
Conversion Instructions Section 5-19
Example The following example shows how to use NEG(––) to find the 2’s complement of
the content of DM 0005 and output the result to IR 105.
00100
NEG(––)
Address Instruction Operands
DM 0005 00000 LD 00100
105 00001 NEG(––)
000 DM 0005
105
000
#0000
Description Converts the eight-digit hexadecimal content of the source words (S and S+1) to
its 2’s complement and outputs the result to the result words (R and R+1). This
operation is effectively the same as subtracting the eight-digit content S and S+1
from $0000 0000 and outputting the result to R and R+1; it will calculate the ab-
solute value of negative signed binary data.
If the content of S is 0000 0000, the content of R will also be 0000 0000 after
execution and EQ (SR 25506) will be turned on.
If the content of S is 8000 0000, the content of R will also be 8000 0000 after
execution and UF (SR 25405) will be turned on.
Note Refer to 1-10 Calculating with Signed Binary Data for more details.
276
Conversion Instructions Section 5-19
Example The following example shows how to use NEGL(––) to find the 2’s complement
of the hexadecimal value in IR 151, IR 150 (001F FFFF) and output the result to
HR 04, HR 03.
00000
NEGL(––)
Address Instruction Operands
150 00000 LD 00000
LR 03 00001 NEGL(––)
000 150
LR 03
000
0000 0000
– 001F FFFF
R+1: LR 04 R: LR 03
FFE0 0001
277
BCD Calculation Instructions Section 5-20
STC(40) @STC(40)
When the execution condition is OFF, STC(40) is not executed. When the
execution condition is ON, STC(40) turns ON CY (SR 25504).
Note Refer to Appendix B Error and Arithmetic Flag Operation for a table listing the
instructions that affect CY.
CLC(41) @CLC(41)
When the execution condition is OFF, CLC(41) is not executed. When the
execution condition is ON, CLC(41) turns OFF CY (SR 25504).
CLEAR CARRY is used to reset (turn OFF) CY (SR 25504) to “0.”
Note Refer to Appendix B Error and Arithmetic Flag Operation for a table listing the
instructions that affect CY.
Au + Ad + CY CY R
278
BCD Calculation Instructions Section 5-20
Example If 00002 is ON, the program represented by the following diagram clears CY with
CLC(41), adds the content of IR 030 to a constant (6103), places the result in DM
0100, and then moves either all zeros or 0001 into DM 0101 depending on the
status of CY (25504). This ensures that any carry from the last digit is preserved
in R+1 so that the entire result can be later handled as eight-digit data.
TR 0
Address Instruction Operands
00002 00000 LD 00002
CLC(41) 00001 OUT TR 0
00002 CLC(41)
ADD(30)
00003 AND(30)
030
030
# 6103
#6103
DM 0100
DM 0100
00004 AND 25504
25504
00005 MOV(21)
MOV(21)
# 0001
#0001
DM 0101
DM 0101
00006 LD TR 0
25504 00007 AND NOT 25504
MOV(21)
00008 MOV(21)
#0000
# 0000
DM 0101
DM 0101
Although two ADD(30) can be used together to perform eight-digit BCD addition,
ADDL(54) is designed specifically for this purpose.
Mi – Su – CY CY R
279
BCD Calculation Instructions Section 5-20
! Caution Be sure to clear the carry flag with CLC(41) before executing SUB(31) if its pre-
vious status is not required, and check the status of CY after doing a subtraction
with SUB(31). If CY is ON as a result of executing SUB(31) (i.e., if the result is
negative), the result is output as the 10’s complement of the true answer. To con-
vert the output result to the true value, subtract the value in R from 0.
Example When 00002 is ON, the following ladder program clears CY, subtracts the con-
tents of DM 0100 and CY from the content of 010 and places the result in HR 10.
If CY is set by executing SUB(31), the result in HR 10 is subtracted from zero
(note that CLC(41) is again required to obtain an accurate result), the result is
placed back in HR 10, and HR 1100 is turned ON to indicate a negative result.
If CY is not set by executing SUB(31), the result is positive, the second subtrac-
tion is not performed, and HR 1100 is not turned ON. HR 1100 is programmed as
a self-maintaining bit so that a change in the status of CY will not turn it OFF
when the program is rescanned.
In this example, differentiated forms of SUB(31) are used so that the subtraction
operation is performed only once each time 00002 is turned ON. When another
subtraction operation is to be performed, 00002 will need to be turned OFF for at
least one cycle (resetting HR 1100) and then turned back ON.
TR 0
00002
CLC(41)
@SUB(31) First
010
subtraction
DM 0100
HR 10
25504
CLC(41)
@SUB(31) Second
#0000
subtraction
HR 10
HR 10
25504
HR 1100
280
BCD Calculation Instructions Section 5-20
The first and second subtractions for this diagram are shown below using exam-
ple data for 010 and DM 0100.
Note The actual SUB(31) operation involves subtracting Su and CY from 10,000 plus
Mi. For positive results the leftmost digit is truncated. For negative results the
10s complement is obtained. The procedure for establishing the correct answer
is given below.
First Subtraction
IR 010 1029
DM 0100 – 3452
CY –0
HR 10 7577 (1029 + (10000 – 3452))
CY 1 (negative result)
Second Subtraction
0000
HR 10 –7577
CY –0
HR 10 2423 (0000 + (10000 – 7577))
CY 1 (negative result)
In the above case, the program would turn ON HR 1100 to indicate that the value
held in HR 10 is negative.
281
BCD Calculation Instructions Section 5-20
Description When the execution condition is OFF, MUL(32) is not executed. When the
execution condition is ON, MUL(32) multiplies Md by the content of Mr, and
places the result In R and R+1.
Md
X Mr
R +1 R
Example When IR 00000 is ON with the following program, the contents of IR 013 and
DM 0005 are multiplied and the result is placed in HR 07 and HR 08. Example
data and calculations are shown below the program.
00000
Address Instruction Operands
MUL(32)
013
00000 LD 00000
00001 MUL(32)
DM 0005
013
HR 07
DM 0005
HR 07
Md: IR 013
3 3 5 6
Mr: DM 0005
X 0 0 2 5
R+1: HR 08 R: HR 07
0 0 0 8 3 9 0 0
Limitations R and R+1 must be in the same data area. DM 6143 to DM 6655 cannot be used
for R.
282
BCD Calculation Instructions Section 5-20
Description When the execution condition is OFF, DIV(33) is not executed and the program
moves to the next instruction. When the execution condition is ON, Dd is divided
by Dr and the result is placed in R and R + 1: the quotient in R and the remainder
in R + 1.
Remainder Quotient
R+1 R
Dr Dd
Example When IR 00000 is ON with the following program, the content of IR 216 is divided
by the content of HR 09 and the result is placed in DM 0017 and DM 0018. Exam-
ple data and calculations are shown below the program.
00000
Address Instruction Operands
DIV(33)
00000 LD 00000
216
00001 DIV(33)
HR 09
216
DM 0017 HR 09
Quotient Remainder DM 0017
R: DM 0017 R + 1: DM 0018
1 1 5 0 0 0 0 2
283
BCD Calculation Instructions Section 5-20
Description When the execution condition is OFF, ADDL(54) is not executed. When the
execution condition is ON, ADDL(54) adds the contents of CY to the 8-digit val-
ue in Au and Au+1 to the 8-digit value in Ad and Ad+1, and places the result in R
and R+1. CY will be set if the result is greater than 99999999.
Au + 1 Au
Ad + 1 Ad
+ CY
CY R+1 R
Example When 00000 is ON, the following program section adds two 12-digit numbers,
the first contained in LR 00 through LR 02 and the second in DM 0010 through
DM 0012. The result is placed in HR 10 through HR 13.
The rightmost 8 digits of the two numbers are added using ADDL(54), i.e., the
contents of LR 00 and LR 01 are added to DM 0010 and DM 0011 and the results
is placed in HR 10 and HR 11. The second addition adds the leftmost 4 digits of
each number using ADD(30), and includes any carry from the first addition. The
last instruction, ADB(50) (see 5-21-1 BINARY ADD – ADB(50)) adds two all-
zero constants to place any carry from the second addition into HR 13.
00000
Address Instruction Operands
CLC(41)
00000 LD 00000
@ADDL(54) 00001 CLC(41)
LR 00 00002 @ADDL(54)
DM 0010 LR 00
HR 10 DM 0010
HR 10
@ADD(30)
00003 @ADD(30)
LR 02
LR 02
DM 0012
DM 0012
HR 12
HR 12
@ADB(50) 00004 @ADB(50)
#0000 # 0000
#0000
# 0000
HR 13
HR 13
284
BCD Calculation Instructions Section 5-20
Mi + 1 Mi
Su + 1 Su
– CY
CY R+1 R
Example The following example works much like that for single-word subtraction. In this
example, however, BSET(71) is required to clear the content of DM 0000 and
285
BCD Calculation Instructions Section 5-20
TR 0
00003
CLC(41)
@SUBL(55) First
HR 00 subtraction
120
DM 0100
25504
@BSET(71)
#0000
DM 0000
DM 0001
CLC(41)
@SUBL(55) Second
DM 0000 subtraction
DM 0100
DM 0100
25504
HR 0100
286
BCD Calculation Instructions Section 5-20
Description When the execution condition is OFF, MULL(56) is not executed. When the
execution condition is ON, MULL(56) multiplies the eight-digit content of Md and
Md+1 by the content of Mr and Mr+1, and places the result in R to R+3.
Md + 1 Md
x Mr + 1 Mr
Description When the execution condition is OFF, DIVL(57) is not executed. When the
execution condition is ON, DIVL(57) the eight-digit content of Dd and D+1 is di-
vided by the content of Dr and Dr+1 and the result is placed in R to R+3: the quo-
tient in R and R+1, the remainder in R+2 and R+3.
Remainder Quotient
Dr+1 Dr Dd+1 Dd
287
BCD Calculation Instructions Section 5-20
Description When the execution condition is OFF, ROOT(72) is not executed. When the
execution condition is ON, ROOT(72) computes the square root of the eight-dig-
it content of Sq and Sq+1 and places the result in R. The fractional portion is trun-
cated.
Sq+1 Sq
Example The following example shows how to take the square root of an eight digit num-
ber. The result is a four-digit number, with the remainder rounded off. and then
round the result.
In this example, √63250561 = 7953.0221..., which is rounded off to 7953.
DM 0001 DM 0000
6 3 2 5 0 5 6 1
63,250,561 = 7953.0221
(The remainder is rounded off.)
001
7 9 5 3
288
Binary Calculation Instructions Section 5-21
Au + Ad + CY CY R
ADB(50) can also be used to add signed binary data. With the
CQM1-CPU4-EV1, CPM1A, and SRM1, the underflow and overflow flags (SR
25404 and SR 25405) indicate whether the result has exceeded the lower or up-
per limits of the 16-bit signed binary data range.
289
Binary Calculation Instructions Section 5-21
In the case below, A6E2 + 80C5 = 127A7. The result is a 5-digit number, so CY
(SR 25504) = 1, and the content of R + 1 becomes #0001.
Au: IR 010
A 6 E 2
Ad: DM 0100
+ 8 0 C 5
R+1: HR 11 R: HR 10
0 0 0 1 2 7 A 7
Note For signed binary calculations, the status of the UF and OF flags indicate wheth-
er the result has exceeded the signed binary data range (–32,768 (8000) to
+32,767 (7FFF)). (CQM1-CPU4-EV1 only)
Mi – Su – CY CY R
290
Binary Calculation Instructions Section 5-21
In the case below, the content of LR 00 (#7A03) and CY are subtracted from
IR 002 (#F8C5). Since the result is positive, CY is 0.
If the result had been negative, CY would have been set to 1. For normal (un-
signed) data, the result would have to be converted to its 2’s complement.
Mi: IR 002
F 8 C 5
Su: LR 00
– 7 A 0 3 CY = 0
(from CLC(41))
– 0 0 0 0
R: HR 01
7 E C 2
Note For signed binary calculations, the status of the UF and OF flags indicate wheth-
er the result has exceeded the signed binary data range (–32,768 (8000) to
+32,767 (7FFF)). (CQM1-CPU4-EV1 only)
291
Binary Calculation Instructions Section 5-21
Description When the execution condition is OFF, MLB(52) is not executed. When the
execution condition is ON, MLB(52) multiplies the content of Md by the contents
of Mr, places the rightmost four digits of the result in R, and places the leftmost
four digits in R+1.
Md
X Mr
R +1 R
Description When the execution condition is OFF, DVB(53) is not executed. When the
execution condition is ON, DVB(53) divides the content of Dd by the content of
Dr and the result is placed in R and R+1: the quotient in R, the remainder in R+1.
Quotient Remainder
R R+1
Dr Dd
292
Binary Calculation Instructions Section 5-21
Au + 1 Au
Ad + 1 Ad
+ CY
CY R+1 R
ADBL(––) can also be used to add signed binary data. The underflow and over-
flow flags (SR 25404 and SR 25405) indicate whether the result has exceeded
the lower or upper limits of the 32-bit signed binary data range.
293
Binary Calculation Instructions Section 5-21
Example The following example shows an eight-digit addition with CY (SR 25504) used to
represent the status of the 9th digit. The status of the UF and OF flags indicate
whether the result has exceeded the signed binary data range (–2,147,483,648
(8000 0000) to +2,147,483,647 (7FFF FFFF)).
Au + 1 : LR 01 Au : LR 00
8 0 0 0 0 0 0 0
Ad + 1 : DM 0011 Ad : DM 0010
F F F F F F F 0
CY R + 1 : DM 0021 R : DM 0020
1 7 F F F F F F 0
1 UF (SR 25405)
0 OF (SR 25404)
Note 1. For unsigned binary addition, CY indicates that the sum of the two values
exceeds FFFF FFFF. (UF and OF can be ignored.)
2. For signed binary addition, the UF flag indicates that the sum of the two val-
ues is below –2,147,483,648 (8000 0000). (CY can be ignored.)
294
Binary Calculation Instructions Section 5-21
Description When the execution condition is OFF, SBBL(––) is not executed. When the
execution condition is ON, SBBL(––) subtracts CY and the eight-digit value in Su
and Su+1 from the eight-digit value in Mi and Mi+1, and places the result in R and
R+1. If the result is negative, CY is set and the 2’s complement of the actual re-
sult is placed in R+1 and R. Use NEGL(––) to convert the 2’s complement to the
true result.
Mi + 1 Mi
Su + 1 Su
– CY
CY R+1 R
SBBL(––) can also be used to subtract signed binary data. The underflow and
overflow flags (SR 25404 and SR 25405) indicate whether the result has ex-
ceeded the lower or upper limits of the 32-bit signed binary data range.
Mi + 1 : LR 03 Mi : LR 02
7 F F F F F F 0
Su + 1 : DM 0023 Su : DM 0022
– F F F F F F F 0
CY R + 1 : LR 03 R : LR 02
1 8 0 0 0 0 0 0 0
0 UF (SR 25405)
1 OF (SR 25404)
Note 1. For unsigned binary data, CY indicates that the result is negative. Take the
2’s complement using NEGL(––) to obtain the absolute value of the true re-
sult. (UF and OF can be ignored.)
2. For signed binary data, the OF flag indicates that the result exceeds
+2,147,483,647 (7FFF FFFF). (CY can be ignored.)
295
Binary Calculation Instructions Section 5-21
Description MBS(––) multiplies the signed binary content of two words and outputs the
8-digit signed binary result to R+1 and R. The rightmost four digits of the result
are placed in R, and the leftmost four digits are placed in R+1.
Note Refer to 1-10 Calculating with Signed Binary Data for more details.
Md
X Mr
R +1 R
Example In the following example, MBS(––) is used to multiply the signed binary contents
of DM 0010 with the signed binary contents of DM 0012 and output the result to
DM 0100 and DM 0101.
Md: DM 0010
1 5 B 1 (5,553)
Mr: DM 0012
X F C 1 3 (–1,005)
296
Binary Calculation Instructions Section 5-21
Md + 1 Md
x Mr + 1 Mr
Example In the following example, MBSL(––) is used to multiply the signed binary con-
tents of IR 101 and IR 100 with the signed binary contents of DM 0021 and
DM 0020 and output the result to LR 24 through LR 01.
297
Binary Calculation Instructions Section 5-21
Quotient Remainder
R R+1
Dr Dd
Example In the following example, DBS(––) is used to divide the signed binary contents of
DM 0010 with the signed binary contents of DM 0020 and output the result to
LR 21 and LR 02.
Dd: DM 0010
D D D A (–8,742)
÷
Dr: DM 0020
0 0 1 A (26)
R+1: LR 02 R: LR 01
F F F A F E B 0 (–336 and –6/26)
Remainder (–6) Quotient (–336)
298
Binary Calculation Instructions Section 5-21
Dr+1 Dr Dd+1 Dd
299
Special Math Instructions Section 5-22
C: 15 14 13 12 11 00
Number of words
in range (N)
Not used – set to zero.
! Caution If bit 14 of C is ON, values above #8000 are treated as negative numbers, so the
results will differ depending on the specified data type. Be sure that the correct
data type is specified.
300
Special Math Instructions Section 5-22
C: 15 14 13 12 11 00
Number of words
in range (N)
Not used – set to zero.
301
Special Math Instructions Section 5-22
! Caution If bit 14 of C is ON, values above #8000 are treated as negative numbers, so the
results will differ depending on the specified data type. Be sure that the correct
data type is specified.
Precautions The average value is calculated in binary. Be sure that the content of S is in
binary.
N must be BCD from #0001 to #0064. If the content of N ≥ #0065, AVG(––) will
operate with N=64.
The average value will be rounded off to the nearest integer value. (0.5 is
rounded up to 1.)
Leave the contents of D+1 set to #0000 after the first execution of AVG(––).
302
Special Math Instructions Section 5-22
Example In the following example, the content of IR 040 is set to #0000 and then increm-
ented by 1 each cycle. For the first two cycles, AVG(––) moves the content of
IR 040 to DM 1002 and DM 1003. On the third and later cycles AVG(––) calcu-
lates the average value of the contents of DM 1002 to DM 1004 and writes that
average value to DM 1000.
00001
@MOV(21)
Address Instruction Operands
#0000
00000 LD 00001
040
00001 @MOV(21)
# 0000
AVG(––)
040
040
00002 AVG(––)
#0003 040
DM 1000 # 0003
DM 1000
CLC(41) 00003 CLC(41)
00004 ADB(50)
040
ADB(50)
# 0001
040
040
#0001
040
303
Special Math Instructions Section 5-22
C: 15 14 13 12 11 00
Number of Items in Range The number of items within the range (N) is contained in the 3 rightmost digits of
C, which must be BCD between 001 and 999. This number will indicate the num-
ber of words or the number of bytes depending the items being summed.
Addition Units Words will be added if bit 13 is OFF and bytes will be added if bit 13 is ON.
If bytes are specified, the range can begin with the leftmost or rightmost byte of
R1. The leftmost byte of R1 will not be added if bit 12 is ON.
MSB LSB
R1 1 2
R1+1 3 4
R1+2 5 6
R1+3 7 8
The bytes will be added in this order when bit 12 is OFF: 1+2+3+4....
The bytes will be added in this order when bit 12 is ON: 2+3+4....
Data Type Data within the range is treated as unsigned binary when bit 14 of C is ON and bit
15 is OFF, and it is treated as signed binary when both bits 14 and 15 are ON.
Data within the range is treated as BCD when bit 14 of C is OFF, regardless of the
status of bit 15.
304
Special Math Instructions Section 5-22
Example In the following example, the BCD contents of the 8 words from DM 0000 to
DM 0007 are added when IR 00001 is ON and the result is written to DM 0010
and DM 0011.
DM 0000 0001
DM 0001 0002
DM 0002 0003
DM 0003 0004 DM 0010 0036
DM 0004 0005 DM 0011 0000
DM 0005 0006
DM 0006 0007
DM 0007 0008
305
Special Math Instructions Section 5-22
Examples
Sine Function The following example demonstrates the use of the APR(––) sine function to cal-
culate the sine of 30°. The sine function is specified when C is #0000.
Enter input data not exceed- Result data has four significant
ing #0900 in BCD. digits, fifth and higher digits are
ignored. The result for sin(90) will
be 0.9999, not 1.
Cosine Function The following example demonstrates the use of the APR(––) cosine function to
calculate the cosine of 30°. The cosine function is specified when C is #0001.
Enter input data not exceed- Result data has four significant
ing #0900 in BCD. digits, fifth and higher digits are
ignored. The result for cos(0) will
be 0.9999, not 1.
Linear Approximation APR(––) linear approximation is specified when C is a memory address. Word C
is the first word of the continuous block of memory containing the linear approxi-
mation data.
The content of word C specifies the number of line segments in the approxima-
tion, and whether the input and output are in BCD or BIN form. Bits 00 to 07 con-
tain the number of line segments less 1, m–1, as binary data. Bits 14 and 15 de-
termine, respectively, the output and input forms: 0 specifies BCD and 1 speci-
fies BIN.
C: 15 14 13 Not used. 07 06 05 04 03 02 01 00
306
Special Math Instructions Section 5-22
Enter the coordinates of the m+1 end-points, which define the m line segments,
as shown in the following table. Enter all coordinates in BIN form. Always enter
the coordinates from the lowest X value (X1) to the highest (Xm). X0 is 0000, and
Y does not have to be entered.
Ym Word Coordinate
C+1 Xm (max. X value)
Y4 C+2 Y0
C+3 X1
Y3 C+4 Y1
Y1 C+5 X2
C+6 Y2
Y2 ↓ ↓
C+(2m+1) Xm
Y0
X C+(2m+2) Ym
X0 X1 X2 X3 X4 Xm
If bit 13 of C is set to 1, the graph will be reflected from left to right, as shown in the
following diagram.
Y Y
X X
X0 Xm Xm X0
DM 0000 $C00B 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1
DM 0001 $05F0 X12
DM 0002 $0000 Y0 (Output and (m–1 = 11: 12 line
input both BIN) segments)
DM 0003 $0005 X1
DM 0004 $0F00 Y1
DM 0005 $001A X2
DM 0006 $0402 Y2
↓ ↓ ↓
DM 0025 $05F0 X12
DM 0026 $1F20 Y12
307
Logic Instructions Section 5-23
In this case, the input data word, IR 010, contains #0014, and f(0014) = #0726 is
output to R, IR 011.
$1F20
$0F00
(x,y)
$0726
$0402
(0,0) X
$0005 $0014 $001A $05F0
Description When the execution condition is OFF, COM(29) is not executed. When the
execution condition is ON, COM(29) clears all ON bits and sets all OFF bits in
Wd.
Precautions The complement of Wd will be calculated every cycle if the undifferentiated form
of COM(29) is used. Use the differentiated form (@COM(29)) or combine
COM(29) with DIFU(13) or DIFD(14) to calculate the complement just once.
Example 15 00
Original 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
15 00
Complement 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
308
Logic Instructions Section 5-23
Description When the execution condition is OFF, ANDW(34) is not executed. When the
execution condition is ON, ANDW(34) logically AND’s the contents of I1 and I2
bit-by-bit and places the result in R.
Example 15 00
I1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
15 00
I2 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
15 00
R 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
309
Logic Instructions Section 5-23
Description When the execution condition is OFF, ORW(35) is not executed. When the
execution condition is ON, ORW(35) logically OR’s the contents of I1 and I2 bit-
by-bit and places the result in R.
Example 15 00
I1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
15 00
I2 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
15 00
R 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1
Example 15 00
I1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
15 00
I2 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
15 00
R 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0
310
Increment/Decrement Instructions Section 5-24
I1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
15 00
I2 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
15 00
R 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
311
Increment/Decrement Instructions Section 5-24
312
Subroutine Instructions Section 5-25
N: Subroutine number
SBS(91) N
000 to 255
Limitations The CQM1-CPU11/21-E supports only subroutine numbers 000 through 127.
The CPM1/CPM1A/SRM1 support only subroutine numbers 000 through 049.
Description A subroutine can be executed by placing SBS(91) in the main program at the
point where the subroutine is desired. The subroutine number used in SBS(91)
indicates the desired subroutine. When SBS(91) is executed (i.e., when the
execution condition for it is ON), the instructions between the SBN(92) with the
same subroutine number and the first RET(93) after it are executed before
execution returns to the instruction following the SBS(91) that made the call.
Main program
SBS(91) 00
Main program
SBN(92) 00
Subroutine
RET(93)
END(01)
SBS(91) may be used as many times as desired in the program, i.e., the same
subroutine may be called from different places in the program).
313
Subroutine Instructions Section 5-25
SBS(91) may also be placed into a subroutine to shift program execution from
one subroutine to another, i.e., subroutines may be nested. When the second
subroutine has been completed (i.e., RET(93) has been reached), program
execution returns to the original subroutine which is then completed before re-
turning to the main program. Nesting is possible to up to sixteen levels. A sub-
routine cannot call itself (e.g., SBS(91) 000 cannot be programmed within the
subroutine defined with SBN(92) 000). The following diagram illustrates two lev-
els of nesting.
The following diagram illustrates program execution flow for various execution
conditions for two SBS(91).
C
A D B C
RET(93)
END(01)
Flags ER: A subroutine does not exist for the specified subroutine number.
A subroutine has called itself.
An active subroutine has been called.
! Caution SBS(91) will not be executed and the subroutine will not be called when ER is
ON.
314
Special Instructions Section 5-26
N: Subroutine number
SBN(92) N
000 to 255
RET(93)
Limitations The CQM1-CPU11/21-E support only subroutine numbers 000 through 127.
The CPM1/CPM1A/SRM1 PCs support only subroutine numbers 000 through
049.
Each subroutine number can be used in SBN(92) once only.
Description SBN(92) is used to mark the beginning of a subroutine program; RET(93) is
used to mark the end. Each subroutine is identified with a subroutine number, N,
that is programmed as a definer for SBN(92). This same subroutine number is
used in any SBS(91) that calls the subroutine (see 5-25-1 SUBROUTINE EN-
TER – SBS(91)). No subroutine number is required with RET(93).
All subroutines must be programmed at the end of the main program. When one
or more subroutines have been programmed, the main program will be
executed up to the first SBN(92) before returning to address 00000 for the next
cycle. Subroutines will not be executed unless called by SBS(91).
END(01) must be placed at the end of the last subroutine program, i.e., after the
last RET(93). It is not required at any other point in the program.
Precautions If SBN(92) is mistakenly placed in the main program, it will inhibit program
execution past that point, i.e., program execution will return to the beginning
when SBN(92) is encountered.
If either DIFU(13) or DIFU(14) is placed within a subroutine, the operand bit will
not be turned OFF until the next time the subroutine is executed, i.e., the oper-
and bit may stay ON longer than one cycle.
Data tracing can be used to facilitate debugging programs. To set up and use
data tracing it is necessary to have a host computer running SSS; no data tracing
is possible from a Programming Console. Data tracing is described in detail in
the SSS Operation Manual: C-series PCs. This section shows the ladder symbol
for TRSM(45) and gives an example program.
Ladder Symbol
TRSM(45)
Description TRSM(45) is used in the program to mark locations where specified data is to be
stored in Trace Memory. Up to 12 bits and up to 3 words may be designated for
tracing. (Refer to the SSS Operation Manual: C-series PCs for details.)
315
Special Instructions Section 5-26
Note *Do not change the status of AR 2515 from the program.
Precautions If TRSM(45) occurs TRSM(45) will not be executed within a JMP(08) – JME(09)
block when the jump condition is OFF.
Example The following example shows the basic program and operation for data tracing.
Force set the Sampling Start Bit (AR 2515) to begin sampling. The Sampling
Start Bit must not be turned ON from the program. The data is read and stored
into trace memory.
When IR 00000 is ON, the Trace Start Bit (AR 2514) is also turned ON, and the
CPU Unit looks at the delay and marks the trace memory accordingly. This can
mean that some of the samples already made will be recorded as the trace
memory (negative delay), or that more samples will be made before they are re-
corded (positive delay).
316
Special Instructions Section 5-26
The sampled data is written to trace memory, jumping to the beginning of the
memory area once the end has been reached and continuing up to the start
marker. This might mean that previously recorded data (i.e., data from this sam-
ple that falls before the start marker) is overwritten (this is especially true if the
delay is positive). The negative delay cannot be such that the required data was
executed before sampling was started.
00000
AR
2514 Starts data tracing.
TRSM(45)
Designates point for
tracing.
317
Special Instructions Section 5-26
Clearing Messages To clear a message, execute FAL(06) 00 or clear it via a Programming Console
or the SSS.
If the message data changes while the message is being displayed, the display
will also change.
Example The following example shows the display that would be produced for the instruc-
tion and data given when 00000 was ON. If 00001 goes ON, a message will be
cleared.
00000
Address Instruction Operands
MSG(46)
00000 LD 00000
DM 0010
00001 MSG(46)
00001
FAL(06) 00 DM 0010
00002 LD 00001
00003 FAL(06) 00
DM contents ASCII
equivalent
DM 0010 4 1 4 2 A B
DM 0011 4 3 4 4 C D MSG
DM 0012 4 5 4 6 E F ABCDEFGHIJKLMNOP
DM 0013 4 7 4 8 G H
DM 0014 4 9 4 A I J
DM 0015 4 B 4 C K L
DM 0016 4 D 4 E M N
DM 0017 4 F 5 0 O P
318
Special Instructions Section 5-26
will be refreshed. This will be in addition to the normal I/O refresh performed dur-
ing the CPU Unit’s cycle.
Note This instruction will have no effect on words that are not being used for I/O.
000 to 127
MCRO(99) @MCRO(99)
I1: First input word
N N
IR, SR, AR, DM, HR, TC, LR
I1 I1
O1: First output word
O1 O1
IR, SR, AR, DM, HR, LR
Limitations DM 6144 to DM 6655 cannot be used for O1. The CPM1/CPM1A/SRM1 PCs
support only subroutine numbers 000 through 049.
Description The MACRO instruction allows a single subroutine to replace several subrou-
tines that have identical structure but different operands. There are 4 input
words, IR 096 to IR 099 (IR 232 to IR 235 in the CPM1/CPM1A/SRM1), and 4
output words, IR 196 to IR 199 (IR 236 to IR 239 in CPM1/CPM1A/SRM1 PCs),
allocated to MCRO(99). These 8 words are used in the subroutine and take their
contents from I1 to I1+3 and O1 to O1+3 when the subroutine is executed.
When the execution condition is OFF, MCRO(99) is not executed. When the
execution condition is ON, MCRO(99) copies the contents of I1 to I1+3 to IR 096
to IR 099, copies the contents of O1 to O1+3 to IR 196 to IR 199, and then calls
and executes the subroutine specified in N. When the subroutine is completed,
the contents of IR 196 through IR 199 is then transferred back to O1 to O1+3
before MCRO(99) is completed.
Note Refer to page 128 for more details on MCRO(99).
Example In this example, the contents of DM 0010 through DM 0013 are copied to IR 096
through IR 099, the contents of DM 0020 through DM 0023 are copied to IR 196
through IR 199, and subroutine 10 is called and executed. When the subroutine
319
Special Instructions Section 5-26
Main program
MCRO(99) 10
DM 0010
DM 0020
Main program
SBN(92) 10
Subroutine
RET(93)
END(01)
Flags ER: A subroutine does not exist for the specified subroutine number.
An operand has exceeded a data area boundary.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
A subroutine has called itself.
An active subroutine has been called.
Note BCNT(67) is an expansion instruction for the SRM1. The function code 67 is the
factory setting and can be changed for the SRM1 if desired.
Limitations N cannot be 0.
DM 6144 to DM 6655 cannot be used for R.
Description When the execution condition is OFF, BCNT(67) is not executed. When the
execution condition is ON, BCNT(67) counts the total number of bits that are ON
in all words between SB and SB+(N–1) and places the result in R.
Flags ER: N is not BCD, or N is 0; SB and SB+(N–1) are not in the same area.
The resulting count value exceeds 9999.
320
Special Instructions Section 5-26
C: 15 14 13 12 11 00
Number of Items in Range The number of items within the range (N) is contained in the 3 rightmost digits of
C, which must be BCD between 001 and 999.
Calculation Units The frame checksum of words will be calculated if bit 13 is OFF and the frame
checksum of bytes will be calculated if bit 13 is ON.
If bytes are specified, the range can begin with the leftmost or rightmost byte of
R1. The leftmost byte of R1 will not be included if bit 12 is ON.
MSB LSB
R1 1 2
R1+1 3 4
R1+2 5 6
R1+3 7 8
321
Special Instructions Section 5-26
When bit 12 is OFF the bytes will be ORed in this order: 1, 2, 3, 4, ....
When bit 12 is ON the bytes will be ORed in this order: 2, 3, 4, 5, ....
Conversion to ASCII The byte frame checksum calculation yields a 2-digit hexadecimal value which is
converted to its 4-digit ASCII equivalent. The word frame checksum calculation
yields a 4-digit hexadecimal value which is converted to its 8-digit ASCII equiva-
lent, as shown below.
Byte frame checksum value Word frame checksum value
4A F10B
D 3 4 4 1 D 4 6 3 1 D+1 3 0 4 2
Example When IR 00000 is ON in the following example, the frame checksum (0008) is
calculated for the 8 words from DM 0000 to DM 0007 and the ASCII equivalent
(30 30 30 38) is written to DM 0010 and DM 0011.
322
Special Instructions Section 5-26
Description FPD(––) can be used in the program as many times as desired, but each must
use a different D. It is used to monitor the time between the execution of FPD(––)
and the execution of a diagnostic output. If the time exceeds T, an FAL(06) non-
fatal error will be generated with the FAL number specified in C.
The program sections marked by dashed lines in the following diagram can be
written according to the needs of the particular program application. The proces-
sing programming section triggered by CY is optional and can used any instruc-
tions but LD and LD NOT. The logic diagnostic instructions and execution condi-
tion can consist of any combination of NC or NO conditions desired.
Execution Branch
FPD(––)(50)
condition
C
D
SR 25504
(CY Flag)
Processing after
error detection.
Logic Diagnostic
diagnostic output
instructions
When the execution condition is OFF, FPD(––) is not executed. When the
execution condition is ON, FPD(––) monitors the time until the logic diagnostics
condition goes ON, turning ON the diagnostic output. If this time exceeds T, the
following will occur:
1, 2, 3... 1. An FAL(06) error is generated with the FAL number specified in the first two
digits of C. If 00 is specified, however, an error will not be generated.
2. The logic diagnostic instructions are searched for the first OFF input condi-
tion and this condition’s bit address is output to the destination words begin-
ning at D.
3. The CY Flag (SR 25504) is turned ON. An error processing program section
can be executed using the CY Flag if desired.
4. If bit 15 of C is ON, a preset message with up to 8 ASCII characters will be
displayed on the Peripheral Device along with the bit address mentioned in
step 2.
Control Data The function of the control data bits in C are shown in the following diagram.
C: 15 14 08 07 00
Diagnostics output
0 (OFF): Bit address output (binary)
1 (ON): Bit address and message output (ASCII)
Logic Diagnostic Instructions If the time until the logic diagnostics condition goes ON exceeds T, the logic diag-
nostic instructions are searched for the OFF input condition. If more than one
input condition is OFF, the input condition on the highest instruction line and
nearest the left bus bar is selected.
00000 00002
Diagnostic
output
00001 00003
323
Special Instructions Section 5-26
When IR 00000 to IR 00003 are ON, the normally closed condition IR 00002
would be found as the cause of the diagnostic output not turning ON.
Diagnostics Output There are two ways to output the bit address of the OFF condition detected in the
logic diagnostics condition.
1, 2, 3... 1. Bit address output (used when bit 15 of C is OFF).
Bit 15 of D indicates whether or not bit address information is stored in D+1.
If there is, bit 14 of D indicates whether the input condition is normally open
or closed.
D: 15 14 13 00
Not used.
Input condition
0 (OFF): Normally open
1 (ON): Normally closed
D+1 contains the bit address code of the input condition, as shown below.
The word addresses, bit numbers, and TC numbers are in binary.
Data D+1 bit status
Area 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
IR, SR 1 0 0 0 Word address Bit number
HR 1 0 0 1 1 Word address Bit number
LR 1 0 0 1 0 0 Word address Bit number
TC* 1 0 0 1 0 1 * Timer or counter number
Note a) *For the TC area, bit 09 of D+1 indicates whether the number is a
timer or counter. A 0 indicates a timer, and a 1 indicates a counter.
b) The status of the leftmost bit of the bit number (bit 03) is reversed.
Example: If D + 1 contains 1000 0110 0100 1000, IR 10000 would be indi-
cated as follows:
1000 0110 0100 1000
Note If 8 characters are not needed in the message, input “0D” after the
last character.
324
Special Instructions Section 5-26
Determining Monitoring Time The procedure below can be used to automatically set the monitoring time, T,
under actual operating conditions when specifying a word operand for T. This
operation cannot be used if a constant is set for T.
Example In the following example, the FPD(––) is set to display the bit address and mes-
sage (“ABC”) when a monitoring time of 123.4 s is exceeded.
SR 25315
MOV(21)
Address Instruction Operands
#4142
00000 LD 25315
HR 15
00001 MOV(21)
SR 25315 # 4142
MOV(21)
HR 15
#430D
00002 LD 25315
HR 16 00003 MOV(21)
LR 0000
# 430D
FPD(––) HR 16
#8010 00004 LD LR 0000
#1234 00005 FPD(––)
HR 10 # 0010
SR 25504 # 1234
(CY Flag)
HR 10
INC(38)
00006 AND 25504
DM 0100
00007 INC(38)
10000 10002 DM 0100
LR 0015 00008 LD 10000
00009 OR 10001
10001 10003 00010 LD NOT 10002
00011 OR NOT 10003
00012 AND LD
00013 OUT LR 0015
FPD(––) is executed and begins monitoring when LR 0000 goes ON. If LR 0015
does not turn ON within 123.4 s and IR 10000 through IR 10003 are all ON,
IR 10002 will be selected as the cause of the error, an FAL(06) error will be gen-
erated with an FAL number of 10, and the bit address and preset message
(“10002–1ABC”) will be displayed on the Peripheral Device.
325
Special Instructions Section 5-26
CY: ON when the time between the execution of FPD(––) and the execution
of a diagnostic output exceeds T.
Description When the execution condition is OFF, INT(89) is not executed. When the execu-
tion condition is ON, INT(89) is used to control interrupts and performs one of the
six functions shown in the following table depending on the value of CC.
Note Refer to 1-5 CQM1 Interrupt Functions and 1-6 CPM1/CPM1A Interrupt Func-
tions for more details.
INT(89) function CC
Mask/unmask input interrupts 000
Clear input interrupts 001
Read current mask status 002
Renew counter SV 003
Mask all interrupts 100
Unmask all interrupts 200
These six functions are described in more detail below. Refer to page 22 for
more information on these functions.
Mask/Unmask I/O Interrupts This function is used to mask and unmask I/O interrupt inputs 00000 to 00003
(CC=000) (00003 to 00006 in CPM1/CPM1A PCs). Masked inputs are recorded, but ig-
nored. When an input is masked, the interrupt program for it will be run as soon
as the bit is unmasked (unless it is cleared beforehand by executing INT(89) with
CC=001).
326
Special Instructions Section 5-26
CQM1 PCs
Word D bits: 3 2 1 0
Clear I/O Interrupts This function is used to clear I/O interrupt inputs 00000 to 00003 (00003 to
(CC=001) 00006 in CPM1/CPM1A PCs). Since interrupt inputs are recorded, masked in-
terrupts will be serviced after the mask is removed unless they are cleared first.
Set the corresponding bit in D to 1 to clear an I/O interrupt input. Bits 00 to 03
correspond to 00000 to 00003 (00003 to 00006 in CPM1/CPM1A PCs). Bits 04
to 15 should be set to 0.
CQM1 PCs
Word D bits: 3 2 1 0
Read Current Mask Status This function is used to write the current mask status for I/O interrupt inputs
(CC=002) 00000 to 00003 (00003 to 00006 in CPM1/CPM1A PCs) to word D. The corre-
sponding bit will be ON if the input is masked. (Bits 00 to 03 correspond to 00000
to 00003 in CQM1 PCs, 00003 to 00006 in CPM1/CPM1A PCs.)
CQM1 PCs
Word D bits: 3 2 1 0
Renew Counter SV This function is used to renew the counter SV for I/O interrupt inputs 00000 to
(CC=003) 00003 (00003 to 00006 in CPM1/CPM1A PCs) to word D. Set the corresponding
327
Special Instructions Section 5-26
Mask/Unmasking All This function is used to mask or unmask all interrupt processing. Masked inputs
Interrupts (CC=100/200) are recorded, but ignored. Refer to page 44 for details.
The control data, D, is not used for this function. Set D to #0000.
Limitations This instruction is available in the CPM1A with transistor outputs and CQM1
only.
N and N+1 must be in the same data area.
DM 6143 to DM 6655 cannot be used for N.
Description PULS(65) is used to set parameters for pulse outputs that are started later in the
program using SPED(64) or ACC(––). The parameters that can be set are the
number of pulses that will be output in independent mode, the direction of pulse
outputs from ports 1 and 2, and the deceleration point for pulse outputs con-
trolled by ACC(––) mode 0.
Since PULS(65) has a relatively long execution time, the cycle time can be re-
duced by executing the differentiated version (@PULS(65)) of this instruction
only when it is needed.
328
Special Instructions Section 5-26
Port Specifier (P) The port specifier indicates the pulse output location. The parameters set by the
in C and N will apply to the next SPED(64) or ACC(––) instruction in which the
same port output location is specified.
P Pulse output location
000 Output bit
001 Port 1
002 Port 2
Control Data (C) The control data determines the direction of the pulse output to ports 1 and 2 and
indicates whether the number of pulses and/or the deceleration point are speci-
fied in N to N+3. This operand should be set to 000 when P=000.
C Direction Number of pulses Deceleration point
000 CW Set in N and N+1 Not set.
001 CCW Set in N and N+1 Not set.
002 CW Set in N and N+1 Set in N+2 and N+3
003 CCW Set in N and N+1 Set in N+2 and N+3
004 CW Not set. Not set.
005 CCW Not set. Not set.
When C=002 or 003, N+3, N+2 contains the 8-digit number of pulses setting for
the deceleration point used in ACC(––) mode 0. N+3, N+2 can be from
00000001 to 16777215. The pulse output started by ACC(––) will begin decel-
eration when this number of pulses have been output.
Leftmost 4 digits Rightmost 4 digits Possible range
Deceleration point: N+3 N+2 0000 0001 to 1677 7215
When C=004 or 005, neither the number of pulses nor the deceleration point are
set. Set N=000 when C=004 or 005.
Frequency Changes The number of pulses set to be output will be used even if SPED(64) is used to
change the pulse frequency during operation.
For example, if the number of pulses setting is 2,100 and the frequency is
changed from 1 KHz to 100 Hz, pulse output will stop in:
12 s if the pulse frequency is changed after 1 s at 1 KHz.
3 s if the pulse frequency is changed after 2 s at 1 KHz.
329
Special Instructions Section 5-26
Limitations This instruction is available in the CPM1A with transistor outputs and CQM1
only.
F must be BCD, #0000 to #5000 when a port is specified, #0000 or #0002 to
#0100 when an output bit is specified.
DM 6144 to DM 6655 cannot be used for F.
Description SPED(64) is used to set, change, or stop pulse output from the specified port or
output bit. When the execution condition is OFF, SPED(64) is not executed.
When the execution condition is ON, SPED(64) sets the pulse frequency F for
the port or output bit specified by P. M determines the output mode.
Since SPED(64) has a relatively long execution time, the cycle time can be re-
duced by executing the differentiated version (@SPED(64)) of this instruction
only when it is needed.
Note Refer to 1-3 Pulse Output Functions for more details.
Port Specifier (P) The port specifier specifies the port or output bit where the pulses will be output.
P Pulse output location
001 Port 1
002 Port 2
000 to Output bits IR 10000 to IR 10015.
150 The first two digits of P specify which bit of IR 100 is the output bit and the
third digit of P is always set to 0. For example, P=000 specifies IR 10000,
P=010 specifies IR 10001, ... and P=150 specifies bit IR 10015.
Output Mode (M) The value of M determines the output mode. A value of 000 indicates indepen-
dent mode and a value of 001 indicates continuous mode.
In independent mode, the pulse output will continue until one of the following oc-
curs:
1, 2, 3... 1. The number of pulses specified by the PULS(65) instruction is reached.
(Execute PULS(65) before SPED(64) when specifying independent mode.)
2. The INI(61) instruction is executed with C=003.
3. SPED(64) is executed again with the output frequency, F, set to 000.
When outputting pulses in independent mode, specify the number of pulses be-
forehand by executing PULS(65). When outputting from port 1 or 2, specify the
direction (CW or CCW) as well.
In independent mode, the number of pulses that have been output to ports 1 and
2 are contained in IR 236 and 237 (port 1) and IR 238 and IR 239 (port 2).
Leftmost 4 digits Rightmost 4 digits
Port 1 pulse output PV: IR 237 IR 236
330
Special Instructions Section 5-26
In continuous mode, pulses will be output until the INI(61) instruction is executed
with C=003 or SPED(64) is executed again with F=0000. If the direction (CW or
CCW) is not specified when outputting from port 1 or 2, the pulses will be CW.
Pulse Frequency (F) The value of F sets the pulse frequency in units of 10 Hz, as shown below. Set-
ting F to 0000 will stop the pulse output at the specified location.
Output location Possible values of F
Port 1 or 2 0000 (stops pulse output) or 0001 to 5000 (10 Hz to 50 kHz)
Output bits 0000 (stops pulse output) or 0002 to 0100 (20 Hz to 1 kHz)
Equation:
Actual frequency (KHz) = 500 (KHz)/INT (500 (kHz)/Set frequency (kHz))
INT: Function for obtaining an integer value
INT (500/Set frequency): Dividing unit
The difference between the set frequency and actual frequency becomes larger
as the frequency becomes higher.
Example:
Set frequency (kHz) Actual frequency (kHz)
45.46 to 50.00 50.00
41.67 to 45.45 45.45
38.47 to 41.66 41.67
: :
31.26 to 33.33 33.33
29.42 to 31.25 31.25
27.78 to 29.41 29.41
: :
20.01 to 20.83 20.83
19.24 to 20.00 20.00
18.52 to 19.23 19.23
: :
10.01 to 10.20 10.20
9.81 to 10.00 10.00
9.62 to 9.80 9.80
: :
5.01 to 5.05 5.05
331
Special Instructions Section 5-26
Precautions With the CQM1-CPU11/21-E, the output refreshing method in DM 6639 (PC Set-
up) must be set to direct output before initiating pulse output.
The pulse output cannot be used when interval timer 0 is operating.
When a pulse output with a frequency of 500 Hz or higher is output from an out-
put bit, set interrupt processing for the TIMH(15) TC numbers 000 to 003 by set-
ting #0104 in DM 6629 of the PC Setup.
Only one output bit at a time can have a pulse output.
Target frequency
100 Hz
T1 T2 T1
332
Special Instructions Section 5-26
Target frequency
T 1 ^ 0.004
Accerationńdeceleration rate
Note 1. Although T1 and T2 will vary slightly depending on the operating conditions,
the number of pulses output will be accurate.
2. PLS2(––) will not operate if pulses are already being output from the speci-
fied port. Check the pulse output flags (AR 0515 for port 1 and AR 0615 for
port 2) before executing PLS2(––).
3. Refer to 1-3 Pulse Output Functions for more details.
Operand Settings P specifies the port where the pulses will be output. Pulses are output from port 1
when P=001, and pulses are output from port 2 when P=002.
D specifies whether the output signal is clockwise (CW) or counter-clockwise
(CCW). The output is CW when D=000 and CCW when D=001.
The content of C determines the acceleration/deceleration rate. During accel-
eration or deceleration, the output frequency is increased or decreased by the
amount set in C every 4.08 ms. C must be BCD from 0001 to 0200 (10 Hz to
2 kHz).
The content of C+1 specifies the target frequency. C+1 must be BCD from 0010
to 5000 (100 Hz to 50 kHz).
The 8-digit content of C+3,C+2 determines the number of pulses that will be out-
put. C+3, C+2 must be BCD between 0000 0001 and 1677 7215.
! Caution With PLS2(––), conditions such as acceleration/deceleration speed and the tar-
get speed can cause low-speed pulse output (100 Hz) to continue for an ex-
tended period of time when stopping. Even when this happens, the correct num-
ber of pulses will be output.
100 Hz
333
Special Instructions Section 5-26
Mode 0 (M=000) Mode 0 is used to output a specified number of CW or CCW pulses from port 1 or
2. The acceleration rate, frequency after acceleration, deceleration point, decel-
eration rate, and frequency after deceleration can all be controlled.
Deceleration rate
Frequency after
acceleration
Frequency after
deceleration
Acceleration rate
PULS(65) Operand Settings PULS(65) must be executed before ACC(––) in order to specify direction, the
total number of pulses to be output, and the deceleration point. The function of
PULS(65) operands are described below. Refer to 5-26-9 SET PULSES –
PULS(65) for more details.
1, 2, 3... 1. The first operand of PULS(65) specifies the output port. Pulses are output
from port 1 when P=001, and from port 2 when P=002.
2. The second operand specifies the direction. The output is clockwise (CW)
when C=002 and counter-clockwise (CCW) when C=003.
3. The third operand specifies the first of 4 control words.
a) The 8-digit content of N+1,N (0000 0001 to 1677 7215) determines the
total number of pulses that will be output.
334
Special Instructions Section 5-26
ACC(––) Control Words The 4 control words indicate the acceleration rate, frequency after acceleration,
deceleration rate, and frequency after deceleration.
1, 2, 3... 1. The content of C determines the acceleration rate. During acceleration, the
output frequency is increased by the amount set in C every 4.08 ms. C must
be BCD from 0001 to 0200 (10 Hz to 2 kHz).
2. The content of C+1 specifies the frequency after acceleration. C+1 must be
BCD from 0000 to 5000 (0 Hz to 50 kHz).
3. The content of C+2 determines the deceleration rate. During deceleration,
the output frequency is decreased by the amount set in C+2 every 4.08 ms.
C must be BCD from 0001 to 0200 (10 Hz to 2 kHz).
4. The content of C+3 specifies the frequency after deceleration. C+3 must be
BCD from 0000 to 5000 (0 Hz to 50 kHz).
Mode 1 (M=001) Mode 1 is used to increase the frequency being output to a target frequency at
the specified rate. Pulse output continues until stopped.
Target frequency
Execution of ACC(––)
The 2 control words indicate the acceleration rate and target frequency.
1, 2, 3... 1. The content of C determines the acceleration rate. During acceleration, the
output frequency is increased by the amount set in C every 4.08 ms. C must
be BCD from 0001 to 0200 (10 Hz to 2 kHz).
2. The content of C+1 specifies the target frequency. C+1 must be BCD from
0000 to 5000 (0 Hz to 50 kHz).
Mode 2 (M=002) Mode 2 is used to decrease the frequency being output to a target frequency at
the specified rate. Output stops when the total number of pulses specified in
PULS(65) have been output.
Frequency before
deceleration
Deceleration rate
Target frequency
The 2 control words indicate the deceleration rate and target frequency.
1, 2, 3... 1. The content of C determines the deceleration rate. During deceleration, the
output frequency is decreased by the amount set in C every 4.08 ms. C must
be BCD from 0001 to 0200 (10 Hz to 2 kHz).
2. The content of C+1 specifies the target frequency. C+1 must be BCD from
0000 to 5000 (0 Hz to 50 kHz).
335
Special Instructions Section 5-26
Mode 3 (M=003) Mode 3 is used to decrease the frequency being output to a target frequency at
the specified rate. Pulse output continues until stopped.
Frequency before
deceleration
Deceleration rate
Target frequency
Execution of ACC(––)
The 2 control words indicate the acceleration rate and target frequency.
1, 2, 3... 1. The content of C determines the acceleration rate. During acceleration, the
output frequency is increased by the amount set in C every 4.08 ms. C must
be BCD from 0001 to 0200 (10 Hz to 2 kHz).
2. The content of C+1 specifies the target frequency. C+1 must be BCD from
0000 to 5000 (0 Hz to 50 kHz).
336
Special Instructions Section 5-26
In order for PWM(––) to be executed, the specified port must be set for variable
duty ratio pulse outputs in the PC Setup. Set the leftmost digit of DM 6643 to 1 to
enable variable duty ratio pulse output from port 1, and set the leftmost digit of
DM 6644 to 1 to enable variable duty ratio pulse output from port 2. It is not pos-
sible to output normal pulses from a port that is set for variable duty ratio output.
Note Refer to 1-3 Pulse Output Functions for more details.
Operand Settings P specifies the port where the pulses will be output. Pulses are output from port 1
when P=001, and pulses are output from port 2 when P=002.
F specifies the frequency of the pulse output, as shown in the following table.
F Frequency
000 5.9 kHz
001 1.5 kHz
002 91.6 Hz
D specifies the duty ratio of the pulse output, i.e., the percentage of time that the
output is ON. D must be BCD from 0001 to 0099 (1% to 99%). The duty ratio is
75% in the following diagram.
ton
t on
+ D (1% to 99%)
T
337
Special Instructions Section 5-26
1, 2, 3... 1. For an address in the DM area, the word address is written to C+1. For ex-
ample, if the lowest address containing the comparison data is DM 0114,
then #0114 is written in C+1.
2. For an address in another data area, the number of addresses from the be-
ginning of the search is written to C+1. For example, if the lowest address
containing the comparison data is IR 114 and the first word in the search
range is IR 014, then #0100 is written in C+1.
If none of addresses in the range contain the comparison data, the EQ Flag (SR
25506) is turned OFF and C+1 is left unchanged.
DM 0010 0000
DM 0011 9898
DM 0012 FFFF
DM 0013 9797
DM 0014 AAAA DM 0000 FFFF
DM 0015 9595 DM 0001 0012
DM 0016 1414
DM 0017 0000
DM 0018 0000
DM 0019 FFFF
338
Special Instructions Section 5-26
! Caution A total of 33 continuous words starting with P1 must be provided for PID(––) to
operate correctly. Also, PID(––) may not operate dependably in any of the fol-
lowing situations: In interrupt programs, in subroutines, between IL(02) and
ILC(03), between JMP(04) and JME(05), and in step programming
(STEP(08)/SNXT(09)). Do not program PID(––) in these situations.
Description PID(––) performs PID control based on the parameters specified in P1 through
P1+6. The data in IW is used to calculate the output data that is written to OW.
The following table shows the function of the parameter words.
Word Bits Parameter name Function/Setting range
P1 00 to 15 Set value (SV). This is the target value for PID control. It can be set to any binary
number with the number of bits set by the input range parameter.
P1+1 00 to 15 Proportional band width. This parameter specifies the proportional band width/input range ratio
from 0.1% to 999.9%. It must be BCD from 0001 to 9999.
P1+2 00 to 15 Integral time Sets the integral time/sampling period ratio used in integral control. It
must be BCD from 0001 to 8191, or 9999. (9999 disables integral con-
trol.)
P1+3 00 to 15 Derivative time Sets the derivative time/sampling period ratio used in derivative con-
trol. It must be BCD from 0001 to 8191, or 0000.
P1+4 00 to 15 Sampling period Sets the interval between samplings of the input data from 0.1 to
102.3 s. It must be BCD from 0001 to 1023.
P1+5 00 to 03 Operation specifier Sets reverse or normal operation. Set to 0 to specify reverse operation
or 1 to specify normal operation.
04 to 15 Input filter coefficient Determines the strength of the input filter. The lower the coefficient,
the weaker the filter.
This setting must be BCD from 100 to 199, or 000. A setting of 000
sets the default value (0.65) and a setting of 100 to 199 sets the coef-
ficient from 0.00 to 0.99.
P1+6 00 to 07 Output range Determines the number of bits of output data. This setting must be
between 00 and 08, which sets the output range between 8 and 16
bits.
08 to 15 Input range Determines the number of bits of input data. This setting must be be-
tween 00 and 08, which sets the input range between 8 and 16 bits.
P1+7 to 00 to 15 Work area Do not use.
P1+32 (Used by the system.)
When the execution condition is OFF, PID(––) is not executed and the instruc-
tion’s data is maintained. While the execution condition is OFF, the desired out-
put data can be written directly to OW for manual control.
When the execution condition first goes from OFF to ON, PID(––) reads the pa-
rameters and initializes the work area. There is a built-in function to change the
output data continuously at startup because sudden changes in the output data
might adversely affect the controlled system.
! Caution Changes made to the parameters will not be effective until the execution condi-
tion for PID(––) goes from OFF to ON.
Note Do not use PID(––) in the following situations; it may not be executed properly.
In interrupt programs
In subroutine programs
In interlocked program sections (between IL and ILC)
In jump program sections (between JMP and JME)
In step ladder program section (created with STEP)
When the execution condition is ON, PID(––) performs the PID calculation on
the input data when the sampling period has elapsed. The sampling period is the
time that must pass before input data is read for processing.
339
Communications Instructions Section 5-27
The following diagram shows the relationship between the sampling period and
PID processing. PID processing is performed only when the sampling period
(100 ms in this case) has elapsed.
1 cycle
70 ms 60 ms 70 ms 70 ms
No processing PID processing
(70 ms) (70+30=100 ms,
PID processing no carryover)
with initial values PID processing No processing
(0 ms) (130 ms, 30 ms carryover) (60 ms)
! Caution The CQM1 or SRM1 will be incapable of receiving more data once 256 bytes
have been received if received data is not read using RXD(47). Read data as
soon as possible after the Reception Completed Flag is turned ON (AR 0806 for
the RS-232C port, AR 0814 for the peripheral port.)
340
Communications Instructions Section 5-27
Control Word The value of the control word determines the port from which data will be read
and the order in which data will be written to memory.
Digit number: 3 2 1 0
The order in which data is written to memory depends on the value of digit 0 of C.
Eight bytes of data 12345678... will be written in the following manner:
Digit 0 = 0 Digit 0 = 1
Flags ER: The CPU Unit is not equipped with an RS-232C port.
Another device is not connected to the specified port.
AR 08: AR 0806 will be turned ON when data has been received normally at the
RS-232C port. Reset when RXD(47) is executed.
AR 0814 will be turned ON when data has been received normally at the
peripheral port. Reset when RXD(47) is executed.
AR 09: Contains the number of bytes received at the RS-232C port. Reset to
0000 when RXD(47) is executed.
AR 10: Contains the number of bytes received at the peripheral port. Reset to
0000 when RXD(47) is executed.
Note Communications flags and counters can be cleared either by specifying 0000 for
N or using the Port Reset Bits (SR 25208 for peripheral port and SR 25209 for
RS-232C port.)
341
Communications Instructions Section 5-27
Description When the execution condition is OFF, TXD(48) is not executed. When the
execution condition is ON, TXD(48) reads N bytes of data from words S to
S+(N÷2)–1, converts it to ASCII, and outputs the data from the specified port.
TXD(48) operates differently in host link mode and RS-232C mode, so these
modes are described separately.
Note 1. Flag AR 0805 will be ON when the CQM1 or SRM1
is capable of transmitting data through the RS-232C port and AR 0813 will
be ON when the CQM1 or SRM1 is capable of transmitting data through the
peripheral port.
2. Refer to 1-9 Communications Functions for details on using the TXD(48)
instruction, setting communications protocol in the PC Setup, etc.
Host Link Mode N must be BCD from #0000 to #0061 (i.e., up to 122 bytes of ASCII). The value of
the control word determines the port from which data will be output, as shown
below.
Digit number: 3 2 1 0
The specified number of bytes will be read from S through S+(N/2)–1, converted
to ASCII, and transmitted through the specified port. The bytes of source data
shown below will be transmitted in this order: 12345678...
MSB LSB
S 1 2
S+1 3 4
S+2 5 6
S+3 7 8
342
Communications Instructions Section 5-27
The following diagram shows the format for host link command (TXD) sent from
the CQM1. The CQM1 automatically attaches the prefixes and suffixes, such as
the node number, header, and FCS.
@ X X X X X X ......... X X X ∗ CR
RS-232C Mode N must be BCD from #0000 to #00256. The value of the control word determines
the port from which data will be output and the order in which data will be written
to memory.
Control Word The value of the control word determines the port from which data will be read
and the order in which data will be written to memory.
Digit number: 3 2 1 0
The specified number of bytes will be read from S through S+(NP2)–1 and trans-
mitted through the specified port.
MSB LSB
S 1 2
S+1 3 4
S+2 5 6
S+3 7 8
When digit 0 of C is 0, the bytes of source data shown above will be transmitted in
this order: 12345678...
When digit 0 of C is 1, the bytes of source data shown above will be transmitted in
this order: 21436587...
Note When start and end codes are specified the total data length should be 256 bytes
max., including the start and end codes.
Flags ER: The CPU Unit is not equipped with an RS-232C port.
Another device is not connected to the peripheral port.
343
Communications Instructions Section 5-27
Description When the execution condition is OFF, STUP(––) is not executed. When the
execution condition is ON, STUP(––) changes the PC Setup settings for the port
specified by N.
N determines which part of the RS-232C Setup is changed.
N Specified Port
IR 000 Built-in RS-232C port (PC Setup: DM 6645 to DM 6649)
IR 001 Communications Board port A (PC Setup: DM 6555 to DM 6559)
IR 002 Communications Board port B (PC Setup: DM 6550 to DM 6554)
If S is a word address, the contents of S through S+4 are copied to the 5 words in
the PC Setup that contain the settings for the port specified by N.
If S is input as the constant #0000, the settings for the specified port are returned
to their default values.
S Function
Word The contents of S through S+4 are copied to the part of the PC Setup
address that contains the settings for the port specified by N.
Constant The settings for the port specified by N are returned to their default val-
(#0000) ues.
Application Example This example shows a program that transfers the contents of DM 0100 through
DM 0104 to the PC Setup area for Communications Board port A (DM 6555
through DM 6569).
00000
Address Instruction Operands
@STUP(––)
00000 LD 00000
001
00001 @STUP(––)
DM 0100
001
DM 0100
344
Advanced I/O Instructions Section 5-28
The settings are transferred as shown below. The Changing RS-232C Setup
Flag (SR 27504) will be turned OFF when the transfer has been completed.
The following table shows the function of the transferred setup data.
Word Content Function
DM 0100 1001 Enables the communications settings in DM 0101 and
sets the communications mode to RS-232C.
DM 0101 0803 Sets the following communications settings:
9,600 bps, 1 start bit, 8-bit data, 1 stop bit, no parity
DM 0102 0000 No transmission delay (0 ms)
DM 0103 2000 Enables the end code CR, LF.
DM 0104 0000 ---
000 to 007
345
Advanced I/O Instructions Section 5-28
Source data Display’s data input logic Display’s latch input logic C
4 digits (S) Same as Output Unit Same as Output Unit 0000
Different from Output Unit 0001
Different from Output Unit Same as Output Unit 0002
Different from Output Unit 0003
8 digits Same as Output Unit Same as Output Unit 0004
(S, S+1) Different from Output Unit 0005
Different from Output Unit Same as Output Unit 0006
Different from Output Unit 0007
If there are 8 digits of source data, they are placed in S and S+1, with the most
significant digits placed in S+1. If there are 4 digits of source data, they are
placed in S.
7SEG(88) displays the 4 or 8-digit data in 12 cycles, and then starts over and
continues displaying the data.
Refer to page 125 for more information on 7SEG(88) and its applications.
Flags ER: S and S+1 are not in the same data area. (When set to display 8-digit
data.)
Indirectly addressed DM word is non-existent. (Content of *DM word is
not BCD, or the DM area boundary has been exceeded.)
There is an error in operand settings.
SR 25409: ON while 7SEG(88) is being executed.
Flags ER: IW and/or OW are not allocated to the correct I/O Units.
Indirectly addressed DM word is non-existent. (Content of *DM word is
not BCD, or the DM area boundary has been exceeded.)
346
Advanced I/O Instructions Section 5-28
R and R+1 are not in the same data area. (When the CQM1 is set to re-
ceive 8-digit data.)
SR 25410: ON while DSW(87) is being executed.
347
Advanced I/O Instructions Section 5-28
348
SECTION 6
Host Link Commands
This section explains the methods and procedures for using host link commands, which can be used for host link communica-
tions via the CQM1/CPM1/CPM1A/SRM1 ports.
349
Communications Procedure Section 6-1
Command Chart The commands listed in the chart below can be used for host link communica-
tions with the CQM1/CPM1/CPM1A/SRM1. These commands are all sent from
the host computer to the PC.
350
Communications Procedure Section 6-1
Commands from Host In host link communications, the host computer ordinarily has the transmission
right first and initiates the communications. The PC then automatically sends a
response.
FCS FCS
Terminator Terminator
FCS FCS
Terminator Terminator
Frame (response) Frame (response)
Commands from PC With CQM1 PCs, it is also possible in host link communications for the PC to
(CQM1 Only) send commands to the host computer. In this case it is the PC that has the trans-
mission right and initiates the communications.
Host
computer
No response
Unit no.
Header code
PC Text
FCS
Terminator
When commands are issued to the host computer, the data is transmitted in one
direction from the PC to the host computer. If a response to a command is re-
quired use a host link communications command to write the response from the
host computer to the PC.
351
Command and Response Formats Section 6-2
@ x 101 x 100 ↵
@
An “@” symbol must be placed at the beginning.
Node No.
Identifies the PC communicating with the host computer.
Specify the node number set for the PC in the PC Setup (DM 6648, DM 6653).
Header Code
Set the 2-character command code.
Text
Set the command parameters.
FCS
Set a 2-character Frame Check Sequence code. See page 354.
Terminator
Set two characters, “” and the carriage return (CHR$(13)) to indicate the end
of the command.
Response Format The response from the PC is returned in the format shown below. Prepare a pro-
gram so that the response data can be interpreted and processed.
352
Command and Response Formats Section 6-2
Text
FCS
Terminator
Frame (response)
Frame (command)
Unit no.
Header code
Host
computer Text
FCS
Terminator Delimiter Delimiter
Unit no.
Header code Text Text
End code
FCS FCS
PC Delimiter Terminator
Text
Frame2 (response) Frame3 (response)
FCS
Delimiter
Frame1 (response)
353
Command and Response Formats Section 6-2
When dividing commands such as WR, WL, WC, or WD that execute write op-
erations, be careful not to divide into separate frames data that is to be written
into a single word. As shown in the illustration below, be sure to divide frames so
that they coincide with the divisions between words.
Frame 1
@ 0 0 W D Data ↵
Data ↵
FCS (Frame Check Sequence) When a frame is transmitted, an FCS is placed just before the delimiter or termi-
nator in order to check whether any data error has been generated. The FCS is
8-bit data converted into two ASCII characters. The 8-bit data is the result of an
EXCLUSIVE OR performed on the data from the beginning of the frame until the
end of the text in that frame (i.e., just before the FCS). Calculating the FCS each
time a frame is received and checking the result against the FCS that is included
in the frame makes it possible to check for data errors in the frame.
@ 1 0 R R 0 0 0 1 4 2 ↵
ASCII code
@ 40 0100 0000
XOR
1 31 0011 0001
XOR
0 30 0011 0000
XOR
R 52 0101 0010
1 31 0011 0001
Calculation 0100 0010
result ↓ ↓ Converted to hexadecimal.
4 2 Handled as ASCII characters.
354
Command and Response Formats Section 6-2
Example Program for FCS This example shows a BASIC subroutine program for executing an FCS check
on a frame received by the host computer.
400 *FCSCHECK
410 L=LEN(RESPONSE$) ’ . .......... Data transmitted and received
420 Q=0:FCSCK$=” ”
430 A$=RIGHT$(RESPONSE$,1)
440 PRINT RESPONSE$,A$,L
450 IF A$=”*” THEN LENGS=LEN(RESPONSE$)-3
ELSE LENGS=LEN(RESPONSE$)-2
460 FCSP$=MID$(RESPONSE$,LENGS+1,2) ’ . ... FCS data received
470 FOR I=1 TO LENGS ’ . .......... Number of characters in FCS
480 Q=ASC(MID$(RESPONSE$,I,1)) XOR Q
490 NEXT I
500 FCSD$=HEX$(Q)
510 IF LEN(FCSD$)=1 THEN FCSD$=”0”+FCSD$ ’ . .... FCS result
520 IF FCSD$<>FCSP$ THEN FCSCK$=”ERR”
530 PRINT”FCSD$=”;FCSD$,”FCSP$=”;FCSP$,”FCSCK$=”;FCSCK$
540 RETURN
Note 1. Normal reception data includes the FCS, delimiter or terminator, and so on.
When an error occurs in transmission, however the FCS or some other data
may not be included. Be sure to program the system to cover this possibility.
2. In this program example, the CR code (CHR$(13)) is not entered for RE-
SPONSE$. When including the CR code, make the changes in lines 430
and 450.
355
Host Link Commands Section 6-3
@ x 101 x 100 R R x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100 ↵
Note Beginning word: 0000 to 0255 in CQM1 PCs, 0000 to 0019 and 0200 to 0255 in
CPM1/CPM1A/SRM1 PCs.
Response Format An end code of 00 indicates normal completion.
Node no. Header End code Read data (1 word) FCS Terminator
code
Read data (for number of words read)
@ x 101 x 100 R L x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100 ↵
Node no. Header End code Read data (1 word) FCS Terminator
code
Read data (for number of words read)
356
Host Link Commands Section 6-3
@ x 101 x 100 R H x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100 ↵
Node no. Header End code Read data (1 word) FCS Terminator
code
Read data (for number of words read)
6-3-4 PV READ –– RC
Reads the contents of the specified number of timer/counter PVs (present val-
ues), starting from the specified timer/counter.
Command Format
@ x 101 x 100 R C x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100 ↵
Node no. Header End code Read data (1 word) FCS Terminator
code Read data (for number of words read)
The response will be divided when reading more than 30 words of data.
357
Host Link Commands Section 6-3
@ x 101 x 100 R G x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100 ↵
The response will be divided when reading the status of more than 123 timer/
counters.
Parameters Read Data (Response)
The status of the number of Completion Flags specified by the command is re-
turned as a response. “1” indicates that the Completion Flag is ON.
@ x 101 x 100 R D x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100 ↵
Note Beginning word: 0000 to 6655 in CQM1 PCs, 0000 to 1023 and 6144 to 6655 in
CPM1/CPM1A PCs, and 0000 to 2047 and 6144 to 6655 in SRM1 PCs.
Node no. Header End code Read data (1 word) FCS Terminator
code
Read data (for number of words read)
358
Host Link Commands Section 6-3
Note 1. Words 1024 to 6143 in CPM1/CPM1A PCs and words 2048 to 6143 in
SRM1 PCs cannot be specified. If an attempt to read any of these words is
made, a response of 0000 will be returned.
2. The response will be divided when reading more than 30 words of data.
Parameters Read Data (Response)
The contents of the number of words specified by the command are returned in
hexadecimal as a response. The words are returned in order, starting with the
specified beginning word.
Note Be careful about the configuration of the DM area, as it varies depending on the
CPU Unit model.
@ x 101 x 100 R J x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100 ↵
Node no. Header End code Read data (1 word ) FCS Terminator
code
Read data
(for number of words read)
@ x 101 x 100 W R x 103 x 102 x 101 x 100 x 163 x 162 x 161 x 160 ↵
Node no. Header Beginning word* Write data (1 word) FCS Terminator
code
Write data
(for number of words to write)
Note 1. Beginning word: 0000 to 0252 in CQM1 PCs, 0000 to 0019 and 0200 to 0252
in CPM1/CPM1A/SRM1 PCs.
2. Divide the command when writing more than 30 words of data.
359
Host Link Commands Section 6-3
@ x 101 x 100 W L x 103 x 102 x 101 x 100 x 163 x 162 x 161 x 160 ↵
Node no. Header Beginning word* Write data (1 word) FCS Terminator
code
Write data
(for number of words to write )
360
Host Link Commands Section 6-3
Command Format
@ x 101 x 100 W H x 103 x 102 x 101 x 100 x 163 x 162 x 161 x 160 ↵
Node no. Header Beginning word* Write data (1 word) FCS Terminator
code
Write data
(for no. of words to write)
6-3-11 PV WRITE –– WC
Writes the PVs (present values) of timers/counters starting from the specified
timer/counter.
Command Format
@ x 101 x 100 W C x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100 ↵
Node no. Header Beginning timer/counter* Write data (1 timer/counter) FCS Terminator
code
Write data
(for no. of PV to write)
Note 1. Beginning T/C: 0000 to 0511 in CQM1 PCs, 0000 to 0127 in CPM1/
CPM1A/SRM1 PCs
2. Divide the command when writing more than 29 words of data.
Response Format An end code of 00 indicates normal completion.
361
Host Link Commands Section 6-3
2. If data is specified for writing which exceeds the allowable range, an error
will be generated and the writing operation will not be executed. If, for exam-
ple, 510 is specified as the beginning word for writing, and three words of
data are specified, then 512 will become the last word for writing data, and
the command will not be executed because TC 512 is beyond area bound-
ary.
@ x 101 x 100 W D x 103 x 102 x 101 x 100 x 163 x 162 x 161 x 160 ↵
Node no. Header Beginning word* Write data (1 word) FCS Terminator
code
Write data
(for number of words to write)
Note 1. Beginning word: 0000 to 6143 in CQM1 PCs, 0000 to 1023 and 6144 to 6655
in CPM1/CPM1A PCs, and 0000 to 2047 and 6144 to 6655 in SRM1 PCs
362
Host Link Commands Section 6-3
@ x 101 x 100 W J x 103 x 102 x 101 x 100 x 163 x 162 x 161 x 160 ↵
Node no. Header Beginning word* Write data (1 word) FCS Terminator
code
Write data
(for the number of words to write)
Note Beginning word: 0000 to 0027 in CQM1 PCs, 0000 to 0015 in CPM1/CPM1A
and SRM1 PCs
363
Host Link Commands Section 6-3
6-3-15 SV READ 1 –– R#
Searches for the first instance of a TIM, TIMH(15), CNT, and CNTR(12) instruc-
tion with the specified TC number in the user’s program and reads the PV, which
assumed to be set as a constant. The SV that is read is a 4-digit decimal number
(BCD). The program is searched from the beginning, which may take as much
as 10 seconds to produce a response.
Command Format
@ x 101 x 100 R # OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100 ↵
Response Format
6-3-16 SV READ 2 –– R$
Reads the constant SV or the word address where the SV is stored. The SV that
is read is a 4-digit decimal number (BCD) written as the second operand for the
TIM, TIMH(15), CNT, or CNTR(12) instruction at the specified program address
in the user’s program. This can only be done with a program of less than 10K.
Command Format
@ x 101 x 100 R $ x 103 x 102 x 101 x 100 OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100 ↵
364
Host Link Commands Section 6-3
@ x 101 x 100 R $ x 161 x 160 OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100 ↵
Note The instruction name specified under “Name” must be in four characters. Fill any
gaps with spaces to make a total of four characters.
@ x 101 x 100 R % x 105 x 104 x 103 x 102 x 101 x 100 OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100
FCS Terminator
365
Host Link Commands Section 6-3
@ x 101 x 100 R % x 161 x 160 OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100 ↵
Note The instruction name specified under “Name” must be in four characters. Fill any
gaps with spaces to make a total of four characters.
6-3-18 SV CHANGE 1 –– W#
Searches for the first instance of the specified TIM, TIMH(15), CNT, or
CNTR(12) instruction in the user’s program and changes the SV to new constant
SV specified in the second word of the instruction. The program is searched from
the beginning, and it may therefore take approximately 10 seconds to produce a
response.
Command Format
@ x 101 x 100 W # OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100 x 103 x 102 x 101 x 100 ↵
366
Host Link Commands Section 6-3
6-3-19 SV CHANGE 2 –– W$
Changes the contents of the second word of the TIM, TIMH(15), CNT, or
CNTR(12) at the specified program address in the user’s program. This can only
be done with a program of less than 10K.
Command Format
@ x 101 x 100 W $ x 103 x 102 x 101 x 100 OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100
367
Host Link Commands Section 6-3
Operand, SV (Response)
In “Operand,” specify the name that indicates the SV classification. Specify the
name in four characters. In “SV,” specify either the word address where the SV is
stored or the constant SV.
Operand Classification Constant or word address
OP1 OP2 OP3 OP4 CQM1 PCs CPM1 PCs
C I O (Space) IR or SR 0000 to 0252 0000 to 0019
0200 to 0252
L R (Space) (Space) LR 0000 to 0063 0000 to 0015
H R (Space) (Space) HR 0000 to 0099 0000 to 0019
A R (Space) (Space) AR 0000 to 0027 0000 to 0015
D M (Space) (Space) DM 0000 to 6655 0000 to 1023
6144 to 6655
D M (Space) DM (indirect) 0000 to 6655 0000 to 1023
6144 to 6655
C O N (Space) Constant 0000 to 9999 0000 to 9999
@ x 101 x 100 W % x 105 x 104 x 103 x 102 x 101 x 100 OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100
368
Host Link Commands Section 6-3
@ x 101 x 100 M S ↵
Node no. Header End code Status data Message FCS Terminator
code
x 161 x 160
Bit 7 6 5 4 3 2 1 0
1 0 0 0
In CQM1 PCs, the “Message” parameter is a FAL/FALS number that exists when
the command is executed. When there is no message, this parameter is omitted.
369
Host Link Commands Section 6-3
@ x 101 x 100 M F x 161 x 160 x 163 x 162 x 161 x 160 x 163 x 162 x 161 x 160 ↵
Node no. Header End code Error information Error information FCS Terminator
code (1st word) (2nd word)
370
Host Link Commands Section 6-3
2nd word
x 163 x 162 x 161 x 160
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0
SRM1 PCs
1st word
x 163 x 162 x 161 x 160
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0
2nd word
x 163 x 162 x 161 x 160
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0
371
Host Link Commands Section 6-3
Command Format
@ x 101 x 100 K S OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100 x 101 x 100 ↵
@ x 101 x 100 K R OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100 x 101 x 100 ↵
372
Host Link Commands Section 6-3
Note The area specified under “Name” must be in four characters. Add spaces after
the data area name if it is shorter than four characters.
Command Format
@ x 101 x 100 F K OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100
FCS Terminator
Bit 15 14 13 12 11 10 1 0
373
Host Link Commands Section 6-3
The bits that are merely set or reset may change status the next time the pro-
gram is executed, but bits that are force-set or force-reset will maintain the
forced status until it is cleared.
Command Format
@ x 101 x 100 K C ↵
374
Host Link Commands Section 6-3
@ x 101 x 100 M M ↵
6-3-29 TEST–– TS
Returns, unaltered, one block of data transmitted from the host computer.
Command Format
375
Host Link Commands Section 6-3
@ x 101 x 100 R P ↵
376
Host Link Commands Section 6-3
@ x 101 x 100 Q Q M R OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100 OP1 OP2
,
Node no. Header Sub-header Read area Read word address Data Data break
code code format
Single read information
Total read information (128 max.)
OP1 OP2 OP3 OP4 x 103 x 102 x 101 x 100 OP1 OP2 ↵
,
Data break Read area Read word address Data FCS Terminator
format
Single read information
Total read information (128 max.)
377
Host Link Commands Section 6-3
Area classifica- Read data Read area Read word Data format
tion CQM1 PCs CPM1/
CPM1A/
SRM1 PCs
IR or SR Bit C I O (S) 0000 to 0255 0000 to 0019 00 to 15 (decimal)
Word 0200 to 0255 “CH”
LR Bit L R (S) (S) 0000 to 0063 0000 to 0015 00 to 15 (decimal)
Word “CH”
HR Bit H R (S) (S) 0000 to 0099 0000 to 0019 00 to 15 (decimal)
Word “CH”
AR Bit A R (S) (S) 0000 to 0027 0000 to 0015 00 to 15 (decimal)
Bit “CH”
Timer Completion Flag T I M (S) 0000 to 0511 0000 to 0127 2 characters other than “CH”
PV “CH”
High-speed timer Completion Flag TIMH 0000 to 0511 0000 to 0127 2 characters other than “CH”
PV “CH”
Counter Completion Flag C N T (S) 0000 to 0511 0000 to 0127 2 characters other than “CH”
PV “CH”
Reversible counter Completion Flag CNTR 0000 to 0511 0000 to 0127 2 characters other than “CH”
PV “CH”
DM Word D M (S) (S) 0000 to 6655 0000 to 1023* Any 2 characters
6144 to 6655
(S): Space
Batch Reading
The bit, word, and timer/counter status is read as a batch according to the read
information that was registered with QQ.
Command Format
@ x 101 x 100 Q Q I R ↵
378
Host Link Commands Section 6-3
ON/
, , , x 163 x 162 x 161 x 160 ↵
OFF
6-3-33 ABORT –– XZ
Aborts the Host Link operation that is currently being processed, and then en-
ables reception of the next command. The ABORT command does not receive a
response.
Command Format
@ x 101 x 100 X Z ↵
6-3-34 INITIALIZE ––
Initializes the transmission control procedure of all the PCs connected to the
host computer. The INITIALIZE command does not use node numbers or FCS,
and does not receive a response.
Command Format
@ ↵
@ x 101 x 100 I C ↵
379
SECTION 7
PC Operations and Processing Time
This section explains the internal processing of the CQM1/CPM1/CPM1A/SRM1, and the time required for processing and
execution. Refer to this section to gain an understanding of the precise timing of CQM1/CPM1/CPM1A/SRM1 operation.
381
CQM1 Cycle Time and I/O Response Time Section 7-1
Power application
ON
Initialization
Transfer contents of
Memory Cassette to
CQM1.
No Check OK?
Overseeing
processes
Yes
Set error flags Preset cycle time
and activate monitoring time.
indicators.
ALARM
(flashing) Execute user’s program.
ERROR or ALARM?
No Program
ERROR End of program?
execution
(lit)
Yes
Check cycle time set-
ting. Cycle
time
Minimum No
cycle
time?
Cycle time
Yes processing
Wait until minimum cycle
time expires.
Service
Service RS-232C port. RS-232C
interface.
Service
Service peripheral port. peripheral
port.
382
CQM1 Cycle Time and I/O Response Time Section 7-1
One cycle of CPU Unit operation is called a cycle. The time required for one
cycle is called the cycle time.
I/O Refresh Methods CQM1 I/O refresh operations are broadly divided into two categories. The first of
these, input refresh, involves reading the ON/OFF status of input points to the
input bits. The second, output refresh, involves writing the ON/OFF status after
program execution to the output points. The CQM1 I/O refresh methods are as
shown in the following table.
Cyclic refresh must be executed for both inputs and outputs. If input refresh is to
be executed at the time of interrupts, then set the input refresh range in the PC
Setup (DM 6630 to DM 6638). Stopping direct refresh can be set in DM 6639 of
the PC Setup.
In addition to the methods described above, it is also possible to execute I/O re-
freshes in the program by means of IORF(97).
Note The percentages can be changed in the PC Setup (DM 6616, DM 6617).
383
CQM1 Cycle Time and I/O Response Time Section 7-1
Cycle Time and Operations The effects of the cycle time on CQM1 operations are as shown below.
Note 1. The number of timers to undergo interrupt processing can be set in DM 6629
of the PC Setup. The default setting is for TC 000 through TC 015.
2. The PC Setup (DM 6655) can be used to disable detection of CYCLE TIME
OVER error.
3. The FALS 9F cycle monitoring time can be changed by means of the PC Set-
up (DM 6618).
Cycle Time Example In this example, the cycle time is calculated for a CQM1 with 80 I/O points. The
I/O is configured as follows:
DC inputs: 48 points (3 words)
Bit outputs: 32 points (2 words)
The rest of the operating conditions are assumed to be as follows:
User’s program:2,000 instructions (configured of LD and OUT instructions)
Clock: None
RS-232C port: Not used
Cycle time: Variable (no minimum set)
Note The average processing time for a single instruction in the user’s program is as-
sumed to be 0.625 µs.
Process Calculation method Time with peripheral de- Time without peripheral
vice device
Overseeing Fixed 0.8 ms 0.8 ms
Program execution 0.625 × 2000 (µs) 1.25 ms 1.25 ms
Cycle time calculation Negligible 0 ms 0 ms
I/O refresh 0.01 × 3 + 0.005 × 2 (µs) 0.04 ms 0.04 ms
RS-232C port servicing Not used. 0 ms 0 ms
Peripheral port servicing Minimum time 0.34 ms 0 ms
Cycle time (1) + (2) + (3) + (4) + (5) + (6) 2.43 ms 2.09 ms
Note 1. The cycle time can be automatically read from the PC via a Peripheral De-
vice.
2. The maximum and current cycle time are stored in AR 26 and AR 27.
3. The cycle time can vary with actual operating conditions and will not neces-
sarily agree precisely with the calculated value.
4. The RS-232C and peripheral port service time will be 0.34 ms minimum,
87 ms maximum.
384
CQM1 Cycle Time and I/O Response Time Section 7-1
The following conditions are taken as examples for calculating the I/O response
times.
Input ON delay: 8 ms
Overseeing time: 1 ms
Instruction execution time: 14 ms
Output ON delay: 10 ms
Position of output instruction: Beginning of program
Communications ports: Not used.
Note The input ON delay for DC Input Units can be set in the PC Setup.
Minimum I/O Response Time The CQM1 responds most quickly when it receives an input signal just prior to
the input refresh phase of the cycle, as shown in the illustration below.
Output point
Output point
385
CQM1 Cycle Time and I/O Response Time Section 7-1
The minimum and maximum I/O response times are shown here, using as an
example the following instructions executed at the master and the slave. In this
example, communications proceed from the master to the slave.
Output (LR) Input Output
Input (LR)
The following conditions are taken as examples for calculating the I/O response
times.
Input ON delay: 8 ms
Master cycle time: 10 ms
Slave cycle time: 14 ms
Output ON delay: 10 ms
Direct output: Not used.
Number of LR words: 64
Note The input ON delay for DC Input Units can be set in the PC Setup.
Minimum I/O Response Time The CQM1 responds most quickly under the following circumstances:
1, 2, 3... 1. The CQM1 receives an input signal just prior to the input refresh phase of the
cycle.
2. The master to slave transmission begins immediately.
386
CQM1 Cycle Time and I/O Response Time Section 7-1
Output point
Maximum I/O Response Time The CQM1 takes the longest to respond under the following circumstances:
1, 2, 3... 1. The CQM1 receives an input signal just after the input refresh phase of the
cycle.
2. The master to slave transmission does not begin on time.
3. Communications are completed just after the slave executes communica-
tions servicing.
Output point
387
CQM1 Cycle Time and I/O Response Time Section 7-1
Processing Time The table below shows the times involved from the generation of an interrupt sig-
nal until the interrupt processing routine is called, and from when the interrupt
processing routine is completed until returning to the original position.
Note 1. When high-speed counter 0 is used with a range comparison table, the tim-
ing of interrupt processing can be affected by the cycle time.
2. When high-speed counters 1 and 2 are used with range comparison tables
(in CQM1-43/44-EV1 CPU Units), the timing of interrupt processing can be
delayed up to 1 ms.
Mask Processing
Interrupts are masked during processing of the operations described below. Un-
til the processing is completed, any interrupts will remain masked for the indi-
cated times.
High-speed timers: The time shown below is required, depending on (a) the
number of timers used with TIMH(15) and (b) the number
of high-speed timers active at that time. (The number of
high-speed timers is set in the PC Setup, DM 6629. The
default setting is 16.)
0 ≤ Standby time ≤ 50 + 3 × (a + b) µs
Up to 50 µs can be required even when no high-speed tim-
ers are used.
388
CQM1 Cycle Time and I/O Response Time Section 7-1
Example Calculation This example shows the interrupt response time (i.e., the time from when the
interrupt input turns ON until the start of the interrupt processing routine) when
input interrupts are used under the conditions shown below.
Number high-speed timers: 0 (No high-speed timers started)
Online edit: Not used
Input refresh at interrupt: No
Minimum Response Time
Interrupt input ON delay: 50 µs
Interrupt mask standby time: 0 µs
+ Change-to-interrupt processing: 40 µs
Minimum response time: 90 µs
Maximum Response Time
Interrupt input ON delay: 50 µs
Interrupt mask standby time: 50 µs
+ Change-to-interrupt processing: 40 µs
Minimum response time: 140 µs
In addition to the response time shown above, the time required for executing
the interrupt processing routine itself and a return time of 40 µs must also be ac-
counted for when returning to the process that was interrupted.
Be sure to allow for interrupt processing time when using interrupts in the pro-
gram.
Outputs from interrupt routines can be output immediately if direct output is
used. Direct output will be used for both the main program and the interrupt rou-
tines, and cannot be set separately.
389
CQM1 Cycle Time and I/O Response Time Section 7-1
Basic Instructions
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs) RSET IL JMP
--- LD 0.5 Any ---
--- LD NOT ---
--- AND
--- AND NOT
--- OR
--- OR NOT
--- AND LD
--- OR LD
--- OUT 0.75 Without direct outputs or for operands other ---
--- OUT NOT than IR 10000 to IR 11515 when direct outputs
are used.
--- SET 1.25 Direct outputs ---
--- RSET 1.25 Direct outputs ---
--- TIM 1.5 Constant for SV 1.5 1.5 1.5
DM for SV 54.1 1.5 1.5
--- CNT 1.5 Constant for SV 1.5 1.5 1.5
DM for SV 51.6 1.5 1.5
Special Instructions
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
00 NOP 0.5 Any 0.0
01 END 29 0.0
02 IL 12.3 10.9
03 ILC 11.3 11.3
04 JMP 18.3 11.9
05 JME 11.0 11.0
06 FAL 56.8 1.5
07 FALS 4.0 1.5
08 STEP 58.2 1.5
09 SNXT 25.0
10 SFT Shift IL JMP
44.2 With 1-word shift register 43.2 15.0 15.0
77.7 With 10-word shift register 68.5 15.0 15.0
415.2 With 100-word shift register 322.0 15.0 15.0
11 KEEP 0.75 Without direct outputs or for operands other
than IR 10000 to IR 11515 when direct outputs
are used.
1.25 Direct outputs using IR 10000 to IR 11515
12 CNTR Shift IL JMP
53.0 Constant for SV 33.1 20.7 20.7
79.6 DM for SV
13 DIFU 21.5 Any Reset IL JMP
21.0 20.8 17.8
14 DIFD 20.8 Any Reset IL JMP
20.8 20.6 17.6
15 TIMH Shift IL JMP
36.5 Constant for SV 54.7 53.0 27.7
36.5 DM for SV 81.0 79.6 27.7
390
CQM1 Cycle Time and I/O Response Time Section 7-1
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
16 WSFT 44.7 With 1-word shift register 2.0
77.0 With 10-word shift register
2.25 ms With 1,024-word shift register using DM
13.05 ms With 6,144-word shift register using DM
20 CMP 26.7 When comparing a constant to a word 2.0
29.5 When comparing two words
77.3 When comparing two DM
21 MOV 23.5 When transferring a constant to a word 2.0
26.3 When moving from one word to another
72.7 When transferring DM to DM
22 MVN 23.7 When transferring a constant to a word 2.0
26.5 When moving from one word to another
72.6 When transferring DM to DM
23 BIN 50.4 When converting a word to a word 2.0
96.0 When converting DM to DM
24 BCD 47.7 When converting a word to a word 2.0
93.3 When converting DM to DM
25 ASL 24.0 When shifting a word 1.5
45.8 When shifting DM
26 ASR 24.0 When shifting a word 1.5
45.8 When shifting DM
27 ROL 24.7 When rotating a word 1.5
46.6 When rotating DM
28 ROR 24.7 When rotating a word 1.5
46.6 When rotating DM
29 COM 25.9 When inverting a word 1.5
48.3 When inverting DM
30 ADD 49.9 Constant + word → word 2.5
53.1 Word + word → word
122.1 DM + DM → DM
31 SUB 49.9 Constant – word → word 2.5
53.1 Word – word → word
122.1 DM – DM → DM
32 MUL 73.7 Constant word → word 2.5
77.0 Word word → word
144.5 DM DM → DM
33 DIV 72.2 Word ÷ constant → word 2.5
75.4 word ÷ word → word
143.0 DM ÷ DM → DM
34 ANDW 41.9 Constant Ɠ word → word 2.5
45.1 Word Ɠ word → word
114.1 DM Ɠ DM → DM
35 ORW 41.9 Constant V word → word 2.5
45.1 Word V word → word
114.1 DM V DM → DM
36 XORW 41.9 Constant V word → word 2.5
45.2 Word V word → word
114.1 DM V DM → DM
391
CQM1 Cycle Time and I/O Response Time Section 7-1
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
37 XNRW 41.9 Constant V word → word 2.5
45.1 Word V word → word
114.1 DM V DM → DM
38 INC 27.8 When incrementing a word 1.5
50.1 When incrementing DM
39 DEC 28.4 When decrementing a word 1.5
50.8 When decrementing DM
40 STC 12.0 Any 1.0
41 CLC 12.0 1.0
45 TRSM 28.8 1.0
46 MSG 24.6 With message in words 1.5
48.4 With message in DM
50 ADB 53.4 Constant + word → word 2.5
56.6 Word + word → word
125.6 DM + DM → DM
51 SBB 53.4 Constant – word → word 2.5
56.6 Word – word → word
125.6 DM – DM → DM
52 MLB 45.7 Constant word → word 2.5
48.9 Word word → word
116.4 DM DM → DM
53 DVB 46.7 Word ÷ constant → word 2.5
49.9 Word ÷ word → word
117.4 DM ÷ DM → DM
54 ADDL 59.3 Word + word → word 2.5
128.9 DM + DM → DM
55 SUBL 59.3 Word – word → word 2.5
128.9 DM – DM → DM
56 MULL 204.5 Word word → word 2.5
271.2 DM DM → DM
57 DIVL 205.9 Word ÷ word → word 2.5
272.6 DM ÷ DM → DM
58 BINL 76.0 Word → word 2.0
120.6 DM → DM
59 BCDL 60.9 Word → word 2.0
105.6 DM → DM
70 XFER 72.9 When transferring a constant to a word 2.5
76.1 When transferring a word to a word
2.90 ms When transferring 1,024 words using DM
16.66 ms When transferring 6,144 words using DM
71 BSET 45.6 When setting a constant to 1 word 2.5
77.9 When setting word constant to 10 words
1.93 ms When setting DM to 1,024 words
10.95 ms When setting DM to 6,144 words
72 ROOT 63.9 Word calculation → word 2.0
110.8 DM calculation → DM
73 XCHG 40.9 Word → word 2.0
85.5 DM → DM
392
CQM1 Cycle Time and I/O Response Time Section 7-1
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
74 SLD 41.1 Shifting 1 word 2.0
101.9 Shifting 10 word
5.49 ms Shifting 1024 words using DM
32.58 ms Shifting 6144 words using DM
75 SRD 41.1 Shifting 1 word 2.0
101.9 Shifting 10 word
5.49 ms Shifting 1,024 words using DM
32.57 ms Shifting 6,144 words using DM
76 MLPX 59.1 When decoding word to word 2.5
136.4 When decoding DM to DM
77 DMPX 45.1 When encoding word to word 2.5
120.6 When encoding DM to DM
78 SDEC 60.6 When decoding word to word 2.5
138.5 When decoding DM to DM
80 DIST 66.0 When setting a constant to a word + a word 2.5
69.3 When setting a word to a word + a word
144.3 When setting DM to DM +DM
101.0 When setting a constant to a stack
104.3 When setting a word to a stack
177.8 When setting DM to a stack via DM
81 COLL 65.1 When setting a constant + a word to a word 2.5
68.3 When setting a word + a word to a word
140.1 When setting DM + DM to DM
61.1 When setting a word + constant to FIFO stack
64.3 When setting a word + word to FIFO stack
137.6 When setting a DM + DM to
FIFO stack via DM
60.3 When setting a word + constant to LIFO stack
63.6 When setting a word + word to LIFO stack
136.8 When setting a DM + DM to
LIFO stack via DM
82 MOVB 46.4 When moving constant to word 2.5
54.9 When moving word to word
125.2 When moving DM to DM
83 MOVD 40.7 When moving constant to word 2.5
49.2 When moving word to word
119.4 When moving DM to DM
84 SFTR 57.4 Shifting 1 word 2.5
98.4 Shifting 10 word
2.26 ms Shifting 1,024 words using DM
12.90 ms Shifting 6,144 words using DM
85 TCMP 95.8 Comparing constant to word-set table 2.5
98.8 Comparing word to word-set table
169.0 Comparing DM to DM-set table
86 ASC 62.5 Word → word 2.5
144.3 DM → DM
91 SBS 41.4 Any 1.5
92 SBN --- ---
93 RET 39.0 1.5
393
CQM1 Cycle Time and I/O Response Time Section 7-1
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
97 IORF 37.7 Refreshing IR 000 2.0
41.7 Refreshing one input word
46.9 Refreshing one output word
112.4 Refreshing 8 I/O words
99 MCRO 140.2 With word-set I/O operands 2.5
188.1 With DM-set I/O operands
Expansion Instructions
Code Mnemonic ON execution Conditions OFF execution
time (µs) time (µs)
17 ASFT 62.7 Shifting a word 2.5
96.7 Shifting 10 words
2.45 ms Shifting 1,024 words via DM
16.33 ms Shifting 6,144 words via DM
18 TKY 81.1 Word to word 2.5
131.8 DM to DM
19 MCMP 123.9 Comparing words 2.5
195.3 Comparing DM
47 RXD 123.1 Inputting 1 byte via word 2.5
847.3 Inputting 256 bytes via DM
48 TXD 105.1 Outputting 1 byte via word (RS-232C) 2.5
832.3 Outputting 256 bytes via DM (RS-232C)
86.3 Outputting 1 byte via word (host link)
141.9 Outputting 256 bytes via DM (host link)
60 CMPL 50.9 Comparing words 2.5
101.0 Comparing DM
61 INI High-speed counter 0 or pulse output from an output bit: 2.5
90.6 Starting comparison via word
114.4 Starting comparison via DM
72.1 Stopping comparison via word
83.0 Stopping comparison via DM
163.6 Changing PV via word
182.2 Changing PV via DM
56.4 Stopping pulse output via word
80.2 Stopping pulse output via DM
High-speed counters 1 and 2 or pulse output from ports 1 and 2:
296.8 Starting comparison via word
324.3 Starting comparison via DM
207.3 Stopping comparison via word
232.8 Stopping comparison via DM
468.3 Changing PV via word
487.8 Changing PV via DM
248.8 Stopping pulse output via word
269.8 Stopping pulse output via DM
Absolute high-speed counters 1 and 2:
296.3 Starting comparison via word
316.8 Starting comparison via DM
202.3 Stopping comparison via word
226.3 Stopping comparison via DM
394
CQM1 Cycle Time and I/O Response Time Section 7-1
395
CQM1 Cycle Time and I/O Response Time Section 7-1
396
CQM1 Cycle Time and I/O Response Time Section 7-1
397
CQM1 Cycle Time and I/O Response Time Section 7-1
398
CQM1 Cycle Time and I/O Response Time Section 7-1
399
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
Power application
No Check OK?
Overseeing
processes
Yes
Set error flags and Preset cycle time
activate indicators. monitoring time.
ALARM
(flashing) Execute user program.
ERROR or ALARM?
No Program
ERROR End of program?
execution
(lit)
Yes
Check cycle time set-
ting. Cycle
time
Minimum No
cycle time set?
Cycle time
Yes processing
Wait until minimum cycle
time expires.
Service
Service peripheral port. peripheral
port.
Note Initialization processes include clearing the IR, SR, and AR areas, presetting
system timers, and checking I/O Units.
400
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
Note The percentage of the cycle allocated to peripheral port servicing can be
changed in the PC Setup (DM 6617).
Cycle Time and Operations The effects of the cycle time on CPM1/CPM1A operations are as shown below.
When a long cycle time is affecting operation, either reduce the cycle time or im-
prove responsiveness with interrupt programs.
Note 1. The PC Setup (DM 6655) can be used to disable detection of CYCLE TIME
OVER error.
2. The cycle monitoring time can be changed in the PC Setup (DM 6618).
Cycle Time Example In this example, the cycle time is calculated for a CPM1/CPM1A CPU Unit with
20 I/O points (12 input points and 8 output points). The I/O is configured as fol-
lows:
401
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
The average processing time for a single instruction in the user’s program is as-
sumed to be 2.86 µs. The cycle times are as shown in the following table.
Process Calculation method Time with peripheral device Time without peripheral de-
vice
1. Overseeing Fixed 0.6 ms 0.6 ms
2. Program execution 2.86 × 500 (µs) 1.43 ms 1.43 ms
3. Cycle time calculation Negligible 0 ms 0 ms
4. I/O refresh 0.01 × 1 + 0.005 × 1 (µs) 0.06 ms 0.06 ms
5. Peripheral port servicing Minimum time 0.26 ms 0 ms
Cycle time (1) + (2) + (3) + (4) + (5) 2.35 ms 2.09 ms
Note 1. The cycle time can be read from the PC via a Peripheral Device.
2. The maximum and current cycle time are stored in AR 14 and AR 15.
3. The cycle time can vary with actual operating conditions and will not neces-
sarily agree precisely with the calculated value.
Output
Input
The following conditions are taken as examples for calculating the I/O response
times.
Input ON delay: 8 ms (input time constant: default setting)
Overseeing time: 1 ms (includes I/O refresh for CPM1A)
Instruction execution time: 14 ms
Output ON delay: 10 ms
Peripheral port: Not used.
Minimum I/O Response Time The CPM1/CPM1A responds most quickly when it receives an input signal just
prior to I/O refreshing, as shown in the illustration below.
Input
point Input ON delay (8 ms)
Input
bit
402
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
Maximum I/O Response Time The CPM1/CPM1A takes longest to respond when it receives the input signal
just after the input refresh phase of the cycle, as shown in the illustration below.
In that case, a delay of approximately one cycle will occur.
Input
point Input ON delay (8 ms)
Input
bit
Master Slave
The following conditions are taken as examples for calculating the I/O response
times. In CPM1/CPM1A PCs, LR area words LR 00 to LR 15 are used in one-to-
one links and the transmission time is fixed at 12 ms.
Input ON delay: 8 ms (input time constant: default setting)
Master cycle time: 10 ms
Slave cycle time: 15 ms
Output ON delay: 10 ms
Peripheral port: Not used.
Minimum I/O Response Time The CPM1/CPM1A responds most quickly under the following circumstances:
1, 2, 3... 1. The CPM1/CPM1A receives an input signal just prior to the input refresh
phase of the cycle.
2. The Master’s communications servicing occurs just as the master-to-slave
transmission begins.
403
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
CPU Program
processing execution
CPU Program
processing execution
Output ON
Slave
Slave’s cycle time (15 ms) delay (10 ms)
Output
point
Min. I/O response time = 8+10+12+15+10 = 55 ms
Maximum I/O Response Time The CPM1/CPM1A takes the longest to respond under the following circum-
stances:
1, 2, 3... 1. The CPM1/CPM1A receives an input signal just after the input refresh
phase of the cycle.
2. The Master’s communications servicing just misses the master-to-slave
transmission.
3. The transmission is completed just after the Slave’s communications servic-
ing ends.
I/O Maximum Response Time Input ON response time + Master’s cycle time x 2 + Transmission time x 3 + Out-
put ON response time
Input
I/O refresh
point
Input ON response time
Master Peripheral port servicing
Input
bit
CPU Program Program Program Program
execution execution execution execution
processing
Master #1 (Data transmission according to input point)
Trans- Trans-
Master to Slave mission Slave to Master mission Master to Slave Transmission time
time time
Output
point
Maximum I/O response time = 8 + 10 x 2 + 12 x 3 + 15 x 3 + 10 = 119 (ms)
404
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
405
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
In addition to the response time shown above, the time required for executing
the interrupt processing routine itself and a return time of 30 µs must also be ac-
counted for when returning to the process that was interrupted.
Basic Instructions
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs) RSET IL JMP
--- LD 1.72 Any ---
--- LD NOT
--- AND 1.32
--- AND NOT
--- OR
--- OR NOT
--- AND LD 0.72
--- OR LD
--- OUT 4.0
--- OUT NOT
--- SET 5.8
--- RSET 5.9
--- TIM 10.0 Constant for SV 16.2 16.0 6.4
DM for SV 31.4 31 6.4
--- CNT 12.5 Constant for SV 14.1 6.2 6.6
DM for SV 29.1 6.2 6.6
Special Instructions
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
00 NOP 0.36 Any
01 END 10.8
02 IL 4.6 2.6
03 ILC 3.6 3.6
04 JMP 4.3 2.4
05 JME 4.7 4.7
06 FAL 38.5 5.5
07 FALS 5.0 5.4
08 STEP 14.9 11.1
09 SNXT 14.2 7.6
10 SFT Reset IL JMP
21.9 With 1-word shift register 19.7 2.6 2.6
34.1 With 10-word shift register 26.5 2.6 2.6
93.6 With 100-word shift register 60.1 2.6 2.6
11 KEEP 6.2 Any Reset IL JMP
6.1 3.1 3.1
12 CNTR Reset IL JMP
25.8 Constant for SV 16.8 12.2 12.2
41.2 DM for SV
13 DIFU 11.8 Any Shift IL JMP
10.1 12.2 12.2
14 DIFD 11.0 Any Shift IL JMP
10.0 9.9 2.3
406
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
15 TIMH Reset IL JMP
19.0 Regular execution, constant for SV 25.7 28.4 15.8
20.2 Interrupt execution, constant for SV
19.0 Regular execution, DM for SV 41.2 43.6 15.8
20.2 Interrupt execution, DM for SV
16 WSFT 29.2 With 1-word shift register 5.6
40.7 With 10-word shift register
1.42 ms With 1,024-word shift register using DM
17 ASFT 29.6 Shifting a word 5.6
50.2 Shifting 10 words
1.76 ms Shifting 1,023 words via DM
20 CMP 15.8 When comparing a constant to a word 5.6
17.2 When comparing two words
46.3 When comparing two DM
21 MOV 16.3 When transferring a constant to a word 5.6
17.7 When moving from one word to another
45.5 When transferring DM to DM
22 MVN 16.4 When transferring a constant to a word 5.6
17.5 When moving from one word to another
45.7 When transferring DM to DM
23 BIN 31.6 When converting a word to a word 5.6
45.7 When converting DM to DM
24 BCD 29.5 When converting a word to a word 5.6
57.3 When converting DM to DM
25 ASL 17.3 When shifting a word 5.5
31.3 When shifting DM
26 ASR 16.9 When shifting a word 5.5
31.1 When shifting DM
27 ROL 14.5 When rotating a word 5.5
28.5 When rotating DM
28 ROR 14.5 When rotating a word 5.5
28.5 When rotating DM
29 COM 18.1 When inverting a word 5.5
32.1 When inverting DM
30 ADD 29.5 Constant + word → word 5.6
30.9 Word + word → word
72.7 DM + DM → DM
31 SUB 29.3 Constant – word → word 5.6
30.5 Word – word → word
72.5 DM – DM → DM
32 MUL 49.1 Constant word → word 5.6
50.5 Word word → word
95.1 DM DM → DM
33 DIV 47.7 Word ÷ constant → word 5.6
50.9 word ÷ word → word
94.3 DM ÷ DM → DM
407
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
34 ANDW 27.1 Constant Ɠ word → word 5.6
28.7 Word Ɠ word → word
70.7 DM Ɠ DM → DM
35 ORW 27.1 Constant V word → word 5.6
28.7 Word V word → word
70.7 DM V DM → DM
36 XORW 27.1 Constant V word → word 5.6
28.7 Word V word → word
70.5 DM V DM → DM
37 XNRW 27.0 Constant V word → word 5.6
28.6 Word V word → word
70.5 DM V DM → DM
38 INC 17.9 When incrementing a word 5.5
31.9 When incrementing DM
39 DEC 18.3 When decrementing a word 5.5
32.3 When decrementing DM
40 STC 6.3 Any 5.5
41 CLC 6.3 5.5
46 MSG 21.5 With message in words 5.5
35.7 With message in DM
50 ADB 30.5 Constant + word → word 5.6
32.1 Word + word → word
73.9 DM + DM → DM
51 SBB 30.9 Constant – word → word 5.6
32.7 Word – word → word
74.5 DM – DM → DM
52 MLB 34.7 Constant word → word 5.6
36.3 Word word → word
80.7 DM DM → DM
53 DVB 35.1 Word ÷ constant → word 5.6
36.7 Word ÷ word → word
81.1 DM ÷ DM → DM
54 ADDL 48.9 Word + word → word 5.6
94.7 DM + DM → DM
55 SUBL 48.9 Word – word → word 5.6
94.7 DM – DM → DM
56 MULL 138.7 Word word → word 5.6
184.3 DM DM → DM
57 DIVL 136.7 Word ÷ word → word 5.6
181.3 DM ÷ DM → DM
60 CMPL 30.4 Comparing words 5.6
60.8 Comparing DM
408
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
61 INI 112.0 Starting comparison via word 5.6
126.0 Starting comparison via DM
48.0 Stopping comparison via word
48.0 Stopping comparison via DM
120.0 Changing PV via word
128.0 Changing PV via DM
46.0 Stopping pulse output via word
60.0 Stopping pulse output via DM
62 PRV 62.2 Designating output via word 5.6
78.0 Designating output via DM
63 CTBL 106.3 Target table with 1 target in words and start 5.6
120.3 Target table with 1 target in DM and start
775.5 Target table with 16 targets in words and start
799.5 Target table with 16 targets in DM and start
711.5 Range table in words and start
722.5 Range table in DM and start
91.9 Target table with 1 target in words
106.3 Target table with 1 target in DM
693.5 Target table with 16 targets in words
709.5 Target table with 16 targets in DM
607.5 Range table in words
621.5 Range table in DM
64 SPED 73.6 Specifying a constant 5.6
75.0 Specifying a word
88.8 Specifying DM 5.6
65 PULS 62.0 Specifying a word 5.6
78.0 Specifying DM
67 BCNT 52.6 Counting a word 5.6
4.08 ms Counting 6,656 words via DM
68 BCMP 79.6 Comparing constant, results to word 5.6
80.8 Comparing word, results to word
123.2 Comparing DM, results to DM
69 STIM 47.5 Word-set one-shot interrupt start 5.6
58.7 DM-set one-shot interrupt start
47.9 Word-set scheduled interrupt start
59.1 DM-set scheduled interrupt start
33.5 Word-set timer read
63.5 DM-set timer read
25.7 Word-set timer stop
54.1 DM-set timer stop
70 XFER 45.5 When transferring a constant to a word 5.6
47.1 When transferring a word to a word
1.78 ms When transferring 1,024 words using DM
71 BSET 28.1 When setting a constant to 1 word 5.6
38.3 When setting word constant to 10 words
1.12 ms When setting DM to 1,024 words
73 XCHG 30.5 Word → word 5.6
59.1 DM → DM
409
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
74 SLD 25.9 Shifting 1 word 5.6
51.7 Shifting 10 word
3.02 ms Shifting 1024 words using DM
75 SRD 25.9 Shifting 1 word 5.6
51.7 Shifting 10 word
3.02 ms Shifting 1,024 words using DM
76 MLPX 47.7 When decoding word to word 5.6
92.7 When decoding DM to DM
77 DMPX 59.5 When encoding word to word 5.6
95.5 When encoding DM to DM
78 SDEC 51.1 When decoding word to word 5.6
96.3 When decoding DM to DM
80 DIST 39.1 When setting a constant to a word + a word 5.6
40.9 When setting a word to a word + a word
84.7 When setting DM to DM +DM
63.4 When setting a constant to a stack
65.0 When setting a word to a stack
109.6 When setting DM to a stack via DM
81 COLL 42.6 When setting a constant + a word to a word 5.6
43.6 When setting a word + a word to a word
83.4 When setting DM + DM to DM
78.0 When setting a word + constant to FIFO stack
79.2 When setting a word + word to FIFO stack
1.76 ms When setting a DM + DM to
FIFO stack via DM
66.8 When setting a word + constant to LIFO stack
68.0 When setting a word + word to LIFO stack
112.0 When setting a DM + DM to
LIFO stack via DM
82 MOVB 32.5 When moving constant to word 5.6
37.5 When moving word to word
79.1 When moving DM to DM
83 MOVD 28.3 When moving constant to word 5.6
33.3 When moving word to word
75.5 When moving DM to DM
84 SFTR 39.3 Shifting 1 word 5.6
52.9 Shifting 10 word
1.42 ms Shifting 1,024 words using DM
85 TCMP 57.7 Comparing constant to word-set table 5.6
58.9 Comparing word to word-set table
101.9 Comparing DM to DM-set table
86 ASC 56.7 Word → word 5.6
103.9 DM → DM
410
CPM1/CPM1A Cycle Time and I/O Response Time Section 7-2
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
89 INT 32.3 Set masks via word 5.6
46.3 Set masks via DM
29.1 Clear interrupts via word
43.1 Clear interrupts via DM
27.3 Read mask status via word
41.5 Read mask status via DM
29.7 Change counter SV via word
43.7 Change counter SV via DM
15.3 Mask all interrupts via word
15.3 Mask all interrupts via DM
15.9 Clear all interrupts via word
15.9 Clear all interrupts via DM
91 SBS 36.6 Any 5.5
92 SBN 1.7 1.7
93 RET 15.0 2.5
97 IORF 40.0 Refreshing IR 000 6.0
142.6 Refreshing one input word
135.4 Refreshing one output word
99 MCRO 74.0 With word-set I/O operands 5.6
116.4 With DM-set I/O operands
411
SRM1 Cycle Time and I/O Response Time Section 7-3
Initialization
Overseeing
processes
CompoBus/S
end wait
Input re-
freshing
Program
execution
Cycle
time
Cycle time
processing
Output re-
freshing
RS-232C
servicing
Service
peripheral
port.
412
SRM1 Cycle Time and I/O Response Time Section 7-3
Minimum Cycle Time In SRM1 PCs, CompoBus/S communications are started after the output re-
fresh is completed. As a result, when the overseeing time plus the RS-232C port
servicing time plus the peripheral port servicing time is shorter than the Compo-
Bus/S communications response time, processing is placed on stand-by until
CompoBus/S communications are completed.
The minimum cycle time therefore is the the CompoBus/S communications re-
sponse time plus the program execution time plus the input refresh time plus the
output refresh time. The CompoBus/S communications response time depends
on the maximum number of nodes set, as follows:
Max. no. of nodes set CompoBus/S response time
32 0.8 ms
16 0.5 ms
Cycle Time and Operations The effects of the cycle time on SRM1 operations are as shown below. When a
long cycle time is affecting operation, either reduce the cycle time or improve
responsiveness with interrupt programs.
Cycle time Operation conditions
10 ms or longer TIMH(15) may be inaccurate when TC 004 through TC 127 are used (operation will be normal for
TC 000 through TC 003).
20 ms or longer Programming using the 0.02-second Clock Bit (SR 25401) may be inaccurate.
100 ms or longer TIM may be inaccurate. Programming using the 0.1-second Clock Bit (SR 25500) may be inaccu-
rate. A CYCLE TIME OVER error is generated (SR 25309 will turn ON). See note 1.
120 ms or longer The FALS 9F monitoring time SV is exceeded. A system error (FALS 9F) is generated, and opera-
tion stops. See note 2.
200 ms or longer Programming using the 0.2-second Clock Bit (SR 25501) may be inaccurate.
Note 1. The PC Setup (DM 6655) can be used to disable detection of CYCLE TIME
OVER error.
2. The cycle monitoring time can be changed in the PC Setup (DM 6618).
413
SRM1 Cycle Time and I/O Response Time Section 7-3
Note 1. The cycle time can be read from the PC via a Peripheral Device.
2. The maximum and current cycle time are stored in AR 14 and AR 15.
3. The cycle time can vary with actual operating conditions and will not neces-
sarily agree precisely with the calculated value.
4. When the peripheral port is used, there is no CompoBus/S end wait time as it
is always 0 or less.
5. CompoBus/S end wait time = 0.8 – 0.18 – 0 – 0 = 0.62 (CompoBus/S com-
munication response time – Overseeing – RS-232C port servicing time –
peripheral port servicing time.
414
SRM1 Cycle Time and I/O Response Time Section 7-3
Cycle time
SRM1 cycle
Communications CompoBus/S
response time cycle time
Input
delay
Input on Slave
Output
Output on Slave delay
Cycle time
SRM1 cycle
Communications CompoBus/S
response time cycle time
Input
delay
Input on Slave
Output
Output on Slave delay
415
SRM1 Cycle Time and I/O Response Time Section 7-3
1, 2, 3... 1. The SRM1 receives an input signal just prior to the I/O refresh phase of the
cycle.
2. The Master’s communications servicing occurs just as the master-to-slave
transmission begins.
3. The Slave’s communications servicing occurs just after the transmission is
completed.
Program
execution
Program
execution
Output ON
Slave’s cycle time (15 ms) delay (10 ms)
Output
point
Min. I/O response time = 8+10+39+15+10 = 82 ms
Maximum I/O Response Time The SRM1 takes the longest to respond under the following circumstances:
1, 2, 3... 1. The SRM1 receives an input signal just after the I/O refresh phase of the
cycle.
2. The Master’s communications servicing just misses the master-to-slave
transmission.
3. The transmission is completed just after the Slave’s communications servic-
ing ends.
Program Program
execution execution
Program Program
execution execution
Output ON
Slave’s cycle time (15 ms) delay (10 ms)
Output
point
416
SRM1 Cycle Time and I/O Response Time Section 7-3
417
SRM1 Cycle Time and I/O Response Time Section 7-3
Basic Instructions
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs) RSET IL JMP
--- LD 0.97 Any ---
--- LD NOT 0.97
--- AND 0.77
--- AND NOT
--- OR 0.78 Any ---
--- OR NOT
--- AND LD 0.39 Any ---
--- OR LD
--- OUT 2.2
--- OUT NOT
--- SET 2.7
--- RSET 2.8
--- TIM 5.7 Constant for SV 9.3 9.1 3.5
DM for SV 17.4 17.2 3.5
--- CNT 6.6 Constant for SV 8.0 3.6 3.8
DM for SV 16.3 3.6 3.8
418
SRM1 Cycle Time and I/O Response Time Section 7-3
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
15 TIMH 10.3 Reset IL JMP
Regular execution, constant for SV 14.1 13.9 7.0
10.9 Interrupt execution, constant for SV 15.6 15.4 8.5
10.3 Regular execution, DM for SV 22.8 22.1 7.0
10.9 Interrupt execution, DM for SV 23.9 23.6 8.5
16 WSFT 16.2 With 1-word shift register 2.9
23.0 With 10-word shift register
712.3 With 1,024-word shift register using DM
17 ASFT* 18.6 Shifting a word 3.0
25.9 Shifting 10 words
865.7 Shifting 1,023 words via DM
20 CMP 9.1 When comparing a constant to a word 3.0
9.9 When comparing two words
25.6 When comparing two DM
21 MOV 9.1 When transferring a constant to a word 3.0
9.5 When moving from one word to another
24.9 When transferring DM to DM
22 MVN 9.3 When transferring a constant to a word 3.0
9.8 When moving from one word to another
25.1 When transferring DM to DM
23 BIN 17.2 When converting a word to a word 3.0
32.0 When converting DM to DM
24 BCD 15.8 When converting a word to a word 3.0
30.6 When converting DM to DM
25 ASL 9.9 When shifting a word 2.9
17.3 When shifting DM
26 ASR 9.7 When shifting a word 3.0
17.2 When shifting DM
27 ROL 8.5 When rotating a word 2.9
16.1 When rotating DM
28 ROR 8.5 When rotating a word 2.9
16.1 When rotating DM
29 COM 10.5 When inverting a word 3.0
17.7 When inverting DM
30 ADD 15.9 Constant + word → word 3.1
16.4 Word + word → word
39.5 DM + DM → DM
31 SUB 15.6 Constant – word → word 3.0
16.3 Word – word → word
38.6 DM – DM → DM
32 MUL 29.7 Constant word → word 3.0
28.5 Word word → word
51.6 DM DM → DM
33 DIV 27.2 Word ÷ constant → word 2.9
28.5 word ÷ word → word
53.1 DM ÷ DM → DM
419
SRM1 Cycle Time and I/O Response Time Section 7-3
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
34 ANDW 14.3 Constant Ɠ word → word 2.9
15.2 Word Ɠ word → word
37.3 DM Ɠ DM → DM
35 ORW 14.3 Constant V word → word 2.9
15.2 Word V word → word
37.3 DM V DM → DM
36 XORW 14.3 Constant V word → word 2.9
15.2 Word V word → word
37.3 DM V DM → DM
37 XNRW 14.3 Constant V word → word 2.9
15.2 Word V word → word
37.3 DM V DM → DM
38 INC 9.9 When incrementing a word 2.9
17.3 When incrementing DM
39 DEC 10.2 When decrementing a word 2.9
17.4 When decrementing DM
40 STC 3.5 Any 2.9
41 CLC 3.0 2.9
46 MSG 11.3 With message in words 2.9
19.4 With message in DM
47 RXD* 39.1 Word specification, 1 byte input 2.9
116.8 DM specification, 256 bytes input
48 TXD* 31.3 Word specification, 1 byte input (RS-232C) 2.9
266.5 DM specification, 256 bytes input (RS-232C)
26.7 Word specification, 1 byte input (Host Link)
34.0 DM specification, 256 bytes input (Host Link)
50 ADB 16.8 Constant + word → word 3.0
17.6 Word + word → word
39.9 DM + DM → DM
51 SBB 17.0 Constant – word → word 3.0
17.8 Word – word → word
40.2 DM – DM → DM
52 MLB 19.1 Constant word → word 3.0
20.1 Word word → word
43.5 DM DM → DM
53 DVB 19.5 Word ÷ constant → word 3.0
20.4 Word ÷ word → word
43.7 DM ÷ DM → DM
54 ADDL 26.7 Word + word → word 3.0
49.9 DM + DM → DM
55 SUBL 26.8 Word – word → word 3.0
49.9 DM – DM → DM
56 MULL 81.4 Word word → word 3.0
106.2 DM DM → DM
57 DIVL 76.9 Word ÷ word → word 3.0
101.8 DM ÷ DM → DM
60 CMPL 16.9 Comparing words 2.9
32.9 Comparing DM
420
SRM1 Cycle Time and I/O Response Time Section 7-3
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
67 BCNT* 26.9 Counting a word 3.0
2.29 ms Counting 6,656 words via DM
68 BCMP* 41.4 Comparing constant, results to word 3.0
41.9 Comparing word, results to word
64.5 Comparing DM, results to DM
69 STIM* 34.7 Word specification, one-shot timer start 3.0
49.5 DM specification, one-shot timer start
35.3 Word specification, scheduled interrupt start
50.0 DM specification, scheduled interrupt start
33.9 Words specification, timer read
49.5 DM specification timer read
11.4 Word specification, timer stop
70 XFER 22.9 When transferring a constant to a word 3.0
24.0 When transferring a word to a word
902.0 When transferring 1,024 words using DM
71 BSET 15.2 When setting a constant to 1 word 3.0
15.7 When setting word constant to 10 words
565.2 When setting DM to 1,024 words
73 XCHG 16.2 Word → word 3.1
31.5 DM → DM
74 SLD 13.6 Shifting 1 word 3.0
26.7 Shifting 10 word
1.54 ms Shifting 1024 words using DM
75 SRD 13.6 Shifting 1 word 3.0
26.6 Shifting 10 word
1.54 ms Shifting 1,024 words using DM
76 MLPX 25.5 When decoding word to word 3.0
48.9 When decoding DM to DM
77 DMPX 35.1 When encoding word to word 3.0
58.1 When encoding DM to DM
78 SDEC 26.8 When decoding word to word 2.9
49.9 When decoding DM to DM
80 DIST 21.3 When setting a constant to a word + a word 3.0
21.9 When setting a word to a word + a word
45.7 When setting DM to DM +DM
34.3 When setting a constant to a stack
35.3 When setting a word to a stack
59.3 When setting DM to a stack via DM
81 COLL 21.4 When setting a constant + a word to a word 3.0
21.8 When setting a word + a word to a word
44.9 When setting DM + DM to DM
34.0 When setting a word + constant to FIFO stack
33.9 When setting a word + word to FIFO stack
892.0 When setting a DM + DM to
FIFO stack via DM
35.4 When setting a word + constant to LIFO stack
36.1 When setting a word + word to LIFO stack
60.5 When setting a DM + DM to
LIFO stack via DM
421
SRM1 Cycle Time and I/O Response Time Section 7-3
Code Mnemonic ON execution Conditions (Top: min.; bottom: max.) OFF execution time (µs)
time (µs)
82 MOVB 18.2 When moving constant to word 3.0
19.0 When moving word to word
42.1 When moving DM to DM
83 MOVD 16.3 When moving constant to word 2.9
17.6 When moving word to word
39.9 When moving DM to DM
84 SFTR 21.0 Shifting 1 word 3.0
26.9 Shifting 10 word
718.5 Shifting 1,024 words using DM
85 TCMP 30.0 Comparing constant to word-set table 3.0
30.7 Comparing word to word-set table
53.1 Comparing DM to DM-set table
86 ASC 30.0 Word → word 3.0
53.7 DM → DM
91 SBS 13.2 Any 3.0
92 SBN --- 1.3
93 RET 7.8 1.3
99 MCRO 26.8 With word-set I/O operands 3.0
43.5 With DM-set I/O operands
422
SECTION 8
Troubleshooting
This section describes how to diagnose and correct the hardware and software errors that can occur during PC operation.
423
Programming Console Operation Errors Section 8-2
8-1 Introduction
PC errors can be divided broadly into the following four categories:
1, 2, 3... 1. Program Input Errors
These errors occur when inputting a program or attempting an operation
used to prepare the PC for operation.
2. Programming Errors
These errors will occur when the program is checked using the Program
Check operation.
3. User-defined Errors
There are three instructions that the user can use to define his own errors or
messages. The instructions will be executed when a particular condition
(defined by the user) has occurred during operation.
4. Operating Errors
These errors occur after program execution has been started.
a) Non-fatal Operating Errors
PC operation and program execution will continue after one or more of
these errors have occurred.
b) Fatal Operating Errors
PC operation and program execution will stop and all outputs from the
PC will be turned OFF when any of these errors have occurred.
The PC’s indicators will indicate when a PC error has occurred and an error mes-
sage or code will be displayed on the Programming Console or host computer if
one is connected. The error code is also contained in SR 25300 to SR 25307.
For the most recent errors, both the type of error and time of occurrence will be
recorded in the PC’s error log area. Details are provided starting on page 430.
There are flags and other information provided in the SR and AR areas that can
be used in troubleshooting. Refer to Section 3 Memory Areas for lists of these.
Note In addition to the errors described above, communications errors can occur
when the PC is part of a Host Link System. Refer to page 432 for details.
424
Programming Errors Section 8-3
425
User-defined Errors Section 8-4
! Caution Expansion instructions (those assigned to function codes 17, 18, 19, 47, 48, 60
to 69, 87, 88, and 89) are not subject to program checks. Program checks also
do not cover DM 1024 to DM 6143 for PCs that do not support this part of the DM
area (e.g., CQM1-CPU11-E and CQM1-CPU21-E). Data will not be written even
if these areas are specified and data read from these areas will always be
“0000.”
426
Operating Errors Section 8-5
The FALS numbers can be set arbitrarily to indicate particular conditions. The
same number cannot be used as both an FAL number and an FALS number.
To clear an FALS error, switch the PC to PROGRAM Mode, correct the cause of
the error, and then clear the error using the Programming Console.
FAILURE POINT DETECT – In CQM1 PCs, non-fatal errors and error messages can also be generated using
FPD(––) FPD(––). Refer to page 322 for details.
! Caution Investigate all errors, whether fatal or not. Remove the cause of the error as
soon as possible and restart the PC. Refer to the CQM1 Operation Manual or
CPM1 Operation Manual for hardware information and Programming Console
operations related to errors. Refer to the SSS Operation Manual for SSS opera-
tions related to errors.
427
Operating Errors Section 8-5
Communication Errors
If an error occurs in communications through the peripheral port or RS-232C
port the corresponding indicator (COM1 or COM2) will stop flashing. Check the
connecting cables as well as the programs in the PC and host computer.
Reset the communications ports with the Port Reset Bits, SR 25208 and
SR 25209.
Output Inhibit
When the OUT INH indicator is lit, the Output Inhibit Bit (SR 25215) is ON and all
outputs from the CPU Unit will be turned off. If it is not necessary to have all out-
puts off, turn OFF SR 25215.
Note ** is 01 to 99 or 9B.
428
Operating Errors Section 8-5
Note ** is 01 to 99 or 9F.
429
Error Log Section 8-6
CQM1 Error Log Area In CQM1 PCs, the error log is stored in DM 6569 through DM 6599.
If a Memory Cassette without a clock is mounted, the date and time will be all
zeros.
Error records will be stored even if pin 1 on the CQM1 DIP switch is turned ON to
protect DM 6144 to DM 6655.
430
Error Log Section 8-6
CPM1/CPM1A Error Log Area In CPM1/CPM1A PCs, the error log is stored in DM 1000 through DM 1021.
DM1000 Error log pointer The location for storing the next error record is shown. (0 to 6)
DM1001 Error log record 0 Each error log record is configured as follows:
DM1002 Bit 15 8 7 0
DM1003
Leading word Error classification Error code
Leading word + 1 00 00
to Leading word + 2 00 00
Error classification: 00: Nonfatal
80: Fatal
DM1019 Error log record 9
DM1020
DM1021
Error Log Storage Methods The error log storage method is set in the PC Setup (DM 6655). Set any of the
following methods.
1, 2, 3... 1. You can store the most recent 10 error log records and discard older re-
cords. This is achieved by shifting the records as shown below so that the
oldest record (record 0) is lost whenever a new record is generated.
Lost
Error log record 1
Error log record 2
All records shifted
2. You can store only the first 10 error log records, and ignore any subsequent
errors beyond those 10.
3. You can disable the log so that no records are stored.
The default setting is the first method. Refer to Error Log Settings on page 21 for
details on the PC Setup for the error log.
Clearing the Error Log To clear the entire error log, turn ON SR 25214 from a peripheral device. (After
the error log has been cleared, SR 25214 will turn OFF again automatically.)
SRM1 Error Log Area In SRM1 PCs, the error log is stored in DM 2000 through DM 2021.
DM2000 Error log pointer The location for storing the next error record is shown. (0 to 7)
DM2001 Error log record 0
DM2002 Each error log record is configured as follows:
DM2003 Bit 15 8 7 0
Leading word Error classification Error code
to Leading word + 1 00 00
Leading word + 2 00 00
Error classification: 00: Nonfatal
DM2019 Error log record 6 80: Fatal
DM2020
DM2021
431
Host Link Errors Section 8-7
Error Log Storage Methods The error log storage method is set in the PC Setup (DM 6655). Set any of the
following methods.
1, 2, 3... 1. You can store the most recent 7 error log records and discard older records.
This is achieved by shifting the records as shown below so that the oldest
record (record 0) is lost whenever a new record is generated.
Lost
Error log record 0
Error log record 1
All records shifted
2. You can store only the first 7 error log records, and ignore any subsequent
errors beyond those 7.
3. You can disable the log so that no records are stored.
The default setting is the first method. Refer to Error Log Settings on page 21 for
details on the PC Setup for the error log.
Clearing the Error Log To clear the entire error log, turn ON SR 25214 from a peripheral device. (After
the error log has been cleared, SR 25214 will turn OFF again automatically.)
@ X X X X X X X X ↵
The header code will vary according to the command. Some commands (com-
posite commands) contain a subcode.
432
Host Link Errors Section 8-7
Power Interruptions The following responses may be received from the CQM1 if a power interruption
occurs, including momentary interruptions. If any of these responses are re-
ceived during or after a power interruption, repeat the command.
Undefined Command Response
@00IC4A*↵
No Response
If no response is received, abort the last command and resend.
433
Troubleshooting Flowcharts Section 8-8
Main Check
Error
Lit
Not lit
RUN indicator lit? Check for fatal errors. (See page 436.)
Lit
Not lit
Normal
Note Always turn off the power to the PC before replacing Units, batteries, wiring, or
cables.
434
Troubleshooting Flowcharts Section 8-8
Yes
Yes
Note The allowable voltage ranges for the CQM1 are as shown below.
CQM1-PA203/PA206: 85 to 264 VAC
CQM1-PD026: 20 to 28 VDC
435
Troubleshooting Flowcharts Section 8-8
Fatal Error Check The following flowchart can be used to troubleshoot fatal errors that occur while
the Power indicator is lit.
No
Is the ERR/ALM
indicator lit?
Yes
Yes
Determine the cause No
Is PC mode displayed
of the error with a on Peripheral Device?
Peripheral Device.
Is PC mode displayed No
Correct the power
on Peripheral Device?
supply.
Yes
Switch to RUN or
MONITOR mode.
Yes
436
Troubleshooting Flowcharts Section 8-8
Non-fatal Error Check Although the PC will continue operating during non-fatal errors, the cause of the
error should be determined and removed as quickly as possible to ensure prop-
er operation. It may to necessary to stop PC operation to remove certain non-fa-
tal errors.
Flashing
Is the ERR/ALM indi-
cator flashing?
Not lit
End
Replace the CPU
Unit.
437
Troubleshooting Flowcharts Section 8-8
I/O Check The I/O check flowchart is based on the following ladder diagram section.
(LS1) (LS2)
00002 00003
10500 SOL1
10500
SOL1 malfunction.
Start
(See note)
Check the voltage at the Wire correctly. Replace terminal Monitor the ON/OFF
IR 10500 terminals. connector. status of IR 10500
with a Peripheral
Device.
No No
No Is terminal Yes No
Operation Is output wiring block making prop- Operation
O.K.? correct? er contact? O.K.? A
To
Yes Yes next
Yes page
Yes Operation No
O.K.?
Note The CPM1 PC doesn’t have the IR 10500 output indicator. Substitute with one
from IR 01000 to IR 01915.
438
Troubleshooting Flowcharts Section 8-8
No
Are the IR 00002
and IR 00003 input indi-
cators operating
A normally?
From
previous Yes
page
No
Operation
No O.K.? Is terminal Yes
Yes block making proper
Operation
O.K.? No contact?
Yes No
No Yes
Is input wiring
correct?
Yes
439
Troubleshooting Flowcharts Section 8-8
Consider
Is the installation envi- No constructing an
ronment okay? instrument panel
or cabinet.
Yes
End.
440
Appendix A
Programming Instructions
A PC instruction is input either by pressing the corresponding Programming Console key(s) (e.g., LD, AND, OR,
NOT) or by using function codes. To input an instruction with its function code, press FUN, the function code, and
then WRITE. Refer to the pages listed programming and instruction details.
Code Mnemonic Name Function Page
— AND AND Logically ANDs status of designated bit with execution condi- 196
tion.
— AND LD AND LOAD Logically ANDs results of preceding blocks. 197
— AND NOT AND NOT Logically ANDs inverse of designated bit with execution 196
condition.
— CNT COUNTER A decrementing counter. 210
— LD LOAD Used to start instruction line with the status of the designated 196
bit or to define a logic block for use with AND LD and OR LD.
— LD NOT LOAD NOT Used to start instruction line with inverse of designated bit. 196
— OR OR Logically ORs status of designated bit with execution condi- 196
tion.
— OR LD OR LOAD Logically ORs results of preceding blocks. 197
— OR NOT OR NOT Logically ORs inverse of designated bit with execution condi- 196
tion.
— OUT OUTPUT Turns ON operand bit for ON execution condition; turns OFF 197
operand bit for OFF execution condition.
— OUT NOT OUTPUT NOT Turns operand bit OFF for ON execution condition; turns op- 197
erand bit ON for OFF execution condition (i.e., inverts opera-
tion).
— RSET RESET Turns the operand bit OFF when the execution condition is 198
ON, and does not affect the status of the operand bit when
the execution condition is OFF.
— SET SET Turns the operand bit ON when the execution condition is 198
ON, and does not affect the status of the operand bit when
the execution condition is OFF.
— TIM TIMER ON-delay (decrementing) timer operation. 209
00 NOP NO OPERATION Nothing is executed and program moves to next instruction. 201
01 END END Required at the end of the program. 201
02 IL INTERLOCK If interlock condition is OFF, all outputs are turned OFF and 201
all timer PVs reset between this IL(02) and the next ILC(03).
03 ILC INTERLOCK CLEAR Other instructions are treated as NOP; counter PVs are 201
maintained.
04 JMP JUMP If jump condition is OFF, all instructions between JMP(04) 203
and the corresponding JME(05) are ignored.
05 JME JUMP END 203
06 (@)FAL FAILURE ALARM AND Generates a non-fatal error and outputs the designated FAL 205
RESET number to the Programming Console.
07 FALS SEVERE FAILURE Generates a fatal error and outputs the designated FALS 205
ALARM number to the Programming Console.
08 STEP STEP DEFINE When used with a control bit, defines the start of a new step 206
and resets the previous step. When used without N, defines
the end of step execution.
09 SNXT STEP START Used with a control bit to indicate the end of the step, reset 206
the step, and start the next step.
10 SFT SHIFT REGISTER Creates a bit shift register. 224
11 KEEP KEEP Defines a bit as a latch controlled by set and reset inputs. 199
12 CNTR REVERSIBLE Increases or decreases PV by one whenever the increment 211
COUNTER input or decrement input signals, respectively, go from OFF
to ON.
13 DIFU DIFFERENTIATE UP Turns ON the designated bit for one cycle on the rising edge 200
of the input signal.
441
Programming Instructions Appendix A
442
Programming Instructions Appendix A
443
Programming Instructions Appendix A
Expansion Instructions
The following table shows the instructions that can be treated as expansion instructions. The default function
codes are given for instructions that have codes assigned by default.
Code Mnemonic Name Function CPU Page
Units
17 (@)ASFT ASYNCHRONOUS SHIFT Creates a shift register that exchanges the con- All 230
REGISTER tents of adjacent words when one of the words is
zero and the other is not.
18 TKY TEN KEY INPUT Inputs 8 digits of BCD data from a 10-key key- CQM1 347
pad.
19 (@)MCMP MULTI-WORD COMPARE Compares a block of 16 consecutive words to CQM1 247
another block of 16 consecutive words.
47 (@)RXD RECEIVE Receives data via a communications port. CQM1/ 340
SRM1
48 (@)TXD TRANSMIT Sends data via a communications port. CQM1/ 342
SRM1
60 CMPL DOUBLE COMPARE Compares two eight-digit hexadecimal values. All 246
61 (@)INI MODE CONTROL Starts and stops counter operation, compares All except 220
and changes counter PVs, and stops pulse out- SRM1
put.
62 (@)PRV HIGH-SPEED COUNTER Reads counter PVs and status data for the high- All except 221
PV READ speed counter. SRM1
63 (@)CTBL COMPARISON TABLE Compares counter PVs and generates a direct All except 215
LOAD table or starts operation. SRM1
64 (@)SPED SPEED OUTPUT Outputs pulses at the specified frequency (10 Hz CQM1 330
to 50 KHz in 10 Hz units). The output frequency
can be changed while pulses are being output.
65 (@)PULS SET PULSES Outputs the specified number of pulses at the CQM1 328
specified frequency. The pulse output cannot be
stopped until the specified number of pulses
have been output.
66 (@)SCL SCALE Performs a scaling conversion on the calculated CQM1 266
value.
67 (@)BCNT BIT COUNTER Counts the total number of bits that are ON in the All 320
specified block of words.
68 (@)BCMP BLOCK COMPARE Judges whether the value of a word is within 16 All 244
ranges (defined by lower and upper limits).
69 (@)STIM INTERVAL TIMER Controls interval timers used to perform sched- All 213
uled interrupts.
87 DSW DIGITAL SWITCH INPUT Inputs 4- or 8-digit BCD data from a digital CQM1 346
switch.
88 7SEG 7-SEGMENT DISPLAY Converts 4- or 8-digit data to 7-segment display CQM1 345
OUTPUT format and then outputs the converted data.
89 (@)INT INTERRUPT CONTROL Performs interrupt control, such as masking and All except 326
unmasking the interrupt bits for I/O interrupts. SRM1
--- (@)ACC ACCELERATION Together with PULS(––), ACC(––) controls the CQM1- 334
CONTROL acceleration and/or deceleration of pulses output CPU43-E
from port 1 or 2. V1
--- (@)ADBL DOUBLE BINARY ADD Adds two 8-digit binary values (normal or signed CQM1 293
data) and outputs the result to R and R+1.
--- (@)APR ARITHMETIC PROCESS Performs sine, cosine, or linear approximation CQM1 305
calculations.
444
Programming Instructions Appendix A
445
Programming Instructions Appendix A
446
Appendix B
Error and Arithmetic Flag Operation
The following table shows the instructions that affect the ER, CY, GT, LT and EQ flags. In general, ER indicates that
operand data is not within requirements. CY indicates arithmetic or data shift results. GT indicates that a compared
value is larger than some standard, LT that it is smaller, and EQ, that it is the same. EQ also indicates a result of
zero for arithmetic operations. Refer to Section 5 Instruction Set for details.
Vertical arrows in the table indicate the flags that are turned ON and OFF according to the result of the instruction.
Although ladder diagram instructions,TIM, and CNT are executed when ER is ON, other instructions with a vertical
arrow under the ER column are not executed if ER is ON. All of the other flags in the following table will also not
operate when ER is ON.
Instructions not shown do not affect any of the flags in the table. Although only the non-differentiated form of each
instruction is shown, differentiated instructions affect flags in exactly the same way.
The ER, CY, GT, LT and EQ Flags are turned OFF when END(01) is executed, so their status cannot be monitored
with a Programming Device.
The status of the ER, CY, GT, LT and EQ Flags is affected by instruction execution and will change each time an
instruction that affects them is executed. Differentiated instructions are executed only once when their execution
condition changes (ON to OFF or OFF to ON) and are not executed again until the next specified change in their
execution condition. The status of the ER, CY, GT, LT and EQ Flags is thus affected by a differentiated instruction
only when the execution condition changes and is not affected during scans when the instruction is not executed,
i.e., when the specified change does not occur in the execution condition. When a differentiated instruction is not
executed, the status of the ER, CY, GT, LT and EQ Flags will not change and will maintain the status produced by
the last instruction that was executed.
Instructions 25503 (ER) 25504 (CY) 25505 (GR) 25506 (EQ) 25507 (LE) 25402 (N) Page
TIM Unaffected Unaffected Unaffected Unaffected Unaffected 209
CNT 210
END(01) OFF OFF OFF OFF OFF OFF 201
STEP(08) Unaffected Unaffected Unaffected Unaffected Unaffected Unaffected 206
SNXT(09) 206
CNTR(12) Unaffected Unaffected Unaffected Unaffected Unaffected 211
TIMH(15) 212
WSFT(16) 225
CMP(20) Unaffected Unaffected 242
MOV(21) Unaffected Unaffected Unaffected 232
MVN(22) 232
BIN(23) OFF 252
BCD(24) Unaffected 253
ASL(25) Unaffected Unaffected 225
ASR(26) OFF 226
ROL(27) 226
ROR(28) 227
COM(29) Unaffected Unaffected Unaffected 308
ADD(30) Unaffected Unaffected Unaffected 278
SUB(31) 279
447
Error and Arithmetic Flag Operation Appendix B
Instructions 25503 (ER) 25504 (CY) 25505 (GR) 25506 (EQ) 25507 (LE) 25402 (N) Page
MUL(32) Unaffected Unaffected Unaffected Unaffected 281
DIV(33) 282
ANDW(34) 309
ORW(35) 309
XORW(36) 310
XNRW(37) 311
INC(38) Unaffected 311
DEC(39) 312
STC(40) Unaffected ON Unaffected Unaffected Unaffected Unaffected 278
CLC(41) Unaffected OFF Unaffected Unaffected Unaffected Unaffected 278
MSG(46) Unaffected Unaffected Unaffected Unaffected Unaffected 317
ADB(50) Unaffected Unaffected 289
SBB(51) 290
MLB(52) Unaffected Unaffected Unaffected 291
DVB(53) Unaffected Unaffected Unaffected 292
ADDL(54) Unaffected Unaffected Unaffected 284
SUBL(55) 285
MULL(56) Unaffected Unaffected Unaffected Unaffected 286
DIVL(57) 287
BINL(58) OFF 254
BCDL(59) Unaffected 254
XFER(70) Unaffected Unaffected Unaffected Unaffected Unaffected 233
BSET(71) 234
ROOT(72) Unaffected Unaffected Unaffected Unaffected 288
XCHG(73) Unaffected Unaffected Unaffected Unaffected Unaffected 235
SLD(74) 228
SRD(75) 228
MLPX(76) 255
DMPX(77) 257
SDEC(78) 259
DIST(80) Unaffected Unaffected Unaffected 235
COLL(81) 237
MOVB(82) Unaffected Unaffected Unaffected Unaffected Unaffected 239
MOVD(83) 240
SFTR(84) Unaffected Unaffected Unaffected Unaffected 229
TCMP(85) Unaffected Unaffected Unaffected Unaffected 243
ASC(86) Unaffected Unaffected Unaffected Unaffected Unaffected 262
SBS(91) 313
MCRO(99) Unaffected Unaffected Unaffected Unaffected Unaffected 319
448
Error and Arithmetic Flag Operation Appendix B
Note 1. Only expansion instructions with default function numbers are applicable to the SRM1 PCs.
2. SR 25410 will be ON when DSW(87) is being executed.
3. SR 25409 will be ON when 7SEG(88) is being executed.
4. SR 25408 will be ON when HKY(––) is being executed.
449
Error and Arithmetic Flag Operation Appendix B
Note 1. Depending on the calculation results, ADBL(––) and SBBL(––) may also affect the status of the overflow
and underflow flags (SR 25404 and SR 25405).
2. Depending on the conversion results, NEG(––) and NEGL(––) may also affect the status of the under-
flow flag (SR 25405).
450
Appendix C
Memory Areas
451
Memory Areas Appendix C
Note 1. IR and LR bits that are not used for their allocated functions can be used as work bits.
2. At least 2,720 bits can be used as work bits. The total number of bits that can be used depends on the
configuration of the PC system.
3. When accessing a PV, TC numbers are used as word data; when accessing Completion Flags, they are
used as bit data.
4. Although the CQM1-CPU11-E and CQM1-CPU21-E do not support DM 1024 through DM 6143, an er-
ror will not occur if they are addressed. Any attempt to write to these words will have no effect and any
reads will produce all zeros.
5. Data in DM 6144 to DM 6655 cannot be overwritten from the program.
SR Area
These bits mainly serve as flags related to CQM1 operation. The following table
provides details on the various bit functions.
Word Bit(s) Function Page
SR 244 00 to 15 Input Interrupt 0 Counter Mode SV 42
SV when input interrupt 0 is used in counter mode (4 digits hexadecimal, 0000 to
FFFF). (Can be used as work bits when input interrupt 0 is not used in counter mode.)
SR 245 00 to 15 Input Interrupt 1 Counter Mode SV
SV when input interrupt 1 is used in counter mode (4 digits hexadecimal, 0000 to
FFFF). (Can be used as work bits when input interrupt 1 is not used in counter mode.)
SR 246 00 to 15 Input Interrupt 2 Counter Mode SV
SV when input interrupt 2 is used in counter mode (4 digits hexadecimal, 0000 to
FFFF). (Can be used as work bits when input interrupt 2 is not used in counter mode.)
SR 247 00 to 15 Input Interrupt 3 Counter Mode SV
SV when input interrupt 3 is used in counter mode (4 digits hexadecimal, 0000 to
FFFF). (Can be used as work bits when input interrupt 3 is not used in counter mode.)
SR 248 00 to 15 Input Interrupt 0 Counter Mode PV Minus One 42
Counter PV-1 when input interrupt 0 is used in counter mode (4 digits hexadecimal).
SR 249 00 to 15 Input Interrupt 1 Counter Mode PV Minus One
Counter PV-1 when input interrupt 1 is used in counter mode (4 digits hexadecimal).
SR 250 00 to 15 Input Interrupt 2 Counter Mode PV Minus One
Counter PV-1 when input interrupt 2 is used in counter mode (4 digits hexadecimal).
SR 251 00 to 15 Input Interrupt 3 Counter Mode PV Minus One
Counter PV-1 when input interrupt 3 is used in counter mode (4 digits hexadecimal).
452
Memory Areas Appendix C
453
Memory Areas Appendix C
Note Writing is not possible for the following words: SR 248 through SR 251, and SR 253 through SR255.
Explanation of SR Bits
SR 25211 (Forced Status Hold Bit)
When the forced set/reset status is cleared, the bits that were forced will be turned ON or OFF as follows:
Forced set cleared: Bit turned ON
Forced reset cleared: Bit turned OFF
All force-set or force-reset bits will be cleared when the PC is switched to RUN mode (see note).
This bit is turned ON and OFF from a peripheral device.
A setting can be made in the PC Setup (DM 6601) to cause the status of this Bit to be retained even when powering
up.
Note DM 6601 in the PC Setup can be set to maintain the previous status of the Forced Status Hold Bit when
power is turned on. This setting can be used to prevent forced status from being cleared even when power is
turned on.
454
Memory Areas Appendix C
AR Area
These bits mainly serve as flags related to CQM1 operation. The following table provides details on the various bit
functions.
With the exception of AR 23 (Power-off Counter), the status of AR words and bits is refreshed each cycle. (AR 23 is
refreshed only for power interruptions.)
Word Bit(s) Function Page
AR 00 to --- Not used.
AR 03
AR 04 08 to 15 CQM1-CPU43/44-EV1: Pulse I/O or Absolute High-speed Counter Status Code: 59
00: Normal
01, 02: Hardware error
03: PC Setup error
04: PC stopped during pulse output
AR 05 00 to 07 CQM1-CPU43/44-EV1: High-speed Counter 1 Range Comparison Flags 59
00 ON: Counter PV is within comparison range 1
01 ON: Counter PV is within comparison range 2
02 ON: Counter PV is within comparison range 3
03 ON: Counter PV is within comparison range 4
04 ON: Counter PV is within comparison range 5
05 ON: Counter PV is within comparison range 6
06 ON: Counter PV is within comparison range 7
07 ON: Counter PV is within comparison range 8
08 CQM1-CPU43/44-EV1: High-speed Counter 1 Comparison Flag 59
OFF: Stopped
ON: Comparing
09 CQM1-CPU43/44-EV1: High-speed Counter 1 Overflow/Underflow Flag 59
OFF: Normal
ON: Overflow or underflow occurred.
10 to 11 Not used.
12 to 15 CQM1-CPU43-EV1: Port 1 Pulse Output Flags 333
12 ON: Deceleration specified. (OFF: Not specified.)
13 ON: Number of pulses specified. (OFF: Not specified.)
14 ON: Pulse output completed. (OFF: Not completed.)
15 ON: Pulse output in progress. (OFF: No pulse output.)
AR 06 00 to 15 CQM1-CPU43/44-EV1: High-speed Counter 2/Port 2 Pulse Output Flags 59
Identical to the High-speed Counter 1/Port 1 Pulse Output Flags in AR 05.
AR 07 00 to 11 Not used.
12 DIP Switch Pin 6 Flag ---
OFF: CPU Unit’s DIP switch pin no. 6 is OFF.
ON: CPU Unit’s DIP switch pin no. 6 is ON.
13 to 15 Not used.
455
Memory Areas Appendix C
456
Memory Areas Appendix C
457
Memory Areas Appendix C
458
Memory Areas Appendix C
Note 1. IR and LR bits that are not used for their allocated functions can be used as work bits.
2. The contents of the HR area, Counter area, and read/write DM area are backed up by a capacitor. At
25C, the capacitor will back up memory for 20 days. Refer to 2-1-2 Characteristics in the CPM1 or
CPM1A Operation Manual for a graph showing the backup time vs. temperature.
3. When accessing a PV, TC numbers are used as word data; when accessing Completion Flags, they are
used as bit data.
4. Data in DM 6144 to DM 6655 cannot be overwritten from the program, but they can be changed from a
Peripheral Device.
459
Memory Areas Appendix C
5. The contents of the HR area, LR area, Counter area, and read/write DM area are backed up by a capaci-
tor. The backup time varies with the ambient temperature, but at 25C, the capacitor will back up
memory for 20 days. If the power supply is off longer than the backup time, memory contents will be
cleared and AR1314 will turn ON. (This flag turns ON when data can no longer be retained by the built-in
capacitor.) Refer to 2-1-2 Characteristics in the CPM1 Operation Manual for a graph showing the back-
up time vs. temperature.
SR Area
These bits mainly serve as flags related to CPM1/CPM1A operation or contain present and set values for various
functions. The functions of the SR area are explained in the following table.
Word(s) Bit(s) Function Page
SR 232 00 to 15 Macro Function Input Area 128
to Contains the input operands for MCRO(99).
SR 235 (Can be used as work bits when MCRO(99) is not used.)
SR 236 00 to 15 Macro Function Output Area
to Contains the output operands for MCRO(99).
SR 239 (Can be used as work bits when MCRO(99) is not used.)
SR 240 00 to 15 Input Interrupt 0 Counter Mode SV 42
SV when input interrupt 0 is used in counter mode (4 digits hexadecimal).
(Can be used as work bits when input interrupt 0 is not used in counter mode.)
SR 241 00 to 15 Input Interrupt 1 Counter Mode SV
SV when input interrupt 1 is used in counter mode (4 digits hexadecimal).
(Can be used as work bits when input interrupt 1 is not used in counter mode.)
SR 242 00 to 15 Input Interrupt 2 Counter Mode SV
SV when input interrupt 2 is used in counter mode (4 digits hexadecimal).
(Can be used as work bits when input interrupt 2 is not used in counter mode.)
SR 243 00 to 15 Input Interrupt 3 Counter Mode SV
SV when input interrupt 3 is used in counter mode (4 digits hexadecimal).
(Can be used as work bits when input interrupt 3 is not used in counter mode.)
SR 244 00 to 15 Input Interrupt 0 Counter Mode PV Minus One 42
Counter PV–1 when input interrupt 0 is used in counter mode (4 digits hexadecimal).
SR 245 00 to 15 Input Interrupt 1 Counter Mode PV Minus One
Counter PV–1 when input interrupt 1 is used in counter mode (4 digits hexadecimal).
SR 246 00 to 15 Input Interrupt 2 Counter Mode PV Minus One
Counter PV–1 when input interrupt 2 is used in counter mode (4 digits hexadecimal).
SR 247 00 to 15 Input Interrupt 3 Counter Mode PV Minus One
Counter PV–1 when input interrupt 3 is used in counter mode (4 digits hexadecimal).
SR 248, 00 to 15 High-speed Counter PV Area 48
SR 249 (Can be used as work bits when the high-speed counter is not used.)
SR 250 00 to 15 Analog Volume Setting 0 129
Used to store the 4-digit BCD set value (0000 to 0200) from analog volume control 0.
SR 251 00 to 15 Analog Volume Setting 1
Used to store the 4-digit BCD set value (0000 to 0200) from analog volume control 1.
460
Memory Areas Appendix C
461
Memory Areas Appendix C
AR Area
These bits mainly serve as flags related to CPM1/CPM1A operation. These bits retain their status even after the
CPM1/CPM1A power supply has been turned off or when operation begins or stops.
Word(s) Bit(s) Function Page
AR 00, 00 to 15 Not used.
AR 01
AR 02 00 to 07 Not used. ---
08 to 11 Number of I/O Units Connected
12 to 15 Not used.
AR 03 to 00 to 15 Not used.
AR 07
AR 08 00 to 07 Not used.
08 to 11 Peripheral Device Error Code 99
0: Normal completion
1: Parity error
2: Frame error
3: Overrun error
12 Peripheral Device Error Flag
13 to 15 Not used.
AR 09 00 to 15 Not used.
AR 10 00 to 15 Power-off Counter (4 digits BCD) ---
This is the count of the number of times that the power has been turned off.
To clear the count, write “0000” from a peripheral device.
AR 11 00 to 07 High-speed Counter Range Comparison Flags 51
00 ON: Counter PV is within comparison range 1
01 ON: Counter PV is within comparison range 2
02 ON: Counter PV is within comparison range 3
03 ON: Counter PV is within comparison range 4
04 ON: Counter PV is within comparison range 5
05 ON: Counter PV is within comparison range 6
06 ON: Counter PV is within comparison range 7
07 ON: Counter PV is within comparison range 8
08 to 14 Not used.
15 Pulse Output Status ---
ON: Stopped.
OFF: Pulses being output.
462
Memory Areas Appendix C
Note 1. The units will be as follows, depending on the unit setting for the cycle monitor time (DM 6618):
Initial status: 0.1-ms unit
When 10-ms unit is set: 0.1-ms unit
When 100-ms unit is set: 1-ms unit
When 1-s unit is set: 10-ms unit
463
Memory Areas Appendix C
2. Areas that cannot be used are cleared when the power is turned on.
3. The contents of AR 10 is backed up by the built-in capacitor. If power is left OFF for longer than the back-
up time, however, the contents may be cleared. For details regarding the backup time, refer to the
CPM1A or CPM1 Operation Manual.
464
Memory Areas Appendix C
Note 1. IR and LR bits that are not used for their allocated functions can be used as work bits.
2. The contents of the HR area, LR area, Counter area, and read/write DM area are backed up by a capaci-
tor. At 25C, the capacitor will back up memory for 20 days. Refer to 2-1-2 Characteristics in the SRM1
Master Control Unit Operation Manual for a graph showing the backup time vs. temperature.
3. When accessing a PV, TC numbers are used as word data; when accessing Completion Flags, they are
used as bit data.
4. Data in DM 6144 to DM 6655 cannot be overwritten from the program, but they can be changed from a
Peripheral Device.
SR Area
These bits mainly serve as flags related to SRM1 operation or contain present and set values for various functions.
The functions of the SR area are explained in the following table.
Word(s) Bit(s) Function Page
SR 240 00 to 15 Not used.
to Can be used as work bits.
SR247
SR 248, 00 to 15 Reserved.
SR249
SR 250, 00 to 15 Not used.
SR251 Can be used as work bits.
SR 252 00 Not used. (system use)
01 to 07 Not used.
08 Peripheral Port Reset Bit 92
Turn ON to reset peripheral port. (Not valid when peripheral device is connected.) Auto-
matically turns OFF when reset is complete.
09 RS-232C Port Reset Bit
Automatically turns OFF when reset is complete.
10 PC Setup Reset Bit 3
Turn ON to initialize PC Setup (DM 6600 through DM 6655). Automatically turns OFF
again when reset is complete. Only effective if the PC is in PROGRAM mode.
11 Forced Status Hold Bit 17
OFF: The forced status of bits that are forced set/reset is cleared when switching be-
tween PROGRAM mode and MONITOR mode.
ON: The status of bits that are forced set/reset are maintained when switching between
PROGRAM mode and MONITOR mode.
12 I/O Hold Bit 17
OFF: IR and LR bits are reset when starting or stopping operation.
ON: IR and LR bit status is maintained when starting or stopping operation.
13 Not used.
14 Error Log Reset Bit 431
Turn ON to clear error log. Automatically turns OFF again when operation is complete.
15 Not used.
465
Memory Areas Appendix C
AR Area
These bits mainly serve as flags related to SRM1 operation. These bits retain their status even after the SRM1
power supply has been turned off or when operation begins or stops.
Word(s) Bit(s) Function Page
AR 00, 00 to 15 Not used.
AR 01
AR 02 00 to 07 Not used.
08 to 11 Not used. (system use)
12 to 15 Not used.
AR 03 00 to 15 Not used.
AR 04 to 00 to 15 Slave Status Flag ---
AR 07
466
Memory Areas Appendix C
467
Memory Areas Appendix C
468
Appendix D
Using the Clock Function
The CQM1 can be provided with a clock function by installing a Memory Cassette equipped with a clock. This
appendix explains how to use the clock.
The following two Memory Cassettes are equipped with a clock:
CQM1-ME04R (EPROM) and CQM1-ME08R (EEPROM).
! Caution The clock will stop and the current date and time information will be lost if the
Memory Cassette is removed from the PC.
469
Appendix E
I/O Assignment Sheet
471
Appendix F
Program Coding Sheet
473
Program Coding Sheet Appendix F
474
Program Coding Sheet Appendix F
475
Appendix G
List of FAL Numbers
FAL FAL contents Corrective measure FAL FAL contents Corrective measure
No. No.
00 35
01 36
02 37
03 38
04 39
05 40
06 41
07 42
08 43
09 44
10 45
11 46
12 47
13 48
14 49
15 50
16 51
17 52
18 53
19 54
20 55
21 56
22 57
23 58
24 59
25 60
26 61
27 62
28 63
29 64
30 65
31 66
32 67
33 68
34 69
477
List of FAL Numbers Appendix G
FAL FAL contents Corrective measure FAL FAL contents Corrective measure
No. No.
70 85
71 86
72 87
73 88
74 89
75 90
76 91
77 92
78 93
79 94
80 95
81 96
82 96
83 97
84 99
478
Appendix H
Extended ASCII
The following codes are used to output characters to the Programming Console or Data Access Console using
MSG(46) or FPD(––). Refer to pages 317 and 322 for details.
Right Left digit
digit 0, 1, 2 3 4 5 6 7 A B C D E F
8, 9
0 0 @ P ` p Ć @ P ` p
1 ! 1 A Q a q ! 1 A Q a q
2 " 2 B R b r " 2 B R b r
3 # 3 C S c s # 3 C S c s
4 $ 4 D T d t $ 4 D T d t
5 % 5 E U e u % 5 E U e u
6 & 6 F V f v & 6 F V f v
7 ' 7 G W g w ' 7 G W g w
8 ( 8 H X h x ( 8 H X h x
9 ) 9 I Y i y ) 9 I Y i y
A * : J Z j z * : J Z j z
B + ; K [ k { + ; K [ k {
C , < L \ l | , < L \ l |
D Ć = M ] m } Ć = M ] m }
E . > N ^ n ~ . > N ^ n
F / ? O _ o « / ? O _ o ~
479
Appendix I
CPM1/CPM1A and CQM1 Memory Area
Comparison
This table shows the differences between the CPM1/CPM1A and CQM1 memory areas.
Data area CPM1/CPM1A CQM1
IR area Input area IR 000 to IR 009 IR 000 to IR 015
Output area IR 010 to IR 019 IR 100 to IR 115
Work areas IR 200 to IR 231 IR 016 to IR 099
and special (IR 020 to IR 199 cannot IR 116 to IR 144
areas be used.)
SR area SR 232 to SR 255 SR 244 to SR 255
HR area HR 00 to HR 19 HR 00 to HR 99
(HR 20 to HR 99 cannot
be used.)
AR area AR 00 to AR 15 AR 00 to AR 27
(AR 16 to AR 27 cannot
be used.)
LR area LR 00 to LR 15 LR 00 to LR 63
(LR 16 to LR 63 cannot
be used.)
Timer/Counter area TC 000 to TC 127 TC 000 to TC 511
(TC 128 to TC 511 can-
not be used.)
DM area Read/write DM 0000 to DM 0999 DM 0000 to DM 1023
DM 1022 to DM 1023 DM 1024 to DM 6143
(DM 1024 to DM 6143
cannot be used.)
Error history DM 1000 to DM 1021 DM 6569 to DM 6599
Read-only DM 6144 to DM 6599 DM 6144 to DM 6568
PC Setup DM 6600 to DM 6655 DM 6600 to DM 6655
481
Glossary
483
Glossary
bit designator An operand that is used to designate the bit or bits of a word to be used by an
instruction.
bit number A number that indicates the location of a bit within a word. Bit 00 is the rightmost
(least-significant) bit; bit 15 is the leftmost (most-significant) bit.
bit-control instruction An instruction that is used to control the status of an individual bit as opposed to
the status of an entire word.
block See logic block and instruction block.
building-block PC A PC that is constructed from individual components, or “building blocks.” With
building-block PCs, there is no one Unit that is independently identifiable as a
PC. The PC is rather a functional assembly of Units.
bus A communications path used to pass data between any of the Units connected
to it.
bus bar The line leading down the left and sometimes right side of a ladder diagram.
Instruction execution proceeds down the bus bar, which is the starting point for
all instruction lines.
byte A unit of data equivalent to 8 bits, i.e., half a word.
call A process by which instruction execution shifts from the main program to a sub-
routine. The subroutine may be called by an instruction or by an interrupt.
Carry Flag A flag that is used with arithmetic operations to hold a carry from an addition or
multiplication operation, or to indicate that the result is negative in a subtraction
operation. The carry flag is also used with certain types of shift operations.
central processing unit A device that is capable of storing programs and data, and executing the instruc-
tions contained in the programs. In a PC System, the central processing unit
executes the program, processes I/O signals, communicates with external de-
vices, etc.
CH See word.
channel See word.
character code A numeric (usually binary) code used to represent an alphanumeric character.
checksum A sum transmitted with a data pack in communications. The checksum can be
recalculated from the received data to confirm that the data in the transmission
has not been corrupted.
clock pulse A pulse available at specific bits in memory for use in timing operations. Various
clock pulses are available with different pulse widths, and therefore different fre-
quencies.
clock pulse bit A bit in memory that supplies a pulse that can be used to time operations. Vari-
ous clock pulse bits are available with different pulse widths, and therefore differ-
ent frequencies.
common data Data that is stored in a memory of a PC and which is shared by other PCs in the
same the same system. Each PC has a specified section(s) of the area allocated
to it. Each PC writes to the section(s) allocated to it and reads the sections allo-
cated to the other PCs with which it shares the common data.
communications cable Cable used to transfer data between components of a control system and con-
forming to the RS-232C or RS-422 standards.
comparison instruction An instruction used to compare data at different locations in memory to deter-
mine the relationship between the data.
484
Glossary
Completion Flag A flag used with a timer or counter that turns ON when the timer has timed out or
the counter has reached its set value.
condition A symbol placed on an instruction line to indicate an instruction that controls the
execution condition for the terminal instruction. Each condition is assigned a bit
in memory that determines its status. The status of the bit assigned to each
condition determines the next execution condition. Conditions correspond to
LOAD, LOAD NOT, AND, AND NOT, OR, or OR NOT instructions.
CONFIG.SYS An MS DOS file containing environment settings for a personal computer.
constant An input for an operand in which the actual numeric value is specified. Constants
can be input for certain operands in place of memory area addresses. Some op-
erands must be input as constants.
control bit A bit in a memory area that is set either through the program or via a Program-
ming Device to achieve a specific purpose, e.g., a Restart Bit is turned ON and
OFF to restart a Unit.
control data An operand that specifies how an instruction is to be executed. The control data
may specify the part of a word is to be used as the operand, it may specify the
destination for a data transfer instructions, it may specify the size of a data table
used in an instruction, etc.
control signal A signal sent from the PC to effect the operation of the controlled system.
Control System All of the hardware and software components used to control other devices. A
Control System includes the PC System, the PC programs, and all I/O devices
that are used to control or obtain feedback from the controlled system.
controlled system The devices that are being controlled by a PC System.
count pulse The signal counted by a counter.
counter A dedicated group of digits or words in memory used to count the number of
times a specific process has occurred, or a location in memory accessed
through a TIM/CNT bit and used to count the number of times the status of a bit
or an execution condition has changed from OFF to ON.
CPU See central processing unit.
CTS An acronym for clear-to-send, a signal used in communications between elec-
tronic devices to indicate that the receiver is ready to accept incoming data.
CY See Carry Flag.
cycle One unit of processing performed by the CPU, including ladder program execu-
tion, peripheral servicing, I/O refreshing, etc.
cycle time The time required to complete one cycle of CPU processing.
cyclic interrupt See scheduled interrupt.
data area An area in the PC’s memory that is designed to hold a specific type of data.
data area boundary The highest address available within a data area. When designating an operand
that requires multiple words, it is necessary to ensure that the highest address in
the data area is not exceeded.
data disk A floppy disk used to same user programs, DM area contents, comments, and
other user data.
data length In communications, the number of bits that is to be treated as one unit in data
transmissions.
485
Glossary
data link An automatic data transmission operation that allows PCs or Units within PC to
pass data back and forth via common data areas.
data link area A common data area established through a data link.
data movement instruction An instruction used to move data from one location in memory to another. The
data in the original memory location is left unchanged.
data sharing The process in which common data areas or common data words are created
between two or more PCs.
data trace A process in which changes in the contents of specific memory locations are re-
corded during program execution.
data transfer Moving data from one memory location to another, either within the same device
or between different devices connected via a communications line or network.
debug A process by which a draft program is corrected until it operates as intended.
Debugging includes both the removal of syntax errors, as well as the fine-tuning
of timing and coordination of control operations.
decimal A number system where numbers are expressed to the base 10. In a PC all data
is ultimately stored in binary form, four binary bits are often used to represent
one decimal digit, via a system called binary-coded decimal.
decrement Decreasing a numeric value, usually by 1.
default A value automatically set by the PC when the user does not specifically set
another value. Many devices will assume such default conditions upon the ap-
plication of power.
definer A number used as an operand for an instruction but that serves to define the
instruction itself, rather that the data on which the instruction is to operate. Defin-
ers include jump numbers, subroutine numbers, etc.
destination The location where an instruction places the data on which it is operating, as op-
posed to the location from which data is taken for use in the instruction. The loca-
tion from which data is taken is called the source.
differentiated instruction An instruction that is executed only once each time its execution condition goes
from OFF to ON. Non-differentiated instructions are executed for each scan as
long as the execution condition stays ON.
differentiation instruction An instruction used to ensure that the operand bit is never turned ON for more
than one scan after the execution condition goes either from OFF to ON for a
Differentiate Up instruction or from ON to OFF for a Differentiate Down instruc-
tion.
digit A unit of storage in memory that consists of four bits.
digit designator An operand that is used to designate the digit or digits of a word to be used by an
instruction.
DIN track A rail designed to fit into grooves on various devices to allow the devices to be
quickly and easily mounted to it.
DIP switch Dual in-line package switch, an array of pins in a signal package that is mounted
to a circuit board and is used to set operating parameters.
direct output A method in which program execution results are output immediately to elimi-
nate the affects of the cycle time.
distributed control A automation concept in which control of each portion of an automated system is
located near the devices actually being controlled, i.e., control is decentralized
486
Glossary
DM area A data area used to hold only word data. Words in the DM area cannot be ac-
cessed bit by bit.
downloading The process of transferring a program or data from a higher-level or host com-
puter to a lower-level or slave computer. If a Programming Device is involved,
the Programming Device is considered the host computer.
electrical noise Random variations of one or more electrical characteristics such as voltage, cur-
rent, and data, which might interfere with the normal operation of a device.
EPROM Erasable programmable read-only memory; a type of ROM in which stored data
can be erased, by ultraviolet light or other means, and reprogrammed.
error code A numeric code generated to indicate that an error exists, and something about
the nature of the error. Some error codes are generated by the system; others
are defined in the program by the operator.
Error Log Area An area used to store records indicating the time and nature of errors that have
occurred in the system.
even parity A communication setting that adjusts the number of ON bits so that it is always
even. See parity.
event processing Processing that is performed in response to an event, e.g., an interrupt signal.
exclusive NOR A logic operation whereby the result is true if both of the premises are true or both
of the premises are false. In ladder-diagram programming, the premises are
usually the ON/OFF states of bits, or the logical combination of such states,
called execution conditions.
exclusive OR A logic operation whereby the result is true if one, and only one, of the premises
is true. In ladder-diagram programming the premises are usually the ON/OFF
states of bits, or the logical combination of such states, called execution condi-
tions.
execution condition The ON or OFF status under which an instruction is executed. The execution
condition is determined by the logical combination of conditions on the same
instruction line and up to the instruction currently being executed.
execution cycle The cycle used to execute all processes required by the CPU, including program
execution, I/O refreshing, peripheral servicing, etc.
execution time The time required for the CPU to execute either an individual instruction or an
entire program.
extended counter A counter created in a program by using two or more count instructions in suc-
cession. Such a counter is capable of counting higher than any of the standard
counters provided by the individual instructions.
extended timer A timer created in a program by using two or more timers in succession. Such a
timer is capable of timing longer than any of the standard timers provided by the
individual instructions.
487
Glossary
FA Factory automation.
factory computer A general-purpose computer, usually quite similar to a business computer, that
is used in automated factory control.
FAL error An error generated from the user program by execution of an FAL(06) instruc-
tion.
FALS error An error generated from the user program by execution of an FALS(07) instruc-
tion or an error generated by the system.
fatal error An error that stops PC operation and requires correction before operation can
continue.
flag A dedicated bit in memory that is set by the system to indicate some type of oper-
ating status. Some flags, such as the carry flag, can also be set by the operator
or via the program.
flicker bit A bit that is programmed to turn ON and OFF at a specific frequency.
floating-point decimal A decimal number expressed as a number (the mantissa) multiplied by a power
of 10, e.g., 0.538 x 10–5.
force reset The process of forcibly turning OFF a bit via a programming device. Bits are usu-
ally turned OFF as a result of program execution.
force set The process of forcibly turning ON a bit via a programming device. Bits are usu-
ally turned ON as a result of program execution.
forced status The status of bits that have been force reset or force set.
frame checksum The results of exclusive ORing all data within a specified calculation range. The
frame checksum can be calculated on both the sending and receiving end of a
data transfer to confirm that data was transmitted correctly.
function code A two-digit number used to input an instruction into the PC.
hardware error An error originating in the hardware structure (electronic components) of the PC,
as opposed to a software error, which originates in software (i.e., programs).
header code A code in an instruction that specifies what the instruction is to do.
hexadecimal A number system where all numbers are expressed to the base 16. In a PC all
data is ultimately stored in binary form, however, displays and inputs on Pro-
gramming Devices are often expressed in hexadecimal to simplify operation.
Each group of four binary bits is numerically equivalent to one hexadecimal digit.
host computer A computer that is used to transfer data to or receive data from a PC in a Host
Link system. The host computer is used for data management and overall sys-
tem control. Host computers are generally small personal or business comput-
ers.
HR area A memory area that preserves bit status during power interrupts and used as
work bits in programming.
I/O bit A bit in memory used to hold I/O status. Input bits reflect the status of input termi-
nals; output bits hold the status for output terminals.
488
Glossary
I/O capacity The number of inputs and outputs that a PC is able to handle. This number
ranges from around one hundred for smaller PCs to two thousand for the largest
ones.
I/O delay The delay in time from when a signal is sent to an output to when the status of the
output is actually in effect or the delay in time from when the status of an input
changes until the signal indicating the change in the status is received.
I/O device A device connected to the I/O terminals on I/O Units. I/O devices may be either
part of the Control System, if they function to help control other devices, or they
may be part of the controlled system.
I/O point The place at which an input signal enters the PC System, or at which an output
signal leaves the PC System. In physical terms, I/O points correspond to termi-
nals or connector pins on a Unit; in terms of programming, an I/O points corre-
spond to I/O bits in the IR area.
I/O refreshing The process of updating output status sent to external devices so that it agrees
with the status of output bits held in memory and of updating input bits in memory
so that they agree with the status of inputs from external devices.
I/O response time The time required for an output signal to be sent from the PC in response to an
input signal received from an external device.
I/O Unit The Units in a PC that are physically connected to I/O devices to input and output
signals. I/O Units include Input Units and Output Units, each of which is available
in a range of specifications.
I/O word A word in the IR area that is allocated to a Unit in the PC System and is used to
hold I/O status for that Unit.
IBM PC/AT or compatible A computer that has similar architecture to, that is logically compatible with, and
that can run software designed for an IBM PC/AT computer.
indirect address An address whose contents indicates another address. The contents of the se-
cond address will be used as the actual operand.
initialization error An error that occurs either in hardware or software during the PC System start-
up, i.e., during initialization.
initialize Part of the startup process whereby some memory areas are cleared, system
setup is checked, and default values are set.
input The signal coming from an external device into the PC. The term input is often
used abstractly or collectively to refer to incoming signals.
input bit A bit in the IR area that is allocated to hold the status of an input.
input device An external device that sends signals into the PC System.
input point The point at which an input enters the PC System. Input points correspond
physically to terminals or connector pins.
input signal A change in the status of a connection entering the PC. Generally an input signal
is said to exist when, for example, a connection point goes from low to high volt-
age or from a nonconductive to a conductive state.
install The preparation necessary to use a program or software package, such as the
LSS or SSS, on a computer.
489
Glossary
instruction A direction given in the program that tells the PC of the action to be carried out,
and the data to be used in carrying out the action. Instructions can be used to
simply turn a bit ON or OFF, or they can perform much more complex actions,
such as converting and/or transferring large blocks of data.
instruction execution time The time required to execute an instruction. The execution time for any one
instruction can vary with the execution conditions for the instruction and the op-
erands used in it.
instruction line A group of conditions that lie together on the same horizontal line of a ladder dia-
gram. Instruction lines can branch apart or join together to form instruction
blocks. Also called a rung.
interface An interface is the conceptual boundary between systems or devices and usual-
ly involves changes in the way the communicated data is represented. Interface
devices perform operations like changing the coding, format, or speed of the
data.
interrupt (signal) A signal that stops normal program execution and causes a subroutine to be run
or other processing to take place.
jump A type of programming where execution moves directly from one point in a pro-
gram to another, without sequentially executing any instructions in between.
jump number A definer used with a jump that defines the points from and to which a jump is to
be made.
ladder diagram (program) A form of program arising out of relay-based control systems that uses circuit-
type diagrams to represent the logic flow of programming instructions. The ap-
pearance of the program is similar to a ladder, and thus the name.
ladder instruction An instruction that represents the conditions on a ladder-diagram program. The
other instructions in a ladder diagram fall along the right side of the diagram and
are called terminal instructions.
Ladder Support Software A software package installed on a IBM PC/AT or compatible computer to func-
tion as a Programming Device.
LED Acronym for light-emitting diode; a device used as for indicators or displays.
leftmost (bit/word) The highest numbered bits of a group of bits, generally of an entire word, or the
highest numbered words of a group of words. These bits/words are often called
most-significant bits/words.
490
Glossary
link A hardware or software connection formed between two Units. “Link” can refer
either to a part of the physical connection between two Units or a software con-
nection created to data existing at another location (i.e., data links).
load The processes of copying data either from an external device or from a storage
area to an active portion of the system such as a display buffer. Also, an output
device connected to the PC is called a load.
logic block A group of instructions that is logically related in a ladder-diagram program and
that requires logic block instructions to relate it to other instructions or logic
blocks.
logic block instruction An instruction used to locally combine the execution condition resulting from a
logic block with a current execution condition. The current execution condition
could be the result of a single condition, or of another logic block. AND Load and
OR Load are the two logic block instructions.
logic instruction Instructions used to logically combine the content of two words and output the
logical results to a specified result word. The logic instructions combine all the
same-numbered bits in the two words and output the result to the bit of the same
number in the specified result word.
main program All of a program except for subroutine and interrupt programs.
mark trace A process in which changes in the contents of specific memory locations are re-
corded during program execution.
masked bit A bit whose status has been temporarily made ineffective.
masking ‘Covering’ an interrupt signal so that the interrupt is not effective until the mask is
removed.
memory area Any of the areas in the PC used to hold data or programs.
message number A number assigned to a message generated with the MESSAGE instruction.
mnemonic code A form of a ladder-diagram program that consists of a sequential list of the
instructions without using a ladder diagram.
MONITOR mode A mode of PC operation in which normal program execution is possible, and
which allows modification of data held in memory. Used for monitoring or debug-
ging the PC.
NC input An input that is normally closed, i.e., the input signal is considered to be present
when the circuit connected to the input opens.
negative delay A delay set for a data trace in which recording data begins before the trace signal
by a specified amount.
nesting Programming one loop within another loop, programming a call to a subroutine
within another subroutine, or programming one jump within another.
NO input An input that is normally open, i.e., the input signal is considered to be present
when the circuit connected to the input closes.
491
Glossary
nonfatal error A hardware or software error that produces a warning but does not stop the PC
from operating.
normally closed condition A condition that produces an ON execution condition when the bit assigned to it
is OFF, and an OFF execution condition when the bit assigned to it is ON.
normally open condition A condition that produces an ON execution condition when the bit assigned to it
is ON, and an OFF execution condition when the bit assigned to it is OFF.
NOT A logic operation which inverts the status of the operand. For example, AND
NOT indicates an AND operation with the opposite of the actual status of the op-
erand bit.
OFF The status of an input or output when a signal is said not to be present. The OFF
state is generally represented by a low voltage or by non-conductivity, but can be
defined as the opposite of either.
OFF delay The delay between the time when a signal is switched OFF (e.g., by an input
device or PC) and the time when the signal reaches a state readable as an OFF
signal (i.e., as no signal) by a receiving party (e.g., output device or PC).
offset A positive or negative value added to a base value such as an address to specify
a desired value.
ON The status of an input or output when a signal is said to be present. The ON state
is generally represented by a high voltage or by conductivity, but can be defined
as the opposite of either.
ON delay The delay between the time when an ON signal is initiated (e.g., by an input de-
vice or PC) and the time when the signal reaches a state readable as an ON sig-
nal by a receiving party (e.g., output device or PC).
one-shot bit A bit that is turned ON or OFF for a specified interval of time which is longer than
one scan.
online edit The process of changed the program directly in the PC from a Programming De-
vice. Online editing is possible in PROGRAM or MONITOR mode. In MONITOR
mode, the program can actually be changed while it is being
operand The values designated as the data to be used for an instruction. An operand can
be input as a constant expressing the actual numeric value to be used or as an
address to express the location in memory of the data to be used.
operating modes One of three PC modes: PROGRAM mode, MONITOR mode, and RUN mode.
operating error An error that occurs during actual PC operation as opposed to an initialization
error, which occurs before actual operations can begin.
OR A logic operation whereby the result is true if either of two premises is true, or if
both are true. In ladder-diagram programming the premises are usually ON/OFF
states of bits or the logical combination of such states called execution condi-
tions.
output The signal sent from the PC to an external device. The term output is often used
abstractly or collectively to refer to outgoing signals.
492
Glossary
output bit A bit in the IR area that is allocated to hold the status to be sent to an output de-
vice.
output device An external device that receives signals from the PC System.
output point The point at which an output leaves the PC System. Output points correspond
physically to terminals or connector pins.
output signal A signal being sent to an external device. Generally an output signal is said to
exist when, for example, a connection point goes from low to high voltage or from
a nonconductive to a conductive state.
overflow The state where the capacity of a data storage location has been exceeded.
overseeing Part of the processing performed by the CPU that includes general tasks re-
quired to operate the PC.
overwrite Changing the content of a memory location so that the previous content is lost.
parity Adjustment of the number of ON bits in a word or other unit of data so that the
total is always an even number or always an odd number. Parity is generally
used to check the accuracy of data after being transmitted by confirming that the
number of ON bits is still even or still odd.
parity check Checking parity to ensure that transmitted data has not been corrupted.
PC configuration The arrangement and interconnections of the Units that are put together to form
a functional PC.
PC System With building-block PCs, all of the Units connected up to, but not including, the
I/O devices. The boundaries of a PC System are the PC and the program in its
CPU at the upper end; and the I/O Units at the lower end.
Peripheral Device Devices connected to a PC System to aid in system operation. Peripheral de-
vices include printers, programming devices, external storage media, etc.
peripheral servicing Processing signals to and from peripheral devices, including refreshing, com-
munications processing, interrupts, etc.
positive delay A delay set for a data trace in which recording data begins after the trace signal
by a specified amount.
Power Supply Unit A Unit that connected to a PC that provides power at the voltage required by the
other Units.
present value The current value registered in a device at any instant during its operation. Pres-
ent value is abbreviated as PV. The use of this term is generally restricted to tim-
ers and counters.
printed circuit board A board onto which electrical circuits are printed for mounting into a computer or
electrical device.
PROGRAM mode A mode of operation that allows inputting and debugging of programs to be car-
ried out, but that does not permit normal execution of the program.
493
Glossary
Programmable Controller A computerized device that can accept inputs from external devices and gener-
ate outputs to external devices according to a program held in memory. Pro-
grammable Controllers are used to automate control of external devices. Al-
though single-unit Programmable Controllers are available, building-block Pro-
grammable Controllers are constructed from separate components. Such Pro-
grammable Controllers are formed only when enough of these separate compo-
nents are assembled to form a functional assembly.
programmed alarm An alarm given as a result of execution of an instruction designed to generate the
alarm in the program, as opposed to one generated by the system.
programmed error An error arising as a result of the execution of an instruction designed to gener-
ate the error in the program, as opposed to one generated by the system.
Programming Device A Peripheral Device used to input a program into a PC or to alter or monitor a
program already held in the PC. There are dedicated programming devices,
such as Programming Consoles, and there are non-dedicated devices, such as
a host computer.
PROM Programmable read-only memory; a type of ROM into which the program or
data may be written after manufacture, by a customer, but which is fixed from
that time on.
prompt A message or symbol that appears on a display to request input from the opera-
tor.
protocol The parameters and procedures that are standardized to enable two devices to
communicate or to enable a programmer or operator to communicate with a de-
vice.
RAM Random access memory; a data storage media. RAM will not retain data when
power is disconnected.
read-only area A memory area from which the user can read status but to which data cannot be
written.
refresh The process of updating output status sent to external devices so that it agrees
with the status of output bits held in memory and of updating input bits in memory
so that they agree with the status of inputs from external devices.
relay-based control The forerunner of PCs. In relay-based control, groups of relays are intercon-
nected to form control circuits. In a PC, these are replaced by programmable cir-
cuits.
reserved word A word in memory that is reserved for a special purpose and cannot be accessed
by the user.
reset The process of turning a bit or signal OFF or of changing the present value of a
timer or counter to its set value or to zero.
response code A code sent with the response to a data transmission that specifies how the
transmitted data was processed.
494
Glossary
response format A format specifying the data required in a response to a data transmission.
response monitoring time The time a device will wait for a response to a data transmission before assum-
ing that an error has occurred.
result word A word used to hold the results from the execution of an instruction.
retrieve The processes of copying data either from an external device or from a storage
area to an active portion of the system such as a display buffer. Also, an output
device connected to the PC is called a load.
retry The process whereby a device will re-transmit data which has resulted in an er-
ror message from the receiving device.
return The process by which instruction execution shifts from a subroutine back to the
main program (usually the point from which the subroutine was called).
reversible counter A counter that can be both incremented and decremented depending on the
specified conditions.
reversible shift register A shift register that can shift data in either direction depending on the specified
conditions.
rightmost (bit/word) The lowest numbered bits of a group of bits, generally of an entire word, or the
lowest numbered words of a group of words. These bits/words are often called
least-significant bits/words.
rising edge The point where a signal actually changes from an OFF to an ON status.
ROM Read only memory; a type of digital storage that cannot be written to. A ROM
chip is manufactured with its program or data already stored in it and can never
be changed. However, the program or data can be read as many times as de-
sired.
rotate register A shift register in which the data moved out from one end is placed back into the
shift register at the other end.
RUN mode The operating mode used by the PC for normal control operations.
scan The process used to execute a ladder-diagram program. The program is ex-
amined sequentially from start to finish and each instruction is executed in turn
based on execution conditions.
scheduled interrupt An interrupt that is automatically generated by the system at a specific time or
program location specified by the operator. Scheduled interrupts result in the
execution of specific subroutines that can be used for instructions that must be
executed repeatedly at a specified interval of time.
self diagnosis A process whereby the system checks its own operation and generates a warn-
ing or error if an abnormality is discovered.
495
Glossary
self-maintaining bit A bit that is programmed to maintain either an OFF or ON status until set or reset
by specified conditions.
servicing The process whereby the PC checks a connector or Unit to see if special proces-
sing is required.
set value The value from which a decrementing counter starts counting down or to which
an incrementing counter counts up (i.e., the maximum count), or the time from
which or for which a timer starts timing. Set value is abbreviated SV.
shift input signal An input signal whose OFF to ON transition causes data to be shifted one bit.
shift register One or more words in which data is shifted a specified number of units to the right
or left in bit, digit, or word units. In a rotate register, data shifted out one end is
shifted back into the other end. In other shift registers, new data (either specified
data, zero(s) or one(s)) is shifted into one end and the data shifted out at the oth-
er end is lost.
signed binary A binary value that is stored in memory along with a bit that indicates whether the
value is positive or negative.
software protect A means of protecting data from being changed that uses software as opposed
to a physical switch or other hardware setting.
source (word) The location from which data is taken for use in an instruction, as opposed to the
location to which the result of an instruction is to be written. The latter is called
the destination.
special instruction An instruction input with a function code that handles data processing opera-
tions within ladder diagrams, as opposed to a basic instruction, which makes up
the fundamental portion of a ladder diagram.
SR area A memory area containing flags and other bits/words with specific functions.
store The process of recording a program written into a display buffer permanently in
memory.
subroutine A group of instructions placed separate from the main program and executed
only when called from the main program or activated by an interrupt.
subroutine number A definer used to identify the subroutine that a subroutine call or interrupt acti-
vates.
subtract count input An input signal used to decrement a counter when the signal changes from OFF
to ON.
switching capacity The maximum voltage/current that a relay can safely switch on and off.
synchronous execution Execution of programs and servicing operations in which program execution
and servicing are synchronized so that all servicing operations are executed
each time the programs are executed.
496
Glossary
syntax error An error in the way in which a program is written. Syntax errors can include
‘spelling’ mistakes (i.e., a function code that does not exist), mistakes in specify-
ing operands within acceptable parameters (e.g., specifying read-only bits as a
destination), and mistakes in actual application of instructions (e.g., a call to a
subroutine that does not exist).
SYSMAC Support Software A software package installed on a IBM PC/AT or compatible computer to func-
tion as a Programming Device.
system configuration The arrangement in which Units in a System are connected. This term refers to
the conceptual arrangement and wiring together of all the devices needed to
comprise the System.
system error An error generated by the system, as opposed to one resulting from execution of
an instruction designed to generate an error.
system error message An error message generated by the system, as opposed to one resulting from
execution of an instruction designed to generate a message.
system setup Operating environment settings for a Programming Device, e.g., the LSS or
SSS.
terminal instruction An instruction placed on the right side of a ladder diagram that uses the final
execution conditions of an instruction line.
timer A location in memory accessed through a TIM/CNT bit and used to time down
from the timer’s set value. Timers are turned ON and reset according to their
execution conditions.
TR area A data area used to store execution conditions so that they can be reloaded later
for use with other instructions.
trace An operation whereby the program is executed and the resulting data is stored to
enable step-by-step analysis and debugging.
trace memory A memory area used to store the results of trace operations.
transfer The process of moving data from one location to another within the PC, or be-
tween the PC and external devices. When data is transferred, generally a copy
of the data is sent to the destination, i.e., the content of the source of the transfer
is not changed.
trigger A signal used to activate some process, e.g., the execution of a trace operation.
trigger address An address in the program that defines the beginning point for tracing. The actu-
al beginning point can be altered from the trigger by defining either a positive or
negative delay.
UM area The memory area used to hold the active program, i.e., the program that is being
currently executed.
Unit In OMRON PC terminology, the word Unit is capitalized to indicate any product
sold for a PC System. Most of the names of these products end with the word
Unit.
unit number A number assigned to some Units to facilitate identification when assigning
words or other operating parameters.
497
Glossary
unsigned binary A binary value that is stored in memory without any indication of whether it is
positive or negative.
uploading The process of transferring a program or data from a lower-level or slave com-
puter to a higher-level or host computer. If a Programming Devices is involved,
the Programming Device is considered the host computer.
watchdog timer A timer within the system that ensures that the scan time stays within specified
limits. When limits are reached, either warnings are given or PC operation is
stopped depending on the particular limit that is reached.
word A unit of data storage in memory that consists of 16 bits. All data areas consists
of words. Some data areas can be accessed only by words; others, by either
words or bits.
word address The location in memory where a word of data is stored. A word address must
specify (sometimes by default) the data area and the number of the word that is
being addressed.
work word A word that can be used for data calculation or other manipulation in program-
ming, i.e., a ‘work space’ in memory. A large portion of the IR area is always re-
served for work words. Parts of other areas not required for special purposes
may also be used as work words.
write protect switch A switch used to write-protect the contents of a storage device, e.g., a floppy
disk. If the hole on the upper left of a floppy disk is open, the information on this
floppy disk cannot be altered.
write-protect A state in which the contents of a storage device can be read but cannot be al-
tered.
498
Index
499
Index
500
Index
501
Index
502
Index
M NEGL(––), 113
nesting, subroutines, 314
macro function, subroutines. See programming
no protocol communications
masking program example, 111
CPM1/CPM1A interrupt processes, 405 SRM1, 107
CQM1 interrupt processes, 388 transmission data configuration, 110
SRM1 interrupt processes, 416 transmission flags, 110
MBS(––), 113 normally open/closed condition, definition, 153
MBSL(––), 113 NOT, definition, 153
memory areas NT Link (CPM1/CPM1A), 103
AR area bits (CPM1/CPM1A), 142, 462
NT Link (SRM1), 106
AR area bits (CQM1), 138, 455
AR area bits (SRM1), 145, 466
DM area (CPM1/CPM1A), 142
DM area (CQM1), 139 O
DM area (SRM1), 145
flag bits (CPM1/CPM1A), 141, 460 one-to-one link communications
flag bits (CQM1), 137, 452 I/O response timing
flag bits (SRM1), 144, 465 CPM1/CPM1A, 403
HR area (CPM1/CPM1A), 142 CQM1, 386
HR area (CQM1), 137 SRM1, 414
HR area (SRM1), 145 link errors (CQM1), 101
IR area bits (CPM1/CPM1A), 140 one-to-one link (CPM1/CPM1A), 101
IR area bits (CQM1), 135
IR area bits (SRM1), 144 one-to-one link (CQM1), 100
link bits (CPM1/CPM1A), 142 one-to-one link (SRM1), 104
link bits (CQM1), 138
link bits (SRM1), 145 operand bit, 154
structure (CPM1/CPM1A), 139, 459 operands, 184
structure (CQM1), 134, 451 allowable designations, 184
structure (SRM1), 143, 464 requirements, 184
503
Index
operations PV
CPM1/CPM1A internal processing, flowchart, 400 CNTR(12), 211
CQM1 internal processing, flowchart, 382 timers and counters, 209
effects on CPM1/CPM1A cycle time, 401
effects on CQM1 cycle time, 384
effects on SRM1 cycle time, 412
SRM1 internal processing, flowchart, 411
Q–R
output bit quick-response inputs (CPM1/CPM1A), 131
controlling ON/OFF time, 198 RET(93), 38
controlling status, 173, 175
right-hand instructions, coding. See instructions
output refresh method, PC Setup settings, 21
RS-232C
outputs, turning OFF, 428 communications
one-to-one link (CQM1), 100
procedures (CQM1/SRM1), 98
receiving (CQM1), 99
P transmitting (SRM1), 98
connecting Units (CQM1), 100
PC Setup. See settings control bits (CQM1), 99
PC Setup settings selecting (CQM1). See host link
CPM1/CPM1A, 9 RS-232C port, servicing time (CQM1/SRM1), 18
CQM1, 4
RS-232C port servicing time, PC Setup settings, 18
SRM1, 13
RXD(47), 110
peripheral port, servicing time, 18
peripheral port servicing time, PC Setup settings, 18
PLS2(––), 22, 25, 26, 29 S
PMW(––), 32 SBBL(––), 113
precautions, general, xiii SBN(92), 67
Program Memory, structure, 154 settings
program write protection, PC Setup settings, 17 basic operations
error log, 21
programming high-speed timers, 20
absolute high–speed counters (CQM1), 63 hold bit status, 17
errors, 425 input digits number, 21
high–speed counter (CPM1/CPM1A), 80 startup mode, 16
high–speed counter (CQM1), 50 changing, 3
instructions, 441 communications, 87, 88
interrupts, 80 conditions (CQM1), 90
interrupts (CQM1), 50, 63 CQM1 PC Setup, 88
jumps, 172 host link (CPM1/CPM1A), 93
macro function, subroutines, 128 host link (CQM1), 91
precautions, 177 host link (SRM1), 95
preparing data in data areas, 234 RS-232C (CQM1/SRM1), 98
special features, 116 defaults, 3
writing, 152 expansion instructions, 117
I/O operations, 16
programming (CQM1)
port servicing scan time, 18
high–speed counters 1 and 2, 57
pulse output word, 23, 26, 32
interrupts, 57
interrupts, 38
programs external sources (CQM1), 39
checking, check levels, 425 parameters (CQM1), 40
executing, 179 pulse outputs (CQM1 only), 22
PRV(62), 34, 65 seven-segment displays, converting data, 259
PULS(65), 23, 26, 27, 36 signed binary data, 111
pulse outputs SPED(64), 23, 25, 26, 27, 28, 36
determining status of ports 1 and 2, 34 startup mode, PC Setup settings, 16
from an output point, 23
from ports 1 and 2, 25 STIM(69), 45
variable-duty-ratio, 32 subroutine number, 315
504
Index
505
Revision History
A manual revision code appears as a suffix to the catalog number on the front cover of the manual.
The following table outlines the changes made to the manual during each revision. Page numbers refer to the
previous version.
507
Revision History
508
Authorized Distributor:
Cat. No. W228-E1-7 Note: Specifications subject to change without notice. Printed in Japan