manualshive.com logo in svg
background image

OPERATION

 

MANUAL

Function Blocks/
Structured Text

Cat. No. W447-E1-08

SYSMAC

CX-Programmer

Ver. 8.1
WS02-CXPC1-V8

Содержание CX-PROGRAMMER V8.1

Страница 1: ...OPERATION MANUAL Function Blocks Structured Text Cat No W447 E1 08 SYSMAC CX Programmer Ver 8 1 WS02 CXPC1 V8...

Страница 2: ...CX Programmer Ver 8 1 WS02 CXPC1 V8 Operation Manual Function Blocks Structured Text Revised February 2009...

Страница 3: ...iv...

Страница 4: ...n some OMRON products often means word and is abbreviated Wd in documentation in this sense The abbreviation PLC means Programmable Controller PC is used however in some Program ming Device displays t...

Страница 5: ...vi...

Страница 6: ...ON 1 Introduction to Function Blocks SECTION 2 Function Block Specifications SECTION 3 Creating Function Blocks SECTION 4 Introduction to Structured Text SECTION 5 Structured Text ST Language Specific...

Страница 7: ......

Страница 8: ...Information 25 SECTION 2 Function Block Specifications 29 2 1 Function Block Specifications 30 2 2 Data Types Supported in Function Blocks 41 2 3 Instance Specifications 42 2 4 Programming Restriction...

Страница 9: ...e Specifications 136 5 2 Data Types Used in ST Programs 137 5 3 Inputting ST Programs 138 5 4 ST Language Configuration 141 5 5 Statement Descriptions 148 5 6 ST language Program Example 166 5 7 Restr...

Страница 10: ...S series CJ series CP series and NSJ series Controllers CX Programmer Ver 8 1 Manuals Name Cat No Contents SYSMAC WS02 CXPC1 V8 CX Programmer Ver 8 1 Operation Manual Function Blocks Structured Text W...

Страница 11: ...mmable Controllers Instructions Reference Manual W474 Describes the ladder diagram programming instructions sup ported by CS CJ series or NSJ series PLCs When programming use this manual together with...

Страница 12: ...CJ2H CPU6 EIP CJ2H CPU6 CJ1G CPU CJ1G H CPU H CJ1G CPU P CJ1M CPU CJ1W SCU21 V1 41 V1 CP1H X CP1H XA CP1H Y NSJ B G5D NSJ B M3D SYSMAC CS CJ Series Communications Commands Reference Manual W342 Descr...

Страница 13: ...nual in combination with the FQM1 Series Operation Manual O012 when programming Cat No Models Name Description W450 CP1H X CP1H XA CP1H Y SYSMAC CP Series CP1H CPU Unit Operation Manual Provides the f...

Страница 14: ...e following sections Section 4 introduces the structure text programming functionality of the CX Programmer and explains the features that are not contained in the non structured text version of CX Pr...

Страница 15: ...xvi...

Страница 16: ...bove warranty period OMRON will replace the defective media without charge If OMRON is unable to replace the defective media or correct the Software the liability of OMRON and the User s remedy shall...

Страница 17: ...xviii Application Considerations SUITABILITY FOR USE THE USER SHALL NOT USE THE SOFTWARE FOR A PURPOSE THAT IS NOT DESCRIBED IN THE ATTACHED USER MANUAL...

Страница 18: ...other reasons EXTENT OF SERVICE 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 carefull...

Страница 19: ...xx...

Страница 20: ...n is important for the safe and reliable application of the CX Programmer and Programmable Controller You must read this section and understand the information contained before attempting to set up or...

Страница 21: ...his manual before attempting to use the product and keep this manual close at hand for reference during operation WARNING It is extremely important that a PLC and all PLC Units be used for the speci f...

Страница 22: ...in serious accidents Check that the system will not be adversely affected if the size of the variable specified in the operand is less than the size in the operand definition before starting PLC oper...

Страница 23: ...he backup operation is in progress 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 writin...

Страница 24: ...variable The same applies to the timing for writing values to the parameters from output variables Always use internal variables with AT settings in the following cases The addresses allocated to Basi...

Страница 25: ...xxvi Application Precautions 4...

Страница 26: ...Part 1 Function Blocks...

Страница 27: ......

Страница 28: ...ction Block Menus in CX Programmer Ver 5 0 and later Versions 8 1 2 Function Blocks 11 1 2 1 Outline 11 1 2 2 Advantages of Function Blocks 12 1 2 3 Function Block Structure 13 1 3 Variables 18 1 3 1...

Страница 29: ...gistered in variable tables A variable can be registered automatically when it is entered in a ladder or ST program Registered variables can also be entered in ladder programs after they have been reg...

Страница 30: ...J1M CJ1M CPU11 12 13 21 22 23 The following CP series CPU Units are compatible CP1H CP1H X XA Y CP1L CP1L M L Note If a user program containing function blocks created on the CX Program mer Ver 5 0 or...

Страница 31: ...H 65H 66H 67H 64H R 65H R 66H R 67H R 1 024 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...

Страница 32: ...input output variables 64 max Allocation of addresses used by variables Automatic allocation The allocation range can be set by the user Actual address specification Supported Array specifications Sup...

