Omron NY532-5400 Reference Manual

Omron NY532-5400 Reference Manual

Ny-series
Hide thumbs Also See for NY532-5400:
Table of Contents

Advertisement

Industrial PC Platform
NY-series
Instructions
Reference Manual
NY532-1500
NY532-1400
NY532-1300
NY532-5400
NY512-1500
NY512-1400
NY512-1300
W560-E1-04

Advertisement

Table of Contents
loading

Summary of Contents for Omron NY532-5400

  • Page 1 Industrial PC Platform NY-series Instructions Reference Manual NY532-1500 NY532-1400 NY532-1300 NY532-5400 NY512-1500 NY512-1400 NY512-1300 W560-E1-04...
  • Page 2 No patent liability is assumed with respect to the use of the information contained herein. Moreover, because OMRON is constantly striving to improve its high-quality products, the information contained in this manual is subject to change without notice. Every precaution has been taken in the preparation of this manual. Neverthe- less, OMRON assumes no responsibility for errors or omissions.
  • Page 3: Introduction

    This manual covers the following products. • NY-series IPC Machine Controller Industrial Panel PC • NY532-15 • NY532-14 • NY532-13 • NY532-5400 • NY-series IPC Machine Controller Industrial Box PC • NY512-15 • NY512-14 • NY512-13 Part of the specifications and restrictions for the Industrial PC are given in other manuals. Refer to Rel- evant Manuals on page 2 and Related Manuals on page 24.
  • Page 4: Relevant Manuals

    Relevant Manuals Relevant Manuals The following table provides the relevant manuals for the NY-series Controller. Read all of the manuals that are relevant to your system configuration and application before you use the NY-series Controller. Most operations are performed from the Sysmac Studio Automation Software. Refer to the Sysmac Stu- dio Version 1 Operation Manual (Cat.
  • Page 5 Relevant Manuals *2 Refer to the NY-series Troubleshooting Manual (Cat. No. W564) for the error management concepts and the error items. NY-series Instructions Reference Manual (W560)
  • Page 6: Manual Structure

    Manual Structure Manual Structure Some of the instructions described in this manual are common to the NJ/NX-series. Therefore, note the following conditions. • You cannot connect a CJ-series Unit with NY-series Controllers. In the instructions, skip items and samples related to CJ-series Units. •...
  • Page 7 Manual Structure Level-1 heading 2 Instruction Descriptions Level-2 heading OR and ORN Level-3 heading Level-3 heading Give the current headings. Takes the logical OR of the value of a BOOL variable and the execution condition. ORN: Takes the logical OR of the inverse of the value of a BOOL variable and the execution condi- tion.
  • Page 8 Manual Structure NY-series Instructions Reference Manual (W560)
  • Page 9: Sections In This Manual

    Sections in this Manual Sections in this Manual Instruction Set Instruction Descriptions Appendices Index NY-series Instructions Reference Manual (W560)
  • Page 10: Table Of Contents

    CONTENTS CONTENTS Introduction ....................... 1 Relevant Manuals ...................... 2 Manual Structure ....................... 4 Sections in this Manual .................... 6 Terms and Conditions Agreement................. 15 Safety Precautions ....................17 Precautions for Safe Use..................18 Precautions for Correct Use................... 19 Regulations and Standards..................20 Versions ........................
  • Page 11 CONTENTS OutABit ........................2-63 Sequence Control Instructions ....... . . 2-65 End ..........................
  • Page 12 CONTENTS AryMean ........................ 2-229 ArySD ........................2-231 ModReal ........................ 2-233 Fraction ......................... 2-235 CheckReal ......................2-237 BCD Conversion Instructions ....... . .2-241 **_BCD_TO_*** .....................
  • Page 13 CONTENTS Exchange ......................2-367 AryExchange ......................2-369 AryMove ........................ 2-371 Clear ........................2-373 Copy**ToNum (Bit String to Signed Integer) ............2-375 Copy**To*** (Bit String to Real Number) ............... 2-377 CopyNumTo** (Signed Integer to Bit String) ............2-379 CopyNumTo** (Signed Integer to Real Number) ..........2-381 Copy**To*** (Real Number to Bit String) ...............
  • Page 14 CONTENTS RecSort ......................... 2-518 RecNum ........................ 2-524 RecMax and RecMin ..................... 2-526 FCS Instructions ......... . .2-531 StringSum ......................
  • Page 15 CONTENTS TruncTime ......................2-651 TruncDt ........................2-655 TruncTod ....................... 2-659 Analog Control Instructions ........2-663 PIDAT ........................
  • Page 16 CONTENTS CIPUCMMWrite ....................2-1028 CIPUCMMSend ....................2-1035 SktUDPCreate ..................... 2-1045 SktUDPRcv ......................2-1053 SktUDPSend ....................... 2-1056 SktTCPAccept ..................... 2-1059 SktTCPConnect ....................2-1062 SktTCPRcv ......................2-1071 SktTCPSend ......................2-1074 SktGetTCPStatus ....................2-1077 SktClose ......................2-1080 SktClearBuf ......................2-1083 SktSetOption ....................... 2-1086 ChangeIPAdr .......................
  • Page 17 CONTENTS GetMyTaskInterval ....................2-1375 Task_IsActive ...................... 2-1378 Lock and Unlock ....................2-1380 ActEventTask ...................... 2-1387 Get**Clk ....................... 2-1393 Get**Cnt ......................2-1394 Appendices A-1 Error Codes That You Can Check with ErrorID..............A-2 A-2 Instructions You Cannot Use in Event Tasks..............A-18 A-3 Instructions Related to NX Message Communications Errors..........A-20 A-4 SDO Abort Codes ........................A-21 A-5 Version Information .......................A-22 Index...
  • Page 18: Terms And Conditions Agreement

    Omron’s exclusive warranty is that the Products will be free from defects in materials and workman- ship for a period of twelve months from the date of sale by Omron (or such other period expressed in writing by Omron). Omron disclaims all other warranties, express or implied.
  • Page 19 Disclaimers Performance Data Data presented in Omron Company websites, catalogs and other materials is provided as a guide for the user in determining suitability and does not constitute a warranty. It may represent the result of Omron’s test conditions, and the user must correlate it to actual application requirements. Actual perfor- mance is subject to the Omron’s Warranty and Limitations of Liability.
  • Page 20: Safety Precautions

    Safety Precautions Safety Precautions Refer to the following manuals for safety precautions. • NY-series Industrial Box PC Hardware User’s Manual (Cat. No. W556) • NY-series Industrial Panel PC Hardware User’s Manual (Cat. No. W557) • NY-series Industrial Panel PC / Industrial Box PC Software User’s Manual (Cat. No. W558) NY-series Instructions Reference Manual (W560)
  • Page 21: Precautions For Safe Use

    Precautions for Safe Use Precautions for Safe Use Refer to the following manuals for precautions for safe use. • NY-series Industrial Box PC Hardware User’s Manual (Cat. No. W556) • NY-series Industrial Panel PC Hardware User’s Manual (Cat. No. W557) •...
  • Page 22: Precautions For Correct Use

    Precautions for Correct Use Precautions for Correct Use Refer to the following manuals for precautions for correct use. • NY-series Industrial Box PC Hardware User’s Manual (Cat. No. W556) • NY-series Industrial Panel PC Hardware User’s Manual (Cat. No. W557) •...
  • Page 23: Regulations And Standards

    Concepts  EMC Directive OMRON devices that comply with EU Directives also conform to the related EMC standards so that they can be more easily built into other devices or the overall machine. The actual products have been checked for conformity to EMC standards.* Whether the products conform to the standards in the system used by the customer, however, must be checked by the customer.
  • Page 24: Versions

    Versions Versions Hardware revisions and unit versions are used to manage the hardware and software in NY-series Con- trollers and EtherCAT slaves. The hardware revision or unit version is updated each time there is a change in hardware or software specifications. Even when two Units or EtherCAT slaves have the same model number, they will have functional or performance differences if they have different hard- ware revisions or unit versions.
  • Page 25 Versions  Changing Information Displayed in Production Information Dialog Box Click the Show Detail or Show Outline Button at the lower right of the Production Information Dialog Box. The view will change between the production information details and outline. Outline View Detail View The information that is displayed is different for the Outline View and Detail View.
  • Page 26: Related Manuals

    Related Manuals Related Manuals The followings are the manuals related to this manual. Use these manuals for reference. Manual name Cat. No. Model numbers Application Description NY-series W557 NY532- Learning the basic An introduction to the entire NY-series sys- IPC Machine Controller specifications of the tem is provided along with the following infor- Industrial Panel PC Hardware...
  • Page 27 NJ/NY-series NC Integrated O030 NJ501-5300 Performing numeri- Describes the functionality to perform the Controller User’s Manual cal control with numerical control. NY532-5400 NJ/NY-series Control- lers. NJ/NY-series G code Instruc- O031 NJ501-5300 Learning about the The G code/M code instructions are...
  • Page 28 Related Manuals Manual name Cat. No. Model numbers Application Description GX-series EtherCAT Slave W488 GX-ID Learning how to use Describes the hardware, setup methods, and Units User’s Manual the EtherCAT remote functions of the EtherCAT remote I/O termi- GX-OD I/O terminals. nals.
  • Page 29: Revision History

    Revision History Revision History A manual revision code appears as a suffix to the catalog number on the front and back covers of the manual. W560-E1-04 Cat. No. Revision code Revision code Date Revised content September 2016 Original production November 2016 Corrected mistakes. April 2017 Corrected mistakes.
  • Page 30 Revision History NY-series Instructions Reference Manual (W560)
  • Page 31: Instruction Set

    Instruction Set This section provides a table of the instructions that you can use with NY-series Con- trollers. Instruction Set ..........1-2 NY-series Instructions Reference Manual (W560)
  • Page 32 1 Instruction Set Instruction Set Type Instruction Name Function Page Ladder Diagram Load Reads the value of a BOOL variable. 2-16 Instructions Load NOT Reads the inverse of the value of a BOOL vari- 2-16 able. Takes the logical AND of the value of a BOOL 2-18 variable and the input value.
  • Page 33 1 Instruction Set Type Instruction Name Function Page Sequence Out- Set-Priority Keep Retains the value of a BOOL variable. It gives 2-53 put Instructions priority to the Set input if both the Set input and Reset input are TRUE. Changes a BOOL variable to TRUE. 2-56 Reset Reset...
  • Page 34 1 Instruction Set Type Instruction Name Function Page Comparison GTascii Text String Performs a greater than comparison between 2-104 Instructions Comparison text strings. Greater Than GEascii Text String Performs a greater than or equal comparison 2-104 Comparison between text strings. Greater Than or Equal Compare...
  • Page 35 1 Instruction Set Type Instruction Name Function Page Counter Instruc- Down-counter Decrements the counter value when the 2-146 tions counter input signal is received. The preset value and counter value must have an INT data type. CTD_** Down-counter Decrements the counter value when the 2-148 Group counter input signal is received.
  • Page 36 1 Instruction Set Type Instruction Name Function Page Math Instruc- SQRT Square Root Finds the square root of a number. 2-204 tions Natural Logarithm Finds the natural logarithm of a real number. 2-206 Logarithm Base 10 Finds the base-10 logarithm of a real number. 2-206 Natural Performs calculations for the natural exponen-...
  • Page 37 1 Instruction Set Type Instruction Name Function Page Data Type Con- **_TO_*** (Integer-to- Integer-to-Real Converts integers to real numbers. 2-268 version Instruc- Real Number Conver- Number tions sion Group) Conversion Group **_TO_*** (Bit String-to- Bit String-to- Converts bit strings to integers. 2-270 Integer Conversion Integer Conversion...
  • Page 38 1 Instruction Set Type Instruction Name Function Page Data Type Con- TRUNC Truncate Truncates a real number at the first decimal 2-316 version Instruc- digit to make an integer. tions Round Round Off Real Rounds a real number at the first decimal digit 2-316 Number to make an integer.
  • Page 39 1 Instruction Set Type Instruction Name Function Page Data Movement SetBlock Block Set Moves the value of a variable or constant to 2-365 Instructions one or more array elements. Exchange Data Exchange Exchanges the values of two variables. 2-367 AryExchange Array Data Exchanges the elements of two arrays.
  • Page 40 1 Instruction Set Type Instruction Name Function Page Conversion Swap Swap Bytes Swaps the upper byte and lower byte of a 16- 2-404 Instructions bit value. Reverse Sign Reverses the sign of a number. 2-405 Decoder Bit Decoder Sets the specified bit to TRUE and the other 2-407 bits to FALSE in array elements that consist of a maximum of 256 bits.
  • Page 41 1 Instruction Set Type Instruction Name Function Page Conversion StringToFixNum Text String-to- Converts a decimal text string to a signed 2-453 Instructions Fixed-decimal fixed-decimal number. Conversion DtToString Date and Time-to- Converts a date and time to a text string. 2-456 Text String Conversion DateToString...
  • Page 42 1 Instruction Set Type Instruction Name Function Page Stack and Table StackPush Push onto Stack Stores a value in a stack. 2-492 Instructions StackFIFO First In First Out Removes the bottom value from a stack. 2-501 StackLIFO Last In First Out Removes the top value from a stack.
  • Page 43 1 Instruction Set Type Instruction Name Function Page Text String CONCAT Concatenate String Joins two to five text strings. 2-548 Instructions LEFT Get String Left Extracts a text string with the specified number 2-550 of characters from the start (left) of a text string.
  • Page 44 1 Instruction Set Type Instruction Name Function Page Time and Time ADD_TIME Add Time Adds two times. 2-594 of Day Instruc- ADD_TOD_TIME Add Time to Time Adds a time to a time of day. 2-596 tions of Day ADD_DT_TIME Add Time to Date Adds a time to a date and time.
  • Page 45 1 Instruction Set Type Instruction Name Function Page Time and Time DaysToMonth Convert Days to Calculates the month based on the number of 2-640 of Day Instruc- Month days from January 1. tions GetDayOfWeek Get Day of Week Gets the day of the week for the specified year, 2-642 month, and day of month.
  • Page 46 1 Instruction Set Type Instruction Name Function Page System Control GetPLCError Get PLC Controller Gets the highest level status (partial fault or 2-818 Instructions Error Status minor fault) and highest level event code of the current Controller errors in the PLC Function Module.
  • Page 47 1 Instruction Set Type Instruction Name Function Page EtherCAT Com- EC_CoESDOWrite Write EtherCAT Writes a value to a CoE object of a specified 2-900 munications CoE SDO slave on the EtherCAT network. Instructions EC_CoESDORead Read EtherCAT Reads a value from a CoE object of a specified 2-903 CoE SDO slave on the EtherCAT network.
  • Page 48 1 Instruction Set Type Instruction Name Function Page EtherNet/IP SktUDPCreate Create UDP Creates a UDP socket request to open a servo 2-1045 Communica- Socket port for the built-in EtherNet/IP. tions Instruc- SktUDPRcv UDP Socket Reads the data from the receive buffer for a 2-1053 tions Receive...
  • Page 49 1 Instruction Set Type Instruction Name Function Page Serial Commu- NX_SerialSend Send No-protocol Sends data in No-protocol Mode from a serial nications Data port on an NX-series Communications Inter- 2-1156 Instructions face Unit or Option Board. NX_SerialRcv Receive No- Reads data in No-protocol Mode from a serial protocol Data port on an NX-series Communications Inter- 2-1169...
  • Page 50 1 Instruction Set Type Instruction Name Function Page SD Memory FileWriteVar Write Variable to Writes the value of a variable to the specified 2-1244 Card Instruc- File file in the SD Memory Card. The value is writ- tions ten in binary format. FileReadVar Read Variable from Reads the contents of the specified file on the...
  • Page 51 1 Instruction Set Type Instruction Name Function Page Other Instruc- ReadNbit_** N-bit Read Group Reads zero or more bits from a bit string. 2-1366 tions WriteNbit_** N-bit Write Group Writes zero or more bits to a bit string. 2-1368 ChkRange Check Subrange Determines if the value of a variable is within 2-1370...
  • Page 52 1 Instruction Set 1-22 NY-series Instructions Reference Manual (W560)
  • Page 53: Instruction Descriptions

    Instruction Descriptions This section describes the specifications of the instructions that you can use with NY- series Controllers. Using this Section ..........2-3 Ladder Diagram Instructions .
  • Page 54 2 Instruction Descriptions EtherNet/IP Communications Instructions ......2-989 Serial Communications Instructions ......2-1155 SD Memory Card Instructions .
  • Page 55: Using This Section

    2 Instruction Descriptions Using this Section The notation used to describe instructions in this section is explained below. Items The following items are provided. Item Description Instruction The instruction word is given. Example: MoveBit Name The name of the instruction is given. Example: Move Bit FB/FUN Whether the instruction is a function block (FB) instruction or a function (FUN) instruction is given.
  • Page 56 2 Instruction Descriptions Item Description Variables • Name The input variables, output variables, and in-out variables are given. Example: In1 However, variables that are used by many instructions are not given on the pages that describe individual instructions. The following eight variables are commonly used. The specifications of these variables are given later.
  • Page 57 2 Instruction Descriptions EN is an input variable that gives the execution condition for a FUN instruction. When you use a FUN instruction in a ladder diagram, connect the execution condition to EN. Name Meaning Description Data type Valid range Default Enable (Execu- Input...
  • Page 58 2 Instruction Descriptions Done is an output variable that shows the completion of execution for some FB instructions. Busy is an output variable that shows that instruction execution is in progress for some FB instructions. Initial Name Meaning Description Data type Valid range value Execute...
  • Page 59 2 Instruction Descriptions  Instructions Processed over More Than One Task Period Task Task Task Task Task Task Task Task period period period period period period period period TRUE Execute FALSE Instruction Instruction Instruction Instruction Instruction Instruction Instruction Instruction executed. executed.
  • Page 60 2 Instruction Descriptions Timing charts are provided below for Execute, Done, Busy, Error, ErrorID, and ErrorIDEx.  Normal End TRUE Execute FALSE One task period TRUE Busy FALSE TRUE Done FALSE TRUE Error FALSE ErrorID ErrorIDEx Execution starts when Execute Execute is FALSE at the end of changes to TRUE.
  • Page 61 2 Instruction Descriptions  Error End TRUE Execute FALSE TRUE Busy FALSE One task period TRUE Done FALSE TRUE Error FALSE ErrorID ErrorIDEx Execute is FALSE at the end of Execution starts when Execute execution, so Error is TRUE for one task changes to TRUE.
  • Page 62 2 Instruction Descriptions Classifica- Data Valid range Default tion type USINT USINT#0 to +255 USINT#0 UINT UINT#0 to +65535 UINT#0 UDINT UDINT#0 to +4294967295 UDINT#0 ULINT ULINT#0 to +18446744073709551615 ULINT#0 Integers SINT SINT#−128 to +127 SINT#0 INT#−32768 to +32767 INT#0 DINT DINT#−2147483648 to +2147483647 DINT#0...
  • Page 63 2 Instruction Descriptions Derivative Data Types (Enumerations, Structures, and Unions) Variables that use derivative data types (enumerations, structures, and unions) are specified as such in the tables of variable data types. The notation is described below. Enumerations The data type for an enumerated variable is given within the table. The following is an example. Here, the data type of the Out variable is enumerated type _eDAYOFWEEK.
  • Page 64 2 Instruction Descriptions Array Specifications Array variable names are followed by “[]” and “(array)” is specified. For these variables, specify an ele- ment of the array (i.e., specify the subscript) as the parameter. An example is shown below. Here, the table shows that In1[] is a BYTE array. Times, durations, Bit strings Integers...
  • Page 65 2 Instruction Descriptions Others Errors Detected for All Instructions The errors that can occur for an instruction are given in the Precautions for Correct Use section. The fol- lowing three errors, however, can be detected for any instruction. They are not listed in the Precautions for Correct Use sections.
  • Page 66 2 Instruction Descriptions 2-14 NY-series Instructions Reference Manual (W560)
  • Page 67: Ladder Diagram Instructions

    Ladder Diagram Instructions Instruction Name Page LD and LDN Load/ 2-16 Load NOT AND and ANDN AND/ 2-18 AND NOT OR and ORN 2-20 OR NOT Out and OutNot Output/ 2-22 Output NOT NY-series Instructions Reference Manual (W560) 2-15...
  • Page 68: Ld And Ldn

    2 Instruction Descriptions LD and LDN Reads the value of a BOOL variable. LDN: Reads the inverse of the value of a BOOL variable. Instruction Name FB/FUN Graphic expression ST expression Load None Variable Variable Variable Upward Downward differentiation differentiation Load NOT None Variable...
  • Page 69 2 Instruction Descriptions If you specify upward or downward differentiation, the operation depends on the following: the value of the variable the last time the instruction was executed and the current value of the variable. This is shown below. Differentiation specifi- Value of variable at last execution and current Instruction Output value...
  • Page 70: And And Andn

    2 Instruction Descriptions AND and ANDN AND: Takes the logical AND of the value of a BOOL variable and the execution condition. ANDN: Takes the logical AND of the inverse of the value of a BOOL variable and the execution condition.
  • Page 71 2 Instruction Descriptions The operation is as shown below if you do not specify upward or downward differentiation. Combination of variable value and execution Output Instruction condition value Variable value: TRUE TRUE Execution condition: TRUE Other than the above. FALSE Variable value: FALSE TRUE ANDN...
  • Page 72: Or And Orn

    2 Instruction Descriptions OR and ORN Takes the logical OR of the value of a BOOL variable and the execution condition. ORN: Takes the logical OR of the inverse of the value of a BOOL variable and the execution condi- tion.
  • Page 73 2 Instruction Descriptions It takes the logical OR of variable A and variable B and outputs the result to variable C. The operation is as shown below if you do not specify upward or downward differentiation. Combination of variable value and execution Output Instruction condition...
  • Page 74: Out And Outnot

    2 Instruction Descriptions Out and OutNot Out: Takes the logical result from the previous instruction and outputs it to a BOOL variable. OutNot: Takes the inverse of the logical result from the previous instruction and outputs it to a BOOL variable. Instruction Name FB/FUN...
  • Page 75: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  OutNot The OutNot instruction takes the inverse of the logical result from the previous instruction and outputs it to a specified BOOL variable. Logic processing result from Output previous instruction TRUE FALSE FALSE TRUE The following figure shows a programming example and timing chart. TRUE FALSE TRUE...
  • Page 76: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • In the following case, an error occurs and nothing is output. • You specify an array element for the variable value and the element does not exist. Example: A BOOL array a[0..5] is defined, but the instruction is executed using a[10] as the vari- able.
  • Page 77: St Statement Instructions

    ST Statement Instructions Instruction Name Page 2-26 CASE Case 2-30 WHILE While 2-34 REPEAT Repeat 2-36 EXIT Break Loop 2-38 RETURN Return 2-41 Repeat Start 2-42 NY-series Instructions Reference Manual (W560) 2-25...
  • Page 78: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The IF construct uses the evaluation result of a specified condition expression to select one of two statements to execute. Instruction Name FB/FUN Graphic expression ST expression None IF condition expression THEN statement; ELSIF condition expression THEN statement;...
  • Page 79: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Operator Meaning Example Evaluation result Logical OR a OR b The result is the logical OR of BOOL variables a and b. Exclusive OR a XOR b The result is the logical exclusive OR of BOOL variables a and NOT a The result is the NOT of BOOL variable a.
  • Page 80: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions You can use ELSIF more than once. The following processing flow is for this example. IF condition expression 1 THEN statement 1; ELSIF condition expression 2 THEN statement 2; ELSIF condition expression 3 THEN statement 3; ELSE statement 4;...
  • Page 81: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming This example assigns INT#0 to variable def if the value of variable abc is less than INT#0. It assigns INT#1 to variable def and INT#2 to variable ghi if the value of variable abc is INT#0. It assigns INT#3 to variable def if the value of variable abc is none of the above.
  • Page 82: Case

    2 Instruction Descriptions CASE You use the CASE construct to select the statement to execute based on the value of a specified inte- ger expression. Instruction Name FB/FUN Graphic expression ST expression CASE Case None CASE integer expression value: statement; value: statement;...
  • Page 83: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions TRUE Equal to value 1? FALSE TRUE Equal to value 2? FALSE Equal to TRUE value n? FALSE Statement m Statement n Statement 2 Statement 1 Additional Information • You can use the CASE construct to build a hierarchy. The following example executes statement 12 if the value of integer expression 1 is 1 and the value of integer expression 11 is 2.
  • Page 84: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • You can use a range of consecutive values. Place two periods between the numbers to indicate con- secutive values. The following example executes statement 1 if the value of the integer expression is between 10 and 15, inclusive. CASE integer expression 1 OF 10..15: statement 1;...
  • Page 85: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming This example assigns INT#10 to variable def if the value of variable abc is INT#1, INT#20 if the value of variable abc is INT#2, and INT#30 if the value of variable abc is INT#3. Otherwise, it assigns the value of variable ghi to variable def.
  • Page 86: While

    2 Instruction Descriptions WHILE The WHILE construct repeatedly executes a statement as long as the evaluation result of a specified condition expression is TRUE. Instruction Name FB/FUN Graphic expression ST expression WHILE While None WHILE condition expression statement; END_WHILE; Variables None Function The WHILE construct repeatedly executes a statement as long as the evaluation result of a specified...
  • Page 87: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following processing flow is for this example. You can use more than one statement. WHILE condition expression DO statement; END_WHILE; FALSE Condition expression TRUE Statement Additional Information • The statement is not executed even once if the condition expression is FALSE the first time it is eval- uated.
  • Page 88: Repeat

    2 Instruction Descriptions REPEAT The REPEAT construct executes a statement once and then executes it repeatedly until a specified condition expression is TRUE. Instruction Name FB/FUN Graphic expression ST expression REPEAT Repeat None REPEAT statement; UNTIL condition expression END_REPEAT; Variables None Function The REPEAT construct executes a statement once and then executes it repeatedly until a specified...
  • Page 89: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following processing flow is for this example. You can use more than one statement. REPEAT statement; UNTIL condition expression END_REPEAT; Statement TRUE Condition expression FALSE Additional Information • The statement is executed once before the condition expression is evaluated. Therefore, the state- ment is always executed at least once.
  • Page 90: Exit

    2 Instruction Descriptions EXIT The EXIT instruction is used to end repeat processing from the lowest level FOR, WHILE, or REPEAT instruction. Instruction Name FB/FUN Graphic expression ST expression EXIT Break Loop None FOR Index:=0 TO 9 BY 1 IF Error[Index] THEN EXIT;...
  • Page 91: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The flowchart for this programming is given below. START position : = INT#0 FALSE INT#0 ≤ position ≤ INT#10 TRUE TRUE If the value of variable A is A = TRUE TRUE, the EXIT instruction is executed and the repeat FALSE processing is ended.
  • Page 92: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The flowchart for this programming is given below. START x := INT#0 y := INT#0 FALSE Repeat processing x ≤ INT#10 for WHILE instruction 1 If the value of variable A is TRUE TRUE, the repeat processing for WHILE instruction 1 is TRUE A = TRUE...
  • Page 93: Return

    2 Instruction Descriptions RETURN Refer to RETURN on page 2-67 in the Sequence Control Instructions for a description of this instruc- tion. NY-series Instructions Reference Manual (W560) 2-41...
  • Page 94: For

    2 Instruction Descriptions Refer to FOR and NEXT on page 2-82 in the Sequence Control Instructions for a description of this instruction. 2-42 NY-series Instructions Reference Manual (W560)
  • Page 95: Sequence Input Instructions

    Sequence Input Instructions Instruction Name Page R_TRIG (Up) and F_TRIG (Down) Up Trigger/ 2-44 Down Trigger TestABit and TestABitN Test A Bit/ 2-47 Test A Bit NOT NY-series Instructions Reference Manual (W560) 2-43...
  • Page 96: R_Trig (Up) And F_Trig (Down)

    2 Instruction Descriptions R_TRIG (Up) and F_TRIG (Down) R_TRIG (Up): Outputs TRUE for one task period only when the input signal changes to TRUE. F_TRIG (Down): Outputs TRUE for one task period only when the input signal changes to FALSE. Instruction Name FB/FUN...
  • Page 97: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a programming example and timing chart. R_TRIG_instance(A, abc); R_TRIG_instance R_TRIG TRUE Clk, In FALSE TRUE Q, Out=abc FALSE Task period  F_TRIG F_TRIG assigns TRUE to output signal Q for one task period only when input signal Clk changes to FALSE.
  • Page 98: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Detection of upward or downward differentiation depends on differences between the current value of Clk or In and the value the last time the instruction was executed. Caution is required when using the JMP instruction or other times that the instruction is not executed every task period.
  • Page 99: Testabit And Testabitn

    2 Instruction Descriptions TestABit and TestABitN TestABit: Outputs the value of the specified bit in a bit string. TestABitN: Outputs the inverse of the value of the specified bit in a bit string. Instruction Name FB/FUN Graphic expression ST expression TestABit Test A Bit Out:=TestABit (In, Pos);...
  • Page 100: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function  TestABit The TestABit instruction assigns the value of the bit at bit position Pos in the bit string In to the bit value Out when EN is TRUE. When EN is FALSE, the value of Out is FALSE. ...
  • Page 101: Sequence Output Instructions

    Sequence Output Instructions Instruction Name Page Reset-Priority Keep 2-50 Set-Priority Keep 2-53 Set and Reset Set/Reset 2-56 SetBits and ResetBits Set Bits/Reset Bits 2-59 SetABit and ResetABit Set A Bit/Reset A Bit 2-61 OutABit Output A Bit 2-63 NY-series Instructions Reference Manual (W560) 2-49...
  • Page 102: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The RS instruction retains the value of a BOOL variable. It gives priority to the Reset input if both the Set input and Reset input are TRUE. Instruction Name FB/FUN Graphic expression ST expression Reset-Priority Keep RS_instance(Set, Reset1, RS_instance Q1);...
  • Page 103: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a programming example and timing chart. RS_instance(A, B, abc); RS_instance Reset1 TRUE Set=A FALSE TRUE Reset1=B FALSE TRUE Q1=abc FALSE Additional Information • The RS instruction behaves like the following self-holding rung. • However, if the RS instruction is in a master control region and the master control region is reset, the behavior will not be the same as the above self-holding rung.
  • Page 104: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • Even if you connect a parameter with a Retain attribute to Q1, the value will not be retained when the power is interrupted. After the power supply is restored, the value of Q1 will be FALSE when the oper- ating mode is changed to RUN mode and the instruction is executed.
  • Page 105: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The SR instruction retains the value of a BOOL variable. It gives priority to the Set input if both the Set input and Reset input are TRUE. Instruction Name FB/FUN Graphic expression ST expression Set-Priority Keep SR_instance(Set1, Reset, SR_instance Q1);...
  • Page 106: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a programming example and timing chart. SR_instance(A, B, abc); SR_instance Set1 Reset TRUE Set1=A FALSE TRUE Reset=B FALSE TRUE Q1=abc FALSE Additional Information • The SR instruction behaves like the following self-holding rung. •...
  • Page 107: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • Even if you connect a parameter with a Retain attribute to Q1, the value will not be retained when the power is interrupted. After the power supply is restored, the value of Q1 will be FALSE when the oper- ating mode is changed to RUN mode and the instruction is executed.
  • Page 108: Set And Reset

    2 Instruction Descriptions Set and Reset Set: Changes a BOOL variable to TRUE. Reset: Changes a BOOL variable to FALSE. Instruction Name FB/FUN Graphic expression ST expression None Upward Downward differentiation differentiation Reset Reset None Upward Downward differentiation differentiation Variables Name Meaning Description...
  • Page 109: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions If you specify upward or downward differentiation, the operation depends on the following: the value of the input for the last execution and the current value of the input. This is shown below. Differentiation speci- Instruction Value of input at last execution and current value Output value fication FALSE at the last execution →...
  • Page 110: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information Differences between the Set and Reset Instructions and the Out Instruction • The Set and Reset instructions operate only when the input value changes to TRUE. They do not operate when the input value is FALSE. When the input value is FALSE, the output does not change. •...
  • Page 111: Setbits And Resetbits

    2 Instruction Descriptions SetBits and ResetBits SetBits: Changes consecutive bits in bit string data to TRUE. ResetBits: Changes consecutive bits in bit string data to FALSE. Instruction Name FB/FUN Graphic expression ST expression SetBits Set Bits SetBits(InOut, Pos, Size); (@)SetBits InOut Size ResetBits...
  • Page 112: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  ResetBits The ResetBits instruction changes the value of Size bits from the bit position Pos in the bit string InOut to FALSE. The status of the other bits will not change. The following example shows the SetBits instruction when Pos is USINT#3 and Size is USINT#2. SetBits(abc, USINT#3, USINT#2);...
  • Page 113: Setabit And Resetabit

    2 Instruction Descriptions SetABit and ResetABit SetABit: Changes the specified bit in bit string data to TRUE. ResetABit: Changes the specified bit in bit string data to FALSE. Instruction Name FB/FUN Graphic expression ST expression SetABit Set A Bit SetABit (InOut, Pos); (@)SetABit InOut ResetABit...
  • Page 114: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  ResetABit The ResetABit instruction changes the value of the bit at bit position Pos in the bit string InOut to FALSE. The bits that are not specified do not change. Even if EN changes to FALSE after execution, the Pos bit in InOut will not change. The following example shows the SetABit instruction when Pos is USINT#3.
  • Page 115: Outabit

    2 Instruction Descriptions OutABit The OutABit instruction changes the specified bit in bit string data to TRUE or FALSE. Instruction Name FB/FUN Graphic expression ST expression OutABit Output A Bit OutABit (InOut, Pos, BitVal); (@)OutABit InOut BitVal Variables Name Meaning Description Valid range Unit...
  • Page 116: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The OutABit instruction stores the value of set value BitVal at bit position Pos in the bit string InOut. Only the bit at Pos changes. The following example is for when Pos is USINT#2 and BitVal is TRUE. OutABit(abc, USINT#2, TRUE);...
  • Page 117: Sequence Control Instructions

    Sequence Control Instructions Instruction Name Page 2-66 RETURN Return 2-67 MC and MCR Master Control Start/ 2-68 Master Control End Jump 2-80 FOR and NEXT Repeat Start/ 2-82 Repeat End BREAK Break Loop 2-89 NY-series Instructions Reference Manual (W560) 2-65...
  • Page 118: End

    2 Instruction Descriptions The End instruction ends execution of a program in the current task period. Instruction Name FB/FUN Graphic expression ST expression None Variables None Function The End instruction ends execution of a program in the current task period. The following figure shows a programming example.
  • Page 119: Return

    2 Instruction Descriptions RETURN The RETURN instruction ends a function or function block and returns processing to the calling instruc- tion. Instruction Name FB/FUN Graphic expression ST expression RETURN Return RETURN; RETURN Variables None Function The RETURN instruction ends a function or function block and returns processing to the calling instruc- tion.
  • Page 120: Mc And Mcr

    2 Instruction Descriptions MC and MCR Marks the starting point of a master control region and resets the master control region. MCR: Marks the end point of a master control region. Instruction Name FB/FUN Graphic expression ST expression Master Control None Start MCNo...
  • Page 121: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The value that is output from the LD instruction changes to FALSE regardless of the value of variable A. MCNo Master control region MCNo If the value of In is TRUE, then master control is not reset. The POUs in the master control region oper- ate normally.
  • Page 122: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Operation FOR and NEXT instructions These instructions are not executed. BREAK instruction This instruction is not executed. Function blocks that are executed The power flow from the left bus bar changes to FALSE. If the instruction over more than one task period (i.e., was operating before the master control reset, execution of the instruction instructions with Done, Busy, and is continued until processing is completed.
  • Page 123: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Set and Reset The previous value of the output is retained while the master control is reset. Master control reset MC_ON TRUE MCNo MC_ON FALSE TRUE FALSE Output from TRUE LD instruction FALSE TRUE FALSE MCNo Master control reset TRUE MC_ON...
  • Page 124: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  CTU, CTD, and CTUD The previous counter value is retained while the master control is reset. When the master control reset is cleared, counting continues from the counter value that was retained. MC_ON Master control reset MCNo TRUE MC_ON...
  • Page 125: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  F_TRIG (Down) When the master control is reset, the execution condition changes to FALSE. If the previous execution condition was TRUE, then the input downward differentiation condition is met. However, the value of the output from the F_TRIG (Down) instruction during the master control reset is forced to change to FALSE, so the output value changes to FALSE.
  • Page 126: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Master control reset MC_ON TRUE MCNo MC_ON FALSE TRUE FALSE TRUE Output from FALSE LD instruction TRUE FALSE MCNo Master control reset TRUE MC_ON FALSE TRUE FALSE TRUE Output from FALSE LD instruction TRUE FALSE Here, the input upward differentiation condition is met and the output value changes to FALSE.
  • Page 127: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  CTU, CTD, and CTUD When the master control is reset, the value of the counter input changes to FALSE. If the value of the counter input is TRUE when the master control reset is cleared, the input upward differentiation condition is met and the instruction counts.
  • Page 128 2 Instruction Descriptions MCNo Reset. TON_instance T#10ms position InitVal Index UINT#0 UINT#10 EndVal These are not executed. StepVal UINT#1 MOVE INT#0 array[position] NEXT FALSE is output. MCNo Precautions for Correct Use • These instructions must be used in a ladder diagram. They cannot be used in ST. They also cannot be used in inline ST in a ladder diagram.
  • Page 129: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If you use the MC and MCR instructions and the JMP instruction together, the operation is as follows: • The following figure shows an MC-MCR pair inside a JMP-Label pair. Here, the jump is executed regardless of the value of In. Flow of processing JMP instruction executed.
  • Page 130: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • The instructions are in the following order in the following figure: JMP instruction, MC instruction, Label, and MCR instruction. First, the jump is made. As a result, the MC instruction is not exe- cuted. Therefore, the instructions after the Label instruction are executed. If the value of In is FALSE, the MCR instruction is executed, but nothing changes.
  • Page 131: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If you use the MC and MCR instructions and the FOR and NEXT instructions together, the operation is as follows: • The following figure shows an MC-MCR pair inside a FOR-NEXT pair. Here, operation is as given in the following table.
  • Page 132: Jmp

    2 Instruction Descriptions The JMP instruction moves processing to the specified jump destination. Instruction Name FB/FUN Graphic expression ST expression Jump None Label Variables None Function When the execution condition is TRUE, the JMP instruction moves processing to the jump destination specified by a Label in a ladder diagram.
  • Page 133: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • The following restrictions apply to the characters that can be used as labels. Item Specification Maximum number of bytes 127 bytes 127 characters when converted to ACSII 31 characters when converted to Japanese characters (including single-byte kana) Character code UTF-8...
  • Page 134: For And Next

    2 Instruction Descriptions FOR and NEXT FOR: Marks the starting position for repeat processing and specifies the repeat condition. NEXT: Marks the ending position for repeat processing. Instruction Name FB/FUN Graphic expression ST expression Repeat Start FOR Index:=InitVal TO End- Val BY StepVal DO expression InitVal...
  • Page 135 2 Instruction Descriptions Function The FOR and NEXT instructions repeat the processing that you place between them. (FOR and END_- FOR are used in ST.) The processing procedure for a FOR-NEXT loop is as follows: The value of InitVal is set in control variable Index. The values of StepVal, Index, and EndVal are checked to see if the conditions in the following table are met.
  • Page 136 2 Instruction Descriptions START INT#0→ InitVal INT#9→ EndVal INT#1→ StepVal InitVal → Index StepVal ≥ 0 and INT#0 is assigned in order FALSE to AryOut[0] to AryOut[9]. Index < EndVal* AryOut[0] INT#0 AryOut[1] INT#0 INT#0 AryOut[2] INT#0 TRUE AryOut[3] INT#0 AryOut[4] INT#0 AryOut[5]...
  • Page 137 2 Instruction Descriptions Additional Information • Execute a BREAK instruction (or an EXIT instruction in ST) to cancel repeat processing. The pro- cessing between the BREAK instruction and the NEXT instruction will not be executed. • FOR-NEXT loops (or FOR-END_FOR loops in ST) can be nested. In the following figure, the pro- cesses are performed in the following order.
  • Page 138 2 Instruction Descriptions • The following table describes operation according to the values of StepVal, InitVal, and EndVal. Programming lan- Values of InitVal Value of StepVal Operation guage and EndVal StepVal > 0 InitVal < EndVal Ladder diagram Operation is normal. InitVal ≥...
  • Page 139 2 Instruction Descriptions • The value of Index after repeat processing is different in a ladder diagram and ST. In a ladder dia- gram, the value of StepVal is not added to Index at the end of repeat processing. In ST, the value of StepVal is added to Index at the end of repeat processing.
  • Page 140 2 Instruction Descriptions The values of x[i] at the previous execution and the current execution of R_TRIG_instance[i] are compared to InitVal Index DINT#0 determine upward differentiation. EndVal DINT#10 DINT#1 StepVal R_TRIG_instance[i] x[i] R_TRIG R_TRIG_instance[i].Q InOut Count2[i] NEXT 2-88 NY-series Instructions Reference Manual (W560)
  • Page 141: Break

    2 Instruction Descriptions BREAK The BREAK instruction is used to cancel repeat processing from the lowest level FOR instruction to the NEXT instruction. Instruction Name FB/FUN Graphic expression ST expression BREAK Break Loop None BREAK Variables None Function The BREAK instruction cancels the repeat processing from the lowest level FOR instruction to the NEXT instruction.
  • Page 142 2 Instruction Descriptions START INT#0→ InitVal INT#10→ EndVal INT#1→ StepVal FALSE StepVal > 0 and InitVal < EndVal TRUE InitVal → Index FALSE Index ≤ EndVal TRUE If the value of A is TRUE TRUE, the repeat processing is ended FALSE immediately.
  • Page 143: Comparison Instructions

    Comparison Instructions Instruction Name Page EQ (=) Equal 2-92 NE (<>) Not Equal 2-94 LT (<), LE (<=), GT (>), and GE (>=) Less Than/Less Than Or Equal/ 2-97 Greater Than/Greater Than Or Equal EQascii Text String Comparison Equal 2-100 NEascii Text String Comparison Not Equal 2-102...
  • Page 144: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions EQ (=) The EQ (=) instruction determines if the contents of two or more variables are all equivalent. Instruction Name FB/FUN Graphic expression ST expression EQ (=) Equal Out:=(In1=In2) & (In2=In3) (@)EQ & ··· & (InN-1=InN); (@)= Variables Name Meaning...
  • Page 145: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In1 is INT#3, In2 is INT#5 and In3 is INT#10. The value of variable abc will be FALSE. abc:=(INT#3=INT#5)&(INT#5=INT#10); INT#3 INT#5 INT#10 The EQ instruction determines if In1 to In3 are all equivalent. If they are different, the value of abc will be FALSE.
  • Page 146: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions NE (<>) The NE (<>) instruction determines if the contents of two variables are not equivalent. Instruction Name FB/FUN Graphic expression ST expression NE (<>) Not Equal Out:=(In1<>In2); (@)NE (@)<> Variables Name Meaning Description Valid range Unit Default In1 and In2 Comparison...
  • Page 147: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The NE (<>) instruction determines if the contents of two variables In1 and In2 are not equivalent. If they are not equivalent, the comparison result Out is TRUE. If they are equivalent, Out is FALSE. When comparing STRING data, “equivalent” means that both the lengths and contents of the text strings are the same.
  • Page 148: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If In1 and In2 are real numbers, the desired results may not be achieved due to rounding error. Do not use this instruction to check if two values are different when one or both of them is a real number. Use a value comparison instruction and check to see if the difference in the absolute values is greater than the allowable range.
  • Page 149: Lt (<), Le (<=), Gt (>), And Ge (>=)

    2 Instruction Descriptions LT (<), LE (<=), GT (>), and GE (>=) These instructions compare the sizes of two or more values. LT (<): Performs a less than comparison. LE (<=): Performs a less than or equal comparison. GT (>): Performs a greater than comparison.
  • Page 150: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variables Name Meaning Description Valid range Unit Default In1 to InN Comparison Input Values to compare, N = 2 to Depends on data type. data Comparison Output Comparison result Depends on data type. result * If you omit the input parameter that connects to InN, the default value is not applied, and a building error will occur. For example, if N is 3 and the input parameters that connect to In1 and In2 are omitted, the default values are applied, but if the input parameter that connects to In3 is omitted, a building error will occur.
  • Page 151: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example shows the LE instruction when In1 is INT#3, In2 is INT#5 and In3 is INT#10. The value of variable abc will be TRUE. abc:=(INT#3<= INT#5)&(INT#5<=INT#10); INT#3 INT#5 INT#10 The LE instruction determines if In1 ≤ In2 ≤ In3. If the comparison conditions are met, the value of abc will be TRUE.
  • Page 152: Eqascii

    2 Instruction Descriptions EQascii The EQascii instruction determines if two or more text strings are all equivalent. Instruction Name FB/FUN Graphic expression ST expression EQascii Text String Com- Out:=EQascii(In1, ··, (@)EQascii parison Equal InN); Variables Name Meaning Description Valid range Unit Default In1 to InN...
  • Page 153: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The EQascii instruction determines if In1 to In3 are all equivalent. If they are different, the value of abc will be FALSE. Compared to see if they are equivalent. Different. Out=abc FALSE 'AB' 'ABC' Additional Information The text string comparison instructions are convenient when you want to reorder text strings according to the character codes.
  • Page 154: Neascii

    2 Instruction Descriptions NEascii The NEascii instruction determines if two text strings are not equivalent. Instruction Name FB/FUN Graphic expression ST expression NEascii Text String Com- Out:=NEascii(In1, In2); (@)NEascii parison Not Equal Variables Name Meaning Description Valid range Unit Default In1 and In2 Comparison Input...
  • Page 155: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The NEascii instruction determines if In1 and In2 are different. If they are different, the value of abc will be TRUE. Compared to see if they are different. Different Out=abc TRUE 'AB' Additional Information The text string comparison instructions are convenient when you want to reorder text strings according to the character codes.
  • Page 156: Ltascii, Leascii, Gtascii, And Geascii

    2 Instruction Descriptions LTascii, LEascii, GTascii, and GEascii These instructions compare the sizes of two or more text strings. LTascii: Performs a less than comparison. LEascii: Performs a less than or equal comparison. GTascii: Performs a greater than comparison. GEascii: Performs a greater than or equal comparison.
  • Page 157: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings In1 to InN Function These instructions compare the sizes of from two to five text strings in In1 to InN (N = 2 to 5). The out- put value Out is shown below for each instruction. Instruction Value of Out LTascii...
  • Page 158: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The LEascii instruction determines if In1 ≤ In2 ≤ In3. If the comparison conditions are met, the value of abc will be TRUE. Values are compared to see if In1 ≤ In2 ≤ In3. Comparison conditions met. Out=abc TRUE 'AB'...
  • Page 159: Cmp

    2 Instruction Descriptions The Cmp instruction compares two values. Instruction Name FB/FUN Graphic expression ST expression Compare Out:=Cmp(In1, In2, OutEQ, (@)Cmp OutGT, OutGE, OutNE, OutLT, OutLE); OutEQ You can omit Out. OutGT OutGE OutNE OutLT OutLE Variables Name Meaning Description Valid range Unit Default...
  • Page 160: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The Cmp instruction compares two values (In1 and In2) and outputs flag values. The values of the flags are as follows: Flag Value OutEQ If In1 equals In2, the flag shows TRUE. Otherwise the flag shows FALSE. OutGT If In1 is greater than In2, the flag shows TRUE.
  • Page 161: Zonecmp

    2 Instruction Descriptions ZoneCmp The ZoneCmp instruction determines if the comparison data is within the specified maximum and mini- mum values. Instruction Name FB/FUN Graphic expression ST expression ZoneCmp Zone Comparison Out:=ZoneCmp(MN, In, (@)ZoneCmp MX); Variables Name Meaning Description Valid range Unit Default Minimum value...
  • Page 162: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The ZoneCmp instruction determines if comparison data In is between maximum value MX and mini- mum value MN. If MX ≥ In ≥ MN, Out will be TRUE. Otherwise, Out will be FALSE. The relationship between values with data types that are not integers or real numbers are determined as given in the following table.
  • Page 163: Tablecmp

    2 Instruction Descriptions TableCmp The TableCmp instruction compares the comparison data with multiple defined ranges in a comparison table. Instruction Name FB/FUN Graphic expression ST expression TableCmp Table Comparison Out:=TableCmp(In, Table, (@)TableCmp Size, AryOut); Table Size AryOut Variables Name Meaning Description Valid range Unit...
  • Page 164: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings OK OK OK OK OK OK OK OK OK OK Table[] (two- dimen- Must be a two-dimensional array with elements that have the same data type as In. sional array) Size...
  • Page 165: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is INT#120 and Size is UINT#3. ghi:=TableCmp(INT#120, abc[1,2], UINT#3, def[3]); TableCmp INT#120 abc[1,2] Table UINT#3 Size AryOut def[3] def[3] In=INT#120 FALSE Table[0,0]=abc[1,2] Table[0,1]=abc[1,3] AryOut[0]=def[3] TRUE Table[1,0]=abc[2,2] Table[1,1]=abc[2,3] AryOut[1]=def[4] Size=UINT#3 Table[2,0]=abc[3,2] FALSE AryOut[2]=def[5] Table[2,1]=abc[3,3]...
  • Page 166: Arycmpeq And Arycmpne

    2 Instruction Descriptions AryCmpEQ and AryCmpNE These instructions compare the values of the elements of two arrays. AryCmpEQ: Determines if the elements are equal. AryCmpNE: Determines if the elements are not equal. Instruction Name FB/FUN Graphic expression ST expression AryCmpEQ Array Comparison AryCmpEQ(In1, In2, Size, (@)AryCmpEQ...
  • Page 167: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function These instructions compare the values of the elements with the same element numbers in two arrays (In1[0] to In1[Size−1] and In2[0] and In2[Size−1]). The comparison results are stored in comparison results array AryOut[] in the elements with the corresponding element numbers (AryOut[0] to Ary- Out[Size −1]).
  • Page 168: Arycmplt, Arycmple, Arycmpgt, And Arycmpge

    2 Instruction Descriptions AryCmpLT, AryCmpLE, AryCmpGT, and AryCmpGE These instructions compare the values of the elements of two arrays. AryCmpLT: Performs a less than comparison. AryCmpLE: Performs a less than or equal comparison. AryCmpGT: Performs a greater than comparison. AryCmpGE: Performs a greater than or equal comparison.
  • Page 169: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variables Name Meaning Description Valid range Unit Default In1[] and Comparison Arrays containing the ele- Depends on data type. In2[] arrays ments to compare (arrays) Input Size Number of Number of elements to com- Depends on data type. comparison pare elements...
  • Page 170: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function These instructions compare the values of the elements with the same element numbers in two arrays (In1[0] to In1[Size −1] and In2[0] and In2[Size −1]). The comparison results are stored in comparison results array AryOut[] in the elements with the corresponding element numbers (AryOut[0] to Ary- Out[Size −1]).
  • Page 171: Arycmpeqv And Arycmpnev

    2 Instruction Descriptions AryCmpEQV and AryCmpNEV These instructions compare a value to the values of the elements of an array. AryCmpEQV: Determines if the elements are equal. AryCmpNEV: Determines if the elements are not equal. Instruction Name FB/FUN Graphic expression ST expression AryCmpEQV Array Value...
  • Page 172: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function These instructions compare comparison value In2 with the specified elements in an array (In1[0] to In1[Size −1]). The comparison results are stored in comparison results array AryOut[] in the elements with the corresponding element numbers (AryOut[0] to AryOut[Size −1]). The value of AryOut[i] is as follows for each instruction: Instruction Value of AryOut[i]...
  • Page 173: Arycmpltv, Arycmplev, Arycmpgtv, And Arycmpgev

    2 Instruction Descriptions AryCmpLTV, AryCmpLEV, AryCmpGTV, and AryCmpGEV These instructions compare a value to the values of the elements of an array. AryCmpLTV: Performs a less than comparison. AryCmpLEV: Performs a less than or equal comparison. AryCmpGTV: Performs a greater than comparison. AryCmpGEV: Performs a greater than or equal comparison.
  • Page 174: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variables Name Meaning Description Valid range Unit Default In1[] (array) Comparison Array containing the ele- array ments to compare Depends on data type. Comparison Value to compare value Input Size Number of Number of elements to com- Depends on data type.
  • Page 175: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function These instructions compare comparison value In2 with the specified elements in an array (In1[0] to In1[Size − 1]). The comparison results are stored in comparison results array AryOut[] in the elements with the corresponding element numbers (AryOut[0] to AryOut[Size −1]). The value of AryOut[i] is as follows for each instruction: Instruction Value of AryOut[i]...
  • Page 176: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-124 NY-series Instructions Reference Manual (W560)
  • Page 177: Timer Instructions

    Timer Instructions Instruction Name Page On-Delay Timer 2-126 Off-Delay Timer 2-132 Timer Pulse 2-135 AccumulationTimer Accumulation Timer 2-138 Timer Hundred-ms Timer 2-141 NY-series Instructions Reference Manual (W560) 2-125...
  • Page 178: Ton

    2 Instruction Descriptions The TON instruction outputs TRUE when the set time elapses after the timer starts. Instruction Name FB/FUN Graphic expression ST expression On-Delay Timer TON_instance (In, PT, Q, TON_instance ET); Variables Name Meaning Description Valid range Unit Default Timer input TRUE: Timer start signal Depends on data type.
  • Page 179: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a programming example and timing chart when PT is T#10ms. Variable abc will change to TRUE 10 ms after variable A changes to TRUE. TON_instance(A, T#10ms, abc, def); TON_instance T#10ms PT=T#10ms TRUE In=A FALSE TRUE Q=abc...
  • Page 180: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • The timing error for which Q is TRUE for PT is −100 ns to (100 ns + 1 task period). The above range includes the following: • The ±100 ns is the timing error of ET. •...
  • Page 181: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming  Measuring Time with One On-Delay Timer The value of TimeUp will change to TRUE 1 second after the value of Trigger changes to TRUE. Variable Data type Initial value Comment Trigger BOOL FALSE Execution condition TimeUp BOOL FALSE...
  • Page 182 2 Instruction Descriptions  Measuring Time with Multiple On-Delay Timers In this example, a total of 100 instances of the On-Delay Timer instruction, TON_instance[0] to TON_instance[99], are programmed. Each timer starts when the value of the corresponding timer input Input[0] to Input[99] changes to TRUE. The timers for the first 10 instances, TON_instance[0] to TON_instance[9], change the correspond- ing values in TimeUp[i] to TRUE i+1 seconds (i = 0 to 9) after execution is started.
  • Page 183 2 Instruction Descriptions Variable Data type Initial value Comment Input ARRAY[0..99] OF BOOL [100(FALSE)] Timer input TimeUp ARRAY[0..99] OF BOOL [100(FALSE)] Timer output [T#1s, T#2s, T#3s, T#4s, T#5s, T#6s, TimePT ARRAY[0..99] OF TIME Set time T#7s, T#8s, T#9s, T#10s, 90(T#0s)] TON_instance ARRAY[0..99] OF TON UINT...
  • Page 184: Tof

    2 Instruction Descriptions The TOF instruction outputs FALSE when the set time elapses after the timer starts. Instruction Name FB/FUN Graphic expression ST expression Off-Delay Timer TOF_instance (In, PT, Q, TOF_instance ET); Variables Name Meaning Description Valid range Unit Default Timer input TRUE: Timer reset signal Depends on data type.
  • Page 185: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a programming example and timing chart for a PT of T#10ms. Variable abc will change to FALSE 10 ms after variable A changes to FALSE. TOF_instance(A, T#10ms, abc, def); TOF_instance T#10ms PT=T#10ms TRUE In=A FALSE TRUE...
  • Page 186: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • The timing error for which Q is TRUE for PT is −100 ns to (100 ns + 1 task period). The above range includes the following: • The ±100 ns is the timing error of ET. •...
  • Page 187: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The TP instruction outputs TRUE while the set time elapses after the timer starts. Instruction Name FB/FUN Graphic expression ST expression Timer Pulse TP_instance (In, PT, Q, TP_instance ET); Variables Name Meaning Description Valid range Unit Default Timer input TRUE: Timer start signal Depends on data type.
  • Page 188: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a programming example and timing chart for a PT of T#10ms. Variable abc changes to TRUE as soon as variable A changes to TRUE. Variable abc changes to FALSE 10 ms later. TP_instance(A, T#10ms, abc, def); TP_instance T#10ms PT=T#10ms...
  • Page 189: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • The timing error for which Q is TRUE for PT is −100 ns to (100 ns + 1 task period). The above range includes the following: • The ±100 ns is the timing error of ET. •...
  • Page 190: Accumulationtimer

    2 Instruction Descriptions AccumulationTimer The AccumulationTimer instruction totals the time that the timer input is TRUE. Instruction Name FB/FUN Graphic expression ST expression AccumulationTimer Accumulation Timer FB AccumulationTimer_in- AccumulationTimer_instance stance(In, PT, Reset, Q, AccumulationTimer ET); Reset Variables Name Meaning Description Valid range Unit Default...
  • Page 191: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a programming example and timing chart for a PT of T#10ms. Variable abc changes to TRUE when variable A is TRUE for a total of 10 ms (i.e., the total time). AccumulationTimer_instance(A, T#10ms, abc, def, ghi); AccumulationTimer_instance AccumulationTimer T#10ms...
  • Page 192: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • The timing error for which Q is TRUE for PT is −100 ns to (100 ns + 1 task period). The above range includes the following: • The ±100 ns is the timing error of ET. •...
  • Page 193: Timer

    2 Instruction Descriptions Timer The Timer instruction outputs TRUE when the set time elapses after the timer starts. The time is set in increments of 100 ms. Instruction Name FB/FUN Graphic expression ST expression Timer Hundred-ms Timer Out:=Timer (In, PT, Tim- Timer erDat, Q, ET);...
  • Page 194: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The Timer instruction outputs TRUE when the set time elapses after the timer starts. The time is set in increments of 100 ms. The timer is reset when timer input In changes to FALSE. Remaining time ET is set to set time PT, and timer output Q changes to FALSE.
  • Page 195: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If this instruction is not executed due to the execution of a jump instruction (e.g., the JMP instruction), the value of ET is not updated. However, timing still continues. Therefore, ET is updated to the correct value the next time the instruction is executed.
  • Page 196: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-144 NY-series Instructions Reference Manual (W560)
  • Page 197: Counter Instructions

    Counter Instructions Instruction Name Page Down-counter 2-146 CTD_** Down-counter Group 2-148 Up-counter 2-150 CTU_** Up-counter Group 2-152 CTUD Up-down Counter 2-155 CTUD_** Up-down Counter Group 2-159 NY-series Instructions Reference Manual (W560) 2-145...
  • Page 198: Ctd

    2 Instruction Descriptions The CTD instruction decrements the counter value when the counter input signal is received. The pre- set value and counter value must have an INT data type. Instruction Name FB/FUN Graphic expression ST expression Down-counter CTD_instance (CD, Load, CTD_instance PV, Q, CV);...
  • Page 199: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions CD is ignored while Load is TRUE. CV is not decremented. The following figure shows a programming example and timing chart for a PV of INT#5. CTD_instance(A, abc, INT#5, def, ghi); CTD_instance Load INT#5 TRUE CD=A FALSE TRUE Load=abc FALSE...
  • Page 200: Ctd_**

    2 Instruction Descriptions CTD_** The CTD_** instruction decrements the counter value when the counter input signal is received. The preset value and counter value must be one of the following data types: DINT, LINT, UDINT, or ULINT. Instruction Name FB/FUN Graphic expression ST expression CTD_**...
  • Page 201: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions When load signal Load changes to TRUE, counter value CV is set to the value of preset value PV and counter output Q changes to FALSE. When counter input signal CD changes to TRUE, CV is decre- mented.
  • Page 202: Ctu

    2 Instruction Descriptions The CTU instruction increments the counter value when the counter input signal is received. The preset value and counter value must have an INT data type. Instruction Name FB/FUN Graphic expression ST expression Up-counter CTU_instance (CU, Reset, CTU_instance PV, Q, CV);...
  • Page 203: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions After the value of CV reaches the value of PV or higher, the value of CV does not change even if the value of CU changes to TRUE. CU is ignored while Reset is TRUE. CV is not incremented. The following figure shows a programming example and timing chart for a PV of INT#5.
  • Page 204: Ctu_**

    2 Instruction Descriptions CTU_** The CTU_** instruction increments the counter value when the counter input signal is received. The preset value and counter value must be one of the following data types: DINT, LINT, UDINT, or ULINT. Instruction Name FB/FUN Graphic expression ST expression CTU_**...
  • Page 205: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions When reset signal Reset changes to TRUE, counter value CV changes to 0 and counter output Q changes to FALSE. When counter input signal CU changes to TRUE, CV is incremented. When the value of CV reaches the value of PV or higher, the value of Q changes to TRUE. After the value of CV reaches the value of PV or higher, the value of CV does not change even if the value of CU changes to TRUE.
  • Page 206: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If this instruction is used in a ladder diagram, the value of Q changes to FALSE if an error occurs in the previous instruction on the rung. 2-154 NY-series Instructions Reference Manual (W560)
  • Page 207: Ctud

    2 Instruction Descriptions CTUD The CTUD instruction creates an up-down counter that operates according to an up-counter input and a down-counter input. The preset value and counter value must have an INT data type. Instruction Name FB/FUN Graphic expression ST expression CTUD Up-down Counter CTUD_instance (CU, CD,...
  • Page 208: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit string Integers dates, and text strings Reset Load Function The CTUD instruction creates an up-down counter that operates according to an up-counter input sig- nal and a down-counter input signal. It has the functions of both an up counter and a down counter. The preset value and counter value must have an INT data type.
  • Page 209: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following table shows the relationship between Reset, Load, CV, QU, and QD. This assumes that the value of PV is larger than 0. Reset Load Operation 0 or FALSE TRUE Only up counter operation is performed. lower •...
  • Page 210: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions TRUE CU=A FALSE TRUE CD=B FALSE TRUE Reset=abc FALSE TRUE Load=def FALSE PV=INT#3 CV=mno TRUE QU=ghi FALSE TRUE QD=jkl FALSE When CV reaches PV, QU changes to TRUE. When Reset changes to TRUE, CV changes to 0, QU changes to FALSE, and QD changes to TRUE.
  • Page 211: Ctud

    2 Instruction Descriptions CTUD_** The CTUD_** instruction creates an up-down counter that operates according to an up-counter input and a down-counter input. The preset value and counter value must be one of the following data types: DINT, LINT, UDINT, or ULINT. Instruction Name FB/FUN...
  • Page 212: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit string Integers dates, and text strings Reset Load OK OK OK OK Must be the same data type as PV Function A CTUD_** instruction creates an up-down counter that operates according to an up-counter input sig- nal and a down-counter input signal.
  • Page 213: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following table shows the relationship between Reset, Load, CV, QU, and QD. This assumes that the value of PV is larger than 0. Reset Load Operation 0 or FALSE TRUE Only up counter operation is performed. lower •...
  • Page 214: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions TRUE CU=A FALSE TRUE CD=B FALSE TRUE Reset=abc FALSE TRUE Load=def FALSE PV=LINT#3 CV=mno TRUE QU=ghi FALSE TRUE QD=jkl FALSE When CV reaches PV, QU changes to TRUE. When Reset changes to TRUE, CV changes to 0, QU changes to FALSE, and QD changes to TRUE.
  • Page 215: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If the value of CU or CD is FALSE and the power supply is interrupted or the operating mode is changed to PROGRAM mode, the value of CV is incremented or decremented once if the value of CU or CD is TRUE when instruction execution is restarted.
  • Page 216: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-164 NY-series Instructions Reference Manual (W560)
  • Page 217: Math Instructions

    Math Instructions Instruction Name Page Instruction Name Page ADD (+) Addition 2-166 Natural Exponential 2-209 Operation AddOU (+OU) Addition with Overflow Check 2-170 EXPT (**) Exponentiation 2-211 SUB (-) Subtraction 2-174 Inc and Dec Increment/Decrement 2-217 SubOU (-OU) Subtraction with Overflow 2-177 Rand Random Number...
  • Page 218: Add (+)

    2 Instruction Descriptions ADD (+) The ADD (+) instruction adds integers or real numbers. It also joins text strings. Instruction Name FB/FUN Graphic expression ST expression ADD (+) Addition Out:=In1 + In2; (@)ADD (@)+ EN ENO Variables Name Meaning Description Valid range Unit Default...
  • Page 219: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Refer to Data Type Ranking Table and Casting Rules in the NJ/NX-series CPU Unit Software User's Manual (Cat. No. W501) or NY-series Industrial Panel PC / Industrial Box PC Software User’s Manual (Cat. No. W558) for the including relationship on data types. Data type that includes In1 to InN Examples: If INT data are added, then INT data is used.
  • Page 220: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Joining Text Strings If In1 to InN are STRING data, the text strings are joined. However, if In1 to InN are STRING data, you must use the instruction in a ladder diagram. The following example is for when In1 is UV, In2 is WX and In3 is YZ. The value of STRING variable abc will be ‘UVWXYZ’.
  • Page 221: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • When you calculate real numbers, use the CheckReal instruction (page 2-237) to see if Out is posi- tive infinity, negative infinity, or nonnumeric data. • Use the CONCAT instruction (page 2-548) to join text strings in structured text. Precautions for Correct Use •...
  • Page 222: Addou (+Ou)

    2 Instruction Descriptions AddOU (+OU) The AddOU (+OU) instruction adds integers and real numbers. It also performs an overflow check for integer addition result. Instruction Name FB/FUN Graphic expression ST expression AddOU (+OU) Addition with Out:=AddOU(In1, ···, InN); (@)AddOU Overflow Check (@)+OU Variables Name...
  • Page 223: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Processing for Overflows An overflow occurs if the sum of In1 to InN exceeds the valid range of the data type of the addition result. If all of In1 to InN are integer data and an overflow occurs, the value of the P_CY system-defined variable (Carry Flag) changes to TRUE.
  • Page 224: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Notation Examples The following example is for when In1 is INT#32767, In2 is INT#1 and variable abc has an INT data type. In1 to InN are all INT data, so the addition result is INT data. The sum of the two numbers (32,768) exceeds the valid range of INT data, so the value of P_CY changes to TRUE.
  • Page 225: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Out can have a different data type than the addition result. However, the data type of Out must include the valid range of the data type of the addition result. Otherwise, a building error will occur. Refer to Data Type Ranking Table and Casting Rules in the NJ/NX-series CPU Unit Software User's Manual (Cat.
  • Page 226: Sub

    2 Instruction Descriptions SUB (-) The SUB (-) instruction subtracts integers and real numbers. Instruction Name FB/FUN Graphic expression ST expression SUB (-) Subtraction Out:=In1 - In2; (@)SUB (@)- EN ENO Variables Name Meaning Description Valid range Unit Default Minuend Minuend Input Depends on data type.
  • Page 227: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Refer to Data Type Ranking Table and Casting Rules in the NJ/NX-series CPU Unit Software User's Manual (Cat. No. W501) or NY-series Industrial Panel PC / Industrial Box PC Software User’s Manual (Cat. No. W558) for the including relationship on data types. Processing for Overflows An overflow occurs if the difference between In1 and In2 exceeds the valid range of the data type of the subtraction result.
  • Page 228: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information When you calculate real numbers, use the CheckReal instruction (page 2-237) to see if Out is positive infinity, negative infinity, or nonnumeric data. Precautions for Correct Use • Out can have a different data type than the subtraction result. However, the data type of Out must include the valid range of the data type of the subtraction result.
  • Page 229: Subou (-Ou)

    2 Instruction Descriptions SubOU (-OU) The SubOU (-OU) instruction subtracts integers or real numbers. It also performs an overflow check for integer subtraction result. Instruction Name FB/FUN Graphic expression ST expression SubOU (-OU) Subtraction with Out:=SubOU(In1, In2); (@)SubOU Overflow Check (@)-OU Variables Name...
  • Page 230: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Processing for Overflows An overflow occurs if the difference between In1 and In2 exceeds the valid range of the data type of the subtraction result. If In1 and In2 are both integer data and an overflow occurs, the value of the P_CY system-defined variable (Carry Flag) changes to TRUE.
  • Page 231: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The SubOU instruction subtracts In2 from In1. The difference between the two values (−129) exceeds the valid range of SINT data, so the value of P_CY changes to TRUE. −128 − 1 = the value of the lower 8 bits of −129 (SINT data size = 8 bits) Subtracted.
  • Page 232: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Out can have a different data type than the subtraction result. However, the data type of Out must include the valid range of the data type of the subtraction result. Otherwise, a building error will occur. Refer to Data Type Ranking Table and Casting Rules in the NJ/NX-series CPU Unit Software User's Manual (Cat.
  • Page 233: Mul (*)

    2 Instruction Descriptions MUL (*) The MUL (*) instruction multiplies integers and real numbers. Instruction Name FB/FUN Graphic expression ST expression MUL (*) Multiplication Out:=In1 * In2; (@)MUL (@)* EN ENO Variables Name Meaning Description Valid range Unit Default In1 to InN Values to Input Numbers to multiply...
  • Page 234: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Refer to Data Type Ranking Table and Casting Rules in the NJ/NX-series CPU Unit Software User's Manual (Cat. No. W501) or NY-series Industrial Panel PC / Industrial Box PC Software User’s Manual (Cat. No. W558) for the including relationship on data types. Data type that includes In1 to InN Examples: If INT data are multiplied, then INT data is used.
  • Page 235: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Differences in Specifications between Ladder Diagrams and ST Specifications of this instruction depend on whether it is used in a ladder diagram or ST. The following table gives the differences in specifications. In ladder diagrams, the specifications of the MUL instruc- tion and the * instruction are exactly the same.
  • Page 236: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If any of the values of In1 to InN is nonnumeric data, the value of the multiplication result is nonnu- meric data. 2-184 NY-series Instructions Reference Manual (W560)
  • Page 237: Mulou (*Ou)

    2 Instruction Descriptions MulOU (*OU) The MulOU (*OU) instruction multiplies integers and real numbers and outputs the result. It also per- forms an overflow check for integer multiplication result. Instruction Name FB/FUN Graphic expression ST expression MulOU (*OU) Multiplication with Out:=MulOU(In1, ···, InN);...
  • Page 238: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Processing for Overflows An overflow occurs if the product of In1 to InN exceeds the valid range of the data type of the multiplica- tion result. If all of In1 to InN are integer data and an overflow occurs, the value of the P_CY system- defined variable (Carry Flag) changes to TRUE.
  • Page 239: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The MulOU instruction multiplies In1 to InN. The product of the two values (40,000) exceeds the valid range of INT data, so the value of P_CY changes to TRUE. 20000 × 2 = the value of the lower 16 bits of 40,000 (INT data size = 16 bits) Multiplied.
  • Page 240: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Out can have a different data type than the multiplication result. However, the data type of Out must include the valid range of the data type of the multiplication result. Otherwise, a building error will occur.
  • Page 241: Div (/)

    2 Instruction Descriptions DIV (/) The DIV (/) instruction divides integers or real numbers. Instruction Name FB/FUN Graphic expression ST expression DIV (/) Division Out:=In1/ In2; (@)DIV (@)/ EN ENO Variables Name Meaning Description Valid range Unit Default Dividend Dividend Input Depends on data type.
  • Page 242: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Data type that includes In1 and In2 Examples: If division is performed for INT data, then INT data is used. If division is performed for INT and DINT data, then DINT data is used. If In1 and In2 are integers and there is a remainder, the remainder is truncated.
  • Page 243: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Differences in Specifications between Ladder Diagrams and ST Specifications of this instruction depend on whether it is used in a ladder diagram or ST. The following table gives the differences in specifications. In ladder diagrams, the specifications of the DIV instruction and the / instruction are exactly the same.
  • Page 244: Mod

    2 Instruction Descriptions The MOD instruction finds the remainder for division of integers. Instruction Name FB/FUN Graphic expression ST expression Modulo-division Out:=In1 MOD In2; (@)MOD Variables Name Meaning Description Valid range Unit Default Dividend Dividend Input Depends on data type. Divisor Divisor Remainder...
  • Page 245: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In1 is INT#18 and In2 is INT#5. The value of variable abc will be INT#3. abc:=INT#18 MOD INT#5; INT#18 INT#5 The MOD instruction divides In1 by In2 to find the remainder. The remainder of 18/5 is 3, so the value of abc will be INT#3.
  • Page 246: Abs

    2 Instruction Descriptions The ABS instruction finds the absolute value of an integer or real number. Instruction Name FB/FUN Graphic expression ST expression Absolute Value Out:=ABS(In); (@)ABS Variables Name Meaning Description Valid range Unit Default Number to Input Number to process Depends on data type.
  • Page 247: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information When you calculate real numbers, use the CheckReal instruction (page 2-237) to see if Out is positive infinity, negative infinity, or nonnumeric data. Precautions for Correct Use • Set the data type of Out to include the absolute value of In. •...
  • Page 248: Radtodeg And Degtorad

    2 Instruction Descriptions RadToDeg and DegToRad RadToDeg: Converts a real number from radians (rad) to degrees (°). DegToRad: Converts a real number from degrees (°) to radians (rad). Instruction Name FB/FUN Graphic expression ST expression RadToDeg Radians to Degrees FUN Out:=RadToDeg(In);...
  • Page 249: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the DegToRad instruction is for when In is REAL#45. The value of the REAL variable abc will be REAL#0.785398. abc:=DegToRad(REAL#45); DegToRad REAL#45 The DegToRad instruction converts the value of In from degrees (°) to radians (rad). An angle of 45°...
  • Page 250: Sin, Cos, And Tan

    2 Instruction Descriptions SIN, COS, and TAN These instructions perform trigonometric calculations on real numbers. SIN: Finds the sine of a number. COS: Finds the cosine of a number. TAN: Finds the tangent of a number. Instruction Name FB/FUN Graphic expression ST expression Sine in Radians Out:=SIN(In);...
  • Page 251: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function These instructions perform trigonometric calculations on real numbers. Number to process In is an angle in radians (rad).  SIN The SIN instruction finds the sine of In. −1  COS The COS instruction finds the cosine of In. −1 ...
  • Page 252: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the COS instruction is for when In is REAL#3.141592. The value of vari- able abc will be REAL#−1.0. abc:=COS(REAL#3.141592); REAL#3.141592 The COS instruction finds the cosine of In. The cosine of 3.141592 is −1.0, so the value of abc will be REAL#−1.0. Cosine found.
  • Page 253: Asin, Acos, And Atan

    2 Instruction Descriptions ASIN, ACOS, and ATAN These instructions perform inverse trigonometric calculations on real numbers. ASIN: Finds the arc sine of a number. ACOS: Finds the arc cosine of a number. ATAN: Finds the arc tangent of a number. Instruction Name FB/FUN...
  • Page 254: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions −1.0 −  ACOS The ACOS instruction finds the arc cosine of In. Out is between 0 and π. −1.0  ATAN The ATAN instruction finds the arc tangent of In. Out is between −π/2 and π/2. If the value of In is positive infinity, the value of Out is π/2.
  • Page 255: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the ACOS instruction is for when In is REAL#−1.0. The value of variable abc will be REAL#3.141592. abc:=ACOS(REAL#-1.0); ACOS REAL#-1.0 The ACOS instruction finds the arccosine of In. The arccosine of −1.0 is 3.141592, so the value of abc will be REAL#3.141592. Arccosine found.
  • Page 256: Sqrt

    2 Instruction Descriptions SQRT The SQRT instruction finds the square root of a number. Instruction Name FB/FUN Graphic expression ST expression SQRT Square Root Out:=SQRT(In); (@)SQRT Variables Name Meaning Description Valid range Unit Default Number to Input Number to process Depends on data type.
  • Page 257: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is REAL#16.0. The value of variable abc will be REAL#4.0. abc:=SQRT(REAL#16.0); SQRT REAL#16.0 The SQRT instruction finds the square root of In. The square root of 16.0 is 4.0, so the value of abc will be REAL#4.0. Square root is found.
  • Page 258: Ln And Log

    2 Instruction Descriptions LN and LOG These instructions find the logarithm of a real number. Finds the natural logarithm of a number. LOG: Finds the base-10 logarithm of a number. Instruction Name FB/FUN Graphic expression ST expression Natural Logarithm Out:=LN(In); (@)LN Logarithm Base 10 Out:=LOG(In);...
  • Page 259: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function These instructions find the logarithm of a real number.  LN The LN instruction finds the natural logarithm (logarithm to base e, where e = 2.718282). 2.718282  LOG The LOG instruction finds the base-10 logarithm. The following example for the LOG instruction is for when In is REAL#1000.0.
  • Page 260: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The LOG instruction finds the base-10 logarithm of a real number. The base-10 logarithm of 1,000.0 is 3.0 so the value of abc will be REAL#3.0. Common logarithm is taken. REAL#1000.0 Out=abc REAL#3.0 Additional Information Use the CheckReal instruction (page 2-237) to see if Out is positive infinity, negative infinity, or nonnu- meric data.
  • Page 261: Exp

    2 Instruction Descriptions The EXP instruction performs calculations for the natural exponential function. Instruction Name FB/FUN Graphic expression ST expression Natural Exponential Out:=EXP(In); (@)EXP Operation Variables Name Meaning Description Valid range Unit Default Exponent Input Exponent Depends on data type. Calculation Output Calculation result...
  • Page 262: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is REAL#1.0. The value of variable abc will be REAL#2.718282. abc:=EXP(REAL#1.0); REAL#1.0 The EXP instruction returns the natural logarithm of In to the base e. The value of e is 2.718282, so the value of abc will be REAL#2.718282. e is taken to the Inth power REAL#1 REAL#2.718282...
  • Page 263: Expt (**)

    2 Instruction Descriptions EXPT (**) The EXPT (**) instruction raises one real number to the power of another real number. Instruction Name FB/FUN Graphic expression ST expression EXPT (**) Exponentiation Out:=EXPT(In, Pwr); (@)EXPT Out:=In ** Pwr; (@)** EN ENO Variables Name Meaning Description...
  • Page 264: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The ** Operator in ST Times, durations, dates, Bit strings Integers and text strings OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK Function Pwr.
  • Page 265: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • Use the EXP instruction (page 2-209) to find powers of base e. • Use the CheckReal instruction (page 2-237) to see if Out is positive infinity, negative infinity, or non- numeric data. Precautions for Correct Use •...
  • Page 266: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Combination of In and Pwr values The following table shows the values of Out for different combinations of In and Pwr values.  The EXPT Function for a Device Other Than the NX1P2 CPU Unit Non- 1 to -1 to nume +∞...
  • Page 267: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  The EXPT Function for the NX1P2 CPU Unit Non- 1 to -1 to nume +∞ 0 to 1 -1 to 0 -∞ +∞ -∞ data Non- +∞ +∞ +∞ +∞ numer ic data Num- Num- Positive even +∞...
  • Page 268: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  The ** Operator Non- 1 to -1 to nume +∞ 0 to 1 -1 to 0 -∞ +∞ -∞ data Nonnu +∞ +∞ +∞ +∞ meric data Num- Num- Positive even +∞ number *1*2 *1*2*3 Nonnu Num- Num- Num-...
  • Page 269: Inc And Dec

    2 Instruction Descriptions Inc and Dec Inc: Increments an integer value. Dec: Decrements an integer value. Instruction Name FB/FUN Graphic expression ST expression Increment Inc(InOut); (@)Inc InOut Decrement Dec(InOut); (@)Dec InOut Variables Name Meaning Description Valid range Unit Default InOut Target data In-out Target data...
  • Page 270: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the Inc instruction is for when variable abc is passed to InOut. If the value of abc is INT#4, the value of abc after the instruction is executed will be INT#5. Inc(abc); InOut The Inc instruction increments InOut.
  • Page 271: Rand

    2 Instruction Descriptions Rand The Rand instruction generates pseudorandom numbers. Instruction Name FB/FUN Graphic expression ST expression Rand Random Number Rand_instance(Execute, Rand_instance Seed, Rnd); Rand Execute ENO Seed Variables Name Meaning Description Valid range Unit Default Seed Random Input Random number pattern Depends on data type.
  • Page 272: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The Rand instruction generates a repeatable series of random numbers. Power ON LREAL#0.12 1st execution: Rnd = abc LREAL#0.34 2nd execution: Rnd = abc 3rd execution: Rnd = abc LREAL#0.56 The same random numbers are generated Power supply turned OFF and ON again. each time the power supply is turned ON.
  • Page 273: Aryadd

    2 Instruction Descriptions AryAdd The AryAdd instruction adds corresponding elements of two arrays. Instruction Name FB/FUN Graphic expression ST expression AryAdd Array Addition AryAdd(In1, In2, Size, Ary- (@)AryAdd Out); Size AryOut Variables Name Meaning Description Valid range Unit Default In1[] (array) Array to Array to process and In2[]...
  • Page 274: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Size is UINT#3. AryAdd(abc[1], def[2], UINT#3, ghi[3]); AryAdd abc[1] def[2] UINT#3 Size AryOut ghi[3] ghi[3] In1[0]=abc[1] In2[0]=def[2] AryOut[0]=ghi[3] 1234 2345 3579 In1[1]=abc[2] 2345 In2[1]=def[3] 3456 AryOut[1]=ghi[4] 5801 Size=UINT#3 In1[2]=abc[3] 3456 In2[2]=def[4] 4567 AryOut[2]=ghi[5] 8023...
  • Page 275: Aryaddv

    2 Instruction Descriptions AryAddV The AryAddV instruction adds the same value to specified elements of an array. Instruction Name FB/FUN Graphic expression ST expression AryAddV Array Value AryAddV(In1, In2, Size, Ary- (@)AryAddV Addition Out); Size AryOut Variables Name Meaning Description Valid range Unit Default...
  • Page 276: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In2 is INT#11 and Size is UINT#3. AryAddV(abc[1], INT#11, UINT#3, def[2]); AryAddV abc[1] INT#11 UINT#3 Size AryOut def[2] def[2] In1[0]=abc[1] In2=INT#11 AryOut[0]=def[2] Size=UINT#3 In1[1]=abc[2] In2=INT#11 AryOut[1]=def[3] In1[2]=abc[3] In2=INT#11 AryOut[2]=def[4] Precautions for Correct Use •...
  • Page 277: Arysub

    2 Instruction Descriptions ArySub The ArySub instruction subtracts corresponding elements of two arrays. Instruction Name FB/FUN Graphic expression ST expression ArySub Array Subtraction ArySub(In1, In2, Size, Ary- (@)ArySub Out); Size AryOut Variables Name Meaning Description Valid range Unit Default In1[] (array) Minuend Minuend array array In2[] (array) Subtrahend...
  • Page 278: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Size is UINT#3. ArySub(abc[1], def[2], UINT#3, ghi[3]); ArySub abc[1] def[2] UINT#3 Size AryOut ghi[3] ghi[3] In1[0]=abc[1] In2[0]=def[2] AryOut[0]=ghi[3] In1[1]=abc[2] In2[1]=def[3] AryOut[1]=ghi[4] Size=UINT#3 In1[2]=abc[3] In2[2]=def[4] AryOut[2]=ghi[5] Precautions for Correct Use • Use the same data type for In1[], In2[], and AryOut[]. If they are different, a building error will occur. •...
  • Page 279: Arysubv

    2 Instruction Descriptions ArySubV The ArySubV instruction subtracts the same value from specified elements of an array. Instruction Name FB/FUN Graphic expression ST expression ArySubV Array Value ArySubV(In1, In2, Size, Ary- (@)ArySubV Subtraction Out); Size AryOut Variables Name Meaning Description Valid range Unit Default...
  • Page 280: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In2 is INT#11 and Size is UINT#3. ArySubV(abc[1], INT#11, UINT#3, def[2]); ArySubV abc[1] INT#11 UINT#3 Size AryOut def[2] def[2] In1[0]=abc[1] In2=INT#11 AryOut[0]=def[2] In1[1]=abc[2] In2=INT#11 AryOut[1]=def[3] Size=UINT#3 In1[2]=abc[3] In2=INT#11 AryOut[2]=def[4] Precautions for Correct Use •...
  • Page 281: Arymean

    2 Instruction Descriptions AryMean The AryMean instruction calculates the average of the elements of an array. Instruction Name FB/FUN Graphic expression ST expression AryMean Array Mean Out := AryMean(In, Size); (@)AryMean Size Variables Name Meaning Description Valid range Unit Default In[] (array) Array to Array to process...
  • Page 282: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Refer to the descriptions of the functions of the ADD (+) instruction (page 2-166), SUB (−) instruction (page 2-174), MUL (*) instruction (page 2-181), and DIV (/) instruction (page 2-189) for the calcula- tion results when the value of In[] is positive infinity, negative infinity, or nonnumeric data.
  • Page 283: Arysd

    2 Instruction Descriptions ArySD The ArySD instruction calculates standard deviation of the elements of an array. Instruction Name FB/FUN Graphic expression ST expression ArySD Array Element Out:=ArySD(In, Size); (@)ArySD Standard Deviation Size Variables Name Meaning Description Valid range Unit Default In[] (array) Array to Array to process...
  • Page 284: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Size is UINT#5. def:=ArySD(abc[1], UINT#5); ArySD abc[1] UINT#5 Size In[0]=abc[1] 123.4 In[1]=abc[2] 234.5 Standard deviation calculated. Size=UINT#5 In[2]=abc[3] 345.6 175.6645 Out=def In[3]=abc[4] 456.7 In[4]=abc[5] 567.8 Precautions for Correct Use • If the value of Size is 0 or 1, the value of Out is 0. •...
  • Page 285: Modreal

    2 Instruction Descriptions ModReal The ModReal instruction calculates the remainder of real number division. Instruction Name FB/FUN Graphic expression ST expression ModReal Real Number Out:=ModReal(In1, In2); (@)ModReal Modulo-division Variables Name Meaning Description Valid range Unit Default Dividend Dividend Input Depends on data type. Divisor Divisor Remainder...
  • Page 286: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information Use the CheckReal instruction (page 2-237) to see if the value of Out is positive infinity, negative infinity, or nonnumeric data. Precautions for Correct Use • The following table shows the values of Out for different combinations of In1 and In2 values. Nonnumeric −∞...
  • Page 287: Fraction

    2 Instruction Descriptions Fraction The Fraction instruction finds the fractional part of a real number. Instruction Name FB/FUN Graphic expression ST expression Fraction Real Number Out:=Fraction(In); (@)Fraction Fraction Variables Name Meaning Description Valid range Unit Default Real Input Real number Depends on data type.
  • Page 288: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • Use the CheckReal instruction (page 2-237) to see if the value of Out is positive infinity, negative infinity, or nonnumeric data. • If you pass an integer parameter to In, the data type is converted as follows: Data type of parameter that is Data type of In passed to In...
  • Page 289: Checkreal

    2 Instruction Descriptions CheckReal The CheckReal instruction checks a real number to see if it is infinity or nonnumeric data. Instruction Name FB/FUN Graphic expression ST expression CheckReal Real Number CheckReal(In, Nan, PosIn- (@)CheckReal Check finite, NegInfinite); PosInfinite NegInfinite Variables Name Meaning Description...
  • Page 290: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The CheckReal instruction checks a real number In to see if it is nonnumeric data, positive infinity, or negative infinity. It outputs the results to Nan, PosInfinite, and NegInfinite. The following figure shows a programming example. The values of REAL variables a and b are multi- plied and the result is tested to see if it is a real number.
  • Page 291: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information Use this instruction on the result of a math instruction that handles real numbers to see if the result is nonnumeric data, positive infinity, or negative infinity. Precautions for Correct Use • Return value Out is not used when the instruction is used in ST. •...
  • Page 292: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-240 NY-series Instructions Reference Manual (W560)
  • Page 293: Bcd Conversion Instructions

    BCD Conversion Instructions Instruction Name Page **_BCD_TO_*** BCD-to-Unsigned Integer 2-242 Conversion Group **_TO_BCD_*** Unsigned Integer-to-BCD 2-245 Conversion Group BCD_TO_** BCD Data Type-to-Unsigned 2-247 Integer Conversion Group BCDsToBin Signed BCD-to-Signed Integer 2-250 Conversion BinToBCDs_** Signed Integer-to-BCD 2-253 Conversion Group AryToBCD Array BCD Conversion 2-256 AryToBin Array Unsigned Integer...
  • Page 294: **_Bcd_To

    2 Instruction Descriptions **_BCD_TO_*** These instructions convert BCD bit strings into unsigned integers. Instruction Name FB/FUN Graphic expression ST expression **_BCD_TO_*** BCD-to-Unsigned Out:=**_BCD_TO_*** (In); (@)**_BCD_TO_*** Integer Conversion Group "**" must be a bit string data type. "***" must be an integer data "**"...
  • Page 295: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following table shows the valid ranges for In and Out according to their data types. Data type Data type Valid range for In Valid range for Out of In of Out USINT UINT UDINT ULINT BYTE 16#00 to 16#99 (BCD) 0 to 99 SINT...
  • Page 296: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • The value of In is outside of the valid range. • The value in In is not BCD bit string data (i.e., contains A, B, C, D, E, or F hexadecimal). 2-244 NY-series Instructions Reference Manual (W560)
  • Page 297: **_To_Bcd

    2 Instruction Descriptions **_TO_BCD_*** These instructions convert unsigned integers to BCD bit strings. Instruction Name FB/FUN Graphic expression ST expression **_TO_BCD_*** Unsigned Integer- Out:=**_TO_BCD_*** (In); (@)**_TO_BCD_*** to-BCD Conversion Group "**" must be an integer data type. "***" must be a bit string "**"...
  • Page 298: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following table shows the valid ranges for In and Out according to their data types. Data type Data type Valid range for In Valid range for Out of In of Out BYTE 0 to 99 16#00 to 16#99 (BCD) WORD 16#0000 to 16#0255 (BCD) USINT...
  • Page 299: Bcd_To

    2 Instruction Descriptions BCD_TO_** The BCD_TO_** instruction converts BCD bit strings into unsigned integers. Instruction Name FB/FUN Graphic expression ST expression BCD_TO_** BCD Data Type-to- Out:=BCD_TO_** (In); (@)BCD_TO_** Unsigned Integer Conversion Group "**" must be an integer data type. "**" must be an integer data type. Variables Name Meaning...
  • Page 300: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following table shows the valid ranges for In and Out according to their data types. Data type Data type Valid range for In Valid range for Out of In of Out USINT UINT UDINT ULINT BYTE 16#00 to 16#99 (BCD) 0 to 99 SINT...
  • Page 301: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Always use the correct instruction name for the data type of Out. • If the data size of Out is larger than the data size of In, the upper digits of Out will contain 0. •...
  • Page 302: Bcdstobin

    2 Instruction Descriptions BCDsToBin The BCDsToBin instruction converts signed BCD bit strings to signed integers. Instruction Name FB/FUN Graphic expression ST expression BCDsToBin Signed BCD-to- Out:=BCDsToBin(In, Format); (@)BCDsToBin Signed Integer Conversion Format Variables Name Meaning Description Valid range Unit Default Data to Data to convert convert...
  • Page 303: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of data format number Format is enumerated type _eBCD_FORMAT. Select one of the following: _BCD0, _BCD1, _BCD2, or _BCD3. The sign specification in the upper four bits of In depends on the BCD format number. The data format examples shown below use WORD data for In. Format = _BCD1 Format = _BCD0 Valid range of In: −999 to 999 (BCD)
  • Page 304: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Use the same sizes of data types for In and Out. • An error occurs in the following cases. ENO will be FALSE, and Out will not change. • The value of Format is _BCD0 and the upper digit of In is 2 to F. •...
  • Page 305: Bintobcds

    2 Instruction Descriptions BinToBCDs_** These instructions convert signed integers to signed BCD bit strings. Instruction Name FB/FUN Graphic expression ST expression BinToBCDs_** Signed Integer-to- Out:=BinToBCDs(In, For- (@)BinToBCDs_** BCD Conversion mat); Group "**" must be a bit string data Format type. "**"...
  • Page 306: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of data format number Format is enumerated type _eBCD_FORMAT. Select one of the following: _BCD0, _BCD1, _BCD2, or _BCD3. The sign specification in the upper four bits of Out depends on the BCD format number. The data format examples shown below use WORD data for Out. Format = _BCD0 Format = _BCD1 Valid range of Out: −999 to 999 (BCD)
  • Page 307: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Always use the correct instruction name for the data type of Out. • An error occurs in the following cases. ENO will be FALSE, and Out will not change. • The value of In is outside of the valid range. •...
  • Page 308: Arytobcd

    2 Instruction Descriptions AryToBCD The AryToBCD instruction converts the elements of an unsigned integer array to BCD bit strings. Instruction Name FB/FUN Graphic expression ST expression AryToBCD Array BCD AryToBCD(In, Size, Ary- (@)AryToBCD Conversion Out); Size AryOut Variables Name Meaning Description Valid range Unit...
  • Page 309: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The AryToBCD instruction converts Size elements of unsigned integer array In[] starting from In[0] to a BCD bit string. It outputs the BCD bit string to BCD array AryOut[]. The following example is for when Size is UINT#3. AryToBCD(abc[1], UINT#3, def[2]);...
  • Page 310: Arytobin

    2 Instruction Descriptions AryToBin The AryToBin instruction converts the elements of an array of BCD bit strings into unsigned integers. Instruction Name FB/FUN Graphic expression ST expression AryToBin Array Unsigned AryToBin(In, Size, Ary- (@)AryToBin Integer Conversion Out); Size AryOut Variables Name Meaning Description...
  • Page 311: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The AryToBin instruction converts Size elements of array of BCD bit strings In[] starting from In[0] to unsigned integers. It outputs the unsigned integers to unsigned integer array AryOut[]. The following example is for when Size is UINT#3. AryToBin(abc[1], UINT#3, def[2]);...
  • Page 312: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-260 NY-series Instructions Reference Manual (W560)
  • Page 313: Data Type Conversion Instructions

    Data Type Conversion Instructions Instruction Name Page Instruction Name Page **_TO_*** (Integer-to-Integer Integer-to-Integer 2-262 RealToFormatString REAL-to-Formatted Text 2-289 Conversion Group) Conversion Group String **_TO_*** (Integer-to-Bit Integer-to-Bit String 2-265 LrealToFormatString LREAL-to-Formatted Text 2-294 String Conversion Group) Conversion Group String **_TO_*** (Integer-to-Real Integer-to-Real Number 2-268 STRING_TO_** (Text String-...
  • Page 314: To_*** (Integer-To-Integer Conversion Group)

    2 Instruction Descriptions **_TO_*** (Integer-to-Integer Conversion Group) These instructions convert integers to integers with different data types. Instruction Name FB/FUN Graphic expression ST expression **_TO_*** Integer-to-Integer Out:=**_TO_*** (In); (@)**_TO_*** Conversion Group "**" and "***" must be different integer data types. "**"...
  • Page 315: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following table shows the valid ranges for In and Out according to their data types. Data type Data type Valid range for In and Out of In of Out UINT UDINT 0 to 255 ULINT USINT SINT 0 to 127 DINT...
  • Page 316: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Data type Data type Valid range for In and Out of In of Out USINT 0 to 255 UINT 0 to 65535 UDINT 0 to 4294967295 LINT ULINT 0 to 9223372036854775807 −128 to 127 SINT −32768 to 32767 DINT −2147483648 to 2147483647 Additional Information...
  • Page 317: To_*** (Integer-To-Bit String Conversion Group)

    2 Instruction Descriptions **_TO_*** (Integer-to-Bit String Conversion Group) These instructions convert integers to bit strings. Instruction Name FB/FUN Graphic expression ST expression **_TO_*** Integer-to-Bit String Out:=**_TO_*** (In); (@)**_TO_*** Conversion Group "**" must be an integer data type. "***" must be a bit string "**"...
  • Page 318: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions WORD data INT data Out=abc 16#FB2E INT#-1234 The following table shows the valid ranges for In and Out according to their data types. Data type Data type Valid range for In Valid range for Out of In of Out BYTE WORD...
  • Page 319: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If In is an unsigned integer and the data size of Out is larger than the data size of In, the upper digits of Out will contain 0. • If the data size of Out is smaller than the data size of In, the upper digits are truncated in Out. 2-267 NY-series Instructions Reference Manual (W560)
  • Page 320: To_*** (Integer-To-Real Number Conversion Group)

    2 Instruction Descriptions **_TO_*** (Integer-to-Real Number Conversion Group) These instructions convert integers to real numbers. Instruction Name FB/FUN Graphic expression ST expression **_TO_*** Integer-to-Real Out:=**_TO_*** (In); (@)**_TO_*** Number Conver- sion Group "**" must be an integer data type. "***" must be a real number "**"...
  • Page 321: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions REAL data INT data Out=abc 1.234e+3 INT#1234 The following table shows the valid ranges for In and Out according to their data types. Data type Data type Valid range for In Valid range for Out of In of Out REAL USINT...
  • Page 322: To_*** (Bit String-To-Integer Conversion Group)

    2 Instruction Descriptions **_TO_*** (Bit String-to-Integer Conversion Group) These instructions convert bit strings to integers. Instruction Name FB/FUN Graphic expression ST expression **_TO_*** Bit String-to-Integer Out:=**_TO_*** (In); (@)**_TO_*** Conversion Group "**" must be a bit string data type. "***" must be an integer data "**"...
  • Page 323: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions WORD data INT data Out=abc 4660 WORD#16#1234 The following table shows the valid ranges for In and Out according to their data types. Data type Data type Valid range for In Valid range for Out of In of Out USINT UINT...
  • Page 324: To_*** (Bit String-To-Bit String Conversion Group)

    2 Instruction Descriptions **_TO_*** (Bit String-to-Bit String Conversion Group) These instructions convert bit strings to bit strings with different data types. Instruction Name FB/FUN Graphic expression ST expression **_TO_*** Bit String-to-Bit Out:=**_TO_*** (In); (@)**_TO_*** String Conversion Group "**" and "***" must be differ- ent bit string data types.
  • Page 325: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions DWORD data WORD data WORD#16#F123 Out=abc 16#0000F123 The following table shows the valid ranges for In and Out according to their data types. Data type Data type Valid range for In and Out of In of Out WORD BYTE DWORD...
  • Page 326: To_*** (Bit String-To-Real Number Conversion Group)

    2 Instruction Descriptions **_TO_*** (Bit String-to-Real Number Conversion Group) These instructions convert bit strings to real numbers. Instruction Name FB/FUN Graphic expression ST expression **_TO_*** Bit String-to-Real Out:=**_TO_*** (In); (@)**_TO_*** Number Conver- sion Group "**" must be a bit string data type.
  • Page 327: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions REAL data WORD data Out=abc 3.2768e+4 WORD#16#8000 The following table shows the valid ranges for In and Out according to their data types. Data Data type type of Valid range for In Valid range for Out of Out REAL BYTE 16#00 to 16#FF...
  • Page 328: To_*** (Real Number-To-Integer Conversion Group)

    2 Instruction Descriptions **_TO_*** (Real Number-to-Integer Conversion Group) These instructions convert real numbers to integers. Instruction Name FB/FUN Graphic expression ST expression **_TO_*** Real Number-to- Out:=**_TO_*** (In); (@)**_TO_*** Integer Conversion Group "**" must be a real number data type. "***" must be an integer data "**"...
  • Page 329: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions LINT data LREAL data Out=abc LREAL#1.0e+10 10000000000 The fractional part of the value of In is rounded off to the closest integer. The following table shows how values are rounded. Value of fractional Treatment Examples part 1.49 → 1 Less than The fractional part is truncated.
  • Page 330: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • To convert an integer to a real number, use an Integer-to-Real Number Conversion Group Instruction. • To convert data with any data type to an integer, use an Integer Conversion Group Instruction. • You can use the following instructions to convert a real number to an integer: TRUNC (Truncate), Round (Round Off Real Number), and RoundUp (Round Up Real Number).
  • Page 331: To_*** (Real Number-To-Bit String Conversion Group)

    2 Instruction Descriptions **_TO_*** (Real Number-to-Bit String Conversion Group) These instructions convert real numbers to bit strings. Instruction Name FB/FUN Graphic expression ST expression **_TO_*** Real Number-to- Out:=**_TO_*** (In); (@)**_TO_*** Bit String Conversion Group "**" must be a real number data type.
  • Page 332: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions LREAL data DWORD data Out=abc 16#0001_0000 LREAL#6.5536e+4 Conversion is performed using the following procedure. The fractional part of the value of In is rounded off to the closest integer as described below. The resulting integer is taken as an unsigned integer and output as a bit string. The following table shows how values are rounded.
  • Page 333: To_*** (Real Number-To-Real Number Conversion Group)

    2 Instruction Descriptions **_TO_*** (Real Number-to-Real Number Conversion Group) These instructions convert real numbers to real numbers with different data types. Instruction Name FB/FUN Graphic expression ST expression **_TO_*** Real Number-to- Out:=**_TO_*** (In); (@)**_TO_*** Real Number Conversion Group "**" and "***" must be dif- ferent real number data types.
  • Page 334: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions LREAL data REAL data Out=abc REAL#3.141592e+0 3.141592e+0 The following table shows the valid ranges for In and Out according to their data types. Data type of In Data type of Out Valid range for In and Out −3.402823e+38 to 3.402823e+38 REAL LREAL...
  • Page 335: To_String (Integer-To-Text String Conversion Group)

    2 Instruction Descriptions **_TO_STRING (Integer-to-Text String Conversion Group) These instructions convert integers to text strings. Instruction Name FB/FUN Graphic expression ST expression **_TO_STRING Integer-to-Text Out:=**_TO_STRING(In); (@)**_TO_STRING String Conversion Group "**" must be an integer data type. "**" must be an integer data type. Variables Name Meaning...
  • Page 336: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the INT_TO_STRING instruction is for when In is INT#1234. abc:=INT_TO_STRING(INT#1234); INT_TO_STRING INT#1234 STRING data INT data Out=abc ‘1234’ INT#1234 The valid range of Out depends on the data type of In as shown below: Data type of In Valid range of Out (maximum number of bytes) USINT...
  • Page 337: To_String (Bit String-To-Text String Conversion Group)

    2 Instruction Descriptions **_TO_STRING (Bit String-to-Text String Conversion Group) These instructions convert bit strings to text strings. Instruction Name FB/FUN Graphic expression ST expression **_TO_STRING Bit String-to-Text Out:=**_TO_STRING(In); (@)**_TO_STRING String Conversion Group "**" must be a bit string data type. "**"...
  • Page 338: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the WORD_TO_STRING instruction is for when In is WORD#16#1F. abc:=WORD_TO_STRING(WORD#16#1F); WORD_TO_STRING WORD#16#1F WORD data STRING data ‘001F’ WORD#16#1F Out=abc The valid range of Out depends on the data type of In as shown below: Data type of In Valid range of Out (maximum number of bytes) BYTE...
  • Page 339: To_String (Real Number-To-Text String Conversion Group)

    2 Instruction Descriptions **_TO_STRING (Real Number-to- Text String Conversion Group) These instructions convert real numbers to text strings. Instruction Name FB/FUN Graphic expression ST expression **_TO_STRING Real Number-to- Out:=**_TO_STRING(In); (@)**_TO_STRING Text String Conversion Group "**" must be a real number data type.
  • Page 340: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Item Description Sign column If In contains a negative value, a minus sign (−) is added. If In contains a positive value, a plus sign (+) is not added. Integer part The integer part is always only one digit. Decimal point The decimal point is always given even if In is not a decimal number.
  • Page 341: Realtoformatstring

    2 Instruction Descriptions RealToFormatString The RealToFormatString instruction converts a REAL variable to a text string with the specified format. Instruction Name FB/FUN Graphic expression ST expression RealToFormatString REAL-to-Formatted Out:=RealToFormat- (@)RealToFormatString Text String String(In, Exponent, Sign, MinLen, DecPlace); Exponent Sign MinLen DecPlace Variables Name...
  • Page 342: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions If In contains a negative value, a minus sign (−) is added to the front of the text string. If In contains a positive value, a plus sign (+) is not added to the front of the text string. The format of Out is determined by exponent Exponent, sign column Sign, minimum number of digits MinLen, and precision DecPlace.
  • Page 343: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Here, no sign column is specified for a negative number, so a minus sign (−) is added to the front of the integer part. abc:=RealToFormatString(REAL#-1234.567, FALSE, FALSE, USINT#16, USINT#10); RealToFormatString REAL#-1234.567 FALSE Exponent FALSE Sign USINT#16 MinLen USINT#10 DecPlace - 1 2 3 4 .
  • Page 344: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Example 5: Exponent: TRUE Sign: TRUE MinLen: USINT#12 DecPlace: USINT#0 The first decimal place is rounded off because DecPlace is USINT#0. The decimal point is also not given. 1 e + 0 3 Example 6: Exponent: FALSE Sign: TRUE MinLen: USINT#8 DecPlace: USINT#0...
  • Page 345: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following table shows how values are rounded. Value of fractional Treatment Examples part 1.49 → 1 Less than The fractional part is truncated. 1.50 → 2 If the ones digit is an even number, the fractional part is truncated.
  • Page 346: Lrealtoformatstring

    2 Instruction Descriptions LrealToFormatString The LrealToFormatString instruction converts a LREAL variable to a text string with the specified for- mat. Instruction Name FB/FUN Graphic expression ST expression LrealToFormatStrin LREAL-to- Out:=LrealToFormatString (@)LrealToFormatString Formatted Text (In, Exponent, Sign, String MinLen, DecPlace); Exponent Sign MinLen DecPlace...
  • Page 347: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The LrealToFormatString instruction converts LREAL variable In to a text string. In is expressed as an alphanumeric text string and output to conversion result Out. A NULL character (16#00) is placed at the end of Out. If In contains a negative value, a minus sign (−) is added to the front of the text string.
  • Page 348: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Here, no sign column is specified for a negative number, so a minus sign (−) is added to the front of the integer part. abc:=LrealToFormatString(LREAL#-1234.56789, FALSE, FALSE, USINT#16, USINT#10); LrealToFormatString LREAL#-1234.56789 FALSE Exponent FALSE Sign USINT#16 MinLen USINT#10 DecPlace - 1 2 3 4 .
  • Page 349: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Example 5: Exponent: TRUE Sign: TRUE MinLen: USINT#12 DecPlace: USINT#0 The first decimal place is rounded off because DecPlace is USINT#0. The decimal point is also not given. 1 e + 0 3 Example 6: Exponent: FALSE Sign: TRUE MinLen: USINT#8 DecPlace: USINT#0...
  • Page 350: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following table shows how values are rounded. Value of fractional Treatment Examples part 1.49 → 1 Less than The fractional part is truncated. 1.50 → 2 If the ones digit is an even number, the fractional part is truncated.
  • Page 351: String_To_** (Text String-To-Integer Conversion Group)

    2 Instruction Descriptions STRING_TO_** (Text String-to- Integer Conversion Group) These instructions convert text strings to integers. Instruction Name FB/FUN Graphic expression ST expression STRING_TO_** Text String-to- Out:=STRING_TO_** (In); (@)STRING_TO_** Integer Conversion Group "**" must be an integer data type. "**" must be an integer data type. Variables Name Meaning...
  • Page 352: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the STRING_TO_DINT instruction is for when In is ‘123456789’. abc:=STRING_TO_DINT(‘123456789’); STRING_TO_DINT ‘123456789’ STRING data DINT data Out=abc 123456789 ‘123456789’ The valid range of In depends on the data type of Out as shown below: Data type of Out Valid range of In (maximum number of bytes)* USINT...
  • Page 353: String_To_** (Text String-To-Bit String Conversion Group)

    2 Instruction Descriptions STRING_TO_** (Text String-to-Bit String Conversion Group) These instructions convert text strings to bit strings. Instruction Name FB/FUN Graphic expression ST expression STRING_TO_** Text String-to-Bit Out:=STRING_TO_** (In); (@)STRING_TO_** String Conversion Group "**" must be a bit string data type.
  • Page 354: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the STRING_TO_BYTE instruction is for when In is ‘ AB’. Any blank charac- ters at the beginning are ignored. abc:=STRING_TO_BYTE(’ AB’); STRING_TO_BYTE ‘ AB’ STRING data BYTE data Out=abc 16#AB ‘ AB’ The valid range of In depends on the data type of Out as shown below: Data type of Out Valid range of In (maximum number of bytes)* BYTE...
  • Page 355: String_To_** (Text String-To-Real Number Conversion Group)

    2 Instruction Descriptions STRING_TO_** (Text String-to- Real Number Conversion Group) These instructions convert text strings to real numbers. Instruction Name FB/FUN Graphic expression ST expression STRING_TO_** Text String-to-Real Out:=STRING_TO_** (In); (@)STRING_TO_** Number Conver- sion Group "**" must be a real number data type.
  • Page 356: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Name Format Sign • Any consecutive blank characters at the beginning of the text string are ignored. Any follow- ing single plus or minus sign is treated as the sign. • The plus sign can be omitted. •...
  • Page 357: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Example 3: The following example does not use the sign, but uses the decimal point, fractional part, and exponent. STRING data LREAL data ‘ ’ Out=abc 1 2 3 . 4 5 6 7 e - 0 2 1.234567 Example 4: The following example does not use the sign, fractional part, decimal point, and expo- nent.
  • Page 358: To_** (Integer Conversion Group)

    2 Instruction Descriptions TO_** (Integer Conversion Group) These instructions convert integers, bit strings, real numbers, and text strings to integers. Instruction Name FB/FUN Graphic expression ST expression TO_** Integer Conversion Out:=TO_** (In); (@)TO_** Group "**" must be an integer data type.
  • Page 359: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • Conversion is performed to within the effective digits of the data type of In. If In is a real number, the fractional part is rounded off to the closest integer. The following table shows how values are rounded.
  • Page 360: To_** (Bit String Conversion Group)

    2 Instruction Descriptions TO_** (Bit String Conversion Group) These instructions convert integers, bit strings, real numbers, and text strings to bit strings. Instruction Name FB/FUN Graphic expression ST expression TO_** Bit String Out:=TO_**(In); (@)TO_** Conversion Group "**" must be a bit string data type.
  • Page 361: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The valid ranges for In and Out depend on their data types. Refer to the descriptions of the functions of the following instructions for the valid ranges: **_TO_*** (Integer-to-Bit String Conversion Group) (page 2-265), **_TO_*** (Bit String-to-Bit String Conversion Group) (page 2-272), and **_TO_*** (Real Num- ber-to-Bit String Conversion Group) (page 2-279).
  • Page 362: To_** (Real Number Conversion Group)

    2 Instruction Descriptions TO_** (Real Number Conversion Group) These instructions convert integers, bit strings, real numbers, and text strings to real numbers. Instruction Name FB/FUN Graphic expression ST expression TO_** Real Number Con- Out:=TO_**(In); (@)TO_** version Group "**" must be a real number data type.
  • Page 363: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions INT data REAL data Out=abc INT#1234 1.234e+3 The valid ranges for In and Out depend on their data types. Refer to the descriptions of the functions of the following instructions for the valid ranges: **_TO_*** (Integer-to-Real Number Conversion Group) (page 2-268), **_TO_*** (Bit String-to-Real Number Conversion Group) (page 2-274), and **_TO_*** (Real Number-to-Real Number Conversion Group) (page 2-281).
  • Page 364: Enumtonum

    2 Instruction Descriptions EnumToNum The EnumToNum instruction converts enumeration data to DINT data. Instruction Name FB/FUN Graphic expression ST expression EnumToNum Enumeration-to- Out:=EnumToNum(In); Integer (@)EnumToNum Variables Name Meaning Description Valid range Unit Default Data to Input Data to convert convert Conversion Output Conversion result...
  • Page 365: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use Version Information A CPU Unit with unit version 1.02 or later and Sysmac Studio version 1.03 or higher are required to use this instruction. Sample Programming In this sample, the operating mode of the user program is defined with enumerated data type Enum- Mode.
  • Page 366: Numtoenum

    2 Instruction Descriptions NumToEnum The NumToEnum instruction converts DINT data to enumeration data. Instruction Name FB/FUN Graphic expression ST expression NumToEnum Integer-to- NumToEnum(In,InOut); Enumeration (@)NumToEnum InOut Variables Name Meaning Description Valid range Unit Default Data to Input Data to convert Depends on data convert type.
  • Page 367: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information If you use this instruction in a ladder diagram, you can use Out to see if the value of In is within the range of values for InOut. Precautions for Correct Use An error occurs if the value of In is not within the range of values for InOut. Out will be FALSE, and the value of InOut will not change.
  • Page 368: Trunc, Round, And Roundup

    2 Instruction Descriptions TRUNC, Round, and RoundUp These instructions change real numbers to integers. TRUNC: Truncates the number at the first decimal digit. Round: Rounds the number at the first decimal digit. RoundUp: Rounds up the number at the first decimal digit. Instruction Name FB/FUN...
  • Page 369: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Round The Round instruction rounds the number at the first decimal digit. The following table shows how values are rounded. Value of fractional part Treatment Examples Less than 0.5 The fractional part is truncated. 1.49 → 1 −1.49 →...
  • Page 370: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-318 NY-series Instructions Reference Manual (W560)
  • Page 371: Bit String Processing Instructions

    Bit String Processing Instructions Instruction Name Page AND (&), OR, and XOR Logical AND/Logical OR/ 2-320 Logical Exclusive OR XORN Logical Exclusive NOR 2-323 Bit Reversal 2-325 AryAnd, AryOr, AryXor, and Array Logical AND/ 2-327 AryXorN Array Logical OR/ Array Logical Exclusive OR/ Array Logical Exclusive NOR NY-series Instructions Reference Manual (W560) 2-319...
  • Page 372: And (&), Or, And Xor

    2 Instruction Descriptions AND (&), OR, and XOR These instructions perform processing on Boolean variables or individual bits in bit stings. AND (&): Logical AND Logical OR XOR: Logical Exclusive OR Instruction Name FB/FUN Graphic expression ST expression AND (&) Logical AND Out:=In1 AND ··AND InN;...
  • Page 373: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function These instructions perform processing on Boolean variables or corresponding bits in bit strings. The data to process is in In1 to InN. In1 to InN and Out must be the same data types. If there are more than two data to process, processing is performed with the following procedure. Processing is performed for In1 and In2.
  • Page 374: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example shows the AND instruction when In1 is BYTE#16#3A, In2 is BYTE#16#28 and In3 is BYTE#16#73. abc:=BYTE#16#3A AND BYTE#16#28 AND BYTE#16#73; BYTE#16#3A BYTE#16#28 BYTE#16#73 In1=BYTE#16#3A 0 0 1 1 1 0 1 0 0 0 1 0 1 0 0 0 In2=BYTE#16#28 0 1 1 1 0 0 1 1 In3=BYTE#16#73...
  • Page 375: Xorn

    2 Instruction Descriptions XORN The XORN instruction performs a logical exclusive NOR operation on Boolean variables or individual bits in bit stings. Instruction Name FB/FUN Graphic expression ST expression XORN Logical Exclusive Out:=In1 XOR NOT ·· XOR (@)XORN NOT InN; Variables Name Meaning...
  • Page 376: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The relationships between input and output variables are given in the following table. If both values are the same, then the processing result is TRUE. Otherwise, the processing result is FALSE. In1 bit In2 bit Out bit FALSE FALSE TRUE...
  • Page 377: Not

    2 Instruction Descriptions The NOT instruction reverses the value of a Boolean variable or the individual bits in a bit string. Instruction Name FB/FUN Graphic expression ST expression Bit Reversal Out:=NOT In; (@)NOT Variables Name Meaning Description Valid range Unit Default Data to Input...
  • Page 378: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use The data types of In and Out must be the same. Otherwise, a building error will occur. 2-326 NY-series Instructions Reference Manual (W560)
  • Page 379: Aryand, Aryor, Aryxor, And Aryxorn

    2 Instruction Descriptions AryAnd, AryOr, AryXor, and AryXorN These instructions process Boolean variables or individual bits in bit stings between arrays. AryAnd: Logical AND AryOr: Logical OR AryXor: Logical Exclusive OR AryXorN: Logical Exclusive NOR Instruction Name FB/FUN Graphic expression ST expression AryAnd Array Logical AND...
  • Page 380: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings In1[] (array) OK OK OK OK OK In2[] (array) Must be same data type as In1[] Size AryOut[] Must be same data type as In1[] (array) Function These instructions process Size elements from the beginning of arrays to process In1[] and In2[]. Pro- cessing is performed for corresponding bits of corresponding elements.
  • Page 381: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  AryXor If both bits are the same, then the processing result is FALSE. If one bit is TRUE and the other is FALSE, then the processing result is TRUE. Bit of ele- Bit of ele- Bit of Ary- ment in In1[] ment in In2[] Out[]...
  • Page 382: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-330 NY-series Instructions Reference Manual (W560)
  • Page 383: Selection Instructions

    Selection Instructions Instruction Name Page Binary Selection 2-332 Multiplexer 2-334 LIMIT Limiter 2-337 Band Deadband Control 2-339 Zone Dead Zone Control 2-342 MAX and MIN Maximum/Minimum 2-345 AryMax and AryMin Array Maximum/Array Minimum 2-347 ArySearch Array Search 2-350 NY-series Instructions Reference Manual (W560) 2-331...
  • Page 384: Sel

    2 Instruction Descriptions The SEL instruction selects one of two selections. Instruction Name FB/FUN Graphic expression ST expression Binary Selection Out:=SEL(G, In0, In1); (@)SEL Variables Name Meaning Description Valid range Unit Default Gate FALSE: Selects In0. FALSE TRUE: Selects In1. Input Depends on data type.
  • Page 385: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The SEL instruction selects one of two selections, In0 and In1. Gate G specifies which of In0 and In1 to select. If G is FALSE, In0 is assigned to Out. If G is TRUE, In1 is assigned to Out. FALSE TRUE Out: = In1...
  • Page 386: Mux

    2 Instruction Descriptions The MUX instruction selects one of two to five selections. Instruction Name FB/FUN Graphic expression ST expression Multiplexer Out:=MUX(K, In0, In1, ···, (@)MUX InN); Variables Name Meaning Description Valid range Unit Default Selector 0: Selects In0. 0 to N 1: Selects In1.
  • Page 387: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The MUX instruction selects one of two to five selections, In0 to InN. Selector K specifies which of In0 to InN to select. The value of one of the input variables is assigned to Out according to the value of K. In0 is assigned if K is 0, In1 is assigned if K is 1, etc.
  • Page 388: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • In0 to InN and Out may be different data types, but observe the following precautions. • Set the valid range of Out to include the valid ranges of In0 to InN. • In0 to InN and Out cannot be different varieties of data types (such as a bit string and an integer, or an integer and a text string).
  • Page 389: Limit

    2 Instruction Descriptions LIMIT The LIMIT instruction limits the value of the input variable to the specified minimum and maximum val- ues. Instruction Name FB/FUN Graphic expression ST expression LIMIT Limiter Out:=LIMIT(MN, In, MX); (@)LIMIT Variables Name Meaning Description Valid range Unit Default Minimum...
  • Page 390: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The LIMIT instruction limits the value of data to limit In according to the maximum value, MX, and the minimum value, MN. The value of processing result Out is as shown below. Value of In Value of Out In <...
  • Page 391: Band

    2 Instruction Descriptions Band The Band instruction performs deadband control. Instruction Name FB/FUN Graphic expression ST expression Band Deadband Control Out:=Band(MN, In, MX); (@)Band Variables Name Meaning Description Valid range Unit Default Minimum Minimum value of deadband value Data to Data to control Input Depends on data type.
  • Page 392: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The Band instruction controls the value of data to control In according to the maximum value, MX, and the minimum value, MN. The value of processing result Out is as shown below. Value of In Value of Out In −...
  • Page 393: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Value of In Value of MN Value of MX Value of Out −∞ +∞ +∞ −∞ Error −∞ +∞ −∞ −∞ • An error occurs in the following cases. ENO will be FALSE, and Out will not change. •...
  • Page 394: Zone

    2 Instruction Descriptions Zone The Zone instruction adds a bias value to the input value. Instruction Name FB/FUN Graphic expression ST expression Zone Dead Zone Control Out:=Zone(BiasN, In, (@)Zone BiasP); BiasN BiasP Variables Name Meaning Description Valid range Unit Default BiasN Negative Negative bias...
  • Page 395: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The Zone instruction controls the value of data to control In according to the positive bias, BiasP, and the negative bias, BiasN. The value of processing result Out is as shown below. Value of Value of In In <...
  • Page 396: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Value of In Value of BiasP Value of BiasN Value of Out +∞ +∞ −∞ −∞ −∞ +∞ Error −∞ −∞ −∞ • An error occurs in the following cases. ENO will be FALSE, and Out will not change. •...
  • Page 397: Max And Min

    2 Instruction Descriptions MAX and MIN MAX: Finds the largest of two to five values. MIN: Finds the smallest of two to five values. Instruction Name FB/FUN Graphic expression ST expression Maximum Out:=MAX(In1, In2, ···, InN); (@)MAX Minimum Out:=MIN(In1, In2, ···, InN); (@)MIN Variables Name...
  • Page 398: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function  MAX The MAX instruction finds the largest value of two to five data to process, In1 to InN.  MIN The MIN instruction finds the smallest value of two to five data to process, In1 to InN. The following example is for the MAX instruction when In1 is INT#10, In2 is INT#5, In3 is INT#23, In4 is INT#14, and In5 is INT#−5.
  • Page 399: Arymax And Arymin

    2 Instruction Descriptions AryMax and AryMin AryMax: Finds the elements with the largest value in a one-dimensional array. AryMin: Finds the elements with the smallest value in a one-dimensional array. Instruction Name FB/FUN Graphic expression ST expression AryMax Array Maximum Out:=AryMax(In, Size, (@)AryMax InOutPos, Num);...
  • Page 400: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function These instructions search Size elements in array to search In[] starting from In[0]. The value that is found is assigned to Out, the element number where it was found is assigned to InOutPos, and the number of times the value was found is assigned to Num. If Num is greater than 1, the value in InOut- Pos is the number of the lowest element that contains the value that was found.
  • Page 401: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If In[] contains real numbers, the desired results may not be achieved due to error. • Always used a one-dimensional array for In[]. • If the value of Size is 0, the values of Out and Num are 0. The value of InOutPos does not change. •...
  • Page 402: Arysearch

    2 Instruction Descriptions ArySearch The ArySearch instruction searches for the specified value in a one-dimensional array. Instruction Name FB/FUN Graphic expression ST expression ArySearch Array Search Out:=ArySearch(In, Size, (@)ArySearch Key, InOutPos, Num); Size InOutPos Variables Name Meaning Description Valid range Unit Default In[] (array)
  • Page 403: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The ArySearch instruction searches Size elements of one-dimensional array to search In[] for elements with the same value as search key Key. The search starts from In[0]. The values of search result Out, found element number InOutPos, and number found Num are as fol- lows: Element with same value as...
  • Page 404: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Always use a one-dimensional array for In[]. • Make sure that Key has the same data type as the elements of In[]. • If the value of Size is 0, the values of Out and Num are 0. The value of InOutPos does not change. •...
  • Page 405: Data Movement Instructions

    Data Movement Instructions Instruction Name Page MOVE Move 2-354 MoveBit Move Bit 2-357 MoveDigit Move Digit 2-359 TransBits Move Bits 2-361 MemCopy Memory Copy 2-363 SetBlock Block Set 2-365 Exchange Data Exchange 2-367 AryExchange Array Data Exchange 2-369 AryMove Array Move 2-371 Clear Initialize...
  • Page 406: Move

    2 Instruction Descriptions MOVE The MOVE instruction moves the value of a constant or variable to another variable. Instruction Name FB/FUN Graphic expression ST expression MOVE Move Out:=In; (@)MOVE Variables Name Meaning Description Valid range Unit Default Move Input Move source Depends on data type.
  • Page 407: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • When moving an array, you can move either one element or all of the elements in the array. To move only one element, add the subscript to the array variable name. To move the entire array, do not add the subscript to the array variable name.
  • Page 408: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • BYTE, WORD, DWORD, and LWORD • USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, REAL, and LREAL • If In is an enumeration, array element, structure, or structure member, then Out must have the same data type as In. •...
  • Page 409: Movebit

    2 Instruction Descriptions MoveBit The MoveBit instruction moves one bit in a bit string. Instruction Name FB/FUN Graphic expression ST expression MoveBit Move Bit MoveBit(In, InPos, InOut, (@)MoveBit InOutPos); InPos InOut InOutPos Variables Name Meaning Description Valid range Unit Default Move Move source Depends on data type.
  • Page 410: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The MoveBit instruction moves one bit from the bit position InPos in move source In to the bit position InOutPos in move destination InOut. The following example is for when InPos is USINT#3 and InOutPos is USINT#5. MoveBit(abc, USINT#3, def, USINT#5);...
  • Page 411: Movedigit

    2 Instruction Descriptions MoveDigit The MoveDigit instruction moves digits (4 bits per digit) in a bit string. Instruction Name FB/FUN Graphic expression ST expression MoveDigit Move Digit MoveDigit(In, InPos, InOut, (@)MoveDigit InOutPos, Size); InPos InOut InOutPos Size Variables Name Meaning Description Valid range Unit...
  • Page 412: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The MoveDigit instruction moves Size digits from the InPos digit in move source In to the InOutPos digit in move destination InOut. One digit is four bits. The following example is for when InPos is USINT#1, InOutPos is USINT#2, and Size is USINT#2. MoveDigit(abc, USINT#1, def, USINT#2, USINT#2);...
  • Page 413: Transbits

    2 Instruction Descriptions TransBits The TransBits instruction moves one or more bits in a bit string. Instruction Name FB/FUN Graphic expression ST expression TransBits Move Bits TransBits(In, InPos, InOut, (@)TransBits InOutPos, Size); InPos InOut InOutPos Size Variables Name Meaning Description Valid range Unit Default...
  • Page 414: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The TransBis instruction moves Size bits from the InPos bit in move source In to the InOutPos bit in move destination InOut. The following example is for when InPos is USINT#3, InOutPos is USINT#4, and Size is USINT#2. TransBits(abc, USINT#3, def, USINT#4, USINT#2);...
  • Page 415: Memcopy

    2 Instruction Descriptions MemCopy The MemCopy instruction moves one or more array elements. The move source and move destination must have the same data type. Instruction Name FB/FUN Graphic expression ST expression MemCopy Memory Copy MemCopy(In, AryOut, Size); (@)MemCopy AryOut Size Variables Name...
  • Page 416: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The MemCopy instruction moves Size elements of move source array In[] starting from In[0] to move destination array AryOut[] starting from AryOut[0]. The following example is for when Size is UINT#3. MemCopy(abc[1], def[2], UINT#3); MemCopy abc[1] AryOut def[2] def[2]...
  • Page 417: Setblock

    2 Instruction Descriptions SetBlock The SetBlock instruction moves the value of a variable or constant to one or more array elements. Instruction Name FB/FUN Graphic expression ST expression SetBlock Block Set SetBlock(In, AryOut, Size); (@)SetBlock AryOut Size Variables Name Meaning Description Valid range Unit...
  • Page 418: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Size is UINT#3. SetBlock(abc, def[1], UINT#3); SetBlock AryOut def[1] def[1] UINT#3 Size AryOut[0]=def[1] In=abc 1234 1234 Size=UINT#3 AryOut[1]=def[2] 1234 AryOut[2]=def[3] 1234 Precautions for Correct Use • Use the same data type for In and AryOut[]. If they are different, a building error will occur. •...
  • Page 419: Exchange

    2 Instruction Descriptions Exchange The Exchange instruction exchanges the values of two variables. Instruction Name FB/FUN Graphic expression ST expression Exchange Data Exchange Exchange(InOut1, InOut2); (@)Exchange InOut1 InOut2 Variables Name Meaning Description Valid range Unit Default InOut1 and Data to In-out Data to exchange Depends on data type.
  • Page 420: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The Exchange instruction exchanges the values of InOut1 and InOut2. Exchanged. InOut1=abc InOut1=abc InOut2=def InOut2=def Precautions for Correct Use • The data types of InOut1 and InOut2 must be the same. If they are different, a building error will occur.
  • Page 421: Aryexchange

    2 Instruction Descriptions AryExchange The AryExchange instruction exchanges the elements of two arrays. Instruction Name FB/FUN Graphic expression ST expression AryExchange Array Data AryExchange(InOut1, (@)AryExchange Exchange InOut2, Size); InOut1 InOut2 Size Variables Name Meaning Description Valid range Unit Default Size Number of Input Number of elements to...
  • Page 422: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Size is UINT#2. AryExchange(abc[1], def[2], UINT#2); AryExchange InOut1 abc[1] abc[1] InOut2 def[2] def[2] UINT#2 Size InOut1[0]=abc[1] Exchanged InOut2[0]=def[2] Size=UINT#2 InOut1[1]=abc[2] InOut2[1]=def[3] Additional Information • Use the MOVE instruction (page 2-354) to assign constants to variables. •...
  • Page 423: Arymove

    2 Instruction Descriptions AryMove The AryMove instruction moves one or more array elements. The data types of the move source and move destination can be different. Instruction Name FB/FUN Graphic expression ST expression AryMove Array Move AryMove(In, AryOut, Size); (@)AryMove AryOut Size Variables...
  • Page 424: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Size is UINT#2. AryMove(abc[1], def[2], UINT#2); AryMove abc[1] AryOut def[2] def[2] UINT#2 Size In[0]=abc[1] AryOut[0]=def[2] Moved Size=UINT#2 In[1]=abc[2] AryOut[1]=def[3] Additional Information • If the data types of In[] and AryOut[] are the same, the MemCopy instruction is faster. •...
  • Page 425: Clear

    2 Instruction Descriptions Clear The Clear instruction initializes a variable. Instruction Name FB/FUN Graphic expression ST expression Clear Initialize Clear(InOut); (@)Clear InOut Variables Name Meaning Description Valid range Unit Default InOut Data to In-out Data to initialize Depends on data type. initialize Return Output...
  • Page 426: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions If InOut is an array, array element, structure, or structure member, the following processing is per- formed. InOut Processing Array All elements in the array are initialized. Array element Only the specified element is initialized. Structure All members in the structure are initialized. Structure member Only the specified member is initialized.
  • Page 427: Copy**Tonum (Bit String To Signed Integer)

    2 Instruction Descriptions Copy**ToNum (Bit String to Signed Integer) The Copy**ToNum instruction copies the content of a bit string directly to a signed integer. Instruction Name FB/FUN Graphic expression ST expression Copy**ToNum Bit Pattern Copy Out:=Copy**ToNum(In); (@)Copy**ToNum (Bit String to Signed Integer) Group "**"...
  • Page 428: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the CopyWordToNum instruction is for when In is WORD#16#4D2. abc:=CopyWordToNum(WORD#16#4D2); CopyWordToNum WORD#16#4D2 WORD#16#4D2 INT#1234 Out = abc (2#00000100_11010010) (WORD#2#00000100_11010010) 2-376 NY-series Instructions Reference Manual (W560)
  • Page 429: Copy**To*** (Bit String To Real Number)

    2 Instruction Descriptions Copy**To*** (Bit String to Real Number) The Copy**To*** instruction copies the content of a bit string directly to a real number. Instruction Name FB/FUN Graphic expression ST expression Copy**To*** Bit Pattern Copy Out:=CopyDwordToReal(In); (@)CopyDwordToReal (Bit String to Real Number) Group Out:=CopyLwordToLreal(In);...
  • Page 430: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The Copy**To*** instruction copies the content of copy source In directly to copy destination Out. There are two instructions depending on the data types of In and Out. Instruction DWORD REAL CopyDwordToReal LWORD LREAL CopyLwordToLreal The following example for the CopyDwordToReal instruction is for when In is DWORD#16#40200000. abc:=CopyDwordToReal(DWORD#16#40200000);...
  • Page 431: Copynumto** (Signed Integer To Bit String)

    2 Instruction Descriptions CopyNumTo** (Signed Integer to Bit String) The CopyNumTo** instruction copies the content of a signed integer directly to a bit string. Instruction Name FB/FUN Graphic expression ST expression CopyNumTo** Bit Pattern Copy Out:=CopyNumTo**(In); (@)CopyNumTo** (Signed Integer to Bit String) Group "**"...
  • Page 432: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the CopyNumToWord instruction is for when In is INT#1234. abc:=CopyNumToWord(INT#1234); CopyNumToWord INT#1234 INT#1234 WORD#16#4D2 Out = abc (2#00000100_11010010) (2#00000100_11010010) 2-380 NY-series Instructions Reference Manual (W560)
  • Page 433: Copynumto** (Signed Integer To Real Number)

    2 Instruction Descriptions CopyNumTo** (Signed Integer to Real Number) The CopyNumTo** instruction copies the content of a signed integer directly to a real number. Instruction Name FB/FUN Graphic expression ST expression CopyNumTo** Bit Pattern Copy Out:=CopyNumToReal(In); (@)CopyNumToReal (Signed Integer to Real Number) Out:=CopyNumToLreal(In);...
  • Page 434: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the CopyNumToReal instruction is for when In is DINT#1075838976. abc:=CopyNumToReal(DINT#1075838976); CopyNumToReal DINT#1075838976 DINT#1075838976 REAL#2.5 Out = abc (2#01000000_00100000_00000000_00000000) (2#01000000_00100000_00000000_00000000) 2-382 NY-series Instructions Reference Manual (W560)
  • Page 435: Copy**To*** (Real Number To Bit String)

    2 Instruction Descriptions Copy**To*** (Real Number to Bit String) The Copy**To*** instruction copies the content of a real number directly to a bit string. Instruction Name FB/FUN Graphic expression ST expression Copy**To*** Bit Pattern Copy Out:=CopyRealToDword(In); (@)CopyRealToDword (Real Number to Bit String) Group Out:=CopyLrealToLword(In);...
  • Page 436: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The Copy**To*** instruction copies the content of copy source In directly to copy destination Out. There are two instructions depending on the data types of In and Out. Instruction REAL DWORD CopyRealToDword LREAL LWORD CopyLrealToLword The following example for the CopyRealToDword instruction is for when In is REAL#2.5. abc:=CopyRealToDword(REAL#2.5);...
  • Page 437: Copy**Tonum (Real Number To Signed Integer)

    2 Instruction Descriptions Copy**ToNum (Real Number to Signed Integer) The Copy**ToNum instruction copies the content of a real number directly to a signed integer. Instruction Name FB/FUN Graphic expression ST expression Copy**ToNum Bit Pattern Copy Out:=CopyRealToNum(In); (@)CopyRealToNum (Real Number to Signed Integer) Out:=CopyLrealToNum(In);...
  • Page 438: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the CopyRealToNum instruction is for when In is REAL#2.5. abc:=CopyRealToNum(REAL#2.5); CopyRealToNum REAL#2.5 REAL#2.5 DINT#1075838976 Out = abc (2#01000000_00100000_00000000_00000000) (2#01000000_00100000_00000000_00000000) 2-386 NY-series Instructions Reference Manual (W560)
  • Page 439: Shift Instructions

    Shift Instructions Instruction Name Page AryShiftReg Shift Register 2-388 AryShiftRegLR Reversible Shift Register 2-390 ArySHL and ArySHR Array N-element Left Shift/ 2-393 Array N-element Right Shift SHL and SHR N-bit Left Shift/ 2-396 N-bit Right Shift NSHLC and NSHRC Shift N-bits Left with Carry/ 2-398 Shift N-bits Right with Carry ROL and ROR...
  • Page 440: Aryshiftreg

    2 Instruction Descriptions AryShiftReg The AryShiftReg instruction shifts a shift register one bit to the left and inserts the input value to the least-significant bit. The shift register consists of array elements. Instruction Name FB/FUN Graphic expression ST expression AryShiftReg Shift Register AryShiftReg_instance(Shift, AryShiftReg_instance...
  • Page 441: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The AryShiftReg instruction shifts Size array elements in the array of bit strings InOut[] to the left (i.e., toward most-significant bit) when Shift changes to TRUE. The shift operation starts from InOut[0]. Input value In is inserted to the least-significant bit. The most-significant bit of the array of bit strings is output to the Carry (CY) Flag (P_CY).
  • Page 442: Aryshiftreglr

    2 Instruction Descriptions AryShiftRegLR The AryShiftRegLR instruction shifts a bit string one bit to the left or right and inserts the input value to the least-significant or most-significant bit. The bit string consists of array elements. Instruction Name FB/FUN Graphic expression ST expression AryShiftRegLR Reversible Shift...
  • Page 443: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The AryShiftRegLR instruction shifts Size array elements of array of bit strings InOut[] to the left when ShiftL changes to TRUE. The shift operation starts from InOut[0]. Input value In is inserted to the least- significant bit. The most-significant bit of the array of bit strings is output to the Carry (CY) Flag (P_CY). Size elements P_CY InOut[1]...
  • Page 444: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description P_CY Carry (CY) Flag BOOL Value stored in Carry Flag Precautions for Correct Use • While Reset is TRUE, the register is not shifted even if ShiftL or ShiftR changes to TRUE. •...
  • Page 445: Aryshl And Aryshr

    2 Instruction Descriptions ArySHL and ArySHR These instructions shift array elements by one or more elements. ArySHL: Shifts the array to the left (toward the higher elements). ArySHR: Shifts the array to the right (toward the lower elements). Instruction Name FB/FUN Graphic expression ST expression...
  • Page 446: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function These instructions shift the upper Size elements in shift register array InOut[] by Num elements. The values that are shifted out of the array are discarded. The default initial value for the data type of InOut[] is stored in the empty elements. If InOut[] is an array of structures, the members of the structures in all elements are initialized.
  • Page 447: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information If InOut[] is BOOL data, the results will be the same as shifting a bit string of Size bits by Num bits. Precautions for Correct Use • The shift operation is not performed if the value of Num is 0. •...
  • Page 448: Shl And Shr

    2 Instruction Descriptions SHL and SHR These instructions shift a bit string by one or more bits. SHL: Shifts the bit string to the left (toward the higher bits). SHR: Shifts the bit string to the right (toward the lower bits). Instruction Name FB/FUN...
  • Page 449: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  SHL The SHL instruction shifts bits from right to left (from least-significant to most-significant bits). The following example is for when In is BYTE#16#89 and Num is ULINT#2. abc:=SHL(BYTE#16#89, ULINT#2); BYTE#16#89 ULINT#2 Bit 0 Bit 7 1 0 0 0 1 0 0 1 Out=abc 0 0 1 0 0 1 0 0...
  • Page 450: Nshlc And Nshrc

    2 Instruction Descriptions NSHLC and NSHRC These instructions shift an array of bit strings by one or more bits. The Carry (CY) Flag is included. NSHLC: Shifts the array to the left (toward the higher elements). NSHRC: Shifts the array to the right (toward the lower elements). Instruction Name FB/FUN...
  • Page 451: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function These instructions shift Size array elements in shift register array InOut[] by the number of bits specified in Num. The shift register starts at InOut[0]. The last bit that is shifted out of the register is output to the Carry (CY) Flag.
  • Page 452: Rol And Ror

    2 Instruction Descriptions ROL and ROR These instructions rotate a bit string by one or more bits. ROL: Rotates the bit string to the left (toward the higher bits). ROR: Rotates the bit string to the right (toward the lower bits). Instruction Name FB/FUN...
  • Page 453: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  ROL The ROL instruction rotates bits from right to left (from least-significant to most-significant bits). The following example is for when In is BYTE#16#89 and Num is ULINT#2. abc:=ROL(BYTE#16#89, ULINT#2); BYTE#16#89 ULINT#2 Bit 7 Bit 0 1 0 0 0 1 0 0 1 Out=abc 0 0 1 0 0 1 1 0...
  • Page 454: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-402 NY-series Instructions Reference Manual (W560)
  • Page 455: Conversion Instructions

    Conversion Instructions Instruction Name Page Instruction Name Page Swap Swap Bytes 2-404 FixNumToString Fixed-decimal Number-to-Text String Con- 2-451 version Reverse Sign 2-405 StringToFixNum Text String-to-Fixed-decimal Conversion 2-453 Decoder Bit Decoder 2-407 DtToString Date and Time-to-Text String Conversion 2-456 Encoder Bit Encoder 2-410 DateToString Date-to-Text String Conversion 2-458...
  • Page 456: Swap

    2 Instruction Descriptions Swap The Swap instruction swaps the upper byte and lower byte of a 16-bit value. Instruction Name FB/FUN Graphic expression ST expression Swap Swap Bytes Out:=Swap(In); (@)Swap Variables Name Meaning Description Valid range Unit Default Data to Input Data to convert Depends on data type.
  • Page 457: Neg

    2 Instruction Descriptions The Neg instruction reverses the sign of a number. Instruction Name FB/FUN Graphic expression ST expression Reverse Sign Out:=Neg(In); (@)Neg Variables Name Meaning Description Valid range Unit Default Data to Input Data to convert Depends on data type. convert Conversion Output...
  • Page 458: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is INT#123. abc:=Neg(INT#123); INT#123 Bits reversed and 1 added. −123(2#1111_1111_1000_0101) 123(2#0000_0000_0111_1011) Out = abc The following example is for when In is UINT#123. Bits reversed and 1 added. 123(2#0000_0000_0111_1011) Out = abc 65413(2#1111_1111_1000_0101) Precautions for Correct Use If you use a different data type for In and Out, make sure the valid range of Out includes the valid range...
  • Page 459: Decoder

    2 Instruction Descriptions Decoder The Decoder instruction sets the specified bit to TRUE and the other bits to FALSE in array elements that consist of a maximum of 256 bits. Instruction Name FB/FUN Graphic expression ST expression Decoder Bit Decoder Decoder(In, Size, InOut);...
  • Page 460: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions InOut[] is a BYTE array, so the ninth bit from the least-significant bit is bit 1 in InOut[1]. Therefore, bit 1 in InOut[1] is made TRUE, all other bits in InOut[1] are made FALSE, and all bits in InOut[0] are made FALSE.
  • Page 461: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • If the value of Size is 0, all bits in InOut[] change to FALSE. • Return value Out is not used when the instruction is used in ST. • An error occurs in the following cases. ENO will be FALSE, and InOut[] will not change. •...
  • Page 462: Encoder

    2 Instruction Descriptions Encoder The Encoder instruction finds the position of the highest TRUE bit in array elements that consist of a maximum of 256 bits. Instruction Name FB/FUN Graphic expression ST expression Encoder Bit Encoder Out:=Encoder(In, Size); (@)Encoder Size Variables Name Meaning...
  • Page 463: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Size is USINT#4, so 2#1001 (i.e., 9) is stored in the lower 4 bits of Out. FALSE is stored in the upper four bits of Out. def:=Encoder(abc[3], USINT#4); Encoder abc[3] USINT#4 Size In[0]=abc[3] 0 0 0 0 0 0 0 0 Size = 16 bits In[1]=abc[4]...
  • Page 464: Bitcnt

    2 Instruction Descriptions BitCnt The BitCnt instruction counts the number of TRUE bits in a bit string. Instruction Name FB/FUN Graphic expression ST expression BitCnt Bit Counter Out:=BitCnt(In); (@)BitCnt Variables Name Meaning Description Valid range Unit Default Count Input String in which to count Depends on data type.
  • Page 465: Colmtoline

    2 Instruction Descriptions ColmToLine_** The ColmToLine_** instruction extracts bit values from the specified position of array elements and out- puts them as a bit string. Instruction Name FB/FUN Graphic expression ST expression ColmToLine_** Column to Line Out:=ColmToLine_**(In, (@)ColmToLine_** Conversion Group Size, Pos);...
  • Page 466: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example shows the ColmToLine_BYTE instruction when Pos is USINT#3 and Size is USINT#4. def:=ColmToLine_BYTE(abc[3], USINT#4, USINT#3); ColmToLine_BYTE abc[3] Size USINT#4 USINT#3 Pos= Most-significant bit Bit 0 USINT#3 0 0 0 0 0 0 0 0 0 0 0 0 In[0]=abc[3] 0 0 0 0 0 0 In[1]=abc[4]...
  • Page 467: Linetocolm

    2 Instruction Descriptions LineToColm The LineToColm instruction takes the bits from a bit string and outputs them to the specified bit position in array elements. Instruction Name FB/FUN Graphic expression ST expression LineToColm Line to Column LineToColm(In, InOut, Size, (@)LineToColm Conversion Pos);...
  • Page 468: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions First, Size bits are extracted from the least-significant bit of data to convert In. These bits are treated individually. Then, the bits are stored in conversion result array InOut[] in the Pos bit of the elements starting from InOut[0]. Size specifies the number of array elements to receive bits. The values of all bits for which values are not stored are retained.
  • Page 469: Gray

    2 Instruction Descriptions Gray The Gray instruction converts a gray code into an angle. Instruction Name FB/FUN Graphic expression ST expression Gray Gray Code Conver- Out:=Gray(In, Resolution, (@)Gray sion ERC, ZPC); Resolution Variables Name Meaning Description Valid range Unit Default Data to Gray code to convert Depends on data type.
  • Page 470: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of Resolution is enumerated type _eGRY_RESOLUTION. The meaning of the enumera- tors are as follows: Enumerator Meaning _R256 _R1B 1-bit (2) _R2B 2-bit (4) _R3B 3-bit (8) _R4B 4-bit (16) _R5B 5-bit (32) _R6B 6-bit (64) _R7B 7-bit (128)
  • Page 471: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Using the Gray code enables prevention of instantaneously incorrect output values because only one bit in the Gray code will change when the output value of the encoder is incremented or decremented by 1. The following figure shows the difference in the output value from an encoder for the Gray code and Binary code.
  • Page 472: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions ZPC: Zero Point Correction The ZPC variable is set to offset the zero position of the rotary encoder. For example, to offset the zero position for a rotary encoder with a resolution of 256, the value of ZPC would be 256 × (90/360), or 64. Notation Example The following example is for when In is WORD#16#1A9, Resolution is _R10B, ERC is UINT#0, and ZPC is UINT#337.
  • Page 473: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Converting from Gray Code to Binary Code The following processing can be used to convert from Gray code to Binary code. The logic symbols in the figure represent logical exclusive ORs. Conversion Circuit for Five Bits Binary code Gray code Precautions for Correct Use An error occurs in the following cases.
  • Page 474: Utf8Tosjis

    2 Instruction Descriptions UTF8ToSJIS The UTF8ToSJIS instruction converts a UTF-8 text string to a SJIS BYTE array. Instruction Name FB/FUN Graphic expression ST expression UTF8ToSJIS UTF-8 to SJIS Out:=UTF8ToSJIS(In, (@)UTF8ToSJIS Character Code SJISCode); Conversion SJISCode Variables Name Meaning Description Valid range Unit Default Text string...
  • Page 475: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is def:=UTF8ToSJIS( , abc[0]); UTF8ToSJIS SJISCode abc[0] abc[0] SJISCode[0]=abc[0] BYTE#16#82 SJISCode[1]=abc[1] BYTE#16#A0 Out=def UINT#2 Precautions for Correct Use • NULL characters at the end of In are not converted. They are also not counted for the number of con- verted elements.
  • Page 476: Sjistoutf8

    2 Instruction Descriptions SJISToUTF8 The SJISToUTF8 instruction converts a SJIS BYTE array to a UTF-8 text string. Instruction Name FB/FUN Graphic expression ST expression SJISToUTF8 SJIS to UTF-8 Out:=SJISToUTF8(In, Size); (@)SJISToUTF8 Character Code Conversion Size Variables Name Meaning Description Valid range Unit Default In[] (array)
  • Page 477: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In[0] is BYTE#16#82, In[1] is BYTE#16#A0, and Size is UINT#2. def:=SJISToUTF8(abc[0], UINT#2); SJISToUTF8 abc[0] UINT#2 Size BYTE#16#82 In[0]=abc[0] Out=def BYTE#16#A0 In[1]=abc[1] Size UINT#2 Precautions for Correct Use • If the value of Size is 0, Out is a text string containing only the NULL character. •...
  • Page 478: Pwlapprox And Pwlapproxnolinechk

    2 Instruction Descriptions PWLApprox and PWLApproxNoLineChk The PWLApprox and PWLApproxNoLineChk instructions perform broken line approximations for inte- ger or real number data. PWLApprox: Checks to see if the broken line data is valid. PWLApproxNoLineChk: Does not check to see if the broken line data is valid. Instruction Name FB/FUN...
  • Page 479: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The PWLApprox and PWLApproxNoLineChk instructions perform approximation for data to convert In. The approximation is based on broken line data that consists of Num times 2 elements that start with Line[0,0] in broken line data array Line[]. As shown below, the Y coordinate that corresponds to the X coordinate In of the broken line data is assigned to conversion result Out.
  • Page 480: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Num-2 Num-2 Num-1 Num-1 Using a Three-dimensional Array for Line[] Using a Two-dimensional Array for Line[] Line[0,0,0] Line[0,0] Line[0,0,1] Line[0,1] Line[0,1,0] Line[1,0] Line[0,1,1] Line[1,1] Line[0,2,0] Line[2,0] Line[0,2,1] Line[2,1] Line[0, Num-1,0] Num-1 Num-1 Line[Num-1,0] Num-1 Line[0, Num-1,1] Line[Num-1,1] Num-1 Notation Example An example of approximation when the value of In is LREAL#3.0 for broken line data array abc[] with...
  • Page 481: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions (abc[1,0],abc[1,1])=(2.0,6.0) (abc[0,0],abc[0,1])=(1.0,5.0) Out=def=LREAL#4.0 (abc[3,0],abc[3,1])=(5.0,3.0) (abc[2,0],abc[2,1])=(4.0,2.0) In=LREAL#3.0 Difference between the PWLApprox and PWLApproxNoLineChk Instructions The PWLApprox and PWLApproxNoLineChk instructions are different in whether the validity of In and Line[] are checked. This also makes the processing times different. The specifications of both instruc- tions are given in the following table.
  • Page 482: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions In the previous example, the processing time will be shorter for the value of In (LREAL#3.0) if the values of the X coordinates in the elements of the broken line data array consist of only the four elements that are close to 3.0 (abc[1,0],abc[1,1])=(2.0,6.0) and (abc[2,0],abc[2,1])=(4.0,2.0).
  • Page 483: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • If the value of In is smaller than the value of Line[0,0] (i.e., the value of X ), then the value of Out will be the value of Line[0,1] (i.e., the value of Y •...
  • Page 484: Pwllinechk

    2 Instruction Descriptions PWLLineChk The PWLLineChk instruction is used to check whether the X coordinates in the broken line data that is used for a Broken Line Approximation without Broken Line Data Check instruction are in ascending order. Instruction Name Graphic expression ST expression PWLLineChk...
  • Page 485: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Num-2 Num-2 Num-1 Num-1 Using a Three-dimensional Array for Line[] Using a Two-dimensional Array for Line[] Line[0,0,0] Line[0,0] Line[0,0,1] Line[0,1] Line[0,1,0] Line[1,0] Line[0,1,1] Line[1,1] Line[0,2,0] Line[2,0] Line[0,2,1] Line[2,1] Line[0, Num-1,0] Num-1 Num-1 Line[Num-1,0] Num-1 Line[0, Num-1,1] Line[Num-1,1] Num-1 Notation Example An example of determining whether the X coordinates are in ascending order in the broken line data...
  • Page 486: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions (abc[0,0],abc[0,1])=(1.0,5.0) (abc[1,0],abc[1,1])=(6.0,6.0) The X coordinates are not in ascending order. (abc[3,0],abc[3,1])=(5.0,3.0) (abc[2,0],abc[2,1])=(4.0,2.0) Additional Information • Use the PWLLineChk in combination with the PWLApproxNoLineChk instruction. Refer to PWLAp- prox and PWLApproxNoLineChk Instructions (page 2-426) for details on the PWLApproxNoLineChk instruction.
  • Page 487: Movingaverage

    2 Instruction Descriptions MovingAverage The MovingAverage instruction calculates a moving average. Instruction Name FB/FUN Graphic expression ST expression MovingAverage Moving Average Out:=MovingAverage(In, (@)MovingAverage CurIndex, Buf, BufSize, Q); CurIndex BufSize Variables Name Meaning Description Valid range Unit Default Input value Number to include in aver- Input Depends on data type.
  • Page 488 2 Instruction Descriptions Function The MovingAverage instruction stores the value of input value In in input value storage array Buf[] each time it is executed. It stores the average of the stored values in calculation result Out. Specify the maxi- mum number of elements to include in the average with BufSize.
  • Page 489 2 Instruction Descriptions Inputting Numbers Up to BufSize Each time the instruction is executed, the value of In is stored in Buf[CurIndex]. The average of CurIn- dex + 1 numbers that start from Buf[0] is calculated and stored in Out. When the number of instruction executions reaches BufSize, the value of Q changes to TRUE.
  • Page 490 2 Instruction Descriptions Initializing the Stored Values − If the value of CurIndex is set to 0 before the instruction is executed, the values in Buf[0] to Buf[BufSize 1] are set to 0 and the current value of In is stored again in Buf[0]. The value of CurIndex changes to 1 and the value of Q changes to FALSE.
  • Page 491 2 Instruction Descriptions Sample Programming This sample shows how to eliminate the effect of noise and other disturbances in analog input data, e.g., from a sensor. It assigns the average (DataAve) of the last 25 values of the input data (InputData) to the input data (InputDataForOperating) for the next process.
  • Page 492 2 Instruction Descriptions Variable Data type Initial value Comment Trigger BOOL FALSE Execution condition LastTrigger BOOL FALSE Value of Trigger from previous task period Operating BOOL FALSE Processing OperatingStart BOOL FALSE Processing started Buffer ARRAY[0..24] OF INT [25(0)] Input value storage array InputData Input value DataAve...
  • Page 493: Dispartreal

    2 Instruction Descriptions DispartReal The DispartReal instruction separates a real number into the signed mantissa and the exponent. Instruction Name FB/FUN Graphic expression ST expression DispartReal Separate Mantissa Out:=DispartReal(In, (@)DispartReal and Exponent Fraction, Exponent); Fraction Exponent Variables Name Meaning Description Valid range Unit Default...
  • Page 494: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is REAL data with a value of REAL#−123.456. DispartReal(REAL#−123.456, abc, def); DispartReal REAL#−123.456 Fraction Exponent Signed mantissa −1234560 Fraction = abc REAL#−123.456 Exponent −4 Exponent = def The following example is for when In is LREAL data with a value of LREAL#−123.456789. DispartReal(LREAL#−123.456789, abc, def);...
  • Page 495: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If the number of valid digits in In exceeds the number of valid digits of Fraction, the value is rounded to fit in the valid range of Fraction. The following table shows how values are rounded. Value of fractional part Treatment Examples...
  • Page 496: Unitereal

    2 Instruction Descriptions UniteReal The UniteReal instruction combines a signed mantissa and exponent to make a real number. Instruction Name FB/FUN Graphic expression ST expression UniteReal Combine Real Out:=UniteReal(Fraction, (@)UniteReal Number Mantissa Exponent); and Exponent Fraction Exponent Variables Name Meaning Description Valid range Unit...
  • Page 497: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information Use the DispartReal instruction (page 2-441) to separate a real number into the signed mantissa and exponent. Precautions for Correct Use • Depending on the values of Fraction and Exponent, error may occur in the conversion from an integer to a real number.
  • Page 498: Numtodecstring And Numtohexstring

    2 Instruction Descriptions NumToDecString and NumToHexString NumToDecString: Converts an integer to a fixed-length decimal text string. NumToHexString: Converts an integer to a fixed-length hexadecimal text string. Instruction Name FB/FUN Graphic expression ST expression NumToDecString Fixed-length Out:=NumToDecString(In, (@)NumToDecString Decimal Text String L, Fill);...
  • Page 499: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  NumToHexString The NumToHexString instruction converts integer In to a hexadecimal text string of UTF-8 alphanu- meric characters. If In is negative, it is expressed in its two’s complement (bits inverted and then 1 added). For either instruction, the number of characters in text string Out is adjusted to number of characters L. If there are not enough characters, the upper digits are filled with fill character Fill.
  • Page 500: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • If the value of L is 0, Out is a text string containing only the NULL character. • If the number of characters in the conversion result exceeds the value of L, L characters from the lower characters of the conversion result are stored in Out.
  • Page 501: Hexstringtonum

    2 Instruction Descriptions HexStringToNum_** The HexStringToNum_** instruction converts a hexadecimal text string to an integer. Instruction Name FB/FUN Graphic expression ST expression Hex- Hexadecimal Text Out:=HexStringToNum_**(In); (@)HexStringToNum_** StringToNu String-to-Number "**" must be an integer data m_** Conversion Group type. "**" must be an integer data type. Variables Name Meaning...
  • Page 502: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Even if the conversion result exceeds the valid range of Out, an error will not occur. The value of Out will be an illegal value. • An error occurs in the following cases. ENO will be FALSE, and Out will not change. •...
  • Page 503: Fixnumtostring

    2 Instruction Descriptions FixNumToString The FixNumToString instruction converts a signed fixed-decimal number to a decimal text string. Instruction Name FB/FUN Graphic expression ST expression FixNumToString Fixed-decimal Out:=FixNumToString(In, (@)FixNumToString Number-to-Text Zero); String Conversion Zero Variables Name Meaning Description Valid range Unit Default Fixed- Signed fixed-decimal...
  • Page 504: Ny-Series Instructions Reference Manual (W560

    16#0001462C ‘83.500’ ‘83.5’ (10#83500) 16#00051AA4 ‘334.500’ ‘334.5’ (10#334500) 16#0003BEFC ‘245.500’ ‘245.5’ (10#245500) Additional Information The format for fixed-point decimal numbers is the same as the fixed-decimal output format of the OMRON FZ-series Vision Sensors. 2-452 NY-series Instructions Reference Manual (W560)
  • Page 505: Stringtofixnum

    2 Instruction Descriptions StringToFixNum The StringToFixNum instruction converts a decimal text string to a signed fixed-decimal number. Instruction Name FB/FUN Graphic expression ST expression StringToFixNum Text String-to- Out:=StringToFixNum(In); (@)StringToFixNum Fixed-decimal Conversion Variables Name Meaning Description Valid range Unit Default Decimal text Input Decimal text string Depends on data type.
  • Page 506: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions In = abc Out = def ‘83.5’ 16#0001462C (10#83500) ‘334.5’ 16#00051AA4 (10#334500) ‘245.5’ 16#0003BEFC (10#245500) The format of the text sting in In is given below. i i i i . f f f f f f f f e + n n Integer Sign Fractional part...
  • Page 507: Ny-Series Instructions Reference Manual (W560

    00003E8 Additional Information The format for fixed-point decimal numbers is the same as the fixed-decimal output format of the OMRON FZ-series Vision Sensors. Precautions for Correct Use • The digits after the third decimal digit are truncated in In. • Underbars (16#5F) in the text string in In are ignored.
  • Page 508: Dttostring

    2 Instruction Descriptions DtToString The DtToString instruction converts a date and time to a text string. Instruction Name FB/FUN Graphic expression ST expression DtToString Date and Out:=DtToString(In); (@)DtToString Time-to-Text String Conversion Variables Name Meaning Description Valid range Unit Default Date and Input Date and time Depends on data type.
  • Page 509: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information Out is in nanoseconds. To get a text string in seconds or milliseconds, combine this instruction with the LEFT or RIGHT instruction (page 2-550). An example to get a text string in seconds is given below. P_On DtToString DT#2000-01-23-01:23:45.678...
  • Page 510: Datetostring

    2 Instruction Descriptions DateToString The DateToString instruction converts a date to a text string. Instruction Name FB/FUN Graphic expression ST expression DateToString Date-to-Text String Out:=DateToString(In); (@)DateToString Conversion Variables Name Meaning Description Valid range Unit Default Date Input Date Depends on data type. Year, month, D#1970-1-1 Text string...
  • Page 511: Todtostring

    2 Instruction Descriptions TodToString The TodToString instruction converts a time of day to a text string. Instruction Name FB/FUN Graphic expression ST expression TodToString Time of Day-to-Text Out:=TodToString(In); (@)TodToString String Conversion Variables Name Meaning Description Valid range Unit Default Time of day Input Time of day Depends on data type.
  • Page 512: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information Out is in nanoseconds. To get a text string in seconds or milliseconds, combine this instruction with the LEFT or RIGHT instruction (page 2-550). An example to get a text string in seconds is given below. TodToString TOD#01:23:45.678 LEFT...
  • Page 513: Graytobin_** And Bintogray

    2 Instruction Descriptions GrayToBin_** and BinToGray_** GrayToBin_**: Converts a gray code to a bit string. BinToGray_**: Converts a bit string to a gray code. Instruction Name FB/FUN Graphic expression ST expression GrayToBin_** Gray Code-to- Out:=GrayToBin_**(In); (@)GrayToBin_** Binary Code Conversion Group "**"...
  • Page 514: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the GrayToBin_BYTE instruction is for when In is BYTE#16#A5. abc:=GrayToBin_BYTE(BYTE#16#A5); GrayToBin_BYTE BYTE#16#A5 Most-significant Bit 0 XOR XOR XOR XOR XOR XOR Out = abc  BinToGray_** The BinToGray_** instructions convert the bit string in data to convert In to a gray code. The conversion procedure is as follows for when In and Out are BYTE data.
  • Page 515: Stringtoary

    2 Instruction Descriptions StringToAry The StringToAry instruction converts a text string to a BYTE array. Instruction Name FB/FUN Graphic expression ST expression StringToAry Text String-to-Array Out:=StringToAry(In, (@)StringToAry Conversion AryOut); AryOut Variables Name Meaning Description Valid range Unit Default Text string Input Text string Depends on data type.
  • Page 516: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is ‘XYZ’. def:=StringToAry(’XYZ’, abc[1]); StringToAry ‘XYZ’ AryOut abc[1] abc[1] Character code for ‘X’ AryOut[0]=abc[1] 16#58 Character code for ‘Y’ 16#59 ‘XYZ’ AryOut[1]=abc[2] Character code for ‘Z’ 16#5A AryOut[2]=abc[3] Out=def UINT#3 Precautions for Correct Use •...
  • Page 517: Arytostring

    2 Instruction Descriptions AryToString The AryToString instruction converts a BYTE array to a text string. Instruction Name FB/FUN Graphic expression ST expression AryToString Array-to-Text String Out:=AryToString(In, Size); (@)AryToString Conversion Size Variables Name Meaning Description Valid range Unit Default In[] (array) BYTE array BYTE array Depends on data type.
  • Page 518: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Size is UINT#3. def:=AryToString(abc[1], UINT#3); AryToString abc[1] UINT#3 Size Character code for ‘V’ In[0]=abc[1] 16#56 Character code for ‘W’ 16#57 Out = def ‘VWX’ In[1]=abc[2] Size = UINT#3 Character code for ‘X’ 16#58 In[2]=abc[3] Character code for ‘Y’...
  • Page 519: Dispartdigit

    2 Instruction Descriptions DispartDigit The DispartDigit instruction separates a bit string into 4-bit units. Instruction Name FB/FUN Graphic expression ST expression DispartDigit Four-bit Separation DispartDigit(In, Num, (@)DispartDigit AryOut); AryOut Variables Name Meaning Description Valid range Unit Default Data to separate Bit string to separate Depends on data type.
  • Page 520: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Num is USINT#3. DispartDigit(abc, USINT#3, def[1]); DispartDigit USINT#3 AryOut def[1] def[1] Num=USINT#3 Highest digit Digit 2 Digit 1 Digit 0 In=abc Bits Bits 0 to 3 4 to 7 AryOut[0]=def[1] AryOut[1]=def[2] Num=USINT#3 AryOut[2]=def[3] 16#0...
  • Page 521: Unitedigit

    2 Instruction Descriptions UniteDigit_** The UniteDigit_** instructions join 4-bit units of data into a bit string. Instruction Name FB/FUN Graphic expression ST expression UniteDigit_** Four-bit Join Group Out:=UniteDigit_**(In, (@)UniteDigit_** Num); "**" must be a bit string data type. "**" must be a bit string data type. Variables Name Meaning...
  • Page 522: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example shows the UniteDigit_WORD instruction when Num is USINT#3. def:=UniteDigit_WORD(abc[1], USINT#3); UniteDigit_WORD abc[1] USINT#3 Bits Bits 4 to 7 0 to 3 In[0]=abc[1] In[1]=abc[2] Num=USINT#3 In[2]=abc[3] In[3]=abc[4] Highest digit Digit 2 Digit 1 Digit 0 Out=def Num=USINT#3 16#0...
  • Page 523: Dispart8Bit

    2 Instruction Descriptions Dispart8Bit The Dispart8Bit instruction separates a bit string into individual bytes. Instruction Name FB/FUN Graphic expression ST expression Dispart8Bit Byte Data Dispart8Bit(In, Num, (@)Dispart8Bit Separation AryOut); AryOut Variables Name Meaning Description Valid range Unit Default Data to separate Bit string to separate Depends on data type.
  • Page 524: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Num is USINT#3. Dispart8Bit(abc, USINT#3, def[1]); Dispart8Bit USINT#3 AryOut def[1] def[1] Num=USINT#3 Highest byte Byte 2 Byte 1 Byte 0 In=abc AryOut[0]=def[1] AryOut[1]=def[2] Num=USINT#3 AryOut[2]=def[3] Additional Information Use the Unite8Bit_** instruction (page 2-473) to join 1-byte units from array elements. Precautions for Correct Use •...
  • Page 525: Unite8Bit

    2 Instruction Descriptions Unite8Bit_** The Unite8Bit_** instructions join bytes of data into a bit string. Instruction Name FB/FUN Graphic expression ST expression Unite8Bit_** Byte Data Join Out:=Unite8Bit_**(In, Num); (@)Unite8Bit_** Group "**" must be a bit string data type. "**" must be a bit string data type. Variables Name Meaning...
  • Page 526: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example shows the Unite8Bit_DWORD instruction when Num is USINT#3. def:=Unite8Bit_DWORD(abc[1], USINT#3); Unite8Bit_DWORD abc[1] USINT#3 In[0]=abc[1] In[1]=abc[2] Num=USINT#3 In[2]=abc[3] In[3]=abc[4] Highest Byte 2 Byte 1 Byte 0 byte Out=def Num=USINT#3 16#00 Additional Information Use the Dispart8Bit instruction (page 2-471) to separate a bit string into 1-byte units. Precautions for Correct Use •...
  • Page 527: Toarybyte

    2 Instruction Descriptions ToAryByte The ToAryByte instruction separates a variable into bytes and stores the bytes in a BYTE array. Instruction Name FB/FUN Graphic expression ST expression ToAryByte Conversion to Byte Out:=ToAryByte(In, Order, (@)ToAryByte Array AryOut); Order AryOut Variables Name Meaning Description Valid range...
  • Page 528: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions When the Data Type of In Is Two Bytes or Larger If the data type of In is two bytes or larger, In is separated into bytes and stored in AryOut[]. The follow- ing data types have two bytes or more. Classification Data type Bit strings...
  • Page 529: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is the same as above and Order is _HIGH_LOW. In[0] DWORD#16#01234567 AryOut[0] 16#45 In[1] DWORD#16#89ABCDEF AryOut[1] 16#67 In[2] DWORD#16#CCDDEEFF AryOut[2] 16#01 AryOut[3] 16#23 AryOut[4] 16#CD AryOut[5] 16#EF Out = UINT#12 AryOut[6] 16#89 16#AB...
  • Page 530: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions When In Is BOOL Data If the data type of In is BOOL (one bit), data is stored in AryOut[] as described below. Value of In (array or not) Storage method in AryOut[] Order Not an array The logical OR of the value of In and 16#00 is stored in AryOut[0].
  • Page 531: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is the same as above and Order is _HIGH_LOW. AryOut[0] 16#45 In[0] TRUE In[1] AryOut[1] 16#89 FALSE Out = UINT#4 AryOut[2] In[2] 16#00 FALSE AryOut[3] In[3] TRUE 16#04 In[4] FALSE In[5] FALSE In[6]...
  • Page 532: Arybyteto

    2 Instruction Descriptions AryByteTo The AryByteTo instruction joins BYTE array elements and stores the result in a variable. Instruction Name FB/FUN Graphic expression ST expression AryByteTo Conversion from AryByteTo(In, Size, Order, (@)AryByteTo Byte Array OutVal); Size Order OutVal Variables Name Meaning Description Valid range...
  • Page 533: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Order specifies the order to join the elements of In[]. The data type of Order is enumerated type _eBYTE_ORDER. The meaning of the enumerators are as follows: Enumerators Meaning _LOW_HIGH Lower byte first, higher byte last _HIGH_LOW Higher byte first, lower byte last When the Data Type of OutVal Is Two Bytes or Larger If the data type of OutVal is two bytes or larger, elements from In[] are joined so that the result is just...
  • Page 534: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when OutVal is the same as above, Size is UINT#4, and Order is _HIGH_LOW. In[0] BYTE#16#67 DWORD#16#23016745 OutVal In[1] BYTE#16#45 Size = UINT#4 In[2] BYTE#16#23 In[3] BYTE#16#01 When the Data Type of OutVal Is One Byte If the data type of OutVal is one byte, one byte of In[] is stored directly in OutVal.
  • Page 535: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions When OutVal Is BOOL Data If the data type of OutVal is BOOL (one bit), data is stored in OutVal as described below. Value of OutVal Storage method in OutVal Order (array or not) Not an array Value of bit 0 of In[0] is stored in OutVal.
  • Page 536: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when OutVal and Size are the same as above and Order is _HIGH_LOW. In[0] BYTE#16#89 TRUE OutVal[0] In[1] Size = UINT#3 OutVal[1] BYTE#16#45 FALSE In[2] BYTE#16#04 TRUE OutVal[2] FALSE OutVal[3] OutVal[4] FALSE OutVal[5] FALSE OutVal[6]...
  • Page 537: Sizeofary

    2 Instruction Descriptions SizeOfAry The SizeOfAry instruction gets the number of elements in an array. Instruction Name FB/FUN Graphic expression ST expression SizeOfAry Get Number of Out:=SizeOfAry(In); (@)SizeOfAry Array Elements Variables Name Meaning Description Valid range Unit Default In[] (array) Array Input Array...
  • Page 538: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information In[] can be an array with two or more dimensions. Out will contain the total number of elements for all dimensions of In[]. For example, if the input parameter that is passed to In[] is ARRAY[0..1,0..2], the value of Out will be UINT#6.
  • Page 539: Packword

    2 Instruction Descriptions PackWord The PackWord instruction joins two 1-byte data into a 2-byte data. Instruction Name Graphic expression ST expression (@)PackWord PackWord 2-byte Join Out:=PackWord(High,Low); High Version Information A CPU Unit with unit version 1.12 or later and Sysmac Studio version 1.16 or higher are required to use this instruction.
  • Page 540: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The PackWord instruction joins two 1-byte data into a 2-byte data. The data specified in High is stored in bit 15-8, and the data specified in Low is stored in bit 7-0. The following example shows the instruction when High is 16#12 and Low is 16#34. The value of variable abc will be 16#1234.
  • Page 541: Packdword

    2 Instruction Descriptions PackDword The PackDword instruction joins four 1-byte data into a 4-byte data. Instruction Name Graphic expression ST expression Out:=PackDword( (@)PackDword HighHigh, HighHigh PackDword 4-byte Join HighLow, HighLow LowHigh, LowHigh LowLow); LowLow Version Information A CPU Unit with unit version 1.12 or later and Sysmac Studio version 1.16 or higher are required to use this instruction.
  • Page 542: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The PackDword instruction joins four 1-byte data into a 4-byte data. The data specified in HighHigh is stored in bit 31-24, the data specified in HighLow in bit 23-16, the data specified in LowHigh in bit 15-8, and the data specified in LowLow in bit 7-0. The following example shows the instruction when HighHigh is 16#12, HighLow is 16#34, LowHigh is 16#56, and LowLow is 16#78.
  • Page 543: Stack And Table Instructions

    Stack and Table Instructions Instruction Name Page StackPush Push onto Stack 2-492 StackFIFO and StackLIFO First In First Out/Last In First Out 2-501 StackIns Insert into Stack 2-504 StackDel Delete from Stack 2-506 RecSearch Record Search 2-508 RecRangeSearch Range Record Search 2-513 RecSort Record Sort...
  • Page 544: Stackpush

    2 Instruction Descriptions StackPush The StackPush instruction stores a value at the top of a stack. Instruction Name FB/FUN Graphic expression ST expression StackPush Push onto Stack StackPush(In, InOut, Size, (@)StackPush Num); InOut Size Variables Name Meaning Description Valid range Unit Default Input value...
  • Page 545: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The instruction assumes that there are number of stored elements Num elements stored in stack array InOut[]. Input value In is written to the next element, InOut[Num]. Then, Num is incremented. For num- ber of stack elements Size, specify the number of elements in InOut[] to use as a stack. The following example is for when Size is UINT#5 and Num is UINT#2.
  • Page 546: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming The array variable StcA[0..9] is used as a stack. As preparations, three values (UINT#1111, UINT#2222, and UINT#3333) are stored in the stack. StcA[0] 1111 StcA[1] 2222 StcA[2] 3333 StcA[3] StcA[4] StcA[5] StcA[6] StcA[7] StcA[8] StcA[9] The StackPush instruction is used to store a new value (UINT#4444) at the top of the stack StcA[3].
  • Page 547: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Finally, the StackIns instruction is used to insert a value (UINT#5555) between StcA[1] and StcA[2]. That means there will be four values in the stack. StackIns instruction executed. StcANum UINT#3 StcANum UINT#4 StcA[0] StcA[0] 1111 1111 StcA[1] 2222 StcA[1] 2222...
  • Page 548: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Initialize stack. Inline ST InitStc Note: The contents of the inline ST are given below. Store three values in stack. InitStc StackPush UINT#1111 InOut StcA[0] StcASize Size StcANum StackPush UINT#2222 InOut StcA[0] StcASize Size StcANum StackPush UINT#3333 InOut StcA[0] StcASize...
  • Page 549: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Add data with StackPush instruction. StcAPushStat StackPush_err StackPush StcAinVal InOut StcA[0] StcASize Size StcANum Processing after normal end of StackPush Inline ST StackPush_err StcAPushStat 1 // Processing after normal end of StackPush Processing after error end of StackPush Inline ST StackPush_err StcAPushStat...
  • Page 550: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Insert data with StackIns instruction. StcAInsStat StackIns_err StackIns StcAInsVal InOut StcA[0] StcASize Size StcANum StcAOffset Offset Processing after normal end of StackIns Inline ST StackIns_err StcAInsStat 1 // Processing after normal end of StackIns Processing after error end of StackIns Inline ST StackIns_err StcAInsStat...
  • Page 551: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Initial value Comment InitStc BOOL FALSE Stack initialization condition preInitStc BOOL FALSE Value of InitStc from previous task period StcANum UINT Number of stored elements StcA ARRAY[0..9] OF UINT [10(0)] Stack array StcASize UINT Number of stack elements StcAPushStat BOOL...
  • Page 552: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions IF (StcAPush_OK=TRUE) THEN StcAPushNormalEnd:=TRUE; // Processing after normal end ELSE StcAPushErrorEnd :=TRUE; // Processing after error end END_IF; END_IF; preStcAPushStat:=StcAPushStat; // Remove data with StackLIFO instruction. IF ( (StcALIFOStat=TRUE) AND (preStcALIFOStat=FALSE) ) THEN StackLIFO( InOut :=StcA[0], // First element in stack array OutVal :=StcAOutVal, // Value removed from stack Size...
  • Page 553: Stackfifo And Stacklifo

    2 Instruction Descriptions StackFIFO and StackLIFO StackFIFO: Removes the bottom value from a stack. StackLIFO: Removes the top value from a stack. Instruction Name FB/FUN Graphic expression ST expression StackFIFO First In First Out StackFIFO(InOut, OutVal, (@)StackFIFO Size, Num); InOut OutVal Size StackLIFO...
  • Page 554: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings Size OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK InOut[] (array) Arrays of enumerations or structures can also be specified. OutVal Must be the same data type as the elements of InOut[].
  • Page 555: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  StackLIFO The StackLIFO instruction removes the top value from a stack. Value of InOut[Num−1] is assigned to OutVal. Then, Num is decremented. The following example is for when Size is UINT#5 and Num is UINT#2. StackLIFO(abc[1], def, UINT#5, ghi); StackLIFO InOut abc[1]...
  • Page 556: Stackins

    2 Instruction Descriptions StackIns The StackIns instruction inserts a value at a specified position in a stack. Instruction Name FB/FUN Graphic expression ST expression StackIns Insert into Stack StackIns(In, InOut, Size, (@)StackIns Num, Offset); InOut Size Offset Variables Name Meaning Description Valid range Unit...
  • Page 557: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The instruction assumes that there are number of stored elements Num elements stored in stack array InOut[]. Insert value In is inserted at the position specified by the offset Offset (InOut[Offset]). All higher elements, i.e., InOut[Offset] to InOut[Num−1], are moved to the next higher element in the stack array. Then, Num is incremented.
  • Page 558: Stackdel

    2 Instruction Descriptions StackDel The StackDel instruction deletes a value from a specified position in a stack. Instruction Name FB/FUN Graphic expression ST expression StackDel Delete from Stack StackDel(InOut, Size, Num, (@)StackDel Offset); InOut Size Offset Variables Name Meaning Description Valid range Unit Default...
  • Page 559: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Size is UINT#6, Num is UINT#3 and Offset is UINT#1. StackDel(abc[1], UINT#6, def, UINT#1); StackDel InOut abc[1] abc[1] Size UINT#6 UINT#1 Offset Decremented. Num = def UINT#3 Num=def UINT#2 InOut[0]=abc[1] Offset=UINT#1 InOut[0]=abc[1] 1234 1234...
  • Page 560: Recsearch

    2 Instruction Descriptions RecSearch The RecSearch instruction searches an array of structures for elements that match the search key with the specified method. Instruction Name FB/FUN Graphic expression ST expression RecSearch Record Search Out:=RecSearch(In, Size, (@)RecSearch Member, Key, Mode, InOutPos, Num); Size Member Mode...
  • Page 561: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings In[] (array) Specify an array of structures. Size Member OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK Specify the same data type as the search member of In[] Must be the same data type as Member.
  • Page 562: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when Size is UINT#5, Key is INT#1234 and Mode is _LINEAR. ghi:=RecSearch(abc[0], UINT#5, abc[0].m, INT#1234, _LINEAR, def[0], jkl); RecSearch abc[0] Size UINT#5 Member abc[0].m INT#1234 Mode _LINEAR InOutPos def[0] def[0] Member=abc[0].m INT#1234 Mode=_LINEAR 0000 In[0]=abc[0]...
  • Page 563: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Using the same example as before, the order of the array elements and the processing results will be as shown below for an ascending binary search. INT#1234 Mode=_BIN_ASC Matches 0000 Out = ghi TRUE In[0]=abc[0] 1234 0000 InOutPos[0] = def[0] UINT#0...
  • Page 564: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If In[] is a three-dimensional array, the element number in the first dimension of the element that matches the search conditions is assigned to InOutPos[0], the element number in the second dimen- sion is assigned to InOutPos[1], and the element number in the third dimension is assigned to InOut- Pos[2].
  • Page 565: Recrangesearch

    2 Instruction Descriptions RecRangeSearch The RecRangeSearch instruction searches an array of structures for elements that match the search condition range with the specified method. Instruction Name FB/FUN Graphic expression ST expression RecRangeSearch Range Record Out:=RecRangeSearch(In, (@)RecRangeSearch Search Size, Member, MN, MX, Condition, Mode, InOutPos, Num);...
  • Page 566: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings In[] (array) Specify an array of structures. Size Member OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK Specify the same data type as the search member of In[]. Must be the same data type as Member.
  • Page 567: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of search method Mode is enumerated type _eSEARCH_MODE. The meaning of the enumerators are as follows: Enumerator Meaning _LINEAR Linear search _BIN_ASC Ascending binary search _BIN_DESC Descending binary search For a linear search, the search is performed in order from the first element of In[]. The following example is for when Size is UINT#5, MN is INT#1000, MX is INT#2000, Condition is _EQ_BOTH and Mode is _LINEAR.
  • Page 568: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Using the same example as before, the order of the array elements and the processing results will be as shown below for an ascending binary search. INT#1000 Condition=_EQ_BOTH INT#2000 Mode=_BIN_ASC Out = ghi Matches 0000 TRUE In[0]=abc[0] 1234 0000 InOutPos[0] =...
  • Page 569: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • In[] can be a member of a higher-level structure. Example: In[0]=str0.str1[0] • In[] can be an array with two or more dimensions. If In[] is a two-dimensional array, the element num- ber in the first dimension of the element that matches the search conditions is assigned to InOut- Pos[0] and the element number in the second dimension is assigned to InOutPos[1].
  • Page 570: Recsort

    2 Instruction Descriptions RecSort The RecSort instruction sorts the elements of an array of structures. Instruction Name FB/FUN Graphic expression ST expression RecSort Record Sort RecSort_instance(Execute, RecSort_instance InOut, Size, Member, Order, RecSort Done, Busy, Error); Execute Done InOut Size Busy Member Error Order Variables...
  • Page 571: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function When the value of Execute is TRUE, Size elements of InOut[] (a structure array) is sorted. Specifically, − the elements from InOut[0] to InOut[Size 1] are sorted. Specifically, the elements from InOut[0] to − InOut[Size 1] are sorted. Order specifies the sort order. Details are provided below. One of the mem- bers to sort in the elements of In[] is passed as an argument to Member.
  • Page 572: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • If the power supply is interrupted during execution of this instruction, the contents of InOut may be corrupted. If you back up the contents of InOut[] each time the instruction is completed normally, you can restore the data if it is corrupted.
  • Page 573: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Retain Comment Variables Sorting BOOL FALSE Processing (retained) OperatingEnd BOOL FALSE Processing completed Trigger BOOL FALSE Execution condition Operating BOOL FALSE Processing RS_instance RecSort_instance RecSort External Variable Data type Comment Variables ARRAY[0..4] OF MyStr Sort array Abc_backup...
  • Page 574: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Restore Abc_backup[] to Abc[] after power interruption. Sorting P_First_RunMode MOVE Abc_backup Determine if execution of the RecSort instruction is completed. RecSort_instance.Done OperatingEnd RecSort_instance.Error Accept trigger. RS_instance Trigger Operating OperatingEnd Reset1 Make backup and execute RecSort instruction. Operating @MOVE Abc_backup RecSort_instance...
  • Page 575: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Retain Comment Variables Sorting BOOL FALSE Processing (retained) Trigger BOOL FALSE Execution condition Value of Trigger from previous LastTrigger BOOL FALSE task period OperatingStart BOOL FALSE Processing started Operating BOOL FALSE Processing RS_instance RecSort_instance...
  • Page 576: Recnum

    2 Instruction Descriptions RecNum The RecNum instruction finds the number of records in an array of structures to the end data. Instruction Name FB/FUN Graphic expression ST expression RecNum Get Number of Out:=RecNum(In, Member, (@)RecNum Records EndDat); Member EndDat Variables Name Meaning Description...
  • Page 577: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when EndDat is INT#9999. def:=RecNum(abc[0], abc[0].m, INT#9999); RecNum abc[0] abc[0].m Member INT#9999 EndDat EndDat INT#9999 Member = abc[0].m 0000 Member m In[0]=abc[0] 3456 0000 0000 Num = def UINT#3 In[1]=abc[1] 2345 0000 0000 In[2]=abc[2] 1234...
  • Page 578: Recmax And Recmin

    2 Instruction Descriptions RecMax and RecMin RecMax: Searches the specified member in the structures of an array of structures for the maximum value. RecMin: Searches the specified member in the structures of an array of structures for the minimum value. Instruction Name FB/FUN...
  • Page 579: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings Member OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK Specify the same data type as the search member of In[]. InOutPos[] (array) OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK * You can specify TIME, DATE, TOD, DT, and STRING data with CPU Units with unit version 1.01 or later and Sysmac Studio...
  • Page 580: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions ghi:=RecMax(abc[0], UINT#5, abc[0].m, def[0], jkl); RecMax abc[0] UINT#5 Size Member abc[0].m InOutPos def[0] def[0] Member=abc[0].m 0000 In[0]=abc[0] 1234 Member m 0000 0000 In[1]=abc[1] 2345 0000 0000 In[2]=abc[2] Size=UINT#5 INT#3456 Out = ghi 3456 0000 0000 In[3]=abc[3] 1234 0000 0000 In[4]=abc[4]...
  • Page 581: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • When In is an enumeration, always use a variable for the input parameter to pass to In. A building error will occur if a constant is passed. • If the value of Size is 0, the values of Out and Num are 0. If Member is STRING data and the value of Size is 0, Out is a text string containing only the NULL character.
  • Page 582: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-530 NY-series Instructions Reference Manual (W560)
  • Page 583: Fcs Instructions

    FCS Instructions Instruction Name Page StringSum Checksum Calculation 2-532 StringLRC Calculate Text String LRC 2-534 StringCRCCCITT Calculate Text String CRC-CCITT 2-536 StringCRC16 Calculate Text String CRC-16 2-538 AryLRC_** Calculate Array LRC Group 2-540 AryCRCCCITT Calculate Array CRC-CCITT 2-542 AryCRC16 Calculate Array CRC-16 2-544 NY-series Instructions Reference Manual (W560) 2-531...
  • Page 584: Stringsum

    2 Instruction Descriptions StringSum The StringSum instruction calculates the checksum for a text string. Instruction Name FB/FUN Graphic expression ST expression StringSum Checksum Out:=StringSum(In, Size); (@)StringSum Calculation Size Variables Name Meaning Description Valid range Unit Default Text string Text string to process Depends on data type.
  • Page 585: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • If the sum of the character codes in In exceeds the number of digits of Size, the upper digits are dis- carded. • An error occurs in the following cases. ENO will be FALSE, and Out will not change. •...
  • Page 586: Stringlrc

    2 Instruction Descriptions StringLRC The StringLRC instruction calculates the LRC value (horizontal parity). Instruction Name FB/FUN Graphic expression ST expression StringLRC Calculate Text Out:=StringLRC(In); (@)StringLRC String LRC Variables Name Meaning Description Valid range Unit Default Text string Input Text string to process Depends on data type.
  • Page 587: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use An error occurs in the following cases. ENO will be FALSE, and Out will not change. • The number of bytes in In is 0 (i.e., the NULL character only). NY-series Instructions Reference Manual (W560) 2-535...
  • Page 588: Stringcrcccitt

    2 Instruction Descriptions StringCRCCCITT The StringCRCCCITT instruction calculates the CRC-CCITT value using the XMODEM method. Instruction Name FB/FUN Graphic expression ST expression StringCRCCCITT Calculate Text Out:=StringCRCCCITT(In, (@)StringCRCCCITT String CRC-CCITT Initial, OutOrder); Initial OutOrder Variables Name Meaning Description Valid range Unit Default Text string Text string to process...
  • Page 589: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is ‘RD’, Initial is WORD#16#0000, and OutOrder is _HIGH_LOW. abc:=StringCRCCCITT(’RD’, WORD#16#0000, _HIGH_LOW); StringCRCCCITT ‘RD’ WORD#16#0000 Initial _HIGH_LOW OutOrder ‘RD’ Character codes CRC-CCITT value Out = abc ‘609D’ Precautions for Correct Use An error occurs in the following cases.
  • Page 590: Stringcrc16

    2 Instruction Descriptions StringCRC16 The StringCRC16 instruction calculates the CRC-16 value using the MODBUS method. Instruction Name FB/FUN Graphic expression ST expression StringCRC16 Calculate Text Out:=StringCRC16(In, (@)StringCRC16 String CRC-16 Initial, OutOrder); Initial OutOrder Variables Name Meaning Description Valid range Unit Default Text string Text string to process...
  • Page 591: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is ‘01’, Initial is WORD#16#FFFF and OutOrder is _LOW_HIGH. abc:=StringCRC16(’01’, WORD#16#FFF _LOW_HIGH); StringCRC16 ‘01’ WORD#16#FFFF Initial _LOW_HIGH OutOrder ‘01’ Character codes CRC-16 value Out = abc ‘D464’ Precautions for Correct Use An error occurs in the following cases.
  • Page 592: Arylrc

    2 Instruction Descriptions AryLRC_** The AryLRC_** instructions calculate the LRC value for an array. Instruction Name FB/FUN Graphic expression ST expression AryLRC_** Calculate Array Out:=AryLRC_**(In, Size); (@)AryLRC_** LRC Group "**" must be a bit string data type. Size "**" must be a bit string data type. Variables Name Meaning...
  • Page 593: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example shows the AryLRC_WORD instruction when Size is UINT#5. def:=AryLRC_WORD(abc[4], UINT#5); AryLRC_WORD abc[4] UINT#5 Size 16#1234 In[0]=abc[4] Exclusive logical OR In[1]=abc[5] 16#2345 16#1638 In[2]=abc[6] 16#3456 Size = UINT#5 Out = def 16#4567 In[3]=abc[7] In[4]=abc[8] 16#5678 Precautions for Correct Use •...
  • Page 594: Arycrcccitt

    2 Instruction Descriptions AryCRCCCITT The AryCRCCCITT instruction calculates the CRC-CCITT value using the XMODEM method. Instruction Name FB/FUN Graphic expression ST expression AryCRCCCITT Calculate Array Out:=AryCRCCCITT(In, (@)AryCRCCCITT CRC-CCITT Size, Initial, OutOrder); Size Initial OutOrder Variables Name Meaning Description Valid range Unit Default In[] (array)
  • Page 595: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of OutOrder is enumerated type _eBYTE_ORDER. The meaning of the enumerators are as follows: Enumerators Meaning _LOW_HIGH Lower byte first, upper byte last _HIGH_LOW Upper byte first, lower byte last Always attach the element number to in-out parameter that is passed to In[], e.g., array[3]. The following example is for when Size is UINT#2, Initial is WORD#16#0000, and OutOrder is _LOW_HIGH.
  • Page 596: Arycrc16

    2 Instruction Descriptions AryCRC16 The AryCRC16 instruction calculates the CRC-16 value using the MODBUS method. Instruction Name FB/FUN Graphic expression ST expression AryCRC16 Calculate Array Out:=AryCRC16(In, Size, (@)AryCRC16 CRC-16 Initial, OutOrder); Size Initial OutOrder Variables Name Meaning Description Valid range Unit Default In[] (array)
  • Page 597: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of OutOrder is enumerated type _eBYTE_ORDER. The meaning of the enumerators are as follows: Enumerator Meaning _LOW_HIGH Lower byte first, upper byte last _HIGH_LOW Upper byte first, lower byte last Always attach the element numbers to the input parameter that is passed to In[], e.g., array[3]. The following example is for when Size is UINT#2, Initial is WORD#16#FFFF and OutOrder is _LOW_HIGH.
  • Page 598: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-546 NY-series Instructions Reference Manual (W560)
  • Page 599: Text String Instructions

    Text String Instructions Instruction Name Page CONCAT Concatenate String 2-548 LEFT and RIGHT Get String Left/Get String Right 2-550 Get String Any 2-552 FIND Find String 2-554 String Length 2-556 REPLACE Replace String 2-557 DELETE Delete String 2-559 INSERT Insert String 2-561 GetByteLen Get Byte Length...
  • Page 600: Concat

    2 Instruction Descriptions CONCAT The CONCAT instruction joins two to five text strings. Instruction Name FB/FUN Graphic expression ST expression CONCAT Concatenate String Out:=CONCAT(In1,···, InN); (@)CONCAT Variables Name Meaning Description Valid range Unit Default In1 to InN Strings to Input Text strings to join, where N Depends on data type.
  • Page 601: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions ‘AB’ Joined. ‘ABCDEF’ Out=abc ‘C’ ‘DEF’ Precautions for Correct Use An error occurs in the following cases. ENO will be FALSE, and Out will not change. • The length of the joined character strings exceeds 1,986 bytes. NY-series Instructions Reference Manual (W560) 2-549...
  • Page 602: Left And Right

    2 Instruction Descriptions LEFT and RIGHT These instructions extract a text string with the specified number of characters. LEFT: Extracts characters from the left (beginning) of the text string. RIGHT: Extracts characters from the right (end) of the text string. Instruction Name FB/FUN...
  • Page 603: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is ‘ABCDEF’ and L is UINT#3. The value of variable abc will be ‘ABC’. abc:=LEFT(‘ABCDEF’, UINT#3); LEFT ‘ABCDEF’ UINT#3 ‘ABCDEF’ Three characters extracted from the left. ‘ABC’ Out=abc  RIGHT Extracts characters from the right (end) of In.
  • Page 604: Mid

    2 Instruction Descriptions The MID instruction extracts a text string with the specified number of characters from the specified character position. Instruction Name FB/FUN Graphic expression ST expression Get String Any Out:=MID(In, L, P); (@)MID Variables Name Meaning Description Valid range Unit Default Source...
  • Page 605: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is ‘ABCDEF’, L is UINT#3, and P is UINT#2. The value of variable abc will be ‘BCD’. abc:=MID(‘ABCDEF’, UINT#3, UINT#2); ‘ABCDEF’ UINT#3 UINT#2 ‘ABCDEF’ Three characters are extracted starting from second character. ‘BCD’...
  • Page 606: Find

    2 Instruction Descriptions FIND The FIND instruction searches a specified text string for the position of a specified text string. Instruction Name FB/FUN Graphic expression ST expression FIND Find String Out:=FIND(In1, In2); (@)FIND Variables Name Meaning Description Valid range Unit Default String to Text string to search...
  • Page 607: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Make sure the number of characters in In2 is less than the number of characters in In1. Otherwise, the value of Out will be 0. • If In2 exists more than once in In1, the position of the first In2 from the beginning of In1 is assigned to Out.
  • Page 608: Len

    2 Instruction Descriptions The LEN instruction finds the number of characters in a text string. Instruction Name FB/FUN Graphic expression ST expression String Length Out:=LEN(In); (@)LEN Variables Name Meaning Description Valid range Unit Default Length Input Text string to find length Depends on data type.
  • Page 609: Replace

    2 Instruction Descriptions REPLACE The REPLACE instruction replaces part of a text string with another text string. Instruction Name FB/FUN Graphic expression ST expression REPLACE Replace String Out:=REPLACE(In1, In2, L, (@)REPLACE Variables Name Meaning Description Valid range Unit Default String for Text string for replacement replaceme Depends on data type.
  • Page 610: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In1 is ‘ABCDEF’, In2 is ‘GHI’, P is UINT#2, and L is UINT#4. The value of variable abc will be ‘AGHIF’. abc:=REPLACE(‘ABCDEF’, ‘GHI’, UINT#4, UINT#2); REPLACE ‘ABCDEF’ ‘GHI’ UINT#4 UINT#2 Deleted ‘AGHIF’...
  • Page 611: Delete

    2 Instruction Descriptions DELETE The DELETE instruction deletes all or part of a text string. Instruction Name FB/FUN Graphic expression ST expression DELETE Delete String Out:=DELETE(In, L, P); (@)DELETE Variables Name Meaning Description Valid range Unit Default String for Text string for deletion Depends on data type.
  • Page 612: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is 'ABCDEF', L is UINT#4, and P is UINT#2. The value of variable abc will be 'AF'. abc:=DELETE(‘ABCDEF’, UINT#4, UINT#2); DELETE ‘ABCDEF’ UINT#4 UINT#2 Deleted Out=abc ‘AF’ ‘ABCDEF’ Precautions for Correct Use •...
  • Page 613: Insert

    2 Instruction Descriptions INSERT The INSERT instruction inserts a text string into another text string. Instruction Name FB/FUN Graphic expression ST expression INSERT Insert String Out:=INSERT(In1, In2, P); (@)INSERT Variables Name Meaning Description Valid range Unit Default Original Text string into which to string insert string Depends on data type.
  • Page 614: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In1 is 'ABCD', In2 is 'GHI', and P is UINT#2. The value of variable abc will be 'ABGHICD'. abc:=INSERT(‘ABCD’, ‘GHI’, UINT#2); INSERT ‘ABCD’ ‘GHI’ UINT#2 Out=abc ‘ABGHICD’ ‘ABCD’ Insert ‘GHI’ Additional Information If P is 0, In1 is inserted at the end of In2.
  • Page 615: Getbytelen

    2 Instruction Descriptions GetByteLen The GetByteLen instruction counts the number of bytes in a text string. Instruction Name FB/FUN Graphic expression ST expression GetByteLen Get Byte Length Out:=GetByteLen(In); (@)GetByteLen Variables Name Meaning Description Valid range Unit Default Count Input Text string to count number Depends on data type.
  • Page 616: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information If In contains only ASCII characters, the result will be the same as the result of the LEN instruction. 2-564 NY-series Instructions Reference Manual (W560)
  • Page 617: Clearstring

    2 Instruction Descriptions ClearString The ClearString instruction clears a text string. Instruction Name FB/FUN Graphic expression ST expression ClearString Clear String ClearString(InOut); (@)ClearString InOut Variables Name Meaning Description Valid range Unit Default InOut Clear string In-out Text string to clear Depends on data type.
  • Page 618: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use Return value Out is not used when the instruction is used in ST. 2-566 NY-series Instructions Reference Manual (W560)
  • Page 619: Toucase And Tolcase

    2 Instruction Descriptions ToUCase and ToLCase ToUCase: Converts all single-byte letters in a text string to uppercase. ToLCase: Converts all single-byte letters in a text string to lowercase. Instruction Name FB/FUN Graphic expression ST expression ToUCase Convert to Out:=ToUCase(In); (@)ToUCase Uppercase ToLCase Convert to...
  • Page 620: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the ToUCase instruction is for when In is ‘xyz’. The value of variable abc will be ‘XYZ’. abc:=ToUCase(‘xyz’); ToUCase ‘xyz’ The ToUCase instruction converts all single-byte letters in In to uppercase. Converted to uppercase. 'xyz' Out=abc 'XYZ'...
  • Page 621: Triml And Trimr

    2 Instruction Descriptions TrimL and TrimR TrimL: Removes blank space from the beginning of a text string. TrimR: Removes blank space from the end of a text string. Instruction Name FB/FUN Graphic expression ST expression TrimL Trim String Left Out:=TrimL(In); (@)TrimL TrimR Trim String Right...
  • Page 622: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example for the TrimL instruction is for when In is ‘ AB C’. The value of variable abc will be ‘ AB C’. abc:=TrimL(‘ AB C’); TrimL ‘ AB C’ The TrimL instruction deletes blank characters from the beginning of In. The blank characters from the beginning of In are deleted.
  • Page 623: Adddelimiter

    2 Instruction Descriptions AddDelimiter The AddDelimiter instruction converts the values in a structure to text strings and adds delimiters. Instruction Name FB/FUN Graphic expression ST expression AddDelimiter Put Text Strings Out:=AddDelimiter(In,Delim- AddDelimiter with Delimiters iter); Delimiter Variables Name Meaning Description Valid range Unit Default...
  • Page 624: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Boolean Data FALSE is converted to ‘0’ and TRUE is converted to ‘1’.  Bit String Data Bits strings are treated as hexadecimal numbers and converted to text strings that express them as alphanumeric characters. The 16# prefix of the hexadecimal number is not output to the text string. If the value of the member requires fewer digits than are provided by the data type of the member, the upper digits will contain ‘0’.
  • Page 625: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions If the value of the member is infinity, or nonnumeric data, the text string will be as shown below. Value of member Text string +∞ 'inf' −∞ '−inf' Nonnumeric data ‘nan’ or ‘−nan’ Examples are given below. Value of member Converted text string REAL#3.14e1...
  • Page 626: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Date and Time Data The structure of the text string to which the value of the member is converted is shown below. YYYY - MM - DD - hh : mm : ss . SS Decimal part Decimal Colon of seconds...
  • Page 627: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Array Data The text strings for the elements of the array are separated with the delimiter. The value of each ele- ment is converted according to the conversion rules for the data type of the array. Only one-dimen- sional arrays are converted.
  • Page 628: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming The myStruct structure has ten members that are SINT variables. Here, the contents of myArray[0..99], which is an array of structure type myStruct, are stored in 100 lines of a file named ‘ABC.csv’ in CSV file format in the SD Memory Card.
  • Page 629 2 Instruction Descriptions  Data Type Definition Name Data type Comment myStruct STRUCT Structure member0 SINT Member member1 SINT Member member2 SINT Member member3 SINT Member member4 SINT Member member5 SINT Member member6 SINT Member member7 SINT Member member8 SINT Member member9 SINT...
  • Page 630 2 Instruction Descriptions Determine if SD Memory Card instruction execution is completed. FileClose_instance.Done OperatingEnd FileOpen_instance.Error FilePuts_instance.Error FileClose_instance.Error Accept trigger. RS_instance Trigger _Card1Ready Operating OperatingEnd Reset1 Initialize row index. Inline ST Operating 1 Index:=INT#0; Execute FileOpen instruction. FileOpen_instance Operating FileOpen Execute Done FileName Busy...
  • Page 631 2 Instruction Descriptions Create a text string for one line. Operating FileOpen_instance.Done FilePuts_instance.Busy FileClose_instance.Busy AddDelimiter myArray[Index] Temp _COMMA Delimiter CONCAT Temp StrDat ’$r$l’ Write a text string for one line to the file. FilePuts_instance Operating FileOpen_instance.Done FilePuts_instance.Busy FileClose_instance.Busy FilePuts Execute Done FileID Busy...
  • Page 632 2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables Execution con- Trigger BOOL False dition Value of Trigger LastTrigger BOOL False from previous task period Processing OperatingStart BOOL False started Operating BOOL False Processing Stage Stage change Index Index DWORD 16#0...
  • Page 633 2 Instruction Descriptions Stage:=INT#2; // Normal end END_IF; IF (FileOpen_instance.Error=TRUE) THEN Stage:=INT#99; // Error end END_IF; // Create a text string for one line. StrDat:=''; Temp :=AddDelimiter(myArray[Index],_COMMA); StrDat:=CONCAT(In1:=Temp, In2:='$r$l'); Stage:=INT#3; // Write text string. FilePuts_instance( Execute:=TRUE, FileID :=Fid, :=StrDat); IF (FilePuts_instance.Done=TRUE) THEN Index:=Index+INT#1;...
  • Page 634: Subdelimiter

    2 Instruction Descriptions SubDelimiter The SubDelimiter instruction reads delimited data from a text string and stores the results as the values of the members of a structure. Instruction Name FB/FUN Graphic expression ST expression SubDelimiter Get Text Out:=SubDelimiter(In, Strings Minus SubDelimiter OutStruct, Delimiters...
  • Page 635: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions If the number of text strings that are delimited in In exceeds the number of members of OutStruct, the remaining data is ignored. If the number of text strings that are delimited in In is less than the number of members of OutStruct, the values of the remaining members are not changed.
  • Page 636: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Note 1 Any ‘ ‘ (blank characters) before the sign column, days, hours, minutes, seconds, or milliseconds are ignored. 2 If any characters in the values of AA, BB, CC, DD, or EE are separated with a single ‘_’ (underbar), the underbar is ignored.
  • Page 637: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2 If any characters in the values of the year, month, day, hour, minutes, or seconds are separated with a single ‘_’ (underbar), the underbar is ignored. 3 Even if there is a ‘0’ before the value of the year, month, day, hour, minutes, or seconds, the data can still be converted.
  • Page 638: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Enumeration Data STRING data that expresses a DINT variable is converted to an enumerator of the enumeration. The same rules as for integers are used to convert to DINT data, the value of the DINT data is taken as the value of the enumeration, and that value is converted to the corresponding enumerator.
  • Page 639: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If there is a STRING member in OutStruct, do not attach a final NULL character to the corresponding data in In. If you use a NULL character anywhere except at the end of In, only the text string through the first NULL character will be converted.
  • Page 640 2 Instruction Descriptions  Data Type Definition Name Data type Comment myStruct STRUCT Structure member0 STRING Member member1 STRING Member member2 STRING Member member3 STRING Member member4 STRING Member Internal Variable Data type Initial value Comment Variables Processing com- OperatingEnd BOOL False pleted...
  • Page 641 2 Instruction Descriptions Determine if instruction execution is completed. FileClose_instance.Done OperatingEnd FileOpen_instance.Error FileGets_instance.Error FileClose_instance.Error Accept trigger. RS_instance Trigger _Card1Ready Operating OperatingEnd Reset1 Initialize InDat[] element index. Inline ST Operating 1 Index:=INT#0; Execute FileOpen instruction. FileOpen_instance Operating FileOpen Execute Done FileName Busy ‘ABC.csv’...
  • Page 642 2 Instruction Descriptions Execute FileGets instruction. FileGets_instance Operating FileOpen_instance.Done FileGets_instance.Busy FileClose_instance.Busy FileGets Execute Done FileID Busy TRUE TrimLF Error ErrorID Inline ST FileGets_instance.Error 1 // Processing after error end Execute SubDelimiter instruction. Operating FileGets_instance.Done SubDelimiter FileGets_instance.Out OutStruct myArray[Index] _COMMA Delimiter InOut Index Execute FileClose instruction when EOF is detected.
  • Page 643 2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables Execution condi- Trigger BOOL False tion Value of Trigger LastTrigger BOOL False from previous task period OperatingStart BOOL False Processing started Operating BOOL False Processing [1000((member0:='',mem- ARRAY[0..999] OF myArray ber1:='',member2:='',mem- Integer data myStruct...
  • Page 644 2 Instruction Descriptions Stage:=INT#99; // Error end END_IF; // Read text string. FileGets_instance( Execute:=TRUE, FileID :=Fid, TrimLF :=TRUE); IF (FileGets_instance.Done=TRUE) THEN // Store the text strings that were read as the values of the myArray[] member. SubDelimiter(FileGets_instance.Out,myArray[Index],_COMMA); Index:=Index+INT#1; // Reached end of file. IF (FileGets_instance.EOF=TRUE) THEN Stage:=INT#3;...
  • Page 645: Time And Time Of Day Instructions

    Time and Time of Day Instructions Instruction Name Page Instruction Name Page ADD_TIME Add Time 2-594 TodToSec Convert Time of Day to 2-625 Seconds ADD_TOD_TIME Add Time to Time of Day 2-596 SecToDt Convert Seconds to Date and 2-626 Time ADD_DT_TIME Add Time to Date and Time 2-598...
  • Page 646: Add_Time

    2 Instruction Descriptions ADD_TIME The ADD_TIME instruction adds two times. Instruction Name FB/FUN Graphic expression ST expression ADD_TIME Add Time Out:=ADD_TIME(In1, In2); (@)ADD_TIME Variables Name Meaning Description Valid range Unit Default Add time 1 Add time 1 Input Depends on data type. T#0s Add time 2 Add time 2...
  • Page 647: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use An error will not occur even if the addition result exceeds the valid range of Out. • T#106751d_23h_47m_16s_854.775807ms + T#0.000001ms → T#-106751d_23h_47m_16s_854.775808ms • T#-106751d_23h_47m_16s_854.775808ms + T#-0.000001ms → T#106751d_23h_47m_16s_854.775807ms 2-595 NY-series Instructions Reference Manual (W560)
  • Page 648 2 Instruction Descriptions ADD_TOD_TIME The ADD_TOD_TIME instruction adds a time to a time of day. Instruction Name FB/FUN Graphic expression ST expression ADD_TOD_TIME Add Time to Time of Out:=ADD_TOD_TIME(In1, (@)ADD_TOD_TIME In2); Variables Name Meaning Description Valid range Unit Default Add time of Add time of day Hour, min- TOD#0:0...
  • Page 649: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use An error will not occur even if the addition result exceeds the valid range of Out. • TOD#23:59:59.999999999 + T#0.000001ms → TOD#0:0:0.000000000 • TOD#0:0:0.000000000 + T#-0.000001ms → TOD#23:59:59.999999999 2-597 NY-series Instructions Reference Manual (W560)
  • Page 650: Add_Dt_Time

    2 Instruction Descriptions ADD_DT_TIME The ADD_DT_TIME instruction adds a time to a date and time. Instruction Name FB/FUN Graphic expression ST expression ADD_DT_TIME Add Time to Date Out:=ADD_DT_TIME(In1, (@)ADD_DT_TIME and Time In2); Variables Name Meaning Description Valid range Unit Default Add date Add date and time Year, month,...
  • Page 651: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The ADD_DT_TIME instruction adds a time, In2, to a date and time In1. The result of addition in Out is also a date and time. Leap years are also accounted for. The following example is for when In1 is DT#1970-1-1-0:0:0 and In2 is T#1d.
  • Page 652: Sub_Time

    2 Instruction Descriptions SUB_TIME The SUB_TIME instruction subtracts one time from another. Instruction Name FB/FUN Graphic expression ST expression SUB_TIME Subtract Time Out:=SUB_TIME(In1, In2); (@)SUB_TIME Variables Name Meaning Description Valid range Unit Default Original Original time time Input Depends on data type. T#0s Time to Time to subtract...
  • Page 653: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use An error will not occur even if the subtraction result exceeds the valid range of Out. • T#106751d_23h_47m_16s_854.775807ms − T#-0.000001ms → T#-106751d_23h_47m_16s_854.775808ms • T#-106751d_23h_47m_16s_854.775808ms − T#0.000001ms → T#106751d_23h_47m_16s_854.775807ms 2-601 NY-series Instructions Reference Manual (W560)
  • Page 654: Sub_Tod_Time

    2 Instruction Descriptions SUB_TOD_TIME The SUB_TOD_TIME instruction subtracts a time from a time of day. Instruction Name FB/FUN Graphic expression ST expression SUB_TOD_TIME Subtract Time from Out:=SUB_TOD_TIME(In1, (@)SUB_TOD_TIME Time of Day In2); Variables Name Meaning Description Valid range Unit Default Time of day Time of day Hour, min-...
  • Page 655: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use An error will not occur even if the subtraction result exceeds the valid range of Out. • TOD#23:59:59.999999999 − T#-0.000001ms → TOD#0:0:0 • TOD#0:0:0 − T#0.000001ms → TOD#23:59:59.999999999 2-603 NY-series Instructions Reference Manual (W560)
  • Page 656: Sub_Tod_Tod

    2 Instruction Descriptions SUB_TOD_TOD The SUB_TOD_TOD instruction subtracts a time of day from another time of day. Instruction Name FB/FUN Graphic expression ST expression SUB_TOD_TOD Subtract Time of Out:=SUB_TOD_TOD(In1, (@)SUB_TOD_TOD In2); Variables Name Meaning Description Valid range Unit Default Time of day Time of day 1 Hour, min- TOD#0:0...
  • Page 657: Sub_Date_Date

    2 Instruction Descriptions SUB_DATE_DATE The SUB_DATE_DATE instruction subtracts another date from another date. Instruction Name FB/FUN Graphic expression ST expression SUB_DATE_DATE Subtract Date Out:=SUB_DATE_DATE(In1, (@)SUB_DATE_DATE In2); Variables Name Meaning Description Valid range Unit Default Date 1 Date 1 Year, month, D#1970- Input Depends on data type.
  • Page 658: Sub_Dt_Dt

    2 Instruction Descriptions SUB_DT_DT The SUB_DT_DT instruction subtracts another date and time from another date and time. Instruction Name FB/FUN Graphic expression ST expression SUB_DT_DT Subtract Date and Out:=SUB_DT_DT(In1, (@)SUB_DT_DT Time In2); Variables Name Meaning Description Valid range Unit Default Date and Date and time 1 Year, month,...
  • Page 659: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description _CurrentTime System Time of Day The time of day from the system clock. The num- ber of seconds from 00:00:00 on January 1,1970. Precautions for Correct Use If the processing result exceeds the valid range of Out, Out will contain an illegal value. 2-607 NY-series Instructions Reference Manual (W560)
  • Page 660: Sub_Dt_Time

    2 Instruction Descriptions SUB_DT_TIME The SUB_DT_TIME instruction subtracts a time from a date and time. Instruction Name FB/FUN Graphic expression ST expression SUB_DT_TIME Subtract Time from Out:=SUB_DT_TIME(In1, (@)SUB_DT_TIME Date and Time In2); Variables Name Meaning Description Valid range Unit Default Date and Date and time Year, month,...
  • Page 661: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The SUB_DT_TIME instruction subtracts a time In2 from a date and time In1. The result of subtraction in Out is a date and time. Leap years are also accounted for. The following example is for when In1 is DT#1970-1-1-0:0:0 and In2 is T#1d. abc:=SUB_DT_TIME(DT#1970-1-7-0:0:0, T#1d);...
  • Page 662: Multime

    2 Instruction Descriptions MULTIME The MULTIME instruction multiplies a time by a specified number. Instruction Name FB/FUN Graphic expression ST expression MULTIME Multiply Time Out:=MULTIME(In1, In2); (@)MULTIME Variables Name Meaning Description Valid range Unit Default Original Original time T#0s time Input Depends on data type.
  • Page 663: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • If In2 is a real number, the multiplication result is rounded to the nearest nanosecond. The following table shows how values are rounded. Value below nanosec- Treatment Examples onds Less than 0.5 The value is truncated. 1.49 →...
  • Page 664: Divtime

    2 Instruction Descriptions DIVTIME The DIVTIME instruction divides a time by a specified number. Instruction Name FB/FUN Graphic expression ST expression DIVTIME Divide Time Out:=DIVTIME(In1, In2); (@)DIVTIME Variables Name Meaning Description Valid range Unit Default Original Original time T#0s time Input Depends on data type.
  • Page 665: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • If the value of In2 is 0, positive infinity, negative infinity, or nonnumeric data, the value of Out is as shown below. Value of Out Value of In2 Other than the right NX1P2 T#-106751d23h47m16.854775808s T#0d_0h_0m_0s_1e-006...
  • Page 666: Concat_Date_Tod

    2 Instruction Descriptions CONCAT_DATE_TOD The CONCAT_DATE_TOD instruction combines a date and a time of day. Instruction Name FB/FUN Graphic expression ST expression CONCAT_DATE Concatenate Date Out:=CONCAT_- (@)CONCAT_DATE_TOD _TOD and Time of Day DATE_TOD(In1, In2); Variables Name Meaning Description Valid range Unit Default Date...
  • Page 667: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The CONCAT_DATE_TOD instruction combines a date In1 and a time of day In2. The result of combin- ing in Out is also a date and time. The following example is for when In1 is D#1970-1-7 and In2 is TOD#23:59:59.999999999. abc:=CONCAT_DATE_TOD(D#1970-1-7, TOD#23:59:59.999999999);...
  • Page 668: Dt_To_Tod

    2 Instruction Descriptions DT_TO_TOD The DT_TO_TOD instruction extracts the time of day from a date and time. Instruction Name FB/FUN Graphic expression ST expression DT_TO_TOD Extract Time of Day Out:=DT_TO_TOD(In); (@)DT_TO_TOD from Date and Time Variables Name Meaning Description Valid range Unit Default Date and...
  • Page 669: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description _CurrentTime System Time of Day The time of day from the system clock. The num- ber of seconds from 00:00:00 on January 1,1970. 2-617 NY-series Instructions Reference Manual (W560)
  • Page 670: Dt_To_Date

    2 Instruction Descriptions DT_TO_DATE The DT_TO_DATE instruction extracts the date from a date and time. Instruction Name FB/FUN Graphic expression ST expression DT_TO_DATE Extract Date from Out:=DT_TO_DATE(In); (@)DT_TO_DATE Date and Time Variables Name Meaning Description Valid range Unit Default Date and Input Date and time Depends on data type.
  • Page 671: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description _CurrentTime System Time of Day The time of day from the system clock. The num- ber of seconds from 00:00:00 on January 1,1970. 2-619 NY-series Instructions Reference Manual (W560)
  • Page 672: Gettime

    2 Instruction Descriptions GetTime The GetTime instruction reads the current time. Instruction Name FB/FUN Graphic expression ST expression GetTime Get Time of Day Out:=GetTime(); (@)GetTime Variables Name Meaning Description Valid range Unit Default Current Output Current time Year, month, time day, hour, minutes, sec- onds...
  • Page 673: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The GetTime instruction reads the current time. The current time of day is the time for the set time zone (not Greenwich mean time (GMT)). The following figure shows a programming example. The current time is assigned to variable abc. abc:=GetTime();...
  • Page 674: Dttosec

    2 Instruction Descriptions DtToSec The DtToSec instruction converts a date and time to the number of seconds from 00:00:00 on January 1, 1970. Instruction Name FB/FUN Graphic expression ST expression DtToSec Convert Date and Out:=DtToSec(In); (@)DtToSec Time to Seconds Variables Name Meaning Description...
  • Page 675: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description _CurrentTime System Time of Day The time of day from the system clock. The num- ber of seconds from 00:00:00 on January 1,1970. Additional Information Use the SecToDt instruction (page 2-626) to convert the number of seconds from 00:00:00 on January 1,1970 to a date and time.
  • Page 676: Datetosec

    2 Instruction Descriptions DateToSec The DateToSec instruction converts a date to the number of seconds from 00:00:00 on January 1, 1970. Instruction Name FB/FUN Graphic expression ST expression DateToSec Convert Date to Out:=DateToSec(In); (@)DateToSec Seconds Variables Name Meaning Description Valid range Unit Default Date...
  • Page 677: Todtosec

    2 Instruction Descriptions TodToSec The TodToSec instruction converts a time of day to the number of seconds from 00:00:00. Instruction Name FB/FUN Graphic expression ST expression TodToSec Convert Time of Out:=TodToSec(In); (@)TodToSec Day to Seconds Variables Name Meaning Description Valid range Unit Default Time of day Input...
  • Page 678: Sectodt

    2 Instruction Descriptions SecToDt The SecToDt instruction converts the number of seconds from 00:00:00 on January 1, 1970 to a date and time. Instruction Name FB/FUN Graphic expression ST expression SecToDt Convert Seconds to Out:=SecToDt(In); (@)SecToDt Date and Time Variables Name Meaning Description...
  • Page 679: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description _CurrentTime System Time of Day The time of day from the system clock. The num- ber of seconds from 00:00:00 on January 1,1970. Additional Information Use the DtToSec instruction (page 2-622) to convert the current time of day to the number of seconds from 00:00:00 on January 1,1970.
  • Page 680: Sectodate

    2 Instruction Descriptions SecToDate The SecToDate instruction converts the number of seconds from 00:00:00 to a date. Instruction Name FB/FUN Graphic expression ST expression SecToDate Convert Seconds to Out:=SecToDate(In); (@)SecToDate Date Variables Name Meaning Description Valid range Unit Default Seconds Input Number of seconds from 0 to 18446744073...
  • Page 681: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use An error occurs in the following case. ENO will be FALSE, and Out will not change. • The value of In is outside of the valid range. 2-629 NY-series Instructions Reference Manual (W560)
  • Page 682: Sectotod

    2 Instruction Descriptions SecToTod The SecToTod instruction converts the number of seconds from 00:00:00 to a time of day. Instruction Name FB/FUN Graphic expression ST expression SecToTod Convert Seconds to Out:=SecToTod(In); (@)SecToTod Time of Day Variables Name Meaning Description Valid range Unit Default Seconds...
  • Page 683: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use An error occurs in the following case. ENO will be FALSE, and Out will not change. • The value of In is outside of the valid range. 2-631 NY-series Instructions Reference Manual (W560)
  • Page 684: Timetonanosec

    2 Instruction Descriptions TimeToNanoSec The TimeToNanoSec instruction converts a time to nanoseconds. Instruction Name FB/FUN Graphic expression ST expression TimeToNanoSec Convert Time to Out:=TimeToNanoSec(In); (@)TimeToNanoSec Nanoseconds Variables Name Meaning Description Valid range Unit Default Time Input Time Depends on data type. T#0s Nanosecon Output...
  • Page 685: Timetosec

    2 Instruction Descriptions TimeToSec The TimeToSec instruction converts a time to seconds. Instruction Name FB/FUN Graphic expression ST expression TimeToSec Convert Time to Out:=TimeToSec(In); (@)TimeToSec Seconds Variables Name Meaning Description Valid range Unit Default Time Input Time Depends on data type. T#0s Seconds Output...
  • Page 686: Nanosectotime

    2 Instruction Descriptions NanoSecToTime The NanoSecToTime instruction converts nanoseconds to a time. Instruction Name FB/FUN Graphic expression ST expression NanoSecToTime Convert Out:=NanoSecToTime(In); (@)NanoSecToTime Nanoseconds to Time Variables Name Meaning Description Valid range Unit Default Nanosecon Input Nanoseconds Time Output Time Depends on data type.
  • Page 687: Sectotime

    2 Instruction Descriptions SecToTime The SecToTime instruction converts seconds to a time. Instruction Name FB/FUN Graphic expression ST expression SecToTime Convert Seconds to Out:=SecToTime(In); (@)SecToTime Time Variables Name Meaning Description Valid range Unit Default Seconds Input Seconds −9223372036 to Seconds 9223372036 Time Output...
  • Page 688: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • In is in seconds. Out is in nanoseconds. • An error occurs in the following case. ENO will be FALSE, and Out will not change. • The value of In is outside of the valid range. 2-636 NY-series Instructions Reference Manual (W560)
  • Page 689: Chkleapyear

    2 Instruction Descriptions ChkLeapYear The ChkLeapYear instruction is used to check for a leap year. Instruction Name FB/FUN Graphic expression ST expression ChkLeapYear Check for Leap Out:=ChkLeapYear(In); (@)ChkLeapYear Year Variables Name Meaning Description Valid range Unit Default Year Input Year 1970 to 2554 Year 1970...
  • Page 690: Getdaysofmonth

    2 Instruction Descriptions GetDaysOfMonth The GetDaysOfMonth instruction gets the number of days in the specified month. Instruction Name FB/FUN Graphic expression ST expression GetDaysOfMonth Get Days in Month Out:=GetDaysOfMonth(Year, (@)GetDaysOfMonth Month); Year Month Variables Name Meaning Description Valid range Unit Default Year Year...
  • Page 691: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming This sample gets the number of days in the current month. Internal Variable Data type Initial value Comment Variables (Year:=0, Month:=0, Day:=0, _sDT Date and time Hour:=0, Min:=0, Sec:=0, NSec:=0) USINT Days in current month External Variable Data type...
  • Page 692: Daystomonth

    2 Instruction Descriptions DaysToMonth The DaysToMonth instruction calculates the month based on the number of days from January 1. Instruction Name FB/FUN Graphic expression ST expression DaysToMonth Convert Days to Out:=DaysToMonth(Year, (@)DaysToMonth Month Days); Year Days Variables Name Meaning Description Valid range Unit Default...
  • Page 693: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • If the value of Year exceeds the valid range, an error will not occur and the value of Out will be an ille- gal value. • An error occurs in the following case. ENO will be FALSE, and Out will not change. •...
  • Page 694: Getdayofweek

    2 Instruction Descriptions GetDayOfWeek The GetDayOfWeek instruction gets the day of the week for the specified year, month, and day of month. Instruction Name FB/FUN Graphic expression ST expression GetDayOfWeek Get Day of Week Out:=GetDayOfWeek(In); (@)GetDayOfWeek Variables Name Meaning Description Valid range Unit Default...
  • Page 695: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is D#2011-1-1. abc:=GetDayOfWeek(D#2011-1-1); GetDayOfWeek D#2011-1-1 Day of the week _SAT Day of the week Out=abc D#2011-1-1 Related System-defined Variables Name Meaning Data type Description _CurrentTime System Time of Day The time of day from the system clock. The num- ber of seconds from 00:00:00 on January 1,1970.
  • Page 696: Getweekofyear

    2 Instruction Descriptions GetWeekOfYear The GetWeekOfYear instruction gets the week number for the specified year, month, and day of month. Instruction Name FB/FUN Graphic expression ST expression GetWeekOfYear Get Week Number Out:=GetWeekOfYear(In); (@)GetWeekOfYear Variables Name Meaning Description Valid range Unit Default Year, Input...
  • Page 697: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description _CurrentTime System Time of Day The time of day from the system clock. The num- ber of seconds from 00:00:00 on January 1,1970. 2-645 NY-series Instructions Reference Manual (W560)
  • Page 698: Dttodatestruct

    2 Instruction Descriptions DtToDateStruct The DtToDateStruct instruction converts a date and time to the year, month, day, hour, minutes, sec- onds, and nanoseconds. Instruction Name FB/FUN Graphic expression ST expression DtToDateStruct Break Down Date Out:=DtToDateStruct(In, (@)DtToDateStruct and Time DateStruct); DateStruct Variables Name Meaning...
  • Page 699: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Name Meaning Content Data type Valid range Unit Default Year Year Year UINT 1970 to 2554 Year Month Month Month USINT 1 to 12 Month USINT 1 to 31 Hour Hour Hour USINT 0 to 23 Hour Minutes Minutes USINT...
  • Page 700: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is DT#1970-1-2-12:34:56.999999999. DtToDateStruct(DT#1970-1-2-12:34:56.999999999, abc); DtToDateStruct DT#1970-1-2-12:34:56.999999999 DateStruct Broken down .Year DT#1970-1-2-12:34:56.999999999 Out=abc UINT#1970 Year .Month Month USINT#1 .Day USINT#2 Hour USINT#12 .Hour Minutes .Min USINT#34 Seconds .Sec USINT#56 .Nsec ULINT#999999999 Nanoseconds Related System-defined Variables Name...
  • Page 701: Datestructtodt

    2 Instruction Descriptions DateStructToDt The DateStructToDt instruction joins a year, month, day, hour, minutes, seconds, and nanoseconds into a date and time. Instruction Name FB/FUN Graphic expression ST expression DateStructToDt Join Time Out:=DateStructToDt(In); (@)DateStructToDt Variables Name Meaning Description Valid range Unit Default Date and...
  • Page 702: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for the following values for the members of In: Year is UINT#1970, Month is USINT#1, Day is USINT#2, Hour is USINT#12, Min is USINT#34, Sec is USINT#56, and Nsec is ULINT#999999999. def:=DateStructToDt(abc); DateStructToDt In=abc .Year Year...
  • Page 703: Trunctime

    2 Instruction Descriptions TruncTime The TruncTime instruction truncates a TIME variable below the specified time unit. Instruction Name FB/FUN Graphic expression ST expression TruncTime Truncate Time Out:=TruncTime(In, (@)TruncTime Accuracy); Accuracy Variables Name Meaning Description Valid range Unit Default Time to Time to truncate Depends on data type.
  • Page 704: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is TIME#123.456789012s and Accuracy is _MICROSEC. abc:=TruncTime(T#123.456789012s, _MICROSEC); TruncTime T#123.456789012s _MICROSEC Accuracy All digits below the microseconds T#123.456789012s are truncated. Out=abc T#123.456789s _MICROSEC Accuracy Additional Information Before you compare two TIME variables with the EQ (=) instruction (page 2-92) or other instructions, use the TruncTime instruction to convert the two variables to the same accuracy.
  • Page 705: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Global Variables Variable Data type Initial value Comment RecentMode Mode The current operation mode Internal Variable Data type Initial value Comment Variables SensorOut BOOL FALSE Sensor output ElapsedTime TIME T#0s Elapsed time SensorTime TIME T#0s Sensor ON time A time that is sufficiently longer than the LongTime TIME...
  • Page 706: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables SensorOut BOOL FALSE Sensor output ElapsedTime TIME T#0s Elapsed time SensorTime TIME T#0s Sensor ON time A time that is sufficiently longer than the LongTime TIME T#1h sensor ON time SensorDone BOOL FALSE...
  • Page 707: Truncdt

    2 Instruction Descriptions TruncDt The TruncDt instruction truncates a DT variable below the specified time unit. Instruction Name FB/FUN Graphic expression ST expression TruncDt Truncate Date and Out:=TruncDt(In, Accuracy); (@)TruncDt Time Accuracy Variables Name Meaning Description Valid range Unit Default Date and Date and time to truncate Depends on data type.
  • Page 708: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is DT#1970-1-1-12:34:56.789012345 and Accuracy is _SEC. abc:=TruncDt(DT#1970-1-1-12:34:56.789012345, _SEC); TruncDt DT#1970-1-1-12:34:56.789012345 _SEC Accuracy All digits below the DT#1970-1-1-12:34:56.789012345 seconds are truncated. Out=abc DT#1970-01-01-12:34:56.000000000 _SEC Accuracy Additional Information Before you compare two DT variables with the EQ (=) instruction (page 2-92) or other instructions, use the TruncDt instruction to convert the two variables to the same accuracy.
  • Page 709: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables SensorOut BOOL FALSE Sensor output Voltage REAL Voltage NumDat UINT UINT#0 Current number of stored data External Variable Data type Comment Variables Recent Record Present value Stack ARRAY[0..99] OF Record Stack Record date and time and voltage SensorOut...
  • Page 710: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions // Activate trigger when sensor output turns ON. R_TRIG_instance(SensorOut, Trigger); IF (Trigger=TRUE) THEN // Store the current date and time down to the milliseconds. Recent.DandT:=TruncDt( :=GetTime(), // Get the date and time. Accuracy:=_MILLISEC); // Accuracy is milliseconds. // Get current voltage.
  • Page 711: Trunctod

    2 Instruction Descriptions TruncTod The TruncTod instruction truncates a TOD variable below the specified time unit. Instruction Name FB/FUN Graphic expression ST expression TruncTod Truncate Time of Out:=TruncTod(In, (@)TruncTod Accuracy); Accuracy Variables Name Meaning Description Valid range Unit Default Time of day Time of day to truncate Depends on data type.
  • Page 712: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following example is for when In is TOD#12:34:56.789012345 and Accuracy is _MILLISEC. abc:=TruncTod(TOD#12:34:56.789012345, _MILLISEC); TruncTod TOD#12:34:56.789012345 _MILLISEC Accuracy All digits below the TOD#12:34:56.789012345 milliseconds are truncated. TOD#12:34:56.789 Out=abc _MILLISEC Accuracy Additional Information Before you compare two TOD variables with the EQ (=) instruction (page 2-92) or other instructions, use the TruncTod instruction to convert the two variables to the same accuracy.
  • Page 713: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables SensorOut BOOL FALSE Sensor output Voltage REAL Voltage NumDat UINT UINT#0 Current number of stored data External Variable Data type Comment Variables Recent Record Present value Stack ARRAY[0..99] OF Record Stack Record time of day and voltage SensorOut...
  • Page 714: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions // Activate trigger when sensor output turns ON. R_TRIG_instance(SensorOut, Trigger); IF (Trigger=TRUE) THEN // Store the current time of day down to the seconds. TmpTod :=DT_TO_TOD(GetTime()); // Get time of day. Recent.TofD:=TruncTod( :=TmpTod, Accuracy:=_SEC); // Accuracy is seconds. // Get current voltage.
  • Page 715: Analog Control Instructions

    Analog Control Instructions Instruction Name Page PIDAT PID Control with Autotuning 2-664 PIDAT_HeatCool Heating/Cooling PID with Autotuning 2-689 TimeProportionalOut Time-proportional Output 2-727 LimitAlarm_** Upper/Lower Limit Alarm Group 2-743 LimitAlarmDv_** Upper/Lower Deviation Alarm Group 2-747 LimitAlarmDvStbySeq_** Upper/Lower Deviation Alarm with 2-752 Standby Sequence Group ScaleTrans Scale Transformation...
  • Page 716: Pidat

    2 Instruction Descriptions PIDAT The PIDAT instruction performs PID control with autotuning (2-PID control with set point filter). Instruction Name FB/FUN Graphic expression ST expression PIDAT PID Control with PIDAT_instance( PIDAT_instance Autotuning Run, PIDAT ManCtl, ATDone StartAT, ManCtl ATBusy StartAT Error ErrorID OprSetParams,...
  • Page 717: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Name Meaning Description Valid range Unit Default ATDone Autotuning TRUE: Normal completion normal FALSE: completion Depends on data type. ATBusy Autotuning TRUE: Autotuning Output busy FALSE: Not autotuning −320 to 320 Manipulated Manipulated variable variable *1 Value of input range lower limit InitSetParams.RngLowLmt to Value of input range upper limit InitSetParams.RngUpLmt *2 Digits below 0.0001 s are truncated.
  • Page 718: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Structure Specifications The data type of operation setting parameter OprSetParams is structure _sOPR_SET_PARAMS. The specifications are as follows: Name Meaning Description Data type Valid range Unit Default OprSetParams Operation Parameters that are set _sO- Setting during operation. PR_SET_PAR Parameters MVLowLmt...
  • Page 719: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Meanings of Variables The meanings of the variables that are used in this command are described below.  Run (Execution Condition) This is the execution condition for the instruction. PID control is performed while the value is TRUE. PID control is stopped when the value changes to FALSE.
  • Page 720: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  ManResetVal (Manual Reset Value) This is the value of MV when the deviation (i.e., the difference between PV and SP) is 0 for the pro- portional action. The value of ManResetVal determines the location of the proportional action band. When integral operation is performed, the manual reset value is ignored.
  • Page 721: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  SampTime (Sampling Period) This is the minimum value of the period for PID processing. Refer to the description of the execution timing of PID processing for details. PID processing is not performed again until the time specified for SampTime has elapsed since the last time PID processing was performed.
  • Page 722: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  DerivativeTime (Derivative Time) This is one of the three PID constants. Refer to the description of the derivative action for details. The larger the value of DerivativeTime is, the stronger the derivative action is.  ManMV (Manual Manipulated Variable) MV is set to this value during manual operation (while ManCtl is TRUE).
  • Page 723: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Process value Repeatedly executed. Manipulated Set point variable Controlled processing system Parameters Proportional (P), Integral (I), and Derivative (D) Actions PID control is performed by combining the proportional action, integral action, and derivative action. These actions are described next. ...
  • Page 724: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Proportional action region Manipulated when the manual reset value is a. variable The position of the proportional action 100% range is determined so that the manipulated variable when the process value and the set point are the same equals the manual reset value.
  • Page 725: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions One of the parameters for the integral action is the integration time. This is the time for the manipu- lated variable from the integral action to equal the manipulated variable from the proportional action when a stepwise deviation occurs. The shorter the integration time is, the stronger the integral action is.
  • Page 726: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The total of the manipulated variables for the proportional, integral, and derivative actions is the manipulated variable for PID control. The changes in the manipulated variable for PID control for a stepwise and ramp deviations are shown below. Deviation Deviation Stepwise response...
  • Page 727: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The formulas of the blocks of this instruction are shown below. The set point filter value (i.e., a coeffi- cient for the set point) is adjusted by using the integration time and the 2-PID parameter α. The opti- mum value of α...
  • Page 728: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Control Status and Manipulated Variable Manipulated variable MV is determined according to the control status as shown in the following table. Value of variable ManCtl Manipulated vari- Run (exe- Error MVTrackSw ATBusy Control status (man- able MV cution con- (error (MV tracking...
  • Page 729: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Autotuning executed. Process value Set point Autotuning hysteresis Time Manipulated variable MV upper limit MV lower limit Time The manipulated variable is set to the MV upper limit. When the deviation reaches 0, the manipulated variable is set to the MV lower limit.
  • Page 730: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Task period = 60 ms and SampTime = 100 ms The task period is less than SampTime, so DIP processing is not executed every period. Task period Task period Task period Task period Task period PIDAT PIDAT PIDAT PIDAT PIDAT...
  • Page 731: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Autotuning Executed at the Start of PIDAT Execution TRUE FALSE TRUE StartAT FALSE TRUE ATBusy FALSE TRUE ATDone FALSE Time StopMV Time Autotuning processing MV set to StopMV. PID constants updated for results of autotuning. 2-679 NY-series Instructions Reference Manual (W560)
  • Page 732: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Autotuning Canceled TRUE FALSE TRUE StartAT FALSE TRUE ATBusy ATBusy also changes to FALSE FALSE when autotuning is canceled. TRUE ATDone ATDone remains FALSE. FALSE Time StopMV Time processing processing Autotuning Autotuning canceled. MV set to StopMV. The PID constants from before autotuning was started are set.
  • Page 733: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  An Autotuning Error Occurs during Autotuning An autotuning error occurs and autotuning is stopped in the following cases. • If the MV equals the MV upper limit and the time for the deviation to reach 0 exceeds 19,999 s. •...
  • Page 734: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If hunting continues too long, increase ProportionalBand or increase IntegrationTime. Increase ProportionalBand or increase IntegrationTime. Time • If rapid hunting occurs, decrease DerivativeTime. Decrease DerivativeTime. Time Initial PID Constants for Temperature Control If you use the PIDAT instruction for temperature control, use the following initial values of the PID con- stants as reference.
  • Page 735: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Control status Automatic operation Automatic operation Variables Instruction execution when autotuning is not when autotuning is being stopped being executed executed MVUpLmt Possible Possible Not possible ManResetVal Possible Possible Not possible MVTrackSw Possible Possible Not possible MVTrackVal Possible Possible Not possible...
  • Page 736: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming In this sample, the PIDAT instruction is used to perform temperature control. The manipulated variable of the PIDAT instruction is converted to a time-proportional value and output to a heating device. This sample uses a timer instruction to convert to a time-proportional value. To use the TimeProportionalOut instruction to convert to a time-proportional value, refer to the sample programming that is provided for the TimeProportionalOut instruction (page 2-727).
  • Page 737: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If the most recent value of MV is smaller than the value of MV when the output control values were determined, the output control values do not change. If the most recent value of MV is larger than the value of MV when the output control values were determined, the most recent value is immediately reflected in the output control values.
  • Page 738: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Initial value Retain Comment ErrorID1 WORD 16#0 Error ID REAL Manipulated variable PulseOnTime TIME T#0s Control output ON time PulseCycTime TIME T#1s Control period ResetPulse BOOL FALSE Timer reset PIDAT_instance PIDAT TOF_instance TON_instance Obtain the process value. Inline ST Note: The contents of the inline ST are given below at Contents of Inline ST1.
  • Page 739: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Initial value Retain Comment Run1 BOOL FALSE Execution condition ManCtl1 BOOL FALSE Manual/auto control Autotuning execution condi- StartAT1 BOOL FALSE tion REAL Process value REAL Set point (MVLowLmt:=0.0, MVUpLmt:=100.0, ManResetVal:=0.0, OprSetParams1 _sOPR_SET_PARAMS MVTrackSw:=FALSE, Operation setting parameters MVTrackVal:=0.0, StopMV:=0.0, ErrorMV:=0.0, Alpha:=0.65, ATCalcGain:=1.0, ATHystrs:=0.2)
  • Page 740: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Error =>Error1, ErrorID =>ErrorID1, =>MV1); // Time-proportional output PulseOnTime:=MULTIME(PulseCycTime, MV1/REAL#100.0); // Calculate ON time output control value. TOF_instance(In:=BOOL#FALSE, PT:=PulseOnTime, Q=>DO1); // Switch between ON and OFF with TOF instruction. TON_instance(In:=BOOL#TRUE, PT:=PulseCycTime, Q=>ResetPulse); // Measure timer reset time with TON instruction. IF (ResetPulse=BOOL#TRUE) THEN // Reset timer.
  • Page 741 2 Instruction Descriptions PIDAT_HeatCool The PIDAT_HeatCool instruction performs heating/cooling PID control with autotuning (2-PID control with set point filter). Instruction Name Graphic expression ST expression PIDAT_HeatCool_instance( Run, PIDAT_HeatCool_instance ManCtl, PIDAT_HeatCool StartAT, ATDone ManCtl ATBusy StartAT Error DeadBand, ErrorID OprSetParams, DeadBand MV_Heat InitSetParams, OprSetParams...
  • Page 742: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variables Name Meaning Description Valid range Unit Default Execution TRUE: Execute condition FALSE: Stop Manual/auto TRUE: Manual operation Depends on ManCtl control FALSE FALSE: Automatic operation data type. Autotuning TRUE: Execute StartAT execution con- FALSE: Cancel dition Process value Process value Set point...
  • Page 743: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Name Meaning Description Valid range Unit Default Autotuning TRUE: Normal completion ATDone normal com- FALSE: pletion Depends on Autotuning TRUE: Autotuning ATBusy data type. busy FALSE: Not autotuning Manipulated Manipulated variable variable Output Manipulated variable for Manipulated variable for heating MV_Heat 0 to 320 heating con-...
  • Page 744: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings ATBusy MV_Heat MV_Cool Function The PIDAT_HeatCool instruction performs heating/cooling PID control of a manipulated variable for a temperature controller or other device. Heating/cooling PID control is started when the value of execution condition Run changes to TRUE. While the value of Run is TRUE, the following process is repeated periodically: process value PV is read, heating/cooling PID processing is performed, and manipulated variable for heating MV_Heat and manipulated variable for cooling MV_Cool are output.
  • Page 745: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Difference between the PIDAT_HeatCool and PIDAT Instructions  PIDAT_HeatCool Instruction The PIDAT_HeatCool instruction uses both a heating device and a cooling device to control the tem- perature. Therefore, manipulated variables are output for two different control operations: the manipulated variable for heating control, MV_Heat, and the manipulated variable for cooling control, MV_Cool.
  • Page 746: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Manipulated Variable MV Compared with Manipulated Variable for Heating Control MV_Heat and Manipulated Variable for Cooling Control MV_Cool MV is the manipulated variable for an instruction like the PIDAT instruction that uses either a heating device or a cooling device to control the temperature. The PIDAT_HeatCool instruction also calculates MV in the same way as the PIDAT instruction.
  • Page 747: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Structure Specifications The data type of operation setting parameter OprSetParams is structure _sOPR_SET_PARAMS. The specifications are as follows: Name Meaning Description Data type Valid range Unit Default Operation Parameters that are set _sO- OprSetParams Setting during operation. PR_SET_PAR Parameters MV Lower...
  • Page 748: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of initial setting parameter InitSetParams is structure _sINIT_SET_PARAMS. The speci- fications are as follows: Name Meaning Description Data type Valid range Unit Default Initial Setting Initial setting parame- _sIN- InitSetParams Parameters ters. IT_SET_PAR Sampling The period for PID pro- T#0.0001s to SampTime...
  • Page 749: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  DeadBand (Deadband) DeadBand determines how the value of MV is distributed to MV_Heat and MV_Cool. DeadBand gives the range of the value of MV centered on an MV value of 0 within which both heating and cool- ing control operations are not performed.
  • Page 750: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  MVLowLmt (MV Lower Limit) and MVUpLmt (MV Upper Limit) You can limit the values of MV_Heat and MV_Cool. The upper and lower limits of MV_Heat and MV_Cool are determined by MVLowLmt and MVUpLmt. The following procedure is used to find the values of MV_Heat and MV_Cool.
  • Page 751: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows the relationship between MV, MV_Heat, and MV_Cool when MVLowLmt is 100 and MVUpLmt is 200. The calculated upper limit of MV_Heat is 200 and the calculated lower limit is 100. The value of MV_Cool is always 0. In other words, the upper and lower limits of MV_Heat are the same as MVUpLmt and MVLowLmt.
  • Page 752: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  ManResetVal (Manual Reset Value) This instruction does not use this variable. Any value that is set is ignored.  MVTrackSw (MV Tracking Switch) MV tracking is a function that sets the MV to an external input value (called the MV tracking value) during automatic operation.
  • Page 753: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Refer to the description of autotuning in the section on the PIDAT instruction (page 2-664) for details.  SampTime (Sampling Period) This is the minimum value of the period for heating/cooling PID processing. Refer to the description of the execution timing of heating/cooling PID processing for details. Heat- ing/cooling PID processing is not performed again until the time specified for SampTime has elapsed since the last time heating/cooling PID processing was performed.
  • Page 754: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The value of ManMV does not have to be between MVLowLmt and MVUpLmt. Value of MV_Heat from automatic operation is used. MV_Heat Value of MV_Heat from manual operation is used. Time ManCtl changed to FALSE. ManCtl changed to TRUE. Value of ManMV changed.
  • Page 755: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Heating/Cooling PID Processing Refer to the section on the PIDAT instruction (page 2-664) for details on PID processing. Heating/cooling PID processing is used to find the manipulated variables using the PID constants for heating control and the PID constants for cooling control. If MV is less than or equal to 0 in the previous processing results, the PID constants for heating control are used.
  • Page 756: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Control Status and Manipulated Variable Manipulated variable MV is determined according to the control status as shown in the following table. Value of variable ManCtl Manipulated vari- Run (exe- Error MVTrackSw ATBusy Control status (man- able MV cution con- (error (MV tracking...
  • Page 757: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Autotuning The 2-PID parameter α is not adjusted very often, so the main parameters that are adjusted for this instruction are the PID constants. The PIDAT instruction supports autotuning of the PID constants. The limit cycle method is used for autotuning.
  • Page 758: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Execution Timing of Heating/Cooling PID Control Heating/cooling PID control is repeated periodically. Heating/cooling PID processing is performed when the PIDAT instruction is executed in the user program. However, if sampling period SampTime has not elapsed since the last time heating/cooling PID pro- cessing was performed, heating/cooling PID processing is not performed.
  • Page 759: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Timing Charts Timing charts for the instruction variables are provided below for different situations.  Autotuning Executed during Automatic Operation • In the following figure, the value of ManCtl is FALSE, so the value of MV will be StopMV as long as the value of Run is FALSE.
  • Page 760: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Autotuning Executed at the Start of PIDAT Execution • In the following figure, the value of ManCtl is FALSE, so the value of MV will be StopMV as long as the value of Run is FALSE. •...
  • Page 761: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Autotuning Canceled • In the following figure, the value of ManCtl is FALSE, so the value of MV will be StopMV as long as the value of Run is FALSE. • When the value of Run changes to TRUE, MV is output based on the PID constants. •...
  • Page 762: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  An Autotuning Error Occurs during Autotuning An autotuning error occurs and autotuning is stopped in the following cases. • If the manipulated variable equals the upper limit of the limit cycle manipulated variable and the time for the deviation to reach 0 exceeds 19,999 s. •...
  • Page 763: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information Adjusting PID Constants Refer to the section on the PIDAT instruction (page 2-664) for the adjustment methods for PID constants. Initial PID Constants for Temperature Control If you use the PIDAT instruction for temperature control, use the following initial values of the PID con- stants as reference.
  • Page 764: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • The following table shows which variables can be changed depending on the operating status. Control status Instruction exe- Automatic operation when Automatic operation when Variables cution autotuning is not being exe- autotuning is being exe- stopped cuted cuted Possible...
  • Page 765: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • SampTime is truncated below 100 nanoseconds. • If the value of StartAT changes to TRUE while the value of ManCtl is TRUE, autotuning starts the next time the value of ManCtl changes to FALSE. • If the value of ErrorMV is not within the valid range (−320 to 320), the value of MV will be 0 when an error occurs.
  • Page 766: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming In this sample, the PIDAT_HeatCool instruction is used to perform temperature control. There is one analog thermocouple input from the controlled system. There are two outputs to the controlled system, a heating digital output and a cooling digital output. The heating digital output turns the heating device ON and OFF.
  • Page 767: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Touch Panel Specifications This sample assumes that a touch panel is connected to the Controller. The following I/O information is handled through the touch panel. Information Sample programming execution flag Manual/auto control flag Set point Inputs Autotuning execution flag Deadband Initial setting parameters Operation setting parameters...
  • Page 768: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Application Programming Definitions of Global Variables Global Variables Net- Variable Data type Initial value Retain work Comment Publish IOBus://rack# J01_Ch1_AI- Not pub- Thermocouple input 0/slot#0/Ch1 InPV lished. from CJ1W-AD04U _AIInPV IOBus://rack# J02_Ch1_Ou 0/slot#1/Ch1 Not pub- Heating output to BOOL FALSE _Out/Ch1_O...
  • Page 769: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Net- Variable Data type Initial value Retain work Comment Publish Integration time for heating control I/O PT_TI_Heat LINT 1000 Input from touch panel (unit: ms) Derivative time for heating control I/O PT_TD_Heat LINT 1000 Input from touch panel (unit: ms) Proportional band for PT_PB_Cool...
  • Page 770: Pidat_Heatcool

    2 Instruction Descriptions Internal Initial Vari- Variable Data type Comment value ables Proportional band for heating con- PB_Heat REAL trol Proportional band for cooling con- PB_Cool REAL trol REAL Manipulated variable Manipulated variable for heating MV_Heat REAL control Manipulated variable for cooling MV_Cool REAL control...
  • Page 771: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions External Vari- Variable Data type Comment ables J01_Ch1_AIInPV Thermocouple input from CJ1W-AD04U J02_Ch1_Out00 BOOL Heating output to CJ1W-OC201 J02_Ch1_Out04 BOOL Cooling output to CJ1W-OC201 Sample programming execution flag PTIn_Run BOOL input from touch panel Manual/auto control flag input from PTIn_ManCtl BOOL touch panel...
  • Page 772: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Convert unit of input values from CJ1W-AD04U and touch panel. Inline ST Note: The contents of the inline ST are given below at Contents of Inline ST1. Execute PIDAT_HeatCool instruction. PIDAT_HeatCool_inst PTIn_Run PIDAT_HeatCool ATDone PTIn_ManCtl ManCtl ATBusy PTIn_StartAT StartAT Error...
  • Page 773: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Heating output to CJ1W-OC201 TPOHeat_Inst PIDAT_HeatCool_inst.ATBusy J02_Ch1_Out00 TimeProportionalOut Enable DOut MVHeat Error CtlPrd_Heat CtlPrd MinPlsWidth Delay ATHeatPhase MVHeatTime CtlPrd_Heat AT_Heat ATHeatPhase EachCtlPrd_ATHeat_inst.Q <> MVHeatTime MVHeatTime CtlPrd_Heat Cooling output to CJ1W-OC201 TPOCool_Inst PIDAT_HeatCool_inst.ATBusy J02_Ch1_Out04 TimeProportionalOut Enable DOut MVCool Error CtlPrd_Cool CtlPrd...
  • Page 774: Ptout_Pv

    2 Instruction Descriptions  Contents of Inline ST2 MVHeatTime := MULTIME(CtlPrd_Heat,(MV_Heat/100)); MVCoolTime := MULTIME(CtlPrd_Cool,(MV_Cool/100));  Contents of Inline ST3 // Create output values to touch panel. PTOut_PV := PV; PTOut_ATDone := PIDAT_HeatCool_inst.ATDone; PTOut_ATBusy := PIDAT_HeatCool_inst.ATBusy; PTOut_Error := PIDAT_HeatCool_inst.Error; PTOut_MV := PIDAT_HeatCool_inst.MV; PTOut_MVHeat := PIDAT_HeatCool_inst.MV_Heat;...
  • Page 775: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Initial Vari- Variable Data type Comment value ables Proportional band for heating con- PB_Heat REAL trol Proportional band for cooling con- PB_Cool REAL trol REAL Manipulated variable Manipulated variable for heating MV_Heat REAL control Manipulated variable for cooling MV_Cool REAL control...
  • Page 776: Thermocouple Input From Cj1W-Ad04U Heating Output To Cj1W-Oc201

    2 Instruction Descriptions External Vari- Variable Data type Comment ables J01_Ch1_AIInPV Thermocouple input from CJ1W-AD04U J02_Ch1_Out00 BOOL Heating output to CJ1W-OC201 J02_Ch1_Out04 BOOL Cooling output to CJ1W-OC201 Sample programming execution flag PTIn_Run BOOL input from touch panel Manual/auto control flag input from PTIn_ManCtl BOOL touch panel...
  • Page 777: Cooling Output To Cj1W-Oc201

    2 Instruction Descriptions PB_Heat := PT_PB_Heat; TI_Heat := NanoSecToTime(PT_TI_Heat*1000000); TD_Heat := NanoSecToTime(PT_TD_Heat*1000000); PB_Cool := PT_PB_Cool; TI_Cool := NanoSecToTime(PT_TI_Cool*1000000); TD_Cool := NanoSecToTime(PT_TD_Cool*1000000); ManMV := PT_ManMV; // Execute PIDAT_HeatCool instruction. PIDAT_HeatCool_inst(Run :=PTIn_Run, ManCtl :=PTIn_ManCtl, StartAT :=PTIn_StartAT, :=PV, :=PTIn_SP, DeadBand :=PTIn_DeadBand, OprSetParams :=PTIn_OprParam, InitSetParams :=PTIn_InitParam, ProportionalBand_Heat :=PB_Heat,...
  • Page 778: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions ( AT_Cool_inst.Q & ATCoolPhase ); // Create output values to touch panel. PTOut_PV := PV; PTOut_ATDone := PIDAT_HeatCool_inst.ATDone; PTOut_ATBusy := PIDAT_HeatCool_inst.ATBusy; PTOut_Error := PIDAT_HeatCool_inst.Error; PTOut_MV := PIDAT_HeatCool_inst.MV; PTOut_MVHeat := PIDAT_HeatCool_inst.MV_Heat; PTOut_MVCool := PIDAT_HeatCool_inst.MV_Cool; PT_PB_Heat := PB_Heat; PT_TI_Heat := TimeToNanoSec(TI_Heat)/1000000; PT_TD_Heat := TimeToNanoSec(TD_Heat)/1000000;...
  • Page 779: Timeproportionalout

    2 Instruction Descriptions TimeProportionalOut The TimeProportionalOut instruction converts a manipulated variable to a time-proportional output. Instruction Name Graphic expression ST expression TimeProportionalOut_instance( Enable, TimeProportionalOut_Instance AIn, TimeProportionalOut CtlPrd, Time- TimeProportion Enable DOut MinPlsWidth, proportional Error alOut Delay, Output CtlPrd DOut, MinPlsWidth Error);...
  • Page 780: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The TimeProportionalOut instruction converts a manipulated variable, such as the one for PID control, to a time-proportional output. A time-proportional output converts a manipulated variable to a time ratio between ON and OFF. While Enable is TRUE, the value of manipulated variable AIn is converted to time-proportional output DOut for control period CtlPrd.
  • Page 781: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Update Timing of the Value of Manipulated Variable AIn When value of AIn is updated depends on whether DOut is FALSE or TRUE.  DOut = FALSE While DOut is FALSE, any change in the value of AIn is applied in the next control period. CtlPrd = 1 s CtlPrd = 1 s 700 ms...
  • Page 782: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Operation of Time-proportional Output DOut for Minimum Pulse Width MinPlsWidth The minimum pulse width is the minimum time that DOut will retain a value of TRUE or FALSE. You can set minimum pulse width MinPlsWidth to reduce chattering in DOut. For example, if the number of times a fan is turned ON and OFF is reduced in cooling control, power consumption is reduced.
  • Page 783: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Operation of Time-proportional Output DOut for Delay The delay prevents DOut from changing to TRUE until the set time has elapsed from the start of the control period. If more than one of this instruction is used, you can offset the timing of when DOut changes to TRUE by setting Delay.
  • Page 784: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • An error occurs if the value of AIn, CtlPrd, MinPlsWidth, or Delay is outside of the valid range. Error changes to TRUE and DOut changes to FALSE. If the value of AIn exceeds the valid range, the operation of DOut will be as shown below depending on when the error is reset.
  • Page 785: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Specifications Temperature control is performed according to the following specifications. Item Specification Input Unit CJ1W-PH41U Isolated-type Universal Input Unit Input types K thermocouples Output Unit CJ1W-OD212 Transistor Output Unit Set point 100°C Upper limit of temperature 200°C Lower limit of temperature 0°C Hysteresis of upper/lower limit alarm...
  • Page 786: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Configuration Diagram CJ1W-PH41U CJ1W-OD212 Bit 00 of output word 1 Heating device Control target Input 1 Sensor with K thermocouple Bit 01 of output word 1 Heating device Control target Input 2 Sensor with K thermocouple Bit 02 of output word 1 Heating device...
  • Page 787 2 Instruction Descriptions  Operation of Upper/Lower Limit Alarms and Upper/Lower Deviation Alarms Hysteresis of upper/ Hysteresis of upper/ lower limit alarm = 5°C lower deviation alarm = 3°C Process temperature (°C) Upper limit of temperature Upper deviation temperature = 50°C Set point 100 Lower deviation temperature = 50°C Lower limit of temperature 0...
  • Page 788: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Name Data type Default Retain Comment Lower limit set value of LowVal ARRAY[0..3] OF REAL [4(0.0)] upper/lower limit alarm Hysteresis of Hystrs_LimitAlarm ARRAY[0..3] OF REAL [4(5)] upper/lower limit alarm Upper/lower limit alarm Q_LimitAlarm ARRAY[0..3] OF BOOL [4(False)] output HighAlm ARRAY[0..3] OF BOOL...
  • Page 789 2 Instruction Descriptions Name Data type Default Retain Comment ARRAY[0..3] OF REAL [4(0.0)] Manipulated variable CtlPrd ARRAY[0..3] OF TIME [4(T#1s)] Control period MinPlsWidth ARRAY[0..3] OF REAL [4(0.0)] Minimum pulse width Delay ARRAY[0..3] OF REAL [4(0.0)] ON-delay time Error in TimeProp Error_ ARRAY[0..3] OF BOOL [4(False)]...
  • Page 790 2 Instruction Descriptions Execute PIDAT instruction. PIDAT_instance Run[index] ATDone[index] PIDAT ATDone ManCtl[index] ManCtl ATBusy ATBusy[index] StartAT[index] Error_PIDAT[index] StartAT Error PV[index] ErrorID ErrorID[index] SP[index] MV[index] OprSetParams OprSetParams InitSetParams InitSetParams ProportionalBand PB[index] PB[index] IntegrationTime TI[index] TI[index] DerivativeTime TD[index] TD[index] ManMV ManMV[index] ManMV[index] Time-proportional output TimeProportionalOut_Instance DOut_TPO...
  • Page 791 2 Instruction Descriptions Name Data type Default Retain Comment index UINT Loop index Execution of LimitAlarm_ON BOOL True Upper/Lower Limit Alarm instruction Execution of LimitAlarmDv_ON BOOL True Upper/Lower Devia- tion Alarm instruction Execution of Time- TimeProportionalO BOOL True proportional Output ut_ON instruction Present value...
  • Page 792 2 Instruction Descriptions Name Data type Default Retain Comment (MVLowLmt:=0.0, MVUpLmt:=100.0, ManResetVal:=0.0, MVTrackSw:=False, Operation setting OprSetParams _sOPR_SET_PARAMS MVTrackVal:=0.0, StopMV:=0.0, parameters ErrorMV:=0.0, Alpha:=0.65, ATCalcGain:=1.0, ATHystrs:=0.2) (SampTime:=T#100ms, Initial setting parame- InitSetParams _sINIT_SET_PARAMS RngLowLmt:=−10.0, ters RngUpLmt:=1000.0, DirOpr:=False) ARRAY[0..3] OF REAL [4(10)] Proportional band ARRAY[0..3] OF TIME [4(T#0S)] Integration time...
  • Page 793 2 Instruction Descriptions :=HighVal[index], :=PV[index], :=LowVal[index], :=Hystrs_LimitAlarm[index], =>Q_LimitAlarm[index], =>HighAlm[index], =>LowAlm[index], Error =>Error_LimitAlarm[index]); // Perform an output as a safety measure if an error occurs in the // LimitAlarmDv_REAL instruction or if an upper/lower limit alarm occurs. Alm_LimitAlarm[index]:=Q_LimitAlarm[index] OR Error_LimitAlarm[index]; // Upper/lower deviation alarm LimitAlarmDv_REAL_instance( Enable :=LimitAlarmDv_ON, :=PV[index],...
  • Page 794: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions INT#2: DO3:=DOut_TPO; ELSE DO4:=DOut_TPO; END_CASE; END_FOR; 2-742 NY-series Instructions Reference Manual (W560)
  • Page 795: Limitalarm

    2 Instruction Descriptions LimitAlarm_** The LimitAlarm_** instruction outputs an alarm if the input value is below the lower limit set value or above the upper limit set value. Instruction Name Graphic expression ST expression LimitAlarm_**_instance( Enable, LimitAlarm_**_Instance LimitAlarm_** Upper/Lower EPS, Enable LimitAlarm_** Limit Alarm...
  • Page 796: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings Enable Must be same data type as H. Must be same data type as H. Must be same data type as H. Function The LimitAlarm_** instruction monitors the input value to see if it is between the lower limit set value and the upper limit set value.
  • Page 797: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Operation of Lower Limit Alarm QL The value of lower limit alarm QL changes as shown below. You can set the hysteresis to prevent hunting in the limit alarm. • If Input value X < Lower limit set value L, then QL is TRUE. •...
  • Page 798: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • Use the LimitAlarm_REAL instruction to reduce the instruction execution time. • You can set EPS to less than H − L. If you do so, both QH and QL can be TRUE at the same time. Hysteresis EPS Input value X for the lower limit alarm...
  • Page 799: Limitalarmdv

    2 Instruction Descriptions LimitAlarmDv_** The LimitAlarmDv_** instruction outputs an alarm if the deviation in the input value from the reference value exceeds the lower deviation set value or the upper deviation set value. Instruction Name Graphic expression ST expression LimitAlarmDv_**instance( Enable, LimitAlarmDv_**_Instance LimitAlarmDv_**...
  • Page 800: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings Enable Must be same data type as X. Must be same data type as X. Must be same data type as X. Must be same data type as X. Function The LimitAlarmDv_** instruction monitors the deviation in the input value from the reference value to see if it exceeds the lower deviation set value or the upper deviation set value.
  • Page 801: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Operation of Upper Deviation Alarm QH Upper deviation alarm QH is the alarm for an upward deviation in respect to reference value Y. The value of QH changes as shown below. You can set the hysteresis to prevent hunting in the deviation alarm.
  • Page 802: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Notation Example The following notation example sets upper deviation set value H to 50°C, lower deviation set value L to 40°C, and hysteresis EPS to 10°C. LimitAlarmDv_LREAL_Instance Alarm LimitAlarmDv_LREAL Enable H_Alarm L_Alarm LREAL#50 Error0 Error LREAL#40 LREAL#10 LimitAlarmDv_LREAL_instance(A,PV,LREAL#50,SP,LREAL#40,LREAL#10,Alarm,H_Alarm,L_Alarm,Error0);...
  • Page 803: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • You can set H and L so that H + L = 0. If you do so, either QH or QL will always be TRUE. For exam- ple, the following figure shows the operation when the value of L is −60 and the value of H is 30. Lower deviation set value L = −60 Hysteresis EPS Upper deviation set value H = 30...
  • Page 804: Limitalarmdvstbyseq

    2 Instruction Descriptions LimitAlarmDvStbySeq_** The LimitAlarmDvStbySeq_** instruction outputs upper and lower deviation alarms with a standby sequence. Instruction Name Graphic expression ST expression LimitAlarmDvStbySeq_**_instance( Enable, LimitAlarmDvStbySeq_**_Instance Upper/Lower LimitAlarmDvStbySeq_** Deviation EPS, Enable LimitAlarmD- Alarm with vStbySeq_** Standby Sequence StbySeqFlag Group Error StbySeqFlag, Error);...
  • Page 805: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings Enable Must be same data type as X. Must be same data type as X. Must be same data type as X. Must be same data type as X. StbySeq Flag Function...
  • Page 806: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions StbySeqFlag changes to FALSE when all of the following conditions are met after Enable changes to TRUE. After StbySeqFlag changes to FALSE, it will not change to TRUE until Enable changes from FALSE to TRUE. • Input value X − Reference value Y < Upper deviation set value H − Hysteresis EPS •...
  • Page 807: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • If −(Input value X − Reference value Y) < Lower deviation set value L − Hysteresis EPS, then QL is FALSE. Input value X Lower deviation set value H Reference value X Hysteresis EPS Time TRUE Lower deviation alarm QL FALSE Standby Sequence...
  • Page 808: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • Use the LimitAlarmDvStbySeq_REAL instruction to reduce the instruction execution time. • You can set EPS to less than H + L. If you do so, both QH and QL can be TRUE at the same time. Refer to the LimitAlarmDv_** instruction (page 2-747).
  • Page 809: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Configuration and Settings The following settings are used for the CJ1W-PH41U Input Unit. Item Set value Input1:Input signal type K(1) Input2:Input signal type K(1) Input3:Input signal type K(1) Input4:Input signal type K(1) The following I/O map settings are used. Unit I/O port Description...
  • Page 810: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Use the LimitAlarmDvStbySeq_REAL instruction to output upper/lower deviation alarms with a standby sequence for the deviation between the set point and the process temperature. Perform an output as a safety measure if an error occurs in the LimitAlarmDvStbySeq_REAL instruction or if an upper/lower deviation alarm occurs.
  • Page 811 2 Instruction Descriptions Application Programming Name Data type Default Retain Comment index UINT Loop index Execution of LimitAlarm_ON BOOL True Upper/Lower Limit Alarm instruction Execution of LimitAlarmDvStbySe- Upper/Lower Deviation BOOL True q_ON Alarm with Standby Sequence instruction Execution of TimeProportionalO BOOL True TimeProportionalOut...
  • Page 812: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Name Data type Default Retain Comment Output for safety mea- sure for Upper/Lower Alm_LimitAlarmDv ARRAY[0..3] OF BOOL [4(False)] Deviation Alarm instruc- tion ARRAY[0..3] OF BOOL [4(False)] Execution condition ManCtl ARRAY[0..3] OF BOOL [4(False)] Manual/auto control Autotuning execution StartAT ARRAY[0..3] OF BOOL [4(False)]...
  • Page 813 2 Instruction Descriptions Control temperature for four points. index UINT#0 InitVal Index UINT#3 EndVal StepVal UINT#1 Obtain the process value. Inline ST Note: Refer to Contents of Inline ST 1 for the contents of the inline ST. Upper/lower limit alarm LimitAlarm_REAL_Instance LimitAlarm_ON Q_LimitAlarm[index]...
  • Page 814 2 Instruction Descriptions Execute PIDAT instruction. PIDAT_instance Run[index] ATDone[index] PIDAT ATDone ManCtl[index] ManCtl ATBusy ATBusy[index] StartAT[index] Error_PIDAT[index] StartAT Error PV[index] ErrorID ErrorID[index] SP[index] MV[index] OprSetParams OprSetParams InitSetParams InitSetParams ProportionalBand PB[index] PB[index] IntegrationTime TI[index] TI[index] DerivativeTime TD[index] TD[index] ManMV ManMV[index] ManMV[index] Time-proportional output TimeProportionalOut_Instance DOut_TPO...
  • Page 815 2 Instruction Descriptions Name Data type Default Retain Comment index UINT Loop index Execution of LimitAlarm_ON BOOL True Upper/Lower Limit Alarm instruction Execution of LimitAlarmDvStby- Upper/Lower Devia- BOOL True Seq_ON tion Alarm with Standby Sequence instruction Execution of Time- TimeProportionalO BOOL True proportional Output...
  • Page 816 2 Instruction Descriptions Name Data type Default Retain Comment Autotuning execution StartAT ARRAY[0..3] OF BOOL [4(False)] condition (MVLowLmt:=0.0, MVUpLmt:=100.0, ManResetVal:=0.0, MVTrackSw:=False, Operation setting OprSetParams _sOPR_SET_PARAMS MVTrackVal:=0.0, StopMV:=0.0, parameters ErrorMV:=0.0, Alpha:=0.65, ATCalcGain:=1.0, ATHystrs:=0.2) (SampTime:=T#100ms, Initial setting parame- InitSetParams _sINIT_SET_PARAMS RngLowmt:=−10.0, ters RngUpLmt:=1000.0, DirOpr:=False) ARRAY[0..3] OF REAL [4(10)]...
  • Page 817 2 Instruction Descriptions LimitAlarm_REAL_instance( Enable :=LimitAlarm_ON, :=HighVal[index], :=PV[index], :=LowVal[index], :=Hystrs_LimitAlarm[index], =>Q_LimitAlarm[index], =>HighAlm[index], =>LowAlm[index], Error =>Error_LimitAlarm[index]); // Perform an output as a safety measure if an error occurs in the // LimitAlarm_REAL instruction or if an upper/lower limit alarm occurs. Alm_LimitAlarm[index]:=Q_LimitAlarm[index] OR Error_LimitAlarm[index]; // Upper/lower deviation alarm with standby sequence LimitAlarmDvStbySeq_REAL_instance( Enable...
  • Page 818 2 Instruction Descriptions CASE index OF INT#0: DO1:=DOut_TPO; INT#1: DO2:=DOut_TPO; INT#2: DO3:=DOut_TPO; ELSE DO4:=DOut_TPO; END_CASE; END_FOR; 2-766 NY-series Instructions Reference Manual (W560)
  • Page 819: Scaletrans

    2 Instruction Descriptions ScaleTrans The ScaleTrans instruction converts input values from an input range to an output range. Instruction Name FB/FUN Graphic expression ST expression ScaleTrans Scale Transfor- (@)ScaleTrans mation :=ScaleTrans(SclIn,X0,Y0,X1,Y1, SclOfs); SclIn SclOfs Variables Name Meaning Description Valid range Unit Default SclIn...
  • Page 820: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following conversion is used. Output Y1−Y0 (Sclln − X0) + Y0 + SclOfs Out = X1−X0 SclOfs Input SclIn Notation Example The following notation example scales an input value of 2,500 from an input range of 0 to 4,000 to an output range of 0% to 100%.
  • Page 821: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • When scaling SclIn to the ranges of the values of PV and SP of the PIDAT instruction, pass the fol- lowing parameters to Y0 and Y1. Variable Parameter InitSetParams.RngLowLmt (input range lower limit of the PIDAT instruction) InitSetParams.RngUpLmt (input range upper limit of the PIDAT instruction) •...
  • Page 822: Ac_Stepprogram

    2 Instruction Descriptions AC_StepProgram The AC_StepProgram instruction calculates the present set point and the predicted set point every task period according to the specified program pattern. Instruction Name Graphic expression ST expression AC_Step Step Program AC_StepProgram_instance( AC_StepProgram_instance Program Enable, Hold, Advance, PV, AC_StepProgram IntegrationTime, Alpha, Option, Enable...
  • Page 823: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, Bit strings Integers dates, and text strings Enable Hold Advance Integration- Time Alpha Option Refer to Function for details on the structure _sAC_STEP_OPTION. Program- Refer to Function for details on the structure _sAC_STEP_DATA. Pattern[] Specify an array. *1*2*3 array Wait...
  • Page 824: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions PresentSP (Present Set Point) Present set point PresentSP is the set point in the present task period. For example, assume that the user sets the set points for 0, 10, 40, and 60 minutes after the start of control as shown below. Also assume that the current time is 30 minutes after the start of control.
  • Page 825: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Structure Specifications The data type of Option is structure _sAC_STEP_OPTION. The specifications are as follows: Name Meaning Description Data type Valid range Unit Default _sAC_STEP Option Option Option _OPTION TRUE: Enable starting at PV Depends on StartAtPV Start at PV BOOL FALSE...
  • Page 826: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of clock information TimeInfo is structure _sAC_STEP_TIME. The specifications are as follows: Name Meaning Description Data type Valid range Unit Default Clock infor- _sAC_STEP TimeInfo Clock information mation _TIME The total of TimeWidth ProgramTime Program time from step 0 to End- TIME...
  • Page 827: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Input the value of IntegrationTime or the IntegrationTime variable in the PIDAT instruction or PIDAT_HeatCool instruction.  Alpha (2-PID Parameter α) This variable is the same as OprSetParams.Alpha in the PIDAT instruction. Input the value of OprSetParams.Alpha or the OprSetParams.Alpha variable in the PIDAT instruc- tion or PIDAT_HeatCool instruction.
  • Page 828: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  PresentSP (Present Set Point) This variable gives the calculated present set point.  PredictSP (Predicted Set Point) This variable gives the calculated predicted set point.  ProgramTime (Program Time) This variable gives the total of TimeWidth from step 0 to EndStepNo in the program pattern. Details on program patterns and steps are provided later.
  • Page 829: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Program Pattern The program pattern divides the processing from the start to end of execution of the instruction into steps and chronologically gives the target set point and time width for each step. The program pattern is expressed in the ProgramPattern[] array, which has elements with a data type of _sAC_STEP_DATA.
  • Page 830: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Start Step Number StartStepNo and End Step Number EndStepNo You can set any steps in the program pattern as the start step and the end step for processing. Set the number of the start step in StartStepNo and the number of the end step in EndStepNo. For example, if you set StartStepNo to 3 and EndStepNo to 6 when you execute the instruction, pro- cessing is performed from step 3 through step 6.
  • Page 831: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Timing during Waiting The operations of the time-related variables during waiting are described in the following table. Name Operation ElapseTime Continues timing. ProgressTime Stops timing and retains the value from when waiting started. Starts timing again from the retained value when waiting ends.
  • Page 832: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Holding Processing for the current step is held unconditionally whenever the value Hold is TRUE. While pro- cessing is held, timing is stopped for all time-related variables. Timing is started again for these time-related variables when the value of Hold changes to FALSE. ...
  • Page 833: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions An example of the start at PV operation is provided below. The following table gives the contents of Pro- gramPattern[]. ProgramPattern[] element number Step number Value of ReachSP Value of TimeWidth T#0s T#10m T#15m T#0s T#15m T#4m T#5m T#0s In this example, the value of PresentSP increases from the value for step 0.
  • Page 834: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Advancing If the value of Advance changes to TRUE during instruction execution, processing moves to the begin- ning of the next step.  Timing for Advancing The operations of the time-related variables when processing is advanced to the next step are described in the following table.
  • Page 835: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Changing the Program Pattern during Instruction Execution You can change the contents of ProgramPattern[] during execution of the instruction. If you change the contents of ProgramPattern[], the PresentSP is calculated again. Processing is started again from the time in StepProgressTime at the step that was in execution before the program pattern was changed.
  • Page 836: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Changing the Program Pattern during Waiting If you change the program pattern during waiting, waiting judgement is performed again for the recalculated PresentSP. However, if the value of StepProgressTime is larger than the value of WaitTimeLimit after the change, waiting is ended immediately and processing moves to the next step.
  • Page 837: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a timing chart for when an error occurs. TRUE Enable FALSE TRUE Done FALSE TRUE Busy FALSE TRUE Error FALSE ErrorID 16#0000 16#**** TRUE Wait FALSE PresentSP PredictSP Execution starts when Enable changes Execution ends when Enable changes to FALSE.
  • Page 838: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming This sample performs temperature control with the optimum PID parameters for each step in the AC_- StepProgram instruction. Processing This sample performs the following two processes. • It calculates the optimum PID parameters for each step. •...
  • Page 839: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Controlling Temperature According to the Program Pattern The optimum PID parameters for each step are used to control temperature according to the pro- gram pattern. The processing procedure is as follows: The user changes the value of ACSP_Enable to the AC_StepProgram instruction to TRUE. The AC_StepProgram instruction is executed and the value of step number StepNo changes to The user changes the value of execution condition Run to the PIDAT instruction to TRUE.
  • Page 840: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  I/O Map The following I/O map settings are used. Data Variable Position Port Description Variable type type Unit1 Ch1 Measured Channel measured REAL N1_Ch1_Mea- Global value (REAL) sured_Value_REAL variable Value REAL Unit1 Ch2 Measured Channel measured REAL N1_Ch2_Mea- Global...
  • Page 841: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables Enable for AC_StepPro- ACSP_Enable BOOL FALSE gram Hold BOOL FALSE Hold Advance BOOL FALSE Advance (StartAtPV:=FALSE, Start- _sAC_STEP StepNo:=0, Option Option _OPTION EndStepNo:=7, Reserved:=[32(16#0)]) [(ReachSP:=30.0, TimeW- idth:=T#0s, WaitWidth:=3.0, WaitTimeLimit:=T#1m), (ReachSP:=100.0, TimeW- idth:=T#10m, WaitWidth:=3.0,...
  • Page 842: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables (ProgramTime:=T#0s, ElapseTime:=T#0s, ProgressTime:=T#0s, TimeInfo _sAC_STEP_TIME Clock information LeftTime:=T#0s, StepProgressTime:=T#0s, StepLeftTime:=T#0s) AC_StepProgram com- ACSP_Done BOOL FALSE pletion PIDAT instruction execu- BOOL FALSE tion condition ManCtl BOOL FALSE Manual/auto control Autotuning execution StartAT BOOL FALSE...
  • Page 843: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Perform holding for AC_StepProgram instruction during autotuning. StartAT Hold Execute AC_StepProgram instruction. ACSP ACSP_Enable ACSP_Done AC_StepProgram Enable Done Hold Hold Busy ACSP_Busy Advance ACSP_Error Advance Error N1_Ch1_Measured_Value_REAL ACSP_ErrorID ErrorID PIDbank[StepNo].TI IntegrationTime Wait Wait OprSetParams.Alpha StepNo Alpha StepNo Option PresentSP Option...
  • Page 844: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables Enable for AC_StepPro- ACSP_Enable BOOL FALSE gram Hold BOOL FALSE Hold Advance BOOL FALSE Advance (StartAtPV:=FALSE, Start- _sAC_STEP StepNo:=0, Option Option _OPTION EndStepNo:=7, Reserved:=[32(16#0)]) [(ReachSP:=30.0, TimeW- idth:=T#0s, WaitWidth:=3.0, WaitTimeLimit:=T#1m), (ReachSP:=100.0, TimeW- idth:=T#10m, WaitWidth:=3.0,...
  • Page 845: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables (ProgramTime:=T#0s, ElapseTime:=T#0s, ProgressTime:=T#0s, TimeInfo _sAC_STEP_TIME Clock information LeftTime:=T#0s, StepProgressTime:=T#0s, StepLeftTime:=T#0s) AC_StepProgram com- ACSP_Done BOOL FALSE pletion PIDAT instruction execu- BOOL FALSE tion condition ManCtl BOOL FALSE Manual/auto control Autotuning execution StartAT BOOL FALSE...
  • Page 846: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions TPO_Enable := TRUE; // Perform holding for AC_StepProgram instruction during autotuning. IF StartAT AND PreStartAT=FALSE THEN Hold := TRUE; END_IF; PreStartAT := StartAT; // Execute AC_StepProgram instruction. IF ACSP_Enable THEN ACSP(Enable :=ACSP_Enable, Hold :=Hold, Advance :=Advance, :=N1_Ch1_Measured_Value_REAL, IntegrationTime:=PIDbank[StepNo].TI, Alpha :=OprSetParams.Alpha,...
  • Page 847: System Control Instructions

    System Control Instructions Instruction Name Page TraceSamp Data Trace Sampling 2-796 TraceTrig Data Trace Trigger 2-799 GetTraceStatus Read Data Trace Status 2-802 SetAlarm Create User-defined Error 2-806 ResetAlarm Reset User-defined Error 2-811 GetAlarm Get User-defined Error Status 2-813 ResetPLCError Reset PLC Controller Error 2-815 GetPLCError Get PLC Controller Error Status...
  • Page 848: Tracesamp

    2 Instruction Descriptions TraceSamp The TraceSamp instruction performs sampling for a data trace. Instruction Name FB/FUN Graphic expression ST expression TraceSamp Data Trace TraceSamp(TraceNo, (@)TraceSamp Sampling Point); TraceNo Point Variables Name Meaning Description Valid range Unit Default TraceNo Trace num- Trace number Input Point...
  • Page 849: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions TraceSamp(USINT#1, USINT#2); TraceSamp USINT#1 TraceNo USINT#2 Point The present values for all variables that are set to be sampled are read and stored with trace number TraceNo and sampling point number Point in trace memory. TraceNo USINT#1 USINT#2 Point -------------- --------------...
  • Page 850: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming Here, sampling is performed at the end of each process A to D. The values of the variables are stored at each point. Process A TraceSamp USINT#0 TraceNo USINT#11 Point Process B TraceSamp USINT#1 TraceNo USINT#12 Point Process C...
  • Page 851: Tracetrig

    2 Instruction Descriptions TraceTrig The TraceTrig instruction generates a trigger for data tracing. Instruction Name FB/FUN Graphic expression ST expression TraceTrig Data Trace Trigger TraceTrig(TraceNo); (@)TraceTrig TraceNo Variables Name Meaning Description Valid range Unit Default TraceNo Trace Input Trace number number Return Output...
  • Page 852: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description Trace Information Trace information *1 NX701 or NJ501 CPU Unit, and NY-series Controller: The variable name is _PLC_TraceSta[0..3]. NX1P2, NJ301 or NJ101 CPU Unit: The variable name is _PLC_TraceSta[0..1]. *2 _sTRACE_STA[] *3 Refer to the NJ/NX-series CPU Unit Software User’s Manual (Cat.
  • Page 853: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Initial value Comment Current_speed Current speed Max_speed Maximum speed IF (Current_speed > Max_speed) THEN TraceTrig(USINT#1); END_IF; 2-801 NY-series Instructions Reference Manual (W560)
  • Page 854: Gettracestatus

    2 Instruction Descriptions GetTraceStatus The GetTraceStatus instruction reads the execution status of a data trace. Instruction Name FB/FUN Graphic expression ST expression GetTraceStatus Read Data Trace GetTraceStatus(TraceNo, (@)GetTraceStatus Status IsStart, IsComplete, ParamErr, IsTrigger); TraceNo IsStart IsComplete ParamErr IsTrigger Variables Name Meaning Description Valid range...
  • Page 855: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Times, durations, dates, Bit strings Integers and text strings IsComplete ParamErr IsTrigger Function The GetTraceStatus instruction reads the execution status of the data trace that is specified with trace number TraceNo. The status that is read is output to execution flag IsStart, completed flag IsComplete, parameter error flag ParamErr, and trigger flag IsTrigger.
  • Page 856: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information Refer to the NJ/NX-series CPU Unit Software User's Manual (Cat. No. W501) or NY-series Industrial Panel PC / Industrial Box PC Software User’s Manual (Cat. No. W558) for details on data tracing. Precautions for Correct Use •...
  • Page 857: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming In this sample, the GetTraceStatus instruction reads the execution status of the data trace with trace number 3. If the data trace is in progress, the TraceTrig instruction is executed to trigger data tracing. Variable Data type Initial value Comment...
  • Page 858: Setalarm

    2 Instruction Descriptions SetAlarm The SetAlarm instruction creates a user-defined error. Instruction Name FB/FUN Graphic expression ST expression SetAlarm Create User- SetAlarm(Code, Info1, (@)SetAlarm defined Error Info2); Code Info1 Info2 Variables Name Meaning Description Valid range Unit Default Code Event code Event code of user-defined 1 to 40000 error to generate...
  • Page 859: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Event code Classification: User fault level 1 to 5000 5001 to 10000 10001 to 15000 15001 to 20000 20001 to 25000 25001 to 30000 30001 to 35000 35001 to 40000 The following figure shows a programming example. A user-defined error with event code 101 is gener- ated.
  • Page 860: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information You can specify either global variables or local variables for Info1 and Info2. Precautions for Correct Use • Up to 32 user-defined errors can be generated in each of the eight event levels (for up to 256 user- defined errors total).
  • Page 861: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Check the value of variable A. TON_instance0 T#5s TON_instance1 T#5s Create user-defined error. @SetAlarm UINT#102 Code Info1 Info2 Reset user-defined error. @ResetAlarm WORD#16#0000 UINT#102 Code _AlarmFlag 2-809 NY-series Instructions Reference Manual (W560)
  • Page 862: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Initial Variable Data type Variables value BOOL FALSE BOOL FALSE BOOL FALSE BOOL FALSE UINT UINT TON_instance0 TON_instance1 External Variable Data type Constant Comment Variables _AlarmFlag WORD Error Status of User-defined Errors // Check the value of variable A. IF (A=TRUE) THEN TON_instance0(In:=TRUE, PT:=T#5s, Q=>B);...
  • Page 863: Resetalarm

    2 Instruction Descriptions ResetAlarm The ResetAlarm instruction resets a user-defined error. Instruction Name FB/FUN Graphic expression ST expression ResetAlarm Reset User-defined ResetAlarm(Code); (@)ResetAlarm Error Code Variables Name Meaning Description Valid range Unit Default Code Event code Input Event code of user-defined Depends on data type.
  • Page 864: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The ResetAlarm instruction resets the user-defined error specified by event code Code. Also an event is recorded in the user-defined event log area to show that a specific user-defined error was reset. Event code UINT#101 User-defined error is reset. Code User-defined Event Log Area Written.
  • Page 865: Getalarm

    2 Instruction Descriptions GetAlarm The GetAlarm instruction gets the highest event level (of user-defined error levels 1 to 8) and the high- est level event code of the current user-defined errors. Instruction Name FB/FUN Graphic expression ST expression GetAlarm Get User-defined Out:=GetAlarm(Level, (@)GetAlarm Error Status...
  • Page 866: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a programming example. abc:=GetAlarm(def, ghi); GetAlarm Level Code The GetAlarm instruction gets the highest event level and the highest level event code of the current user-defined error and outputs them to Level and Code. Current user-defined error exists.
  • Page 867: Resetplcerror

    2 Instruction Descriptions ResetPLCError The ResetPLCError instruction resets errors in the PLC Function Module. Instruction Name FB/FUN Graphic expression ST expression ResetPLCError Reset PLC ResetPLCError(Execute, ResetPLCError_instance Controller Error Done, Busy, Error, ErrorID); ResetPLCError Execute Done Busy Error ErrorID Variables Only common variables are used. Function The ResetPLCError instruction resets errors in the PLC Function Module.
  • Page 868: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming The ResetPLCError instruction is executed when the value of Trigger changes to TRUE. Normal end processing is performed if execution of the ResetPLCError instruction ends normally (i.e., if the value of Done is TRUE). Error end processing is performed if execution ends in an error (i.e., if the value of Error is TRUE).
  • Page 869: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Initial value Comment Trigger BOOL FALSE Execution condition Value of Trigger from previous LastTrigger BOOL FALSE task period OperatingStart BOOL FALSE Processing started Operating BOOL FALSE Processing ResetPLCError_instance ResetPLCError // Detect when Trigger changes to TRUE. IF ( (Trigger=TRUE) AND (LastTrigger=FALSE) ) THEN OperatingStart:=TRUE;...
  • Page 870: Getplcerror

    2 Instruction Descriptions GetPLCError The GetPLCError instruction gets the highest level status (partial fault or minor fault) and highest level event code of the current Controller errors in the PLC Function Module. Instruction Name FB/FUN Graphic expression ST expression GetPLCError Get PLC Controller Out:=GetPLCError(Level, (@)GetPLCError...
  • Page 871: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a programming example. abc:=GetPLCError(def, ghi); GetPLCError Level Code The GetPLCError instruction gets the highest level status and the highest level event code of the current Controller errors in the PLC Function Module and outputs them to Level and Code. Current Controller error exists.
  • Page 872: Geteiperror

    2 Instruction Descriptions GetEIPError The GetEIPError instruction gets the highest level status (partial fault or minor fault) and highest level event code of the current Controller errors in the EtherNet/IP Function Module. Instruction Name FB/FUN Graphic expression ST expression GetEIPError Get EtherNet/IP Out:=GetEIPError(Level, (@)GetEIPError...
  • Page 873: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The following figure shows a programming example. abc:=GetEIPError(def, ghi); GetEIPError Level Code The GetEIPError instruction gets the highest level status and the highest level event code of the current Controller errors in the EtherNet/IP Function Module and outputs them to Level and Code.
  • Page 874: Resetmcerror

    2 Instruction Descriptions ResetMCError The ResetMCError instruction resets Controller errors in the Motion Control Function Module. Instruction Name FB/FUN Graphic expression ST expression ResetMCError Reset Motion ResetMCError_instance( ResetMCError_instance Control Error Execute, Done, Busy, ResetMCError Failure Error, ErrorID); Execute Done Busy Failure Error ErrorID...
  • Page 875: Ny-Series Instructions Reference Manual (W560

    • If you attempt to execute this instruction during an MC Test Run, the value of Busy remains TRUE and the instruction is not executed. • If you execute this instruction for an OMRON G5-series Servo Drive, perform exclusive control of the instructions so that the ResetECError instruction is not executed at the same time.
  • Page 876: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming This sample detects Controller errors in the EtherCAT Master Function Module and Motion Control Function Module. If errors are detected, they are reset. The processing procedure is as follows: The GetECError instruction is executed to detect any Controller errors in the EtherCAT Master Function Module.
  • Page 877: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Initial value Comment Request BOOL FALSE Error detection reset request EC_Err_Level UINT Highest event level in EtherCAT Master Function Module Highest level event code in EtherCAT Master Function EC_Err_Code DWORD DWORD#16#0 Module EC_Operating BOOL FALSE Resetting error in EtherCAT Master Function Module MC_Err_Level...
  • Page 878: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Initial value Comment Request BOOL FALSE Error detection reset request EC_Error BOOL FALSE Error in EtherCAT Master Function Module EC_Err_Level UINT Highest event level in EtherCAT Master Function Module EC_Err_Code DWORD DWORD#16#0 Highest level event code in EtherCAT Master Function Module EC_Stage Error reset in EtherCAT Master Function Module MC_Error...
  • Page 879: Getmcerror

    2 Instruction Descriptions GetMCError The GetMCError instruction gets the highest level status (partial fault or minor fault) and highest level event code of the current Controller errors in the Motion Control Function Module. Instruction Name FB/FUN Graphic expression ST expression GetMCError Get Motion Control Out:=GetMCError(Level,...
  • Page 880: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The GetMCError instruction gets the highest level status and the highest level event code of the current Controller errors in the Motion Control Function Module and outputs them to Level and Code. If there are currently no Controller errors, the value of error flag Out is FALSE. If there is more than one Con- troller error at the highest event level, the value of Code is the event code for the Controller error that occurred first.
  • Page 881: Resetecerror

    2 Instruction Descriptions ResetECError The ResetECError instruction resets a Controller error in the EtherCAT Master Function Module. Instruction Name FB/FUN Graphic expression ST expression ResetECError Reset EtherCAT ResetECError_instance( ResetECError_instance Error Execute, Done, Busy, Error, ResetECError ErrorID); Execute Done Busy Error ErrorID Variables Only common variables are used.
  • Page 882: Ny-Series Instructions Reference Manual (W560

    • The error may not be reset immediately after you execute this instruction. Use the GetECError instruction to confirm that the errors were reset. • If you execute this instruction for an OMRON G5-series Servo Drive, perform exclusive control of the instructions so that the ResetMCError, MC_Reset, or MC_GroupReset instruction is not executed at the same time.
  • Page 883: Getecerror

    2 Instruction Descriptions GetECError The GetECError instruction detects errors in the EtherCAT Master Function Module. Instruction Name FB/FUN Graphic expression ST expression GetECError Get EtherCAT Error Out:=GetECError(Level, (@)GetECError Status Code); Level Code Variables Name Meaning Description Valid range Unit Default Error flag Depends on data type.
  • Page 884: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The GetECError instruction detects errors in the EtherCAT Master Function Module. The value of Out is TRUE if there is an error and FALSE if there is no error. Level gives the status of the current error with the highest level. Code gives the event code of the current error with the highest level.
  • Page 885: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Notation Example The following figure shows a programming example. abc:=GetECError(def, ghi); GetECError Level Code The GetECError instruction detects current communications port errors, master errors, and slave errors in the EtherCAT Master Function Module. There is a current error. Out = abc TRUE Acquired.
  • Page 886: Setinfo

    2 Instruction Descriptions SetInfo The SetInfo instruction creates user-defined information. Instruction Name FB/FUN Graphic expression ST expression SetInfo Create User- SetInfo(Code, Info1, Info2); (@)SetInfo defined Information Code Info1 Info2 Variables Name Meaning Description Valid range Unit Default Code Event code Event code of user-defined 40001 to 60000 40001...
  • Page 887: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Function The SetInfo instruction generates the user-defined information specified by event code Code. The time of occurrence, event code Code, event level, attached information Info1, and attached information Info2 are stored in the user event log area that corresponds to the level of the event code. The following figure shows a programming example.
  • Page 888: Restartnxunit

    2 Instruction Descriptions RestartNXUnit The RestartNXUnit instruction restarts an EtherCAT Coupler Unit or NX Unit. Instruction Name FB/FUN Graphic expression ST expression RestartNXUnit Restart NX RestartNXUnit_instance(Execute, RestartNXUnit_instance Units UnitProxy, Done, Busy, Error, RestartNXUnit ErrorID, ErrorIDEx); Execute Done UnitProxy Busy Error ErrorID ErrorIDEx Variables...
  • Page 889: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of UnitProxy is structure _sNXUNIT_ID. The meanings of the members are as follows: Name Meaning Content Data type UnitProxy Specified Unit Specified Unit _sNXUNIT_ID Node address of the Communications NodeAdr Node address UINT Coupler Unit IP address of the Communications IPAdr IP address...
  • Page 890: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description _EC_MBXSlavTbl[i] Message Communica- BOOL This variable indicates whether communications are tions Enabled Slave Table possible for each slave. “i” is the node address. TRUE: Communications are possible. FALSE: Communications are not possible. _NXB_UnitMsgActiveTbl NX Unit Message Enabled BOOL...
  • Page 891: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period. The value of Done changes to TRUE when processing is completed.
  • Page 892 2 Instruction Descriptions • Error is TRUE if an error occurred. The meanings of the values of ErrorID and ErrorIDEx are given in the following table. Value of ErrorID Value of ErrorIDEx Meaning 16#0419 16#00000000 The data type of UnitProxy is not correct. 16#00000401 The specified Unit does not support the instruction.
  • Page 893: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Value of ErrorID Value of ErrorIDEx Meaning 16#0030 0000 The specified Unit is busy. 16#8001 0000 Execute the instruction again. The specified Unit is not supported for connection. 16#0031 0000 Check the version of the Unit. 16#80000000 An error occurred in the communications network.
  • Page 894: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Version Information A CPU Unit with unit version 1.05 or later and Sysmac Studio version 1.06 or higher are required to use this instruction. However, some versions/unit versions of the following products do not support restarting specified NX Units independently. •...
  • Page 895: Nx_Changewritemode

    2 Instruction Descriptions NX_ChangeWriteMode The NX_ChangeWriteMode instruction changes an EtherCAT Coupler Unit or NX Unit to a mode that allows writing data. Instruction Name FB/FUN Graphic expression ST expression NX_Change Change to NX NX_ChangeWriteMode_instance Unit Write NX_ChangeWriteMode_instance (Execute, UnitProxy, Done, Busy, WriteMode Mode Error, ErrorID, ErrorIDEx);...
  • Page 896: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Pass the device variable that is assigned to the specified Unit to UnitProxy. Related Instructions and Execution Procedure You can use this instruction to write data with the following attributes to an EtherCAT Coupler Unit, an NX Unit on the EtherCAT Coupler Unit, or an NX Unit connected to the NX bus of the CPU Unit. •...
  • Page 897: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description _EC_MBXSlavTbl[i] Message Communica- BOOL This variable indicates whether communications are tions Enabled Slave Table possible for each slave. “i” is the node address. TRUE: Communications are possible. FALSE: Communications are not possible. _NXB_UnitMsgActiveTbl NX Unit Message Enabled BOOL...
  • Page 898 2 Instruction Descriptions • Error is TRUE if an error occurred. The meanings of the values of ErrorID and ErrorIDEx are given in the following table. Value of ErrorID Value of ErrorIDEx Meaning 16#0419 16#0000 0000 The data type of UnitProxy is not correct. 16#0000 0401 The specified Unit does not support the instruction.
  • Page 899: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Value of ErrorID Value of ErrorIDEx Meaning The specified node address is not correct. 16#00140000 Make sure that the Unit configuration is correct. 16#00300000 The specified Unit is busy. 16#80010000 Execute the instruction again. The specified Unit is not supported for connection. 16#00310000 Check the version of the Unit.
  • Page 900: Nx_Saveparam

    2 Instruction Descriptions NX_SaveParam The NX_SaveParam instruction saves the data that was written to the specified EtherCAT Coupler Unit or NX Unit. Instruction Name FB/FUN Graphic expression ST expression NX_Save Save NX Unit NX_SaveParam_instance(Execute, Parameters NX_SaveParam_instance UnitProxy, TimeOut, Done, Busy, Param Error, ErrorID, ErrorIDEx);...
  • Page 901: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of UnitProxy is structure _sNXUNIT_ID. The meanings of the members are as follows: Name Meaning Description Data type UnitProxy Specified Unit Unit for which to save _sNXUNIT_ID data NodeAdr Node address Node address of the UINT Communications Cou- pler Unit...
  • Page 902: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Notation Example The following notation example saves the data that was written to the ‘NX1’ NX Unit. A variable that is named ‘NX1’ with a data type of _sNXUNIT_ID is assigned to the NX Unit. NX_SaveParam_instance(A, NX1, UINT#0, abc, def, ghi, jkl, mno);...
  • Page 903: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period. The value of Done changes to TRUE when processing is completed.
  • Page 904 2 Instruction Descriptions • Error is TRUE if an error occurred. The meanings of the values of ErrorID and ErrorIDEx are given in the following table. Value of ErrorID Value of ErrorIDEx Meaning • The value of UnitProxy is outside of the valid range. 16#0400 16#00000000 •...
  • Page 905: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Value of ErrorID Value of ErrorIDEx Meaning 16#00120000 The value of UnitProxy is not correct. 16#00130000 Set the variable that indicates the specified EtherCAT Coupler 16#00150000 Unit again. 16#00160000 The specified node address is not correct. 16#00140000 Make sure that the Unit configuration is correct.
  • Page 906: Nx_Readtotalpowerontime

    2 Instruction Descriptions NX_ReadTotalPowerOnTime The NX_ReadTotalPowerOnTime instruction reads the total power ON time from a Communications Coupler Unit or NX Unit. Instruction Name FB/FUN Graphic expression ST expression NX_ReadTotalPowerONTime_instance( Execute, NX_ReadTotalPowerOnTime_instance UnitProxy, NX_ReadTotalPowerOnTime Done, NX_Read Read NX Unit Execute Done TotalPower Total Power ON Busy,...
  • Page 907: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The data type of UnitProxy is structure _sNXUNIT_ID. The meanings of the members are as follows: Name Meaning Description Data type UnitProxy Specified Unit Specified Unit _sNXUNIT_ID Node address of the Communications NodeAdr Node address UINT Coupler Unit IP address of the Communications IPAdr IP address...
  • Page 908: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Data Name Meaning Description type This variable indicates when communications are _EC_MBXSlavTbl[i] Message Communica- possible for each slave. tions Enabled Slave BOOL TRUE: Communications are possible. “i” is the node address. Table FALSE: Communications are not possible. This table indicates the slaves that can perform NX Unit Message message communications.
  • Page 909 2 Instruction Descriptions Value of Value of Meaning ErrorID ErrorIDEx 16#00000401 The specified Unit does not support the instruction. 16#00001001 16#00001002 An input parameter, output parameter, or in-out parameter is incorrect. 16#00170000 Confirm that the intended parameter is used for the input parameter, out- 16#00200000 put parameter, or in-out parameter.
  • Page 910 2 Instruction Descriptions Value of Value of Meaning ErrorID ErrorIDEx The status of the specified Unit does not agree with the value of the read source or write destination NX object. Take the following actions if the value of Obj.Index is between 0x6000 and 0x6FFF or between 0x7000 and 0x7FFF.
  • Page 911: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Value of Value of Meaning ErrorID ErrorIDEx 16#80040000 16#81000000 An error occurred in the communications network. 16#82010000 16#2C00 Check the Unit and cable connections. 16#82040000 Make sure that the power supply to the Unit is ON. 16#82050000 16#90000000 The number of instructions that can be simultaneously executed was 16#2C01...
  • Page 912: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions External Variable Data type Comment Variables NX_Unit _sNXUNIT_ID J01_Ch1_In00 BOOL Maintenance mode button Button to read total power ON J01_Ch1_In01 BOOL time Button for completion of Unit J01_Ch1_In02 BOOL replacement J02_Ch1_Out00 BOOL Unit replacement warning lamp Get button status. Maintenance_Mode J01_Ch1_In00 Maintenance mode button...
  • Page 913: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Initial Variable Data type Comment Variables value Maintenance_Mode BOOL FALSE Maintenance mode Run_Mode BOOL FALSE Run mode Reading the total PushButton_Read BOOL FALSE power ON time Completion of Unit PushButton_Changed BOOL FALSE replacement Unit replacement Lamp_Warning_UnitLifeTime BOOL FALSE warning...
  • Page 914: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions 2-862 NY-series Instructions Reference Manual (W560)
  • Page 915: Program Control Instructions

    Program Control Instructions Instruction Name Page PrgStart Enable Program 2-864 PrgStop Disable Program 2-873 PrgStatus Read Program Status 2-893 NY-series Instructions Reference Manual (W560) 2-863...
  • Page 916: Prgstart

    2 Instruction Descriptions PrgStart The PrgStart instruction enables the execution of the specified program. Instruction Name FB/FUN Graphic expression ST expression (@)PrgStart Enable Pro- Out:=PrgStart(PrgName, PrgStart gram isFirstRun); PrgName isFirstRun Variables Name Meaning Description Valid range Unit Default 128 bytes max. (127 single-byte Program alphanumeric...
  • Page 917: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Operation Example When a Program in the Current Task Is Specified An operation example is provided below for when a program is specified that is in the same task as the task that executes the instruction.  Enabling a Program Executed After the PrgStart Instruction •...
  • Page 918: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Operation Example When a Program in a Different Task Is Specified An operation example is provided below for when a program is specified that is in a different task from the task that executes the instruction.  Enabling a Program in a Task with a Lower Execution Priority Than the Current Task •...
  • Page 919: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Enabling a Program in a Task with a Lower Execution Priority from an Event Task • There are three programs in this example. P1 is in an event task (execution priority: 8), and P2 and P3 are in a periodic task (execution priority: 16). •...
  • Page 920: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Enabling a Program in an Event Task with a Lower Execution Priority from a Periodic Task • There are three programs in this example. P1 is in a periodic task (execution priority: 16), and P2 and P3 are in an event task (execution priority: 48). •...
  • Page 921: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Enabling a Program in an Event Task with a Lower Execution Priority from an Event Task • There are three programs in this example. P1 is in an event task (execution priority: 8), and P2 and P3 are in an event task (execution priority: 48). •...
  • Page 922: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The relation between isFirstRun and P_First_Run is shown in the following table. The behavior of P_First_Run depends on whether the specified program is disabled or already enabled. Value of isFirstRun Status of the program Value of P_First_Run TRUE Disabled.
  • Page 923: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Data Name Meaning Description type This flag is TRUE for one task period after execution of the program starts. Otherwise it is FALSE. However, if the value of isFirstRun is changed to First Program Period FALSE and the PrgStart instruction is executed, P_First_Run BOOL...
  • Page 924: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • An error will not occur even if you specify a program that is already in an enabled state and execute this instruction. • If you execute this instruction more than once for the same program, the isFirstRun specification in the instruction instance that was executed first is used.
  • Page 925: Prgstop

    2 Instruction Descriptions PrgStop The PrgStop instruction disables execution of the specified program. Instruction Name FB/FUN Graphic expression ST expression Disable (@)PrgStop PrgStop Out:=PrgStop(PrgName); Program PrgName Variables Name Meaning Description Valid range Unit Default 128 bytes max. (127 single-byte Program alphanumeric PrgName Input...
  • Page 926: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Operation Example When a Program in the Current Task Is Specified An operation example is provided below for when a program is specified that is in the same task as the task that executes the instruction.  Disabling a Program Executed After the PrgStop Instruction •...
  • Page 927: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Operation Example When a Program in a Different Task Is Specified An operation example is provided below for when a program is specified that is in a different task from the task that executes the instruction.  Disabling a Program in a Task with a Lower Execution Priority Than the Current Task •...
  • Page 928: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Disabling a Program in a Task with a Lower Execution Priority from an Event Task • There are three programs in this example. P1 is in an event task (execution priority: 8), and P2 and P3 are in a periodic task (execution priority: 16). •...
  • Page 929: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Disabling a Program in an Event Task with a Lower Execution Priority from a Periodic Task • There are three programs in this example. P1 is in a periodic task (execution priority: 16), and P2 and P3 are in an event task (execution priority: 48). •...
  • Page 930: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Disabling a Program in an Event Task with a Lower Execution Priority from an Event Task • There are three programs in this example. P1 is in an event task (execution priority: 8), and P2 and P3 are in an event task (execution priority: 48). •...
  • Page 931: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information • Use the PrgStart instruction (page 2-864) to enable a specified program from the user program. • Use the PrgStatus instruction (page 2-893) to read the status of a specified program from the user program. Precautions for Correct Use •...
  • Page 932: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming  Example in Which One of Three Programs Is Executed in Each Consecutive Task Period In this example, there are three programs, P1, P2, and P3. One of each of these programs is executed in each consecutive task period and then they are repeated. Instructions are executed in the P_Main program to enable and disable these three programs.
  • Page 933: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Default Comment iStep DINT Number of program to execute Set iStep variable to 0 at start of operation. P_First_RunMode MOVE iStep Increment iStep variable. InOut iStep iStep Execute PrgStop and PrgStart instructions. @PrgStop iStep 'P3' PrgName @PrgStart...
  • Page 934: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Default Comment iStep DINT Number of program to execute // Set iStep variable to 0 at start of operation. IF P_First_RunMode THEN iStep:=0; END_IF; // Execute PrgStop and PrgStart instructions. iStep:=iStep+1; // PrgStop???PrgStart???? IF iStep = 1 THEN PrgStop('P3');...
  • Page 935: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Example of Executing Only the Specified Program or Programs the Next Time Operation Starts In this example, the program or programs to execute the next time operation starts are specified before the power supply to the Controller is turned OFF. When the power supply is next turned ON, only the specified program or programs are executed.
  • Page 936: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Data Type Definitions A structure called myConfig is defined as shown in the following table. Struc- Variable Data type Offset type Comment ture  myConfig STRUCT Module configuration configName STRING[32] Module configuration name moduleA BOOL Module A execution flag moduleB BOOL Module B execution flag...
  • Page 937: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Default Retain Comment Open FileOpen Instance of FileOpen instruction TopLineGetter FileGets Instance of FileGets instruction LineGetter FileGets Instance of FileGets instruction Close FileClose Instance of FileClose instruction PTInput_TargetConfig- Number of the module configuration USINT Num_Retain to execute next time operation starts CurrentLineNum...
  • Page 938: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Get number of the module configuration to execute next time operation starts. P_First_RunMode PTInput_TargetConfigNum_Retain TargetLineNum USINT#1 Calculate number of rows from contents of row 1 of configuration file. GetConfigNumDone ConfigNum LineMax USINT#1 Detect error when number of rows in configuration file does not match number of the module configuration to execute next time operation starts.
  • Page 939: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Manage processing flag and error flags. Open.Busy Busy TopLineGetter.Busy LineGetter.Busy Close.Busy Open.Error Error TopLineGetter.Error LineGetter.Error isOverLine SubDeliNG TopLineGetter.Error Close.Done Error_exceptOpen LineGetter.Error isOverLine SubDeliNG Error_exceptOpen NY-series Instructions Reference Manual (W560) 2-887...
  • Page 940: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Open configuration file. P_First_RunMode Open.Done Open.Error opening opening Open opening Busy TopLineGetter.Done FileOpen Execute Done 'Config.txt' FileName Busy _RDWR_CREATE Mode Error ErrorID myFileID FileID TopLineGetting TopLineGetter.Error TopLineGetting Read row 1 of configuration file. TopLineGetter TopLineGetting Busy FileGets STRING_TO_USINT Execute Done...
  • Page 941: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions LineGetter.Done SubDelimiter SelectDone CurrentLineNum LineGetter.Out TargetLineNum OutStruct CurrentConfig CurrentConfig _COMMA Delimiter SelectDone SubDeliNG SelectDone InOut CurrentLineNum CurrentLineNum Close configuration file. Close Busy SelectDone FileClose Execute Done myFileID FileID Busy Error Error_exceptOpen ErrorID Execute PrgStart instruction. SelectDone CurrentConfig.moduleA PrgStart 'Program1' PrgName...
  • Page 942: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Default Retain Comment Open FileOpen Instance of FileOpen instruction TopLineGetter FileGets Instance of FileGets instruction LineGetter FileGets Instance of FileGets instruction Close FileClose Instance of FileClose instruction PTInput_TargetConfig- Number of the module configuration USINT Num_Retain to execute next time operation starts CurrentLineNum...
  • Page 943: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Variable Data type Default Retain Comment RS_5 Instance of RS instruction Expansion done flag from module SubDeliDone BOOL FALSE configuration to CurrentConfig. R_SelectDone R_TRIG Instance of R_TRIG instruction // Get number of the module configuration to execute next time operation starts. IF P_First_RunMode THEN TargetLineNum := PTInput_TargetConfigNum_Retain + USINT#1;...
  • Page 944: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions // Close configuration file. Close(Execute := ((SelectDone OR Error_exceptOpen) & NOT(Busy)), FileID := myFil- eID); // Execute PrgStart instruction. R_SelectDone(Clk:=SelectDone); //moduleA PrgStart(EN := (R_SelectDone.Q & CurrentConfig.moduleA), PrgName :='Program1', isFirstRun:=TRUE); //moduleB PrgStart(EN := (R_SelectDone.Q & CurrentConfig.moduleB), PrgName :='Program2', isFirstRun:=TRUE);...
  • Page 945: Prgstatus

    2 Instruction Descriptions PrgStatus The PrgStatus instruction reads the status of the specified program. Instruction Name FB/FUN Graphic expression ST expression Read Program (@)PrgStatus PrgStatus Out:=PrgStatus(PrgName); Status PrgName Variables Defaul Name Meaning Description Valid range Unit 128 bytes max. (127 single-byte Program alphanumeric PrgName...
  • Page 946: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Program status Description • The Initial Status for the relevant program is set to Run on the Enabled the next time the timing for execu- Sysmac Studio. tion occurs • The PrgStart instruction was executed for the program. •...
  • Page 947: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions  Reading the Status of the Program That Includes the PrgStatus Instruction • The PrgStop instruction with P1 specified is executed in P1 of task period 1. • The PrgStatus instruction with P1 specified is then executed in P1 of task period 1. •...
  • Page 948: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming In this example, there are three programs, P1, P2, and P3. Operations on a touch panel are used to change the program to execute. Touch Panel Specifications This example assumes that a touch panel is connected to the Controller. The touch panel has the following lamps.
  • Page 949: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Global Variables Variable Data type Initial value Comment PTIn_Type Execution program change button input PTOut_P1Status BOOL FALSE P1 executing lamp output PTOut_P2Status BOOL FALSE P2 executing lamp output PTOut_P3Status BOOL FALSE P3 executing lamp output External Variable Data type Comment Variables...
  • Page 950: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions External Variable Data type Comment Variables Execution program change PTIn_Type button input PTOut_P1Status BOOL P1 executing lamp output PTOut_P2Status BOOL P2 executing lamp output PTOut_P3Status BOOL P3 executing lamp output // Change program to execute. IF PTIn_Type = 1 THEN PrgStop('P3');...
  • Page 951: Ethercat Communications Instructions

    EtherCAT Communications Instructions Instruction Name Page EC_CoESDOWrite Write EtherCAT CoE SDO 2-900 EC_CoESDORead Read EtherCAT CoE SDO 2-903 EC_StartMon Start EtherCAT Packet Monitor 2-908 EC_StopMon Stop EtherCAT Packet Monitor 2-914 EC_SaveMon Save EtherCAT Packets 2-916 EC_CopyMon Transfer EtherCAT Packets 2-918 EC_DisconnectSlave Disconnect EtherCAT Slave 2-920...
  • Page 952: Ec_Coesdowrite

    2 Instruction Descriptions EC_CoESDOWrite The EC_CoESDOWrite instruction writes a value to a CoE* object of a specified slave on an EtherCAT network. Instruction Name Graphic expression ST expression EC_CoES- Write EtherCAT EC_CoESDOWrite_instance(Execute, EC_CoESDOWrite_instance DOWrite CoE SDO NodeAdr, SdoObj, TimeOut, WriteDat, EC_CoESDOWrite WriteSize, Done, Busy, Error, ErrorID, Execute...
  • Page 953 2 Instruction Descriptions Function The EC_CoESDOWrite instruction writes data to the CoE object of the node specified with slave node address NodeAdr. The content of WriteDat is written to the object. The number of bytes of data to write is specified with WriteSize. The SDO parameter is specified with SdoObj. The data type of SdoObj is structure _sSDO_ACCESS.
  • Page 954: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Always use a variable for the input parameter to pass to WriteDat. A building error will occur if a con- stant is passed. • Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period.
  • Page 955: Ec_Coesdoread

    2 Instruction Descriptions EC_CoESDORead The EC_CoESDORead instruction reads a value from a CoE* object of a specified slave on an Ether- CAT network. Instruction Name Graphic expression ST expression EC_CoES- Read Ether- EC_CoESDORead_instance(Execute, EC_CoESDORead_instance DORead CAT CoE SDO NodeAdr, SdoObj, TimeOut, ReadDat, EC_CoESDORead Done, Busy, Error, ErrorID, AbortCode, Execute...
  • Page 956 2 Instruction Descriptions Function The EC_CoESDORead instruction reads data from the CoE object of the node specified with slave node address NodeAdr. The read data is stored in ReadDat. Then size of data that was stored is stored in ReadSize. The value of ReadSize is valid only when the data was stored successfully. The SDO parameter is specified with SdoObj.
  • Page 957 IOL_WriteObj. Sample Programming This sample uses an EtherCAT SDO message to read the software version of an OMRON 1S-series Servo Drive. The node address of the slave is 1. The object index for the software version is 16#100A. The subindex is 0. The read value is stored in STRING variable VersionInfo.
  • Page 958 2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables Trigger BOOL FALSE Execution condition (Index:=0, Subindex:=0, SdoObject _sSDO_ACCESS SDO parameter IsCompleteAccess:=FALSE) VersionInfo STRING[256] Read data EC_CoESDORe- EC_CoESDORead ad_instance External Variable Data type Constant Comment Variables ARRAY[1..512] OF Message Communications Enabled Slave _EC_MBXSlavTbl Table BOOL...
  • Page 959 2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables Trigger BOOL FALSE Execution condition (Index:=0, Subindex:=0, SdoObject _sSDO_ACCESS SDO parameter IsCompleteAccess:=FALSE) DoSdoRead BOOL FALSE Processing VersionInfo STRING[256] Read data NormalEnd UINT Normal end ErrorEnd UINT Error end EC_CoESDORe- EC_CoESDORead ad_instance External...
  • Page 960: Ec_Startmon

    2 Instruction Descriptions EC_StartMon The EC_StartMon instruction starts execution of packet monitoring for EtherCAT communications. Instruction Name Graphic expression ST expression EC_StartMon Start EtherCAT EC_SatrtMon_instance(Execute, Done, EC_StartMon_instance Packet Monitor Busy, Error, ErrorID); EC_StartMon Execute Done Busy Error ErrorID Variables Only common variables are used. Function The EC_StartMon instruction starts execution of packet monitoring for EtherCAT communications.
  • Page 961: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period. The value of Done changes to TRUE when processing is completed.
  • Page 962: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables OperatingEnd BOOL FALSE Processing completed Operating BOOL FALSE Execution condition RS_instance EC_StopMon_instance EC_StopMon EC_SaveMon_instance EC_SaveMon EC_CopyMon_instance EC_CopyMon EC_StartMon_instance EC_StartMon External Variable Data type Constant Comment Variables _EC_ErrSta WORD Built-in EtherCAT Error _EC_PktMonStop BOOL Packet Monitoring Stopped...
  • Page 963: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Instruction execution EC_StopMon_instance EC_SaveMon_instance Operating _Card1Ready EC_StopMon EC_SaveMon Execute Done Execute Done Busy Busy Error Error ErrorID ErrorID EC_CopyMon_instance EC_StartMon_instance EC_CopyMon EC_StartMon Execute Done Execute Done ‘PacketFile’ FileName Busy Busy Error Error ErrorID ErrorID Processing after normal end Inline ST Operating 1 // Processing after normal end...
  • Page 964: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Variable Data type Initial value Comment Variables Controller error in the EtherCAT Master EC_Err BOOL FALSE Function Module. EC_Err_Trigger BOOL FALSE Detect when EC_Err changes to TRUE. DoEC_PktSave BOOL FALSE Processing Stage Stage change R_TRIG_instance R_TRIG EC_StopMon_instance EC_StopMon EC_SaveMon_instance...
  • Page 965: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions // Copy EtherCAT packet data file to the SD Memory Card. EC_CopyMon_instance( Execute :=TRUE, FileName :='PacketFile'); IF (EC_CopyMon_instance.Done=TRUE) THEN Stage:=INT#4; // Normal end ELSIF (EC_CopyMon_instance.Error=TRUE) THEN Stage:=INT#30; // Error end END_IF; // Restart EtherCAT packet monitor. EC_StartMon_instance( Execute :=TRUE);...
  • Page 966: Ec_Stopmon

    2 Instruction Descriptions EC_StopMon The EC_StopMon instruction stops execution of packet monitoring for EtherCAT communications. Instruction Name Graphic expression ST expression EC_StopMon Stop EtherCAT EC_StopMon_instance(Execute, EC_StopMon_instance Packet Monitor Done, Busy, Error, ErrorID); EC_StopMon Execute Done Busy Error ErrorID Variables Only common variables are used. Function The EC_StopMon instruction stops execution of packet monitoring for EtherCAT communications.
  • Page 967: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • This instruction can be used only for the NJ/NX-series and NY-series Controller EtherCAT ports. • You can execute a maximum of 32 of the following instructions at the same time: EC_CoESDOWrite, EC_CoESDORead, EC_StartMon, EC_StopMon, EC_SaveMon, EC_CopyMon, EC_DisconnectSlave, EC_ConnectSlave, EC_ChangeEnableSetting, IOL_ReadObj, and IOL_Write- Obj.
  • Page 968: Ec_Savemon

    2 Instruction Descriptions EC_SaveMon The EC_SaveMon instruction saves EtherCAT communications packet data to an internal file in the main memory of the CPU Unit. Instruction Name Graphic expression ST expression EC_SaveMon Save EtherCAT EC_SaveMon_instance(Execute, EC_SaveMon_instance Packets Done, Busy, Error, ErrorID); EC_SaveMon Execute Done...
  • Page 969: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions • This instruction can be used only for the NJ/NX-series and NY-series Controller EtherCAT ports. • You cannot execute this instruction while packet monitoring is in progress. Execute the EC_StopMon instruction in advance to stop packet monitoring. •...
  • Page 970: Ec_Copymon

    2 Instruction Descriptions EC_CopyMon The EC_CopyMon instruction transfers packet data in an internal file in the main memory of the CPU Unit to a SD Memory Card. Instruction Name Graphic expression ST expression EC_CopyMon Transfer EC_CopyMon_instance(Execute, EC_CopyMon_instance EtherCAT FileName, Done, Busy, Error, ErrorID); EC_CopyMon Packets Execute...
  • Page 971: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period. The value of Done changes to TRUE when processing is completed.
  • Page 972: Ec_Disconnectslave

    2 Instruction Descriptions EC_DisconnectSlave The EC_DisconnectSlave instruction disconnects the specified slave from the network. Instruction Name Graphic expression ST expression EC_Discon- Disconnect EC_DisconnectSlave_instance(Execute, EC_DisconnectSlave_instance nectSlave EtherCAT NodeAdr, Done, Busy, Error, ErrorID); EC_DisconnectSlave Slave Execute Done NodeAdr Busy Error ErrorID Variables Name Meaning Description...
  • Page 973: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Additional Information Refer to the NJ/NX-series CPU Unit Built-in EtherCAT Port User’s Manual (Cat. No. W505) or NY- series Industrial Panel PC / Industrial Box PC Built-in EtherCAT Port User’s Manual (Cat. No. W562) for details on EtherCAT communications. Precautions for Correct Use •...
  • Page 974: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions You cannot execute the EC_ChangeEnableSetting instruction at the same time as the EC_Disconnect- Slave or EC_ConnectSlave instruction. The sample programming that is provided for the EC_Chan- geEnableSetting instruction on page 2-929 uses the same ExclusiveFlg global variable as in this sample programming as an example of exclusive control of instructions.
  • Page 975: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Determine if execution of the EC_DisconnectSlave instruction is completed. EC_DisconnectSlave_instance.Done Operating1End EC_DisconnectSlave_instance.Error Accept trigger 1. RS_instance1 Trigger1 _EC_EntrySlavTbl[1] Operating1 Operating1End Reset1 Execute EC_DisconnectSlave instruction. EC_DisconnectSlave_instance Operating1 ExclusiveFlg EC_DisconnectSlave Execute Done UINT#1 NodeAdr Busy Error ErrorID Exclusive control of instructions EC_DisconnectSlave_instance.Busy ExclusiveFlg EC_DisconnectSlave_instance.Busy...
  • Page 976: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Accept trigger 2. RS_instance2 Trigger2 _EC_DisconnSlavTbl[1] Operating2 Operating2End Reset1 Execute EC_ConnectSlave instruction. EC_ConnectSlave_instance Operating2 ExclusiveFlg EC_ConnectSlave Execute Done UINT#1 NodeAdr Busy Error ErrorID Exclusive control of instructions EC_ConnectSlave_instance.Busy ExclusiveFlg EC_ConnectSlave_instance.Busy ExclusiveFlg Processing after normal end Inline ST EC_ConnectSlave_instance.Done Operating2 1 // Processing after normal end...
  • Page 977: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Initial Variable Data type Comment Variables value Trigger1 BOOL FALSE Execution condition 1 Value of Trigger1 from previous task LastTrigger1 BOOL FALSE period Operating1Start BOOL FALSE Processing 1 started. Operating1 BOOL FALSE Processing 1 EC_DisconnectSlave instruction execu- DisconnectSet BOOL FALSE...
  • Page 978: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions EC_DisconnectSlave_instance( Execute:=NOT(ExclusiveFlg), NodeAdr:=UINT#1); // Exclusive control of instructions R_TRIG_instance1(EC_DisconnectSlave_instance.Busy, DisconnectSet); F_TRIG_instance1(EC_DisconnectSlave_instance.Busy, DisconnectReset); RS_instance1(DisconnectSet, DisconnectReset, ExclusiveFlg); IF (EC_DisconnectSlave_instance.Done=TRUE) THEN // Processing after normal end Operating1:=FALSE; END_IF; IF (EC_DisconnectSlave_instance.Error=TRUE) THEN // Processing after error end Operating1:=FALSE; END_IF; END_IF; // Detect when Trigger2 changes to TRUE. IF ( (Trigger2=TRUE) AND (LastTrigger2=FALSE) AND (_EC_DisconnSlavTbl[1]=TRUE) ) THEN Operating2Start:=TRUE;...
  • Page 979: Ec_Connectslave

    2 Instruction Descriptions EC_ConnectSlave The EC_ConnectSlave instruction connects the specified slave to the EtherCAT network. Instruction Name Graphic expression ST expression EC_Connect- Connect Ether- EC_ConnectSlave_instance(Execute, EC_ConnectSlave_instance Slave CAT Slave NodeAdr, Done, Busy, Error, ErrorID); EC_ConnectSlave Execute Done NodeAdr Busy Error ErrorID Variables Name...
  • Page 980: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Related System-defined Variables Name Meaning Data type Description _EC_EntrySlavTbl[i] Network Connected BOOL[] This variable shows if slaves are part of (i.e., exist on) Slave Table the network. “i” is the node address. TRUE: Part of the network. FALSE: Not part of the network.
  • Page 981: Ec_Changeenablesetting

    2 Instruction Descriptions EC_ChangeEnableSetting The EC_ChangeEnableSetting instruction enables or disables an EtherCAT slave. Instruction Name Graphic expression ST expression EC_Chan- Enable/Dis- EC_ChangeEnableSetting_in- EC_ChangeEnableSetting_instance geEnableSet- able Ether- stance(Execute, NodeAdr, IsEnable, EC_ChangeEnableSetting ting CAT Slave Done, Busy, Error, ErrorID); Execute Done NodeAdr Busy IsEnable Error...
  • Page 982: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Status before instruction execution Status after instruction execution Value of IsEn- Enabled/ Participating/ able Normal/error end Enabled/disabled Exists disabled not participating TRUE FALSE Enabled Enabled Not participating Error end (not changed) TRUE FALSE TRUE Enabled Disabled Normal end FALSE Disabled TRUE...
  • Page 983: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Precautions for Correct Use • Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period. The value of Done changes to TRUE when processing is completed.
  • Page 984: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Sample Programming  Example of Disconnecting EtherCAT Slaves from the EtherCAT Network Production line 1 in the following system is left running while EtherCAT slaves C, D, and E on produc- tion line 2 are removed. Motion control axes are already set for EtherCAT slaves C, D, and E. There- fore, the EtherCAT slaves are disabled and the axes are changed to unused axes.
  • Page 985: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Exclusive Control of Instructions You can execute only one EC_ChangeEnableSetting instruction at the same time. Also, the EC_Chan- geEnableSetting instruction is executed over more than one task. Confirm the completion of the EC_ChangeEnableSetting instruction before you execute the next EC_ChangeEnableSetting instruc- tion.
  • Page 986: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Initial Vari- Variable Data type Comment value ables Changing axis to unused axis AxisUnuseDone_DevC BOOL FALSE completed for EtherCAT slave C Disabling EtherCAT slave C com- SlaveDisableDone_DevC BOOL FALSE pleted Holding completion of processing DoneHold_DevC BOOL FALSE for EtherCAT slave C Changing axis to unused axis...
  • Page 987: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Accept execution condition trigger. Trigger1 Operating1End Operating1 Operating1 Change axis to unused axis MC_ChangeAxisUse_DevC and disable EtherCAT slave C. MC_ChangeAxisUse Axis Axis Operating1 DoneHold_DevC AxisUnuseDone_DevC MC_Axis000 Execute Done _mcUnusedAxis AxisUse Busy CommandAborted Error ErrorID EC_ChangeEnableSetting_DevC AxisUnuseDone_DevC ExclusiveFlg SlaveDisableDone_DevC EC_ChangeEnableSetting Execute...
  • Page 988: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Exclusive control of instructions EC_ChangeEnableSetting_DevD.Busy ExclusiveFlg EC_ChangeEnableSetting_DevD.Busy ExclusiveFlg SlaveDisableDone_DevD Operating1End DoneHold_DevD DoneHold_DevD Change axis to unused axis MC_ChangeAxisUse_DevE and disable EtherCAT slave E. MC_ChangeAxisUse Axis Axis Operating1 DoneHold_DevD DoneHold_DevE AxisUnuseDone_DevE MC_Axis002 Execute Done _mcUnusedAxis AxisUse Busy CommandAborted Error ErrorID EC_ChangeEnableSetting_DevE...
  • Page 989: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Initial Vari- Variable Data type Comment value ables Operating1End BOOL FALSE Processing completed Trigger1 BOOL FALSE Execution condition Operating1 BOOL FALSE Processing Operating1Set BOOL FALSE Processing started Light1On BOOL FALSE Lighting removal OK lamp Holding completion of pro- DoneHold_DevC BOOL FALSE...
  • Page 990: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions // Accept execution condition trigger. R_TRIG_instance1(Trigger1, Operating1Set); RS_instance1( :=Operating1Set, Reset1:=Operating1End, =>Operating1); // Change axis to unused axis for EtherCAT slave C. MC_ChangeAxisUse_DevC( Axis :=MC_Axis000, Execute:=(Operating1 & NOT(DoneHold_DevC)), AxisUse:=_mcUnusedAxis); // Disable EtherCAT slave C. EC_ChangeEnableSetting_DevC( Execute :=(Operating1 & MC_ChangeAxisUse_DevC.Done & NOT(ExclusiveFlg)), NodeAdr :=UINT#1, IsEnable:=FALSE);...
  • Page 991: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Execute :=(Operating1 & DoneHold_DevD & MC_ChangeAxisUse_DevE.Done & NOT(ExclusiveFlg)), NodeAdr :=UINT#3, IsEnable:=FALSE); // Exclusive control of instructions R_TRIG_DevE(EC_ChangeEnableSetting_DevE.Busy, ExclusiveFlgSet); F_TRIG_DevE(EC_ChangeEnableSetting_DevE.Busy, ExclusiveFlgReset); RS_ExFlg_DevE( :=ExclusiveFlgSet, Reset1:=ExclusiveFlgReset, =>ExclusiveFlg); RS_DevE( :=EC_ChangeEnableSetting_DevE.Done, Reset1:=Operating1End, =>DoneHold_DevE); // Confirm changing axis to unused axis and disabling EtherCAT slave E. Operating1End:=(Operating1 &...
  • Page 992: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions The Controller enables EtherCAT slaves F and G. Also, the axes for those slaves are changed to used axes. When enabling and changing the axes to used axes is completed for the two EtherCAT slaves, the Controller lights an installation completed lamp. Instruction to Change Axes to Used Axes The MC_ChangeAxisUse instruction is used to change axes to used axes.
  • Page 993: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Initial Vari- Variable Data type Comment value ables Processing com- Operating2End BOOL FALSE pleted Trigger2 BOOL FALSE Execution condition Operating2 BOOL FALSE Processing Changing axis to used axis com- AxisUseDone_DevF BOOL FALSE pleted for EtherCAT slave F Enabling EtherCAT SlaveEnableDone_DevF BOOL...
  • Page 994: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Accept execution condition trigger. Trigger2 Operating2End Operating2 Operating2 Enable EtherCAT slave F. EC_ChangeEnableSetting_DevF ExclusiveFlg DoneHold_DevF Operating2 SlaveEnableDone_DevF EC_ChangeEnableSetting Execute Done UINT#4 NodeAdr Busy TRUE IsEnable Error ErrorID Exclusive control of instructions. Start enabling EtherCAT slave F and confirm completion. EC_ChangeEnableSetting_DevF.Busy ExclusiveFlg EC_ChangeEnableSetting_DevF.Busy...
  • Page 995: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Exclusive control of instructions. Start enabling EtherCAT slave G and confirm completion. EC_ChangeEnableSetting_DevG.Busy ExclusiveFlg EC_ChangeEnableSetting_DevG.Busy ExclusiveFlg Change axis to used axis for EtherCAT slave G. MC_ChangeAxisUse_DevG MC_ChangeAxisUse Axis Axis DoneHold_DevG Operating2 SlaveEnableDone_DevG AxisUseDone_DevG MC_Axis004 Execute Done _mcUsedAxis AxisUse Busy CommandAborted...
  • Page 996: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Internal Initial Vari- Variable Data type Comment value ables EC_ChangeEnableSetting_DevF EC_ChangeEnableSetting R_TRIG_DevF R_TRIG F_TRIG_DevF F_TRIG RS_ExFlg_DevF RS_DevF MC_ChangeAxisUse_DevG MC_ChangeAxisUse EC_ChangeEnableSetting_DevG EC_ChangeEnableSetting R_TRIG_DevG R_TRIG F_TRIG_DevG F_TRIG RS_ExFlg_DevG RS_DevG External Variable Data type Constant Comment Variables Axis variable for EtherCAT slave MC_Axis003 _sAXIS_REF Axis variable for EtherCAT slave...
  • Page 997: Ny-Series Instructions Reference Manual (W560

    2 Instruction Descriptions Execute :=(Operating2 & DoneHold_DevF & NOT(ExclusiveFlg) & NOT(DoneHold_DevG)), NodeAdr :=UINT#5, IsEnable:=TRUE); // Exclusive control of instructions. Start enabling EtherCAT slave F and confirm // completion. R_TRIG_DevG(EC_ChangeEnableSetting_DevG.Busy, ExclusiveFlgSet); F_TRIG_DevG(EC_ChangeEnableSetting_DevG.Busy, ExclusiveFlgReset); RS_ExFlg_DevG( :=ExclusiveFlgSet, Reset1:=ExclusiveFlgReset, =>ExclusiveFlg); // Change axis to used axis for EtherCAT slave G. MC_ChangeAxisUse_DevG( Axis :=MC_Axis004,...
  • Page 998: Nx_Writeobj

    2 Instruction Descriptions NX_WriteObj The NX_WriteObj instruction writes data to an NX object in an EtherCAT Coupler Unit or NX Unit. Instruction Name FB/FUN Graphic expression ST expression NX_WriteObj Write NX Unit NX_WriteObj_instance(Execute, Object UnitProxy, Obj, TimeOut, WriteDat, NX_WriteObj_instance Done, Busy, Error, ErrorID, NX_WriteObj ErrorIDEx);...
  • Page 999 2 Instruction Descriptions The data type of UnitProxy is structure _sNXUNIT_ID. The meanings of the members are as follows: Name Meaning Content Data type UnitProxy Specified Unit Specified Unit _sNXUNIT_ID NodeAdr Node address Node address of the UINT Communications Cou- pler Unit IPAdr IP address...
  • Page 1000 2 Instruction Descriptions Use the NX_WriteObj instruction to write data to the Unit. Use the NX_SaveParam instruction (page 2-848) to save the data that you wrote.  Execution Procedure 3 Use the following procedure to write data with the following attributes. •...

Table of Contents