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.
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...
!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.
• 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...
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.
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.
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.
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...
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.
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...
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.
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.
(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.
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.
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).
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 ........
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.
• 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.
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.
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.)
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.
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.
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.
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).
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.
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 −...
(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...
(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.
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...
• 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...
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...
(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...
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.
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...
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...
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...
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...
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...
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...
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:...
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...
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...
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...
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...
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-...
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.)
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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.
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.
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.
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.
• 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.
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.
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).
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.
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 −...
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.
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.
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.
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.
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...
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.
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.
• 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.
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...
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;...
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.
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.
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*)
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.
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.
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 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.