Страница 33: ...k library file cxf Project Text Files Containing Function Blocks cxt Data equivalent to that in project files created with CX Programmer Ver 6 0 cxp can be saved as CXT text files cxt 1 1 4 Function B...

Страница 34: ...is play shows details such as the relationship between instance nesting levels and allocated variable addresses in the instances Insert Function Block Invocation F Creates an instance in the program s...

Страница 35: ...n Point Used with the Step Run or Continuous Step Run com mands to automatically scroll the display and always show the pause point Break Point List Displays a list of the break points that have been...

Страница 36: ...ds a variable to the last line Insert Variable Above Inserts the variable above the current cursor position Below Inserts the variable below the current cursor position Cut Cuts the variable Copy Copi...

Страница 37: ...a single function block by using the parameters in the standard process as input variables such as timer SVs control constants speed settings and travel distances Reduce Coding Errors Coding mistakes...

Страница 38: ...ained in function blocks Each function block definition contains the algorithm and variable definitions as shown in the following diagram 1 Algorithm Standardized programming is written with variable...

Страница 39: ...initialized the next time an instance is executed the same instance name can be used to save memory Number of Instances Multiple instances can be created from a single function block definition Up to...

Страница 40: ...d address Note 1 Only addresses in the following areas can be used as parameters CIO Area Auxiliary Area DM Area EM Area banks 0 to C Holding Area and Work Area The following cannot be used Index and...

Страница 41: ...l symbol as an external variable Using Input Output Variables In Out When using an input output variable set the address for the input parameter A constant cannot be set The address set for the input...

Страница 42: ...cation and the timer will not function properly if both instructions are exe cuted P_On 1 0 10 CONTROL EN ENO ON_TIME OFF_TIME 20 CASCADE_01 P_On 1 1 10 CONTROL EN ENO ON_TIME OFF_TIME 15 CASCADE_02 P...

Страница 43: ...ock1 N A Auto Program Instance sample of function block definition A The instance is registered in the global symbol table with the instance name as the symbol name Name Data type Address value The fu...

Страница 44: ...obal symbols for use within instances For details on variable usage refer to the section on Variable Type Usage under Variable Definitions in 2 1 2 Function Block Elements The following table shows th...

Страница 45: ...able bit to either 1 TRUE or 0 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 v...

Страница 46: ...Function Block SFC Memory Allo cation from the PLC Menu Set the areas in the Function Block SFC Memory Allocation Dialog Box a b 15 0 15 0 t Name Type AT Initial Value Retained a BOOL Name Type AT b...

Страница 47: ...9 CJ2H CPU67 EIP EM banks 7 to E CJ2H CPU68 EIP EM banks 11 to 18 FB Instance Area Default value Applicable memory areas Start address End address Size Non Retain H512 H1407 896 CIO WR HR DM EM Retai...

Страница 48: ...it can be reused in other projects PLCs 1 5 1 Creating Function Blocks and Executing Instances The following procedure outlines the steps required to create and execute a function block 1 2 3 1 First...

Страница 49: ...te In the CX Programmer Ver 5 0 each function block definition can be com piled and checked as a program We recommend compiling to perform a pro gram check on each function block definition file befor...

Страница 50: ...C 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 Support for ST Language i...

Страница 51: ...Version 7 0 The STRING data type text cannot be used in ST programming See note There are no text processing functions sup ported for ST programming Even in a ladder program the user has to con sider...

Страница 52: ...der ST programs in function blocks Note The CX Simulator Ver 1 6 sold separately must be installed in order to use these functions Note I O break conditions cannot be set Previous version Ver 6 0 New...

Страница 53: ...lock instance s lad der diagram could not be monitored while moni toring the program online It was only possible to check the program in the function block definition The I O status of a function bloc...

Страница 54: ...rogramming Restrictions 53 2 4 3 Programming Restrictions 54 2 5 Function Block Applications Guidelines 56 2 5 1 Deciding on Variable Data Types 56 2 5 2 Determining Variable Types Inputs Outputs In O...

Страница 55: ...U Units Suffix CPU44H 45H 64H 65H 66H 67H 64H R 65H R 66H R 67H R 2 048 max per CPU Unit Suffix CPU42H 43H 63H 256 max per CPU Unit CJ1M CPU Units CJ1M CPU11 12 13 21 22 23 256 max per CPU Unit CP1H C...

Страница 56: ...cters long Variables name cannot contain spaces or any of the following characters Variable names cannot start with a number 0 to 9 Variable names cannot contain two underscore characters in a row The...

Страница 57: ...o and from instances using addresses Variables used only within instance Global symbols registered as vari ables beforehand with the CX Pro grammer or user defined global symbols Status of value at ne...

Страница 58: ...ut parameter value will be set when the parameter for input variable EN goes ON and the instance is executed Note The input parameter setting cannot be omitted when using the CX Programmer EN Enable V...

Страница 59: ...in the execution cycle of the algorithm do not write the value to a parameter Assign the value to an in ternal variable and use an AT setting specified addresses Initial Value An initial value can be...

