Omron CP - PROGRAMMING MANUAL 05-2007 Programming Manual

Omron CP - PROGRAMMING MANUAL 05-2007 Programming Manual

Cp1h/cp1l cpu unit
Table of Contents

Advertisement

Cat. No. W451-E1-03
SYSMAC CP Series
CP1H-X40D@-@, CP1H-XA40D@-@,
CP1H-Y20DT-D
CP1L-L14D@-@, CP1L-L20D@-@,
CP1L-M30D@-@, CP1L-M40D@-@
CP1H/CP1L CPU Unit
PROGRAMMING MANUAL

Advertisement

Table of Contents
loading

Summary of Contents for Omron CP - PROGRAMMING MANUAL 05-2007

  • Page 1 Cat. No. W451-E1-03 SYSMAC CP Series CP1H-X40D@-@, CP1H-XA40D@-@, CP1H-Y20DT-D CP1L-L14D@-@, CP1L-L20D@-@, CP1L-M30D@-@, CP1L-M40D@-@ CP1H/CP1L CPU Unit PROGRAMMING MANUAL...
  • Page 2 SYSMAC CP Series CP1H-X40D@-@, CP1H-XA40D@-@, CP1H-Y20DT-D CP1H CPU Units CP1L-L14D@-@, CP1L-L20D@-@, CP1L-M30D@-@, CP1L-M40D@-@ CP1L CPU Units Programming Manual Revised May 2007...
  • Page 4 1. Indicates lists of one sort or another, such as procedures, checklists, etc. OMRON, 2005 All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, mechanical, electronic, photocopying, recording, or otherwise, without the prior written permission of OMRON.
  • Page 5 Unit upgrades. Notation of Unit Versions The unit version is given to the right of the lot number on the nameplate of the on Products products for which unit versions are being managed, as shown below.
  • Page 6 Procedure When the Device Type and CPU Type Are Known 1,2,3... 1. If you know the device type and CPU type, select them in the Change PLC Dialog Box, go online, and select PLC - Edit - Information from the menus.
  • Page 7 2. Click the Settings Button and, when the Device Type Settings Dialog Box is displayed, select the CPU type. Example for CP1H Example for CP1L viii...
  • Page 8 3. Go online and select PLC - Edit - Information The PLC Information Dialog Box will be displayed. Example for the CP1H Unit version...
  • Page 9 If you don't know the device type and CPU type but are connected directly to the CPU Unit on a serial line, select PLC - Auto Online to go online, and then select PLC - Edit - Information from the menus.
  • Page 10 Unit version ■ Unit Manufacturing Information (CP1H CPU Units Only) 1,2,3... 1. In the IO Table Window, right-click and select Unit Manufacturing infor- mation - CPU Unit.
  • Page 11 2. The following Unit Manufacturing information Dialog Box will be displayed. Unit version Use the above display to confirm the unit version of the CPU Unit connected online. Using the Unit Version The following unit version labels are provided with the CPU Unit.
  • Page 12: Table Of Contents

    3-15 Double-precision Floating-point Instructions ........
  • Page 13 3-20 High-speed Counter/Pulse Output Instructions ........
  • Page 14: About This Manual

    The CP Series is centered around the CP1H and CP1L CPU Units and is designed with the same basic architecture as the CS and CJ Series. The Special I/O Units and CPU Bus Units of the CJ Series can thus be used with the CP1H CPU Units. CJ-series Basic I/O Units, however, cannot be used.
  • Page 15 Section 3 describes each of the instructions that can be used in programming CP-series PLCs. Instructions are described in order of function. Section 4 lists the execution times and number of steps for all instructions supported by the CP1H PLCs, and describes the execution times for function block instances.
  • Page 16: Related Manuals

    Related Manuals The following manuals are used for the CP-series CPU Units. Refer to these manuals as required. Cat. No. Model numbers Manual name Description W451 CP1H-X40D@-@ SYSMAC CP Series Provides the following information on the CP Series: CP1H-XA40D@-@ CP1H and CP1L CPU •...
  • Page 17 Provides operating procedures for creating protocol tion Manual macros (i.e., communications sequences) with the CX-Protocol and other information on protocol mac- ros. The CX-Protocol is required to create protocol mac- ros for user-specific serial communications or to customize the standard system protocols. xviii...
  • Page 18 WHETHER SUCH CLAIM IS BASED ON CONTRACT, WARRANTY, NEGLIGENCE, OR STRICT LIABILITY. In no event shall the responsibility of OMRON for any act exceed the individual price of the product on which liability is asserted. IN NO EVENT SHALL OMRON BE RESPONSIBLE FOR WARRANTY, REPAIR, OR OTHER CLAIMS...
  • Page 19 The following are some examples of applications for which particular attention must be given. This is not intended to be an exhaustive list of all possible uses of the products, nor is it intended to imply that the uses listed may be suitable for the products: •...
  • Page 20 PERFORMANCE DATA Performance data given in this manual is provided as a guide for the user in determining suitability and does not constitute a warranty. It may represent the result of OMRON's test conditions, and the users must correlate it to actual application requirements.
  • Page 21 xxii...
  • Page 22 Conformance to EC Directives ........
  • Page 23: Intended Audience

    !WARNING It is extremely important that a PLC and all PLC Units be used for the speci- fied purpose and under the specified conditions, especially in applications that can directly or indirectly affect human life. You must consult with your OMRON representative before applying a PLC System to the above-mentioned appli- cations.
  • Page 24 As a countermeasure for such errors, external safety measures must be provided to ensure safety in the system. • The PLC or outputs may remain ON or OFF due to deposits on or burning of the output relays, or destruction of the output transistors. As a counter- measure for such problems, external safety measures must be provided to ensure safety in the system.
  • Page 25: Operating Environment Precautions

    !Caution The CP-series CPU Units automatically back up the user program and param- eter data to flash memory when these are written to the CPU Unit. I/O mem- ory (including the DM Area, Counter present values and Completion Flags, and HR Area), however, is not written to flash memory.
  • Page 26: Application Precautions

    • Connecting or disconnecting the connectors !Caution Failure to abide by the following precautions could lead to faulty operation of the PLC or the system, or could damage the PLC or PLC Units. Always heed these precautions. • Install external breakers and take other safety measures against short-cir- cuiting in external wiring.
  • Page 27 Doing either of these may break the cables. • Do not place objects on top of the cables. Doing so may break the cables. • When replacing parts, be sure to confirm that the rating of a new part is correct.
  • Page 28 • If the I/O Hold Bit is turned ON, the outputs from the PLC will not be turned OFF and will maintain their previous status when the PLC is switched from RUN or MONITOR mode to PROGRAM mode.
  • Page 29: Conformance To Ec Directives

    EMC Directives OMRON devices that comply with EC Directives also conform to the related EMC standards so that they can be more easily built into other devices or the overall machine. The actual products have been checked for conformity to EMC standards (see the following note).
  • Page 30: Relay Output Noise Reduction Methods

    The CP1H/CP1L PLCs conforms to the Common Emission Standards (EN61131-2) of the EMC Directives. However, noise generated by relay out- put switching may not satisfy these Standards. In such a case, a noise filter must be connected to the load side or other appropriate countermeasures must be provided external to the PLC.
  • Page 31: Conditions For Meeting Emc Directives When Using Cp1, Cp-Series, Or Cpm1A Relay Expansion I/O Units

    100 to 200 V, insert the varistor between the con- tacts. When switching a load with a high inrush current such as an incandescent lamp, suppress the inrush current as shown below. Countermeasure 1 Countermeasure 2...
  • Page 32 Conformance to EC Directives Recommended Connection Method 1,2,3... 1. Cable Connection Method 2. Connection Method As shown below, connect a ferrite core to each end of the CP1W-CN811 I/O Connecting Cable. SYSMAC CP1H AC100-240V L2/N BATTERY POWER PERIPHERAL ERR/ALM BKUP...
  • Page 33 Conformance to EC Directives xxxiv...
  • Page 34: Programming Concepts

    Programs and Tasks ........
  • Page 35: Programming Concepts

    I/O refreshing In the above example, programming would be executed in the following order: start of A, B, remainder of A, C, and then D. This assumes that the interrupt condition for interrupt task 100 was established during execution of program A.
  • Page 36 I/O refreshing I/O refreshing A task that has been executed will be executed in subsequent cycles, and a task that is on standby will remain on standby in subsequent cycles unless it is executed again from another task. Note Unlike earlier programs that can be compared to reading a scroll, tasks can be compared to reading through a series of individual cards.
  • Page 37: Basic Information On Instructions

    (destinations) Memory Power Flow The power flow is the execution condition that is used to control the execute and instructions when programs are executing normally. In a ladder program, power flow represents the status of the execution condition. Input Instructions •...
  • Page 38 An instruction may become not be executed or may act differently depending on instruction conditions. Instruction conditions are reset (canceled) at the start of each task, i.e., they are reset when the task changes. The following instructions are used in pairs to set and cancel certain instruc- tion conditions.
  • Page 39: Instruction Location And Execution Conditions

    Manual for details on these block programs. (2) If an instruction requiring an execution condition is connected directly to the left bus bar without a logical start instruction, a program error will oc- cur when checking the program on a CX-Programmer.
  • Page 40: Addressing I/O Memory Areas

    Bit number (00 to 15) Word address (Leading zeros are omitted.) Example: The address of bit 03 in word 0001 in the CIO Area would be as shown below. This address is given as “CIO 1.03” in this manual. 1.03...
  • Page 41: Specifying Instruction Operands

    Section 1-1 Programming Concepts Example: The address of word W5 (bits 00 to 15) in the Work Area is given as shown below. Word address Example: The address of word D200 (bits 00 to 15) in the DM Area is given as shown below.
  • Page 42 0 1 0 0 BCD Mode the word address in Data Memory (DM). Add *D200 BCD: 100 an asterisk (*) at the front to specify an indirect address in BCD Mode. Specifies D100. *D@@@@@ Add an asterisk (*). 00000 to 9999...
  • Page 43 DR offset The bit or word with the PLC memory DR0 ,IR0 DR0,IR0 an indirect address in IR@ + the contents of DR@ is address specified. using a reg- Loads the bit with the PLC memory Specify DR@ ,IR@. DR (data register) ister address in IR0 + the value in DR0.
  • Page 44 –32768 to +(400) +32767 D200 D300 Unsigned deci- & &0 to &65535 CMP(020) D400 &999 All BCD data or a #0000 to #9999 B(414) limited range of D500 BCD data #2000 D600 32-bit con- All binary data or Unsigned binary...
  • Page 45 + 1 if there is D202 an even number of characters. ASCII characters that can be used in a text string includes alphanumeric characters, Katakana and sym- bols (except for special characters). The characters are shown in the following table. ASCII Characters...
  • Page 46: Data Formats

    Section 1-1 Programming Concepts 1-1-6 Data Formats The following table shows the data formats that the CP Series can handle. Data type Data format Decimal 4-digit hexadecimal Unsigned 0 to 0000 to FFFF 15 14 13 12 11 10 9...
  • Page 47 In signed binary data, the leftmost bit indicates the sign of binary 16-bit data. The value is expressed in 4-digit hexadecimal. Positive Numbers: A value is positive or 0 if the leftmost bit is 0 (OFF). In 4- digit hexadecimal, this is expressed as 0000 to 7FFF hex.
  • Page 48 4-digit hexadecimal. The two’s complement b hex of a hex is FFFF hex – a hex + 0001 hex = b hex. To determine the two’s complement b hex of “a hex,” use b hex = 10000 hex –...
  • Page 49 Programming Concepts Signed BCD Data Signed BCD data is a special data format that is used to express negative numbers in BCD. Although this format is found in applications, it is not strictly defined and depends on the specific application. The CP Series supports the...
  • Page 50: Instruction Variations

    Input instructions that create logical starts and intermediate instructions read bit status, make comparisons, test bits, or perform other types of processing every cycle. If the results are ON, power flow is output (i.e., the execution con- dition is turned ON).
  • Page 51 (power flow) when results switch from ON to OFF. The execution con- dition will turn OFF the next cycle.
  • Page 52: I/O Instruction Timing

    Differentiated Instructions • A differentiated instruction has an internal flag that tells whether the previ- ous value is ON or OFF. At the start of operation, the previous value flags for upwardly differentiated instruction (DIFU and @ instructions) are set to ON and the previous value flags for downwardly differentiated instructions (DIFD and % instructions) are set to OFF.
  • Page 53: 1-1-10 Refresh Timing

    Note (a) Do not use the Always ON Flag or A200.11 (First Cycle Flag) as the input bit for an upwardly differentiated instruction. The instruc- tion will never be executed.
  • Page 54 I/O will be refreshed as shown below when an instruction is executing if an Variation (!) real I/O bit in the built-in I/O of the CPU Unit is specified as an operand. • When a bit operand is specified for an instruction, I/O will be refreshed for the 16 bits of the word containing the bit.
  • Page 55: 1-1-11 Program Capacity

    CJ-series CPU Bus Units in the CIO and DM Areas, as well as data link data and other data specific to the CPU Bus Units. The unit number of the CPU Bus Unit is specified when DLNK(226) is exe- cuted to refresh all of the following data at the same time.
  • Page 56 Programming that requires power flow from right to left cannot be used. Thus, flow is different from when circuits are made up of hard-wired control relays. For example, when the circuit “a” is imple-...
  • Page 57 In circuit “b,” contact E included cannot be written in a ladder diagram. The program must be rewritten. 2. There is no limit to the number of I/O bits, work bits, timers, and other input bits that can be used. Rungs, however, should be kept as clear and simple as possible even if it means using more input bits to make them easier to understand and maintain.
  • Page 58 1. A ladder program must be closed so that signals (power flow) will flow from the left bus bar to the right bus bar. A rung error will occur if the program is not closed (but the program can be executed).
  • Page 59 Instructions in a ladder program are executed in order from the top rung in a single cycle, so the result of output instruction in the lower rungs will be ultimately reflected in the output bit and the results of any pre- vious instructions controlling the same bit will be overwritten and not out- put.
  • Page 60: 1-1-13 Inputting Mnemonics

    Create a single rung consisting of two instruction blocks using an AND LD instruction to AND the blocks or by using an OR LD instruction to OR the blocks. The following example shows a complex rung that will be used to explain the procedure for inputting mnemonics (rung summary and order).
  • Page 61: 1-1-14 Program Examples

    Section 1-1 Programming Concepts 2. Program the blocks from top to bottom and then from left to right. 0.00 0.01 10.00 10.01 LD 0.00 LD 10.00 AND 0.01 AND 10.01 OR LD 5.00 0.04 0.05 LD 0.04 OR 5.00 AND 0.05 0.06...
  • Page 62 0.04 AND LD A block 102.01 B block • Separate the rung into A and B blocks, and program each individually. • Connect A and B blocks with an AND LD. • Program A block. Instruction Operands LD NOT 0.00 B1 block 0.01...
  • Page 63 Section 1-1 Programming Concepts • Repeat for as many A to n blocks as are present. 5.00 A block B block C block n block Complex Rungs 0.00 0.01 Instruction Operand 0.00 0.01 102.04 0.00 0.02 0.03 0.01 0.02 0.03 0.02...
  • Page 64 OR and OL LD Instructions Caution or Rewriting With an OR or OR NOT instruction, an OR is taken with the results of the lad- der logic from the LD or LD NOT instruction to the OR or OR NOT instruction, so the rungs can be rewritten so that the OR LD instruction is not required.
  • Page 65 CIO 102.10 can be turned ON for one cycle. Rungs Requiring Rewriting PLCs execute instructions in the order the mnemonics are entered so the sig- nal flow (power flow) is from left to right in the ladder diagram. Power flows from right to left cannot be programmed. 0.00 0.03 102.11...
  • Page 66: Precautions

    A is not executed. Condition Flag Example: = Instruction B If the Condition Flag is connected directly to the left bus bar, instruction B will be executed based on the execution results of a previous rung if instruction A is not executed. Note Condition Flags are used by all instruction within a single program (task) but they are cleared when the task switches.
  • Page 67 Reflects instruction B execution results. Condition Flag Example: = Make sure each of the results is picked up once by an OUTPUT instruction to ensure that execution results for instruction B will be not be picked up. Instruction A Reflects instruction A execution results.
  • Page 68 #300 D300 The Equals Flag will turn ON if D100 in the rung above contains #10. #200 will be moved to D200 for instruction (1), but then the Equals Flag will be turned OFF because the #200 source data is not 0000 hex. The MOV instruction at (2) will then be executed and #300 will be moved to D300.
  • Page 69 The CP1H CPU Units support instructions to save and load the Condition Flag status (CCS(282) and CCL(283)). These can be used to access the sta- tus of the Condition Flags at other locations in a task or in a different task.
  • Page 70 ER Flag turns ON. When the ER Flag is ON, the status of other Condition Flags, such as the <, >, OF, and UF Flags, will not change and status of the = and N Flags will vary from instruction to instruction.
  • Page 71: Special Program Sections

    Work Area, and thus for the following instruction, W500 to W511 will be transferred to D0 to D11 and the present values for T0 to T7 will be transferred to D12 to D19.
  • Page 72 (Therefore, a subrou- tine cannot be placed in a step ladder, block program, FOR - NEXT, or JMP0 - JME0 section.) If a program other than a subroutine program is placed after a subroutine program (SBN to RET), that program will not be executed.
  • Page 73 BLOCK PROGRAM PAUSE and RESTART Note (1) A step ladder program section can be used in an interlock section (be- tween IL and ILC). The step ladder section will be completely reset when the interlock is ON. (2) A step ladder program section can be used between MULTIPLE JUMP (JMP0) and MULTIPLE JUMP END (JME0).
  • Page 74: Checking Programs

    (1) Block programs can be used in a step ladder program section. (2) A block program can be used in an interlock section (between IL and ILC). The block program section will not be executed when the interlock is ON.
  • Page 75: Program Checks With The Cx-Programmer

    Refer to individual instruction descriptions for details. When the program is checked on the CX-Programmer, the operator can spec- ify program check levels A, B, and C (in order of the seriousness of the error), as well as a custom check level.
  • Page 76: Program Execution Check

    Here, data required at the beginning of instruction processing was checked and as a result, the instruction was not executed, the ER Flag (Error Flag) will be turned ON and the EQ and N Flags may be retained or turned OFF depending upon the instruction.
  • Page 77: Other Errors

    CX-Programmer. In the rare even that this error does occur, it will be treated as a program error, operation will stop (fatal error), and the Illegal Instruction Flag (A295.14) will turn ON.
  • Page 78: Checking Fatal Errors

    A298/A299. Note If the Error Flag or Access Error Flag turns ON, it will be treated as a program error and it can be used to stop the CPU from running. Specify operation for program errors in the PLC Setup.
  • Page 79: Introducing Function Blocks

    ST program. Registered variables can also be entered in ladder programs after they have been registered in the variable table. • A single function block can be converted to a library function as a single file, making it easy to reuse function blocks for standard processing.
  • Page 80: Function Block Specifications

    Microsoft Windows 95, 98, 98SE, Me, 2000, XP, or NT 4.0 (with service pack 6 or higher) Memory 64 Mbytes min. with Windows 98, 98SE, or NT 4.0 (with service pack 6 or higher) Refer to the CX-Programmer Ver. 7.0 Operation Manual (W437) for details.
  • Page 81: Files Created With Cx-Programmer

    Function Block Library A function block definition created in a project with CX-Programmer can be Files (*.cxf) saved as a file (1 definition = 1 file), enabling definitions to be loaded into other programs and reused. Note When function blocks are nested, all of the nested (destination) function block definitions are included in this function block library file (.cxf).
  • Page 82 Tasks and Programs ........
  • Page 83: Programming With Tasks

    Overview CP-series CPU Unit control operations can be divided by functions, controlled devices, processes, developers, or any other criteria and each operation can be programmed in a separate unit called a “task.” Using tasks provides the fol- lowing advantages: 1,2,3...
  • Page 84 (Cards are activated or deactivated by task con- trol instructions.) • A card that is activated will remain activated and will be read in subse- quent sequences. A card that is deactivated will remain deactivated and...
  • Page 85: Tasks And Programs

    • Cyclic tasks • Interrupt tasks Each program allocated to a task is executed independently and must end with an END(001) instruction. I/O refreshing will be executed only after all task programs in a cycle have been executed. Program A...
  • Page 86: Basic Cpu Unit Operation

    Programming with Tasks 2-1-3 Basic CPU Unit Operation The CPU Unit will execute cyclic tasks starting at the task with the lowest number. It will also interrupt cyclic task execution to execute an interrupt task if an interrupt occurs. Cyclic task 0...
  • Page 87: Types Of Tasks

    Interrupt tasks can also be executed as extra cyclic tasks. Cyclic Tasks A cyclic task that is READY will be executed once each cycle (from the top of the program until the END(001) instruction) in numerical order starting at the task with the lowest number.
  • Page 88 Section 2-1 Programming with Tasks Input Interrupts (Direct An interrupt task can be executed each time one of the built-in inputs on the Mode and Counter Mode) CPU Unit turns ON or OFF (Direct Mode) or when a specified number of inputs has been counted (Count Mode).
  • Page 89: Task Execution Conditions And Settings

    PROGRAM mode. READY Status A task attribute can be set to control when the task will go to READY status. The attribute can be set to either activate the task using the TASK ON instruc-...
  • Page 90: Status Transitions

    • Running: The task is in READY or RUN status. (There is no way to tell the difference between these.) • Stopped: The task is in INI or WAIT status. (There is no way to tell the dif- ference between these.)
  • Page 91: Using Tasks

    A cyclic task that is in READY status will maintain that status in subsequent cycles, and a cyclic task that is in Standby status will maintain that status in subsequent cycles. The TASK ON and TASK OFF instructions can be used only within cyclic...
  • Page 92 Using Tasks Note At least one cyclic task must be in READY status in each cycle. If there is not cyclic task in READY status, the Task Error Flag (A295.12) will turn ON, and the CPU Unit will stop running.
  • Page 93 Standby status. Cyclic Task Numbers If task m turns ON task n and m > n, task n will go to READY status the next and the Execution cycle. Cycle (Including Extra...
  • Page 94: Task Instruction Limitations

    Section 2-2 Using Tasks • Other words and bits in I/O Memory are shared by all tasks. CIO 10.00 for example is the same bit for both cyclic task 1 and cyclic task 2. Therefore, be very careful in programming any time I/O memory areas other than the IR and DR Areas are used because values changed with one task will be used by other tasks.
  • Page 95: Flags Related To Tasks

    Cyclic Tasks cyclic tasks. Task Flags A Task Flag is turned ON when a cyclic task in READY status and is turned (TK00 to TK31) OFF when the task is in Disabled (INI) or in Standby (WAIT) status. Task num- bers 00 to 31 correspond to Task Flags TK00 to TK31.
  • Page 96 Flag (A200.15) will also not turn ON if a cyclic task is shifted from Dis- abled to RUN status or if it is put in Standby status by another task through the TKOF(821) instruction before the right to execute actually is obtained.
  • Page 97 Section 2-2 Using Tasks Task Number when The type of task and the current task number when a task stops execution Program Stopped (A294) due to a program error will be stored as follows: Type A294 Cyclic task 0000 to 001F hex (correspond to task numbers 0 to 31)
  • Page 98: Examples Of Tasks

    2-2-4 Examples of Tasks An overall control task that is set to go to READY status at the start of opera- tion is generally used to control READY/Standby status for all other cyclic tasks (including extra cyclic tasks). Of course, any cyclic task can control the READY/Standby status of any other cyclic task as required by the application.
  • Page 99: Designing Tasks

    6. A task in READY status will be executed in subsequent cycles as long as the task itself or another task does not shift it to Standby status. Be sure to insert a TKOF(821) (TASK OFF) instruction for other tasks if processing is to be branched between tasks.
  • Page 100 I/O memory used only for individual tasks by task. Relationship of Tasks to Up to 128 block programs can be created in the tasks. This is the total number Block Programs for all tasks. The execution of each entire block program is controlled from the ladder diagram, but the instructions within the block program are written using mnemonics.
  • Page 101: Global Subroutine

    (including extra cyclic tasks). GSBS(750) is used to call a global subroutine. The subroutine number must be between 0 and 255. The global subroutine is defined at the end of interrupt task number 0 (just before END(001)) between GSBN(751) and GRET(752) instructions.
  • Page 102 To enable input interrupts, execute the SET INTERRUPT MASK instruction (MSKS(690)) in a cyclic task for the interrupt number. Using inputs as interrupt inputs must be enabled in advance in the PLC Setup. Note Do not enable unneeded input interrupt tasks. If the interrupt input is triggered by noise and there isn’t a corresponding interrupt task, a fatal error (task...
  • Page 103 Interrupt input number task number CIO 0.00 CIO 0.01 CIO 1.00 CIO 1.01 CIO 1.02 CIO 1.03 • CP1L M and L (20 I/O-point) CPU Units Interrupt Input interrupt Interrupt input number task number CIO 0.04 CIO 0.05 CIO 0.06 CIO 0.07...
  • Page 104 Match High-speed Counter interrupt task 10 Scheduled Interrupt Scheduled interrupt tasks are disabled in the default PLC Setup at the start of Task: Task 2 cyclic task execution. Perform the following steps to enable scheduled inter- rupt tasks.
  • Page 105: External Interrupt

    Tasks: Tasks 0 to 255 cessing is performed at the CPU Unit in PLCs containing CJ-series Special I/O Units or CPU Bus Units. Settings don’t have to be made in the CPU Unit. The specified interrupt task must be programmed in the CPU Unit.
  • Page 106: Interrupt Task Flags And Words

    Mode), High-speed interrupt tasks, External interrupt tasks, Scheduled inter- rupt task. If more than one of the same type of interrupt occurs at the same time, the one with the lower task number will be executed first. Keep in mind that the above order of execution means that time may be...
  • Page 107: Application Precautions

    Special I/O Unit, be sure to turn OFF cyclic refresh for the Special I/O Unit (using the unit number) in the PLC Setup. A interrupt task error will occur if you try to refresh a Special I/O Unit with an IORF(097) instruction from an interrupt task while the Unit is also being refreshed by cyclic I/O refresh or by I/O refresh instructions (IORF(097) or immediate refresh instructions (!)).
  • Page 108: Cx-Programmer Operations For Tasks

    2. Click the General Tab, and select the Task Type and Task No. For a cyclic task, select the Operation start Option to start the task at startup if re-...
  • Page 109 Section 2-4 CX-Programmer Operations for Tasks...
  • Page 110: Instructions

    Sequence Output Instructions ........
  • Page 111 Timer and Counter Instructions........3-5-1 TIMER: TIM/TIMX(550) .
  • Page 112 3-10 Symbol Math Instructions ........
  • Page 113 3-10-26 DOUBLE UNSIGNED BINARY DIVIDE: /UL(433)... 3-10-27 BCD DIVIDE: /B(434)........
  • Page 114 3-14-12 COSINE: COS(461) ........
  • Page 115 3-15-21 Double-precision Floating-point Input Instructions ... . . 3-16 Table Data Processing Instructions ....... . .
  • Page 116 3-19 Interrupt Control Instructions ........
  • Page 117 3-28 Failure Diagnosis Instructions ........
  • Page 118 3-33 Model Conversion Instructions ........
  • Page 119: Notation And Layout Of Instruction Descriptions

    Item Contents Name and Mnemonic The heading of each section consists of the name of the instruction followed by the mnemonic with the function code in parentheses. Example: MOVE BIT: MOVB(082) Purpose The basic purpose of the instruction is described after the section heading.
  • Page 120 The memory areas addresses that can be used each operand are listed in a table like the following one. The letters used in the column headings on the left are the same as those used in the ladder symbol. “---” is used to indicate when an area can- not be specific for an operand.
  • Page 121 Always OFF Flag P_Off Precautions for DM The DM Area is smaller in the CP1L L CPU Units, in comparison to the other Area Addresses in CP-series CPU Units. The operand specifications listed in this Programming CP1L L CPU Units...
  • Page 122: Sequence Input Instructions

    Section 3-2 Sequence Input Instructions The following table shows example DM Area ranges in the CP1L L CPU Units. CP1H and CP1L M CPU Units CP1L L CPU Units DM Area D00000 to D32767 DM Area D00000 to D09999, D32000 to D32767...
  • Page 123 , –(– –)IR0 to, –(– –)IR15 Description LD is used for the first normally open bit from the bus bar or for the first nor- mally open bit of a logic block. If there is no immediate refreshing specifica- tion, the specified bit in I/O memory is read. If there is an immediate refreshing specification, the status of the Basic Input Unit’s input terminal is...
  • Page 124: Load Not: Ld Not

    OR LD 100.00 3-2-2 LOAD NOT: LD NOT Purpose Indicates a logical start and creates an ON/OFF execution condition based on the reverse of the ON/OFF status of the specified operand bit. Ladder Symbol Starting point of block Bus bar...
  • Page 125 ,–(– –)IR0 to, –(– –)IR15 Description LD NOT is used for the first normally closed bit from the bus bar, or for the first normally closed bit of a logic block. If there is no immediate refreshing specifi- cation, the specified bit in I/O memory is read and reversed. If there is an immediate refreshing specification, the status of the Basic Input Unit’s input...
  • Page 126: And: And

    0.05 OR LD 100.00 3-2-3 AND: AND Purpose Takes a logical AND of the status of the specified operand bit and the current execution condition. Ladder Symbol Variations Variations Creates ON Each Cycle AND Result is ON Creates ON Once for Upward Differentiation...
  • Page 127 (!@ or !%). If either of these is specified, the input is refreshed from the CPU Unit just before the instruction is executed and the execution condi- tion is turned ON for one cycle only after the status goes from OFF to ON, or from ON to OFF.
  • Page 128: And Not: And Not

    AND LD 100.00 3-2-4 AND NOT: AND NOT Purpose Reverses the status of the specified operand bit and takes a logical AND with the current execution condition. Ladder Symbol Variations Variations Creates ON Each Cycle AND NOT Result is ON...
  • Page 129 AND NOT is used for a normally closed bit connected in series. AND NOT cannot be directly connected to the bus bar, and cannot be used at the begin- ning of a logic block. If there is no immediate refreshing specification, the specified bit in I/O memory is read.
  • Page 130: Or: Or

    Section 3-2 Sequence Input Instructions 3-2-5 OR: OR Purpose Takes a logical OR of the ON/OFF status of the specified operand bit and the current execution condition. Ladder Symbol Bus bar Variations Variations Creates ON Each Cycle OR Result is ON...
  • Page 131: Or Not: Or Not

    OR is used for a normally open bit connected in parallel. A normally open bit is configured to form a logical OR with a logic block beginning with a LOAD or LOAD NOT instruction (connected to the bus bar or at the beginning of the logic block).
  • Page 132 OR NOT is used for a normally closed bit connected in parallel. A normally closed bit is configured to form a logical OR with a logic block beginning with a LOAD or LOAD NOT instruction (connected to the bus bar or at the beginning of the logic block).
  • Page 133: And Load: And Ld

    AND LD Serial connection between logic block A and logic block B. The logic block consists of all the instructions from a LOAD or LOAD NOT instruction until just before the next LOAD or LOAD NOT instruction on the same rungs.
  • Page 134 ON (i.e., when either CIO 0.00 or CIO 0.01 is ON) and either of the execution conditions in the right logic block is ON (i.e., when either CIO 0.02 is ON or CIO 0.03 is OFF).
  • Page 135: Or Load: Or Ld

    AND LOAD is not more than eight. To use nine or more, program using method (1). If there are nine or more with method (2), then a program error will occur during the program check by the CX-Programmer.
  • Page 136 An ON execution condition would be pro- duced either when CIO 0.00 is ON and CIO 0.01 is OFF or when CIO 0.02 and CIO 0.03 are both ON. The operation of and mnemonic code for the OR...
  • Page 137 OR LOAD is not more than eight. To use nine or more, pro- gram using method (1). If there are nine or more with method (2), then a pro- gram error will occur during the program check by the CX-Programmer.
  • Page 138: Differentiated And Immediate Refreshing Instructions

    Immediate refresh instructions (i.e., instructions with !) can be used only for built-in I/O on the CPU Unit. They cannot be used for I/O on CPM1A Expan- sion Units or CPM1A Expansion I/O Units. Use IORF(097) for I/O on CPM1A...
  • Page 139: Operation Timing For I/O Instructions

    Section 3-2 Sequence Input Instructions 3-2-10 Operation Timing for I/O Instructions The following chart shows the differences in the timing of instruction opera- tions for a program configured from LD and OUT. Input received Input received Input received Input received...
  • Page 140: Tr Bits

    TR bit is required. In instruction block (1), the ON/OFF status at point A is the same as for output CIO 100.00, so AND 0.01 and OUT 100.01 can be coded without requiring a TR bit.
  • Page 141 Section 3-2 Sequence Input Instructions TR0 to TR15 output A TR bit address cannot be repeated within the same block in a program with Duplication many output branches, as shown in the following diagram. It can, however, be used again in a different block.
  • Page 142 3-2-13 CONDITION ON/OFF: UP(521) and DOWN(522) Purpose UP(521) turns ON the execution condition for the next instruction for one cycle when the execution condition it receives goes from OFF to ON. DOWN(522) turns ON the execution condition for the next instruction for one cycle when the execution condition it receives goes from ON to OFF.
  • Page 143 LD TSTN(351), AND TSTN(351), and OR TSTN(351) are used in the program like LD NOT, AND NOT, and OR NOT; the execution condition is OFF when the specified bit in the specified word is ON, and ON when the bit is OFF. Ladder Symbols...
  • Page 144 LD NOT, AND NOT, and OR NOT; the execution condition is OFF when the specified bit in the specified word is ON and ON when the bit is OFF. Unlike LD NOT, AND NOT, and OR NOT, bits in the DM area can be used as operands in TSTN(351).
  • Page 145 TST(350) or TSTN(351). Examples LD TST(350) and LD TSTN(351) In the following example, CIO 100.01 is turned ON when bit 3 of D10 is ON. 100.01 &3 In the following example, CIO 100.02 is turned ON when bit 3 of D10 is OFF.
  • Page 146: Sequence Output Instructions

    Section 3-3 Sequence Output Instructions In the following example, CIO 100.02 is turned ON when CIO 0.01 is ON or bit 3 of D10 is OFF. 100.02 0.01 &3 Sequence Output Instructions 3-3-1 OUTPUT: OUT Purpose Outputs the result (execution condition) of the logical processing to the speci- fied bit.
  • Page 147: Output Not: Out Not

    CPU Unit just after the instruction is executed at the same time as it writes the sta- tus of the execution condition (power flow) to the specified output bit in I/O memory.
  • Page 148 Description If there is no immediate refreshing specification, the status of the execution condition (power flow) is reversed and written to a specified bit in I/O memory. If there is an immediate refreshing specification, the status of the execution condition (power flow) is reversed and also written to the CPU Unit’s output terminal in addition to the output bit in I/O memory.
  • Page 149 ,–(– –) IR0 to, –(– –) IR15 Description When S turns ON, the designated bit will go ON and stay ON until reset, regardless of whether S stays ON or goes OFF. When R turns ON, the desig- nated bit will go OFF. The relationship between execution conditions and KEEP(011) bit status is shown below.
  • Page 150 Status of C KEEP(011) has an immediate refreshing variation (!KEEP(011)). When an external output bit has been specified for B in a !KEEP(011) instruction, any changes to B will be refreshed when !KEEP(011) is executed and reflected immediately in the output bit for the CPU Unit built-in output.
  • Page 151 KEEP(011) can be used to create flip-flops as shown below. If a holding bit is used for B, the bit status will be retained even during a power interruption. KEEP(011) can thus be used to program bits that will maintain status after restarting the PLC following a power interruption.
  • Page 152 CIO 100.00 remains ON until CIO 0.01 goes ON. When CIO 0.02 goes ON and CIO 0.03 goes OFF in the following example, CIO 100.01 is turned ON. CIO 100.01 remains ON until CIO 0.04 or CIO 0.05 goes ON.
  • Page 153 ,IR0+(++) to ,IR15+(++) ,–(– –) IR0 to ,15–(– –) IR Description When the execution condition goes from OFF to ON, DIFU(013) turns B ON. When DIFU(013) is reached in the next cycle, B is turned OFF. Execution condition Status of B 1 cycle When the execution condition goes from ON to OFF, DIFD(014) turns B ON.
  • Page 154 CLEAR: IL(002) and ILC(003), 3-4-6 JUMP and JUMP END: JMP(004) and JME(005), and 3-19 Interrupt Control Instructions for details. If DIFU(013) is used in a FOR-NEXT loop and the loop repeats in a cycle, the controlled bit will be always ON or always OFF within that loop.
  • Page 155: Set And Reset: Set And Rset

    Sequence Output Instructions Section 3-3 3-3-5 SET and RESET: SET and RSET Purpose SET turns the operand bit ON when the execution condition is ON. RSET turns the operand bit OFF when the execution condition is ON. Ladder Symbols B: Bit RSET...
  • Page 156 RSET turns the operand bit OFF when the execution condition is ON, and does not affect the status of the operand bit when the execution condition is OFF. Use SET to turn ON a bit that has been turned OFF with RSET. Execution condition...
  • Page 157 Example Differences between OUT/OUT NOT and SET/RSET The operation of SET differs from that of OUT because the OUT instruction turns the operand bit OFF when its execution condition is OFF. Likewise, RSET differs from OUT NOT because OUT NOT turns the operand bit ON when its execution condition is OFF.
  • Page 158 Specifies the first word in which bits will be turned ON or OFF. N1: Beginning Bit Specifies the first bit which will be turned ON or OFF. N1 must be #0000 to #000F (&0 to &15). N2: Number of Bits Specifies the number of bits which will be turned ON or OFF.
  • Page 159 ON if N1 is not within the specified range of 0000 to 000F. OFF in all other cases. Examples SETA(530) Example When CIO 0.00 is turned ON in the following example, the 20 bits (0014 hexa- decimal) beginning with bit 5 of CIO 200 are turned ON. 0.00 N1: Bit 5 N2: 20 bits &5...
  • Page 160 Interrupt tasks Operands D: Word Address Specifies the word in which the bit will be turned ON or OFF. N: Beginning Bit Specifies the bit which will be turned ON or OFF. N must be #0000 to #000F (&0 to &15).
  • Page 161 The functions of SETB(532) and RSTB(533) are described separately below. Operation of SETB(532) SETB(532) turns ON bit N of word D when the execution condition is ON. The status of the bit is not affected when the execution condition is OFF. Unlike SET, SETB(532) can turn ON a bit in the DM area.
  • Page 162 RSTB(533) turns OFF bit N of word D when the execution condition is ON. The status of the bit is not affected when the execution condition is OFF. (Use SETB(532) to turn ON the bit.) Unlike RST, RSTB(533) can turn OFF a bit in the DM area.
  • Page 163 Operands D: Word Address Specifies the word containing the bit to be controlled. N: Beginning Bit Specifies the bit to be controlled. N must be #0000 to #000F (&0 to &15). Operand Specifications Area CIO Area CIO 0 to CIO 6143...
  • Page 164 OUT instruction in an interlocked program section.) When a word is specified for the bit number (N), only bits 00 to 03 of N are used. For example, if N contains FFFA hex, OUTB(534) will control bit 10 of word D.
  • Page 165: Sequence Control Instructions

    END(001) completes the execution of a program for that cycle. No instructions written after END(001) will be executed. Execution proceeds to the program with the next task number. When the pro- gram being executed has the highest task number in the program, END(001) marks the end of the overall main program.
  • Page 166: Overview Of Interlock Instructions

    Interrupt tasks Description No processing is performed for NOP(000), but this instruction can be used to set aside lines in the program where instructions will be inserted later. When the instructions are inserted later, there will be no change in program addresses.
  • Page 167 Regular interlocks (IL(002) and IL(003)) cannot be nested, but multiple inter- Interlocks and Multiple locks (MILH(517), MILR(518), and MILC(519)) can be nested. Ladder pro- Interlocks gramming can be simplified by nesting multiple interlocks, as shown in the following diagram. Interlocks with MILH and MILC Interlocks with IL and ILC...
  • Page 168 Note The different interlocks (IL-ILC, MILH-MILC, and MILR-MILC) can be used together as long as the interlocked program sections do not overlap. For example, all three interlock methods can be used without overlapping, as shown in the following diagram. MILH...
  • Page 169 MTIM(543), MTIMX(554), SET, RSET, CNT, CNTX(546), CNTR(012), CNTRX(548), SFT, and KEEP(011) retain their previous status. If there are bits which you want to remain ON in an interlocked program sec- tion, set these bits to ON with SET just before IL(002).
  • Page 170 Negative Flag OFF or unchanged Precautions The cycle time is not shortened when a section of the program is interlocked because the interlocked instructions are executed internally. The operation of DIFU(013), DIFD(014), and differentiated instructions is not dependent solely on the status of the execution condition when they are pro- grammed between IL(002) and ILC(003).
  • Page 171 Section 3-4 Sequence Control Instructions In general, IL(002) and ILC(003) are used in pairs, although it is possible to use more than one IL(002) with a single ILC(003) as shown in the following diagram. If IL(002) and ILC(003) are not paired, an error message will appear when the program check is performed but the program will be executed prop- erly.
  • Page 172 (i.e., when the interlock is started. 2. Assume that CIO 0.01 turns ON while CIO 0.00 is OFF (i.e., while the interlock is in effect). 3. DIFU(013) will be executed to turn ON CIO 100.00 when CIO 0.00 turns ON (i.e., when the interlock is released) if the input condition for DIFU(013) (CIO 0.01) is still ON.
  • Page 173 Section 3-4 Sequence Control Instructions Examples When CIO 0.00 is OFF in the following example, all outputs between IL(002) and ILC(003) are interlocked. When CIO 0.00 is ON in the following example, the instructions between IL(002) and ILC(003) are executed normally.
  • Page 174 N: Interlock Number Operands N: Interlock Number The interlock number must be between 0 and 15. Match the interlock number of the MILH(517) (or MILR(518)) instruction with the same number in the cor- responding MILC(519) instruction. The interlock numbers can be used in any order.
  • Page 175 CNTRX(548), SFT, and KEEP(011) retain their previous status. The MILH(517)/MILR(518) instruction turns OFF the Interlock Status Bit (operand D) when the interlock is in engaged and turns ON the bit when the interlock is not engaged. Consequently, the Interlock Status Bit can be moni- tored to check whether or not the interlock for a given interlock number is engaged.
  • Page 176 A1 (Peripheral processing) Partial interlock (Conveyor RUN) A2 (Conveyor operation) • A1 and A2 are interlocked when the Emergency Stop Button is ON. • A2 is interlocked when Conveyor RUN is OFF. Global interlock (Emergency stop) When the Emergency Stop is ON (input...
  • Page 177 MILR(518). When a program section is interlocked with MILR(518), a differentiated instruction will not be executed when the interlock is cleared even if the differ- entiation condition was activated during the interlock (comparing the status of the execution condition when the interlock started to its status when the inter- lock was cleared).
  • Page 178 2. The DIFU's CIO 0.01 input condition goes from OFF to ON while CIO 0.00 is OFF (DIFU interlocked), 3. When CIO 0.00 goes from OFF to ON (interlock cleared), DIFU is executed if CIO 0.01 is still ON. 0.01 DIFU 100.00...
  • Page 179 2. The DIFU's CIO 0.01 input condition goes from OFF to ON while CIO 0.00 is OFF (DIFU interlocked), 3. When CIO 0.00 goes from OFF to ON (interlock cleared), DIFU is not executed even though CIO 0.01 is still ON.
  • Page 180 100.00 Controlling Interlock Status from the CX-Programmer An interlock can be engaged or released manually by force-resetting or force- setting the Interlock Status Bit (specified with operand D of MILH(517) and MILR(518)) from the CX-Programmer. The forced status of the Interlock Sta- tus Bit has priority and overrides the interlock status calculated by program execution.
  • Page 181 MILH MILH MILC MILC Unlike the IL(002) interlocks, MILH(517) and MILR(518) interlocks can be nested, so the operation of similar programs will be different if MILH(517) or MILR(518) is used instead of ILC(002). Program with MILH(517)/MILC(519) Interlocks MILH 100.00 MILH 100.01...
  • Page 182 ILC(003) interlock.) Not interlocked Not interlocked If there are bits which you want to remain ON in a program section interlocked by MILH(517) or MILR(518), set these bits to ON with SET just before the MILH(517) or MILR(518) instruction. Flags...
  • Page 183 A1 and A3 operate together. (They are interlocked when "a" is OFF, regardless of the ON/OFF status of "b".) MILC If there is an ILC(003) instruction between an MILH(517) and MILC(519) pair, the program section between MILH(517) and ILC(003) will be interlocked.
  • Page 184 The MILC(519) instruction is ignored. MILC If there is an ILC(003) instruction between an MILR(518) and MILC(519) pair, the ILC(003) instruction will be ignored and the full program section between MILR(518) and MILC(519) will be interlocked.
  • Page 185 This MILC(519) instruction is ignored. MILC MILC If there is an MILH(517) instruction between an IL(002) and ILC(003) pair and the IL(002) interlock is engaged, the MILH(517) instruction has no effect. In this case, the program section between IL(002) and ILC(003) will be inter- locked.
  • Page 186 MILC Examples When W0.00 and W0.01 are both ON, the instructions between MILH(517) with interlock number 0 and MILC(519) with interlock number 0 are executed normally. When W0.00 is OFF, the instructions between MILH(517) with interlock num- ber 0 and MILC(519) with interlock number 0 are interlocked.
  • Page 187 JUMP and JUMP END: JMP(004) and JME(005) Purpose When the execution condition for JMP(004) is OFF, program execution jumps directly to the first JME(005) in the program with the same jump number. JMP(004) and JME(005) are used in pairs. Ladder Symbols...
  • Page 188 Section 3-4 Sequence Control Instructions Description When the execution condition for JMP(004) is ON, no jump is made and the program is executed consecutively as written. When the execution condition for JMP(004) is OFF, program execution jumps directly to the first JME(005) in the program with the same jump number. The instructions between JMP(004) and JME(005) are not executed, so the status of outputs between JMP(004) and JME(005) is maintained.
  • Page 189 JME(005) and JMP(004) will be executed repeatedly as long as the execution condition for JMP(004) is OFF. A Cycle Time Too Long error will occur if the execution condition is not turned ON or END(001) is not executed within the maximum cycle time.
  • Page 190 The operation of CJP(510) is the basically the opposite of JMP(004). When the execution condition for CJP(510) is ON, program execution jumps directly to the first JME(005) in the program with the same jump number. CJP(510) and JME(005) are used in pairs.
  • Page 191 DR0 to DR15, IR0 to IR15 Description The operation of CJP(510) and CJPN(511) differs only in the execution condi- tion. CJP(510) jumps to the first JME(005) when the execution condition is ON and CJPN(511) jumps to the first JME(005) when the execution condition is OFF.
  • Page 192 Operation of CJP(510) When the execution condition for CJP(510) is OFF, no jump is made and the program is executed consecutively as written. When the execution condition for CJP(510) is ON, program execution jumps directly to the first JME(005) in the program with the same jump number.
  • Page 193 OFF (CJP(510)) or ON (CJPN(511)). A Cycle Time Too Long error will occur if the jump is not completed by changing the execution condition executing END(001) within the maximum cycle time.
  • Page 194 When the execution condition for JMP0(515) is OFF, all instructions from JMP0(515) to the next JME0(516) in the program are processed as NOP(000). Use JMP0(515) and JME0(516) in pairs. There is no limit on the number of pairs that can be used in the program.
  • Page 195 Not allowed Not allowed Description When the execution condition for JMP0(515) is ON, no jump is made and the program executed consecutively as written. When the execution condition for JMP0(515) is OFF, all instructions from JMP0(515) to the next JME0(516) in the program are processed as NOP(000).
  • Page 196 Section 3-4 Sequence Control Instructions Example When CIO 0.00 is OFF in the following example, the instructions between JMP0(515) and JME0(516) are processed as NOP(000) instructions and the outputs maintain their previous status. When CIO 0.00 is ON in the following example, the instructions between JMP0(515) and JME0(516) are executed normally.
  • Page 197 The BREAK(514) instruction can be used to cancel the loop. If N is set to 0, the instructions between FOR(512) and NEXT(513) are pro- cessed as NOP(000) instructions. Loops can be used to process tables of data with a minimum amount of pro- gramming. Repeated N times...
  • Page 198 Section 3-4 Sequence Control Instructions FOR-NEXT loops can be nested up to 15 levels. In the example below, pro- gram sections A, B, and C are executed as follows: C, A C, and A &3 &2 Use BREAK(514) to escape from a FOR-NEXT loop. Several BREAK(514) instructions (the number of levels nested) are required to escape from nested loops.
  • Page 199 • MULTIPLE JUMP and JUMP END: JMP(515) and JME(516) • STEP DEFINE and STEP START: STEP(008)/SNXT(009) Note If a loop repeats in one cycle and a differentiated bit is used in the FOR-NEXT loop, that bit will be always ON or always OFF within that loop. Example...
  • Page 200 Not allowed Description Program BREAK(514) between FOR(512) and NEXT(513) to cancel the FOR-NEXT loop when BREAK(514) is executed. When BREAK(514) is exe- cuted, the rest of the instructions up to NEXT(513) are processed as NOP(000). Condition a ON N repetitions Repetitions forced to end.
  • Page 201: Timer And Counter Instructions

    Using binary data instead of BCD allows the SV range for timers and counter to be increased from 0 to 9999 to 0 to 65535. It also enables using binary data calculated with other instructions directly as a timer/counter SV. The refresh method is valid even when setting an SV indirectly (i.e., using the contents of...
  • Page 202: Timer Operation

    Note (1) TIM PVs are refreshed at execution for all times and also every 100 ms for T0000 to T0015. (2) TIMH(015)/TIMHX(551) PVs are refreshed at execution for all times and also every 10 ms for T0000 to T0015.
  • Page 203 TIM or TIMX(550) operates a decrementing timer with units of 0.1-s. The set- ting range for the set value (SV) is 0 to 999.9 s for TIM and 0 to 6,553.5 s for TIMX(550). The timer accuracy is 0 to 0.01 s.
  • Page 204 DR0 to DR15, IR0 to IR15 Description When the timer input is OFF, the timer specified by N is reset, i.e., the timer’s PV is reset to the SV and its Completion Flag is turned OFF. When the timer input goes from OFF to ON, TIM/TIMX(550) starts decrement- ing the PV.
  • Page 205 When a TIM/TIMX(550) timer is forced set, its Completion Flag will be turned ON and its PV will be set to 0. When a TIM/TIMX(550) timer is forced reset, its Completion Flag will be turned OFF and its PV will be reset to the SV.
  • Page 206 Timer and Counter Instructions The timer’s Completion Flag is refreshed only when TIM/TIMX(550) is exe- cuted, so a delay of up to one cycle may be required for the Completion Flag to be turned ON after the timer times out.
  • Page 207 Purpose TIMH(015)/TIMHX(551) operates a decrementing timer with units of 10-ms. The setting range for the set value (SV) is 0 to 99.99 s for TIMH(015) and 0 to 655.35 s for TIMHX(551). The timer accuracy is 0 to 0.01 s.
  • Page 208 DR0 to DR15, IR0 to IR15 Description When the timer input is OFF, the timer specified by N is reset, i.e., the timer’s PV is reset to the SV and its Completion Flag is turned OFF. When the timer input goes from OFF to ON, TIMH(015)/TIMHX(551) starts decrementing the PV.
  • Page 209 16 to 4095 will be held when the timer is on standby. The operation of the = Flag and N Flag depends on the model of the CPU Unit. Refer to Flags, above, for details. Timers will be reset or paused in the following cases. (When a timer is reset, its PV is reset to the SV and its Completion Flag is turned OFF.)
  • Page 210 Completion Flags and PVs will be maintained when the operating mode is changed. (2) If the IOM Hold Bit (A500.12) has been turned ON and the status of the IOM Hold Bit itself is protected in the PLC Setup, the status of timer Com- pletion Flags and PVs will be maintained even when the power is inter- rupted.
  • Page 211 PV will begin counting down from the SV (#0064 = 100 = 1.00 s). The Timer Completion Flag, T0000, will be turned ON when the PV reaches 0000. When CIO 0.00 goes OFF, the timer PV will be reset to the SV and the Com- pletion Flag will be turned OFF.
  • Page 212 DR0 to DR15, IR0 to IR15 Description When the timer input is OFF, the timer specified by N is reset, i.e., the timer’s PV is reset to the SV and its Completion Flag is turned OFF. When the timer input goes from OFF to ON, TMHH(540)/TMHHX(552) starts decrementing the PV.
  • Page 213 Completion Flags and PVs will be maintained when the operating mode is changed. (2) If the IOM Hold Bit (A500.12) has been turned ON and the status of the IOM Hold Bit itself is protected in the PLC Setup, the status of timer Com- pletion Flags and PVs will be maintained even when the power is inter- rupted.
  • Page 214 Purpose TTIM(087)/TTIMX(555) operates an incrementing timer with units of 0.1-s. The setting range for the set value (SV) is 0 to 999.9 s for TTIM(087) and 0 to 6,553.5 s for TTIMX(555). The timer accuracy is –0.01 to 0 s.
  • Page 215 When the timer input is ON, TTIM(087)/TTIMX(555) increments the PV. When the timer input goes OFF, the timer will stop incrementing the PV, but the PV will retain its value. The PV will resume timing when the timer input goes ON again.
  • Page 216 0. Timer Completion Flag T0001 will be turned ON when the PV reaches the SV. If the reset input is turned ON, the timer PV will be reset to 0000 and the Com- pletion Flag (T0001) will be turned OFF. (Usually the reset input is turned ON...
  • Page 217 Section 3-5 Timer and Counter Instructions If the timer input is turned OFF before the SV is reached, the timer will stop timing but the PV will be maintained. The timer will resume from its previous PV when the timer input is turned ON again.
  • Page 218 D2+1 S: SV Word S+1 and S contain the 8-digit binary or BCD SV. (S and S+1 must be in the same data area.) The SV must be between #00000000 to #99999999 for TIML(542) and &00000000 to &4294967294 (decimal) or #00000000 to #FFFFFFFF (hexadecimal) for TIMLX(553).
  • Page 219 TIML(542)/TIMLX(553) is a decrementing ON-delay timer with units of 0.1-s that uses an 8-digit SV and an 8-digit PV. When the timer input is OFF, the timer is reset, i.e., the timer’s PV is reset to the SV and its Completion Flag is turned OFF.
  • Page 220 When timer input CIO 0.00 is ON in the following example, the timer PV (in D101 and D100) will be set to the SV (in D201 and D200) and the PV will begin counting down. The timer Completion Flag (CIO 200.00) will be turned ON when the PV reaches 0000 0000.
  • Page 221 Subroutines Interrupt tasks Not allowed Not allowed Operands D1: Completion Flags D1 contains the eight Completion Flags as well as the pause and reset bits. Do not use. Completion Flags Reset bit Pause bit D2: PV Word D2 contains the 4-digit binary or BCD PV.
  • Page 222 PV, the corresponding Completion Flag (D1 bits 00 through 07) is turned ON. When the PV reaches 9999, the PV will be reset to 0000 and all of the Com- pletion Flags will be turned OFF. If the reset bit is turned ON while the timer is operating or paused, the PV will be reset to 0000 and all of the Completion Flags will be turned OFF.
  • Page 223 Unlike most timers, MTIM(543)/MTIMX(554) does not use a timer number. (Timer area PV refreshing is not performed for MTIM(543)/MTIMX(554).) When the PV reaches 9999, the PV will be reset to 0000 and all of the Com- pletion Flags will be turned OFF.
  • Page 224 Section 3-5 Timer and Counter Instructions When eight or fewer SVs are required, set the word after the last SV to 0000. MTIM(543)/MTIMX(554) will ignore the SV that is set to 0000 and all of the remaining SVs. These SVs are ignored.
  • Page 225 S+1: D201 S+2: D202 S+3: D203 S+4: D204 S+5: D205 S+6: D206 S+7: D207 Timer input Timer input must remain ON CIO 0.00 while the timer is timing. Reset bit CIO 200.08 Pause bit CIO 200.09 Timing resumes. Max. PV = 9999...
  • Page 226 Section 3-5 Timer and Counter Instructions 3-5-7 COUNTER: CNT/CNTX(546) Purpose CNT/CNTX(546) operates a decrementing counter. The setting range 0 to 9,999 for CNT and 0 to 65,535 for CNTX(546). Ladder Symbol Count input N: Counter number S: Set value Reset input...
  • Page 227 A counter’s PV is refreshed when the count input goes from OFF to ON and the Completion Flag is refreshed each time that CNT/CNTX(546) is executed. The Completion Flag is turned ON if the PV is 0 and it is turned OFF if the PV is not 0.
  • Page 228 When a CNT/CNTX(546) counter is forced set, its Completion Flag will be turned ON and its PV will be reset to 0000. When a CNT/CNTX(546) counter is forced reset, its Completion Flag will be turned OFF and its PV will be set to the SV.
  • Page 229 Counter PVs are retained even through a power interruption. If you want to restart counting from the SV instead of resuming the count from the retained PV, add the First Cycle Flag (A200.11) as a reset input to the counter. First Cycle Flag (A200.11)
  • Page 230 Counter PV When incrementing, the Completion Flag will be turned ON when the PV is incremented from the SV back to 0 and it will be turned OFF again when the PV is incremented from 0 to 1. Counter PV...
  • Page 231 0 and both count inputs will be ignored. The Completion Flag will be ON only when the PV has been incremented from the SV to 0 or decremented from 0 to the SV; it will be OFF in all other cases.
  • Page 232 Examples Basic Operation of CNTR(012)/CNTRX(548) The counter PV is reset to 0 by turning the reset input (CIO 0.02) ON and OFF. The PV is incremented by 1 each time that the increment input (CIO 0.00) goes from OFF to ON. When the PV is incremented from the SV (3), it is automatically reset to 0 and the Completion Flag is turned ON.
  • Page 233 In the following example, the SV for CNTR(012) 0007 is determined by the content of CIO 1. The content of CIO 1 can be controlled by an external switch so that the set value can be changed manually from the switch.
  • Page 234 . At the same time, the PVs will all be set to the maximum value (9999 for BCD and FFFF for binary). (The PV will be set to the SV the next time that the timer or counter instruction is executed.)
  • Page 235 In most cases, the effect of CNR(545)/CNRX(547) is different from directly resetting the instructions. For example, when a TIM/TIMX(550) instruction is reset directly its PV is set to the SV, but when that timer is reset by CNR(545)/ CNRX(547) its PV is set to the maximum value of 9999.
  • Page 236 In this example, a TIM instruction and a CNT instruction are combined to make a 500-second timer. TIM 0001 generates a pulse every 5 s and CNT 0002 counts these pulses. The set value for this combination is the timer interval counter SV.
  • Page 237 700-second timer. If the First Cycle Flag (A200.11) is ORed with the counter’s reset input (CIO 0.01), the counter’s PV will be reset to the SV (0700) when program exe- cution begins rather than resuming the count from the previous PV.
  • Page 238 A TIM timer can be combined with OUT or OUT NOT to control how long a One-shot Bit particular bit is ON or OFF. In this example, CIO 100.00 will be ON for 1.5 sec- onds (the SV of T0001) after CIO 0.00 goes ON.
  • Page 239 Two TIM timers can be combined to make a bit turn ON and OFF at regular intervals while the execution condition is ON. In this example, CIO 200.00 will be OFF for 1.0 second and then ON for 1.5 seconds as long as CIO 0.00 is 0.00...
  • Page 240 Timer and Counter Instructions The timer or counter instruction will not be executed if the PLC memory address in the specified Index Register is not the address of a timer or counter Using Index Registers to indirectly address timers and counters can reduce the size of the program and increase flexibility.
  • Page 241 4. MOV(021) moves &100 into D0 for indirect addressing of the timer SVs. 5. The content of IR0, IR1, IR2, and D0 are incremented by 1 each time as this loop is executed 100 times, starting timers T0 through T99.
  • Page 242: Comparison Instructions

    Purpose Input comparison instructions compare two values (constants and/or the con- tents of specified words) and create an ON execution condition when the comparison condition is true. Input comparison instructions are available to compare signed or unsigned data of one-word or double length data.
  • Page 243 Unlike instructions such as CMP(020) and CMPL(060), the result of an input comparison instruction is reflected directly as an execution condition, so it is not necessary to access the result of the comparison through an Arith- metic Flag and the program is simpler and faster.
  • Page 244 Comparison Instructions Section 3-6 Inputting the Instructions The input comparison instructions are treated just like the LD, AND, and OR instructions to control the execution of subsequent instructions. Input type Operation The instruction can be connected directly to the left bus bar.
  • Page 245 Comparison Instructions Section 3-6 Summary of Input Comparison Instructions The following table shows the function codes, mnemonics, names, and func- tions of the 72 input comparison instructions. (For one-word comparisons C1=S and C2=S ; for double comparisons C1=S +1, S...
  • Page 246 AND<=S AND SIGNED LESS THAN OR EQUAL OR<=S OR SIGNED LESS THAN OR EQUAL LD<=SL LOAD DOUBLE SIGNED LESS THAN OR EQUAL True if AND<=SL AND DOUBLE SIGNED LESS THAN OR EQUAL OR<=SL OR DOUBLE SIGNED LESS THAN OR EQUAL LD>...
  • Page 247 D200, CIO 100.00 is turned ON and execution proceeds to the next line. If the content of D100 is not less than that of D200, the remainder of the instruction line is skipped and execution moves to the next instruction line.
  • Page 248 Operands C: Control Word Bits 00 to 05 of C specify whether or not the time data will be masked for the comparison. Bits 00 to 05 mask the seconds, minutes, hours, day, month, and year, respectively. If all 6 values are masked, the instruction will not be exe- cuted, the execution condition will be OFF, and the Error Flag will be turned Masks seconds data when ON.
  • Page 249 Month: 01 to 12 (BCD) Year: 00 to 99 (BCD) Note When using the CPU Unit’s internal clock data for the comparison, set S A351 to specify the CPU Unit’s internal clock data (A351 to A353). through S +2: Comparison Time Data through S +2 contain the comparison time data.
  • Page 250 Time values can be masked individually and excluded from the comparison operation. To mask a time value, set the corresponding bit in the control word (C) to 1. Bits 00 to 05 of C mask the seconds, minutes, hours, day, month, and year, respectively.
  • Page 251 Comparison Instructions Example: When C = 39 hex, the rightmost 6 bits are 111001 (year=1, month=1, day=1, hours=0, minutes=0, and seconds=1) so only the hours and minutes are com- pared. This mask setting can be used to perform a particular operation at a given time (hour and minute) each day.
  • Page 252 Example When CIO 0.00 is ON and the time is 13:00:00, CIO 100.00 is turned ON. The contents of A351 to A353 (the CPU Unit’s internal calendar/clock data) are used as the present time data and the contents of D100 to D102 are used as the comparison time data.
  • Page 253 CMP(020) compares the unsigned binary data in S and S and outputs the result to Arithmetic Flags (the Greater Than, Greater Than or Equal, Equal, Less Than or Equal, Less Than, and Not Equal Flags) in the Auxiliary Area. Unsigned binary comparison Arithmetic Flags...
  • Page 254 Control the desired output or right-hand instruction with a branch from the same input condition that controls CMP(020), as shown in the following dia- gram. In this case, the Equals Flag and output A will be turned ON when S Correct Use of CMP(020)
  • Page 255 Arithmetic Flags. 3-6-4 DOUBLE COMPARE: CMPL(060) Purpose Compares two double unsigned binary values (constants and/or the contents of specified words) and outputs the result to the Arithmetic Flags in the Auxil- iary Area. Ladder Symbol CMPL(060) : Comparison data 1...
  • Page 256 CMPL(060) compares the unsigned binary data in S +1, S and S +1, S and outputs the result to Arithmetic Flags (the Greater Than, Greater Than or Equal, Equal, Less Than or Equal, Less Than, and Not Equal Flags) in the Auxiliary Area. Unsigned binary comparison S2+1 Arithmetic Flags (>, >=, =, <=, <, <>)
  • Page 257 Do not program another instruction between CMPL(060) and the instruction controlled by the Arithmetic Flag because the other instruction might change the status of the Arithmetic Flag. In this case, the results of instruction B might change the results of CMPL(060).
  • Page 258 CIO 1001 and CIO 1000 is compared to the eight-digit unsigned binary data in CIO 1501 and CIO 1500 and the result is output to the Arith- metic Flags. The results recorded in the Greater Than, Equals, and Less Than Flags are immediately saved to CIO 100.00 (Greater Than), CIO 100.01...
  • Page 259 Control the desired output or right-hand instruction with a branch from the same input condition that controls CPS(114), as shown in the following dia- gram. In this case, the Equals Flag and output A will be turned ON when S Correct Use of CPS(114)
  • Page 260 Do not program another instruction between CPS(114) and the instruction controlled by the Arithmetic Flag because the other instruction might change the status of the Arithmetic Flag. In this case, the results of instruction B might change the results of CPS(114).
  • Page 261 CPSL(115) compares the double signed binary data in S +1, S and S and outputs the result to Arithmetic Flags (the Greater Than, Greater Than or Equal, Equal, Less Than or Equal, Less Than, and Not Equal Flags) in the Auxiliary Area. Signed binary comparison...
  • Page 262 Do not program another instruction between CPSL(115) and the instruction controlled by the Arithmetic Flag because the other instruction might change the status of the Arithmetic Flag. In this case, the results of instruction B might change the results of CPSL(115).
  • Page 263 Than Flag will be turned ON, causing CIO 100.00 to be turned ON. • If the content of D2 and D1 is equal to that of D6 and D5, the Equals Flag will be turned ON, causing CIO 100.01 to be turned ON.
  • Page 264 R: Result word Each bit of R contains the result of a comparison between two words in the 16-word sets. Bit n of R (n = 00 to 15) contains the result of the comparison between words S +n and S...
  • Page 265 +n is equal to the content of S +n; bit n of R is turned ON if the contents are not equal. If the contents of all 16 pairs of words are the same, the Equals Flag will turn ON after the instruction has been executed.
  • Page 266 R: Result word Each bit of R contains the result of a comparison between S and a word in the 16-word table. Bit n of R (n = 00 to 15) contains the result of the comparison between S and T+n.
  • Page 267 T+15 and turns ON the corresponding bit in word R when the data are equal. Bit n of R is turned ON if the content of T+n is equal to S and it is turned OFF if they are not equal.
  • Page 268 3-6-9 BLOCK COMPARE: BCMP(068) Purpose Compares the source data to 16 ranges (defined by 16 lower limits and 16 upper limits) and turns ON the corresponding bit in the result word when the source data is within a range. Ladder Symbol...
  • Page 269 (B+2n) provides the lower limit and the second word (B+2n+1) provides the upper limit of range n (n = 0 to 15). If S is within any of these ranges (inclusive of the upper and lower limits), the corresponding bit in R is turned ON. The rest of the bits in R will be turned OFF.
  • Page 270 B+30 B+31 Bit 15 of R For example, bit 00 of R is turned ON if S is within the first range (B B+1), bit 01 of R is turned ON if S is within the second range (B+2 B+3), ..., and bit 15 of R is turned ON if S is within the fifteenth range (B+30...
  • Page 271 3-6-10 EXPANDED BLOCK COMPARE: BCMP2(502) Purpose Compares the source data to up to 256 ranges (defined by 256 lower limits and 256 upper limits) and turns ON the corresponding bit in the result word when the source data is within a range.
  • Page 272 Comparison Instructions R: First result word Each bit of each R word contains the result of a comparison between S and one of the ranges defined the comparison block. The maximum number of result words is 16, i.e., m equals 0 to 15.
  • Page 273 If S is within any of these ranges (inclusive of the upper and lower limits), the corresponding bits in the result words (R to R+15 max.) are turned ON. The rest of the bits in R will be turned OFF.
  • Page 274 For example, if the source data in CIO 1000 is in the range defined by D201 and D202, then bit 00 of CIO 2000 is turned ON and if it in not in the range, then bit 00 of CIO 2000 is turned OFF. Likewise, the source...
  • Page 275 ZCP(088) compares the 16-bit signed binary data in CD with the range defined by LL and UL and outputs the result to the Greater Than, Equals, and Less Than Flags in the Auxiliary Area. (The Less Than or Equal, Greater...
  • Page 276 Control the desired output or right-hand instruction with a branch from the same input condition that controls ZCP(088), as shown in the following dia- gram. In this case, the Equals Flag and output A will be turned ON when Correct Use of ZCP(088)
  • Page 277 Example When CIO 0.00 is ON in the following example, the 16-bit unsigned binary data in D0 is compared to the range 0005 to 001F hex (5 to 31 decimal) and the result is output to the Arithmetic Flags. CIO 100.00 is turned ON if 0005 hex content of D0 001F hex.
  • Page 278 ZCPL(116) compares the 32-bit signed binary data in CD+1, CD with the range defined by LL+1, LL and UL+1, UL and outputs the result to the Greater Than, Equals, and Less Than Flags in the Auxiliary Area. (The Less Than or Equal, Greater Than or Equal, and Not Equal Flags are left unchanged.)
  • Page 279 Section 3-6 Comparison Instructions The operation of ZCPL(116) is almost identical to that of ZCP(088) except that ZCPL(116) compares 32-bit values instead of 16-bit values. Refer to 3-6-11 AREA RANGE COMPARE: ZCP(088) for diagrams showing how to use results in the program and an example program section.
  • Page 280: Data Movement Instructions

    Data Movement Instructions Section 3-7 Data Movement Instructions This section describes instructions used to move data in various ways. Instruction Mnemonic Function Page code MOVE MOVE NOT DOUBLE MOVE MOVL DOUBLE MOVE NOT MVNL MOVE BIT MOVB MOVE DIGIT MOVD...
  • Page 281 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –) IR0 to, –(– –) IR15 Description Transfers S to D. If S is a constant, the value can be used for a data setting. Bit status not Source word Destination word changed.
  • Page 282 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –) IR0 to, –(– –) IR15 Description MVN(022) inverts the bits in S and transfers the result to D. The content of S is left unchanged. Source word Destination word Bit status inverted.
  • Page 283 Section 3-7 Data Movement Instructions Example When CIO 0.00 is ON in the following example, the status of the bits in CIO 200 is inverted and the result is copied to D100. 0.00 D100 CIO 200 D100 3-7-3 DOUBLE MOVE: MOVL(498) Purpose Transfers two words of data to the specified words.
  • Page 284 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –) IR0 to, 1–(– –) IR5 Description MOVL(498) transfers S+1 and S to D+1 and D. If S+1 and S are constants, the value can be used for a data setting. Bit status not changed.
  • Page 285 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –) IR0 to, –(– –) IR15 Description MVNL(499) inverts the bits in S+1 and S and transfers the result to D+1 and D. The contents of S+1 and S are left unchanged. Bit status inverted.
  • Page 286 Operands C: Control Word The rightmost two digits of C indicate which bit of S is the source bit and the leftmost two digits of C indicate which bit of D is the destination bit. Source bit: 00 to 0F...
  • Page 287 MOVB(082) copies the specified bit (n) from S to the specified bit (m) in D. The other bits in the destination word are left unchanged. Note The same word can be specified for both S and D to copy a bit within a word. Flags Name...
  • Page 288 Digit 1 Digit 0 C: Control Word The first three digits of C indicate the first source digit (m), the number of dig- its to transfer (n), and the first destination digit (l), as shown in the following diagram. First digit in S (m): 0 to 3...
  • Page 289 If the number of digits being read or written exceeds the leftmost digit of S or D, MOVD(083) will wrap to the rightmost digit of the same word. Note The same word can be specified for both S and D to copy a bit within a word. Flags Name...
  • Page 290 When CIO 0.00 is ON in the following example, four digits of data are copied from CIO 200 to CIO 300. The transfer begins with the digit 1 of CIO 200 and digit 0 or CIO 300, in accordance with the control word’s value of 0031.
  • Page 291 Data Movement Instructions Operands C: Control Word The first three digits of C indicate the first source digit (m), the number of dig- its to transfer (n), and the first destination digit (l), as shown in the following diagram. First bit in S (l l ): 0 to F...
  • Page 292 XFRB(062) transfers up to 255 consecutive bits from the source words (begin- ning with bit l of S) to the destination words (beginning with bit m of D). Bits in the destination words that are not overwritten by the source bits are left unchanged.
  • Page 293 Subroutines Interrupt tasks Operands N: Number of Words Specifies the number of words to be transferred. The possible range for N is 0000 to FFFF (0 to 65,535 decimal). S: First Source Word Specifies the first source word. S+(N 1) D: First Destination Word Specifies the first destination word.
  • Page 294 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –) IR0 to, –(– –) IR15 Description XFER(070) copies N words beginning with S (S to S+(N–1)) to the N words beginning with D (D to D+(N–1)). N words S+(N 1)
  • Page 295 Subroutines Interrupt tasks Operands S: Source Word Specifies the source data or the word containing the source data. St: Starting Word Specifies the first word in the destination range. E: End Word Specifies the last word in the destination range.
  • Page 296 ON if St is greater than E. OFF in all other cases. Precautions Be sure that the starting word (St) and end word (E) are in the same data area and that St Some time will be required to complete BSET(071) when the source data is being transferred to a large number of words.
  • Page 297 DR0 to DR15 Index Registers Indirect addressing ,IR0 to ,IR15 using Index Registers –2048 to +2047, IR0 to –2048 to +2047, IR15 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –) IR0 to, –(– –) IR15 Description XCHG(073) exchanges the contents of E1 and E2.
  • Page 298 Section 3-7 Data Movement Instructions Example When CIO 0.00 is ON in the following example, the content of D100 is exchanged with the content of D200. 0.00 D100 D200 D100 D200 D100 D200 3-7-11 DOUBLE DATA EXCHANGE: XCGL(562) Purpose Exchanges the contents of a pair of consecutive words with another pair of consecutive words.
  • Page 299 XCHG(073) exchanges the contents of E1+1 and E1 with the contents of E2+1 and E2. E1+1 E2+1 To exchange 3 or more words, use XFER(070) to transfer the words to a third set of words (a buffer) as shown in the following diagram. XFER(070) operation...
  • Page 300 Of: Offset This value is added to the base address to calculate the destination word. The offset can be any value from 0000 to FFFF (0 to 65,535 decimal), but Bs and Bs+Of must be in the same data area.
  • Page 301 ON if the leftmost bit of the source data is 1. OFF in all other cases. Precautions Be sure that the offset does not exceed the end of the data area, i.e., Bs and Bs+Of are in the same data area. Example When CIO 0.00 is ON in the following example, the contents of D100 will be...
  • Page 302 Of: Offset This value is added to the base address to calculate the source word. The off- set can be any value from 0000 to FFFF (0 to 65,535 decimal), but Bs and Bs+Of must be in the same data area.
  • Page 303 ON if the leftmost bit of the source data is 1. OFF in all other cases. Precautions Be sure that the offset does not exceed the end of the data area, i.e., Bs and Bs+Of are in the same data area. Example When CIO 0.00 is ON in the following example, the contents of D110 (D100 +...
  • Page 304 Internal I/O memory address of S Index Register If a timer or counter is specified in S, MOVR(560) will write the PLC memory address of the timer/counter Completion Flag in D. Use MOVRW(561) to write the PLC memory address of the timer/counter PV in D.
  • Page 305 Be sure to set a register using MOVR(560) in an interrupt task before using the register. Any changes to the contents of an IR or DR made in an interrupt task will not affect the contents of the register in a cyclic task.
  • Page 306 Internal I/O memory address of S Timer/counter PV only Index Register MOVRW(561) will set the PLC memory address of the timer or counter’s PV in D. Use MOVR(560) to set the PLC memory address of the timer or counter Completion Flag.
  • Page 307: Data Shift Instructions

    Data Shift Instructions Section 3-8 Data Shift Instructions This section describes instructions used to shift data within or between words, but in differing amounts and directions. Instruction Mnemonic Function code Page SHIFT REGISTER REVERSIBLE SHIFT REGIS- SFTR ASYNCHRONOUS SHIFT ASFT...
  • Page 308 When the execution condition on the shift input changes from OFF to ON, all the data from St to E is shifted to the left by one bit (from the rightmost bit to the leftmost bit), and the ON/OFF status of the data input is placed in the rightmost bit.
  • Page 309 The following example shows a 48-bit shift register using words CIO 1000 to CIO 1002. A 1-s clock pulse is used so that the execution condition produced by CIO 0.05 is shifted into a 3-word register between CIO 1000.00 and CIO 1002.15 every second.
  • Page 310 St to E is moved in the designated shift direction (designated by bit 12 of C) by 1 bit, and the ON/OFF status of the data input is placed in the rightmost or leftmost bit. The bit data shifted out of the shift register is placed in the Carry Flag (CY).
  • Page 311 Controlling Data Resetting Data All bits from St to E and the Carry Flag are set to 0 and no other data can be received when the reset input bit (bit 15 of C) is ON. Shifting Data Left (from Rightmost to Leftmost Bit)
  • Page 312 Section 3-8 Data Shift Instructions 3-8-3 ASYNCHRONOUS SHIFT REGISTER: ASFT(017) Purpose Shifts all non-zero word data within the specified word range either towards St or toward E, replacing 0000 hex word data. Ladder Symbol ASFT(017) C: Control word St: Starting word...
  • Page 313 OFF in all other cases. Precautions When the Clear Flag (bit 15 of C) goes ON, all bits in the shift register, from St to E, will be reset (i.e., set to 0). The Clear Flag has priority over the Shift Enable Bit (bit 14 of C).
  • Page 314 Examples Shifting Data: If the Shift Enable Bit, H0.14, goes ON when CIO 0.00 is ON, all words with non-zero data content from D100 through D109 will be shifted in the direction designated by the Shift Direction Bit, H0.13 (e.g., 1: Toward St) if the word to the left of the non-zero data is all zeros.
  • Page 315 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description WSFT(016) shifts data from St to E in word units and the data from the source word S is places into St. The contents of E is lost. Lost Flags...
  • Page 316 Description ASL(025) shifts the contents of Wd one bit to the left (from rightmost bit to left- most bit). “0” is placed in the rightmost bit and the data from the leftmost bit is shifted into the Carry Flag (CY).
  • Page 317 If as a result of the shift the contents of Wd is zero, the Equals Flag will turn If as a result of the shift the contents of the leftmost bit of Wd is 1, the Nega- tive Flag will turn ON.
  • Page 318 If as a result of the shift the contents of Wd and Wd +1 are zero, the Equals Flag will turn ON. If as a result of the shift the contents of the leftmost bit of Wd +1 is 1, the Neg- ative Flag will turn ON.
  • Page 319 Data Shift Instructions Examples When CIO 0.01 is ON, word CIO 1000 and CIO 1001 will shift one bit to the left. “0” is placed into CIO 1000.00 and the contents of CIO 1001.15 will be shifted to the Carry Flag (CY).
  • Page 320 When ASR(026) is executed, the Error Flag and the Negative Flag will turn OFF. If as a result of the shift the contents of Wd is zero, the Equals Flag will turn Examples When CIO 0.00 is ON, word CIO 1000 will shift one bit to the right. “0” will be placed in CIO 1000.15 and the contents of CIO 1000.00 will be shifted to the...
  • Page 321 ASRL(571) shifts the contents of Wd and Wd +1 one bit to the right (from left- most bit to rightmost bit). “0” will be placed in the leftmost bit of Wd +1 and the contents of the rightmost bit of Wd will be shifted into the Carry Flag (CY).
  • Page 322 Data Shift Instructions Examples When CIO 0.01 is ON, word CIO 2000 and CIO 2001 will shift one bit to the right. “0” will be placed into CIO 2001.15 and the contents of CIO 2000.00 will be shifted to the Carry Flag (CY).
  • Page 323 If as a result of the shift the contents of Wd is zero, the Equals Flag will turn If as a result of the shift the contents of the leftmost bit of Wd is 1, the Nega- tive Flag will turn ON.
  • Page 324 ON when the leftmost bit is 1 as a result of the shift. OFF in all other cases. Precautions When ROLL(572) is executed, the Error Flag will turn OFF. If as a result of the shift the contents of Wd and Wd +1 are zero, the Equals Flag will turn ON.
  • Page 325 Section 3-8 Data Shift Instructions If as a result of the shift the contents of the leftmost bit of Wd + 1 is 1, the Neg- ative Flag will turn ON. Note It is possible to set the Carry Flag contents to 1 or 0 immediately before exe- cuting this instruction, by using the Set Carry (STC(040)) or Clear Carry (CLC(041)) instructions.
  • Page 326 If as a result of the shift the contents of Wd is zero, the Equals Flag will turn If as a result of the shift the contents of the leftmost bit of Wd is 1, the Nega- tive Flag will turn ON.
  • Page 327 Section 3-8 Data Shift Instructions 3-8-12 DOUBLE ROTATE RIGHT: RORL(573) Purpose Shifts all Wd and Wd +1 bits one bit to the right including the Carry Flag (CY). Ladder Symbol RORL(573) Wd: Word Variations Variations Executed Each Cycle for ON Condition...
  • Page 328 If as a result of the shift the contents of Wd and Wd +1 are zero, the Equals Flag will turn ON. If as a result of the shift the contents of the leftmost bit of Wd + 1 is 1, the Neg- ative Flag will turn ON.
  • Page 329 If as a result of the shift the contents of Wd is zero, the Equals Flag will turn If as a result of the shift the contents of the leftmost bit of Wd is 1, the Nega- tive Flag will turn ON.
  • Page 330 0.00 1000 Wd: CIO 1000 Instruction executed once 3-8-14 DOUBLE ROTATE LEFT WITHOUT CARRY: RLNL(576) Purpose Shifts all Wd and Wd +1 bits one bit to the left not including the Carry Flag (CY). Ladder Symbol RLNL(576) Wd: Word Variations...
  • Page 331 If as a result of the shift the contents of Wd and Wd +1 are zero, the Equals Flag will turn ON. If as a result of the shift the contents of the leftmost bit of Wd + 1 is 1, the Neg- ative Flag will turn ON.
  • Page 332 3-8-15 ROTATE RIGHT WITHOUT CARRY: RRNC(575) Purpose Shifts all Wd bits one bit to the right not including the Carry Flag (CY). The contents of the rightmost bit of Wd shifts to the leftmost bit and to the Carry Flag (CY).
  • Page 333 If as a result of the shift the contents of Wd is zero, the Equals Flag will turn If as a result of the shift the contents of the leftmost bit of Wd is 1, the Nega- tive Flag will turn ON.
  • Page 334 If as a result of the shift the contents of Wd and Wd +1 are zero, the Equals Flag will turn ON. If as a result of the shift the contents of the leftmost bit of Wd + 1 is 1, the Neg- ative Flag will turn ON.
  • Page 335 Section 3-8 Data Shift Instructions Examples When CIO 0.01 is ON, words CIO 2000 and CIO 2001 will shift one bit to the right, (excluding the Carry Flag (CY)). The contents of CIO 2001.00 will be shifted to CIO 2000.15.
  • Page 336 When CIO 0.00 is ON, words CIO 1000 through CIO 1002 will shift by one digit (4 bits) to the left. A zero will be placed in bits 0 to 3 of word CIO 1000 and the contents of bits 12 to 15 of CIO 1002 will be lost.
  • Page 337 ,–(– –)IR0 to, –(– –)IR15 Description SRD(075) shifts data between St and E by one digit (4 bits) to the right. “0” is placed in the leftmost digit (bits 15 to 12 of E), and the content of the rightmost digit (bits 3 to 0 of St) is lost.
  • Page 338 When CIO 0.00 is ON, words CIO 1000 through CIO 1002 will shift by one digit (4 bits) to the right. A zero will be placed in bits 12 to 15 of CIO 1002 and the contents of bits 0 to 3 of word CIO 1000 will be lost.
  • Page 339 (B hex) will be shifted one bit to the left (from the rightmost bit to the leftmost bit). “0” will be placed into bit 3 of CIO 100. The contents of the leftmost bit in the shift area (bit 13 of CIO 100) are copied into the Carry Flag (CY).
  • Page 340 Operands C: 0000 to 000F hex (0 to 15) N: 0000 to FFFF hex (0 to 65535) Note All words in the shift register must be in the same area. Operand Specifications Area CIO Area CIO 0 to CIO 6143...
  • Page 341 Examples When CIO 0.00 is ON, all bits from the beginning bit 2 to end of the shift data length 11 bits (B hex), will be shifted one bit to the right , (from the leftmost bit to the rightmost bit).
  • Page 342: Specified Values Only

    Section 3-8 Data Shift Instructions 3-8-21 SHIFT N-BITS LEFT: NASL(580) Purpose Shifts the specified 16 bits of word data to the left by the specified number of bits. Ladder Symbol NASL(580) D: Shift word C: Control word Variations Variations Executed Each Cycle for ON Condition...
  • Page 343 If as a result of the shift the contents of D is 0000 hex, the Equals Flag will turn ON. If as a result of the shift the contents of the leftmost bit of D is 1, the Negative Flag will turn ON.
  • Page 344 No. of bits to shift: 10 bits (Contents of the rightmost bit is inserted.) 3-8-22 DOUBLE SHIFT N-BITS LEFT: NSLL(582) Purpose Shifts the specified 32 bits of word data to the left by the specified number of bits. Ladder Symbol NSLL(582) D: Shift word...
  • Page 345 NSLL(582) shifts D and D+1 (the shift words) by the specified number of binary bits (specified in C) to the left (from the rightmost bit to the leftmost bit). Either zeros or the value of the rightmost bit will be placed into the specified number of bits of the shift word starting from the rightmost bit.
  • Page 346 If as a result of the shift the contents of D is 0000, the Equals Flag will turn If as a result of the shift the contents of the leftmost bit of D, D+1 is 1, the Neg- ative Flag will turn ON.
  • Page 347 Data Shift Instructions Examples When CIO 0.00 is ON, CIO 1000 and CIO 1001 will be shifted to the left (from the rightmost bit to the leftmost bit) by 10 bits. The number of bits to shift is specified in bits 0 to 7 of word D300 (control data). The contents of bit 0 of...
  • Page 348 NASR(581) shifts D (the shift word) by the specified number of binary bits (specified in C) to the right (from the rightmost bit to the leftmost bit). Either zeros or the value of the rightmost bit will be placed into the specified number of bits of the shift word starting from the rightmost bit.
  • Page 349 If as a result of the shift the contents of D is 0000 hex, the Equals Flag will turn ON. If as a result of the shift the contents of the leftmost bit of D is 1, the Negative Flag will turn ON.
  • Page 350 No. of bits to shift: 10 bits (Contents of the leftmost bit is inserted.) 3-8-24 DOUBLE SHIFT N-BITS RIGHT: NSRL(583) Purpose Shifts the specified 32 bits of word data to the right by the specified number of bits. Ladder Symbol NSRL(583)
  • Page 351 If as a result of the shift the contents of D +1 is 00000000 hex, the Equals Flag will turn ON. If as a result of the shift the contents of the leftmost bit of D +1 is 1, the Nega- tive Flag will turn ON.
  • Page 352 Data Shift Instructions Examples When CIO 0.00 is ON, CIO 1000 and CIO 1001 will be shifted 10 bits to the right (from the leftmost bit to the rightmost bit). The number of bits to shift is specified in bits 0 to 7 of word D300 (control data). The contents of bit 15 of...
  • Page 353: Increment/Decrement Instructions

    ++BL DECREMENT BCD – –B DOUBLE DECREMENT BCD – –BL 3-9-1 INCREMENT BINARY: ++(590) Purpose Increments the 4-digit hexadecimal content of the specified word by 1. Ladder Symbol ++(590) Wd: Word Variations Variations Executed Each Cycle for ON Condition ++(590)
  • Page 354 OFF to ON. The Equals Flag will be turned ON if the result is 0000, the Carry Flag will be turned ON when a digit changes from F to 0, and the Negative Flag will be turned ON when bit 15 of Wd is ON in the result.
  • Page 355 Section 3-9 Increment/Decrement Instructions Operation of @++(590) The up-differentiated variation is used in the following example, so the content of D100 will be incremented by 1 only when CIO 0.00 has gone from OFF to 0.00 Incremented only for up-differentiation.
  • Page 356 The Equals Flag will be turned ON if the result is 0000 0000, the Carry Flag will be turned ON when a digit changes from F to 0, and the Negative Flag will be turned ON if bit 15 of Wd+1 is ON in the result.
  • Page 357 Section 3-9 Increment/Decrement Instructions Operation of @++L(591) The up-differentiated variation is used in the following example, so the content of D101 and D100 will be incremented by 1 only when CIO 0.00 has gone from OFF to ON. 0.00 @++L Incremented only for up-differentiation.
  • Page 358 OFF to ON. The Equals Flag will be turned ON if the result is 0000, the Carry Flag will be turned ON when a digit changes from 0 to F, and the Negative Flag will be turned ON if bit 15 of Wd is ON in the result.
  • Page 359 Section 3-9 Increment/Decrement Instructions Operation of @– –(592) The up-differentiated variation is used in the following example, so the content of D100 will be decremented by 1 only when CIO 0.00 has gone from OFF to 0.00 Decremented only for up-differentiation.
  • Page 360 The Equals Flag will be turned ON if the result is 0000 0000, the Carry Flag will be turned ON when a digit changes from 0 to F, and the Negative Flag will be turned ON if bit 15 of Wd+1 is ON in the result.
  • Page 361 Increment/Decrement Instructions Operation of @– –L(593) The up-differentiated variation is used in the following example, so the content of D201 and D200 will be decremented by 1 only when CIO 0.01 has gone from OFF to ON. Decremented only for up-differentiation.
  • Page 362 ON if a digit in Wd went from 9 to 0 during execution. OFF in all other cases. Precautions The content of Wd must be BCD. If it is not BCD, an error will occur and the Error Flag will be turned ON. Examples...
  • Page 363 Section 3-9 Increment/Decrement Instructions Operation of @++B(594) The up-differentiated variation is used in the following example, so the content of D100 will be incremented by 1 only when CIO 0.00 has gone from OFF to 0.00 Incremented only for @++B up-differentiation.
  • Page 364 ON if a digit in Wd+1 or Wd went from 9 to 0 during exe- cution. OFF in all other cases. Precautions The content of Wd+1 and Wd must be BCD. If it is not BCD, an error will occur and the Error Flag will be turned ON. Examples Operation of ++BL(595) In the following example, the 8-digit BCD content of D201 and D200 will be incremented by 1 every cycle as long as CIO 0.01 is ON.
  • Page 365 Increment/Decrement Instructions Operation of @++BL(595) The up-differentiated variation is used in the following example, so the BCD content of D201 and D200 will be incremented by 1 only when CIO 0.01 has gone from OFF to ON. Incremented only for 0.01...
  • Page 366 ON if a digit in Wd went from 0 to 9 during execution. OFF in all other cases. Precautions The content of Wd must be BCD. If it is not BCD, an error will occur and the Error Flag will be turned ON. Examples Operation of –...
  • Page 367 Section 3-9 Increment/Decrement Instructions Operation of @– –B(596) The up-differentiated variation is used in the following example, so the BCD content of D1000 will be decremented by 1 only when CIO 0.00 has gone from OFF to ON. 0.00 Decremented only for up-differentiation.
  • Page 368 ON if a digit in Wd+1 or Wd went from 0 to 9 during exe- cution. OFF in all other cases. Precautions The content of Wd+1 and Wd must be BCD. If it is not BCD, an error will occur and the Error Flag will be turned ON. Examples Operation of – –BL(597) In the following example, the 8-digit BCD content of D2001 and D2000 will be decremented by 1 every cycle as long as CIO 0.01 is ON.
  • Page 369: Symbol Math Instructions

    Symbol Math Instructions Operation of @– –BL(597) The up-differentiated variation is used in the following example, so the BCD content of D2001 and D2000 will be decremented by 1 only when CIO 0.01 has gone from OFF to ON. Decremented only for up-differentiation.
  • Page 370 DOUBLE SIGNED BINARY DIVIDE UNSIGNED BINARY DIVIDE DOUBLE UNSIGNED BINARY DIVIDE BCD DIVIDE DOUBLE BCD DIVIDE 3-10-1 SIGNED BINARY ADD WITHOUT CARRY: +(400) Purpose Adds 4-digit (single-word) hexadecimal data and/or constants. Ladder Symbol +(400) Au: Augend word Ad: Addend word...
  • Page 371 If the result of adding two negative numbers is positive (in the range 0000 to 7FFF hex), the Underflow Flag will turn ON. If as a result of the addition, the content of the leftmost bit of R is 1, the Nega- tive Flag will turn ON.
  • Page 372 Section 3-10 Symbol Math Instructions Examples When CIO 0.00 is ON in the following example, D100 and D110 will be added as 4-digit signed binary values and the result will be output to D120. 0.00 D100 D110 D120 3-10-2 DOUBLE SIGNED BINARY ADD WITHOUT CARRY: +L(401) Purpose Adds 8-digit (double-word) hexadecimal data and/or constants.
  • Page 373 If the result of adding two negative numbers is positive (in the range 00000000 to 7FFFFFFF hex), the Underflow Flag will turn ON. If as a result of the addition, the content of the leftmost bit of R+1 is 1, the Negative Flag will turn ON.
  • Page 374 Section 3-10 Symbol Math Instructions 3-10-3 SIGNED BINARY ADD WITH CARRY: +C(402) Purpose Adds 4-digit (single-word) hexadecimal data and/or constants with the Carry Flag (CY). Ladder Symbol +C(402) Au: Augend word Ad: Addend word R: Result word Variations Variations Executed Each Cycle for ON Condition...
  • Page 375 If the result of adding two negative numbers and CY is positive (in the range 0000 to 7FFF hex), the Underflow Flag will turn ON. If as a result of the addition, the content of the leftmost bit of R is 1, the Nega- tive Flag will turn ON.
  • Page 376 Section 3-10 Symbol Math Instructions 3-10-4 DOUBLE SIGNED BINARY ADD WITH CARRY: +CL(403) Purpose Adds 8-digit (double-word) hexadecimal data and/or constants with the Carry Flag (CY). Ladder Symbol +CL(403) Au: 1st augend word Ad: 1st addend word R: 1st result word...
  • Page 377 If the result of adding two negative numbers and CY is positive (in the range 00000000 to 7FFFFFFF hex), the Underflow Flag will turn ON. If as a result of the addition, the content of the leftmost bit of R+1 is 1, the Negative Flag will turn ON.
  • Page 378 –2048 to +2047 ,IR0 to –2048 to +2047 ,IR15 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description +B(404) adds the BCD values in Au and Ad and outputs the result to R. (BCD) (BCD) CY will turn (BCD) ON when there is a carry.
  • Page 379 OFF in all other cases. Precautions If Au or Ad is not BCD, an error is generated and the Error Flag will turn ON. If as a result of the addition, the content of R is 0000 hex, the Equals Flag will turn ON.
  • Page 380 OFF in all other cases. Precautions If Au, Au +1 or Ad, Ad +1 are not BCD, an error is generated and the Error Flag will turn ON. If as a result of the addition, the content of R, R +1 is 00000000 hex, the Equals Flag will turn ON.
  • Page 381 –2048 to +2047 ,IR0 to –2048 to +2047 ,IR15 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description +BC(406) adds BCD values in Au, Ad, and CY and outputs the result to R. (BCD) (BCD) CY will turn (BCD) ON when there is a carry.
  • Page 382 OFF in all other cases. Precautions If Au or Ad is not BCD, an error is generated and the Error Flag will turn ON. If as a result of the addition, the content of R is 0000 hex, the Equals Flag will turn ON.
  • Page 383 OFF in all other cases. Precautions If Au, Au +1 or Ad, Ad +1 are not BCD, an error is generated and the Error Flag will turn ON. If as a result of the addition, the content of R, R +1 is 00000000 hex, the Equals Flag will turn ON.
  • Page 384 32768 to 32767 (signed decimal) Data Registers DR0 to DR15 Index Registers Indirect addressing ,IR0 to ,IR15 using Index Registers –2048 to +2047 ,IR0 to –2048 to +2047 ,IR15 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15...
  • Page 385 If the result of subtracting a positive number from a negative number is posi- tive (in the range 0000 to 7FFF hex), the Underflow Flag will turn ON. If as a result of the subtraction, the content of the leftmost bit of R is 1, the Negative Flag will turn ON.
  • Page 386 2147483648 to 2147483647 (signed decimal) Data Registers Index Registers IR0 to IR15 Indirect addressing ,IR0 to ,IR15 using Index Registers –2048 to +2047 ,IR0 to –2048 to +2047 ,IR15 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15...
  • Page 387 If the result of subtracting a positive number from a negative number is posi- tive (in the range 00000000 to 7FFFFFFF hex), the Underflow Flag will turn If as a result of the subtraction, the content of the leftmost bit of R+1 is 1, the Negative Flag will turn ON.
  • Page 388 CIO 201 and CIO 200, and the result is output in eight-digit binary to CIO 301 and CIO 300. If the result is negative, the instruc- tion at (2) will be executed, and the actual result will then be output to CIO 301 and CIO 300.
  • Page 389 R+1: CIO 301 R+1: CIO 300 The Carry Flag (CY) is turned ON, so the actual number is –97AE06D3. Because the content of CIO 301 and CIO 300 is negative, CY is used to turn ON CIO 302.00 to indicate this.
  • Page 390 Section 3-10 Symbol Math Instructions 3-10-11 SIGNED BINARY SUBTRACT WITH CARRY: –C(412) Purpose Subtracts 4-digit (single-word) hexadecimal data and/or constants with the Carry Flag (CY). Ladder Symbol C(412) Mi: Minuend word Su: Subtrahend word R: Result word Variations Variations Executed Each Cycle for ON Condition –C(412)
  • Page 391 If the result of subtracting a positive number and CY from a negative number is positive (in the range 0000 to 7FFF hex), the Underflow Flag will turn ON. If as a result of the subtraction, the content of the leftmost bit of R is 1, the Negative Flag will turn ON.
  • Page 392 Section 3-10 Symbol Math Instructions 3-10-12 DOUBLE SIGNED BINARY SUBTRACT WITH CARRY: –CL(413) Purpose Subtracts 8-digit (double-word) hexadecimal data and/or constants with the Carry Flag (CY). Ladder Symbol –CL(413) Mi: Minuend word Su: Subtrahend word R: Result word Variations Variations Executed Each Cycle for ON Condition –CL(413)
  • Page 393 If the result of subtracting a positive number and CY from a negative number is positive (in the range 00000000 to 7FFFFFFF hex), the Underflow Flag will turn ON. If as a result of the subtraction, the content of the leftmost bit of R+1 is 1, the Negative Flag will turn ON. Note To clear the Carry Flag (CY), execute the Clear Carry (CLC(041)) instruction.
  • Page 394 If the result of the subtraction is a negative number (Mi<Su or Mi+1, Mi <Su+1, Su), the result is output as a 2’s complement. The Carry Flag (CY) will turn ON. To convert the 2’s complement to the true number, a program which subtracts the result from 0 is necessary, as an input condition of the Carry Flag (CY).
  • Page 395 OFF in all other cases. Precautions If Mi and/or Su are not BCD, an error is generated and the Error Flag will turn If as a result of the subtraction, the content of R is 0000 hex, the Equals Flag will turn ON.
  • Page 396 ,–(– –)IR0 to, –(– –)IR15 Description –BL(415) subtracts the BCD values in Su and Su+1 from Mi and Mi+1 and outputs the result to R, R+1. If the result is negative, it is output to R, R+1 as a 10’s complement. (BCD)
  • Page 397 9999 – 7556 + 1 = 2444. For a four digit number, the 10’s complement of A is 9999 – A + 1 = B. To obtain the true number from the 10’s complement B: A = 10000 – B. For example, to obtain the true number from the 10’s complement 2444: 10000 –...
  • Page 398 R+1: CIO 301 R+1: CIO 300 The Carry Flag (CY) will be turned ON, so the actual number is –7,488,681. Because the content of CIO 301 and CIO 300 is negative, CY is used to turn ON CIO 302.00 to indicate this.
  • Page 399 Section 3-10 Symbol Math Instructions 3-10-15 BCD SUBTRACT WITH CARRY: –BC(416) Purpose Subtracts 4-digit (single-word) BCD data and/or constants with the Carry Flag (CY). Ladder Symbol –BC(416) Mi: Minuend word Su: Subtrahend word R: Result word Variations Variations Executed Each Cycle for ON Condition –BC(416)
  • Page 400 OFF in all other cases. Precautions If Mi and/or Su are not BCD, an error is generated and the Error Flag will turn If as a result of the subtraction, the content of R is 0000 hex, the Equals Flag will turn ON.
  • Page 401 ,–(– –)IR0 to, –(– –)IR15 Description –BCL(417)subtracts the BCD values in Su, Su+1, and CY from Mi and Mi+1 and outputs the result to R, R+1. If the result is negative, it is output to R, R+1 as a 10’s complement. (BCD)
  • Page 402 9999 – 7556 + 1 = 2444. For a four digit number, the 10’s complement of A is 9999 – A + 1 = B. To obtain the true number from the 10’s complement B: A = 10000 – B. For example, to obtain the true number from the 10’s complement 2444: 10000 –...
  • Page 403 If as a result of the multiplication, the content of R is 0000 hex, the Equals Flag will turn ON. If as a result of the multiplication, the content of the leftmost bit of R+1 and R is 1, the Negative Flag will turn ON.
  • Page 404 Section 3-10 Symbol Math Instructions Examples When CIO 0.00 is ON in the following example, D100 and D110 will be multi- plied as 4-digit signed hexadecimal values and the result will be output to D121 and D120. 0.00 D100 D110...
  • Page 405 If as a result of the multiplication, the content of R, R+1, R+2, R+3 is 0000 hex, the Equals Flag will turn ON. If as a result of the multiplication, the content of the leftmost bit of R+1 is 1, the Negative Flag will turn ON.
  • Page 406 –2048 to +2047 ,IR0 to –2048 to +2047 ,IR15 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description *U(420) multiplies the binary values in Md and Mr and outputs the result to R, R+1. (Unsigned binary) (Unsigned binary) (Unsigned binary)
  • Page 407 If as a result of the multiplication, the content of R, R+1 is 0000 hex, the Equals Flag will turn ON. If as a result of the multiplication, the content of the leftmost bit of R+1 is 1, the Negative Flag will turn ON.
  • Page 408 If as a result of the multiplication, the content of R to R+3 is 0000 hex, the Equals Flag will turn ON. If as a result of the multiplication, the content of the leftmost bit of R to R+3 is 1, the Negative Flag will turn ON.
  • Page 409 ON when Mr is not BCD. OFF in all other cases. Equals Flag ON when the result is 0. OFF in all other cases. Precautions If Md and/or Mr are not BCD, an error will be generated and the Error Flag will turn ON.
  • Page 410 Section 3-10 Symbol Math Instructions If as a result of the multiplication, the content of R, R+1 is 0000 hex, the Equals Flag will turn ON. Examples When CIO 0.00 is ON in the following example, D100 and D110 will be multi- plied as 4-digit BCD values and the result will be output to D121 and D120.
  • Page 411 OFF in all other cases. Precautions If Md, Md+1 and/or Mr, Mr+1 are not BCD, an error will be generated and the Error Flag will turn ON. If as a result of the multiplication, the content of R, R+1, R+2, R+3 is 0000 hex, the Equals Flag will turn ON.
  • Page 412 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description /(430) divides the signed binary (16 bit) values in Dd by those in Dr and out- puts the result to R, R+1. The quotient is placed in R and the remainder in R+1.
  • Page 413 If as a result of the division, the content of R is 0000 hex, the Equals Flag will turn ON. If as a result of the division, the content of the leftmost bit of R is 1, the Nega- tive Flag will turn ON.
  • Page 414 If as a result of the division, the content of R+1, R is 00000000 hex, the Equals Flag will turn ON. If as a result of the division, the content of the leftmost bit of R+1, R is 1, the Negative Flag will turn ON.
  • Page 415 When CIO 0.01 is ON in the following example, D201 and D200 will be divided by D211 and D210 as 8-digit signed hexadecimal values, the quotient will be output to D221 and D220, and the remainder will be output to D223 and D222.
  • Page 416 If as a result of the division, the content of R is 0000 hex, the Equals Flag will turn ON. If as a result of the division, the content of the leftmost bit of R is 1, the Nega- tive Flag will turn ON.
  • Page 417 (unsigned deci- (unsigned deci- mal) mal) Data Registers Index Registers Indirect addressing ,IR0 to ,IR15 using Index Registers –2048 to +2047 ,IR0 to –2048 to +2047 ,IR15 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15...
  • Page 418 If as a result of the division, the content of R, R+1, is 0000 hex, the Equals Flag will turn ON. If as a result of the division, the content of the leftmost bit of R+1 is 1, the Neg- ative Flag will turn ON.
  • Page 419 OFF in all other cases. Precautions If Dd or Dr are not BCD or if the remainder (R+1) is 0, an error will be gener- ated and the Error Flag will turn ON. If as a result of the division, the content of R is 0000 hex, the Equals Flag will turn ON.
  • Page 420 Section 3-10 Symbol Math Instructions Examples When CIO 0.00 is ON in the following example, D100 will be divided by D110 as 4-digit BCD values and the quotient will be output to D120 and the remain- der to D121. 0.00...
  • Page 421 OFF in all other cases. Precautions If Dd, Dd+1 and/or Dr, Dr+1 are not BCD or the content of Dr, Dr+1 is 0, an error will be generated and the Error Flag will turn ON. If as a result of the division, the content of R, R+1 is 00000000 hex, the Equals Flag will turn ON.
  • Page 422: Conversion Instructions

    Section 3-11 Conversion Instructions 3-11 Conversion Instructions This section describes instructions used for data conversion. Instruction Mnemonic Function code Page BCD-TO-BINARY DOUBLE BCD-TO-DOUBLE BINL BINARY BINARY-TO-BCD DOUBLE BINARY-TO-DOU- BCDL BLE BCD 2’S COMPLEMENT DOUBLE 2’S COMPLEMENT NEGL 16-BIT TO 32-BIT SIGNED...
  • Page 423 –2048 to +2047 ,IR0 to –2048 to +2047 ,IR15 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description BIN(023) converts the BCD data in S to binary data and writes the result to R. (BCD) (BIN) Flags Name...
  • Page 424 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description BINL(058) converts the 8-digit BCD data in S and S+1 to 8-digit hexadecimal (32-bit binary) data and writes the result to R and R+1. (BCD) (BCD)
  • Page 425 Examples The following diagram shows an example of 8-digit BCD-to-binary conversion. When CIO 0.00 is ON in the following example, the 8-digit BCD value in CIO 201 and CIO 200 is converted to hexadecimal and stored in D1001 and D1000.
  • Page 426 –2048 to +2047 ,IR0 to –2048 to +2047 ,IR15 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description BCD(024) converts the binary data in S to BCD data and writes the result to (BIN) (BCD) Flags Name...
  • Page 427 Step program areas Subroutines Interrupt tasks Operands S: First Source Word The content of S+1 and S must be between 0000 0000 and 05F5 E0FF hexa- decimal (0000 0000 and 9999 9999 decimal). Operand Specifications Area CIO Area CIO 0 to CIO 6142...
  • Page 428 The following diagram shows an example of 8-digit BCD-to-binary conversion. When CIO 0.00 is ON in the following example, the hexadecimal value in CIO 201 and CIO 200 is converted to a BCD value and stored in D1001 and D1000.
  • Page 429 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description NEG(160) calculates the 2’s complement of S and writes the result to R. The 2’s complement calculation basically reverses the status of the bits in S and adds 1. 2's complement...
  • Page 430 S+1 and S and adds 1. 2's complement (Complement + 1) (S+1, S) (R+1, R) Note This operation (reversing the status of the bits and adding 1) is equivalent to subtracting the content of S+1 and S from 0000 0000.
  • Page 431 Note The result for 8000 hex will be 8000 hex. Example When CIO 0.01 is ON in the following example, NEGL(161) calculates the 2’s complement of the content of D1001 and D1000 and writes the result to D2001 and D2000.
  • Page 432 R+1 and R. The conversion is accomplished by copying the content of S to R and writing FFFF to R+1 if bit 15 of S is 1 or writing 0000 to R+1 if bit 15 of S is 0. Source word (S) If bit 15 of S is 1, FFFF is transferred to R+1.
  • Page 433 Subroutines Interrupt tasks Operands S: Source Word The data in the source word indicates the location of the bit(s) that will be turned ON. C: Control Word The control word specifies whether MLPX(076) will perform a 4-to-16 bit con- version or an 8-to-256 bit conversion, the number of digits or bytes to be con- verted, and the starting digit or byte.
  • Page 434 ,–(– –)IR0 to, –(– –)IR15 Description MLPX(076) can perform 4-to-16 bit or 8-to-256 bit conversions. Set the left- most digit of C to 0 to specify 4-to-16 bit conversion and set it to 1 to specify 8- to-256 bit conversion. 4-to-16 bit Conversion When the leftmost digit of C is 0, MLPX(076) takes the value of the specified digit in S (0 to F) and turns ON the corresponding bit in the result word.
  • Page 435 When the leftmost digit of C is 1, MLPX(076) takes the value of the specified byte in S (00 to FF) and turns ON the corresponding bit in the range of 16 result words. All other bits in the result words will be turned OFF. Up to two bytes can be converted.
  • Page 436 4-to-16 bit Conversion When CIO 0.00 is ON in the following example, MLPX(076) will convert 3 dig- its in CIO 200 beginning the second digit, as indicated by C (#0021). The cor- responding bits in D100 to D102 will be turned ON.
  • Page 437 Conversion Instructions 3-11-9 DATA ENCODER: DMPX(077) Purpose FInds the location of the first or last ON bit within the source word (or 16-word range), and writes that value to the specified digit (or byte) in the result word. Ladder Symbol...
  • Page 438 ,–(– –)IR0 to, –(– –)IR15 Description DMPX(077) can perform 16-to-4 bit or 256-to-8 bit conversions. Set the left- most digit of C to 0 to specify 16-to-4 bit conversion and set it to 1 to specify 256-to-8 bit conversion. 16-to-4 bit Conversion...
  • Page 439 16-word ranges of source words. The locations of these bits are written to R beginning with the specified byte. (Set the third digit of C to 0 to find the leftmost ON bits or 1 to find the rightmost ON bits.) l =0 (Convert one 16-word range.)
  • Page 440 When CIO 0.00 is ON in the following example, DMPX(077) will find the left- most ON bits in CIO 200 to C202 and write those locations to 3 digits in R beginning with the second digit, as indicated by C (#0021).
  • Page 441 The converted ASCII data is written to the destination word(s) beginning with the specified byte in D. Three destination words (D to D+3) will be required if 4 digits are being converted and the leftmost byte is selected as the first byte in D.
  • Page 442 Right (0) Parity It is possible to specify the parity of the ASCII data for use in error control dur- ing data transmissions. The leftmost bit of each ASCII character will be auto- matically adjusted for even, odd, or no parity.
  • Page 443 When two or more digits are being converted, ASC(086) will read the bytes in S from right to left and will wrap around to the rightmost byte if necessary. The following diagram shows some example values for Di and the conversions that they produce.
  • Page 444 D: D200 D201 3-11-11 ASCII TO HEX: HEX(162) Purpose Converts up to 4 bytes of ASCII data in the source word to their hexadecimal equivalents and writes these digits in the specified destination word. Ladder Symbol HEX(162) S: First source word...
  • Page 445 D: Destination word The converted hexadecimal digits are written into D from right to left, begin- ning with the specified first digit. Any digits in the destination word that are not overwritten with the converted data will be left unchanged.
  • Page 446 First digit to write Parity It is possible to specify the parity of the ASCII data for use in error control dur- ing data transmissions. The leftmost bit in each byte is the parity bit. With no parity the parity bit should always be zero, with even parity the status of the parity bit should result in an even number of ON bits, and with odd parity the status of the parity bit should result in an odd number of ON bits.
  • Page 447 OFF in all other cases. Precautions An error will occur and the Error Flag will be turned ON if there is a parity error in the ASCII data, the ASCII data in the source words is not equivalent to hexadecimal digits, or the content of Di is not within the specified ranges.
  • Page 448 S: First Source Word Specifies the first source word. S and S+15 must be in the same data area. N: Bit Number Specifies the bit number (0000 to 000F or &0 to &15) to be copied from the source words.
  • Page 449 S+15 to the destination word D. Bit N of S+m is copied to bit m of D, i.e., bit N of S is copied to bit 00 of D and bit N of S+15 is copied to bit 15 of D.
  • Page 450 D115 D: D200 3-11-13 LINE TO COLUMN: COLM(064) Purpose Converts the 16 bits of the source word to a column of bits in a 16-word range of destination words (the same bit number in 16 consecutive words). Ladder Symbol COLM(064)
  • Page 451 COLM(064) copies the 16 bits from S to the 16 bits with bit number N in the 16-word range D to D+15. Bit m of S is copied to bit N of D+m, i.e., bit 00 of S is copied to bit N of D and bit 15 of S is copied to bit N of D+15.
  • Page 452 Section 3-11 Conversion Instructions Example When CIO 0.00 is ON in the following example, COLM(064) copies the 16 bits in D200 (bits 00 through 15) to bit 5 in D100 through D115. 0.00 D200 D100 S: D200 D: D100 D101...
  • Page 453 Refer to 3-11-5 2’S COMPLEMENT: NEG(160)395 for details. A value of –0 in the source data will be treated as 0 and will not cause an error. Also, the status of bits 13 to 15 of S is not checked when C=0000.
  • Page 454 When CIO 0.00 is ON in the following example, the signed BCD data format and range in D100 are checked against the format specified in the control word (0000). The source data is correct, so the signed BCD data in D100 is converted to signed binary and output to D200.
  • Page 455 When CIO 0.01 is ON in the following example, the signed BCD data format and range in D300 are checked against the format specified in the control word (0003). The source data is correct, so the signed BCD data in D300 is converted to signed binary and output to D400.
  • Page 456 3-11-6 DOUBLE 2’S COMPLEMENT: NEGL(161) for details. Values of –0 in the source data will be treated as 0 and will not cause an error. Also, the status of bits 13 to 15 of S+1 is not checked when C=0000.
  • Page 457 OFF in all other cases. Example When CIO 0.00 is ON in the following example, the double signed BCD data format and range in D101 and D100 are checked against the format specified in the control word (0002). The source data is correct, so the double signed BCD data in D101 and D100 is converted to double signed binary and output to D201 and D200.
  • Page 458 Specifies the signed BCD format. C must be 0000 to 0003. S: Source Word Contains the signed binary data to be converted. The content of S must be within the valid range of the BCD format specified in C. Setting...
  • Page 459 BCDS(471) converts signed binary data to signed BCD data. First the signed binary data in word S is checked to verify that it is within the valid range for the signed BCD format specified in the control word (C). If the source data is cor- rect, the signed binary data in S is converted to signed BCD and output to D.
  • Page 460 A: Negative (–1) F: Negative (–) The following table shows the possible signed binary values for each signed BCD format. An error will occur if the source data is not within the allowed range for the specified signed BCD format. Setting...
  • Page 461 BDSL(473) converts double signed binary data to double signed BCD data. First the double signed binary data in S+1 and S is checked to verify that it is within the valid range for the signed BCD format specified in the control word (C).
  • Page 462 Section 3-11 Conversion Instructions Note Values of –0 in the source data will be treated as 0 and will not cause an error. The control word specifies the signed BCD format that will be used for the result, as shown below.
  • Page 463 ON if C=0000 or 0001 and the result’s sign bit is ON after execution. ON if C=0002 and the leftmost digit of the result is F. ON if C=0003 and the leftmost digit of the result is A or F. OFF in all other cases. Example When CIO 0.00 is ON in the following example, the double signed binary data...
  • Page 464 User-specified Resolution 0 hex = 256, 1 hex = 360, 2 hex = 720, 3 hex = 1,024, 4 to F hex = Do not use. Note: The above setting is valid when the resolution is set to 0 hex in bits 00 to 03 of C.
  • Page 465 ) from an absolute encoder that outputs a gray binary code. (2) If the word specified for S is allocated to an Input Unit, the input data con- verted by GRY(474) will be for the gray binary code from the previous...
  • Page 466 OFF in all cases. Examples When CIO 0.00 is ON in the following example, the gray binary code in CIO 1000 is converted according to the settings in the control data in D0 to D2 and the result is output to D200. 0.00...
  • Page 467 Section 3-11 Conversion Instructions ■ Example 2: Converting to Angle Data with a 10-bit Resolution and Zero Point Offset of 0151 Hex C: D0 Resolution: 10-bit Conversion mode: 360 Mode Operating mode: Gray binary code conversion C+1: D1 0151 Zero point offset: 0151 hex C+2: D2 User-specified resolution: Not used.
  • Page 468 Section 3-11 Conversion Instructions ■ Example 4: Converting to BCD Data with for an OMRON E6C2-AG5C Absolute Encoder (Resolution: 360/rotation, Encoder Remainder Compensation: 76) and Zero Point Offset of 000A Hex C: D0 Resolution: User-specified Conversion mode: BCD Mode Operating mode: Gray binary code conversion...
  • Page 469: Logic Instructions

    DOUBLE EXCLUSIVE NOR XNRL COMPLEMENT DOUBLE COMPLEMENT COML 3-12-1 LOGICAL AND: ANDW(034) Purpose Takes the logical AND of corresponding bits in single words of word data and/ or constants. Ladder Symbol ANDW(034) : Input 1 : Input 2 R: Result word...
  • Page 470 If as a result of the AND, the content of R is 0000 hex, the Equals Flag will turn ON. If as a result of the AND, the leftmost bit of R is 1, the Negative Flag will turn 3-12-2 DOUBLE LOGICAL AND: ANDL(610)
  • Page 471 ON when the leftmost bit of R is 1. OFF in all other cases. Precautions When ANDL(610) is executed, the Error Flag will turn OFF. If as a result of the AND, the content of R, R+1 is 00000000 hex, the Equals Flag will turn ON.
  • Page 472 Section 3-12 Logic Instructions If as a result of the AND, the leftmost bit of R+1 is 1, the Negative Flag will turn ON. Examples When the execution condition CIO 0.00 is ON, the logical AND will be taken of corresponding bits in CIO 1001, CIO 1000 and CIO 2001, CIO 2000 and the results will be output to corresponding bits in D201 and D200.
  • Page 473 When ORW(035) is executed, the Error Flag will turn OFF. If as a result of the OR, the content of R is 0000 hex, the Equals Flag will turn If as a result of the OR, the leftmost bit of R is 1, the Negative Flag will turn...
  • Page 474 • When any of the corresponding bits in I +1, I and I +1are 1, a 1 will be output to the corresponding bit it R+1. When any of them are 0, a 0 will be output to the corresponding bit in R+1. +1) + (I (R, R+1)
  • Page 475 If as a result of the OR, the content of R, R+1 is 00000000 hex, the Equals Flag will turn ON. If as a result of the OR, the leftmost bit of R+1 is 1, the Negative Flag will turn Examples When the execution condition CIO 0.00 is ON, the logical OR will be taken of...
  • Page 476 When XORW(036) is executed, the Error Flag will turn OFF. If as a result of the OR, the content of R is 0000 hex, the Equals Flag will turn If as a result of the OR, the leftmost bit of R is 1, the Negative Flag will turn...
  • Page 477 • When the content of any of the corresponding bits in I +1, I and I +1are different, a 1 will be output to the corresponding bit it R, R+1. When any of them are the same, a 0 will be output to the corresponding bit in R, R+1.
  • Page 478 Precautions When XORL(612) is executed, the Error Flag will turn OFF. If as a result of the exclusive OR, the content of R, R+1 is 00000000 hex, the Equals Flag will turn ON. If as a result of the exclusive OR, the leftmost bit of R+1 is 1, the Negative Flag will turn ON.
  • Page 479 • When the content of corresponding bits of I and I are different, a 0 will be output to the corresponding bit of R and when they are different, 1 will be output to the corresponding bit in R.
  • Page 480 If as a result of the NOR, the content of R is 0000 hex, the Equals Flag will turn ON. If as a result of the NOR, the leftmost bit of R is 1, the Negative Flag will turn 3-12-8 DOUBLE EXCLUSIVE NOR: XNRL(613)
  • Page 481 Precautions When XNRL(613) is executed, the Error Flag will turn OFF. If as a result of the exclusive NOR, the content of R, R+1 is 00000000 hex, the Equals Flag will turn ON. If as a result of the exclusive NOR, the leftmost bit of R+1 is 1, the Negative Flag will turn ON.
  • Page 482 COM(029) reverses the status of every specified bit in Wd. Wd Wd: 1 0 and 0 Note When using the COM instruction, be aware that the status of each bit will change each cycle in which the execution condition is ON. Flags Name...
  • Page 483 When COM(029) is executed, the Error Flag will turn OFF. If as a result of COM, the content of R is 0000 hex, the Equals Flag will turn If as a result of COM, the leftmost bit of R is 1, the Negative Flag will turn ON. Examples When CIO 0.00 is ON in the following example, the status of each bit will be...
  • Page 484: Special Math Instructions

    If as a result of COML, the content of R, R+1 is 00000000 hex, the Equals Flag will turn ON. If as a result of COML, the leftmost bit of R+1 is 1, the Negative Flag will turn Examples When CIO 0.01 is ON in the following example, the status of each bit in D201 and D200 will be reversed.
  • Page 485 Binary data (32 bits) Binary data (16 bits) The range of data that can be specified for words S+1 and S is 0000 0000 to 3FFF FFFF. If a number from 4000 0000 to 7FFF FFFF is specified, it will be treated as 3FFF FFFF for the square root computation.
  • Page 486 If the input data is BCD, use the ROOT(072) instruction. Example When CIO 0.00 is ON in the following example, ROTB(620) calculates the square root of the data in CIO 1001 and CIO 1000, and writes the integer por- tion of the result in D100. CIO 1001 CIO 1000 0.00...
  • Page 487 ON if the result is 0000. OFF in all other cases. Precautions The operands of this instruction (S+1, S, and R) are all treated as BCD val- ues. If the input data is binary, use the ROTB(620) instruction. Examples Square Root of 8-digit Number When CIO 0.00 is ON in the following example, ROOT(072) calculates the...
  • Page 488 D103 @INC 2000 D103 1,2,3... 1. The source words (D101 and D100) to be are cleared to 0000 0000. 2. The 4-digit number is moved from CIO 1000 to D101. CIO 1000 D101 D100 3. ROOT(072) calculates the square root of D101 and D100 and writes the...
  • Page 489 CIO 2000 and the remainder going to D103. D102 CIO 2000 D103 6. If the content of D103 is greater than 4900, CIO 2000 is incremented by 1. In this case, the result is 78. 5600 > 4900 CIO 2000...
  • Page 490 3.402823 Note If C is a word address, APR(069) extrapolates the Y value for the X value in S based on coordinates (forming line segments) entered in advance in a table beginning at C. Refer to the Description section below for details.
  • Page 491 When C is 0000, APR(069) calculates the SIN(S) and writes the result to R. The range for S is 0000 to 0900 BCD (0.0 to 90.0 ) and the range for R is 0000 to 9999 BCD (0.0000 to 0.9999). The remainder of the result beyond the fourth decimal place is eliminated.
  • Page 492 C+1 through C+2m+2. If 32-bit binary or floating point data is being used, the line-segment data is contained in words C+1 through C+4m+4. Bits 00 to 07 contain the number (binary) of line coordinates less 1, m–1. Bits 08 to 12 are not used. Bit 13 specifies either f(x)=f(S) or f(x)=f(X –S): OFF...
  • Page 493 3. X < S Converted value = Y Up to 256 endpoints can be stored in the line-segment data table beginning at C+1. The following 5 kinds of I/O data can be used: • 16-bit unsigned BCD data • 16-bit unsigned binary data •...
  • Page 494 Setting the Data Format in Control Word C • 16-bit Unsigned BCD Data The input data and/or the output data can be 16-bit unsigned BCD data. Also, the linear extrapolation function can be set to operate on the value specified in S directly or on X –S.
  • Page 495 Section 3-13 Special Math Instructions Note If the “Data length specification for S and D” in bit 10 of C is set to 1 and a 16-bit constant is input for S, the input data will be convert- ed to 32-bit signed binary before the linear extrapolation calcula- tion.
  • Page 496 This example shows how to construct a linear extrapolation with 12 coordi- 0.00 nates. The block of data is continuous, as it must be, from D1000 to D1026 (C to C + (2 12 + 2)). The input data is taken from CIO 1000, and the result is D1000 output to CIO 1001.
  • Page 497 Section 3-13 Special Math Instructions In this case, the source word, CIO 1000, contains 0014, and f(0014) = 0726 is output to R, CIO 1001. $1F20 $0F00 (x,y) $0726 $0402 (0,0) $0005 $0014 $001A $05F0 The linear-extrapolation calculation is shown below.
  • Page 498 Special Math Instructions Linear Extrapolation (C: Word Address) Using 32-bit Signed Binary Data In this example, APR(069) is used to convert the fluid height in a tank to fluid volume based on the shape of the holding tank. Fluid height to volume...
  • Page 499 Special Math Instructions Linear Extrapolation (C: Word Address) Using Floating-point Data In this example, APR(069) is used to convert the fluid height in a tank to fluid volume based on the shape of the holding tank. X0 (rightmost 16 bits)
  • Page 500 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description FDIV(079) divides the floating-point value in Dd and Dd+1 by that in Dr and Dr+1 and places the result in R and R+1. Quotient Dr+1...
  • Page 501 The leftmost digit can range from 0 to F; positive exponents range from 0 to 7 and negative exponents range from 8 to F (0 to –7). The rightmost 7 digits must be BCD.
  • Page 502 Special Math Instructions Floating-point Division of Two BCD Numbers In this example, the 4-digit BCD number in D0 is divided by the 4-digit BCD number in D1 and the floating-point result is written to D2 and D3. To perform the floating point division, the BCD value in D0 is converted to floating-point format in D2001 and D2000 and the BCD value in D1 is con- verted to floating-point format in D2003 and D2002.
  • Page 503 Section 3-13 Special Math Instructions 1,2,3... 1. D2000 and D2002 are set to 0000 and D2001 and D2003 are set to 4000. Dividend Divisor D2001 D2000 D2003 D2002 #4000 transferred. #0000 transferred. (D2000 and D2002 cleared.) (3452 = 0.3452 x 10 0079 = 0.0079 x 10...
  • Page 504 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description BCNT(067) counts the total number of bits that are ON in all words between S and S+(N–1) and places the result in R. N words Counts the number of ON bits.
  • Page 505: Floating-Point Math Instructions

    Floating-point Math Instructions Section 3-14 Example When CIO 0.00 is ON in the following example, BCNT(067) counts the total number of ON bits in the 10 words from CIO 200 and CIO 209 and writes the result to D1000. 0.00 BCNT...
  • Page 506 The mantissa portion of binary floating-point data fits the formal 2.0 > 1.f 1.0. Number of Digits The number of effective digits for floating-point data is 24 bits for binary (approximately seven digits decimal). Floating-point Data The following data can be expressed by floating-point data: •...
  • Page 507 Example 31 30 23 22 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Sign: –...
  • Page 508 Example 31 30 23 22 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Sign: –...
  • Page 509 In this program example, the X-axis and Y-axis coordinates (x, y) are provided by 4-digit BCD content of D0 and D1. The distance (r) from the origin and the angle ( , in degrees) are found and output to D100 and D101. In the result, everything to the right of the decimal point is truncated.
  • Page 510 Floating-point Math Instructions Section 3-14 0.00 D200 D201 D200 D202 D201 D204 D202 D202 D206 D204 D204 D208 D206 D208 D210 D210 D212 D204 D202 D214 D214 D216 D216 D218 D212 D220 D218 D221 D220 D100 D221 D101...
  • Page 511 –1 calculate tan (y/x). ATAN(465) outputs the result in radians, so DEG(459) is used to convert to degrees. The result is then output to D219 and D218 as floating-point data. 4. The data is converted back from floating-point to BCD.
  • Page 512 Floating-point data (32 bits) Signed binary data (16 bits) Only the integer portion of the floating-point data is converted, and the fraction portion is truncated. The integer portion of the floating-point data must be within the range of –32,768 to 32,767.
  • Page 513 Section 3-14 Floating-point Math Instructions Precautions The content of S+1 and S must be floating-point data and the integer portion must be in the range of –32,768 to 32,767. 3-14-2 FLOATING TO 32-BIT: FIXL(451) Purpose Converts a 32-bit floating-point value to 32-bit signed binary data and places the result in the specified result words.
  • Page 514 ON if bit 15 of R+1 is ON after execution. OFF in all other cases. Precautions The content of S+1 and S must be floating-point data and the integer portion must be in the range of –2,147,483,648 to 2,147,483,647. 3-14-3 16-BIT TO FLOATING: FLT(452)
  • Page 515 Signed binary data (16 bits) Floating-point data (32 bits) Only values within the range of –32,768 to 32,767 can be specified for S. To convert signed binary data outside of that range, use FLTL(453). Example conversions: A signed binary value of 3 is converted to 3.0.
  • Page 516 ,–(– –)IR0 to, –(– –)IR15 Description FLTL(453) converts the 32-bit signed binary value in S+1 and S to 32-bit float- ing-point data (IEEE754-format) and places the result in R+1 and R. A single 0 is added after the decimal point in the floating-point result.
  • Page 517 ON if the result is negative. OFF in all other cases. Precautions The result will not be exact if a number with an absolute value greater than 16,777,215 (the maximum value that can be expressed in 24-bits) is con- verted.
  • Page 518 Overflow Flag will turn ON and the result will be output as If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON and the result will be output as 0.
  • Page 519 Negative Flag ON if the result is negative. OFF in all other cases. Precautions The augend (Au+1 and Au) and Addend (Ad+1 and Ad) data must be in IEEE754 floating-point data format. 3-14-6 FLOATING-POINT SUBTRACT: –F(455) Purpose Subtracts one 32-bit floating-point number from another and places the result in the specified result words.
  • Page 520 Overflow Flag will turn ON and the result will be output as If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON and the result will be output as 0.
  • Page 521 Section 3-14 Floating-point Math Instructions Precautions The Minuend (Mi+1 and Mi) and Subtrahend (Su+1 and Su) data must be in IEEE754 floating-point data format. 3-14-7 FLOATING-POINT MULTIPLY: *F(456) Purpose Multiplies two 32-bit floating-point numbers and places the result in the speci- fied result words.
  • Page 522 Overflow Flag will turn ON and the result will be output as If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON and the result will be output as 0.
  • Page 523 Section 3-14 Floating-point Math Instructions 3-14-8 FLOATING-POINT DIVIDE: /F(457) Purpose Divides one 32-bit floating-point number by another and places the result in the specified result words. Ladder Symbol /F(457) Dd: First Dividend word Dr: First Divisor word R: First result word...
  • Page 524 Overflow Flag will turn ON and the result will be output as If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON and the result will be output as 0.
  • Page 525 ,–(– –)IR0 to, –(– –)IR15 Description RAD(458) converts the 32-bit floating-point number in S+1 and S from degrees to radians and places the result in R and R+1. (The floating point source data must be in IEEE754 format.) Source (degrees, 32-bit floating-point data)
  • Page 526 Overflow Flag will turn ON and the result will be output as If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON and the result will be output as 0.
  • Page 527 Overflow Flag will turn ON and the result will be output as If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON and the result will be output as 0.
  • Page 528 Description SIN(460) calculates the sine of the angle (in radians) expressed as a 32-bit floating-point value in S+1 and S and places the result in R+1 and R. (The floating point source data must be in IEEE754 format.) Source (32-bit floating-point data)
  • Page 529 Section 3-14 Floating-point Math Instructions Specify the desired angle (–65,535 to 65,535) in radians in S+1 and S. If the angle is outside of the range –65,535 to 65,535, an error will occur and the instruction will not be executed. For information on converting from degrees to radians, see 3-14-19 LOGARITHM: LOG(468) DEGREES-TO-RADIANS: RAD(458).
  • Page 530 Description COS(461) calculates the cosine of the angle (in radians) expressed as a 32- bit floating-point value in S+1 and S and places the result in R+1 and R. (The floating point source data must be in IEEE754 format.) Source (32-bit floating-point data) Result (32-bit floating-point data) Specify the desired angle (–65,535 to 65,535) in radians in S+1 and S.
  • Page 531 ON if the result is negative. OFF in all other cases. Precautions The source data in S+1 and S must be in IEEE754 floating-point data format. 3-14-13 TANGENT: TAN(462) Purpose Calculates the tangent of a 32-bit floating-point number (in radians) and places the result in the specified result words.
  • Page 532 Description TAN(462) calculates the tangent of the angle (in radians) expressed as a 32- bit floating-point value in S+1 and S and places the result in R+1 and R. (The floating point source data must be in IEEE754 format.) Source (32-bit floating-point data) Result (32-bit floating-point data) Specify the desired angle (–65,535 to 65,535) in radians in S+1 and S.
  • Page 533 Calculates the arc sine of a 32-bit floating-point number and places the result in the specified result words. (The arc sine function is the inverse of the sine function; it returns the angle that produces a given sine value between –1 and...
  • Page 534 1.0, an error will occur and the instruction will not be executed. The result is output to words R+1 and R as an angle (in radians) within the range of – /2 to /2. The following diagram shows the relationship between the input data and result.
  • Page 535 Description ACOS(464) computes the angle (in radians) for a cosine value expressed as a 32-bit floating-point number in S+1 and S and places the result in R+1 and R. (The floating point source data must be in IEEE754 format.) –1...
  • Page 536 1.0, an error will occur and the instruction will not be executed. The result is output to words R+1 and R as an angle (in radians) within the range of 0 to . The following diagram shows the relationship between the input data and result.
  • Page 537 Source (32-bit floating-point data) Result (32-bit floating-point data) The result is output to words R+1 and R as an angle (in radians) within the range of – /2 to /2. The following diagram shows the relationship between the input data and...
  • Page 538 ON if the result is negative. OFF in all other cases. Precautions The source data in S+1 and S must be in IEEE754 floating-point data format. 3-14-17 SQUARE ROOT: SQRT(466) Purpose Calculates the square root of a 32-bit floating-point number and places the result in the specified result words.
  • Page 539 ,–(– –)IR0 to, –(– –)IR15 Description SQRT(466) calculates the square root of the 32-bit floating-point number in S+1 and S and places the result in R+1 and R. (The floating point source data must be in IEEE754 format.) Source (32-bit floating-point data) Result (32-bit floating-point data) The source data must be positive;...
  • Page 540 32-bit floating-point value. Underflow Flag Negative Flag Precautions The source data in S+1 and S must be in IEEE754 floating-point data format. 3-14-18 EXPONENT: EXP(467) Purpose Calculates the natural (base e) exponential of a 32-bit floating-point number and places the result in the specified result words.
  • Page 541 Description EXP(467) calculates the natural (base e) exponential of the 32-bit floating- point number in S+1 and S and places the result in R+1 and R. In other words, EXP(467) calculates e (x = source) and places the result in R+1 and R.
  • Page 542 ON if the absolute value of the result is too small to be expressed as a 32-bit floating-point value. Negative Flag Precautions The source data in S+1 and S must be in IEEE754 floating-point data format. 3-14-19 LOGARITHM: LOG(468) Purpose Calculates the natural (base e) logarithm of a 32-bit floating-point number and places the result in the specified result words.
  • Page 543 Source (32-bit floating-point data) Result (32-bit floating-point data) The source data must be positive; if it is negative, an error will occur and the instruction will not be executed. If the absolute value of the result is greater than the maximum value that can...
  • Page 544 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description PWR(840) raises the 32-bit floating-point number in B+1 and B to the power of the 32-bit floating-point number in E+1 and E. In other words, PWR(840) calculates X (X = B+1 and B; Y = E+1 and E).
  • Page 545 If the absolute value of the result is greater than the maximum value that can be expressed as floating-point data, the Overflow Flag will turn ON. If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON.
  • Page 546 S and S specify the first of two words containing the 32- bit data. It is also possible to input the floating-point data as an 8-digit hexa- decimal constant. Inputting the Instructions The input comparison instructions are treated just like the LD, AND, and OR instructions to control the execution of subsequent instructions.
  • Page 547 AND connection <F OR connection <F ON execution condition when comparison result is true. Options With the three input types and six symbols, there are 18 different possible combinations. Symbol Option (data format) (Equal) F: Single-precision floating-point data < >...
  • Page 548 D100, D101 is less than that of D200, D201, execution proceeds to the next line and CIO 100.00 is turned ON. If the content of D100, D101 is not less than that of D200, D201, execution does not proceed to the next instruc- tion line.
  • Page 549 FLOATING LESS THAN Comparison (<F) S1: D100 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 S2: D200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
  • Page 550 FSTR(448) expresses the 32-bit floating-point number in S+1 and S (IEEE754-format) in decimal notation or scientific notation according to the control data in words C to C+2, converts the number to ASCII text, and out- puts the result to the destination words starting at D.
  • Page 551 A decimal point (ASCII: 2E hex) is added if the number fractional digits is greater than 0. Spaces (ASCII: 20 hex) are added if the integer part of the floating-point data is shorter than the integer part of the result (total number of characters - sign digit - decimal point - fractional digits).
  • Page 552 A decimal point (ASCII: 2E hex) is added if the number fractional digits is greater than 0. Spaces (ASCII: 20 hex) are added if the integer part of the floating-point data is shorter than the integer part of the result (total number of characters - sign digit - decimal point - fractional digits - E digit).
  • Page 553 0.00 FSTR D100 Conversion 1 0 1 0 1 0 0 0 0 1 1 1 0 0 1 0 0.327457 0 0 1 1 1 1 1 0 1 0 1 0 0 1 1 1 Decimal notation Storage...
  • Page 554 0.00 FSTR D100 Conversion 1 0 1 0 1 0 0 0 0 1 1 1 0 0 1 0 0.327457 0 0 1 1 1 1 1 0 1 0 1 0 0 1 1 1 Scientific notation 0001(Hex)
  • Page 555 Conversion of ASCII text number to 32-bit floating-point data 32-bit floating-point data 1 1 1 0 1 0 0 1 0 1 1 1 1 0 0 1 123.456 1 1 0 0 0 0 1 0 1 1 1 1 0 1 1 0...
  • Page 556 Section 3-14 Floating-point Math Instructions Storage of ASCII Text The following diagrams show how the ASCII text number is converted to float- ing-point data. Different conversion methods are used for numbers stored with decimal notation and scientific notation. ASCII Character Storage...
  • Page 557 Conversion 2D ( ) 20 (Space) 30 (0) 31 (1) 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 2E (.) 32 (2) 33 (3) 34 (4) 1 0 1 1 1 1 1 1 1 0 0 1 1 1 1 0...
  • Page 558: Double-Precision Floating-Point Instructions

    Comparison Instructions =D, <>D, <D, <=D, >D, or >=D Data Format Floating-point data expresses real numbers using a sign, exponent, and man- tissa. When data is expressed in floating-point format, the following formula applies. e–1,023 Real number = (–1) (1.f)
  • Page 559 4847 3231 1615 It is not necessary for the user to be aware of the IEEE754 data format when reading and writing double-precision floating-point data. It is only necessary to remember that double-precision floating point values occupy four words each.
  • Page 560 Example 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
  • Page 561 0.0. Infinity Values of + and – can be expressed by setting the sign to 0 for positive or 1 for negative. The exponent will be 2,047 (2 – 1) and the mantissa will be 0.
  • Page 562 Calculations r = re In this example, the 4-digit BCD angle ( , in degrees) is read from D0 and the 4-digit BCD distance (r) is read from D1000. A (x, y) = A (rcos ,rsin ) • Ladder Program for the •...
  • Page 563 400B 5C92 9.3969262078591 91AC 8EEB Comparison of the Calculation Results When the real-number results are compared, it is clear that the double-preci- sion calculation yields a more accurate result. 3-15-1 DOUBLE FLOATING TO 16-BIT: FIXD(841) Purpose Converts a double-precision (64-bit) floating-point value to 16-bit signed binary data and places the result in the specified result word.
  • Page 564 Floating-point data (64 bits) Signed binary data (16 bits) Only the integer portion of the floating-point data is converted, and the fraction portion is truncated. The integer portion of the floating-point data must be within the range of –32,768 to 32,767.
  • Page 565 Floating-point data (64 bits) Signed binary data (32 bits) Only the integer portion of the floating-point data is converted, and the fraction portion is truncated. (The integer portion of the floating-point data must be within the range of –2,147,483,648 to 2,147,483,647.)
  • Page 566 ON if bit 15 of D+1 is ON after execution. OFF in all other cases. Precautions The content of words S to S+3 must be floating-point data and the integer por- tion must be in the range of –2,147,483,648 to 2,147,483,647. 3-15-3 16-BIT TO DOUBLE FLOATING: DBL(843)
  • Page 567 D+3. A single 0 is added after the decimal point in the floating-point result. Signed binary data (16 bits) Floating-point data (64 bits) Only values within the range of –32,768 to 32,767 can be specified for S. To convert signed binary data outside of that range, use DBLL(844). Example conversions: A signed binary value of 3 is converted to 3.0.
  • Page 568 DBLL(844) converts the 32-bit signed binary value in S+1 and S to double- precision (64-bit) floating-point data (IEEE754-format) and places the result in words D to D+3. A single 0 is added after the decimal point in the floating- point result.
  • Page 569 Section 3-15 Double-precision Floating-point Instructions 3-15-5 DOUBLE FLOATING-POINT ADD: +D(845) Purpose Adds two double-precision (64-bit) floating-point numbers and places the result in the specified destination words. Ladder Symbol +D(845) Au: First augend word Ad: First addend word D: First destination word...
  • Page 570 Overflow Flag will turn ON and the result will be output as If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON and the result will be output as 0.
  • Page 571 –D(846) subtracts the double-precision (64-bit) floating-point number in words Su to Su+3 from the double-precision (64-bit) floating-point number in Mi to Mi+3 and places the result in words D to D+3. (The floating point data must be in IEEE754 format.)
  • Page 572 Overflow Flag will turn ON and the result will be output as If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON and the result will be output as 0.
  • Page 573 Section 3-15 Double-precision Floating-point Instructions 3-15-7 DOUBLE FLOATING-POINT MULTIPLY: *D(847) Purpose Multiplies two double-precision (64-bit) floating-point numbers and places the result in the specified result words. Ladder Symbol *D(847) Md: First Multiplicand word Mr: First Multiplier word D: First destination word...
  • Page 574 *D(847) multiplies the double-precision (64-bit) floating-point number in words Description Md to Md+3 by the double-precision (64-bit) floating-point number in words Mr to Mr+3 and places the result in words D to D+3. (The floating point data must be in IEEE754 format.) S1+3...
  • Page 575 Section 3-15 Double-precision Floating-point Instructions 3-15-8 DOUBLE FLOATING-POINT DIVIDE: /D(848) Purpose Divides one double-precision (64-bit) floating-point number by another and places the result in the specified destination words. Ladder Symbol /D(848) Dd: First Dividend word Dr: First Divisor word D: First destination word...
  • Page 576 /D(848) divides the double-precision (64-bit) floating-point number in words Dd to Dd+3 by the double-precision (64-bit) floating-point number in words Dr to Dr+3 and places the result in words D to D+3. (The floating point data must be in IEEE754 format.)
  • Page 577 Description RADD(849) converts the double-precision (64-bit) floating-point number in words S to S+3 from degrees to radians and places the result in words D to D+3. (The floating point source data must be in IEEE754 format.) Source (degrees, 64-bit floating-point data)
  • Page 578 Overflow Flag will turn ON and the result will be output as If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON and the result will be output as 0.
  • Page 579 Description DEGD(850) converts the double-precision (64-bit) floating-point number in words S to S+3 from radians to degrees and places the result in words D to D+3. (The floating point source data must be in IEEE754 format.) Source (radians, 64-bit floating-point data)
  • Page 580 Specify the desired angle (–65,535 to 65,535) in radians in words S to S+3. If the angle is outside of the range –65,535 to 65,535, an error will occur and the instruction will not be executed. For information on converting between degrees and radians, see 3-15-9 DOUBLE DEGREES TO RADIANS: RADD(849) or 3-15-10 DOUBLE RADIANS TO DEGREES: DEGD(850).
  • Page 581 Negative Flag ON if the result is negative. OFF in all other cases. Precautions The source data in words S to S+3 must be in IEEE754 floating-point data for- mat. 3-15-12 DOUBLE COSINE: COSD(852) Purpose Calculates the cosine of a double-precision (64-bit) floating-point number (in radians) and places the result in the specified destination words.
  • Page 582 Specify the desired angle (–65,535 to 65,535) in radians in words S to S+3. If the angle is outside of the range –65,535 to 65,535, an error will occur and the instruction will not be executed. For information on converting between degrees and radians, see 3-15-9 DOUBLE DEGREES TO RADIANS: RADD(849) or 3-15-10 DOUBLE RADIANS TO DEGREES: DEGD(850).
  • Page 583 Specify the desired angle (–65,535 to 65,535) in radians in words S to S+3. If the angle is outside of the range –65,535 to 65,535, an error will occur and the instruction will not be executed. For information on converting between degrees and radians, see 3-15-9 DOUBLE DEGREES TO RADIANS: RADD(849) or 3-15-10 DOUBLE RADIANS TO DEGREES: DEGD(850).
  • Page 584 Section 3-15 Double-precision Floating-point Instructions If the absolute value of the result is greater than the maximum value that can be expressed as floating-point data, the Overflow Flag will turn ON and the result will be output as The following diagram shows the relationship between the angle and result.
  • Page 585 1.0, an error will occur and the instruction will not be executed. The result is output to words D to D+3 as an angle (in radians) within the range of – /2 to /2. The following diagram shows the relationship between the input data and...
  • Page 586 Negative Flag ON if the result is negative. OFF in all other cases. Precautions The source data in words S to S+3 must be in IEEE754 floating-point data for- mat. 3-15-15 DOUBLE ARC COSINE: ACOSD(855) Purpose Calculates the arc cosine of a double-precision (64-bit) floating-point number and places the result in the specified result words.
  • Page 587 1.0, an error will occur and the instruction will not be executed. The result is output to words D to D+3 as an angle (in radians) within the range of 0 to . The following diagram shows the relationship between the input data and result.
  • Page 588 Underflow Flag Unchanged Negative Flag Unchanged Precautions The source data in words S to S+3 must be in IEEE754 floating-point data for- mat. 3-15-16 DOUBLE ARC TANGENT: ATAND(856) Purpose Calculates the arc tangent of a double-precision (64-bit) floating-point number and places the result in the specified result words. (The arc tangent function is the inverse of the tangent function;...
  • Page 589 (The floating point source data must be in IEEE754 format.) –1 The result is output to words D to D+3 as an angle (in radians) within the range of – /2 to /2. The following diagram shows the relationship between the input data and result.
  • Page 590 Description SQRTD(857) calculates the square root of the double-precision (64-bit) float- ing-point number in words S to S+3 and places the result in words D to D+3. (The floating point source data must be in IEEE754 format.) The source data must be positive; if it is negative, an error will occur and the instruction will not be executed.
  • Page 591 Underflow Flag Unchanged Negative Flag Unchanged Precautions The source data in words S to S+3 must be in IEEE754 floating-point data for- mat. 3-15-18 DOUBLE EXPONENT: EXPD(858) Purpose Calculates the natural (base e) exponential of a double-precision (64-bit) float- ing-point number and places the result in the specified result words.
  • Page 592 Overflow Flag will turn ON and the result will be output as If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON and the result will be output as 0.
  • Page 593 (64-bit) floating-point value. Negative Flag Unchanged Precautions The source data in words S to S+3 must be in IEEE754 floating-point data for- mat. 3-15-19 DOUBLE LOGARITHM: LOGD(859) Purpose Calculates the natural (base e) logarithm of a double-precision (64-bit) float- ing-point number and places the result in the specified destination words.
  • Page 594 (64-bit) floating-point number in words S to S+3 and places the result in words D to D+3. The source data must be positive; if it is negative, an error will occur and the instruction will not be executed. If the absolute value of the result is greater than the maximum value that can...
  • Page 595 Negative Flag ON if the result is negative. OFF in all other cases. Precautions The source data in words S to S+3 must be in IEEE754 floating-point data for- mat. 3-15-20 DOUBLE EXPONENTIAL POWER: PWRD(860) Purpose Raises a double-precision (64-bit) floating-point number to the power of another double-precision (64-bit) floating-point number.
  • Page 596 If the absolute value of the result is greater than the maximum value that can be expressed as floating-point data, the Overflow Flag will turn ON. If the absolute value of the result is less than the minimum value that can be expressed as floating-point data, the Underflow Flag will turn ON.
  • Page 597 64- bit data. The 64-bit floating-point data cannot be input as constants. Inputting the Instructions The input comparison instructions are treated just like the LD, AND, and OR instructions to control the execution of subsequent instructions. Input type Operation The instruction can be connected directly to the left bus bar.
  • Page 598 <D OR connection <D ON execution condition when comparison result is true. Options With the three input types and six symbols, there are 18 different possible combinations. Symbol Option (data format) (Equal) D: Double-precision floating-point data < >...
  • Page 599 EQUAL OR>=D OR DOUBLE FLOATING GREATER THAN OR EQUAL Flags In this table, C1 = content of S1 to S1+3 and C2 = content of S2 to S2+3. Name Label Operation Error Flag ON if C1 or C2 is not a valid floating-point number (NaN).
  • Page 600: Table Data Processing Instructions

    DOUBLE FLOATING LESS THAN Comparison (<D) S1 :D100 1 0 0 0 1 0 1 1 0 1 0 0 0 1 0 0 S1 :D200 0 1 1 1 1 0 0 1 0 0 1 1 1 1 1 0...
  • Page 601 Operands TB through TB+3: Stack control words The first four words of the stack contain the PLC memory address of the last word in the stack and the stack pointer (the PLC memory address of the next word to be overwritten by PUSH(632)).
  • Page 602 The minimum value for the number of words in the stack (N) is 5 because N includes the four words that contain the pointer to the last word in the stack and the stack pointer. An error will occur if N is not in the range 0005 to FFFF.
  • Page 603 When CIO 0.00 is ON in the following example, SSET(630) secures a 10-word stack from D0 to D9. D0 and D1 contain the PLC memory address of the last word in the stack. D2 and D3 contain the stack pointer. The stack itself begins in D4.
  • Page 604 –2048 to +2047 ,IR0 to –2048 to +2047 ,IR15 DR0 to DR15, IR0 to IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description PUSH(632) writes the content of S to the address indicated by the stack pointer (TB+3 and TB+2) and increments the stack pointer by one.
  • Page 605 The stack must be defined in advance with SSET(630). Examples When CIO 0.00 is ON in the following example, PUSH(632) copies the con- tent of D200 to the stack beginning at D0. In this case, the stack pointer indi- cates D7. 0.00...
  • Page 606 Section 3-16 Table Data Processing Instructions 3-16-3 FIRST IN FIRST OUT: FIFO(633) Purpose Reads the first word of data written to the specified stack (the oldest data in the stack). Ladder Symbol FIFO(633) TB: First stack address D: Destination word...
  • Page 607 TB+4 is deleted. The data at the end of the stack (the address that was indicated by the stack pointer) is left unchanged.
  • Page 608 D: D300 After the data is written to D300, the stack pointer is decremented by one and the remaining data is shifted down. (The content of D5 is shifted to D4 and the content of D6 is shifted to D5.)
  • Page 609 Operands TB through TB+3: Stack control words The first four words of the stack contain the PLC memory address of the last word in the stack and the stack pointer (the PLC memory address of the next word to be overwritten by PUSH(632)).
  • Page 610 Use LIFO(634) in combination with PUSH(632). After PUSH(632) has been used to write data into a stack, LIFO(634) can be used to read data from the stack on a last-in first-out basis. After data is stored by PUSH(632), the stack pointer indicates the address next to the last data.
  • Page 611 (1 to 65,535 words). TB: First table word Indicates the first word of the table. All of the words in the table must be in the same data area. In other words TB and TB+LR NR–1 must be in the same...
  • Page 612 DIM(631) registers the words from TB to TB+LR NR–1 as table number N. Table number N has NR records and each record is LR words long. The data within this region cannot be changed once the region has been declared as records.
  • Page 613 Depending on the settings for the record length (LR) and number of records (NR), it is possible that a single table (from TB and TB+LR NR–1) will overlap two data areas. Verify that no problems will arise before specifying a table that overlaps a data area boundary.
  • Page 614 Indicates the table number. N must be between 0 and 15. R: Record number Indicates the record number of the desired record. R must be 0000 to FFFE hexadecimal (0 to 65,534). Record numbers begin with 0, so the valid record numbers are 0 to NR–1 for a table with NR records.
  • Page 615 DIM(631). Examples When CIO 0.00 is ON in the following example, SETR(635) finds the PLC memory address of the first word of record 3 of table number 10 and stores this address in Index Register IR11. 0.00...
  • Page 616 Description GETR(636) finds which record includes the PLC memory address contained in the specified Index Register and writes that record number in D. The PLC memory address contained in the Index Register does not have to be the first word in the record; it can be any word in the record.
  • Page 617 Interrupt tasks Operands C and C+1: Control words C specifies the number of words in the range and bit 15 of C+1 indicates whether or not to output the number of matches to DR0. Number of words in range 000 0000...
  • Page 618 C and C+1 must be in the same data area. R1: First word in range R1 specifies the first word in the search range. The words from R1 to R1+(C– 1) are searched for the desired data. (C is the number of words set in C.) Search range R1+(C–1) Note R1 and R1+C–1 must be in the same data area.
  • Page 619 D109 00010067 0003 Number of matches If the table length is specified as &10 (10 decimal) or A hexadecimal, the num- ber of matches will not be output to the data register DR0. 3-16-9 SWAP BYTES: SWAP(637) Purpose Switches the leftmost and rightmost bytes in all of the words in the range.
  • Page 620 Interrupt tasks Operands N: Number of words N specifies the number of words in the range and must be 0001 to FFFF hexadecimal (or &1 to &65,535). R1: First word in range R1 specifies the first word in the range.
  • Page 621 OFF in all other cases. Examples When CIO 0.00 is ON in the following example, SWAP(637) switches the data in the leftmost bytes with the data in the rightmost bytes in each word in the 10-word range from W0 to W9. 0.00 &10...
  • Page 622 C specifies the number of words in the range, bit 15 of C+1 indicates whether the data will be treated as signed binary or unsigned binary, and bit 14 of C+1 indicates whether or not to output the PLC memory address of the word that contains the maximum value to IR0.
  • Page 623 OFF in all other cases. Precautions When bit 15 of C+1 has been set to 1, the data within the range is treated as signed binary data and hexadecimal values 8000 to FFFF are considered negative. Thus, the results of the search will differ depending on the data-type...
  • Page 624 When CIO 0.00 turns ON in the following example, MAX(182) searches the 10-word range (specified in D100) beginning at D200 for the maximum value. The maximum value is written to D300 and the PLC memory address of the word containing the maximum value is written to IR0.
  • Page 625 C specifies the number of words in the range, bit 15 of C+1 indicates whether the data will be treated as signed binary or unsigned binary, and bit 14 of C+1 indicates whether or not to output the PLC memory address of the word that contains the minimum value to IR0.
  • Page 626 OFF in all other cases. Precautions When bit 15 of C+1 has been set to 1, the data within the range is treated as signed binary data and hexadecimal values 8000 to FFFF are considered negative. Thus, the results of the search will differ depending on the data-type...
  • Page 627 D208 D209 D: D300 000100CF 3-16-12 SUM: SUM(184) Purpose Adds the bytes or words in the range and outputs the result to two words. Ladder Symbol SUM(184) C: First control word R1: First word in range D: First destination word...
  • Page 628 C specifies the number of units (bytes or words) to be summed. (Bit 13 of C+1 determines whether bytes or words are being summed.) Bits 12 to 15 of C+1 indicate what type of data is being summed, as shown in the following diagram.
  • Page 629 R1 if bytes are being added. When bit 14 of C+1 has been set to 0, SUM(184) treats the data as binary. In this case, bit 15 determines whether the data is signed (bit 15 = 1) or unsigned (bit 15 = 0).
  • Page 630 Table Data Processing Instructions Examples When CIO 0.00 is ON in the following example, SUM(184) adds 10 bytes (specified in D300) of unsigned binary data beginning with the rightmost byte of D100 and writes the result to D201 and D200.
  • Page 631 When bit 13 of C+1 has been set to 1, FCS(180) calculates the FCS value for bytes of data. In this case, bit 12 determines whether the calculation starts with the rightmost byte of R1 (bit 12 = 1) or the leftmost byte of R1 (bit 12 = 0). Number of words/bytes in range...
  • Page 632 R1 if bytes are being added. When bit 13 of C+1 has been set to 1, FCS(180) operates on bytes of data. In this case, bit 12 determines whether the calculation starts with the rightmost byte of R1 (bit 12 = 1) or the leftmost byte of R1 (bit 12 = 0).
  • Page 633 Table Data Processing Instructions Examples When CIO 0.00 is ON in the following example, FCS(180) calculates the FCS value for the 10 bytes (specified in D300) of data beginning with the rightmost byte of D100 and writes the result to D200. 0.00...
  • Page 634 Operands TB through TB+3: Stack control words The first four words of the stack contain the PLC memory address of the last word in the stack and the stack pointer (the PLC memory address of the next available word in the stack.)
  • Page 635 When CIO 0.00 is ON in the following example, SNUM(638) counts the num- ber of words from the beginning of the data region at D4 to the stack pointer position - 1 (D6) and outputs the result to D300. (In this case, the stack pointer indicates D7.) The stack area begins at D0.
  • Page 636 Operands TB through TB+3: Stack control words The first four words of the stack contain the PLC memory address of the last word in the stack and the stack pointer (the PLC memory address of the next available word in the stack.)
  • Page 637 SREAD(639) can be used to read the data for an item currently on a conveyor. The position of the desired item is simply the number of items back (the offset...
  • Page 638 When CIO 0.00 is ON in the following example, SREAD(639) reads the data in the specified word in the stack starting at D0 and outputs the data to D100. In this case, the stack pointer indicates D7 and the offset value is 3, so the data is read from D4.
  • Page 639 Operands TB through TB+3: Stack control words The first four words of the stack contain the PLC memory address of the last word in the stack and the stack pointer (the PLC memory address of the next available word in the stack.)
  • Page 640 SWRIT(640) can be used to change the data for an item currently on a con- veyor. The position of the desired item is simply the number of items back (the...
  • Page 641 When CIO 0.00 is ON in the following example, SWRIT(640) writes the data in D100 to the specified word in the stack starting at D0. In this case, the stack pointer indicates D7 and the offset value is 3, so the data in D4 is overwritten.
  • Page 642 3-16-17 STACK DATA INSERT: SINS(641) Purpose Inserts the source data at the specified location in the stack and shifts the rest of the data in the stack downward. The offset value indicates the location of the desired data element (how many data elements before the current pointer position).
  • Page 643 Last word in stack SINS(641) can be used to insert the data for an item that is inserted in the midst of items already on a conveyor. The position of the insertion point is simply the number of items back (the offset value) from the most recent item...
  • Page 644 SINS(641) inserts one word of data into the stack, so there must be at least one available word at the end of the stack. If the stack is full, an error will occur and the source data will not be inserted.
  • Page 645 Operands TB through TB+3: Stack control words The first four words of the stack contain the PLC memory address of the last word in the stack and the stack pointer (the PLC memory address of the next available word in the stack.)
  • Page 646 SDEL(642) can be used to delete the data for an item that is rejected from the items on a conveyor. The position of the deletion point is simply the number of items back (the offset value) from the most recent item added to the conveyor.
  • Page 647 D100, shifts the remaining data upward, and decrements the stack pointer. In this case, the stack pointer indicates D7 and the offset value is 3, so the data is deleted from D4. The remaining data is shifted up one word and the stack pointer is decremented from D7 to D6.
  • Page 648: Data Control Instructions

    Applicable Program Areas Block program areas Step program areas Subroutines Interrupt tasks Not allowed Not allowed Parameters The following diagrams show the locations of the parameter data. For details on the parameters, refer to PID Parameter Settings in this section.
  • Page 649 The result is then stored as the manipulated variable in output word D. The parameters are obtained when the execution condition turns from OFF to ON, and the Error Flag will turn ON if the settings are outside of the permissi- ble range.
  • Page 650 PV input (S) Manipulated variable (D) The number of valid input data bits within the 16 bits of the PV input (S) is designated by the input range setting in C+6, bits 08 to 11. For example, if 12 bits (4 hex) is designated for the input range, the range from 0000 hex to 0FFF hex will be enabled as the PV.
  • Page 651 C+9 to C+38 are initialized when operation is started. If the C data is out of range, an error will occur and the Error Flag will turn ON. If the actual sampling period is more than twice the designated sampling period, an error will occur and the Error Flag will turn ON.
  • Page 652 The number of valid input data bits for the measured value is designated by Manipulated Variable the input range setting in C+6, bits 08 to 11, and the number of valid output Ranges data bits for the manipulated variable output is designated by the output range setting in C+6, bits 0 to 3.
  • Page 653 When overshooting is prevented with simple PID control, stabilization of dis- Value PID with Two turbances is slowed (1). If stabilization of disturbances is speeded up, on the Degrees of Freedom other hand, overshooting occurs and response toward the target value is slowed (2).
  • Page 654 Not allowed PID action. (0.01 to 99.99 s, in units of 10 ms) Bits 04 to 15 2-PID parameter ( ) The input filter coefficient. Nor- 000 hex: = 0.65 of C+5 mally use 0.65 (i.e., a setting of Setting from 100 to 163 hex 000).
  • Page 655 Note (1) When the unit is designated as 1, the range is from 1 to 8,191 times the period. When the unit is designated as 9, the range is from 0.1 to 819.1 s. When 9 is designated, set the integral and derivative times to within a range of 1 to 8,191 times the sampling period.
  • Page 656 80 ms is less than 100 ms, PID(190) will not be executed. For the fourth cycle, the 80 ms is added to 60 ms. Because the sum of 140 ms is greater than 100 ms, PID(190) will be executed and the surplus of 40 ms (i.e., 120 ms –...
  • Page 657 Combining integral action with proportional action reduces the offset accord- ing to the time that has passed, so that the PV will match the SV. The strength of the integral action is indicated by the integral time, which is the time...
  • Page 658 PID Action PID action combines proportional action (P), integral action (I), and derivative action (D). It produces superior control results even for control objects with dead time. It employs proportional action to provide smooth control without hunting, integral action to automatically correct any offset, and derivative action to speed up the response to disturbances.
  • Page 659 The general relationship between PID parameters and control status is shown below. • When it is not a problem if a certain amount of time is required for stabili- zation (settlement time), but it is important not to cause overshooting, then enlarge the proportional band.
  • Page 660 Section 3-17 Data Control Instructions • If the period is short and hunting occurs, it may be that the control system response is quick and the derivative action is too strong. In that case, set the derivative action lower. Control by measured PID...
  • Page 661 14 13 0 0 0 AT Calculation Gain AT Command Bit Limit-cycle Hysteresis C+10 C+11 Work area (30 words: Cannot be used by user.) C+40 Operand Specifications Area CIO Area CIO 0 to CIO 0 to CIO 0 to CIO 6143...
  • Page 662 D. The parameter settings are read when the execution condition turns from OFF to ON, and the Error Flag will turn ON if the settings are outside of the permis- sible range. If the settings are within the permissible range, PID processing will be exe- cuted using the initial values.
  • Page 663 PID Control The number of valid input data bits within the 16 bits of the PV input (S) is designated by the input range setting in C+6, bits 08 to 11. For example, if 12 bits (4 hex) is designated for the input range, the range from 0000 hex to 0FFF hex will be enabled as the PV.
  • Page 664 C+11 to C+40 are initialized when operation is started. If the C data is out of range, an error will occur and the Error Flag will turn ON. If an error occurred during autotuning, the Error Flag will turn ON.
  • Page 665 Data Control Instructions If the actual sampling period is more than twice the designated sampling period, an error will occur and the Error Flag will turn ON. PID control will still be executed, however. The Carry Flag turns ON while PID control is being executed.
  • Page 666 Bit 15 of C+9 AT Command Bit This control bit starts autotuning. As a Control Bit: Allowed • Set the AT Command Bit to 1 to • 0 perform autotuning. (Autotuning Executes autotuning. can be started while • 1 PIDAT(191) is being executed.)
  • Page 667 0000 MV output lower limit MV output upper limit Max. value of output range Example 1: At the rising edge of CIO 0.00 (OFF to ON), the work area in D211 to D240 is Interrupting PID Control to initialized according to the parameters (shown below) set in D200 to D208.
  • Page 668 Reverse operation (bit 00: 0), PID constant change enable setting = 0 0 3 2 period: 0.5 s OFF (bit 01: 0), set value = manipulated variable output 50% (bit C+5: D205 03: 1), 2-PID parameter = 0.65 (bits 04 to 15: 000 hex)
  • Page 669 Example 3: Autotuning can be interrupted by turning bit 15 of D209 (C+9) from ON to Interrupting Autotuning OFF. PID control will be restarted with the P, I, and D constants that were in Before Completion effect before autotuning was started.
  • Page 670 Description When the execution condition is ON, LMT(680) controls output data according to whether or not the specified input data (signed 16-bit binary) is within the upper and lower limits. The contents of words C and C+1 are as follows:...
  • Page 671 Section 3-17 Data Control Instructions If the input data (S) is less than the lower limit (C), the lower limit data will be output to D and the Less Than Flag will turn ON. If the input data (S) is greater than the upper limit (C+1), the upper limit data will be output to D and the Greater Than Flag will turn ON.
  • Page 672 D300 D300 D100 3-17-4 DEAD BAND CONTROL: BAND(681) Purpose Controls output data according to whether or not input data is within the lower and upper limits of the range (dead band range.) Ladder Symbol BAND(681) S: Input word C: First limit word...
  • Page 673 C and C+1 must have the same area classification. If the input data (S) is greater than or equal to the lower limit (C) and less than or equal to the upper limit (C+1), 0000 (hex) will be output to D and the Equals Flag will turn ON.
  • Page 674 OFF in all other cases. Precautions If the upper limit is less than the lower limit, an error will occur and the Error Flag will turn ON. If the input data (S) is greater than the upper limit, the Greater Than Flag will turn ON.
  • Page 675 The contents of words C and C+1 are as follows: Negative bias Positive bias If the input data (S) is less than zero, the input data plus the negative bias will be output to D and the Less Than Flag will turn ON.
  • Page 676 If the input data (S) is greater than zero, the input data plus the positive bias will be output to D and the Greater Than Flag will turn ON. If the input data (S) is equal to zero, 0000 will be output to D and the Equals Flag will turn ON.
  • Page 677 Contents of D200 3-17-6 TIME-PROPORTIONAL OUTPUT: TPO(685) Purpose Inputs the duty ratio or manipulated variable from the specified word, converts the duty ratio to a time-proportional output based on the specified parameters, and outputs the result from the specified output.
  • Page 678 Specifies the input word containing the input duty ratio or manipulated vari- able. Bits 04 to 07 of C specify the input type, i.e., whether the input word con- tains an input duty ratio or manipulated variable. (Set these bits to 0 hex to specify a input duty ratio or to 1 hex to specify a manipulated variable.)
  • Page 679 Example: When the control period is 1 s and the input value is 50%, the bit is ON for 0.5 s and OFF for 0.5 s. When the control period is 1 s and the input value is 80%, the bit is ON for 0.8 s and OFF for 0.2 s.
  • Page 680 Section 3-17 Data Control Instructions In this case, set the same value for the PID Control instruction’s output range and the TPO(685) instruction’s manipulated variable range. For example, when the PID Control instruction’s output range and the TPO(685) instruc- tion’s manipulated variable range are both set to 12 bits (0000 to 0FFF hex),...
  • Page 681 • When instruction execution starts, the output bit (R) is turned ON/OFF according to the duty ratio. • The parameters (in C to C+3) are read in real time each time that the instruction is executed. When changing the parameters, change all of them at the same time so that different sets of parameters are not mixed.
  • Page 682 0.70 s 0.30 s Output Time Each control period's output is determined by the duty ratio at the beginning of that period. Use this setting for general applications. • Input time setting = 1 (Use lower value.) Control period (a)
  • Page 683 Output Time If the duty ratio rises above the initial value early enough, the duty ratio will be adjusted and the output will be turned ON sooner. (With this setting the output's ON/OFF order is reversed and the output goes from OFF to ON.) Use this setting for applications such as avoiding undershooting when using time- proportional control to control cooling and using relatively long control period.
  • Page 684 MV range), converts the duty ratio to a time- proportional output, and outputs the pulses to CIO 100.05. In this case, CIO 100 is allocated to a Transistor Output Unit and bit CIO 100.05 is connected to a solid state relay for heater control.
  • Page 685 CIO 100.06. In this case, the control period is 1 s and the output limit function is enabled with a lower limit 20.00% and an upper limit of 80.00%.
  • Page 686 SCL(194) is used to convert the unsigned binary data contained in the source word S into unsigned BCD data and place the result in the result word R according to the linear function defined by points (As, Ad) and (Bs, Bd). The address of the first word containing the coordinates of points (As, Ar) and (Bs, Br) is specified for the first parameter word P1.
  • Page 687 Analog Input Units according to user-defined scale parameters. For example, if a 1 to 5-V input to an Analog Input Unit is input to memory as 0000 to 0FA0 hexadecimal, the value in memory can be scaled to 50 to 200 C using SCL(194).
  • Page 688 In this example, values from 0000 to 00C8 hexadecimal will be converted to negative values. SCL(194), however, can output only unsigned BCD values from 0000 to 9999, so 0000 BCD will be output whenever the contents of D0 is between 0000 and 00C8 hexadecimal.
  • Page 689 Section 3-17 Data Control Instructions Reverse Scaling Reverse scaling can also be used by setting As < Bs and Ar > Br. The follow- ing relationship will result. R (unsigned BCD) Point A Point B S (unsigned binary) Reverse scaling can be used, for example, to convert (reverse scale) 1 to 5 V (0000 to 0FA0 hexadecimal) to 0300 to 0000, respectively, as shown in the fol- lowing diagram.
  • Page 690 ( X, Y) and an offset. The address of the first word containing X, Y, and the offset is specified for the first parameter word P1. The sign of the result is indicated by the status of the Carry Flag (ON: negative, OFF: positive).
  • Page 691 Analog Input Units according to user-defined scale parameters. For example, if a 1 to 5-V input to an Analog Input Unit is input to memory as 0000 to 0FA0 hexadecimal, the value in memory can be scaled to –100 to 200 C using SCL2(486).
  • Page 692 Scaling 1 to 5-V Analog Input to 0 to 300 In the following example, it is assumed that an analog signal from 1 to 5 V is converted and input to CIO 2005 as 0000 to 0FA0 hexadecimal. SCL2(486) is used to convert (scale) the value in CIO 2005 to a value between 0000 and 0300 BCD.
  • Page 693 Scaling 1 to 5-V Analog Input to –200 to 200 In the following example, it is assume that an analog signal from 1 to 5 V is converted and input to CIO 2005 as 0000 to 0FA0 hexadecimal. SCL2(486) is used to convert (scale) the value in CIO 2005 to a value between –0200 and...
  • Page 694 Section 3-17 Data Control Instructions Operands The contents of the five words starting with the first parameter word (P1) are shown in the following diagram. Offset of linear function 8000 to 7FFF (signed binary) P1+1 0001 to 9999 (BCD) P1+2...
  • Page 695 SCL3(487) is used to convert data using a user-defined scale to signed binary for Analog Output Units. For example, SCL3(487) can convert 0 to 200 C to 0000 to 0FA0 (hex) and output an analog output signal 1 to 5 V from the Ana- log Output Unit.
  • Page 696 BCD or if the value for X (C+1) is not between 0001 and 9999 BCD. The Equals Flag will turn ON when the contents of the result word D is 0000. The Negative Flag will turn ON if the MSB of the result in R is 1, i.e., if the result is negative.
  • Page 697 Not allowed Operands N: Number of Cycles The number of cycles must be between 0001 and 0040 hexadecimal (0 to 64 cycles). R: Result Word and R+1: First Work Area Word R will contain the average value after the specified number of cycles. R+1 pro- vides information on the averaging process and R+2 to R+N+1 contain the previous values of S as shown in the following diagram.
  • Page 698 S in order to words starting with R+2. The Previous Value Pointer (bits 00 to 07 of R+1) is incremented each time a value is written. Until the Nth value is written, the contents of S will be output unchanged to R and the Average Value Flag (bit 15 of R+1) will remain OFF.
  • Page 699 D200. The contents will be stored in order in the ten words from CIO 302 to CIO 311. The average of the contents of these ten words will be placed in CIO 300 and then bit 15 of CIO 301 will be turned ON.
  • Page 700 CIO 200 0000 0001 0002 0003 Average D1000 0000 0001 0001 0002 Pointer D1001 0001 0002 8000 8001 D1002 0000 0000 0000 0003 3 previous values of IR 40 D1003 0001 0001 0001 D1004 0002 0002...
  • Page 701: Subroutines

    GSBS GLOBAL SUBROUTINE ENTRY GSBN GLOBAL SUBROUTINE RETURN GRET 3-18-1 SUBROUTINE CALL: SBS(091) Purpose Calls the subroutine with the specified subroutine number and executes that program. Ladder Symbol SBS(091) N: Subroutine number Variations Variations Executed Each Cycle for ON Condition...
  • Page 702 Section 3-18 Subroutines Description SBS(091) calls the subroutine with the specified subroutine number. The sub- routine is the program section between SBN(092) and RET(093). When the subroutine is completed, program execution continues with the next instruc- tion after SBS(091). Execution condition ON...
  • Page 703 Section 3-18 Subroutines Subroutines can be nested up to 16 levels. Nesting is when another subrou- tine is called from within a subroutine program, such as shown in the following example, which is nested to 3 levels. SBN 10 SBN 11...
  • Page 704 CIO 100.00 is turned ON by DIFU(013) when CIO 0.01 has gone from OFF to ON. If CIO 0.00 is OFF in the following cycle, subroutine 0001 will not be executed again and output CIO 100.00 will remain ON.
  • Page 705 Precautions SBS(091) and the corresponding SBN(092) must be programmed in the same task. An error will occur if the corresponding SBN(092) is not in the task. SBS(091) will be treated as NOP(000) when it is within a program section interlocked by IL(002) and ILC(003).
  • Page 706 Subroutines Example 2: Sequential (Non-nested) Subroutines When CIO 0.00 is ON in the following example, subroutine 1 is executed and program execution returns to the next instruction after SBS(091) 1. When CIO 0.01 is ON, subroutine 2 is executed and program execution returns to the next instruction after SBS(091) 2.
  • Page 707 Subroutines Example 3: Nested Subroutines When CIO 0.00 is ON in the following example, subroutine 1 is executed. If CIO 0.01 is ON, subroutine 2 is executed from within subroutine 1 and pro- gram execution returns to the next instruction after SBS(091) 2 when subrou- tine 2 is completed.
  • Page 708 When MCRO(099) is executed, the contents of S through S+3 are copied to A600 through A603 (macro area inputs) and the specified subroutine is exe- cuted.
  • Page 709 The four words of input data (words or bits) in A600 to A603 and the four words of output data (words or bits) in A604 to A607 must be used in the sub- routine called by MCRO(099). It is not possible to pass more than four words of data.
  • Page 710 The second MCRO(099) instruction operates in the same way, but the input data in CIO 200 to CIO 203 is passed to A600 to A603 and the output data in A604 to A607 is passed to CIO 400 to CIO 403.
  • Page 711 SBN(092) indicates the beginning of the subroutine with the specified subrou- tine number. The end of the subroutine is indicated by RET(093). The region of the program beginning at the first SBN(092) instruction is the subroutine region. A subroutine is executed only when it has been called by SBS(091) or MCRO(099).
  • Page 712 NOP(000). Place the subroutines after the main program and just before the END(001) instruction in the program for each task. If part of the main program is placed after the subroutine region, that program section will be ignored. Subroutine region...
  • Page 713 The step instructions, STEP(008) and SNXT(009) cannot be used in subrou- tines. Not allowed Example When CIO 0.00 is ON in the following example, subroutine 10 is executed and program execution returns to the next instruction after the SBS(091) or MCRO(099) instruction that called the subroutine. 0.00...
  • Page 714 3-18-5 GLOBAL SUBROUTINE CALL: GSBS(750) Purpose Calls the global subroutine with the specified subroutine number and exe- cutes that program. The same global subroutine can be called from two or more tasks. GSBS(750) is used in combination with GSBN(751) and GRET(752), the GLOBAL SUBROUTINE ENTRY and GLOBAL SUBROUTINE RETURN instructions.
  • Page 715 The global subroutine region (between GSBN(751) and GRET(752)) must be defined in interrupt task 0. If it is defined in another task, an error will occur and the Error Flag will be turned ON when the GSBS(750) instruction is exe- cuted.
  • Page 716 GRET An SBS(091) or GSBS(750) instruction can be written within a subroutine region (SBN(092) to RET(093)) or global subroutine region (GSBN(751) to GRET(752)) to “nest” subroutines. Subroutines can be nested up to 16 levels. Interrupt task 0 GSBN 10 GSBN 11...
  • Page 717 The operation of differentiated instructions in a global subroutine is unpredict- able if a subroutine is executed more than once in the same cycle. In the fol- lowing example, global subroutine 0001 is executed when CIO 0.00 is ON and CIO 100.00 is turned ON by DIFU(013) when CIO 0.01 has gone from OFF to...
  • Page 718 GLOBAL SUBROUTINE RETURN instruction, GRET(752) must be programmed in interrupt task 0. If the global subroutine region is not pro- grammed in interrupt task 0, an error will occur and the Error Flag will be turned ON when the GSBS(750) instruction is executed.
  • Page 719 Interrupt task 0 GSBN Global subroutine program S GRET Example 2 Two or more global subroutine programs can be programmed in interrupt task 0. In this case, interrupt task 0 can be divided and used as the subroutine function’s task.
  • Page 720 Section 3-18 Subroutines When CIO 0.00 is ON, global subroutine program 1 is executed. When CIO 0.01 is ON, global subroutine program 2 is executed. Cyclic or interrupt task 0.00 GSBS CIO 0.00 ON 0.01 CIO 0.01 CIO 0.01 ON...
  • Page 721 The global subroutine region (between GSBN(751) and GRET(752)) must be defined in interrupt task 0. If it is defined in another task, an error will occur and the Error Flag will be turned ON when the GSBS(750) instruction is exe-...
  • Page 722 0 just before the END(001) instruction. When two or more global subroutines are being used, group them together in interrupt task 0 after the end of the main program. If part of the main program is placed after the global subroutine region, that program section will be ignored.
  • Page 723 Section 3-18 Subroutines • Always place the global subroutines in interrupt task 0. An error will occur if a global subroutine is called and the subroutine is not in interrupt task 0. Not allowed Cyclic task 1 Cyclic task 1...
  • Page 724 Section 3-18 Subroutines Example When CIO 0.00 is ON in the following example, global subroutine 10 is exe- cuted and program execution returns to the next instruction after the GSBS(750) instruction that called the subroutine. Cyclic or interrupt task 0.00...
  • Page 725: Interrupt Control Instructions

    Both input interrupt tasks and scheduled interrupt tasks are masked (dis- abled) and the internal timer for scheduled interrupts is stopped when the PLC enters RUN mode. MSKS(690) can be used to unmask or mask input interrupts and set the time intervals for scheduled interrupts.
  • Page 726 Note Input interrupts 6 and 7 cannot be used on Y CPU Units and CP1L CPU Units. Input interrupts 4, 5, 6, and 7 cannot be used on CP1L CPU Units with 14 I/O Points. Scheduled Interrupts N specifies the scheduled interrupt number and the starting method and S specifies the interrupt interval.
  • Page 727 • The internal timer can be reset or not reset depending on the operands for MSKS(690). • When the internal timer is reset, timing will start after the timer is reset and scheduled interrupt will occur at the interval specified in S from the...
  • Page 728 A426.11 where the multiple I/O refreshing occurred. Precautions Be sure that the time interval is longer than the time required to execute the scheduled interrupt task. When IORF(097) is being executed within an interrupt task to refresh I/O in a Special I/O Unit, cyclic refreshing with that Special I/O Unit must be disabled in the PLC Setup.
  • Page 729 When W0.01 turns ON in the following example, MSKS(690) sets the sched- ule interrupt interval for schedule interrupt 0 to 10.5 ms (assuming the unit is set to 0.1 ms in the PLC Setup), resets the internal timer, and starts the inter- nal timer.
  • Page 730 Note Input interrupts 6 and 7 cannot be used on Y CPU Units and CP1L CPU Units. Input interrupts 4, 5, 6, and 7 cannot be used on CP1L CPU Units with 14 I/O Points. Scheduled Interrupts N specifies the scheduled interrupt number and the data to read and D speci- fies the storage location for the read data.
  • Page 731 The scheduled interrupt interval (set value) or the present value of the internal timer specified with N is stored in D as a hexadecimal value. The units for the scheduled interrupt interval is specified in the PLC Setup as the Scheduled Interrupt Interval.
  • Page 732: S Recorded Interrupt Clear Specification

    0001 hex: Recorded interrupt cleared Note Input interrupts 6 and 7 cannot be used on Y CPU Units and CP1L CPU Units. Input interrupts 4, 5, 6, and 7 cannot be used on CP1L CPU Units with 14 I/O Points.
  • Page 733 Section 3-19 Interrupt Control Instructions Scheduled Interrupts N specifies the scheduled interrupt number and S specifies the time to the first scheduled interrupt. Operand Contents Specify the scheduled interrupt number. 4: Scheduled interrupt 0 (interrupt task 2) 0000 to 270F hex:...
  • Page 734 CLI(691) can be used to clear these recorded interrupts before they are executed. Scheduled Interrupts: N = 4 N is 4, the content of S specifies the time interval to the first scheduled inter- rupt task after MSKS(690) is executed. MSKS(690) Execution of scheduled interrupt task.
  • Page 735 All interrupt tasks will remain disabled until EI(694) is executed. DI(693) cannot be executed from an interrupt task. DI(693) cannot be executed for more than one cyclic task at a time. To disable more than one cycle execution task, insert DI(693) in each cyclic task. Any...
  • Page 736 Interrupt tasks are executed under registered conditions. Task No. 1 DI instruction is valid. Examples When CIO 0.,00 is ON in the following example, DI(693) disables all interrupt tasks. 0.00 Disables execution of all interrupt tasks. 3-19-5 ENABLE INTERRUPTS: EI(694) Purpose Enables execution of all interrupt tasks that were disabled with DI(693).
  • Page 737 Section 3-19 Interrupt Control Instructions Precautions EI(694) does not require an execution condition. It is always executed with an ON execution condition. EI(694) cannot unmask input interrupts that have not been unmasked by MSKS(690) or set scheduled interrupts that have not been set by MSKS(690).
  • Page 738: High-Speed Counter/Pulse Output Instructions

    • To change the PV of the high-speed counter. • To change the PV of interrupt inputs in counter mode. • To change the PV of the pulse output (origin fixed at 0). • To stop pulse output. Ladder Symbol...
  • Page 739: Operand Specifications

    PWM output 1 Note (1) Interrupt inputs 4 and 5 cannot be used in the CP1L L CPU Units with 14 I/O points. (2) Interrupt inputs 6 and 7 cannot be used in the CP1H Y CPU Units or the CP1L L CPU Units with 14 I/O points.
  • Page 740 IR15 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description INI(880) performs the operation specified in C for the port specified in P. The possible combinations of operations and ports are shown in the following table. P: Port specifier C: Control data...
  • Page 741 ■ Stopping Pulse Output (P = 0000 to 0003, 1000, or 1001 hex and C = 0003 hex) If C is 0003 hex, INI(880) immediately stops pulse output for the specified port.
  • Page 742 High-speed Counter/Pulse Output Instructions Example When CIO 0.00 turns ON in the following example, SPED(885) starts output- ting pulses from pulse output 0 in Continuous Mode at 500 Hz. When CIO 0.01 turns ON, pulse output is stopped by INI(880). 0.00...
  • Page 743 PWM output 1 Note Input interrupts 6 and 7 cannot be used on Y CPU Units and CP1L CPU Units. Input interrupts 4, 5, 6, and 7 cannot be used on CP1L CPU Units with 14 I/O Points. C: Control Data The function of INI(880) is determined by the control data, C.
  • Page 744 ,IR0+(++) to ,IR15+(++) ,–(– –)IR0 to, –(– –)IR15 Description PRV(881) reads the data specified in C for the port specified in P. The possi- ble combinations of data and ports are shown in the following table. P: Port specifier C: Control data...
  • Page 745 PV Overflow/Underflow Flag OFF: Normal ON: Error PWM out- The PWM output is stored in D. D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Pulse Output In-progress Flag OFF: Stopped ON: Outputting...
  • Page 746 Counter input method 0000 to CP1H X/XA CPU Unit, unit version 1.0 Pulse output 2 or 3 0000 0000 to 0000 7530 hex (0 to 30,000) 0003 hex CP1H X/XA CPU Unit, unit version 1.1 Pulse output 0 or 1 0000 0000 to 0001 86A0 hex (0 to 100,000)
  • Page 747 Section 3-20 The count is calculated by counting each pulse regardless of the frequen- cy. At high frequencies, the rising or falling edges of some pulses will be corrupted, resulting in errors (roughly 1% error max. at 100 kHz and the maximum error at 1 MHz).
  • Page 748 PRV2(883) function 0@*0 hex Converts frequency to rotation speed. (See note.) 0001 hex Converts counter PV to total number of revolutions. Note The second digit of C (@) specifies the units and the third digit (*) specifies the frequency calculation method.
  • Page 749: T0000 To T4095

    PRV2(883) converts the pulse frequency input from high-speed counter 0, according to the conversion method specified in C1 and the pulses/revolution coefficient specified in C2, and outputs the result to D and D+1. Select one of the following conversion methods by setting C1 to 0000 hex or 0001 hex.
  • Page 750 • Counter input method: 4 differential phase mode Conversion result = 0000 0000 to 0003 0D40 hex (0 to 200,000) (If a frequency higher than 200 kHz has been input, the output will re- main at the maximum value of 0003 0D40 hex.) •...
  • Page 751 Pulses per revolution #0003 D200 Example 2 When CIO 0.01 is ON in the following programming example, PRV2(883) reads the counter PV, converts that value to number of revolutions, and out- puts the hexadecimal result to D301 and D300. 0.01 PRV2 #0001...
  • Page 752 Step program areas Subroutines Interrupt tasks Operands P: Port Specifier P specifies the port for which pulses are to be counted as shown in the follow- ing table. Port 0000 hex High-speed counter 0 0001 hex High-speed counter 1 0002 hex High-speed counter 2...
  • Page 753 For range comparison, the comparison table always contains eight ranges. The table is 40 words long, as shown below. If it is not necessary to set eight ranges, set the interrupt task number to FFFF hex for all unused ranges.
  • Page 754: Dr0 To Dr15, Ir0 To Ir15

    ■ Registering a Comparison Table (C = 0002 or 0003 hex) If C is set to 0002 or 0003 hex, a comparison table will be registered, but com- parison will not be started. Comparison is started with INI(880). ■...
  • Page 755 • The range comparison table contains 8 ranges, each of which is defined by a lower limit and an upper limit. If a range is not to be used, set the interrupt task number to FFFF hex to disable the range.
  • Page 756 0002 3-20-5 SPEED OUTPUT: SPED(885) Purpose SPED(885) is used to set the output pulse frequency for a specific port and start pulse output without acceleration or deceleration. Either independent mode positioning or continuous mode speed control is possible. For indepen- dent mode positioning, the number of pulses is set using PULS(886).
  • Page 757 1 hex: Pulse + direction Always 0 hex. Note: Use the same pulse output method when using both pulse outputs 0 and 1 (CP1H only). F: First Pulse Frequency Word The value of F and F+1 sets the pulse frequency in Hz.
  • Page 758 SPED(885) starts pulse output on the port specified in P using the method specified in M at the frequency specified in F. Pulse output will be started each time SPED(885) is executed. It is thus normally sufficient to use the differenti- ated version (@SPED(885)) of the instruction or an execution condition that is turned ON only for one scan.
  • Page 759 Note (1) Pulse output will stop immediately if the CPU Unit is changed to PRO- GRAM mode. (2) The number of output pulses must be set each time output is restarted.
  • Page 760 High-speed Counter/Pulse Output Instructions Section 3-20 (4) The direction set in the SPED(885) operand will be ignored if the number of pulses is set with PULS(881) as an absolute value. Operation Purpose Application Frequency changes Description Procedure/ instruction Starting To out-...
  • Page 761 Example When CIO 0.00 turns ON in the following programming example, PULS(886) sets the number of output pulses for pulse output 0. An absolute value of 5,000 pulses is set. SPED(885) is executed next to start pulse output using the CW/CCW method in the clockwise direction in independent mode at a tar- get frequency of 500 Hz.
  • Page 762 Subroutines Interrupt tasks Operands P: Port Specifier The port specifier indicates the port. The parameters set in D and N will apply to the next SPED(885) or ACC(888) instruction in which the same port output location is specified. Port 0000 hex...
  • Page 763 • The direction set for SPED(885) or ACC(888) will be ignored if the num- ber of pulses is set with PULS(881) as an absolute value. • It is possible to move outside of the range of the PV of the pulse output amount ( 2,147,483,648 to 2,147,483,647).
  • Page 764 Only independent mode positioning is supported. PLS2(887) can also be executed during pulse output to change the number of output pulses, target frequency, acceleration rate, or deceleration rate.
  • Page 765 1 hex: Pulse + direction Always 0 hex. Note: Use the same pulse output method when using both pulse outputs 0 and 1. S: First Word of Settings Table The contents of S to S+5 control the pulse output as shown in the following diagrams.
  • Page 766 PLS2(887) starts pulse output on the port specified in P using the mode spec- ified in M at the start frequency specified in F (1 in diagram). The frequency is increased every pulse control period (4 ms) at the acceleration rate specified in S until the target frequency specified in S is reached (2 in diagram).
  • Page 767 Acceleration will not be per- formed by PLS2(887) for this application, but if the acceleration rate is set to 0, the Error Flag will turn ON and PLS2(887) will not be executed. Al- ways set the acceleration rate to a value other than 0.
  • Page 768 Note To prevent the (Indepen- Execution of rates) target posi- ACC(888) dent) PLS2(887) executed to change deceler- (independent tion from the target frequency and accel- ation mode) being eration/deceleration rates. rates) PLS2(887) (The target position is not changed changed. The original target intentionally, position is specified again.)
  • Page 769 Pulse number of frequency direction ing positioning pulses positioning with PLS2(887) Change of direction at the absolute pulse spec- Target specified deceleration rate PULS(886) ification to change to frequency Number of pulses absolute pulses and (position) changed reverse direction.
  • Page 770 Note Triangular Control If the specified number of pulses is less than the number required to reach the target frequency and return to zero, the function will automatically reduce the acceleration/deceleration time and perform triangular control (acceleration and deceleration only.) An error will not occur.
  • Page 771 100,000 pulses. Pulse output is accelerated at a rate of 500 Hz every 4 ms starting at 200 Hz until the target speed of 50 kHz is reached. From the decel- eration point, the pulse output is decelerated at a rate of 250 Hz every 4 ms starting until the starting speed of at 200 Hz is reached, at which point pulse output is stopped.
  • Page 772 PLS2(887) executed. 3-20-8 ACCELERATION CONTROL: ACC(888) Purpose ACC(888) outputs pulses to the specified output port at the specified fre- quency using the specified acceleration and deceleration rate. (Acceleration rate is the same as the deceleration rate.) Either independent mode position- ing or constant mode speed control is possible.
  • Page 773 1 hex: Pulse + direction Always 0 hex. Note: Use the same pulse output method when using both pulse outputs 0 and 1 (CP1H only). S: First Word of Settings Table The content of S to S+2 controls the pulse output as shown in the following diagrams.
  • Page 774 ACC(888) starts pulse output on the port specified in P using the mode speci- fied in M using the target frequency and acceleration/deceleration rate speci- fied in S. The frequency is increased every pulse control period (4 ms) at the acceleration rate specified in S until the target frequency specified in S is reached.
  • Page 775 High-speed Counter/Pulse Output Instructions Section 3-20 • If the difference between the starting speed and target speed is be- tween 200 and 300 KHz, the acceleration/deceleration rate will be 3 Hz or higher. • If the difference between the starting speed and target speed is be- tween 900 and 1,000 KHz, the acceleration/deceleration rate will be 10 Hz or higher.
  • Page 776 S and when that point is reached, the frequency is decreased every pulse control period (4 ms) at the deceleration rate specified in S until the specified number of points has been output, at which point pulse output is stopped.
  • Page 777 Note Triangular Control If the specified number of pulses is less than the number required to reach the target frequency and return to zero, the function will automatically reduce the acceleration/deceleration time and perform triangular control (acceleration and deceleration only.) An error will not occur.
  • Page 778 CW/CCW method. Pulse output is accelerated at a rate of 20 Hz every 4 ms until the target frequency of 500 Hz is reached. When CIO 0.01 turns ON, ACC(888) changes to an acceleration rate of 10 Hz every 4 ms until the target frequency of 1,000 Hz is reached.
  • Page 779 0 hex: CW/CCW 1 hex: Pulse + direction Mode 0 hex: Origin search 1 hex: Origin return Note: Use the same pulse output method when using both pulse outputs 0 and 1. Operand Specifications Area CIO Area Work Area Holding Bit Area...
  • Page 780 Origin Proximity Input Signal Type Origin Input Signal Type An origin search or origin return is started each time ORG(889) is executed. It is thus normally sufficient to use the differentiated version (@ORG(889)) of the instruction or an execution condition that is turned ON only for one scan.
  • Page 781 (3 in diagram). The decelera- tion point is calculated from the number of pulses remaining to the origin and the deceleration rate and when that point is reached, the pulse output is...
  • Page 782 Example When CIO 0.00 turns ON in the following programming example, ORG(889) starts an origin return operation for pulse output 0 by outputting pulses using the CW/CCW method. According to the PLC Setup, the initial speed is 100 pps, the target speed is 200 pps, and the acceleration and deceleration rates are 50 Hz/4 ms.
  • Page 783 Duty factor in increments of 0.1%, Frequency in increments of 1 Hz F: Frequency F specifies the frequency of the pulse output. The value of F must be in one of the following ranges. • When specified in 0.1 Hz units: 0001 to FFFF hex (0.1 and 6,553.5 Hz) •...
  • Page 784: Step Instructions

    Example When CIO 0.00 turns ON in the following programming example, PWM(891) starts pulse output from pulse output 0 at 200 Hz with a duty factor of 50%. When CIO 0.01 turns ON, the duty factor is changed to 25%.
  • Page 785 It defines the start of each process and specified the control bit for it. It is also placed at the end of the step programming area after the last SNXT(009) to indicate the end of the step programming area. When it appears at the end of the step programming area, STEP(008) does not take a control bit.
  • Page 786: Ir0+(++) To ,Ir15+(++) ,-(- -)Ir0 To, -(- -)Ir15

    Step Instructions When defining the beginning of a step, a control bit is specified as follows:. STEP(008) B: Bit When defining the end of a step a control bit is not specified as follows: STEP(008) Variations Variations Executed Each Cycle for ON Condition...
  • Page 787 When SNXT(009) is placed at the very end of the step programming area, it ends step execution and turns OFF the previous control bit. The control bit specified for B is a dummy bit. This bit will however be turned ON, so be sure to select a bit that will not cause problems.
  • Page 788 Input SNXT(009) at the end of the step programming area and make sure that the control bit is a dummy bit in the Work Area. If a control bit for a step is used in the last SNXT(009) in the step programming area, the corresponding step will be started when SNXT(009) is executed.
  • Page 789 Be sure that two steps are not executed during the same cycle. Instructions that Cannot be Used Within Step Programs The instructions that cannot be used within step programs are listed in the fol- lowing table. Function...
  • Page 790 Section 3-21 Step Instructions Step a starts when C turns ON A executed When d turns ON, b starts (A is interlocked) B executed e turns ON (B is interlocked) End of step programming area Normal ladder Returns to normal ladder program...
  • Page 791 Step W0.00 starts from the next instruction W0.00 Step W0.00 Step (A) ladder program 0.01 W0.00 turns OFF, W0.01 turns ON and step W0.01 starts W0.01 Step W0.01 starts from the next instruction W0.01 Step (B) ladder program Step W0.01 0.02...
  • Page 792 0.03 W0.02 W0.02 Step W0.02 (C) Step (C) ladder program 0.04 W100.00 Branching Control 0.01 (Step (A) 0.02 (Step (B) starting condition) starting condition) Step (A) W0.00 Step (B) W0.01 0.03 (Step (A) Step (C) transition 0.04 (Step (B) Step (C) transition condition)
  • Page 793 This is not picked up as an error in the program check using the CX-Program- mer. A duplicate bit error will only occur in a step ladder program only when a control bit in a step instructions is also used in the normal ladder diagram.
  • Page 794 0.02 (Step (A) 0.03 (Step (C) Step (D) Step (B) transition transition condition) condition) Step (B) W0.01 Step (D) W0.03 0.04 (When both Step (B) and Step (D) are complete, moves to Step (E) Step (E) W0.04 0.05 (Step (C) reset conditions)
  • Page 795 Section 3-21 Step Instructions 0.01 W0.00 W0.02 W0.00 Step W0.00 (A) Step (A) ladder program 0.02 W0.01 W0.01 Step W0.01 Step (B) ladder program 200.03 0.04 W0.04 200.03 W0.02 Step W0.02 (C) Step (C) ladder program 0.03 W0.03 W0.03 Step W0.03 Step (D) ladder program W0.04...
  • Page 796: Application Examples

    Sequential Execution and inspection/discharge, be executed in sequence with each process being reset before continuing on the next process. Various sensors (SW1, SW2, SW3, and SW4) are positioned to signal when processes are to start and end. Robot hand Solenoid 1...
  • Page 797 C reset. W100.00 Example 2: The following process requires that a product is processed in one of two ways, Branching Execution depending on its weight, before it is printed. The printing process is the same regardless of which of the first processes is used. Various sensors are posi- tioned to signal when processes are to start and end.
  • Page 798 A and B. Because of the way CIO 0.01 (SW A1) and CIO 0.02 (SW B1) are programmed, only one of these will be exe- cuted with an ON execution condition to start either process A or process B.
  • Page 799 The following process requires that two parts of a product pass simulta- Parallel Execution neously through two processes each before they are joined together in a fifth process. Various sensors are positioned to signal when processes are to start and end.
  • Page 800 A and C. These instructions branch from the same instruction line and are always executed together, starting steps for both A and C. When the steps for both A and C have finished, the steps for process B and D begin immediately.
  • Page 801 Section 3-21 Step Instructions 0.01 (SW1, SW2) Process A started. Process C W0.00 started. W0.02 W0.00 Programming for process A 0.02 (SW3) Process A reset. Process B W0.01 started. W0.01 Programming for process B Used to W0.03 W0.03 turn off process D.
  • Page 802: Basic I/O Unit Instructions

    Operands St: Starting Word CIO 0 to CIO 999 (I/O Bit Area) or CIO 2000 to CIO 2959 (Special I/O Unit Bit Area) E: End Word CIO 0 to CIO 999 (I/O Bit Area) or CIO 2000 to CIO 2959 (Special I/O Unit Bit Area) Note St and E must be in the same memory area.
  • Page 803 When refreshing is specified for words in the Special I/O Unit bit area, all 10 words allocated to the Unit will be refreshed as long as the first word of the 10 words allocated to the Unit is included in the specified range of words.
  • Page 804 OFF in all other cases. Precautions An error will occur if words in both the I/O Bit Area (CIO 0 to CIO 999) and the Special I/O Unit Bit Area (CIO 2000 to CIO 2959) are specified for the same instruction.
  • Page 805 Section 3-22 3-22-2 7-SEGMENT DECODER: SDEC(078) Purpose Converts the hexadecimal contents of the designated digit(s) into 8-bit, 7-seg- ment display code and places it into the upper or lower 8-bits of the specified destination words. Ladder Symbol SDEC(078) S: Source word...
  • Page 806 SDEC(078) regards the data specified by S as 4-digit hexadecimal data, con- verts the digits specified in S by Di (first digit and number of digits) to 7-seg- ment data and outputs the results to D in the bits specified in Di.
  • Page 807 Section 3-22 Examples When CIO 0.00 turns ON in the following example, the contents of the 3 digits beginning with digit 1 in D100 will be converted from hexadecimal data to 7- segment data, and the results will be output to the upper byte of D200 and both bytes of D201.
  • Page 808 I: Input Word (Data Line D0 to D3 Inputs) Specify the input word allocated to the Input Unit and connect the digital switch’s D0 to D3 data lines to the Input Unit as shown in the following dia- gram. Leftmost 4 digits...
  • Page 809 Note: Only when C1 = 0001 hex to read 8 digits. C1: Number of Digits Specifies the number of digits that will be read from the external digital switch. Set C1 to 0000 hex to read 4 digits or 0001 hex to read 8 digits. 12 11 Number of digits...
  • Page 810 (either 4-digit or 8-digit, specified in C1) of digital switch data line data from I, and stores the result in D and D+1. (If 4 digits are read, the result is stored in D. If 8 digits are read, the result is stored in D and D+1.) DSW(210) reads the 4-digit or 8-digit switch data once every 16 cycles, and then starts over and continues reading the data.
  • Page 811 D0 to D3. The digital switch is connected through CIO 3 and CIO 104. Since 8 digits of data are being read, C1 (D32000 in this case) is set to 0001 hex. D32001 is used as the system word.
  • Page 812 I: Input Word (Data Line Inputs) Specify the input word allocated to the Input Unit and connect the ten-key key- pad’s 0 to 9 data lines to the Input Unit as shown in the following diagram. Bits 00 to 09 correspond to keys 0 to 9.
  • Page 813 ,–(– –)IR0 to, –(– –)IR15 Description TKY(211) reads numeric data from input word I, which is allocated to a ten- key keypad connected to an Input Unit, and stores up to 8 digits of BCD data in register words D and D +1.
  • Page 814 There is no restriction on the number of times that TKY(211) can appear in the program. External Connections Connect the ten-key keypad so that the switches for keys 0 through 9 are input to contacts 0 through 9 of the Input Unit, as shown in the following dia- gram. Tenkey pad CPM1A-20EDT...
  • Page 815 I: Input Word (Data Line D0 to D3 Inputs) Specify the input word allocated to the Input Unit and connect the hexadeci- mal keypad’s D0 to D3 data lines to the Input Unit as shown in the following diagram. Bits 00 to 03 correspond...
  • Page 816 Specifies the leading word address where the hexadecimal keypad’s numeric input (up to 8 digits) will be stored. (In addition, each time that a key is pressed, the corresponding bit in D+2 (0 to F) will be turned ON and remains ON until another key is pressed.)
  • Page 817 Description HKY(212) outputs the selection signals to bits 00 to 03 of O, reads the data in order from bits 00 to 03 of I, and stores up to 8 digits of hexadecimal data in register words D and D+1.
  • Page 818 Section 3-22 Basic I/O Unit Instructions External Connections Connect the hexadecimal keypad to Input Unit contacts 0 to 3 and Output Unit contacts 0 to 3, as shown in the following diagram. CPM1A-20EDT Sixteen-key Pad Timing Chart 16-key selection signals...
  • Page 819 In this example, HKY(212) reads up to 8 digits of hexadecimal data from a hexadecimal keypad and stores the data in D0 and D1. The hexadecimal key- pad is connected through CIO 2 and CIO 102. D32000 is used as the system word.
  • Page 820 Basic I/O Unit Instructions Operands I: Input Word Specify the input word allocated to the Input Unit and connect the 8 input sig- nal lines to the Input Unit as shown in the following diagram. Bits 00 to 07 correspond to Input Unit inputs 0 to 7.
  • Page 821 32 to 47. Bits 00 to 15 correspond to matrix elements 48 to 63. C: System Word Specifies a work word used by the instruction. This word cannot be used in any other application. System word (Cannot be accessed by the user.)
  • Page 822 MTR(213) outputs the selection signals to bits 00 to 07 of O, reads the data in order from bits 00 to 07 of I, and stores the 64 bits of data in the 4 words D through D+3. MTR(213) reads the status of the 64-bit matrix every 24 CPU Unit cycles.
  • Page 823 Basic I/O Unit Instructions Precautions Do not read or write the system word (C) from any other instruction. MTR(213) will not operate correctly if the system word is accessed by another instruction. The system word is not initialized by MTR(213) in the first cycle when program execution starts.
  • Page 824 Rightmost 4-digit data output C: Control Data The value of C indicates the number of digits of source data and the logic for the Input and Output Units, as shown in the following table. (The logic refers to the transistor output’s NPN or PNP logic.) Source data Display’s data input logic...
  • Page 825 7SEG(214) displays the 4-digit or 8-digit data in 12 cycles, and then starts over and continues displaying the data. The One Round Flag (bit 08 of O when converting 4 digits, bit 12 of O when converting 8 digits) is turned ON for one cycle in every 12 cycles after 7SEG(214) has turned ON each of the latch output signals.
  • Page 826 This example shows an 8-digit display. With a 4-digit display, the data outputs (D0 to D3) would be connected to outputs 0 to 3 and the latch outputs (LE0 to LE3) would be connected to outputs 4 to 7. Output point 12...
  • Page 827 D101 and outputs the data through CIO 102. There are 8 digits of data being output and the 7-segment display’s logic is the same as the Output Unit’s logic, so the control data (C) is set to 0004. D32000 is used as the system word, D.
  • Page 828 Special I/O Unit or CPU Bus Unit whose unit number is designated by S and outputs the data to D. Refer to the operation manual of the Special I/ O Unit or CPU Bus Unit from which data is being read for specific details for each Unit.
  • Page 829 • The number of words to transfer (S) is outside the range of 0001 to 0080 (hex). • The unit number (S) is outside the range of 0000 to 005F hex or 8000 to 800F hex. • A Special I/O Unit or CPU Bus Unit not affected by IORD(222) is desig- nated.
  • Page 830 Outputs the contents of the CPU Unit’s I/O memory area to a Special I/O Unit or CPU Bus Unit. This instruction can be used in the CP1H CPU Units only. It cannot be used in the CP1L CPU Units. If IOWR(223) is used in a CP1L CPU Unit, Error Flag (ER) will be turned ON.
  • Page 831 Description IOWR(223) writes the designated number of words (D) from the first source word (designated by S) onwards and outputs them to the Special I/O Unit or CPU Bus Unit that has the unit number designated by D. Unit number of Special I/O Unit or CPU Bus Unit...
  • Page 832 • The number of words to transfer (D) is outside the range of 0001 to 0080 (hex). • The unit number (D) is outside the range of 0000 to 005F hex or 8000 to 800F hex. • A Special I/O Unit or CPU Bus Unit not affected by IOWR(223) is desig- nated.
  • Page 833 • Specific data refreshing for Units such as Units that support data links This instruction can be used in the CP1H CPU Units only. It cannot be used in the CP1L CPU Units. If DLNK(226) is used in a CP1L CPU Unit, Error Flag...
  • Page 834 Block program areas Step program areas Subroutines Interrupt tasks Operands N: Unit number Specifies the CPU Bus Unit’s unit number (0000 to 000F hex or 0 to 15 deci- mal). Operand Specifications Area CIO Area CIO 0 to CIO 6143...
  • Page 835 The following table shows how DLNK(226) differs from IORF(097). Instruction Operation DLNK(226) • I/O refreshing of the CPU Bus Unit Area in the CIO Area (25 words) • I/O refreshing of the CPU Bus Unit Area in the DM Area (100 words) •...
  • Page 836 Basic I/O Unit Instructions Precautions I/O refreshing will not be performed if a CPU Bus Unit Error (A402.07) or CPU Bus Unit Setup Error (A402.03) has occurred in the specified CPU Bus Unit. I/O refreshing will be stopped if an I/O Bus Error occurs while I/O refreshing is being performed by DLNK(226).
  • Page 837 Data link area Controller Link The actual timing for data link area refreshing in this example is as follows: • When transmitting: Data is transmitted over the network the next time that the token right is acquired. (The transmitted data is delayed up to 1 com- munications cycle time max.)
  • Page 838: Serial Communications Instructions

    There are two types of serial communications instruction. The TXD(236), RXD(235), TXDU(256), and RXDU(255) instructions send and receive data in no-protocol (custom) communications with an external device. PMCR(260) sends and receives data using user-defined protocols with an external device. The difference is shown in the following tables. Note (1) The TXD(236) and RXD(235) instructions transfer data only through a port on a Serial Communications Option Board.
  • Page 839 Calls and executes a communications sequence registered in a CJ-series Serial Communications Unit. This instruction can be used in the CP1H CPU Units only. It cannot be used in the CP1L CPU Units. If PMCR(260) is used in a CP1L CPU Unit, Error Flag (ER) will be turned ON.
  • Page 840 Always set a word address for R even if there is no receive data. If a constant is set, an error will occur, the Error Flag will turn ON, and PMCR(260) will not be executed. If there is no receive data, R will not be used and can be used for other purposes.
  • Page 841 12 to 15 of C1 and the physical port specified in bits 8 to 11 of C1 for the unit address specified in bits 0 to 7 of C1. If a symbol is specified as the operand for a send message, the number of send words specified in S and beginning from S+1 will be used as the send area.
  • Page 842 CJ-series Expansion Units. The unit address of the communications part- ner must be set in bits 0 to 7 of C1 to specify which Unit is to be used and the serial port number must be set in bits 8 to 11. Unit addresses are specified as shown in the following table.
  • Page 843 PMCR(260). To prevent more than one communications sequence from being executed for the same logical port, the corresponding Communications Port Enable Flag (A202.00 to A202.07) should be used as a N.O. input in the exe- cution condition for PMCR(260), as shown in the above diagram.
  • Page 844 Add NC condition to program for the Serial Setting Change Flag. 2401 (hex) No registration table An error has occurred in the protocol macro data or data is being trans- mitted. Transmit the protocol macro data using the CX-Programmer. Others Refer to the CJ-series Communications Commands Reference Manual (W342) for other response codes.
  • Page 845 7 (A202.07) is ON and the Protocol Macro Execution Flag (CIO 1500.15) is OFF. If an operand is specified for the symbol in a send message, 2 words of data starting from D101 will be used as the send area (because the contents of D100 is #0003).
  • Page 846 If this function is used, data will be transferred from the first m words of the receive area to the receive buffer after the buffer is cleared to all zeros but before the communications sequence is executed. This pre-...
  • Page 847 Section 3-23 Serial Communications Instructions The following programming example shows the instructions used to con- stantly or periodically execute PMCR(260) to read data through a single receive operation. Protocol Communica- Macro tions Port En- Always ON Execution abled Flag Flag...
  • Page 848 Section 3-23 Serial Communications Instructions 3-23-3 TRANSMIT: TXD(236) Purpose Outputs the specified number of bytes of data from a serial port on a Serial Communications Option Board mounted to the CPU Unit. Ladder Symbol TXD(236) S: First source word C: Control word...
  • Page 849 Data can be sent only when the port’s Send Ready Flag is ON. The Send Ready Flag is A392.13 serial port 1 and A392.05 for serial port 2. Up to 259 bytes can be sent, including the send data (N = 256 bytes max.), the start code, and the end code.
  • Page 850 N is 256 bytes. Data is sent in the order specified in C. Nothing will be sent if 0 is specified for N. If RS signal control is specified in C, bit 15 of S will be used as the RS signal.
  • Page 851 If ER signal control is specified in C, bit 15 of S will be used as the ER signal. If RS and ER signal control is specified in C, bit 15 of S will be used as the RS signal and bit 14 of S will be used as the ER signal.
  • Page 852 Serial Communications Instructions Example: Sending Data When CIO 0.01 and the Serial Port 1 Send Ready Flag (A392.13) are ON in the following example, five bytes of data starting from the lower byte of D100 is sent to the Serial Communications Option Board mounted in option slot 1.
  • Page 853 Section 3-23 Serial Communications Instructions 3-23-4 RECEIVE: RXD(235) Purpose Reads the specified number of bytes of data from a serial port on a Serial Communications Option Board mounted to the CPU Unit. Ladder Symbol RXD(235) D: First destination word C: Control word...
  • Page 854 Serial Communications Option Board and stores N bytes of data in words D to D+(N 2)–1. If N bytes of data has not been received at the port, then only the data that has been received will be stored.
  • Page 855 Precautions RXD(235) can be used only for serial ports on Serial Communications Option Boards mounted to the CPU Unit. In addition, the port must be set to no-proto- col mode. The following receive message frame format can be set in the PLC Setup.
  • Page 856 15 of D. If CS and DR signal monitoring is specified in C, the status of the CS signal will be stored in bit 15 of D and the status of the DR signal will be stored in bit 14 of D.
  • Page 857 Section 3-23 Serial Communications Instructions Related PLC Setup Settings The following PLC Setup settings must be made for the serial port 1 or serial port 2 executing RXD(235). after setting the communications mode to no-pro- tocol (RS-232C mode). Setting Description...
  • Page 858 A CJ Unit Adapter is required to use CJ-series Serial Communications Units. This instruction can be used in the CP1H CPU Units only. It cannot be used in the CP1L CPU Units. If TXDU(256) is used in a CP1L CPU Unit, Error Flag (ER) will be turned ON.
  • Page 859 Note The serial port’s unit address can be specified directly by setting the serial port number to 0 and setting the destination unit address to the serial port’s unit address. (Set the destination unit address to 80 hex + 4...
  • Page 860 0 to 7 of C+1, through the port specified with bits 8 to 11 of C+1. The logical port number can be set to any value between 0 and 7 and is specified with bits 12 to 15 of C+1.
  • Page 861 DM Setup Area. If start and end codes are specified, the codes will be added to the send data (N). In this case, the maximum number of bytes that can be specified for N is 256 bytes.
  • Page 862 If ER signal control is specified in C, bit 15 of S will be used as the ER signal. If RS and ER signal control is specified in C, bit 15 of S will be used as the RS signal and bit 14 of S will be used as the ER signal.
  • Page 863 The flag status is retained until the next communica- tions instruction is executed. Even if an error has occurred, a flag will be reset to 0 the next time that a communications instruction is executed for that port. Completion Codes...
  • Page 864 Serial Communications Unit with unit number 2. The 5 bytes of output data are read from the DM Area beginning at the rightmost byte of D100 and out- put through logical port 3 to a general-purpose device such as a printer.
  • Page 865 Serial Communications Unit's unit address to the serial port's unit address. (Set the unit address to 80 hex + 4 x unit number for port 1 or 81 hex + 4 x unit number for port 2.) C+1:...
  • Page 866 A CJ Unit Adapter is required to use CJ-series Serial Communications Units. This instruction can be used in the CP1H CPU Units only. It cannot be used in the CP1L CPU Units. If RXDU(255) is used in a CP1L CPU Unit, Error Flag (ER) will be turned ON.
  • Page 867 D. If fewer than N bytes of data have been received at the port, then only the data that has been received will be stored. The logical port number can be set to any value between 0 and 7 and is specified with bits 12 to 15 of C+1.
  • Page 868 Section 3-23 Serial Communications Instructions The following diagram shows the order in which data is sent and the contents of the send frame for various start and end code settings. No Start or End Code Data Number of bytes (Specified in allocated...
  • Page 869 15 of D. If CS and DR signal monitoring is specified in C, the status of the CS signal will be stored in bit 15 of D and the status of the DR signal will be stored in bit 14 of D.
  • Page 870 ON. Program the Reception Completed Flag as a normally open condition of RXDU(255). An error will occur and the Error Flag will turn ON in the following cases. • The Communications Port Enabled Flag for the specified logical port is OFF when RXDU(255) is executed.
  • Page 871 The flag status is retained until the next communica- tions instruction is executed. Even if an error has occurred, a flag will be reset to 0 the next time that a communications instruction is executed for that port. Completion Codes...
  • Page 872 Indicates the number of bytes received in hexadecimal, between 0000 and 0100 hex (0 to 256 decimal). Example: Flag Operation The following diagram shows the operation of RXDU(255) and related flags. End code or specified number of bytes received. Reception processing...
  • Page 873 3: Communications port No. 3 Most significant bytes Least significant bytes D: D100 D101 D102 Received in 1 2 3 4 5 6 7 8 A B C D E F G H I J K L specified D103 order: 10 bytes D104...
  • Page 874 2 hex: Port 2 In CP1L L (14 or 20 I/O points) CPU Units: 1 or 2 hex: Port 1 0 hex: Invalid setting (The Error Flag will go ON if 0 hex is specified.) Operand Specifications Area CIO Area...
  • Page 875 STUP(237) writes 10 words of data from S to S+9 to the communications setup area of the Unit with the specified unit address, as shown in the follow- ing table. When the constant #0000 is designated to S, the communications settings of the corresponding port will be set to default.
  • Page 876 When CIO 0.00 turns ON in the following example, the communications parameters for serial port 1 of the Serial Communications Unit will be changed to the settings contained in the 10 words from D100 to D109. In this example, the setting are changed the protocol mode to the protocol macro mode.
  • Page 877: Network Instructions

    FA control devices. (Refer to the CS/CJ/CP Series Communications Commands Reference Man- ual for details on FINS commands.) With FINS commands it is possible to communicate (by the command/response format) with any Unit in any network on just by specifying the network address, node number, and unit number of the destination Unit.
  • Page 878 CS-series Inner Board: E1 hexadecimal e. Computer:01 Unit number Destination device (hexadecimal) Node number Unit number +10 Node number Node number Node number Note It is also possible to directly specify a serial port (unit address) within the des- tination device.
  • Page 879 Port 1: 80 hex + 4 unit number Unit number Hexadecimal AC B0 Decimal 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 Port 2: 81 hex + 4 unit number Unit number Hexadecimal AD B1...
  • Page 880 In order to communicate through the network, it is necessary to register a routing table in each PLC’s CPU Unit which indicates the route by which data will be transferred to the desired node. Each routing table is made up of a local network table and a relay network table.
  • Page 881 By sending a SEND(090), RECV(098), or CMND(490) instruction to a serial port set to Host Link mode, the necessary Host Link header and terminator will be attached to the FINS command and the command will be sent to the host computer.
  • Page 882 Host Link Slave Communications from a Host Computer (Host Link) It is possible to send FINS commands from a host computer to the PLC to which it is connected as well as other devices in the network (CPU Units, Spe- cial I/O Units, computers, etc.).
  • Page 883 Port Numbers instructions can be executed simultaneously. Only one instruction can be exe- cuted at a time for each communications port. Exclusive control must be used when more than 8 instructions are executed. These 8 communications port numbers are shared by the network instructions...
  • Page 884 Section 3-24 Network Instructions Automatic Allocation of The port number can be specified as “F” instead of from 0 to 7 to automati- Communications Ports cally allocate the communications port, i.e., the next open communications port is used automatically. @Communica- tions instruction When “F”...
  • Page 885 Each flag will turn ON for just one cycle after a communications Communications Error error occurs. Bits 00 to 07 correspond to ports 0 to 7. Use the Used Communications Port Number stored in A218 to determine which flag to access.
  • Page 886 Communica- tions instruc- tions completed. tion executed. Communications Port Enabled Flags (A20200 to A20207) Normal completion: First Cycle Flags after Network Communications Finished (A21400 to A2407) ON for one cycle Communications Port Com- Cleared to zeros Response stored pletion Codes (A203 to A210)
  • Page 887 A218 Confirms that the First Cycle Flags after Network Communications Finished for the (Used port) automatically allocated port number (corresponding bit for word b in A214) is ON. c (Standby) Confirms that the First Cycle Flags after Network Communications Error for the automatically allocated port number (corresponding bit for word b in A215) is OFF.
  • Page 888 Accessing the Completion Code after Executing Communications Instructions The completion codes are generally used to troubleshoot errors when they occur. A completion code of 0000 hex can, however, also be used to confirm that communications have completed normally. Execution condition...
  • Page 889 DI(693) and EI(694) to disable interrupts before and after communications instructions using automatically allocated communications port numbers in the cyclic tasks regardless of whether user-specified or automatically allo- cated communications port numbers are being used in the interrupt tasks. An example is shown below. Cyclic Execution Task...
  • Page 890 Preventing Exceeding the Maximum Number of Communications Ports If there is a possibility of executing more than eight communications instruc- tions at the same time, use the following type of programming to confirm if a communications port is available even when using automatically allocated communications port numbers.
  • Page 891 When CMND(490) is being executed, the content of S is read and the corresponding FINS command is composed. 3. If the send processing cannot be completed in a the time available in “serial communications port servicing” period, the processing will be continued in the next cycle’s serial communications port servicing.
  • Page 892 FINS command.) 3-24-2 About Explicit Message Instructions (CP1H Only) Methods for Using Explicit There are two methods that can be used to send explicit messages from a Message Communications PLC. • Use the CMND(490) to send a FINS command code of 2801 hex (EXPLICIT MESSAGE SEND).
  • Page 893 Error Flag for FINS commands is used to determine if the explicit message was never sent (i.e., when the flag is ON) or if there was an error in the explicit message that was sent (i.e., when the flag is OFF).
  • Page 894 Section 3-24 Network Instructions 2) Error End The are two possibilities for error ends, as described in the next two subsec- tions. a) When the Explicit Message Could Not Be Sent In this case, the explicit message was never sent on the network, e.g., because the network was not running.
  • Page 895 When the Explicit Message Was Sent But an Explicit Error Response Was Returned In this case, the explicit message was sent but an error existed in the explicit message command frame (code not supported, illegal size, etc.). Here, the Explicit Communications Error Flag (A213.00 to A213.07: Communications...
  • Page 896 Ladder Programming Example 1: User Specification of Communications Port Number Examples Communications Port Enabled Flag Execution a (Executing) is turned ON and held ON when the A202.00 condition execution condition and Communications Port KEEP Enabled Flag (A202.00) turn ON. a (Executing) is turned OFF when d (Execution...
  • Page 897 Port: F The automatically allocated port number stored in A218 (application communications port numbers 0 to 7 is moved to a user-specified work word b (port). A218 Detects when the First Cycle Flag after Network Communications Finished b (port) for the automatically allocated communications port is ON in A214, i.e., the...
  • Page 898 (a) Set the destination unit address (bits 00 to 07 of C+2) to the unit address of the CPU Unit or CJ-series Serial Communications Unit and set the serial port number (bits 08 to 11 of C+1) to 1 for port 1 or 2 for port 2.
  • Page 899 (6) The maximum node number depends on the network being used. For a Controller Link, the allowed range is 00 to 20 hexadecimal (0 to 32). Set the destination node number to FF to broadcast to all nodes; set it to 00 to transmit within the local node.
  • Page 900 This is known as a broadcast transmis- sion. If a response is requested (bits 12 to 15 of C+3 set to 0) but a response has not been received within the response monitoring time, the data will be retransmitted up to 15 times (retries set in bits 0 to 3 of C+3).
  • Page 901 SEND(090) can be executed to transmit data from the PLC to the host computer the next time that the PLC has the right to transmit. It is also possible to transmit to other host computers connected to other PLCs elsewhere in the network.
  • Page 902 The Error Flag will be turned ON in this case. When an address in the current bank of the EM Area is specified for D, the transmitted data will be written to the current EM bank of the destination node.
  • Page 903 07) are ON in the following example, the ten words from D100 to D109 are transmitted to node number 3 in the local network where they are written to the ten words from D200 to D209. The data will be retransmitted up to 3 times if a response is not received within ten seconds.
  • Page 904 PLC. (a) Set the source unit address (bits 00 to 07 of C+2) to the unit ad- dress of the CP-series CPU Unit or the Serial Communications Unit and set the serial port number (bits 08 to 11 of C+1) to 1 for port 1 or 2 for port 2.
  • Page 905 81 + 4 1 = 85 hex (133 decimal) (4) When specifying the serial port without a routing table for the serial gate- way function (conversion to host link FINS), set the serial port’s unit ad- dress in the source network address byte.
  • Page 906 Data can be received from a host computer connected to the PLC’s serial port (when set to host link mode) as well as a PLC or computer connected through a Controller Link or Ethernet network.
  • Page 907 (the FINS command enclosed in the host link header and terminator). If the destination serial port is in the local PLC, set the network address to 00 (local network) in C+1, set the node address to 00 (local PLC) in C+2, and set the unit address to 00 (Serial Communications Option Board on CPU Unit), or unit number + 10 hexadecimal (CJ-series Serial Communications Unit).
  • Page 908 The Error Flag will be turned ON in this case. When an address in the current bank of the EM Area is specified for D, the transmitted data will be written to the current EM bank of the destination node.
  • Page 909 (The default setting of 0000 sets a monitoring time of 2 seconds.) Note (1) The number of bytes of command data in C is 0002 to the maximum data length in hexadecimal. For example, the number of bytes would be 0002 to 07C6 hex (2 to 1,990 bytes) for Controller Link systems.
  • Page 910 Bus Unit) (b) Set the destination unit address directly into bits 00 to 07 of C+3. In this case, set the serial port number in bits 08 to 11 of C+2 to 0 for direct specification. CP1H or CP1L M (30 or 40 I/O points) CPU Unit Serial Commu-...
  • Page 911 (8) The maximum node number depends on the network being used. For a Controller Link, the allowed range is 00 to 20 hexadecimal (0 to 32). Set the destination node number to FF to broadcast to all nodes; set it to 00 to transmit within the local node.
  • Page 912 This is known as a broad- cast transmission. If a response is requested (bits 12 to 15 of C+4 set to 0) but a response has not been received within the response monitoring time, the command data will be retransmitted up to 15 times (retries set in bits 0 to 3 of C+3).
  • Page 913 CMND(490) can be executed to transmit any FINS command from the PLC to the host computer the next time that the PLC has the right to trans- mit. It is also possible to transmit to other host computers connected to other PLCs elsewhere in the network.
  • Page 914 • Sending to a PLC operating as a Host Link Slave The serial gateway function can be used to send any FINS command to a PLC that is connected as a host link slave and through a serial port on a CP1H Serial Communications Option Board or CJ-series Serial Commu- nications Unit.
  • Page 915: Send

    2-byte command code (0101), the 2-byte completion code, and then the 10 words of data, for a total of 12 words or 24 bytes. The data will be retransmitted up to 3 times if a response is not received...
  • Page 916: Explt

    Purpose Sends an explicit message with any service code. This instruction can be used in the CP1H CPU Units only. It cannot be used in the CP1L CPU Units. If EXPLT(720) is used in a CP1L CPU Unit, Error Flag (ER) will be turned ON.
  • Page 917 Set the number of bytes of source data from words S+1 on. For example, set S to 000A hex if there are 5 words of data (S+1 to S+5). Do not include the 2 bytes in word S itself. Include the leftmost bytes of S+1 to S+5, which contain 00.
  • Page 918 The allowed setting range is 0 to 010E hex (270 words). If the number of words of received data exceeds the value set here, a FINS error will occur (response too long, code 11 0B) and no data at all will be stored (in the area starting at D+3).
  • Page 919 D+2. Number of Bytes Settings The number of bytes of send data in S includes the 10 bytes in S+1 to S+5 as well as the number of bytes of service data beginning at S+6. (For example, if there is 1 byte of service data, there are 11 bytes of data all together, so S must be set to 000B hex.)
  • Page 920 The corresponding Communications Port Completion Code (A203 to A210) will be 0000 hex if the instruction ended normally, an explicit message error code if an explicit messaging error occurred, or a FINS error code if a FINS error occurred. For details on the general operation of the explicit message instructions, refer to 3-24-2 About Explicit Message Instructions (CP1H Only).
  • Page 921 (order of data in the line). For example, when the service data is in 2-byte or 4-byte units, the order of data in the frame is left- most to rightmost order in 2-digit pairs, as shown in the following diagram.
  • Page 922 Operations from a DRT2 Slave (I/O Terminal). In this case, the Total ON Time or Number of Contact Operations for input 3 are read. Service Code = 0E hex, Class ID = 09 hex, Instance ID = 03 hex, and Attribute ID = 66 hex.
  • Page 923: Egatr

    Explicit DRM2-OD16 Slave message with node address 45 Number of bytes of data: S+1 to S+5 = 5 words = 10 bytes = 0A hex S+1: Slave’s node address = 45 = 2D hex S+2: Service Code = 0E hex...
  • Page 924 Specifies the first word of the received message (D to D+267 max.). Contains the number of bytes of received service data from words D+1 on. Does not include the 2 bytes in word D itself. Includes only the number of bytes of Service Data starting at D+1.
  • Page 925 The allowed setting range is 0 to 010C hex (268 words). If the number of words of received data exceeds the value set here, a FINS error will occur (response too long, code 11 0B) and no data at all will be stored (in the area starting at D+3).
  • Page 926 0001 hex. D will contain 0001 hex regardless of the byte order setting, i.e., whether the byte is stored in the rightmost or leftmost byte of D.) The setting in bits 12 to 15 of C+1 (0 or 8 hex) determines the byte-order of the service data stored at S+6 and D+3.
  • Page 927 (order of data in the line). For example, when the service data is in 2-byte or 4-byte units, the order of data in the frame is left- most to rightmost order in 2-digit pairs, as shown in the following diagram.
  • Page 928 2-byte or 4-byte units. 1. Data in 2-byte Units • Storing Data from the Leftmost Byte (Bits 12 to 15 of C = 0 hex) Example: Storing the value 1234 hex in D+1 The data in the frame is...
  • Page 929 In this case, the Total ON Time or Number of Contact Operations for input 3 are read. Service Code = 0E hex, Class ID = 95 hex, Instance ID = 01 hex, and Attribute ID = 65 hex. The general status is returned in 1 byte.
  • Page 930: Esatr

    Sends an information write command in an explicit message (Set Attribute Single, ServiceCode: 10 hex). This instruction can be used in the CP1H CPU Units only. It cannot be used in the CP1L CPU Units. If ESATR(722) is used in a CP1L CPU Unit, Error Flag (ER) will be turned ON.
  • Page 931 Specifies the first word of the send message (S to S+271 max.). Set the number of bytes of source data from words S+1 on. For example, set S to 0008 hex if there are 4 words of data (S+1 to S+4). Do not include the 2 bytes in word S itself.
  • Page 932 C. When the response to the explicit message is received, it is stored in the range of words beginning at D+2. The setting in bits 12 to 15 of C (0 or 8 hex) determines the byte-order of the service data stored at S+5.
  • Page 933 The corresponding Communications Port Completion Code (A203 to A210) will be 0000 hex if the instruction ended normally, an explicit message error code if an explicit messaging error occurred, or a FINS error code if a FINS error occurred. For details on the general operation of the explicit message instructions, refer to 3-24-2 About Explicit Message Instructions (CP1H Only).
  • Page 934 (order of data in the line). For example, when the service data is in 2-byte or 4-byte units, the order of data in the frame is left- most to rightmost order in 2-digit pairs, as shown in the following diagram.
  • Page 935 Section 3-24 Network Instructions • Storing Data from the Rightmost Byte (Bits 12 to 15 of C = 8 hex) Example: Storing the value 1234 hex in S+5 The data in the frame is in the order 34 Frame In this case, 1234 hex is...
  • Page 936: Echrd

    Explicit Slave (I/O Terminal) message with node address 10 Number of bytes of data: S+1 to S+6 = 6 words = 12 bytes = 0C hex S:+1 Slave’s node address = 10 = 0A hex S+2: Class ID = 08 hex...
  • Page 937 Specifies the leading word address containing the data to be read from the remote CPU Unit. D: First Destination Word in Local CPU Unit Specifies the leading word address where the read data will be stored in the local CPU Unit. C: First Control Word Specifies the first of five control words (C to C+4).
  • Page 938 Reads the specified number of words from the first read word (specified in S) in the remote CPU Unit with the node address specified in C, and stores the data in the local CPU Unit memory words beginning at D.
  • Page 939 Example In this example, ECHRD(723) is used to read the I/O memory of a CJ-series CPU Unit on the DeviceNet network, and store the data in the I/O memory of the local CPU Unit. Communications Port Enabled Flag (Port 6) 0.00...
  • Page 940: Echwr

    Writes data from the local CPU Unit to another CPU Unit in the network. This instruction can be used in the CP1H CPU Units only. It cannot be used in the CP1L CPU Units. If ECHWR(724) is used in a CP1L CPU Unit, Error Flag (ER) will be turned ON.
  • Page 941 ,–(– –)IR0 to, –(– –)IR15 Description Writes the specified number of words beginning at S from the local CPU Unit to the write destination beginning at D in the remote CPU Unit with the node address specified in C. Note ECHWR(724) sends an explicit message with the Service Code 1E hex (Byte Data Write).
  • Page 942 The corresponding Communications Port Completion Code (A203 to A210) will be 0000 hex if the instruction ended normally, an explicit message error code if an explicit messaging error occurred, or a FINS error code if a FINS error occurred. For details on the general operation of the explicit message instructions, refer to 3-24-2 About Explicit Message Instructions (CP1H Only).
  • Page 943 When CIO 0.00 and A202.06 (the Communications Port Enabled Flag for port 6) are ON, ECHWR(724) reads D0 to D2 from the I/O memory of the local CPU Unit and stores the data in D100 to D102 of the CJ-series CPU Unit with node address 7 on the DeviceNet Network.
  • Page 944: Function Page

    Section 3-25 Display Instructions D200 Node address of remote CPU Unit to be written to = 07 hex (node 07) C+1: D201 Write data size (number of words) = 3 hex Communications port = 6 hex (port 6), C+2: D202 and the DeviceNet Unit’s unit address = 12 hex...
  • Page 945 To clear a message that has been registered, execute MSG(046) with S set to the message number of the message you want to clear and N set to a con- stant (0000 to FFFF).
  • Page 946 SCH(047) displays two user-specified digits on the 7-segment display on the CPU Unit. This instruction can be used in the CP1H CPU Units only. It cannot be used in the CP1L CPU Units. If SCH(047) is used in a CP1L CPU Unit, Error Flag (ER) will be turned ON.
  • Page 947 The display will remain even if the execution condition of SCH(047) goes OFF. Use SCTRL(048) to clear the display. If the contents of C is not 0000 or 0001 hex, an error will occur, the ER Flag will turn ON, and nothing will be displayed.
  • Page 948 CPU Unit according to specifications for individual display segments. This instruction can be used in the CP1H CPU Units only. It cannot be used in the CP1L CPU Units. If SCTRL(048) is used in a CP1L CPU Unit, the Instruc- tion Processing Error Flag (A295.08) will be turned ON.
  • Page 949 7-segment display on the CPU Unit according to the value of C. Any combination of segments can be lit. The display will remain until SCTRL(048) is executed with C set to #0000 to clear all of the display segments.
  • Page 950 Example When W0.02 turns ON in the following example, the individual segments of the 7-segment display on the CPU Unit will be controlled according to the con- tents of D200 (7678 =“Ht”). The display remains even when W0.02 turns OFF.
  • Page 951: Clock Instructions

    HOURS TO SECONDS SECONDS TO HOURS CLOCK ADJUSTMENT DATE 3-26-1 CALENDAR ADD: CADD(730) Purpose Adds time to the calendar data in the specified words. Ladder Symbol CADD(730) C: First calendar word T: First time word R: First result word Variations...
  • Page 952 Section 3-26 Clock Instructions Operands C through C+2: Calendar Data Set the calendar data in C through C+2 as shown in the following diagram. Seconds: 00 to 59 (BCD) Minutes: 00 to 59 (BCD) Hour: 00 to 23 (BCD) Day: 01 to 31 (BCD)
  • Page 953 Section 3-26 Clock Instructions R through R+2: Result Data R through R+2 contain the result of the addition. Seconds: 00 to 59 (BCD) Minutes: 00 to 59 (BCD) Hour: 00 to 23 (BCD) Day: 01 to 31 (BCD) Month: 01 to 12 (BCD)
  • Page 954 Section 3-26 Clock Instructions Description CADD(730) adds the calendar data (words C through C+2) to the time data (words T and T+1) and outputs the resulting calendar data to R through R+2. Minutes Seconds Hour Year Month Minutes Seconds Hours...
  • Page 955 Subroutines Interrupt tasks Operands C through C+2: Calendar Data Set the calendar data in C through C+2 as shown in the following diagram. Seconds: 00 to 59 (BCD) Minutes: 00 to 59 (BCD) Hour: 00 to 23 (BCD) Day: 01 to 31 (BCD)
  • Page 956 Section 3-26 Clock Instructions R through R+2: Result Data R through R+2 contain the result of the addition. Seconds: 00 to 59 (BCD) Minutes: 00 to 59 (BCD) Hour: 00 to 23 (BCD) Day: 01 to 31 (BCD) Month: 01 to 12 (BCD)
  • Page 957 OFF in all other cases. Examples When CIO 0.00 turns ON in the following example, the time data in D200 and D201 (hours, minutes, seconds) is subtracted from the calendar data in D100 through D102 (year, month, day, hour, minutes, seconds) and the result is out- put to D300 through D302.
  • Page 958 Subroutines Interrupt tasks Operands S and S+1: Source Data Set the hours/minutes/seconds source data in S and S+1, as shown in the fol- lowing diagram. Seconds: 00 to 59 (BCD) Minutes: 00 to 59 (BCD) Hours: 0000 to 9999 (BCD) D and D+1: Result Data D and D+1 contain the result data in seconds-only format.
  • Page 959 Operation Error Flag ON if the minutes data in S (bits 08 to 15) is not BCD and in the range 00 to 59. ON if the seconds data in S (bits 00 to 07) is not BCD and in the range 00 to 59.
  • Page 960 Subroutines Interrupt tasks Operands S and S+1: Source Data Set the seconds source data in S and S+1, as shown in the following diagram. Rightmost 4 digits Seconds: 0000 to 9999 (BCD) Leftmost 4 digits Seconds: 0000 to 3599 (BCD) D and D+1: Result Data D and D+1 contain the result data in hours/minutes/seconds format.
  • Page 961 Name Label Operation Error Flag ON if the seconds data in S and S+1 is not BCD and in the range 0 to 35,999,999. OFF in all other cases. Equals Flag ON if the content of D+1, D is 00000000 after the operation.
  • Page 962 Section 3-26 Clock Instructions Examples When CIO 0.00 turns ON in the following example, the seconds data in D100 and D101 (123,456 seconds) is converted to hours/minutes/seconds data and the result is output to D200 and D201. 0.00 D100 S: D100...
  • Page 963 Clock Instructions Operands S through S+3: New Clock Setting Set the new clock setting in S through S+3 as shown in the following diagram. S through S+3 must be in the same data area. Seconds: 00 to 59 (BCD) Minutes: 00 to 59 (BCD)
  • Page 964 ON if the new clock setting in S through S+3 is not within the specified range. OFF in all other cases. Precautions An error will not be generated even if the internal clock is set to a non-existent date (such as November 31).
  • Page 965: Always Set To

    Section 3-27 Debugging Instructions Examples When CIO 0.00 turns ON in the following example, the internal clock is set to 20:15:30 on Thursday, May 2, 2005. 0.00 D100 S: D100 Minute Second D101 Day of Hour the month D102 Year...
  • Page 966 It is possible to incorporate two or more TRSM(045) instructions in a program. In this case, the value of the same specified bit or word will be stored in Trace Memory each time that one of the TRSM(045) instructions is executed.
  • Page 967 The following table shows relevant bits and flags in the Auxiliary Area. Only A508.14 and A508.15 are meant to be controlled by the user, and A508.15 must not be turned ON from the program, i.e., it must be turned ON only from the CX-Programmer.
  • Page 968 See note. Valid from here on Note Trace Memory has a ring structure. Data is stored to the end of the Trace Memory area and then wraps to the beginning of the area, ending just before the first valid data sample.
  • Page 969: Failure Diagnosis Instructions

    Generating or Clearing User-defined Non-fatal Errors The following table shows the function of the operands. Note The value of operand N must be different from the content of A529 (the system-generated FAL/FALS number). Function #0001 to #01FF Clears the non-fatal error with the correspond- ing FAL number.
  • Page 970: Operand Specifications

    The operation of FAL(006) depends on the value of N. Set N to 0000 to clear an error and set N to 0001 to 01FF to generate an error. A system error will be generated if the value of N equals the content of A529.
  • Page 971 A360.01 to A391.15 Displaying Messages with Non-fatal User-defined Errors If S is a word address and an ASCII message has been stored at S, that mes- sage will be displayed at the Programming Device when FAL(006) is exe- cuted. (If a message is not required, set S to a constant.) The message beginning at S will be registered when FAL(006) is executed.
  • Page 972 Failure Diagnosis Instructions Generating Non-fatal System Errors When FAL(006) is executed with N set to an FAL number (&1 to &511) that is equal to the content of A529 (the system-generated FAL/FALS number), a non-fatal error will be generated with the error code and error details code specified in S and S+1.
  • Page 973 Every cycle (when an FAL Error occurs) ting is read Even if PLC Setup word 129 bit 15 is set to 1 (Do not record FAL Errors in Error Log.), the following errors will be recorded: • Fatal errors generated by FALS(007) •...
  • Page 974 The value of S will determine the processing, as shown in the following ta- ble. Process &1 to &511 (0001 to 01FF hex) The FAL error of the specified number will be cleared. FFFF hex All non-fatal errors (including system errors) will be cleared.
  • Page 975 A400. Precautions N must between 0000 and 01FF. An error will occur and the Error Flag will be turned ON if N is outside of the specified range. Examples Generating a Non-fatal Error When CIO 0.00 is ON in the following example, FAL(006) will generate a non-...
  • Page 976 (000A hex) is stored in A529. 1,2,3... 1. The specified error code (0200) will be written to A400 if it is the most se- rious error. 2. The error code and the time/date that the error occurred will be written to the Error Log Area (A100 through A199).
  • Page 977 0200 D201 0001 Error unit number: 1 3-28-2 SEVERE FAILURE ALARM: FALS(007) Purpose Generates user-defined fatal errors. Fatal errors stop PLC operation. Ladder Symbol • Generating User-defined Fatal Errors FALS(007) N: FALS number S: First message word or constant (0000 to FFFF) •...
  • Page 978 N equals the content of A529.) Generating Fatal User-defined Errors When FALS(007) is executed with N set to an FALS number (1 to 511) that is not equal to the content of A529 (the system-generated FAL/FALS number), a...
  • Page 979 C101 TO C2FF Displaying Messages with Fatal User-defined Errors If S is a word address, the ASCII message beginning at S will be displayed at the Programming Device when FALS(007) is executed. (If a message is not required, set S to a constant.) The message beginning at S will be registered when FALS(007) is executed.
  • Page 980 Section 3-28 Failure Diagnosis Instructions When FALS(007) is executed with N set to an FAL number (1 to 511) that is equal to the content of A529 (the system-generated FAL/FALS number), a fatal error will be generated with the error code and error details code speci- fied in S and S+1.
  • Page 981 There are two ways to clear fatal system errors generated with FALS(007). 1. Turn the PLC OFF and then ON again. 2. When keeping the PLC ON, the system error must be cleared as if the specified error had actually occurred.
  • Page 982 S to S+7 will be displayed if the null character is omitted. N must between 0001 and 01FF. An error will occur and the Error Flag will be turned ON if N is outside of the specified range.
  • Page 983 (000A hex) is stored in A529. 1,2,3... 1. The specified error code (80E1) will be written to A400 if it is the most se- rious error. 2. The error code and the time/date that the error occurred will be written to the Error Log Area (A100 through A199).
  • Page 984 T: Monitoring Time T must be between 0 and 9,999 decimal (between 0000 and 270F hex). A value of 0 disables time monitoring; values in the range of 1 to 270F set the monitoring time from 0.1 to 999.9 seconds.
  • Page 985 Time Monitoring Function FPD(269) starts timing when it is executed (when execution condition A goes ON); it will generate a non-fatal error and turn ON the Carry Flag if the diag- nostic output is not turned ON within the specified monitoring time.
  • Page 986 The following processing will be performed when the Carry Flag is turned ON. (This processing will not be performed if the FAL number is set to 000 in C.) 1,2,3... 1. The FAL Error Flag (A402.15) will be turned ON. (PLC operation contin- ues.)
  • Page 987 Not possible to use. Bit Address and Message Output (C=8@@@) When the leftmost digit of C is set to 8, the ASCII address of the input bit is output to R+2 to R+4. R contains two flags which indicate whether an input bit has been found and whether it is used in a normally open or normally closed input condition.
  • Page 988 Not possible to use. Register words R+2 to R+4 indicate the address of the input which prevented the diagnostic output from being turned ON. The bit address is output to these words in ASCII. The following table shows the ASCII representations for each area.
  • Page 989 Every cycle (when an FAL Error occurs) read Even if PLC Setup word 129 bit 15 is set to 1 (Do not record FAL Errors in Error Log.), the following errors will be recorded: • Fatal errors generated by FALS(007) •...
  • Page 990 (R) setting. The monitoring time is refreshed only when FPD(269) is executed. If the cycle time is longer than 100 ms, the monitoring time will not be refreshed normally and FPD(269) will not operate correctly because the monitoring time is...
  • Page 991 1,2,3... 1. The Carry Flag is turned ON. 2. When the rightmost 3 digits of C specify an FAL number of 00A hex (10), the corresponding Executed FAL Number Flag (A360.10) will be turned ON, the corresponding error code (410A) is written in A400, and the FAL Error Flag (A402.15) is turned ON.
  • Page 992 (CIO 200.00) to go ON after the execution condition (CIO 1000.00) goes ON. If the measured time exceeds the monitoring time in T, the measured time is multiplied by 1.5 and that value is stored in T as the new monitoring time.
  • Page 993 A598.00 Execution condition CIO 200.00 No error generated. Diagnostic output CIO 1000.00 Measured time: t 1.5) Teaching : Initial setting in T : Measured time t’ : New setting in T after teaching (When t > t , t’ 1.5)
  • Page 994: Other Instructions

    Interrupt tasks Description When the execution condition is ON, STC(040) turns ON the Carry Flag (CY). Although STC(040) turns the Carry Flag ON, the flag will be turned ON/OFF by the execution of subsequent instructions which affect the Carry Flag.
  • Page 995 Description When the execution condition is ON, CLC(040) turns OFF the Carry Flag (CY). Although CLC(040) turns the Carry Flag OFF, the flag will be turned ON/ OFF by the execution of subsequent instructions which affect the Carry Flag. Flags...
  • Page 996 10 ms (0 to 39,990 ms). The following table shows the watchdog timer settings in the PLC Setup. The default value for the maximum cycle time is 1,000 ms, although it can be set anywhere from 1 to 40,000 ms in 10-ms units.
  • Page 997 Saves the current status of the Condition Flags in a separate area within the CPU Unit. The current status of the Flags is preserved so that it can be read (restored) with CCL(283) at a different location in the program, in a different task, or even in a later cycle.
  • Page 998 CPU Unit. The Status of the following Condition Flags will be preserved: ER, CY, >, =, <, N, OF, UF, >=, <>, and <=. The preserved status of the Condition Flags can be read (restored) later only with CCL(283), the LOAD CONDITION FLAGS instruction.
  • Page 999 There are no flags affected by these instructions. Examples In the following example, CCS(282) preserves the results of a Comparison so that this result can be used as an execution condition later in the program. 0.00 When CIO 0.00 is ON in the following...
  • Page 1000 When the execution condition is ON, CCL(283) restores (reads) the status of the Condition Flags (except for the ALWAYS ON and ALWAYS OFF Flags). The Status of the following Condition Flags will be restored (read): ER, CY, >, =, <, N, OF, UF, >=, <>, and <=.
  • Page 1001 2. FRMCV(284) determines the CP-series PLC memory address that corre- sponds to the same CV-series data area address. 3. The CP-series PLC memory address is output to D. (An index register (IR0 to IR15) must be specified for D.) The following example shows FRMCV(284) used to convert the CV-series PLC memory address in D0.

Table of Contents