Table of Contents

Advertisement

Quick Links

Cat. No. W447-E1-09
SYSMAC
CX-Programmer Ver. 9
WS02-CXPC1-V9
OPERATION MANUAL
Function Blocks/
Structured Text

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the WS02-CXPC1-V9 - V9 and is the answer not in the manual?

Questions and answers

Summary of Contents for Omron WS02-CXPC1-V9 - V9

  • Page 1 Cat. No. W447-E1-09 SYSMAC CX-Programmer Ver. 9 WS02-CXPC1-V9 OPERATION MANUAL Function Blocks/ Structured Text...
  • Page 3 CX-Programmer Ver. 9.@ WS02-CXPC1-V9 Operation Manual Function Blocks/Structured Text Revised December 2009...
  • Page 5  OMRON, 2008 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 7 SECTION 1 Introduction to Function Blocks SECTION 2 Function Block Specifications SECTION 3 Creating Function Blocks Part 2: Structured Text SECTION 4 Introduction to Structured Text SECTION 5 Structured Text (ST) Language Specifica- tions SECTION 6 Creating ST Programs Appendices...
  • Page 9: Table Of Contents

    Instruction Support and Operand Restrictions........
  • Page 10 Index..........201 Revision History ........203...
  • Page 11 Structured Text (ST) functions. The function block and structure text functionality of CX-Program- mer is supported by CJ2H CPU Units, by CS1-H, CJ1-H, and CJ1M CPU Units with unit version 3.0 or later, by CP-series CPU Units, and by NSJ-series and FQM1-series Controllers.
  • Page 12 CS1-H, CJ1-H, and CJ1M CPU Unit Manuals Name Cat. No. Contents SYSMAC CJ Series W472 Provides an outline of and describes the design, installation, CJ2H-CPU6@-EIP, CJ2H-CPU6@ maintenance, and other basic operations for the CJ-series Programmable Controllers CJ2 CPU Units. Hardware User's Manual...
  • Page 13 CP1H-XA@@@@-@ CP1H-Y@@@@-@ NSJ@-@@@@(B)-G5D NSJ@-@@@@(B)-M3D SYSMAC CS/CJ Series Communications Commands Reference Manual NSJ-series NSJ Controller Manual Refer to the following manual for NSJ-series NSJ Controller specifications and handling methods not given in this manual. Cat. No. Models Name Description W452 NSJ5-TQ@@(B)-G5D...
  • Page 14 Use this manual in combination with the FQM1 Series FQM1-MMA22 Reference Manual Operation Manual (O012) when programming. CP-series PLC Unit Manuals Refer to the following manuals for specifications and handling methods not given in this manual for CP- series CPU Units. Cat. No. Models Name...
  • Page 15 Appendices provide information on structured text errors and ST function descriptions. !WARNING Failure to read and understand the information provided in this manual may result in per- sonal injury or death, damage to the product, or product failure. Please read each section in its entirety and be sure you understand the information provided in the section and related sections before attempting any of the procedures or operations given.
  • Page 17 Warranty and Limitations of Liability WARRANTY (1) The warranty period for the Software is one year from either the date of purchase or the date on which the Software is delivered to the specified location. (2) If the User discovers a defect in the Software (i.e., substantial non-conformity with the manual), and returns it to OMRON within the above warranty period, OMRON will replace the Software without charge by offering media or downloading services from the Internet.
  • Page 18 Application Considerations SUITABILITY FOR USE THE USER SHALL NOT USE THE SOFTWARE FOR A PURPOSE THAT IS NOT DESCRIBED IN THE ATTACHED USER MANUAL. xviii...
  • Page 19 The license fee of the Software does not include service costs, such as dispatching technical staff. ERRORS AND OMISSIONS The information in this manual has been carefully checked and is believed to be accurate; however, no responsibility is assumed for clerical, typographical, or proofreading errors, or omissions.
  • Page 21: Precautions

    Application Precautions ........
  • Page 22: Intended Audience

    !WARNING It is extremely important that a PLC and all PLC Units be used for the speci- fied purpose and under the specified conditions, especially in applications that can directly or indirectly affect human life. You must consult with your OMRON representative before applying a PLC System to the above-mentioned appli- cations.
  • Page 23: Application Precautions

    Application Precautions • When the size to be processed by the instruction operand is fixed: The number of array elements must be the same as the number of ele- ments to be processed by the instruction. Otherwise, the CX-Programmer will output an error when compiling.
  • Page 24 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 memory on the CX-Programmer, select Display dialog to show PLC Memory Backup Status in the PLC properties and then select Windows - PLC Memory Backup Status from the View Menu.
  • Page 25 AT setting. Alternatively, specify the first or last element in an internal variable specified as an array variable. • Values are passed in a batch from the input parameters to the input vari- ables or input-output variables before algorithm execution (not at the same time as the instructions in the algorithm are executed).
  • Page 26 Application Precautions xxvi...
  • Page 27: Function Blocks

    Part 1: Function Blocks...
  • Page 29: Introduction To Function Blocks

    Variable Properties ........
  • Page 30: 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 31: Function Block Specifications

    CP1L-M/L Note If a user program containing function blocks created on the CX-Program- mer Ver. 5.0 or later is downloaded to a CPU Unit that does not support function blocks (CS/CJ-series CPU Units with unit version 2.0 or earlier), all instances will be treated as illegal commands and it will not be possi- ble to edit or execute the user program.
  • Page 32 • Suffix -CPU44H/45H/64H/65H/66H/67H/64H-R/65H-R/66H-R/67H-R: 1,024 or earlier. max. per CPU Unit • Suffix -CPU42H/43H/63H: 128 max. per CPU Unit CJ1M CPU Units: • CJ1M-CPU11/12/13/21/22/23: 128 max. per CPU Unit CP1H CPU Units: • All models: 128 max. per CPU Unit CP1L CPU Units: •...
  • Page 33 The file memory program file (*.obj) includes function block definitions and blocks as files 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 34: Files Created With Cx-Programmer Ver. 6.0 Or Later

    Function Block Library A function block definition created in a project with CX-Programmer Ver. 6.0 Files (*.cxf) can be saved as a file (1 definition = 1 file), enabling definitions to be loaded into other programs and reused. Note When function blocks are nested, all of the nested (destination) function block definitions are included in this function block library file (.cxf).
  • Page 35 View Monitor FB Instance When monitoring the program online, monitors ST variable status as well as I/O bit and word status (I/O bit monitor) of the ladder diagram in the instance. (Supported by CX-Programmer Ver. 6.1 and later only). To Lower Layer Displays on the right side the contents of the function block definition of the selected instance.
  • Page 36 Pop-up Menu for Inserted Function Blocks Pop-up menu Function Open Displays the contents of the selected function block definition on the right side of the window. Save Function Block File Saves the selected function block definition in a file. Compile Compiles the selected function block definition.
  • Page 37: Function Blocks

    When a function block definition’s input variables, output variables, or input-output vari- ables have been changed after the instance was created, an error will be indicated by displaying the instance’s left bus bar in red. This command updates the instance with the new information and clears the error.
  • Page 38: Advantages Of Function Blocks

    Function blocks allow complex programming units to be reused easily. Once standard programming is created in a function block and saved in a file, it can be reused just by placing the function block in a program and setting the parameters for the function block’s I/O.
  • Page 39: Function Block Structure

    Section 1-2 Function Blocks The function blocks are created with variable names that are not tied to actual addresses, so new programs can be developed easily just by reading the def- initions from the file and placing them in a new program.
  • Page 40 Section 1-2 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” or “function block instance.”...
  • Page 41 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 42 AT setting (specified address- es). !Caution If an address is specified in an input parameter, the values in the address are passed to the input variable. The actual address data itself cannot be passed.
  • Page 43 &8 OFF_TIME variables 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 44: 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 45: Variable Usage And Properties

    Also, the name cannot contain two underscore characters in a row. The character string cannot be the same as that of a an index register such as in IR0 to IR15. For details on other restrictions, refer to Variable Defi- nitions in 2-1-2 Function Block Elements.
  • Page 46: 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 47: Internal Allocation Of Variable Addresses

    When an instance is created from a function block definition, the CX-Program- mer internally allocates addresses to the variables. Addresses are allocated to all of the variables registered in the function block definition except for vari- ables that have been assigned actual addresses with the AT Settings prop- erty.
  • Page 48 T3072 T4095 1024 Counters C3072 C4095 1024 Note Force-setting/resetting is enabled when the following EM banks are specified: CJ2H-CPU64(-EIP)/-CPU65(-EIP) EM bank 3 CJ2H-CPU66(-EIP) EM banks 6 to 9 CJ2H-CPU67(-EIP) EM banks 7 to E CJ2H-CPU68(-EIP) EM banks 11 to 18 CS/CJ-series CPU Units Ver.
  • Page 49: 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 50: 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 51: Version Upgrade Information

    Support has been improved for the structured text and SFC languages, which are IEC61131-3 languages. Ladder, structured text (ST), and SFC program- ming can be combined freely, so that the best language for each process can be used, which reduces program development time and makes the program easier to understand.
  • Page 52 '@READ';) to easily set a variable containing text (i.e., ASCII charac- • There are no text processing functions sup- ters). In doing this, the user does not have to be concerned with the ported for ST programming. ASCII code or code size.
  • Page 53 Version Upgrade Information Section 1-6 Version 6.0 to 6.1 Upgrade Information Support for NSJ-series The PLC model (“device type”) can be set to “NSJ” and the CPU type can be NSJ Controllers set to the G5D. Support for FQM1 Unit The new models of the FQM1 Flexible Motion Controller are now supported Version 3.0...
  • Page 54 Monitor FB Ladder Instance function block definition.) from the pop-up menu. At this point, it will be possible to monitor the status of I/O bits and the content of words, change PVs, force-set/reset bits, and monitor differentiation (ON/OFF transitions) of bits.
  • Page 55: Function Block Specifications

    PLCs, as well as usage precautions and guidelines. Function Block Specifications ........
  • Page 56: Function Block Specifications

    Nesting is not supported. • CX-Programmer Ver. 6.0 and later versions: Supports nesting up to 8 levels. (The instance called from the program is counted as one nesting level.) Number of variables Maximum number of variables per function block definition used in a function block •...
  • Page 57: Function Block Specifications

    • Variables name cannot contain spaces or any of the following characters: ! “ # $ % & ‘ ( ) = - ~ ^ \ | ‘ @ { [ + ; * : } ] < , > . ? / •...
  • Page 58 Input variables pass external operands to the instance. The input variables are displayed on the left side of the instance. The value of the input source (data contained in the specified parameter just before the instance was called) will be passed to the input variable.
  • Page 59 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 60 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 61 The ENO variable is created as the default output variable. The ENO output variable will be turned ON when the instance is called. The user can change this value. The ENO output variable can be used as a flag to check whether or not instance execution has been completed normally.
  • Page 62 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 63 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 64 With the array setting, a large number of variables with the same properties can be used by registering just one variable. • An array set for an internal variable can have from 1 to 32,000 array ele- ments. An array set for an input-output variable can have the number of elements given in the following table.
  • Page 65 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 66 Section 2-1 Function Block Specifications ting the data in each array element, specify the first or last element in the array variable for the operand. Example: Function block definition Instance Variable WORD[10] Algorithm SCL-BODY Specifying this array element in LD P_On...
  • Page 67: Data Types Supported In Function Blocks

    Counter PV: 0 to 9999 (BCD), 0 to 65535 (binary) FUNCTION Function block instance BLOCK Note The TIMER and COUNTER data types cannot be used in structured text func- tion blocks. 2-2-2 Derivative Data Types Array 1-dimensional array; 32,000 elements max.
  • Page 68: Instance Specifications

    • Instance names cannot contain spaces or any of the following characters: ! “ # $ % & ‘ ( ) = - ~ ^ \ | ‘ @ { [ + ; * : } ] < , > . ? / •...
  • Page 69 T3072 T4095 1024 Counters C3072 C4095 1024 Note Force-setting/resetting is enabled when the following EM banks are specified: CJ2H-CPU64(-EIP)/-CPU65(-EIP) EM bank 3 CJ2H-CPU66(-EIP) EM banks 6 to 9 CJ2H-CPU67(-EIP) EM banks 7 to E CJ2H-CPU68(-EIP) EM banks 11 to 18 CS/CJ-series CPU Units Ver.
  • Page 70 Note (1) Except when the data type is set to TIMER or COUNTER. (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 71 CIO 5000 to CIO 5999 (default) Note (1) Except when the data type is set to TIMER or COUNTER. (2) Bit data can be accessed even if the DM Area is specified for the non-re- tained area. Retained Area None...
  • Page 72 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 73: Parameter Specifications

    Body Use the same internal variables Use different internal variables 2-3-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 74 & or + followed by decimal number (2) The size of function block input variables and output variables must match the size of program symbols (global and local), as shown in the fol- lowing table. Size Function block variable data...
  • Page 75: 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 76 "INSTANCE_FB1," "INSTANCE_FB2," etc., are the FUNCTION BLOCK data type instance names. Note: Any combination of ladder diagrams and structured text programming can be used between the called and the calling function block. The function block nesting levels can also be displayed in a directory tree for- mat with the FB Instance Viewer function.
  • Page 77: Programming Restrictions

    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 78 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 79: St Programming Restrictions

    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. 2-4-2 ST Programming Restrictions Restrictions when •...
  • Page 80: Programming Restrictions

    A function block’s input cannot be connected to another function block’s out- Connections put. In this case, a variable must be registered to transfer the execution status from the first function block’s output to the second function blocks input. D3000...
  • Page 81 Section 2-4 Programming Restrictions 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. Program FB definition Instance name...
  • Page 82: Function Block Applications Guidelines

    Not Provided D32000 to D32767 Provided If there is an instruction in the user program that accesses an address in an FB instance area, the CX-Programmer will output an error in the following cases. • When a program check is performed by the user by selecting Program - Compile from the Program Menu or Compile All Programs from the PLC Menu.
  • Page 83: Determining Variable Types (Inputs, Outputs, In Out, Externals, And Internals)

    Determining Variable Types (Inputs, Outputs, In Out, 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 84 Internal operation involves passing the address Results from Values set for the parameter to the input-output variable, but the use of the input-out- Passed from Input put variable inside the function block is the same as that of other variables.
  • Page 85: At Settings For Internal Variables

    Array Settings for Input-Output Variables and Internal Variables Using Array Variables When specifying the first or last of a range of words in an instruction operand to Specify First or Last (see note), the instruction operates according to the address after AT specifi- Word in Multiword cation or internal allocation.
  • Page 86 2-7 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 87: Specifying Addresses Allocated To Special I/O Units

    100 elements, variable names = read_data[0] to read_data[99] • Data Settings and Internal Function Block Processing • Input-output variables: Set the input parameter to the address of the first word in the read data (example: D200). FREAD (omitted) (omitted) (omitted) read_data[0] •...
  • Page 88: 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 89 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 90 Section 2-5 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 91: Precautions For Instructions With Operands Specifying The First Or Last Of Multiple Words

    (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 92 Precautions for Instructions with Operands Specifying the First or Last of Multiple Words 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 93 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 94: 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 95 Note When specifying the first or last word of multiple words in an in- struction operand, input parameters cannot be used to pass data to or from variables. Either an AT setting must be used or one of the following must be used: 1) An input-output variable set to an array must be used and the address of the first word must be set for the input parameter (CX-Programmer version 7.0 or higher) or 2) An...
  • Page 96: Cpu Unit Function Block Specifications

    CPU Unit Function Block Specifications The specifications of the functions blocks used in CS/CJ-series and CP-series CPU Units are given in the following tables. Refer to the other operation man- uals for the CS/CJ Series and CP Series for other specifications.
  • Page 97 CPU Unit Function Block Specifications Section 2-8 Item Specification Function Maxi- 1,024 1,024 1,024 1,024 1,024 1,024 blocks number of definitions Maxi- 2,048 2,048 2,048 2,048 2,048 2,048 number of instances Com- Total for 2,048 2,048 1,280 1,280 1,280 1,280...
  • Page 98 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 99 Rack x 7 Racks) Program capacity (steps) Data memory 32K words Number of connectable Expan- 7 Units (CP-series Expansion Units and Expansion I/O Units) sion Units and Expansion I/O Units Function blocks Maximum num- ber of definitions Maximum num-...
  • Page 100 Racks) Rack) Racks) Program capacity (steps) Data memory 32K words (D00000 to D32767) 10K words (D00000 to D09999, and D32000 to D32767) Number of connectable Expan- 3 Units (CP-series Expansion Units and 1 Unit (CP-series Expan- None sion Units and Expansion I/O Units...
  • Page 101: 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 102: Number Of Function Block Program Steps And Instance Execution Time

    CPU Unit. 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 103: Function Block Instance Execution Time

    Output variables with a 1-word data type (INT): 5 Function block definition section: 100 steps Number of steps for 1 instance = 57 + (5 + 5) × 6 steps + 100 steps + 27 steps = 244 steps When the program is written in ST language, the actual number of steps can- not be calculated.
  • Page 104 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 = 3.3 µs + (3 + 2) × 0.19 µs + 10 µs = 14.25 µs 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 105: Creating Function Blocks

    Creating a Project ........
  • Page 106: 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 107 Function Block details. 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 108: 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 109 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 110 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 pop-up 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 111: Defining Function Blocks Created By User

    • To add a variable to the last line, select Insert Variable from the pop- up 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 pop-up menu.
  • Page 112 (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 113: Part

    (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 114 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 115 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 116 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 117 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 118 Generating Function Block Definitions from Existing Ladder Programming One or more program circuits in a user program can be converted to the lad- der programming in a function block definition. Note This function is designed to help you create function block definitions based on existing ladder programming.
  • Page 119 Note Even if an address is allocated to I/O, it will be considered to be “not used” and converted to an internal variable if it is not used outside the selected circuits (no matter where it is used inside the selected circuits).
  • Page 120 Section 3-2 Procedures 7. Click the Yes Button to insert an instance and click the No Button to not insert an instance. 8. The following New Function Block Invocation Dialog Box will appear if the Yes Button was clicked. Enter the function block instance name and click the OK Button. An in- stance of the function block definition will be inserted below the original program circuits as shown below.
  • Page 121 Example: MOV(021) for W0 and SET for W0.02 ↓ Here, the instruction can be changed to specify a word instead of a bit. As shown below, W0 is used both for MOV(021) and SETB(532), and the bit number for SETB(532) is specified using &2.
  • Page 122 Section 3-2 Procedures ↓ As shown below, the variables must be changed to specify the first word in an array and a specific word in the same array after the function block definition has been generated. Example: DT_WORD is set as a WORD array variable with 2 elements.
  • Page 123: Creating Instances From Function Block Definitions

    D100 Specified for the First Destination Word for XFER(070) ↓ As shown below, the variables must be changed to set the first elements in two different arrays after the function block definition has been generated. Example: DT_WORD1 and DT_WORD2 are set as WORD array variables with 5 elements each.
  • Page 124 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 125: Setting Function Block Parameters Using The Enter 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 126 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 127 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 128: Setting The Fb Instance Areas

    HR, DM, EM note 1.) note 2.) note 2.) Timers T3072 T4095 1024 Counters C3072 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.
  • Page 129 Retain None Timers T206 T255 Counters C206 C255 Note Bit data can be accessed even if the DM Area is specified for the non-retained area. CP-series CPU Units FB Instance Default value Applicable memory Area areas Start address End address...
  • Page 130: 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/SFC Memory Address from the pop-up menu. (Alternately, select Memory Allocation - Function Block/SFC Memory - Function Block/SFC Memory Address from the PLC Menu.)
  • Page 131 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 132: Copying And Editing Function Block Definitions

    Use the following operation to copy and edit the function block definition that has been created. 1. Select the function block to copy, right-click, and select Copy from the pop- up menu. 2. Position the cursor over the function block item under the PLC in the project directory, right-click and select Paste from the pop-up menu.
  • Page 133: 3-2-11 Checking The Size Of The Function Block Definition

    2. The function block definition size and number of function block definitions will be displayed in the Memory View Dialog Box as shown below. • The Used #, Free #, and Max # fields under Function Block refer to the number of function block definitions.
  • Page 134: Compiling Function Block Definitions (Checking Program)

    Section 3-2 Procedures 3-2-12 Compiling Function Block Definitions (Checking Program) A function block definition can be compiled to perform a program check on it. Use the following procedure. 1,2,3... Select the function block definition, right-click, and select Compile from the pop-up menu.
  • Page 135: 3-2-14 Password Protection Of Function Block Definitions

    • Symbol table • Program 4. Click the OK Button, and display the Print Dialog Box. After setting the printer, number of items to print and the paper setting, click the OK button. 5. The following variable table followed by the algorithm (e.g, ladder program- ming language) will be printed.
  • Page 136 Properties from the pop-up menu. (Alternately, select Proper- ties from the View Menu.) 2. The Function Block Properties Dialog Box will be displayed. Click the Pro- tection Tab and click the Set Button. 3. The Function Block Protect Setting Dialog Box will be displayed. Select the protection level in the Protection Type Field.
  • Page 137 3. The Function Block Protection Release Dialog Box will be displayed. Input the password in the Password Field and click the Release Button. 4. If the password was correct, the protection will be cleared and the function block definition’s icon will change to a normal icon in the project work- space.
  • Page 138: 3-2-15 Comparing Function Blocks

    3-2-15 Comparing Function Blocks It is possible to compare the edited function block with a function block in the actual PLC or another project file to check whether the two function blocks are identical.
  • Page 139: 3-2-17 Downloading/Uploading Programs To The Actual Cpu Unit

    With the CX-Programmer Ver. 6.0 and later versions, it is possible to monitor Programs within the status of bits and content of words in a ladder program within an instance Instances when monitoring the program. To monitor I/O bits and words (I/O Bit Monitor), either double-click the instance or right-click the instance and select Monitor FB Ladder Instance from the pop-up menu.
  • Page 140 (3) If an array variable is used in a function block and a symbol is used for the array variable’s arguments, the present value cannot be monitored if that array variable is used as the operand of an input condition or special in- struction.
  • Page 141 The variable’s PV is displayed in blue characters. The ST program is displayed in the left side of the window (called the ST pro- gram monitor window). The values of variables used in the ST program are displayed in the right side of the window (called the ST variable monitor window).
  • Page 142 (displayed in reverse video when selected), right-click, and select Set - Value from the pop-up menu. Select the variable. The Set New Value Dialog Box will be displayed. Input the new value in the Value field. Force-setting and Force-resetting Bits...
  • Page 143 1. Select View - Window - Watch. A Watch Window will be displayed. 2. Use any one of the three following methods to display the FB variables reg- istration Dialog Box. a. Right-click the instance and select Register in Watch Windows from the pop-up menu.
  • Page 144 The CX-One Ver 1.1 (CX-Programmer Ver. 6.1) and later versions have a sim- Programs in Instances ulation function that can simulate the operation of a ladder program or ST pro- gram within a function block instance. Both step execution and break point operation are supported.
  • Page 145 1,2,3... 1. Pause execution of the instance. (See note.) 2. Click the Step In Icon or select Tools - Simulation - Mode - Step In. Example: Step In from Instance to Internal Ladder Program Click the Step In Icon to Stopped here.
  • Page 146 (In this case, the Step In operation cannot be used.) Note When a break point is set for an instance, the break point is valid for that instance only. (The break point is not valid for other instances created from...
  • Page 147: 3-2-19 Online Editing Function Block Definitions

    2. Click the Memory Tab, right-click the area for which to reserve memory, and select Online edit reserved memory from the pop-up menu. 3. Enter the size of memory to reserve in each field in the Memory Size Edit for FB Online Edit Dialog Box.
  • Page 148 The following dialog box will be displayed before the FB Online Editor is started. At the same time, a list of instances that will be affected is displayed in the Output Window. Note Affect of Function Block Definition Changes on Instances When a function block definition is changed, the contents of all in- stances that call that function block definition will also be changed.
  • Page 149 Section 3-2 Procedures 3. After editing the contents of the function block definition, select FB online Edit - Send Changes. The following FB Online Edit - Transfer Dialog Box will be displayed. 4. Select one of the following transfer modes and click the Yes Button.
  • Page 150 Section 3-2 The new function block definition will be transferred to the buffer memory in the CPU Unit and the progress of the transfer will be displayed in a dialog box. (At this point, the CPU Unit will still be operating with the previous function block definition.)
  • Page 151 Program - Transfer FB Source later to transfer the source code as well. Even if the source code is not trans- ferred, it will be automatically transferred when you go offline unless the com- puter or CX-Programmer crashes before the source code can be transferred.
  • Page 152 The cycle time will again be extended when the results of online editing are backed up to built-in flash memory. (At this time, the BKUP indicator on the front of the CPU Unit will flash and the progress will be displayed on the CX- Programmer.) Maximum Cycle Time The maximum extensions to the cycle time are given in the following table.
  • Page 153 (i.e., until the BKUP indicator stops flashing). If the power supply is turned OFF before the data is backed up, the data will not be backed up and the program will return to the status it had before online editing was...
  • Page 154 Section 3-2 Procedures...
  • Page 155: Structured Text (St)

    Part 2: Structured Text (ST)
  • Page 157: Introduction To Structured Text

    Overview..........CX-Programmer Specifications ........
  • Page 158: St Language

    IEC 61131-3 standard, and these ST-language programs can be allo- cated to tasks. The PLC must be a CS/CJ-series CPU Unit with unit version 4.0 or later, or a CJ2-series CPU Unit. The following list shows the features of the ST language.
  • Page 159: Cx-Programmer Specifications

    CX-Programmer Operation Manual (W446). • For details on the CX-Programmer operating environment used with other programs (function block or SFC), refer to Part 1: Function Blocks in this manual, or the CX-Programmer Operation Manual: SFC (W469).
  • Page 160 Section 4-2 CX-Programmer Specifications...
  • Page 161: Structured Text (St) Language Specifications

    Data Types Used in ST Programs ........
  • Page 162: Structured Text Language Specifications

    • Control statement: Includes statements such as selection statements and iteration statements. For details on each kind of statement, refer to 5-4 ST Language Configura- tion. ■ Statement Contents Statements are composed of the following elements.
  • Page 163: Data Types Used In St Programs

    • UDINT BCD is recognized as DWORD. • ULINT BCD is recognized as LWORD. • CHANNEL is recognized as WORD. (2) This data type cannot be used in an ST program. A program error will oc- cur if this data type is specified. 5-2-2...
  • Page 164: Inputting St Programs

    (;). The statement cannot be completed by simply using a car- riage return. • Do not use a semicolon (;) as a delimiter within a statement such as fol- lowing 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 165 Variable Names variable names. • [!], ["], [#], [$], [%], [&], [`], [(],, [)], [-], [=], [^], [~], [\], [|], [@], [`], [[], [{], [;], [+], [:], [*], []], [}], [,], [<], [.], [>], [/], [?] • The numbers 0 to 9 cannot be used as the first character of variable names.
  • Page 166: Cx-Programmer's St Input Screen Display

    Carriage return (ASCII 0D) $T or $t Tab (ASCII 09) • When a text string is being stored from the ladder program in an ST func- tion block’s STRING variable, append a NULL character (#00) to the end of the text string.
  • Page 167: St Language Configuration

    5-4-1 Statements Statement Function Example End of statement Ends the statement Comment All text between (* and *) is treated as (*comment*) a comment. Assign- Assignment Substitutes the results of the expres- A:=B; ment state- sion, variable, or value on the right for ment the variable on the left.
  • Page 168: Variables

    Negative hexadecimal, octal, and binary numbers are expressed as 2’s com- plements. The valid range of INT data is -32,768 to 32,767 in decimal, but 0000 to FFFF in hexadecimal, so the 2’s complement is used for negative integers. For example, when a value of -10 decimal is set in an INT variable, it will be expressed as 16#FFF6 in hexadecimal.
  • Page 169: Standard Functions

    Section 5-4 ST Language Configuration 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. 5-4-5 Standard Functions Function type...
  • Page 170 UINT, UDINT, ULINT Note The data type returned for numerical functions is the same as that used in the argument. Therefore, variables substituted for function return values must be the same data type as the argument. Text String Functions The following functions can be used with CS/CJ-series CPU Units with unit version 4.0 or later, or CJ2-series CPU Units.
  • Page 171 Functions Syntax Source_data_type_TO_New_data_type (Variable_name) Example: REAL_TO_INT (C) In this example, the data type for variable C will be changed from REAL to INT. Data Type Combinations The combinations of data types that can be converted are given in the follow- ing table.
  • Page 172: Omron Expansion Functions

    In this example, the STRING variable C will be changed to an integer. Data Type Combinations The combinations of data types that can be converted are given in the follow- ing table. (YES = Conversion possible, No = Conversion not possible)
  • Page 173 WORD internal logic port number.) Internal_logic INT, _port UINT, WORD Angle Conversion The following functions can be used with CS/CJ-series CPU Units with unit Instructions version 4.0 or later, or CJ2-series CPU Units. Function Argument Return value Description Example data type...
  • Page 174: Statement Descriptions

    Statement Descriptions 5-5-1 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 175 Example: IF(A>10) The condition can also be specified as a boolean variable only rather than an equation. As a result, the variable value is 1 (ON) = True result, 0 (OFF) = False result. • Statements that can be used in expression_1 and expression_2 are assignment statements, IF, CASE, FOR, WHILE, or REPEAT.
  • Page 176 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 177 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 state-...
  • Page 178 ■ Examples Example 1: If variable A>0 is true, variable X will be substituted with numerical value 10. If A>0 is false, but variable B=1, variable X will be substituted with numerical value 1.
  • Page 179 ■ Precautions • CASE must be used together with END_CASE. • The result of the integer_equation must be in integer format (INT, DINT, LINT, UINT, UDINT, or ULINT). • Statements that can be used in expression_@ are assignment state- ments, IF, CASE, FOR, WHILE, or REPEAT.
  • Page 180 A is a value between 6 and 10, variable X is substituted with numerical value 3. If variable A is 11, 12, or a value between 15 and 20, variable X is substituted with numerical value 4. If neither of these cases matches, variable Y will be substituted with 0.
  • Page 181: Variable

    Use the FOR statement when the number of iterations has been determined beforehand. FOR is particularly useful when switching the number of ele- ments in an array variable according to the value of a specified iteration vari- able. ■ Description When the iteration_variable is the initial_value, the expression is executed.
  • Page 182 END_FOR; 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 unexpected operations. Example: FOR i:=0 TO 100 BY 1 DO array[i]:=0; i:=i+5;...
  • Page 183 • Statements that can be used in the expression are assignment state- ments, IF, CASE, FOR, WHILE, or REPEAT. • Multiple statements can be executed in the expression. Be sure to use a semicolon (;) delimiter between multiple statements in an expression.
  • Page 184 Section 5-5 Statement Descriptions Example 2: While X<3000, the value of X is doubled, and the value is substi- tuted 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 185 (2) Even if the condition equation is true before the expression has been ex- ecuted, the expression will be executed. ■ 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.
  • Page 186 (see note). The two methods (entry method 1 and entry method 2) that can be used to enter these parameters are described in the fol- lowing paragraphs.
  • Page 187 ST task or SFC action program) Note When B and D are omitted, as shown above, C is moved to the B position and passed automatically in the order that values are registered in that variable table. In contrast, the values from the D position are automatically received at E in the order that values are registered in that variable table.
  • Page 188 Calcu_execute (A:=B,C=>D) ; The value of B is passed to A, and at the same time the value of C is re- ceived at D. A: Called function block definition’s input variable name B: One of the following values, depending on the ST program being used •...
  • Page 189 INSTANCE_FB is an instance name of data type FUNCTIONBLOCK. Variable Settings • Setting the variables of the ST program and SFC program (call source) The ST program and SFC program have the following variables, and the following values are passed with the called function block.
  • Page 190 ■ Example of Entry Method 1 Instance_FB(EN:=A,FB_IN1:=IN1,FB_IN2:=IN2,FB_IN3:= IN3, FB_OUT1=>OUT1,FB_OUT2=> OUT2,FB_OUT3=> OUT3,ENO=>B) • It is all right for the arguments and return values to be listed in irregular order. • The input variables' arguments must be at the beginning of the list, or just after the EN variable if the EN variable is listed.
  • Page 191: Program

    Example: Instance_FB(IN1, IN2, IN3, OUT1, OUT3) In this case, the OUT3 at the end of the list would return the value from FB_OUT2. • The EN and ENO data cannot be entered as an argument or return value.
  • Page 192: St-Language Program Example

    ST-language Program Example • ST-language Algorithm If bCheck is true, function block 2 is called to calculate the average value. The 3 values data1, data2, and data3 are passed to function block 2 input variables input1, input2, and input3 respectively. The result of the calcula- tion (average) is returned to AVG.
  • Page 193: Restrictions

    A, B, and C are INT data types, A:=B+C; is possible. If, however, A and B are INT data types, but C is a REAL data type or LINT data type, a syn- tax error will occur for A:=B+C;.
  • Page 194 END_FOR; 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 statement. Operation will be unstable when this statement is executed.
  • Page 195: Creating St Programs

    Creating a Project ........
  • Page 196: Procedures

    1,2,3... 1. Start the CX-Programmer and select File -New. 2. In the Change PLC Dialog Box, select a PLC model that supports ST pro- grams from the Device Type list. Refer to 4-2-1 PLC Models Compatible with ST Programs (ST Tasks) for a table of the PLC models that support ST programs.
  • Page 197: Allocating The St Program To A Task

    The ST program that was inserted in the project must be allocated to a task as an execution unit. If a program has not been allocated to a task, there will be a check mark over that program’s icon in the project workspace.
  • Page 198: Creating The St Program

    3. Click the Close Button to close the Program Properties Dialog Box. 4. When the program is allocated to a task, the check mark over the ST pro- gram’s icon will be deleted. The allocated task number will be shown in pa- rentheses after the program name.
  • Page 199 2. Creating the ST Program 1,2,3... 1. The ST language can be input directly in the ST Editor Window, or the ST data can be created in a text editor and then pasted in the ST Editor Win- dow by selecting Edit - Paste.
  • Page 200: Compiling The St Program (Checking Program)

    6-1-5 Compiling the ST Program (Checking Program) The ST program can be compiled to perform a program check on it. Use the following procedure. 1,2,3... 1. Select the ST program, right-click, and select Compile from the pop-up menu.
  • Page 201: Comparing St Programs

    The ST program can be monitored. Program’s Variables The ST program is displayed in the left side of the window (called the ST pro- gram monitor window). The values of variables used in the ST program are displayed in the right side of the window (called the ST variable monitor window).
  • Page 202: Online Editing Of St Programs

    2. Select the desired ST program in the project workspace, and display it in program view. 3. Select Program - Online Edit - Begin. At this point, it will be possible to edit the ST program. 4. Start editing the ST program.
  • Page 203 To discard the changes made to the ST program, select Program - Online Changes Edit - Cancel. The edited ST program will not be sent to the PLC, and the ST program will revert to the original status before online editing was started.
  • Page 204 1,2,3... 1. Start the CX-Programmer. 2. The following dialog box will be displayed if a project’s ST source code was being transferred in Quick Mode and the transfer failed. 3. Click the OK Button. the CX-Programmer will start the backup project from the previous Quick Mode transfer.
  • Page 205 • Online editing is not possible for ST programs that exceed 4 Ksteps (except for CJ2-series CPU Units). • A maximum of 0.5 Ksteps can be added to or deleted from an ST program during one online editing operation (except for CJ2-series CPU Units).
  • Page 206 Section 6-1 Procedures...
  • Page 207: System-Defined External Variables Supported In Function Blocks

    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 208: A System-Defined External Variables Supported In Function Blocks

    Appendix A System-defined external variables supported in function blocks...
  • Page 209: Structured Text Errors

    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 210 (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 211 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 212 Conversion from '%s' to '%s', Data may be lost due to con- Y:=DINT_TO_INT(X); (*X is a DINT type variable, Y is an possible loss of data version of a data type with a INT type variable*) large data size to a data type with a small data size.
  • Page 213: Function Descriptions

    Result:=LEN(Message); → "8" is stored in Result variable. LEFT: Extract Characters from Left • Function Extracts the specified number of characters from the left of the specified text string. • Application Return_value := LEFT(Source_string, Number_of_characters); • Arguments and Return Values...
  • Page 214 Result:=RIGHT(Message,3); → "FGH" is stored in the Result variable. MID: Extract Characters from Middle • Function Extracts the specified number of characters starting from the specified position of the specified text string. • Application Return_value := MID (Source_string, Number_of_characters, Position);...
  • Page 215 → "ABEFGHC" is stored in the Result variable. Result DELETE: Delete Characters • Function Deletes the specified number of characters starting from the specified position of the specified text string. • Application Return_value := DEL (Source_string, Number_of_characters, Position); • Arguments and Return Values...
  • Page 216 → "ABXYEFGH" is stored in the Result variable. Result FIND: Find Characters • Function Finds the first occurrence of the specified text string in another text string and returns the position. If the text string is not found, 0 is returned. • Application Return_value := FIND(Source_string, Find_string);...
  • Page 217 → "2" is stored in the Result variable. Memory Card Functions WRITE_TEXT: Create Text File • Function Writes the specified text sting into the specified file in the Memory Card. • Application Write_Text (Write_string, Directory_name_and_file_name, Delimiter, Parameter); • Arguments and Return Values...
  • Page 218 A343.15 ON when a Memory Card has been detected. Detected Flag For further information and precautions on related Auxiliary Area flags, refer to the section on the FWRIT File Memory Instruction in the CS/CJ-series Instruction Reference Manual. Communications Functions TXD_CPU: Send String via CPU Unit RS-232C Port •...
  • Page 219 ON when sending is enabled in no-protocol mode. Ready Flag For further information and precautions on related Auxiliary Area flags, refer to the section on TXD Serial Com- munications Instruction in the CS/CJ-series Instruction Reference Manual. TXD_SCB: Send String via Serial Port on Serial Communications Board •...
  • Page 220 ON when sending is enabled in no-protocol mode. Flag For further information and precautions on related Auxiliary Area flags, refer to the section on TXD Serial Com- munications Instruction in the CS/CJ-series Instruction Reference Manual. TXD_SCU: Send String via Serial Port on Serial Communications Unit •...
  • Page 221 1: (* Create send text data *) Message := '@READ'; iProcess := 2; 2: (* Execute send function if Communications Port Enable Flag and TXDU Execution Flag are ON *) IF (P_ComInstEnable = TRUE) AND (P_TXDU_Exe = FALSE) THEN TXD_SCU(Message, 0, 2, 7);...
  • Page 222 Port 1: n+9 Port 2: n+19 For further information and precautions on related Auxiliary Area flags, refer to the section on TXDU Serial Communications Instruction in the CS/CJ-series Instruction Reference Manual. RXD_CPU: Receive String via CPU Unit RS-232C Port •...
  • Page 223 Contains the number of characters received in no-protocol Reception Counter mode. For further information and precautions on related Auxiliary Area flags, refer to the section on RXD Serial Com- munications Instruction in the CS/CJ-series Instruction Reference Manual. RXD_SCB: Receive String via Serial Port on Serial Communications Board •...
  • Page 224 Contains the number of characters received in no-protocol Counter mode. For further information and precautions on related Auxiliary Area flags, refer to the section on RXD Serial Com- munications Instruction in the CS/CJ-series Instruction Reference Manual. RXD_SCU: Receive String via Serial Port on Serial Communications Unit •...
  • Page 225 P_ComInstEnable (* Communications Port Enable Flag *)*) AT A202.07 Use port 7 (* Use the following: Unit number: 0, Serial port number: 2, Logical port number: 7 *) (* Receive data when P_DoRecvData is ON and iProcess is 0 *) IF (P_DoRecvData = TRUE) AND (iProcess = 0) THEN iProcess := 1;...
  • Page 226 Port 1: n+10 Port 2: n+20 For further information and precautions on related Auxiliary Area flags, refer to the section on RXDU Serial Communications Instruction in the CS/CJ-series Instruction Reference Manual. Angle Conversion Functions DEG_TO_RAD: Convert Degrees to Radians •...
  • Page 227: Index

    AT settings setting parameters restrictions specifications automatically generating function block definitions structure functions function blocks restrictions compiling global symbol table data types determining debugging function blocks differentiation IEC 61131-3 restrictions...
  • Page 228 Index menus variable names main variables popup address allocations monitoring function blocks checking address allocations creating as needed definitions introduction properties online editing registering in advance function block definitions restrictions restrictions setting allocation areas output variables usage outputs parameters outline...
  • Page 229: 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. W447-E1-09 Revision code The following table outlines the changes made to the manual during each revision. Page numbers refer to the previous version.
  • Page 230 Revision History...
  • Page 232 © c i f c i t Cat. No. W447-E1-09...

This manual is also suitable for:

Sysmac cx-programmer 9Sysmac ws02-cxpc1-v9

Table of Contents