Страница 60: ...es Internal variables are used within an instance These variables are hidden within each instance They cannot be referenced from outside of the instance and are not displayed in the instance The value...

Страница 61: ...els To hold the values of variables in function blocks however use the Retain Option and not the IOM Hold Bit Initial Value An initial value can be set for an internal variable that is not being retai...

Страница 62: ...Timer Completion Flag 1 bit or the timer present value 16 bits is specified depending on the in struction operand The TIMER data type cannot be used in structured text function blocks 2 The COUNTER d...

Страница 63: ...in advance PLC addresses for other nodes in the network Example If the READ DATA FILE instruction FREAD is being used in the function block definition and it is necessary to check the File Memory Ope...

Страница 64: ...The index indicates the location of the element in the array A one dimensional array is an array with just one index number Example When an internal variable named SCL is set as an array variable with...

Страница 65: ...e power is interrupted and PLC operation starts Algorithm Enter the logic programming using the registered variables Operand Input Restrictions Addresses cannot be directly input into instruction oper...

Страница 66: ...nteger 32 0 to 4 294 967 295 ULINT Unsigned long 8 byte integer 64 0 to 18 446 744 073 709 551 615 REAL Real number 32 3 402823 1038 to 1 175494 10 38 0 1 175494 10 38 to 3 402823 1038 LREAL Long real...

Страница 67: ...stance s internal variables input variables output variables and input output variables These areas are known as the function block instance areas and the user must specify the first addresses and siz...

Страница 68: ...CPU67 EIP EM banks 7 to E CJ2H CPU68 EIP EM banks 11 to 18 FB Instance Area Default value Applicable memory areas Start address End address Size Non Retain H512 H1407 896 CIO WR HR DM EM Retain H1408...

Страница 69: ...Variables for which the retain property for power OFF and operation start is set as non retained See note 1 Applicable areas H Function block Special Holding Area I O CIO Area H Holding Area W Interna...

Страница 70: ...ction Block Holding Area words for the non retained area and retained area If there are not sufficient words use words in areas not used by the user program FQM1 Flexible Motion controller Non retaine...

Страница 71: ...e created If this occurs execute the optimization opera tion to effectively use the allocated areas and remove the unused areas Comments A comment of up to 30 000 characters long can be entered Creati...

Страница 72: ...ce B I O variables Internal variables Body I O variables Internal variables Body FB definition Variable definitions Body Item Applicable data Input parameters Values See note 1 addresses and program s...

Страница 73: ...imal point Negative value followed by real number with decimal point 3 402823 1038 to 1 175494 10 38 0 1 175494 10 38 to 3 402823 1038 LREAL Long real number 64 bits 1 79769313486232 10308 to 2 225073...

Страница 74: ...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 When the input to...

Страница 75: ...guage ladder language or either combination of the two The function block nesting levels can also be displayed in a directory tree for mat with the FB Instance Viewer function The nested function blo...

Страница 76: ...s in I O memory Restrictions for Input Variables Output Variables and Input Output Variables Unsupported Data Areas Addresses in the following data areas cannot be used as parameters for input variabl...

Страница 77: ...instructions cannot be used to reset multiple timers and counters within a function block at the same time Always specify the same variable for the first operand timer counter num ber 1 and second ope...

Страница 78: ...tements Iteration statements FOR WHILE REPEAT and EXIT statements RETURN statements Function block calling statements Arithmetic operators Logical operators Comparison operators Numerical functions Ar...

Страница 79: ...n task units but uploading is possible Programming Console Displays When a user program created with the CX Programmer is downloaded to the CPU Unit and read by a Programming Console the instances wil...

Страница 80: ...er and NSJ Controllers FQM1 Flexible Motion Controllers FB EN ENO AAA BBB D200 D100 0 0 LD P_On AAA MOV AAA BBB 10 0 Program FB definition Body Instance name Fatal error occurs here Function block ins...

Страница 81: ...Deciding on Variable Data Types Integer Data Types 1 2 or 4 word Data Use the following data types when handling single numbers in 1 2 or 4 word units INT and UINT DINT and DINT LINT and ULINT Note U...

Страница 82: ...riable as described in 2 5 4 Array Settings for Input Output Variables and Internal Variables Values are passed in a batch from the input parameters to the input vari ables before algorithm execution...

Страница 83: ...ss set for the input parameter can be used inside the FB Input output variables should thus be used when it s necessary to pass large quantities of data to a function block W0 00 OK_Flag NG_Flag W0 01...

Страница 84: ...r details refer to 2 5 5 Specifying Addresses Allocated to Special I O Units When Auxiliary Area bits that are not pre registered to external variables are used and these bits are registered to global...

Страница 85: ...der programming within the function block to set data into the array Handling Control Data in Multiple Words In this example an array contains the number of words and first source word operand S1 for...

Страница 86: ...t be calculated as follows Remainder Dividend Divisor Quotient 2 5 5 Specifying Addresses Allocated to Special I O Units Use Index Registers IR0 to IR15 indirectly specified constant offset to spec if...

Страница 87: ...ex Register indirect speci fication IR0 to IR15 Note After storing the real I O memory addresses in the Index Registers using the MOVR 560 instruction Index Registers can be indirectly specified using...

