Omron CX-PROGRAMMER 5.0-FUNCTION BLOCK OPERATION Operation Manual

Omron CX-PROGRAMMER 5.0-FUNCTION BLOCK OPERATION Operation Manual

Function blocks
Table of Contents

Advertisement

Cat.No. W438-E1-01
SYSMAC
WS02-CXPC1-E-V50
CS1-H, CJ1-H, CJ1M CPU Units
CX-Programmer Ver.5.0
OPERATION MANUAL
Function Blocks

Advertisement

Table of Contents
loading

Summary of Contents for Omron CX-PROGRAMMER 5.0-FUNCTION BLOCK OPERATION

  • Page 1 Cat.No. W438-E1-01 SYSMAC WS02-CXPC1-E-V50 CS1-H, CJ1-H, CJ1M CPU Units CX-Programmer Ver.5.0 OPERATION MANUAL Function Blocks...
  • Page 2 CX-Programmer Ver. 5.0 WS02-CXPC1-E-V50 CS1-H, CJ1-H, CJ1M CPU Units Operation Manual Function Blocks Produced July 2004...
  • Page 4  OMRON, 2004 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 6: Table Of Contents

    Instruction Support and Operand Restrictions........
  • Page 7 TABLE OF CONTENTS viii...
  • Page 8: About This Manual

    This manual describes the function blocks and related functionality of the CX-Programmer Ver. 5.0 used together with CS1-H, CJ1-H, and CJ1M CPU Units with unit version 3.0 or later, and includes the sections described on the next page. The CX-Programmer Ver. 5.0 is software that enables the per- sonal computer to be used as a function block programming device, and can be used only for SYS- MAC CS-series and CJ-series CPU Units that support function blocks.
  • Page 9 !WARNING Failure to read and understand the information provided in this manual may result in per- sonal injury or death, damage to the product, or product failure. Please read each section in its entirety and be sure you understand the information provided in the section and...
  • Page 10 Application Precautions ........
  • Page 11: 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-men- tioned applications.
  • Page 12: Application Precautions

    • If the other operand specifying a size is a variable, the CX-Programmer Ver. 5.0 will not output an error when compiling, even if the size of the array variable is not the same as that specified by the other operand (variable).
  • Page 13 Do not turn OFF the power supply to the CPU Unit when the BKUP indicator is lit. The data will not be backed up if power is turned OFF. To display the status of writing to flash...
  • Page 14 Application Precautions • Values are passed in a batch from the input parameters to the input vari- ables before algorithm execution (not at the same time as the instructions in the algorithm are executed). Therefore, to pass the value from a...
  • Page 15 Application Precautions...
  • Page 16 Variable Properties ........
  • Page 17: Introducing The 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 18: Function Block Specifications

    Computer IBM PC/AT or compatible computers 133 MHz Pentium or faster with Windows 98, SE, or NT 4.0 (with service pack 6 or higher) Microsoft Windows 95, 98, SE, Me, 2000, XP, or NT 4.0 (with service pack 6 or higher) Memory 64 Mbytes min.
  • Page 19: Files Created With Cx-Programmer Ver. 5.0

    The file memory program file (*.obj) includes function block definitions and blocks as instances. files Function Each function block definition can be stored as a single file (.cxf) for reuse in block library other projects. files Note The structured text (ST language) conforms to the IEC 61131-3 standard, but CX-Programmer Ver.
  • Page 20: Main Menu

    Function Block Library A function block definition created in a project with CX-Programmer Ver. 5.0 Files (*.cxf) can be saved as a file (1 definition = 1 file), enabling definitions to be loaded into other programs and reused. Project Text Files Data equivalent to that in project files created with CX-Programmer Ver.
  • Page 21 This command updates the instance with the new information and clears the error. Go To Function Block Definition Displays the selected instance’s function block definition on the right side of the window. Shortcut Keys...
  • Page 22: Function Blocks

    A function block is a basic program element containing a standard processing function that has been defined in advance. Once the function block has been defined, the user just has to insert the function block in the program and set the I/O in order to use the function.
  • Page 23: Function Block Structure

    The variables in the function block cannot be accessed directly from the out- side, so the data can be protected. (Data cannot be changed unintentionally.) Improved Reusability with The function block’s I/O is entered as variables, so it isn’t necessary to change Variable Programming data addresses in a block when reusing it.
  • Page 24 CPU Unit is either 128 or 1,024 depending on the CPU Unit model. Instances To use an actual function block definition in a program, create a copy of the function block diagram and insert it in the program. Each function block defini- tion that is inserted in the program is called an “instance”...
  • Page 25 256 or 2,048 instances can be created for a single CPU Unit depending on the CPU Unit model. The allowed number of instances is not related to the number of function block definitions and the number of tasks in which the instances are inserted.
  • Page 26 Even if an input source address (i.e., an input parameter) or an output desti- nation address (i.e., an output parameter) is a word address, the data that is passed will be the data in the form and size specified by the variable data type starting from the specified word address.
  • Page 27 &8 variables OFF_TIME If internal variables are not used, if processing will not be affected, or if the internal variables are used in other locations, the same instance name can be used at multiple locations in the program. Cyclic task 0...
  • Page 28: Variables

    1-3-1 Introduction In a function block, the addresses (see note) are not entered as real I/O mem- ory addresses, they are all entered as variable names. Each time an instance is created, the actual addresses used by the variable are allocated automati- cally in the specified I/O memory areas by the CX-Programmer.
  • Page 29: Variable Properties

    Array Settings A variable can be treated as a single array of data with the same properties. To convert a variable to an array, specify that it is an array and specify the maximum number of elements. This property can be set for internal variables only. Only one-dimensional arrays are supported by the CX-Programmer Ver.
  • Page 30: Variable Properties And Variable Usage

    (FALSE). Set a WORD variable to a value between 0 and 65,535 (between 0000 and FFFF hex). If an initial value is not set, the variable will be set to 0. For example, a bool- ean variable would be 0 (FALSE) and a WORD variable would be 0000 hex.
  • Page 31: Converting Function Block Definitions To Library Files

    Although the words can be input when creating a function block, an error will occur when the program is checked. If this area is specified not to be retained in the Function Block Memory Allocation Dialog Box, turn the power ON/OFF or clear the area without retaining the values when starting opera- tion.
  • Page 32: Usage Procedures

    Once a function block definition has been created and an instance of the algo- rithm has been created, the instance is used by calling it when it is time to execute it. Also, the function block definition that was created can be saved in a file so that it can be reused in other projects (PLCs).
  • Page 33: Reusing Function Blocks

    PLCs. 1,2,3... 1. Select the function block that you want to save and save it as a function block definition file (*.cxf). 2. Open the other PLC’s project and open/read the function block definition file (*.cxf) that was saved.
  • Page 34 PLCs, as well as usage precautions and guidelines. Function Block Specifications ........
  • Page 35 2-6-23 Network Instructions ........
  • Page 36: Function Block Definition

    Comment Function blocks can have comments. Function Block Each function block definition has a name. The names can be up to 64 char- Definition Name acters long and there are no prohibited characters. The default function block name is FunctionBlock@, where @ is a serial number.
  • Page 37: Timx Tim_A Off_Time

    • Variables name cannot contain spaces or any of the following characters: ! “ # $ % & ‘ ( ) = - ~ ^ \ | ‘ @ { [ + ; * : } ] < , > . ? / •...
  • Page 38 1. The same name cannot be assigned to an input variable and output vari- able. If it is necessary to have the same variable as an input variable and output variable, register the variables with different names and transfer the value of the input variable to the output variable in the function block with an instruction such as MOV.
  • Page 39 Section 2-1 Initial Value Initial values can be set for input variables, but the value of the input parame- ter will be enabled (the input parameter value will be set when the parameter for input variable EN goes ON and the instance is executed).
  • Page 40 AT setting (specified addresses). Initial Value An initial value can be set for an output variable that is not being retained, i.e., when the Retain Option is not selected. An initial value cannot be set for an output variable if the Retain Option is selected.
  • Page 41 When the Retain Option is selected, the value of the variable is retained when the power is interrupted or operation starts unless the CPU Unit does not have a backup battery. If the CPU Unit does not have a good battery, the value will be unstable.
  • Page 42 Variable Properties Variable Name The variable name is used to identify the variable in the function block. The name can be up to 30,000 characters long. The same name can be used in other function blocks. Note A variable name must be input for variables, even ones with AT settings (spec- ified address).
  • Page 43 • An array can have from 1 to 32,000 array elements. • The array setting can be set for internal variables only. • Any data type can be specified for an array variable, as long as it is an internal variable.
  • Page 44 Note Equations can contain only arithmetic operators (+, − , *, and /). An array is a collection of data elements that are the same type of data. Each array element is specified with the same variable name and a unique index.
  • Page 45: Instance Specifications

    First or Last of Multiple Words. Initial Values When an instance is executed the first time, initial values can be set for input variables, internal variables, and output variables. For details, refer to Initial Value under the preceding descriptions of input variables, internal variables, and output variables.
  • Page 46 • Instance names cannot contain spaces or any of the following characters: ! “ # $ % & ‘ ( ) = - ~ ^ \ | ‘ @ { [ + ; * : } ] < , > . ? / •...
  • Page 47 Section 2-2 Instance Specifications (2) Bit data can be accessed even if the DM or EM Area is specified for the non-retained area or retained area. (3) The same bank number cannot be specified as the current bank in the user program if the EM Area is specified for the non-retained area or re- tained area.
  • Page 48 If the user program contains an instruction to access the function block Instance Area from the instance area, an error will be displayed in the Compile Tab of the Output Win- User Program dow of CX-Programmer if the following operations are attempted.
  • Page 49: Parameter Specifications

    Body Use the same internal variables Use different internal variables 2-2-2 Parameter Specifications The data that can be set by the user in the input parameters and output parameters is as follows: Item Applicable data Input parameters Values (See note 1.), addresses, and program symbols (glo- bal symbols and local symbols) (See note 2.)
  • Page 50: Operating Specifications

    EN is ON. Instance In this case, the input to EN is bit 0.0 at the left of the diagram. • When the input to EN is ON, the instance is executed and the execution results are reflected in bit 1.0 and word D10.
  • Page 51 3. Write values from output Parameters variables to parameters. Data cannot be exchanged with parameters in the algorithm itself. In addition, if an output variable is not changed by the execution of the algo- rithm, the output parameter will retain its previous value.
  • Page 52: Restrictions On Function Blocks

    Internal variable a !Caution An instance will not be executed while its EN input variable is OFF, so Differ- entiation and Timer instructions will not be initialized while EN is OFF. If Differ- entiation or Timer instructions are being used, use the Always ON Flag (P_On) for the EN input condition and include the instruction’s input condition...
  • Page 53 Differentiation An instance will not be executed while its EN input variable is OFF, so the fol- Instructions in Function lowing precautions are essential when using a Differentiation Instruction in a Block Definitions function block definition.
  • Page 54 Timer Instructions in An instance will not be executed while its EN input variable is OFF, so the fol- Function Block Definitions lowing precautions are essential when using a Timer Instruction in a function block definition.
  • Page 55 0.00 The timer’s completion flag (UP) is turned OFF when input condition a (0.00) goes OFF. • If the same instance containing a timer is used in multiple locations at the same time, the timer will be duplicated. ST Programming •...
  • Page 56 Error-related If a fatal error occurs in the CPU Unit while a function block definition is being Restrictions executed, ladder program execution will stop at the point where the error occurred.
  • Page 57: Function Block Applications Guidelines

    Determining Variable Types (Inputs, Outputs, Externals, and Internals) Using Input Variable to To paste a function block into the program and then change the value (not the Change Passed Values address itself) to be passed to the function block for each instance, use an input variable.
  • Page 58: At Settings For Internal Variables

    W501 is passed. The address can be specified, but the address itself is not passed. • Values are passed in a batch from the input parameters to the input vari- ables before algorithm execution (not at the same time as the instruction in the algorithm is executed).
  • Page 59: Array Settings For Internal Variables

    2-6 Instruction Support and Operand Restrictions. 2. Set the data in each of the array elements using the MOV instruction in the function block definition. 3. Specify the first (or last) element of the array variable for the operand. This enables specification of the first (or last) address in a range of words.
  • Page 60: Specifying Addresses Allocated To Special I/O Units

    Note When ST language is used, it isn’t necessary to use an array to receive the result of a division operation. Also, the remainder can’t be calculated directly in ST language. The remainder must be calculated as follows: Remainder = Dividend −...
  • Page 61: Using Index Registers

    (e.g., &b in second operand of SETB instruction when writing and TST instruction when reading). Example: Special I/O Units 1) Specify the first CIO Area word n (n = CIO 2000 + unit number × 10) Instance for function block definition A. Used constants:...
  • Page 62 IR0. Note (1) When Index Registers IR0 to IR15 are used within function blocks, using the same Index Register within other function blocks or in the program outside of function blocks will create competition between the two in- stances and the program will not execute properly.
  • Page 63 Section 2-4 Function Block Applications Guidelines Application Examples The following examples are for using Index Registers IR0 to IR15 within func- tion blocks. Example Details Saving the Index Register Value before Using Index Register When Index Registers are used within this...
  • Page 64: Precautions For Instructions With Operands Specifying The First Or Last

    (or external variable setting). Therefore, the variable data type and num- ber of array elements are unrelated to the operation of the instruction. Either specify a variable with an AT setting, or an array variable with a size that matches the data size to be processed by the instruction.
  • Page 65 Precautions for Instructions with Operands Specifying the First or Last of Multiple Section 2-5 Size to Be Processed in the Instruction Operand Is Fixed Make sure that the number of elements in the array is the same as size to be processed by the instruction. Otherwise, the CX-Programmer will output an error when compiling.
  • Page 66 The result depends on the following conditions. Size to Be Processed by Instruction Is Fixed If the size to be processed by the instruction is a fixed operand, and this size does not match the number of array elements, the CX-Programmer will output a compile error.
  • Page 67: Instruction Support And Operand Restrictions

    Using a WORD data type with 10 elements for both variables a and b: To transfer 20 words, be sure to specify 20 elements for both array variables a and b. Internally allocated address Internally allocated address Example: H700...
  • Page 68: Sequence Input Instructions

    • Any operands for which an AT setting must be specified for an I/O mem- ory address on a remote node in the network are indicated as Specify address at remote node with AT setting in the AT setting or array required column.
  • Page 69 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported AT setting or code variable array variable data types required (Required word data size shown in parentheses.) AND NOT AND NOT BOOL !AND NOT @AND NOT %AND NOT...
  • Page 70: Sequence Output Instructions

    Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported AT setting or code variable array variable data types required (Required word data size shown in parentheses.) BIT TEST AND TST S: Source word WORD AND TST...
  • Page 71 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported AT setting or code variable array variable data types required (Required word data size shown in parentheses.) B: Bit BOOL @SET %SET !SET !@SET !%SET RESET RSET...
  • Page 72: Sequence Control Instructions

    (Required word data size shown in parentheses.) NO OPERATION NOP INTERLOCK INTERLOCK CLEAR MULTI-INTER- MILH N: Interlock number # + decimal MILH LOCK DIFFER- only ENTIATION D: Interlock Status BOOL HOLD MULTI-INTER- MILR N: Interlock number # + decimal...
  • Page 73: Timer And Counter Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-4 Timer and Counter Instructions Instruction Mnemonic Function Symbol Operands Supported AT setting or code variable array variable data types required (Required word data size shown in parentheses.) TIMER N: Timer number TIMER...
  • Page 74 COUNTER (See note.) CNRX N1: 1st number in TIMER or CNRX range COUNTER @CNRX (See note.) (BIN) N2: Last number in TIMER or range COUNTER (See note.) Note Enabled when the same variable is specified for N1 and N2.
  • Page 75: Comparison Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-5 Comparison Instructions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) Symbol Compari- LD,AND, OR 300 (=) S1: Comparison...
  • Page 76 1 S2: Comparison DINT data 2 TABLE TCMP S: Source data WORD TCMP COMPARE @TCMP T: 1st word of table WORD Yes (16) R: Result word UINT MULTIPLE MCMP S1: 1st word of set WORD Yes (16) MCMP COMPARE...
  • Page 77: Data Movement Instructions

    Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) DOUBLE AREA ZCPL CD: Compare data UDINT ZCPL RANGE COMPARE...
  • Page 78 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported AT setting or code variable array variable data types required (Required word data size shown in parentheses.) MOVE NOT S: Source WORD @MVN D: Destination WORD DOUBLE MOVE...
  • Page 79: Data Shift Instructions

    Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported AT setting or code variable array variable data types required (Required word data size shown in parentheses.) SINGLE WORD DIST S: Source word WORD DIST DISTRIBUTE @DIST...
  • Page 80 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported AT setting or code variable array variable data types required (Required word data size shown in parentheses.) ASYNCHRO- ASFT C: Control word UINT ASFT NOUS SHIFT @ASFT...
  • Page 81 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported AT setting or code variable array variable data types required (Required word data size shown in parentheses.) DOUBLE RORL Wd: Word UDINT RORL ROTATE RIGHT @RORL ROTATE RIGHT...
  • Page 82: Increment/Decrement Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-8 Increment/Decrement Instructions Instruction Mnemonic Function Symbol Operands Supported AT setting code variable or array data types variable required (Required word data size shown in parenthe- ses.) INCREMENT Wd: Word UINT BINARY DOUBLE INCRE-...
  • Page 83 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) DOUBLE SIGNED Au: 1st augend DINT BINARY ADD word WITHOUT CARRY...
  • Page 84 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) DOUBLE SIGNED Mi: Minuend word DINT BINARY SUB- Su: Subtrahend...
  • Page 85 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) DOUBLE SIGNED Md: 1st multiplicand DINT BINARY MULTIPLY word Mr: 1st multiplier...
  • Page 86 Instruction Support and Operand Restrictions Section 2-6 Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) DOUBLE SIGNED Dd: 1st dividend DINT BINARY DIVIDE word Dr: 1st divisor word DINT...
  • Page 87: Conversion Instructions

    Instruction Support and Operand Restrictions Section 2-6 Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) DOUBLE BCD Dd: 1st dividend DWORD DIVIDE word @/BL Dr: 1st divisor word DWORD...
  • Page 88 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) DOUBLE 2’S COM- NEGL S: 1st source word DWORD NEGL...
  • Page 89: Logic Instructions

    Instruction Support and Operand Restrictions Section 2-6 Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) SIGNED BCD-TO- BINS C: Control word UINT BINS BINARY @BINS...
  • Page 90 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operand Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) LOGICAL OR I1: Input 1 WORD @ORW I2: Input 2...
  • Page 91: Special Math Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-12 Special Math Instructions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) BINARY ROOT ROTB S: 1st source word...
  • Page 92 Instruction Support and Operand Restrictions Section 2-6 Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) FLOATING TO 32- FIXL S: 1st source word REAL FIXL...
  • Page 93 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) SINE S: 1st source word REAL @SIN R: 1st result word...
  • Page 94 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) Floating Symbol LD, AND, 329 (=F) S1:Comparoson REAL Using LD:...
  • Page 95: Double-Precision Floating-Point Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-14 Double-precision Floating-point Instructions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) DOUBLE FLOATING FIXD S: 1st source word LREAL...
  • Page 96 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) DOUBLE DEGREES RADD S: 1st source word LREAL RADD TO RADIANS...
  • Page 97: Table Data Processing Instructions

    Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) DOUBLE LOGA- LOGD S: 1st source word LREAL LOGD RITHM...
  • Page 98 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) PUSH ONTO PUSH Not supported in func- TB: 1st stack...
  • Page 99 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) FIND MINIMUM C: 1st control word UDINT @MIN R1: 1st word in...
  • Page 100: Data Control Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-16 Data Control Instructions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) PID CONTROL S: Input word UINT...
  • Page 101: Subroutine Instructions

    Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) SCALING 2 SCL2 S: Source word SCL2 @SCL2 P1: 1st parameter...
  • Page 102: Interrupt Control Instructions

    Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) GLOBAL SUBROU- GSBN Not supported in func- N: Subroutine num-...
  • Page 103: High-Speed Counter And Pulse Output Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-19 High-speed Counter and Pulse Output Instructions (CJ1M-CPU21/ 22/23 Only) Instruction Mnemonic Function Symbol/Operands Function Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.)
  • Page 104: Step Instructions

    Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol/Operands Function Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) ACCELERATION P: Port specifier UINT CONTROL @ACC M: Output mode...
  • Page 105 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) 7-SEGMENT SDEC S: Source word UINT SDEC DECODER @SDEC Di: Digit designator UINT...
  • Page 106: Serial Communications Instructions

    Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) INTELLIGENT I/O IORD C: Control data UINT IORD READ @IORD...
  • Page 107 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) TRANSMIT S: 1st source word UINT Yes (not fixed) @TXD...
  • Page 108: Network Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-23 Network Instructions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) NETWORK SEND SEND S: 1st source word...
  • Page 109 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) EXPLICIT SET ESATR S: 1st word of send WORD Yes (not...
  • Page 110: File Memory Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-24 File Memory Instructions Instruction Mnemonic Function Symbol Operand Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) READ DATA FILE FREAD C: Control word...
  • Page 111: Clock Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-26 Clock Instructions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) CALENDAR ADD CADD C: 1st calendar WORD...
  • Page 112: Debugging Instructions

    Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) SECONDS TO S: 1st source word DWORD Yes (2) HOURS...
  • Page 113: Failure Diagnosis Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-28 Failure Diagnosis Instructions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) FAILURE ALARM N: FAL number # + decimal...
  • Page 114: Block Programming Instructions

    Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) CONVERT FRMCV Not supported in func- S: Word containing ADDRESS FROM...
  • Page 115 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) CONDITIONAL ELSE Not supported in func- BLOCK BRANCH- tion blocks...
  • Page 116: Text String Processing Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-31 Text String Processing Instructions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) MOV STRING MOV$ S: 1st source word...
  • Page 117 Section 2-6 Instruction Support and Operand Restrictions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) REPLACE IN RPLC$ S1: Text string first UINT Yes (not...
  • Page 118: Task Control Instructions

    Section 2-6 Instruction Support and Operand Restrictions 2-6-32 Task Control Instructions Instruction Mnemonic Function Symbol Operands Supported code variable setting or data types array variable required (Required word data size shown in parenthe- ses.) TASK ON TKON N: Task number...
  • Page 119: Special Instructions For Function Blocks

    CPU Unit Function Block Specifications The specifications of the functions blocks used in CS/CJ-series CS1-H, CJ1- H, and CJ1M CPU Units with version 3.0 or later are as follows. Refer to the other Operation Manuals for the CS/CJ Series for other specifications.
  • Page 120 Section 2-7 CPU Unit Function Block Specifications Item Specification × × Extended Data 32K words 1 bank 32K words 1 bank × × × × Memory words words words words E0_00000 to E0_00000 to E0_32767 13 banks 7 banks 3 banks...
  • Page 121 1,024 jump number in JMP instruction Internal inputs 10 points • 4 interrupt inputs (pulse catch) • 2 high-speed counter inputs (50-kHz phase dif- ference or 100-kHz single-phase) Internal outputs 6 points 6 points • 2 pulse outputs (100 kHz) •...
  • Page 122: Operation Of Timer Instructions

    When instruction is The PV is refreshed each time the instruction is executed. executed If the PV is 0, the Completion Flag is turned ON. If it is not 0, the Completion Flag is turned OFF. When execution of all All PV are refreshed once each cycle.
  • Page 123: Number Of Function Block Program Steps And Instance Execution Time

    CS/CJ-series CPU Units with unit version 3.0 or later. Number of steps = Number of instances × (Call part size m + I/O parameter transfer part size n × Num- ber of parameters) + Number of instruction steps in the function block definition p (See note.)
  • Page 124 Output variables with a 1-word data type (INT): 2 Total instruction processing time in function block definition section: 10 µ s Execution time for 1 instance = 6.8 µ s + (3 + 2) × 0.3 µ s + 10 µ s = 18.3 µ s...
  • Page 125 Section 2-8 Number of Function Block Program Steps and Instance Execution Time Note The execution time is increased according to the number of multiple instances when the same function block definition has been copied to multiple locations.
  • Page 126: Creating Function Blocks

    Creating a Project ........
  • Page 127: Procedural Flow

    Inserting Instances in the Ladder Section Window and then Inputting the Instance Name 1,2,3... 1. Place the cursor at the location at which to create an instance (i.e., a copy) of the function block and press the F Key. 2. Input the name of the instance.
  • Page 128 Refer to 3-2-5 Setting Function Block Parameters Using the P Key for details. the Function Block 1,2,3... 1. Place the cursor at the position of the input variable or output variable and press the P Key. 2. Input the source address for the input variable or the destination address for the output variable.
  • Page 129: Procedures

    3-2-2 Creating a New Function Block Definition 1,2,3... 1. When a project is created, a Function Blocks icon will appear in the project workspace as shown below. Function Blocks will appear under the PLC. 2. Function block definitions are created by inserting function block defini- tions after the Function Blocks icon.
  • Page 130 Tab and the select the default file in the OMRON FB library storage location field. 3. Specify the folder in which the OMRON FB Library file is located, select the library file, and click the Open Button. The library file will be inserted as a...
  • Page 131 One of the following windows will be displayed when the newly created Func- Definitions tion Block 1 icon is double-clicked (or if it is right-clicked and Open is selected from the popup menu). A variable table for the variables used in the function block is displayed on top and an input area for the ladder program or struc- tured text is displayed on the bottom.
  • Page 132: Defining Function Blocks Created By User

    • To add a variable to the last line, select Insert Variable from the popup menu. • To add the variable to the line above or below a line within the list, se- lect Insert Variable - Above or Below from the popup menu.
  • Page 133 (4) The following text is used to indicate I/O memory addresses in the PLC and thus cannot be input as variable names in the function block variable table. • A, W, H, HR, D, DM, E, EM, T, TIM, C, or CNT followed by a numeric value...
  • Page 134 (variable type: internal). Contact entered with function block internal variable aaa as operand. The rest of the ladder program is input in exactly the same way as for stan- dard programs with CX-Programmer. Note Addresses cannot be directly input for instruction operands within function blocks.
  • Page 135: Registering Variables As Required

    ST program input directly or pasted from one created in a text editor. Note (1) Tabs or spaces can be input to create indents. They will not affect the al- gorithm. (2) The display size can be changed by holding down the Ctrl Key and turn- ing the scrolling wheel on a wheel mouse.
  • Page 136: At Settings

    Instruction input. Function block internal variable registered. 5. If the type or properties of a variable that was input are not correct, double- click the variable in the variable table and make the required corrections.
  • Page 137 Select Array Variable. Input the number of elements. When the name of an array variable is entered in the algorithm in the func- tion block definition, square brackets surrounding the index will appear af- ter the array name.
  • Page 138 Operand: Address and I/O under Options in Tools Menu Comment The user program symbol names (in the global symbol table only) will be gen- erated automatically as AutoGen_ + Address (if the option is deselected, the symbol names will be removed).
  • Page 139: Creating Instances From Function Block Definitions

    Select the function block from which to create an instance. 3. As an example, set the instance name in the FB Instance Field to sample, set the function block in the FB Definition Field to FunctionBlock1, and click the OK Button. As shown below, a copy of the function block definition called FunctionBlock1 will be created with an instance name of sample.
  • Page 140: Setting Function Block Parameters Using The P Key

    Note If changes are made in the I/O variables in a variable table for a function block definition, the bus bar to the left of all instances that have been created from that function block definition will be displayed in red to indicate an error. When this happens, select the function block, right-click, and select Update Invoca- tion.
  • Page 141 Set the data in all the input parameters. If even a single input parameter remains blank, the left bus bar for the instance will be displayed in red to indi- cate an error. If this happens, the program cannot be transferred to the CPU Unit.
  • Page 142 Note If a non-boolean data type is used for the input variable and only a numerical value (e.g., 20) is input, the value for the CIO Area address (e.g, CIO 0020) will be passed, and not the numerical value. To set a numerical value, always −...
  • Page 143: Setting The Fb Instance Areas

    C4095 1024 Note (1) Bit data can be accessed even if the DM or EM Area is specified for the non-retained area or retained area. (2) The Function Block Holding Area words are allocated in H512 to H1535. These words cannot be specified in instruction operands in the user pro- gram.
  • Page 144: Checking Internal Address Allocations For Variables

    1,2,3... 1. Select View - Symbols - Global. 2. Select the instance in the global symbol table, right-click, and select Func- tion Block Memory Address from the popup menu. (Alternately, select Function Block Memory - Function Block Memory Address from the PLC Menu.)
  • Page 145 Memory in the variables’ instance area. Consecutive addresses are required for each instance, so all of the variables will be allocated to a different block of addresses if the original block of addresses cannot accommodate the change in variables. This will result in an unused block of addresses. The following procedure can be used to eliminate the unused areas in memory so that memory is used more efficiently.
  • Page 146: Copying And Editing Function Block Definitions

    CPU Unit’s internal flash memory is the value multiplied by 1,024 and divided by 4. • The Used #, Free #, and Max # fields under Function Block refer to the number of function block definitions. 3-2-11 Compiling Function Block Definitions (Checking Program) A function block definition can be compiled to perform a program check on it.
  • Page 147: Printing Function Block Definition

    Print from the File Menu. The following Target Print Rung Dialog Box will be displayed. 2. Select the All Rung or Select Rung option. When the Select Rung option is selected, specify the start rung and end rung numbers. When a page number has been specified in the header and footer fields in File - Page Setup, the first page number can be specified.
  • Page 148: Saving And Reusing Function Block Definition Files

    Section 3-2 Procedures Note For details on print settings, refer to the section on printing in the CX-Pro- grammer Ver. 5.0 Operation Manual (W437). 3-2-13 Saving and Reusing Function Block Definition Files The function block definition that has been created can be saved indepen- dently as a function block library file (*.cxf) to enable reusing it in other...
  • Page 149: Downloading/Uploading Programs To The Actual Cpu Unit

    After a program containing function blocks has been created, it can be down- loaded from the CX-Programmer to an actual CPU Unit that it is connected to online. Programs can also be uploaded from the actual CPU Unit. It is also possible to check if the programs on the CX-Programmer Ver.
  • Page 150 Section 3-2 Procedures 3. Click the Browse Button, select the variable to be monitored, and click the OK Button. Select the variable to monitor. Note Instance variables displayed instance_name, variable_name. 4. Click the OK Button. Variable values will be display in the Watch Window as shown below.
  • Page 151 Section 3-2 Procedures...
  • Page 152: A Data Types

    PV: 16 bits Completion Flag: 0 or 1 Counter PV: 0 to 9999 (BCD), 0 to 65535 (binary) Note The TIMER and COUNTER data types cannot be used in structured text function blocks. Derivative Data Types Array 1-dimensional array; 32,000 elements max.
  • Page 153 Appendix A Data Types...
  • Page 154: B Structured Text (St Language) Specifications

    • Do not use a semicolon (;) as a delimiter within a statement such as following reserved words, values, or equations. Inserting a semicolon within a statement, except at the end of a statement, will result in a syntax error.
  • Page 155 • The following characters enclosed in square brackets cannot be used in variable names. [!], [“], [#], [$], [%], [&], [‘], [(],, [)], [-], [=], [^], [~], [\], [|], [@], [‘], [[], [{], [;], [+], [:], [*], []], [}], [,], [<], [.], [>], [/], [?] •...
  • Page 156 • Consider the operator priority in the structured text syntax, or enclose operations requiring priority in parentheses. Example: AND takes priority over OR. Therefore, in the example X OR Y AND Z, priority will be given to Y AND Z.
  • Page 157 Note Operations are performed according to the data type. Therefore, the addition result for INT data, for example, must be a variable using the INT data type. Par- ticularly care is required when a carry or borrow occurs in an operation for integer type variables. For example, using integer type variables A=3 and B= 2, if the operation (A/B)*2 is performed, the result of A/B is 1 (1.5 with the value below the decimal discarded), so (A/B)*2 = 2.
  • Page 158 Note The data type returned for numerical functions is the same as that used in the argument. Therefore, vari- ables substituted for function return values must be the same data type as the argument. Arithmetic Functions The following general exponential function can be used in structured text.
  • Page 159: Reserved Words

    REAL LREAL Statement Details Assignment Summary The left side of the statement (variable) is substituted with the right side of the statement (equation, variable, or constant). Reserved Words Combination of colon (:) and equals sign (=). Statement Syntax Variable: = Equation, variable, or constant;...
  • Page 160 Example 3: Substitute variable A with the constant 10. A:=10; Precautions The data type of the equation, variable, or constant to be assigned must be the same as the data type of the variable to be substituted. Otherwise, a syntax error will occur. Control Statements...
  • Page 161: If Then

    False Condition True Expression Examples Example 1: If variable A>0 is true, variable X will be substituted with numerical value 10. If A>0 is false, variable X will be substituted with numerical value 0. IF A>0 THEN X:=10; ELSE X:=0;...
  • Page 162: Usage

    Summary This statement is used to execute an expression when a specified condition is met. If the first condition is not met, but another condition is met, a corresponding expression is executed. If none of the conditions is met, a different expression is executed.
  • Page 163: Description

    A boolean (BOOL data type) variable only can also be specified as the condition rather than an equation. For boolean conditions, the result is true when the variable value is 1 (ON) and false when it is 0 (OFF). • Statements that can be used in expression_@ are assignment statements, IF, CASE, FOR, WHILE, or REPEAT.
  • Page 164 Examples Example 1: If variable A is 1, variable X is substituted with numerical value 1. If variable A is 2, variable X is substituted with numerical value 2. If variable A is 3, variable X is substituted with numerical value 3. If neither of these cases matches, variable Y will be substituted with 0.
  • Page 165 Structured Text (ST Language) Specifications Example 2: If variable A is 1, variable X is substituted with numerical value 1. If variable A is 2 or 5, variable X is substituted with numerical value 2. If variable A is a value between 6 and 10, variable X is substituted with numerical value 3.
  • Page 166 IF i=101 THEN a:=TRUE; ELSE a:=FALSE; END_IF; • Do not use a FOR statement in which an iteration variable is changed directly. Doing so may result in unex- pected operations. Example: FOR i:=0 TO 100 BY 1 DO array[i]:=0; i:=i+5;...
  • Page 167 IF DATA[n]<MIN THEN MIN:=DATA[n]; END IF; END_FOR; WHILE Statement Summary This statement is used to execute a specified expression repeatedly for as long as a specified condition is true. Reserved Words WHILE, DO, END_WHILE Statement Syntax WHILE <condition> DO <expression>;...
  • Page 168 Example 2: While X<3000, the value of X is doubled, and the value is substituted for the array variable DATA[1]. The value of X is then multiplied by 2 again, and the value is substituted for the array variable DATA[2]. This process is repeated.
  • Page 169 This statement is used within iteration statements (FOR, WHILE, REPEAT) only to force an iteration statement to end. This statement can also be used within an IF statement to force an iteration statement to end when a specified condition is met.
  • Page 170 Example Processing is repeated from when variable n = 1 until 50 in increments of 1 and n is added to array variable DATA[n]. If DATA[n] exceeds 100, however, processing will end. FOR n:=1; TO 50 BY 1 DO DATA[n]:=DATA[n]+n;...
  • Page 171 • Integers can only be allocated to variables with data types WORD, DWORD, INT, DINT, UINT, UDINT, or ULINT. For example, if A is an INT data type, A:=1; it possible. If the value is not an integer data type, a syntax error will occur.
  • Page 172: Error Messages

    100*) Conversion cannot convert A numeric equation in which Y:=ABS(X); (*X is an INT type variable, Y is a UINT type from %s to %s the data type of the operation variable*) result does not match the vari-...
  • Page 173 (IF, WHILE, REPEAT, FOR, CASE). Invalid parameter in FOR loop A variable with data type other FOR I:=1 TO 100 DO (*I is a WORD type variable*) declaration than INT, DINT, LINT, UINT, X:=X+1; UDINT, or ULINT has been END_FOR;...
  • Page 174 Negation not supported by %s A minus symbol was used Y:=-X; (*X is an UINT type variable, Y is an INT type vari- data type before a variable with a data able*)
  • Page 175: Commonly Asked Questions

    Q: What occurs when the array subscript is exceeded? A: For the array variable INT[10] with 10 elements, an error will not be detected for the following type of state- ment. Operation will be unstable when this statement is executed.
  • Page 176: C External Variables

    WORD A451 DM Area specification P_DM WORD A460 EM0 to C Area specification P_EM0 to P_EMC WORD A461 to A473 Note These words are external variables for the OMRON FB Library. Do not use these words for creating function blocks.
  • Page 177 Appendix C External Variables...
  • Page 178: Index

    definition...
  • Page 179 Index variables address allocations menus checking address allocations main creating as needed popup definitions introduction monitoring function blocks properties registering in advance restrictions setting allocation areas online editing usage restrictions output variables outputs parameters outline precautions applications xiii general safety...
  • Page 180: Revision History

    Revision History A manual revision code appears as a suffix to the catalog number on the front cover of the manual. Cat. No. W438-E1-01 Revision code The following table outlines the changes made to the manual during each revision. Page numbers refer to the previous version.
  • Page 181 Revision History...
  • Page 182 Regional Headquarters OMRON EUROPE B.V. Wegalaan 67-69, NL-2132 JD Hoofddorp The Netherlands Tel: (31)2356-81-300/Fax: (31)2356-81-388 OMRON ELECTRONICS LLC 1 East Commerce Drive, Schaumburg, IL 60173 U.S.A. Tel: (1)847-843-7900/Fax: (1)847-843-8568 OMRON ASIA PACIFIC PTE. LTD. 83 Clemenceau Avenue, #11-01, UE Square,...
  • Page 183 Authorized Distributor: Cat. No. W438-E1-01 Note: Specifications subject to change without notice Printed in Japan This manual is printed on 100% recycled paper.

This manual is also suitable for:

Cx-programmer 5.0Sysmac ws02-cxpc1-e-v50Cs1-hCj1-hCj1m

Table of Contents