Страница 88: ...incorporate processing in the program to return the Index Register to the saved value 2 Always set the value before using Index Registers Operation will not be stable if Index Registers are used with...

Страница 89: ...Area word n Example The real I O memory address for the first word of CIO 1500 unit number 25 allocated in the CPU Bus Unit allocation area based on the CPU Bus Unit s unit number 0 to 15 passed from...

Страница 90: ...truction The follow ing precautions apply 1 2 3 1 If a non array variable is specified without AT setting and without a match ing data size the CX Programmer will output an error when compiling 2 The...

Страница 91: ...in a serious accident Do not use variables with a size that does not match the data size to be pro cessed by the instruction in the operand specifying the first address or last address for a range of...

Страница 92: ...perand Specifying Size Constant The CX Programmer will output an error when compiling Example BLOCK TRANSFER XFER W S D W Number of words S First source word D First destination word When 20 is specif...

Страница 93: ...sion 3 0 are given as Not supported in function blocks in the Symbol col umn Restrictions on Operands Operands that specify the first or last of multiple words thereby requiring AT setting or specific...

Страница 94: ...rsion 7 0 or higher or 2 An array variable with the required number of elements must be pre pared and after the array data is set in the function block definition the first or last element in the arra...

Страница 95: ...Memory 32K words 25 banks E0_00000 to E18_32767 32K words 15 banks E0_00000 to EE_32767 32K words 10 banks E0_00000 to E9_32767 32K words 4 banks E0_00000 to E3_32767 32K words 4 banks E0_00000 to E3...

Страница 96: ...64 64 128 64 64 64 Item Specification Item Specification Model CJ1H CPU67H CPU67H R CJ1H CPU66H CPU66H R CJ1H CPU65H CPU65H R CPU64H R CJ1G CPU45H CJ1G CPU44H CJ1G CPU43H CJ1G CPU42H I O points 2 560...

Страница 97: ...city steps 20K 10K 5K 20K 10K 5K Number of Expan sion Racks 1 max Expansion not supported 1 max Expansion not supported Data memory 32K words Extended Data Memory None Pulse start times 46 s without a...

Страница 98: ...models XA models Y models Model CP1H X40DR A CP1H X40DT D CP1H X40DT1 D CP1H XA40DR A CP1H XA40DT D CP1H XA40DT1 D CP1H Y20DT D Max number of I O points 320 points 40 built in points 40 points Expansi...

Страница 99: ...its and Expansion I O Units 3 Units CP series Expansion Units and Expansion I O Units 1 Unit CP series Expan sion Unit or Expansion I O Unit None Function blocks Maximum num ber of definitions 128 Max...

Страница 100: ...function blocks Refer to the descriptions of individual instruc tion in the CS CJ Series Instruction Reference for details Item Coordinator Module Motion Control Modules Model FQM1 CM002 FQM1 MMA22 FQ...

Страница 101: ...ations i e for multiple instances Therefore in the above equation the number of instances is not multiplied by the number of instruction steps in the function block definition p The following table ap...

Страница 102: ...xible Motion Controllers Use the following equation to calculate the effect of instance execution on the cycle time when function block definitions have been created and the instances copied into the...

Страница 103: ...S1H CPU6 H CJ1H CPU6 H CS1G CPU4 H CJ1G CPU4 H NSJ CJ1M CPU CP1H X CP1H XA CP1H Y CP1L M CP1L L A Startup time Startup time not including I O parameter transfer 3 3 s 6 8 s 8 8 s 15 0 s B I O paramete...

Страница 104: ...riables 104 3 2 8 Copying and Editing Function Block Definitions 106 3 2 9 Checking the Source Function Block Definition from an Instance 106 3 2 10 Checking Instance Information such as Nesting Level...

Страница 105: ...unction Blocks Structured Text from the pop up menu Define the Function Block Refer to 3 2 3 Defining Function Blocks Created by User for details Registering Variables before Inputting the Ladder Prog...

Страница 106: ...tance and select Function Block SFC Memory Function Block SFC Memory Allocation from the PLC Menu 2 Set the function block memory allocations Printing Saving and Reusing Function Block Files Compile t...

Страница 107: ...s shown below 2 Function block definitions are created by inserting function block defini tions after the Function Blocks icon Creating Function Block Definitions Function blocks can be defined by the...

Страница 108: ...ated the name FunctionBlock will be assigned automatically where is a serial number These names can be changed All names must contain no more than 64 characters Using OMRON FB Library Files Use the fo...

Страница 109: ...nt the variable table is empty because there are no variables allo cated for I O memory addresses in the PLC Ladder Program or Structure Text as an Algorithm With some exceptions the ladder program fo...

Страница 110: ...t be switched while registering or displaying the variables 1 2 3 1 Make the sheet for the type of variable to be registered active in the vari able table See note Place the cursor in the sheet right...

Страница 111: ...iable is registered can be changed by double clicking and changing the setting in the Usage field N Internals I Inputs O Outputs E Externals P In Out The variable can also be copied or moved between t...

Страница 112: ...d Data Registers DR can be input directly as follows not as variables Addresses DR0 to DR5 direct specifica tions IR0 to IR15 and indirect specifications IR0 to IR15 Using Structured Text An ST langua...

Страница 113: ...structured text program can be input first and variable registered as they are required Using a Ladder Program When using a ladder diagram a dialog box will be displayed to register the variable when...

Страница 114: ...istered using the CX Programmer A variable name is required to achieve this Use the following procedure to specify an address 1 2 3 1 After inputting the variable name in the New Variable Dialog Box c...

Страница 115: ...t a dialog box will not be displayed to register the variable whenever a variable name that has not been registered is input Be sure to always register variables used in standard text programming in t...

Страница 116: ...nder Options in Tools Menu Addresses and I O comments are not registered in the function block defini tion variable tables Addresses are displayed in the operand in red I O com ments will be lost Doub...

Страница 117: ...s function is designed to help you create function block definitions based on existing ladder programming It does not automatically generate finish def initions After generating a function block defin...

Страница 118: ...Menu If necessary double click any variable in the variable list and change the name or comment The array and AT settings can also be changed 4 Click the OK Button The following Function Block Ladder...

Страница 119: ...nction is convenient for converting existing ladder programming that has been proven in actual operation into function blocks The application of addresses within the selected program cir cuits is anal...

Страница 120: ...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 us...

Страница 121: ...498 and DT_WORD 1 is specified for MOV 021 Instructions with Two Operands Specifying Starting and Ending Words Example D0 to D9 Specified for BSET 071 As shown below the variables must be changed to s...

Страница 122: ...second operand of XFER 070 3 2 4 Creating Instances from Function Block Definitions If a function block definition is registered in the global symbol table either of the following methods can be used...

Страница 123: ...able with the FUNCTION BLOCK data type 2 Input the instance name select the function block from which to create an instance and click the OK Button 3 As an example set the instance name in the FB Inst...

Страница 124: ...left bus bar i e an EN must always be inserted 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 bee...

Страница 125: ...definition Press the P Key with the cursor on the left of the instance The New Parameter Dialog Box will be displayed Input the address from which to pass data to the input variable The value of 001 i...

Страница 126: ...1038 LREAL Long real number 64 bits 1 79769313486232 10308 to 2 22507385850720 10 308 0 2 22507385850720 10 308 to 1 79769313486232 10308 WORD 16 bit data 16 bits followed by hexadecimal number 4 digi...

Страница 127: ...are specified CS CJ series CPU Units Ver 3 0 or Later and NSJ Controllers Note 1 Bit data can be accessed even if the DM or EM Area is specified for the non retained area or retained area FB Instance...

Страница 128: ...ses in the function block instance areas overlap with any of the addresses used in the user program an error will occur when compil ing This error will also occur when a program is downloaded edited o...

Страница 129: ...pop up menu Alternately select Memory Allocation Function Block SFC Memory Function Block SFC Memory Address from the PLC Menu 3 The FB Interface Memory Dialog Box will be displayed Check the I O memo...

Страница 130: ...ted 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...

Страница 131: ...from an Instance Use the following procedure to check the function block definition from which an instance was created Either double click the instance or right click the instance and select To Lower...

Страница 132: ...ing Function Block Definitions Checking Program A function block definition can be compiled to perform a program check on it Use the following procedure When nesting this area shows the nesting level...

Страница 133: ...ble table and algorithm displayed select 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 i...

Страница 134: ...ies This level of protection prevents unintended program changes modifications and also protects against misap propriation of program materials Password Protection on Writing Only This password protec...

Страница 135: ...block definition has been password protected the func tion block definition s icon will change to indicate that it is protected The icon also indicates the protection level as shown below Prohibit wr...

Страница 136: ...1 2 3 1 In the project workspace select the function block definition right click and select Properties from the pop up menu Alternately select Proper ties from the View Menu 2 The Function Block Prop...

Страница 137: ...ock definition and perform a program check 2 When function blocks are being nested the function block definition of the called nested function blocks are included and saved in the function block libra...

Страница 138: ...ble 3 2 18 Monitoring and Debugging Function Blocks The following procedures can be used to monitor programs containing func tion blocks Monitoring I O in Ladder Programs within Instances With the CX...

Страница 139: ...ms within an instance 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 Instance from the pop...

Страница 140: ...ht click and select Set Value from the pop up menu The Set New Value Dialog Box will be displayed Input the new value in the Value field Force setting and Force resetting Bits To force set force reset...

Страница 141: ...owing procedure to monitor instance variables 1 2 3 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 D...

Страница 142: ...lt Data Type is A All Special data types BOOL and INT can also be selected 4 Click the OK Button The selected variable will be registered in the Watch Window and the value will be displayed as shown b...

Страница 143: ...ct the Simulator Debug Option in the Tool bars Tab 3 Select Work Online Simulator from the CX Programmer s PLC Menu and transfer the program to the CX Simulator in the computer Note Steps 2 and 3 can...

Страница 144: ...of a ladder ST program within an instance Step Run operation and return to one level higher in the program the program or instance that was the source of the call 1 2 3 1 During Step Run operation mo...

Страница 145: ...change the color select Tools Options and click the Appearance Tab Select Pause Simulator Simulator Instruction Break or Simulator IO Break and change the color for that condition Break Point Operatio...

Страница 146: ...uctions not in instances can be changed and instances can be deleted Instances cannot be added instance names cannot be changed and changes cannot be made to variable tables or algorithms in function...

Страница 147: ...rted 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 chan...

Страница 148: ...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 Normal Mode Quick Mode Refer to Trans...

Страница 149: ...procedure from the beginning Transfer Modes Normal Mode In Normal Mode both the source code and object code are transferred to the CPU Unit Some time may be required for Normal Mode transfers because...

Страница 150: ...ck definitions always select 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 u...

Страница 151: ...time are given in the following table Note Cycle Time Monitor Time Be sure that the cycle time monitor time set in the PLC Setup is not exceeded when the program is rewritten as a result of online ed...

Страница 152: ...r details The previous status flags for all differentiated instructions DIFU 013 instructions DIFD 014 and instructions will be initialized i e turned OFF when online editing is finished After perform...

Страница 153: ...128 Procedures Section 3 2...

Страница 154: ...Part 2 Structured Text ST...

Страница 155: ......

Страница 156: ...ng functionality of the CX Programmer and explains the features that are not contained in the non structured text version of CX Programmer 4 1 ST Language 132 4 1 1 Overview 132 4 2 CX Programmer Spec...

Страница 157: ...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 There are many control statements ava...

Страница 158: ...U Unit model CJ2H CJ2H CPU68 67 66 65 64 68 EIP 67 EIP 66 EIP 65 EIP 64 EIP CS1G H with unit version 4 0 CS1G CPU45H 44H 43H 42H CS1H H with unit version 4 0 CS1H CPU67H 66H 65H 64H 63H CJ1G H with un...

Страница 159: ...134 CX Programmer Specifications Section 4 2...

Страница 160: ...Derivative Data Types 137 5 3 Inputting ST Programs 138 5 3 1 Syntax Rules 138 5 3 2 CX Programmer s ST Input Screen Display 140 5 4 ST Language Configuration 141 5 4 1 Statements 141 5 4 2 Variables...

Страница 161: ...fer to 5 4 4 Operators Functions Refer to 5 4 5 Standard Functions and 5 4 6 OMRON Expan sion Functions Example of a Control Statement Note In an ST program addresses are not input as actual I O memor...

Страница 162: ...7 483 647 LINT Long 8 byte integer 64 9 223 372 036 854 775 808 to 9 223 372 036 854 775 807 UINT Unsigned integer 16 0 to 65 535 UINT BCD Unsigned BCD integer See note 1 UDINT Unsigned double integer...

Страница 163: ...nywhere within statements Therefore use spaces carriage returns and tabs between reserved words and equations to make them easier to read Spaces carriage returns and tabs cannot be used between the fo...

Страница 164: ...are used in this way Operator Priority Consider the operator priority in the structured text syntax or enclose operations requiring priority in parentheses Example AND takes priority over OR Therefor...

Страница 165: ...xt keywords reserved words Blue Comments Green Errors Red Other Black Changing Fonts To change font sizes or display colors select Tools Options click the Appearance Tab and then click the ST Font But...

Страница 166: ...al_value TO final_value BY increment DO expression END_FOR WHILE DO END_WHILE Repeatedly evaluates an expression as long as a condition is true WHILE condition DO expression END_WHILE REPEAT UNTIL END...

Страница 167: ...cording to the data type Therefore the addition result for INT data for example must be a variable using the INT data type Particularly care is required when a carry or borrow occurs in an operation f...

Страница 168: ...ariable b stored in variable a LN argument REAL LREAL REAL LREAL Natural logarithm LOGe argument a LN b natural logarithm of vari able b stored in variable a LOG argument REAL LREAL REAL LREAL Common...

Страница 169: ...ers Source_ string STRING STRING Extracts charac ters from a text string starting from the right a RIGHT b c number of characters specified by variable c extracted from the eight of text string b and...

Страница 170: ...g stored in variable a Replace_ string STRING Number_of_ characters INT UINT Position INT UINT FIND Source_string Find_string Source_ string STRING INT Finds characters within a text string a FIND b c...

Страница 171: ...ES YES YES YES YES YES YES No No No LREAL No YES YES YES YES YES YES YES YES YES No No No STRING No YES YES No YES YES No YES YES No No No No Function type Description Memory Card Functions Functions...

Страница 172: ...number of characters specified by variable b are received from the serial port specified by variable c on the Serial Communications Board and stored in variable a Number_of_ characters INT UINT WORD...

Страница 173: ...bstitutes stores an equation variable or constant for the variable Examples Example 1 Substitute variable A with the result of the equation X 1 A X 1 Example 2 Substitute variable A with the value of...

Страница 174: ...tion for the evaluation result 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 res...

Страница 175: ...h true variable X will be substituted with numerical value 10 and variable Y will be substituted with numerical value 20 If variable A 0 and variable B 1 are both false variable X and variable Y will...

Страница 176: ...ondition 2 If false Condition 3 If true execute expression 3 etc Condition n If true execute expression n If none of these conditions are met condition m is executed Precautions IF must be used togeth...

Страница 177: ...0 is false but variable B 2 variable X will be substituted with numerical value 2 If either of these conditions is met variable X will be substituted with numeri cal value 0 IF A 0 THEN X 10 ELSIF B...

Страница 178: ...d in expression_ are assignment state ments IF CASE FOR WHILE or REPEAT Multiple statements can be executed in expression_ Be sure to use a semicolon delimiter between multiple statements in an expres...

Страница 179: ...numerical value 2 If vari able 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 numeri...

Страница 180: ...expression is executed This process is repeated If the iteration_variable final_value_equation see note 2 the processing ends Note 1 If the value from the increment_equation is negative the condition...

Страница 181: ...tial_value final_value_equation and increment_equation Example 1 The iteration is performed when the iteration variable n 0 to 50 in increments of 5 and the array variable SP n is substituted with 100...

Страница 182: ...This process is repeated If the condition is false the expres sion is not executed and the condition evaluation ends Precautions WHILE must be used in combination with END_WHILE Before executing the...

Страница 183: ...repeat processing for as long as a condition is met after specified processing when the number of iterations is undetermined beforehand depends on whether the condition is met This statement can be us...

Страница 184: ...thin an IF statement to force an iteration statement to end when a specified condition is met Reserved Words EXIT Statement Syntax Example Using within IF Statement FOR WHILE REPEAT expression IF cond...

Страница 185: ...forcibly end an SFC program and function block that is executing an ST task Function Block Call Statement Summary This statement calls a function block definition Reserved Words None Statement Syntax...

Страница 186: ...lues depending on the ST program being used Calling function block s input variable or a constant when ST is being used in the function block s instance Global variable or local variable name when ST...

Страница 187: ...tion s output variable name or constant D One of the following values depending on the ST program being used Calling function block s output variable or constant when ST is being used in the function...

Страница 188: ...N3 Passed to FB_IN3 input variable OUT1 Received from FB_OUT1 output variable OUT2 Received from FB_OUT2 output variable OUT3 Received from FB_OUT3 output variable A Note Data type BOOL Passed to EN i...

Страница 189: ...N1 FB_IN2 IN2 FB_IN3 IN3 FB_OUT1 OUT1 FB_OUT2 OUT2 FB_OUT3 OUT3 ENO B EN and ENO not entered Instance_FB FB_IN1 IN1 FB_IN2 IN2 FB_IN3 IN3 FB_OUT1 OUT1 FB_OUT2 OUT2 FB_OUT3 OUT3 ENO not entered Instanc...

Страница 190: ...return the value from FB_OUT2 The EN and ENO data cannot be entered as an argument or return value Specification method 1 cannot be used together with specification method B in the same function bloc...

Страница 191: ...lculates the average value of input1 input2 and input3 and stores the result in average average input1 input2 input3 3 5 6 ST language Program Example 5 6 1 Using an ST Program in a Function Block Con...

Страница 192: ...e if A is a REAL data type a syntax error will occur for A 2 Use A 2 0 Bits TRUE FALSE can only be allocated to variables with the BOOL data type For example if A is a BOOL data type A FALSE is possib...

Страница 193: ...an error will not be detected for the following type of statement Operation will be unstable when this statement is executed i 15 INT i 10 Q Are the variables in the structured text editor automatical...

Страница 194: ...ing a New ST Program 170 6 1 3 Allocating the ST Program to a Task 171 6 1 4 Creating the ST Program 172 6 1 5 Compiling the ST Program Checking Program 174 6 1 6 Downloading Uploading Programs to the...

Страница 195: ...settings refer to the CX Programmer Operation Manual W446 6 1 2 Creating a New ST Program Use the following procedure to create an ST program in a project 1 2 3 1 Right click the Programs Item in the...

Страница 196: ...t 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 Note The following procedure which allocates a program to a task can be per...

Страница 197: ...t Input the ST language after registering the variables Register the variables as you input the ST language Inputting the ST Language after Registering Variables There are two kinds of variables globa...

Страница 198: ...can be created in a text editor and then pasted in the ST Editor Win dow by selecting Edit Paste If the symbol table with the registered variables is displayed while inputting the ST program it is eas...

Страница 199: ...standard text programming in the variable table either as you need them or after completing the program 6 1 5 Compiling the ST Program Checking Program The ST program can be compiled to perform a prog...

Страница 200: ...he Watch Window These oper ations are described below Monitoring Variables Variable values are displayed in blue in the ST variable monitor window Changing PVs To change a PV select the desired variab...

Страница 201: ...d in systems that cannot be shut down such as systems that operate 24 hours day ST programs can be edited online when the PLC is in an operating mode other than RUN mode This function cannot be used w...

Страница 202: ...making Quick Mode faster than Normal Mode After transferring the object code in Quick Mode either 1 select Program Transfer SFC ST Source to PLC to transfer the source code or 2 transfer the source co...

Страница 203: ...to be transferred 2 Connect online with the PLC that was the destination of the Quick Mode transfer The flashing yellow message Src Fail will be displayed in the CX Programmer s status bar 3 Select Pr...

Страница 204: ...ximum 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 After performing online editing do not turn OFF the power supply t...

Страница 205: ...180 Procedures Section 6 1...

Страница 206: ...ways ON Flag P_On BOOL CF113 Clock Pulses 0 02 second clock pulse bit P_0_02s BOOL CF103 0 1 second clock pulse bit P_0_1s BOOL CF100 0 2 second clock pulse bit P_0_2s BOOL CF101 1 minute clock pulse...

Страница 207: ...182 System defined external variables supported in function blocks Appendix A...

Страница 208: ...type was substituted Y ABS X X is an INT type variable Y is a UINT type variable Division by Zero The numeric expression con tains division by 0 End of comment not found The comment does not have a cl...

Страница 209: ...EPEAT in the syntax UNTIL X 10 END_REPEAT Invalid variable for Function output The specified variable for the function output is illegal A non boolean BOOL variable or numeral has been specified as th...

Страница 210: ...variable with a data type that does not support negative values UINT UDINT ULINT Y X X is an UINT type variable Y is an INT type vari able There must be one line of valid code excluding com ments The...

Страница 211: ...ord has been used in an invalid location For example use of the EXIT statement outside a loop syn tax Conversion from s to s possible loss of data Data may be lost due to con version of a data type wi...

Страница 212: ...the right of the specified text string Application Return_value RIGHT Source_string Number_of_characters Variable name Data type Description String STRING Specifies the text string for which to find...

Страница 213: ...turn_value STRING Returns the extracted charac ters Variable name Data type Description Source_string STRING Specifies the text string from which to extract characters Number_of_characters INT UINT Sp...

Страница 214: ...in message 1 in the following illustration Return_value STRING Returns the text string with the characters inserted Variable name Data type Description Source_string STRING Specifies the text string...

Страница 215: ...INT UINT Specifies the number of characters to be replaced Position INT UINT Specifies the position from which to replace characters The first character is position 1 e g position 1 is A in mes sage 1...

Страница 216: ...es the directory and file name including the root direc tory The file name must be 8 characters or less The file name extension is always TXT For example the following file name creates a file named L...

Страница 217: ...Auxiliary Area Easy backup operation Memory Card Detected Flag A343 15 ON when a Memory Card has been detected Variable name Data type Description Send_string STRING Specifies the text string to send...

Страница 218: ...mode Variable name Data type Description Send_string STRING Specifies the text string to send Serial_port INT UINT WORD Specifies the number of the serial port 1 Serial port 1 2 Serial port 2 Variabl...

Страница 219: ...otocol mode Port 2 Send Ready Flag A356 13 ON when sending is enabled in no protocol mode Variables BOOL P_DoSendData Variable to control send function INT iProcess Process number STRING Message Send...

Страница 220: ...iProcess Process number STRING Message Send message BOOL P_TXDU_Exe TXDU Execution Flag AT 1519 05 Unit number 0 Use serial port 2 BOOL P_ComInstEnable Communications Port Enable Flag AT A202 07 Use...

Страница 221: ...rt must be set to no protocol communications Arguments and Return Values Related Auxiliary Area Flag Address Communications Instruction Enable Flags A202 00 to A202 07 ON when network communications c...

Страница 222: ...RS 232C Port Reception Overflow Flag A392 07 ON when a data overflow occurred during reception in no pro tocol mode RS 232C Port Reception Counter A393 Contains the number of characters received in no...

Страница 223: ...A356 07 ON when a data overflow occurred during reception in no pro tocol mode Port 1 Reception Counter A357 Contains the number of characters received in no protocol mode Port 2 Reception Completed F...

Страница 224: ...Variable to control receive function INT iProcess Process number STRING Message Variable to store received message BOOL P_RXDU_Recv Status of Serial Communications Unit AT 1519 06 Unit No 0 Use serial...

Страница 225: ...ag A202 00 to A202 07 ON when network communications can be executed The bit numbers correspond directly to the internal logic port numbers Bits 00 to 07 Internal logic ports 0 to 7 Related CPU Bus Un...

Страница 226: ...ions 13 checking for an instance 106 compiling 107 creating 82 saving to files 112 function blocks advantages 12 application guidelines 56 creating 23 debugging 113 defining 85 elements 31 errors 55 m...

Страница 227: ...safety precautions xxii specifications CX Programmer Ver 5 0 5 function block operation 49 instances 42 structured text function block definition 84 restrictions 53 symbol name automatically generatin...

Страница 228: ...program variable monitoring 03 July 2006 Added Ver 7 0 upgrade information 04 January 2007 Pages 17 and 18 Changed can to cannot in table two locations and changed note Page 29 Changed text in inputs...

Страница 229: ...204 Revision History...

Страница 230: ......

Страница 231: ...5302 U S A Tel 1 847 843 7900 Fax 1 847 843 7787 OMRON ASIA PACIFIC PTE LTD No 438A Alexandra Road 05 05 08 Lobby 2 Alexandra Technopark Singapore 119967 Tel 65 6835 3011 Fax 65 6835 2711 OMRON CHINA...

Отзывы: